mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-12 11:10:35 +00:00
rpc: support 0x form of Uint256 in requests
This commit is contained in:
parent
c4057b8906
commit
8ff2d35723
2 changed files with 7 additions and 1 deletions
|
@ -6,6 +6,7 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
||||
|
@ -127,7 +128,7 @@ func (p *Param) GetUint256() (util.Uint256, error) {
|
|||
return util.Uint256{}, err
|
||||
}
|
||||
|
||||
return util.Uint256DecodeStringLE(s)
|
||||
return util.Uint256DecodeStringLE(strings.TrimPrefix(s, "0x"))
|
||||
}
|
||||
|
||||
// GetUint160FromHex returns Uint160 value of the parameter encoded in hex.
|
||||
|
|
|
@ -123,6 +123,11 @@ func TestParamGetUint256(t *testing.T) {
|
|||
assert.Equal(t, u256, u)
|
||||
require.Nil(t, err)
|
||||
|
||||
p = Param{StringT, "0x" + gas}
|
||||
u, err = p.GetUint256()
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, u256, u)
|
||||
|
||||
p = Param{StringT, 42}
|
||||
_, err = p.GetUint256()
|
||||
require.NotNil(t, err)
|
||||
|
|
Loading…
Reference in a new issue