Add supplyOf query
This commit is contained in:
parent
894084a433
commit
0c5f72a55f
@ -137,5 +137,29 @@ describe("BankExtension", () => {
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("supplyOf", () => {
|
||||
it("works for existing denom", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const client = await makeBankClient(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.bank.unverified.supplyOf(simapp.denomFee);
|
||||
expect(response).toEqual({
|
||||
amount: "18000000000",
|
||||
denom: simapp.denomFee,
|
||||
});
|
||||
});
|
||||
|
||||
it("returns zero for non-existent denom", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const client = await makeBankClient(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.bank.unverified.supplyOf("gintonic");
|
||||
expect(response).toEqual({
|
||||
amount: "0",
|
||||
denom: "gintonic",
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -12,6 +12,7 @@ export interface BankExtension {
|
||||
readonly balance: (address: string, denom: string) => Promise<cosmos.ICoin>;
|
||||
readonly allBalances: (address: string) => Promise<cosmos.ICoin[]>;
|
||||
readonly totalSupply: () => Promise<cosmos.ICoin[]>;
|
||||
readonly supplyOf: (denom: string) => Promise<cosmos.ICoin>;
|
||||
};
|
||||
};
|
||||
}
|
||||
@ -55,6 +56,11 @@ export function setupBankExtension(base: QueryClient): BankExtension {
|
||||
const { supply } = await queryService.totalSupply({});
|
||||
return supply.map(toObject);
|
||||
},
|
||||
supplyOf: async (denom: string) => {
|
||||
const { amount } = await queryService.supplyOf({ denom: denom });
|
||||
assert(amount);
|
||||
return toObject(amount);
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
1
packages/stargate/types/queries/bank.d.ts
vendored
1
packages/stargate/types/queries/bank.d.ts
vendored
@ -7,6 +7,7 @@ export interface BankExtension {
|
||||
readonly balance: (address: string, denom: string) => Promise<cosmos.ICoin>;
|
||||
readonly allBalances: (address: string) => Promise<cosmos.ICoin[]>;
|
||||
readonly totalSupply: () => Promise<cosmos.ICoin[]>;
|
||||
readonly supplyOf: (denom: string) => Promise<cosmos.ICoin>;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user