cosmos / cosmjs

The Swiss Army knife to power JavaScript based client solutions ranging from Web apps/explorers over browser extensions to server-side clients like faucets/scrapers.
https://cosmos.github.io/cosmjs/
Apache License 2.0
655 stars 344 forks source link

nextKey is not returned when calling GetTxsEvent #1108

Open swmd opened 2 years ago

swmd commented 2 years ago

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())
webmaster128 commented 2 years ago

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?