From 5fdf72b1abba65bcaed116791b6b8b70edb17e49 Mon Sep 17 00:00:00 2001 From: Bas van Kervel Date: Tue, 16 Jun 2015 15:16:06 +0200 Subject: [PATCH] fixed web3 rpc test failures --- rpc/api/web3_args.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) 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 +}