From 4e92642dec1b80c7930a5960325dab3badba625c Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Wed, 25 Mar 2020 17:23:13 +0300 Subject: [PATCH] rpc: allow to unmarshal integer params from string --- pkg/rpc/request/param.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/rpc/request/param.go b/pkg/rpc/request/param.go index fa9141546..55052990e 100644 --- a/pkg/rpc/request/param.go +++ b/pkg/rpc/request/param.go @@ -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.