cosmjs icon indicating copy to clipboard operation
cosmjs copied to clipboard

nextKey is not returned when calling GetTxsEvent

Open swmd opened this issue 3 years ago • 1 comments

It appears that the pagination does not work properly when calling QueryClient.queryUnverified().

Here's the pagination object I am passing into the function.

pagination: {
	countTotal: true,
	key: new Uint8Array(),
	offset: Long.fromNumber(0, true),
	limit: Long.fromNumber(5, true),
	reverse: false,
}

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.

Edit: To give you a bit more context on this issue, I am pasting the whole code snippet here.

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())

swmd avatar Apr 01 '22 09:04 swmd

This issue seems to be specific for that query. Which Cosmos SDK version are you using in your backend? What value do you get returned in total in the response?

webmaster128 avatar Jun 29 '22 13:06 webmaster128