diff options
author | Jeffrey Wilcke <geffobscura@gmail.com> | 2015-06-24 01:19:33 +0800 |
---|---|---|
committer | Jeffrey Wilcke <geffobscura@gmail.com> | 2015-06-24 01:19:33 +0800 |
commit | 72e2613a9fe3205fa5a67b72b832e03b2357ee88 (patch) | |
tree | bbc987510d279d9e174ff8f684158d668131661e /rpc/api/args.go | |
parent | 5daf8729be88eca87b302ebf7a46fc69cad0f6d0 (diff) | |
parent | 67e6f74e9af00ff011a6a02f18644804eb18cdaa (diff) | |
download | go-tangerine-72e2613a9fe3205fa5a67b72b832e03b2357ee88.tar go-tangerine-72e2613a9fe3205fa5a67b72b832e03b2357ee88.tar.gz go-tangerine-72e2613a9fe3205fa5a67b72b832e03b2357ee88.tar.bz2 go-tangerine-72e2613a9fe3205fa5a67b72b832e03b2357ee88.tar.lz go-tangerine-72e2613a9fe3205fa5a67b72b832e03b2357ee88.tar.xz go-tangerine-72e2613a9fe3205fa5a67b72b832e03b2357ee88.tar.zst go-tangerine-72e2613a9fe3205fa5a67b72b832e03b2357ee88.zip |
Merge branch 'release/0.9.32'v0.9.32
Diffstat (limited to 'rpc/api/args.go')
-rw-r--r-- | rpc/api/args.go | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/rpc/api/args.go b/rpc/api/args.go new file mode 100644 index 000000000..fc85448e6 --- /dev/null +++ b/rpc/api/args.go @@ -0,0 +1,58 @@ +package api + +import ( + "encoding/json" + + "github.com/ethereum/go-ethereum/rpc/shared" +) + +type CompileArgs struct { + Source string +} + +func (args *CompileArgs) 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("arg0", "is not a string") + } + args.Source = argstr + + return nil +} + +type FilterStringArgs struct { + Word string +} + +func (args *FilterStringArgs) 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) + } + + var argstr string + argstr, ok := obj[0].(string) + if !ok { + return shared.NewInvalidTypeError("filter", "not a string") + } + switch argstr { + case "latest", "pending": + break + default: + return shared.NewValidationError("Word", "Must be `latest` or `pending`") + } + args.Word = argstr + return nil +} |