Merge pull request #2212 from nspcc-dev/fix-nep17-paging

rpc: use uint64 for timestamp boundaries in GetNEP17Transfers
This commit is contained in:
Roman Khimov 2021-10-11 17:42:59 +03:00 committed by GitHub
commit 38ba6d735e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 7 deletions

View file

@ -165,18 +165,18 @@ additional parameter and then use paging to request the next batch of
transfers. transfers.
Example requesting 10 events for address NbTiM6h8r99kpRtb428XcsUk1TzKed2gTc Example requesting 10 events for address NbTiM6h8r99kpRtb428XcsUk1TzKed2gTc
within 0-1600094189 timestamps: within 0-1600094189000 timestamps:
```json ```json
{ "jsonrpc": "2.0", "id": 5, "method": "getnep17transfers", "params": { "jsonrpc": "2.0", "id": 5, "method": "getnep17transfers", "params":
["NbTiM6h8r99kpRtb428XcsUk1TzKed2gTc", 0, 1600094189, 10] } ["NbTiM6h8r99kpRtb428XcsUk1TzKed2gTc", 0, 1600094189000, 10] }
``` ```
Get the next 10 transfers for the same account within the same time frame: Get the next 10 transfers for the same account within the same time frame:
```json ```json
{ "jsonrpc": "2.0", "id": 5, "method": "getnep17transfers", "params": { "jsonrpc": "2.0", "id": 5, "method": "getnep17transfers", "params":
["NbTiM6h8r99kpRtb428XcsUk1TzKed2gTc", 0, 1600094189, 10, 1] } ["NbTiM6h8r99kpRtb428XcsUk1TzKed2gTc", 0, 1600094189000, 10, 1] }
``` ```
#### Websocket server #### Websocket server

View file

@ -283,7 +283,7 @@ func (c *Client) GetNEP17Balances(address util.Uint160) (*result.NEP17Balances,
// are supported since neo-go 0.77.0 and limit and page since neo-go 0.78.0. // are supported since neo-go 0.77.0 and limit and page since neo-go 0.78.0.
// These parameters are positional in the JSON-RPC call, you can't specify limit // These parameters are positional in the JSON-RPC call, you can't specify limit
// and not specify start/stop for example. // and not specify start/stop for example.
func (c *Client) GetNEP17Transfers(address string, start, stop *uint32, limit, page *int) (*result.NEP17Transfers, error) { func (c *Client) GetNEP17Transfers(address string, start, stop *uint64, limit, page *int) (*result.NEP17Transfers, error) {
params := request.NewRawParams(address) params := request.NewRawParams(address)
if start != nil { if start != nil {
params.Values = append(params.Values, *start) params.Values = append(params.Values, *start)

View file

@ -1206,14 +1206,14 @@ var rpcClientErrorCases = map[string][]rpcClientErrorCase{
{ {
name: "getnep17transfers_invalid_params_error 2", name: "getnep17transfers_invalid_params_error 2",
invoke: func(c *Client) (interface{}, error) { invoke: func(c *Client) (interface{}, error) {
var stop uint32 var stop uint64
return c.GetNEP17Transfers("Nhfg3TbpwogLvDGVvAvqyThbsHgoSUKwtn", nil, &stop, nil, nil) return c.GetNEP17Transfers("Nhfg3TbpwogLvDGVvAvqyThbsHgoSUKwtn", nil, &stop, nil, nil)
}, },
}, },
{ {
name: "getnep17transfers_invalid_params_error 3", name: "getnep17transfers_invalid_params_error 3",
invoke: func(c *Client) (interface{}, error) { invoke: func(c *Client) (interface{}, error) {
var start uint32 var start uint64
var limit int var limit int
return c.GetNEP17Transfers("Nhfg3TbpwogLvDGVvAvqyThbsHgoSUKwtn", &start, nil, &limit, nil) return c.GetNEP17Transfers("Nhfg3TbpwogLvDGVvAvqyThbsHgoSUKwtn", &start, nil, &limit, nil)
}, },
@ -1221,7 +1221,7 @@ var rpcClientErrorCases = map[string][]rpcClientErrorCase{
{ {
name: "getnep17transfers_invalid_params_error 4", name: "getnep17transfers_invalid_params_error 4",
invoke: func(c *Client) (interface{}, error) { invoke: func(c *Client) (interface{}, error) {
var start, stop uint32 var start, stop uint64
var page int var page int
return c.GetNEP17Transfers("Nhfg3TbpwogLvDGVvAvqyThbsHgoSUKwtn", &start, &stop, nil, &page) return c.GetNEP17Transfers("Nhfg3TbpwogLvDGVvAvqyThbsHgoSUKwtn", &start, &stop, nil, &page)
}, },