Skip to content

Commit

Permalink
solidity compiler and contract metadocs integration
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
zelig committed May 5, 2015
1 parent 3fef601 commit a73c623
Show file tree
Hide file tree
Showing 21 changed files with 1,393 additions and 502 deletions.
347 changes: 286 additions & 61 deletions cmd/geth/admin.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions cmd/geth/info_test.json
Original file line number Diff line number Diff line change
@@ -0,0 +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."}}}}}
29 changes: 18 additions & 11 deletions cmd/geth/js.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package main
import (
"bufio"
"fmt"
"math/big"
"os"
"path"
"strings"
Expand Down Expand Up @@ -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 {
Expand All @@ -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()
Expand Down Expand Up @@ -142,13 +149,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
Expand Down
Loading

0 comments on commit a73c623

Please sign in to comment.