mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-22 19:29:39 +00:00
rpc: allow to unmarshal integer params from string
This commit is contained in:
parent
4f26064aab
commit
4e92642dec
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