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
635 stars 328 forks source link

fix(stargate/allBalances): use pagination if there are more than 100 balances #1538

Open phips28 opened 6 months ago

phips28 commented 6 months ago

I have a Kujira wallet that has more than 100 balances/tokens (~116 at the time writing), therefore the allBalances function does not return all balances, only 100.

This PR changes check if there is a pagination key and gets the next page of balances.

Test I used locally:

    it("returns all balances > 100 with pagination", async () => {
      const client = await StargateClient.connect("https://rpc-kujira.synergynodes.com/");

      const balances = await client.getAllBalances("kujira1xww4yf8atl6sduqap74grkhxna5cw8r8jgw3fj");

      console.log("balances", balances);

      expect(balances.length).toBeGreaterThan(100);

      client.disconnect();
    });

But I cant add a test for it, as balances/tokens can change. If you have an idea how to add a test for it, let me know!

phips28 commented 6 months ago

@webmaster128 can you review/merge that pls?

phips28 commented 6 months ago

Can we get this merged pls? or any feedback what to imporove/change?

NotJeremyLiu commented 1 day ago

Hey folks, I'm from the Skip Go (formerly known as Skip API) team. This is a high priority improvement from our use case and is a big cause of customer complaints. Is there anything we can do to up-prioritize including this?

BlockJayn commented 23 hours ago

I've tried to find a way to reach out to @webmaster128, no luck unfortunately...