aboutsummaryrefslogtreecommitdiffstats
path: root/rpc
diff options
context:
space:
mode:
authorTaylor Gerring <taylor.gerring@gmail.com>2015-03-04 22:22:59 +0800
committerTaylor Gerring <taylor.gerring@gmail.com>2015-03-04 22:22:59 +0800
commitc3deafabda6e97c0077609ab375be69936d512d4 (patch)
tree30e18fae7deedf50a6cbabeccf7c5020282b4968 /rpc
parentc92e48ce3f9de2196a713b24d5c27d6c664826d9 (diff)
downloadgo-tangerine-c3deafabda6e97c0077609ab375be69936d512d4.tar
go-tangerine-c3deafabda6e97c0077609ab375be69936d512d4.tar.gz
go-tangerine-c3deafabda6e97c0077609ab375be69936d512d4.tar.bz2
go-tangerine-c3deafabda6e97c0077609ab375be69936d512d4.tar.lz
go-tangerine-c3deafabda6e97c0077609ab375be69936d512d4.tar.xz
go-tangerine-c3deafabda6e97c0077609ab375be69936d512d4.tar.zst
go-tangerine-c3deafabda6e97c0077609ab375be69936d512d4.zip
Update NewTXArgs to accept hex
Diffstat (limited to 'rpc')
-rw-r--r--rpc/api.go15
-rw-r--r--rpc/args.go34
2 files changed, 28 insertions, 21 deletions
diff --git a/rpc/api.go b/rpc/api.go
index f023709ca..406960fce 100644
--- a/rpc/api.go
+++ b/rpc/api.go
@@ -252,12 +252,12 @@ func (p *EthereumApi) GetBlock(args *GetBlockArgs, reply *interface{}) error {
}
func (p *EthereumApi) Transact(args *NewTxArgs, reply *interface{}) error {
- if len(args.Gas) == 0 {
- args.Gas = defaultGas.String()
+ if args.Gas == ethutil.Big0 {
+ args.Gas = defaultGas
}
- if len(args.GasPrice) == 0 {
- args.GasPrice = defaultGasPrice.String()
+ if args.GasPrice == ethutil.Big0 {
+ args.GasPrice = defaultGasPrice
}
// TODO if no_private_key then
@@ -281,7 +281,10 @@ func (p *EthereumApi) Transact(args *NewTxArgs, reply *interface{}) error {
p.register[ags.From] = append(p.register[args.From], args)
}
*/
- result, _ := p.xeth().Transact( /* TODO specify account */ args.To, args.Value, args.Gas, args.GasPrice, args.Data)
+ result, err := p.xeth().Transact( /* TODO specify account */ args.To, args.Value.String(), args.Gas.String(), args.GasPrice.String(), args.Data)
+ if err != nil {
+ return err
+ }
*reply = result
//}
@@ -289,7 +292,7 @@ func (p *EthereumApi) Transact(args *NewTxArgs, reply *interface{}) error {
}
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)
+ result, err := p.xeth().Call( /* TODO specify account */ args.To, args.Value.String(), args.Gas.String(), args.GasPrice.String(), args.Data)
if err != nil {
return err
}
diff --git a/rpc/args.go b/rpc/args.go
index e839da8bf..5686cbdec 100644
--- a/rpc/args.go
+++ b/rpc/args.go
@@ -1,8 +1,12 @@
package rpc
-import "encoding/json"
+import (
+ "encoding/json"
+ "math/big"
-import "github.com/ethereum/go-ethereum/core"
+ "github.com/ethereum/go-ethereum/core"
+ "github.com/ethereum/go-ethereum/ethutil"
+)
type GetBlockArgs struct {
BlockNumber int32
@@ -23,12 +27,12 @@ func (obj *GetBlockArgs) UnmarshalJSON(b []byte) (err error) {
}
type NewTxArgs struct {
- From string `json:"from"`
- To string `json:"to"`
- 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 *big.Int `json:"value"`
+ Gas *big.Int `json:"gas"`
+ GasPrice *big.Int `json:"gasPrice"`
+ Data string `json:"data"`
}
func (obj *NewTxArgs) UnmarshalJSON(b []byte) (err error) {
@@ -40,18 +44,18 @@ func (obj *NewTxArgs) UnmarshalJSON(b []byte) (err error) {
Gas string
GasPrice string
Data string
- Code string
+ // Code string
}
if err = json.Unmarshal(b, &ext); err == nil {
- if len(ext.Data) == 0 {
- ext.Data = ext.Code
- }
+ // if len(ext.Data) == 0 {
+ // ext.Data = ext.Code
+ // }
obj.From = ext.From
obj.To = ext.To
- obj.Value = ext.Value
- obj.Gas = ext.Gas
- obj.GasPrice = ext.GasPrice
+ obj.Value = ethutil.Big(ext.Value)
+ obj.Gas = ethutil.Big(ext.Gas)
+ obj.GasPrice = ethutil.Big(ext.GasPrice)
obj.Data = ext.Data
return