diff options
author | Bas van Kervel <bas@ethdev.com> | 2015-06-16 21:16:06 +0800 |
---|---|---|
committer | Bas van Kervel <bas@ethdev.com> | 2015-06-22 14:54:21 +0800 |
commit | 5fdf72b1abba65bcaed116791b6b8b70edb17e49 (patch) | |
tree | 9c1fcdda1ad60ec77cbcde7614b35a431ca7df7b /rpc | |
parent | c3f6c322c07a96d3930c75d05ed3859e7d80ddbc (diff) | |
download | dexon-5fdf72b1abba65bcaed116791b6b8b70edb17e49.tar.gz dexon-5fdf72b1abba65bcaed116791b6b8b70edb17e49.tar.zst dexon-5fdf72b1abba65bcaed116791b6b8b70edb17e49.zip |
fixed web3 rpc test failures
Diffstat (limited to 'rpc')
-rw-r--r-- | rpc/api/web3_args.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/rpc/api/web3_args.go b/rpc/api/web3_args.go index 5455a6c8e..38af7191e 100644 --- a/rpc/api/web3_args.go +++ b/rpc/api/web3_args.go @@ -1,5 +1,29 @@ package api +import ( + "encoding/json" + + "github.com/ethereum/go-ethereum/rpc/shared" +) + type Sha3Args struct { Data string } + +func (args *Sha3Args) UnmarshalJSON(b []byte) (err error) { + var obj []interface{} + if err := json.Unmarshal(b, &obj); err != nil { + return shared.NewDecodeParamError(err.Error()) + } + + if len(obj) < 1 { + return shared.NewInsufficientParamsError(len(obj), 1) + } + + argstr, ok := obj[0].(string) + if !ok { + return shared.NewInvalidTypeError("data", "is not a string") + } + args.Data = argstr + return nil +} |