From 6eb3cad6d5cef5916b2fcf05163fb45eb3ec8c57 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Mon, 11 Oct 2021 16:56:20 +0300 Subject: [PATCH] rpc: use uint64 for timestamp boundaries in GetNEP17Transfers Block's timestamp is in milliseconds, so it overflows uint32. --- docs/rpc.md | 6 +++--- pkg/rpc/client/rpc.go | 2 +- pkg/rpc/client/rpc_test.go | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/rpc.md b/docs/rpc.md index 7790bad2b..7e25e1516 100644 --- a/docs/rpc.md +++ b/docs/rpc.md @@ -165,18 +165,18 @@ additional parameter and then use paging to request the next batch of transfers. Example requesting 10 events for address NbTiM6h8r99kpRtb428XcsUk1TzKed2gTc -within 0-1600094189 timestamps: +within 0-1600094189000 timestamps: ```json { "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: ```json { "jsonrpc": "2.0", "id": 5, "method": "getnep17transfers", "params": -["NbTiM6h8r99kpRtb428XcsUk1TzKed2gTc", 0, 1600094189, 10, 1] } +["NbTiM6h8r99kpRtb428XcsUk1TzKed2gTc", 0, 1600094189000, 10, 1] } ``` #### Websocket server diff --git a/pkg/rpc/client/rpc.go b/pkg/rpc/client/rpc.go index 1792d6ce5..5e0de0217 100644 --- a/pkg/rpc/client/rpc.go +++ b/pkg/rpc/client/rpc.go @@ -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. // These parameters are positional in the JSON-RPC call, you can't specify limit // 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) if start != nil { params.Values = append(params.Values, *start) diff --git a/pkg/rpc/client/rpc_test.go b/pkg/rpc/client/rpc_test.go index 4641f2517..874a7e303 100644 --- a/pkg/rpc/client/rpc_test.go +++ b/pkg/rpc/client/rpc_test.go @@ -1206,14 +1206,14 @@ var rpcClientErrorCases = map[string][]rpcClientErrorCase{ { name: "getnep17transfers_invalid_params_error 2", invoke: func(c *Client) (interface{}, error) { - var stop uint32 + var stop uint64 return c.GetNEP17Transfers("Nhfg3TbpwogLvDGVvAvqyThbsHgoSUKwtn", nil, &stop, nil, nil) }, }, { name: "getnep17transfers_invalid_params_error 3", invoke: func(c *Client) (interface{}, error) { - var start uint32 + var start uint64 var limit int return c.GetNEP17Transfers("Nhfg3TbpwogLvDGVvAvqyThbsHgoSUKwtn", &start, nil, &limit, nil) }, @@ -1221,7 +1221,7 @@ var rpcClientErrorCases = map[string][]rpcClientErrorCase{ { name: "getnep17transfers_invalid_params_error 4", invoke: func(c *Client) (interface{}, error) { - var start, stop uint32 + var start, stop uint64 var page int return c.GetNEP17Transfers("Nhfg3TbpwogLvDGVvAvqyThbsHgoSUKwtn", &start, &stop, nil, &page) },