mirror of
https://github.com/cosmos/cosmjs.git
synced 2025-03-10 13:47:12 +00:00
Add pagination support to BankExtension.totalSupply
This commit is contained in:
parent
26557c1c20
commit
3216b838dc
@ -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
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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<Coin>;
|
||||
readonly allBalances: (address: string) => Promise<Coin[]>;
|
||||
readonly totalSupply: () => Promise<Coin[]>;
|
||||
readonly totalSupply: (paginationKey?: Uint8Array) => Promise<QueryTotalSupplyResponse>;
|
||||
readonly supplyOf: (denom: string) => Promise<Coin>;
|
||||
readonly denomMetadata: (denom: string) => Promise<Metadata>;
|
||||
readonly denomsMetadata: () => Promise<Metadata[]>;
|
||||
@ -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 });
|
||||
|
Loading…
x
Reference in New Issue
Block a user