diff options
author | obscuren <geffobscura@gmail.com> | 2015-01-30 03:39:26 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-01-30 03:39:26 +0800 |
commit | 0031f388ac1f6f4a23c5c75e5eeb4a007f0b2f31 (patch) | |
tree | 05a525e94ee55bd9c4a84301989176d40d76cb61 /rpc/args.go | |
parent | 6488a392a347d0d47212fdc78386e3e0e5841d7d (diff) | |
download | dexon-0031f388ac1f6f4a23c5c75e5eeb4a007f0b2f31.tar dexon-0031f388ac1f6f4a23c5c75e5eeb4a007f0b2f31.tar.gz dexon-0031f388ac1f6f4a23c5c75e5eeb4a007f0b2f31.tar.bz2 dexon-0031f388ac1f6f4a23c5c75e5eeb4a007f0b2f31.tar.lz dexon-0031f388ac1f6f4a23c5c75e5eeb4a007f0b2f31.tar.xz dexon-0031f388ac1f6f4a23c5c75e5eeb4a007f0b2f31.tar.zst dexon-0031f388ac1f6f4a23c5c75e5eeb4a007f0b2f31.zip |
More dapp samples
* Info DApp, coin DApp
* Additional rpc methods
Diffstat (limited to 'rpc/args.go')
-rw-r--r-- | rpc/args.go | 43 |
1 files changed, 38 insertions, 5 deletions
diff --git a/rpc/args.go b/rpc/args.go index 79519e7d2..aaa017c4e 100644 --- a/rpc/args.go +++ b/rpc/args.go @@ -69,10 +69,28 @@ func (a *PushTxArgs) requirementsPushTx() error { type GetStorageArgs struct { Address string - Key string } func (obj *GetStorageArgs) UnmarshalJSON(b []byte) (err error) { + if err = json.Unmarshal(b, &obj.Address); err != nil { + return NewErrorResponse(ErrorDecodeArgs) + } + return +} + +func (a *GetStorageArgs) requirements() error { + if len(a.Address) == 0 { + return NewErrorResponse("GetStorageAt requires an 'address' value as argument") + } + return nil +} + +type GetStateArgs struct { + Address string + Key string +} + +func (obj *GetStateArgs) UnmarshalJSON(b []byte) (err error) { arg0 := "" if err = json.Unmarshal(b, arg0); err == nil { obj.Address = arg0 @@ -81,7 +99,7 @@ func (obj *GetStorageArgs) UnmarshalJSON(b []byte) (err error) { return NewErrorResponse(ErrorDecodeArgs) } -func (a *GetStorageArgs) requirements() error { +func (a *GetStateArgs) requirements() error { if a.Address == "" { return NewErrorResponse("GetStorageAt requires an 'address' value as argument") } @@ -92,9 +110,8 @@ func (a *GetStorageArgs) requirements() error { } type GetStorageAtRes struct { - Key string `json:"key"` - Value string `json:"value"` - Address string `json:"address"` + Key string `json:"key"` + Value string `json:"value"` } type GetTxCountArgs struct { @@ -218,3 +235,19 @@ func toFilterOptions(options *FilterOptions) core.FilterOptions { type FilterChangedArgs struct { n int } + +type DbArgs struct { + Database string + Key string + Value string +} + +func (a *DbArgs) requirements() error { + if len(a.Database) == 0 { + return NewErrorResponse("DbPutArgs requires an 'Database' value as argument") + } + if len(a.Key) == 0 { + return NewErrorResponse("DbPutArgs requires an 'Key' value as argument") + } + return nil +} |