diff options
author | Bas van Kervel <bas@ethdev.com> | 2015-06-10 17:29:52 +0800 |
---|---|---|
committer | Bas van Kervel <basvankervel@gmail.com> | 2015-06-11 20:01:41 +0800 |
commit | bd38428f33b127e9c60d26127695e50c55798fcd (patch) | |
tree | 9bb838822fc3d1b28775f57223a30a243d4df9f2 /rpc/api/personal_args.go | |
parent | 87b62f75a7b9c15c17f3352f1b50ad88966e7070 (diff) | |
download | go-tangerine-bd38428f33b127e9c60d26127695e50c55798fcd.tar go-tangerine-bd38428f33b127e9c60d26127695e50c55798fcd.tar.gz go-tangerine-bd38428f33b127e9c60d26127695e50c55798fcd.tar.bz2 go-tangerine-bd38428f33b127e9c60d26127695e50c55798fcd.tar.lz go-tangerine-bd38428f33b127e9c60d26127695e50c55798fcd.tar.xz go-tangerine-bd38428f33b127e9c60d26127695e50c55798fcd.tar.zst go-tangerine-bd38428f33b127e9c60d26127695e50c55798fcd.zip |
cleanup of javascript API
Diffstat (limited to 'rpc/api/personal_args.go')
-rw-r--r-- | rpc/api/personal_args.go | 45 |
1 files changed, 28 insertions, 17 deletions
diff --git a/rpc/api/personal_args.go b/rpc/api/personal_args.go index b41fc06e7..b3e683638 100644 --- a/rpc/api/personal_args.go +++ b/rpc/api/personal_args.go @@ -16,13 +16,16 @@ func (args *NewAccountArgs) UnmarshalJSON(b []byte) (err error) { return shared.NewDecodeParamError(err.Error()) } - passhrase, ok := obj[0].(string) - if !ok { - return shared.NewInvalidTypeError("passhrase", "not a string") + if len(obj) < 1 { + return shared.NewInsufficientParamsError(len(obj), 1) } - args.Passphrase = passhrase - return nil + if passhrase, ok := obj[0].(string); ok { + args.Passphrase = passhrase + return nil + } + + return shared.NewInvalidTypeError("passhrase", "not a string") } type DeleteAccountArgs struct { @@ -36,17 +39,21 @@ func (args *DeleteAccountArgs) UnmarshalJSON(b []byte) (err error) { return shared.NewDecodeParamError(err.Error()) } - addr, ok := obj[0].(string) - if !ok { + if len(obj) < 2 { + return shared.NewInsufficientParamsError(len(obj), 2) + } + + if addr, ok := obj[0].(string); ok { + args.Address = addr + } else { return shared.NewInvalidTypeError("address", "not a string") } - args.Address = addr - passhrase, ok := obj[1].(string) - if !ok { + if passhrase, ok := obj[1].(string); ok { + args.Passphrase = passhrase + } else { return shared.NewInvalidTypeError("passhrase", "not a string") } - args.Passphrase = passhrase return nil } @@ -65,17 +72,21 @@ func (args *UnlockAccountArgs) UnmarshalJSON(b []byte) (err error) { args.Duration = -1 - addrstr, ok := obj[0].(string) - if !ok { + if len(obj) < 2 { + return shared.NewInsufficientParamsError(len(obj), 2) + } + + if addrstr, ok := obj[0].(string); ok { + args.Address = addrstr + } else { return shared.NewInvalidTypeError("address", "not a string") } - args.Address = addrstr - passphrasestr, ok := obj[1].(string) - if !ok { + if passphrasestr, ok := obj[1].(string); ok { + args.Passphrase = passphrasestr + } else { return shared.NewInvalidTypeError("passphrase", "not a string") } - args.Passphrase = passphrasestr return nil } |