diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e20e236..be44bcbc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,12 +61,16 @@ and this project adheres to - @cosmjs/stargate: Remove Cosmos SDK 0.42 support ([#1094]). - @cosmjs/tendermint-rpc: Change spelling of field `codeSpace` to `codespace` in `TxData` and `BroadcastTxSyncResponse` ([#1234]). +- @cosmjs/stargate: `BankExtension.totalSupply` now takes a pagination key + argument and returns the full `QueryTotalSupplyResponse` including the next + pagination key ([#1095]). [#1131]: https://github.com/cosmos/cosmjs/pull/1131 [#1168]: https://github.com/cosmos/cosmjs/pull/1168 [#1133]: https://github.com/cosmos/cosmjs/issues/1133 [#1094]: https://github.com/cosmos/cosmjs/issues/1094 [#1234]: https://github.com/cosmos/cosmjs/issues/1234 +[#1095]: https://github.com/cosmos/cosmjs/issues/1095 ## [0.28.11] - 2022-07-13 diff --git a/packages/stargate/src/modules/bank/queries.spec.ts b/packages/stargate/src/modules/bank/queries.spec.ts index bfd4d1ad..7f7b96ff 100644 --- a/packages/stargate/src/modules/bank/queries.spec.ts +++ b/packages/stargate/src/modules/bank/queries.spec.ts @@ -100,8 +100,8 @@ describe("BankExtension", () => { pendingWithoutSimapp(); const [client, tmClient] = await makeClientWithBank(simapp.tendermintUrl); - const response = await client.bank.totalSupply(); - expect(response).toEqual([ + const { supply } = await client.bank.totalSupply(); + expect(supply).toEqual([ { amount: simapp.totalSupply.toString(), denom: simapp.denomFee, diff --git a/packages/stargate/src/modules/bank/queries.ts b/packages/stargate/src/modules/bank/queries.ts index 9c596789..c631fe47 100644 --- a/packages/stargate/src/modules/bank/queries.ts +++ b/packages/stargate/src/modules/bank/queries.ts @@ -1,16 +1,16 @@ /* eslint-disable @typescript-eslint/naming-convention */ import { assert } from "@cosmjs/utils"; import { Metadata } from "cosmjs-types/cosmos/bank/v1beta1/bank"; -import { QueryClientImpl } from "cosmjs-types/cosmos/bank/v1beta1/query"; +import { QueryClientImpl, QueryTotalSupplyResponse } from "cosmjs-types/cosmos/bank/v1beta1/query"; import { Coin } from "cosmjs-types/cosmos/base/v1beta1/coin"; -import { createProtobufRpcClient, QueryClient } from "../../queryclient"; +import { createPagination, createProtobufRpcClient, QueryClient } from "../../queryclient"; export interface BankExtension { readonly bank: { readonly balance: (address: string, denom: string) => Promise; readonly allBalances: (address: string) => Promise; - readonly totalSupply: () => Promise; + readonly totalSupply: (paginationKey?: Uint8Array) => Promise; readonly supplyOf: (denom: string) => Promise; readonly denomMetadata: (denom: string) => Promise; readonly denomsMetadata: () => Promise; @@ -34,9 +34,11 @@ export function setupBankExtension(base: QueryClient): BankExtension { const { balances } = await queryService.AllBalances({ address: address }); return balances; }, - totalSupply: async () => { - const { supply } = await queryService.TotalSupply({}); - return supply; + totalSupply: async (paginationKey?: Uint8Array) => { + const response = await queryService.TotalSupply({ + pagination: createPagination(paginationKey), + }); + return response; }, supplyOf: async (denom: string) => { const { amount } = await queryService.SupplyOf({ denom: denom });