diff options
author | zelig <viktor.tron@gmail.com> | 2015-04-23 06:11:11 +0800 |
---|---|---|
committer | zelig <viktor.tron@gmail.com> | 2015-05-07 18:58:21 +0800 |
commit | 009b2216921b15962f2612687c1460a8342d49d6 (patch) | |
tree | 4adbbaccdb83a3ea55034f1681d01132452ff48d /cmd/geth/js.go | |
parent | 97c37356fdcfac8b704c3d75b33e322a737c4e55 (diff) | |
download | dexon-009b2216921b15962f2612687c1460a8342d49d6.tar.gz dexon-009b2216921b15962f2612687c1460a8342d49d6.tar.zst dexon-009b2216921b15962f2612687c1460a8342d49d6.zip |
solidity compiler and contract metadocs integration
* common/compiler: solidity compiler + tests
* rpc: eth_compilers, eth_compileSolidity + tests
* fix natspec test using keystore API, notice exp dynamically changes addr, cleanup
* resolver implements registrars and needs to create reg contract (temp)
* xeth: solidity compiler. expose getter Solc() and paths setter SetSolc(solcPath)
* ethereumApi: implement compiler related RPC calls using XEth - json struct tests
* admin: make use of XEth.SetSolc to allow runtime setting of compiler paths
* cli: command line flags solc to set custom solc bin path
* js admin api with new features debug and contractInfo modules
* wiki is the doc https://github.com/ethereum/go-ethereum/wiki/Contracts-and-Transactions
Diffstat (limited to 'cmd/geth/js.go')
-rw-r--r-- | cmd/geth/js.go | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/cmd/geth/js.go b/cmd/geth/js.go index d8c26eb2f..c9839dabb 100644 --- a/cmd/geth/js.go +++ b/cmd/geth/js.go @@ -20,6 +20,7 @@ package main import ( "bufio" "fmt" + "math/big" "os" "path" "strings" @@ -62,19 +63,26 @@ type jsre struct { re *re.JSRE ethereum *eth.Ethereum xeth *xeth.XEth + wait chan *big.Int ps1 string atexit func() corsDomain string prompter } -func newJSRE(ethereum *eth.Ethereum, libPath string, interactive bool, corsDomain string) *jsre { +func newJSRE(ethereum *eth.Ethereum, libPath, solcPath, corsDomain string, interactive bool, f xeth.Frontend) *jsre { js := &jsre{ethereum: ethereum, ps1: "> "} // set default cors domain used by startRpc from CLI flag js.corsDomain = corsDomain - js.xeth = xeth.New(ethereum, js) + if f == nil { + f = js + } + js.xeth = xeth.New(ethereum, f) + js.wait = js.xeth.UpdateState() + // update state in separare forever blocks + js.xeth.SetSolc(solcPath) js.re = re.New(libPath) - js.apiBindings() + js.apiBindings(f) js.adminBindings() if !liner.TerminalSupported() || !interactive { @@ -87,18 +95,17 @@ func newJSRE(ethereum *eth.Ethereum, libPath string, interactive bool, corsDomai js.atexit = func() { js.withHistory(func(hist *os.File) { hist.Truncate(0); lr.WriteHistory(hist) }) lr.Close() + close(js.wait) } } return js } -func (js *jsre) apiBindings() { - - ethApi := rpc.NewEthereumApi(js.xeth) - //js.re.Bind("jeth", rpc.NewJeth(ethApi, js.re.ToVal)) - +func (js *jsre) apiBindings(f xeth.Frontend) { + xe := xeth.New(js.ethereum, f) + ethApi := rpc.NewEthereumApi(xe) jeth := rpc.NewJeth(ethApi, js.re.ToVal, js.re) - //js.re.Bind("jeth", jeth) + js.re.Set("jeth", struct{}{}) t, _ := js.re.Get("jeth") jethObj := t.Object() @@ -143,13 +150,13 @@ var net = web3.net; js.re.Eval(globalRegistrar + "registrar = new GlobalRegistrar(\"" + globalRegistrarAddr + "\");") } -var ds, _ = docserver.New(utils.JSpathFlag.String()) +var ds, _ = docserver.New("/") func (self *jsre) ConfirmTransaction(tx string) bool { if self.ethereum.NatSpec { notice := natspec.GetNotice(self.xeth, tx, ds) fmt.Println(notice) - answer, _ := self.Prompt("Confirm Transaction\n[y/n] ") + answer, _ := self.Prompt("Confirm Transaction [y/n]") return strings.HasPrefix(strings.Trim(answer, " "), "y") } else { return true |