aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--rpc/api.go10
-rw-r--r--rpc/args.go6
-rw-r--r--rpc/messages.go24
3 files changed, 24 insertions, 16 deletions
diff --git a/rpc/api.go b/rpc/api.go
index b97558bda..24491833d 100644
--- a/rpc/api.go
+++ b/rpc/api.go
@@ -311,7 +311,7 @@ func (p *EthereumApi) PushTx(args *PushTxArgs, reply *interface{}) error {
return nil
}
-func (p *EthereumApi) GetStateAt(args *GetStateArgs, reply *interface{}) error {
+func (p *EthereumApi) GetStorageAt(args *GetStorageAtArgs, reply *interface{}) error {
err := args.requirements()
if err != nil {
return err
@@ -333,7 +333,7 @@ func (p *EthereumApi) GetStateAt(args *GetStateArgs, reply *interface{}) error {
return nil
}
-func (p *EthereumApi) GetStorageAt(args *GetStorageArgs, reply *interface{}) error {
+func (p *EthereumApi) GetStorage(args *GetStorageArgs, reply *interface{}) error {
err := args.requirements()
if err != nil {
return err
@@ -527,14 +527,14 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
return p.GetBalanceAt(args, reply)
case "eth_getStorage":
// TODO handle defaultBlock
- args, err := req.ToGetStateArgs()
+ args, err := req.ToStorageArgs()
if err != nil {
return err
}
- return p.GetStateAt(args, reply)
+ return p.GetStorage(args, reply)
case "eth_getStorageAt":
// TODO handle defaultBlock
- args, err := req.ToStorageAtArgs()
+ args, err := req.ToGetStorageAtArgs()
if err != nil {
return err
}
diff --git a/rpc/args.go b/rpc/args.go
index 5686cbdec..42d9855b7 100644
--- a/rpc/args.go
+++ b/rpc/args.go
@@ -102,12 +102,12 @@ func (a *GetStorageArgs) requirements() error {
return nil
}
-type GetStateArgs struct {
+type GetStorageAtArgs struct {
Address string
Key string
}
-func (obj *GetStateArgs) UnmarshalJSON(b []byte) (err error) {
+func (obj *GetStorageAtArgs) UnmarshalJSON(b []byte) (err error) {
arg0 := ""
if err = json.Unmarshal(b, &arg0); err == nil {
obj.Address = arg0
@@ -116,7 +116,7 @@ func (obj *GetStateArgs) UnmarshalJSON(b []byte) (err error) {
return errDecodeArgs
}
-func (a *GetStateArgs) requirements() error {
+func (a *GetStorageAtArgs) requirements() error {
if a.Address == "" {
return NewErrorWithMessage(errArguments, "GetStorageAt requires an 'address' value as argument")
}
diff --git a/rpc/messages.go b/rpc/messages.go
index b37d8229d..3ab99d2c5 100644
--- a/rpc/messages.go
+++ b/rpc/messages.go
@@ -120,23 +120,31 @@ func (req *RpcRequest) ToPushTxArgs() (*PushTxArgs, error) {
return args, nil
}
-func (req *RpcRequest) ToGetStateArgs() (*GetStateArgs, error) {
- if len(req.Params) < 1 {
+func (req *RpcRequest) ToGetStorageAtArgs() (*GetStorageAtArgs, error) {
+ if len(req.Params) < 2 {
return nil, errArguments
}
- args := new(GetStateArgs)
- // TODO need to pass both arguments
- r := bytes.NewReader(req.Params[0])
- err := json.NewDecoder(r).Decode(args)
- if err != nil {
+ args := new(GetStorageAtArgs)
+ var arg0, arg1 string
+
+ r0 := bytes.NewReader(req.Params[0])
+ if err := json.NewDecoder(r0).Decode(arg0); err != nil {
return nil, errDecodeArgs
}
+ r1 := bytes.NewReader(req.Params[1])
+ if err := json.NewDecoder(r1).Decode(arg1); err != nil {
+ return nil, errDecodeArgs
+ }
+
+ args.Address = arg0
+ args.Key = arg1
+
return args, nil
}
-func (req *RpcRequest) ToStorageAtArgs() (*GetStorageArgs, error) {
+func (req *RpcRequest) ToStorageArgs() (*GetStorageArgs, error) {
if len(req.Params) < 1 {
return nil, errArguments
}