aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/api/args.go
diff options
context:
space:
mode:
authorBas van Kervel <bas@ethdev.com>2015-06-17 22:22:35 +0800
committerBas van Kervel <bas@ethdev.com>2015-06-22 15:17:09 +0800
commita4a4e9fcf824189d8d06940492a01effe6e6cf92 (patch)
tree5e7b9cea12d319e4ab1d6ca746102e080259297f /rpc/api/args.go
parent3e1d635f8d40815ef2262e017a969ed6f5eb2a5d (diff)
downloadgo-tangerine-a4a4e9fcf824189d8d06940492a01effe6e6cf92.tar
go-tangerine-a4a4e9fcf824189d8d06940492a01effe6e6cf92.tar.gz
go-tangerine-a4a4e9fcf824189d8d06940492a01effe6e6cf92.tar.bz2
go-tangerine-a4a4e9fcf824189d8d06940492a01effe6e6cf92.tar.lz
go-tangerine-a4a4e9fcf824189d8d06940492a01effe6e6cf92.tar.xz
go-tangerine-a4a4e9fcf824189d8d06940492a01effe6e6cf92.tar.zst
go-tangerine-a4a4e9fcf824189d8d06940492a01effe6e6cf92.zip
removed old rpc structure and added new inproc api client
Diffstat (limited to 'rpc/api/args.go')
-rw-r--r--rpc/api/args.go57
1 files changed, 57 insertions, 0 deletions
diff --git a/rpc/api/args.go b/rpc/api/args.go
new file mode 100644
index 000000000..4ef1b26e7
--- /dev/null
+++ b/rpc/api/args.go
@@ -0,0 +1,57 @@
+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
+} \ No newline at end of file