Merge pull request #794 from nspcc-dev/fix/rpc
rpc: allow to unmarshal integer params from string
This commit is contained in:
commit
e5fbf3ef2c
1 changed files with 6 additions and 3 deletions
|
@ -5,6 +5,7 @@ import (
|
|||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
||||
|
@ -55,10 +56,12 @@ func (p Param) GetString() (string, error) {
|
|||
// GetInt returns int value of te parameter.
|
||||
func (p Param) GetInt() (int, error) {
|
||||
i, ok := p.Value.(int)
|
||||
if !ok {
|
||||
return 0, errors.New("not an integer")
|
||||
if ok {
|
||||
return i, nil
|
||||
} else if s, ok := p.Value.(string); ok {
|
||||
return strconv.Atoi(s)
|
||||
}
|
||||
return i, nil
|
||||
return 0, errors.New("not an integer")
|
||||
}
|
||||
|
||||
// GetArray returns a slice of Params stored in the parameter.
|
||||
|
|
Loading…
Reference in a new issue