Skip to content

Commit 45c070f

Browse files
committed
Merge pull request #833 from ethersphere/frontier/solidity
solidity compiler and contract metadocs integration
2 parents 637b241 + 009b221 commit 45c070f

21 files changed

+1449
-503
lines changed

cmd/geth/admin.go

Lines changed: 285 additions & 61 deletions
Large diffs are not rendered by default.

cmd/geth/info_test.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"code":"605280600c6000396000f3006000357c010000000000000000000000000000000000000000000000000000000090048063c6888fa114602e57005b60376004356041565b8060005260206000f35b6000600782029050604d565b91905056","info":{"abiDefinition":[{"constant":false,"inputs":[{"name":"a","type":"uint256"}],"name":"multiply","outputs":[{"name":"d","type":"uint256"}],"type":"function"}],"compilerVersion":"0.9.13","developerDoc":{"methods":{}},"language":"Solidity","languageVersion":"0","source":"contract test {\n /// @notice Will multiply `a` by 7.\n function multiply(uint a) returns(uint d) {\n return a * 7;\n }\n}\n","userDoc":{"methods":{"multiply(uint256)":{"notice":"Will multiply `a` by 7."}}}}}

cmd/geth/js.go

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ package main
2020
import (
2121
"bufio"
2222
"fmt"
23+
"math/big"
2324
"os"
2425
"path"
2526
"strings"
@@ -62,19 +63,26 @@ type jsre struct {
6263
re *re.JSRE
6364
ethereum *eth.Ethereum
6465
xeth *xeth.XEth
66+
wait chan *big.Int
6567
ps1 string
6668
atexit func()
6769
corsDomain string
6870
prompter
6971
}
7072

71-
func newJSRE(ethereum *eth.Ethereum, libPath string, interactive bool, corsDomain string) *jsre {
73+
func newJSRE(ethereum *eth.Ethereum, libPath, solcPath, corsDomain string, interactive bool, f xeth.Frontend) *jsre {
7274
js := &jsre{ethereum: ethereum, ps1: "> "}
7375
// set default cors domain used by startRpc from CLI flag
7476
js.corsDomain = corsDomain
75-
js.xeth = xeth.New(ethereum, js)
77+
if f == nil {
78+
f = js
79+
}
80+
js.xeth = xeth.New(ethereum, f)
81+
js.wait = js.xeth.UpdateState()
82+
// update state in separare forever blocks
83+
js.xeth.SetSolc(solcPath)
7684
js.re = re.New(libPath)
77-
js.apiBindings()
85+
js.apiBindings(f)
7886
js.adminBindings()
7987

8088
if !liner.TerminalSupported() || !interactive {
@@ -87,18 +95,17 @@ func newJSRE(ethereum *eth.Ethereum, libPath string, interactive bool, corsDomai
8795
js.atexit = func() {
8896
js.withHistory(func(hist *os.File) { hist.Truncate(0); lr.WriteHistory(hist) })
8997
lr.Close()
98+
close(js.wait)
9099
}
91100
}
92101
return js
93102
}
94103

95-
func (js *jsre) apiBindings() {
96-
97-
ethApi := rpc.NewEthereumApi(js.xeth)
98-
//js.re.Bind("jeth", rpc.NewJeth(ethApi, js.re.ToVal))
99-
104+
func (js *jsre) apiBindings(f xeth.Frontend) {
105+
xe := xeth.New(js.ethereum, f)
106+
ethApi := rpc.NewEthereumApi(xe)
100107
jeth := rpc.NewJeth(ethApi, js.re.ToVal, js.re)
101-
//js.re.Bind("jeth", jeth)
108+
102109
js.re.Set("jeth", struct{}{})
103110
t, _ := js.re.Get("jeth")
104111
jethObj := t.Object()
@@ -143,13 +150,13 @@ var net = web3.net;
143150
js.re.Eval(globalRegistrar + "registrar = new GlobalRegistrar(\"" + globalRegistrarAddr + "\");")
144151
}
145152

146-
var ds, _ = docserver.New(utils.JSpathFlag.String())
153+
var ds, _ = docserver.New("/")
147154

148155
func (self *jsre) ConfirmTransaction(tx string) bool {
149156
if self.ethereum.NatSpec {
150157
notice := natspec.GetNotice(self.xeth, tx, ds)
151158
fmt.Println(notice)
152-
answer, _ := self.Prompt("Confirm Transaction\n[y/n] ")
159+
answer, _ := self.Prompt("Confirm Transaction [y/n]")
153160
return strings.HasPrefix(strings.Trim(answer, " "), "y")
154161
} else {
155162
return true

0 commit comments

Comments
 (0)