cosmos-sdk: nextKey is not returned when calling GetTxsEvent

Summary of Bug

It appears that the pagination does not work properly when calling QueryClient.queryUnverified(). There are two issues I found in the response:

  1. nextKey is always an empty array.
  2. offset and limit keys don’t work correctly. When I passed offset=4, limit=7, it just returned the result from the beginning. The response had the transactions of indexes 0-6.

Version

v0.44

Steps to Reproduce

Here’s the code snippet I used to get the transactions history.

import { Tendermint34Client } from "@cosmjs/tendermint-rpc"
import { QueryClient } from "@cosmjs/stargate"
import { GetTxsEventRequest } from "cosmjs-types/cosmos/tx/v1beta1/service"

const client = QueryClient.withExtensions(
    await Tendermint34Client.connect({rpc_endpoint}),
)

client.queryUnverified("/cosmos.tx.v1beta1.Service/GetTxsEvent", GetTxsEventRequest.encode({
    events: [
        "message.action='delegate'",
	"delegate.validator='{validator_address}'",
    ],
    pagination: {
	countTotal: true,
	key: new Uint8Array(),
	offset: Long.fromNumber(0, true),
	limit: Long.fromNumber(5, true),
	reverse: false,
    },
    orderBy: OrderBy.ORDER_BY_ASC,
}).finish())

For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 19 (12 by maintainers)

Commits related to this issue

Most upvoted comments

Probably GetTxsEvent shouldn’t accept sdk query.PageRequest (nor return a query.PageResponse) and just use page and limit/perPage params like it’s the case for the corresponding CLI query command QueryTxsByEventsCmd?

Yes, this seems reasonable to me. It should not accept and return those parameters 👍

@facundomedica or @julienrbrt would you have some bandwidth to look into pagination?