aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/api/eth_args.go
diff options
context:
space:
mode:
authorBas van Kervel <bas@ethdev.com>2015-06-09 22:06:51 +0800
committerBas van Kervel <basvankervel@gmail.com>2015-06-11 20:01:41 +0800
commitcc9ae399338557b6671e8fc83bb696c5ddb068fe (patch)
tree718e82c53c9dffebaf83cda6d1d1afe652e94e25 /rpc/api/eth_args.go
parent08d72a9245ce6f1e11f84a6b59d66cb083bea9f9 (diff)
downloaddexon-cc9ae399338557b6671e8fc83bb696c5ddb068fe.tar
dexon-cc9ae399338557b6671e8fc83bb696c5ddb068fe.tar.gz
dexon-cc9ae399338557b6671e8fc83bb696c5ddb068fe.tar.bz2
dexon-cc9ae399338557b6671e8fc83bb696c5ddb068fe.tar.lz
dexon-cc9ae399338557b6671e8fc83bb696c5ddb068fe.tar.xz
dexon-cc9ae399338557b6671e8fc83bb696c5ddb068fe.tar.zst
dexon-cc9ae399338557b6671e8fc83bb696c5ddb068fe.zip
added admin API
Diffstat (limited to 'rpc/api/eth_args.go')
-rw-r--r--rpc/api/eth_args.go30
1 files changed, 15 insertions, 15 deletions
diff --git a/rpc/api/eth_args.go b/rpc/api/eth_args.go
index 1ef6f9efb..ad9a35fa2 100644
--- a/rpc/api/eth_args.go
+++ b/rpc/api/eth_args.go
@@ -226,19 +226,14 @@ func (args *GetDataArgs) UnmarshalJSON(b []byte) (err error) {
return nil
}
-type NewSignArgs struct {
+type NewSigArgs struct {
From string
Data string
}
-func (args *NewSignArgs) UnmarshalJSON(b []byte) (err error) {
- var obj []json.RawMessage
- var ext struct {
- From string
- Data string
- }
+func (args *NewSigArgs) UnmarshalJSON(b []byte) (err error) {
+ var obj []interface{}
- // Decode byte slice to array of RawMessages
if err := json.Unmarshal(b, &obj); err != nil {
return shared.NewDecodeParamError(err.Error())
}
@@ -248,21 +243,26 @@ func (args *NewSignArgs) UnmarshalJSON(b []byte) (err error) {
return shared.NewInsufficientParamsError(len(obj), 1)
}
- // Decode 0th RawMessage to temporary struct
- if err := json.Unmarshal(obj[0], &ext); err != nil {
- return shared.NewDecodeParamError(err.Error())
+ from, ok := obj[0].(string)
+ if !ok {
+ return shared.NewInvalidTypeError("from", "not a string")
}
+ args.From = from
- if len(ext.From) == 0 {
+ if len(args.From) == 0 {
return shared.NewValidationError("from", "is required")
}
- if len(ext.Data) == 0 {
+ data, ok := obj[1].(string)
+ if !ok {
+ return shared.NewInvalidTypeError("data", "not a string")
+ }
+ args.Data = data
+
+ if len(args.Data) == 0 {
return shared.NewValidationError("data", "is required")
}
- args.From = ext.From
- args.Data = ext.Data
return nil
}