diff options
author | obscuren <geffobscura@gmail.com> | 2015-01-29 20:10:34 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-01-29 20:10:34 +0800 |
commit | 84adf77bf3492351de82f0ec820a1d280e85a5cd (patch) | |
tree | e841925b72cbef95cde5d6c8763d145812486336 /rpc | |
parent | f75dcc7f4c60800055f6d15c5e6660ed76465eb6 (diff) | |
download | dexon-84adf77bf3492351de82f0ec820a1d280e85a5cd.tar.gz dexon-84adf77bf3492351de82f0ec820a1d280e85a5cd.tar.zst dexon-84adf77bf3492351de82f0ec820a1d280e85a5cd.zip |
Added RPC "Call" for JS calls to contracts
Diffstat (limited to 'rpc')
-rw-r--r-- | rpc/args.go | 11 | ||||
-rw-r--r-- | rpc/packages.go | 19 |
2 files changed, 23 insertions, 7 deletions
diff --git a/rpc/args.go b/rpc/args.go index 0c3087151..ff4974792 100644 --- a/rpc/args.go +++ b/rpc/args.go @@ -28,11 +28,12 @@ func (obj *GetBlockArgs) requirements() error { } type NewTxArgs struct { - Recipient string `json:"recipient"` - Value string `json:"value"` - Gas string `json:"gas"` - GasPrice string `json:"gasprice"` - Data string `json:"data"` + From string `json:"from"` + To string `json:"to"` + Value string `json:"value"` + Gas string `json:"gas"` + GasPrice string `json:"gasPrice"` + Data string `json:"data"` } // type TxResponse struct { diff --git a/rpc/packages.go b/rpc/packages.go index 3eaa71a7f..4302f6018 100644 --- a/rpc/packages.go +++ b/rpc/packages.go @@ -67,8 +67,17 @@ func (p *EthereumApi) Transact(args *NewTxArgs, reply *interface{}) error { if err != nil { return err } - result, _ := p.xeth.Transact( /* TODO specify account */ args.Recipient, args.Value, args.Gas, args.GasPrice, args.Data) - fmt.Println("result:", result) + result, _ := p.xeth.Transact( /* TODO specify account */ args.To, args.Value, args.Gas, args.GasPrice, args.Data) + *reply = result + return nil +} + +func (p *EthereumApi) Call(args *NewTxArgs, reply *interface{}) error { + result, err := p.xeth.Call( /* TODO specify account */ args.To, args.Value, args.Gas, args.GasPrice, args.Data) + if err != nil { + return err + } + *reply = result return nil } @@ -206,6 +215,12 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error return err } return p.Transact(args, reply) + case "eth_call": + args, err := req.ToNewTxArgs() + if err != nil { + return err + } + return p.Call(args, reply) case "web3_sha3": args, err := req.ToSha3Args() if err != nil { |