nervosnetwork / ckb-sdk-go

MIT License
21 stars 23 forks source link

Wrong parameter types for some RPC methods #209

Closed janbormet closed 1 year ago

janbormet commented 1 year ago

Some methods in the Client interface of the indexer package receive a parameter limit uint64:

GetCells(ctx context.Context, searchKey *SearchKey, order SearchOrder, limit uint64, afterCursor string) (*LiveCells, error)

// GetTransactions returns the transactions collection by the lock or type script.
GetTransactions(ctx context.Context, searchKey *SearchKey, order SearchOrder, limit uint64, afterCursor string) (*TxsWithCell, error)

// GetTransactionsGrouped returns the grouped transactions collection by the lock or type script.
GetTransactionsGrouped(ctx context.Context, searchKey *SearchKey, order SearchOrder, limit uint64, afterCursor string) (*TxsWithCells, error)

The RPC Indexer module documentation requires the limit value to be UInt32 though. If you call e.g. client.GetCells(_, _, _, math.MaxUint64, _), the rpc node will return an error: Invalid params: Invalid Uint32 0xffffffffffffffff: number too large to fit in target type.

These should be adjusted to receive uint32 and their implementation should properly convert to UInt32 (indexer/indexer.go)

There might also be similar issues with other RPC methods, I did not check exhaustively.