From 12124ec865e32e4351855b3d9a4572075dce8671 Mon Sep 17 00:00:00 2001 From: sotnikov-s Date: Sat, 26 Aug 2023 15:01:17 +0400 Subject: [PATCH] add optional height param to voting power queries --- src/helpers/dao.ts | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/helpers/dao.ts b/src/helpers/dao.ts index 9debbdaf..b8af7f20 100644 --- a/src/helpers/dao.ts +++ b/src/helpers/dao.ts @@ -392,22 +392,34 @@ export class Dao { ); } - async queryTotalVotingPower(): Promise { + async queryTotalVotingPower( + height?: number, + ): Promise { return await this.chain.queryContract( this.contracts.core.address, { - total_power_at_height: {}, + total_power_at_height: + typeof height === 'undefined' ? {} : { height: height }, }, ); } - async queryVotingPower(addr: string): Promise { + async queryVotingPower( + addr: string, + height?: number, + ): Promise { return await this.chain.queryContract( this.contracts.core.address, { - voting_power_at_height: { - address: addr, - }, + voting_power_at_height: + typeof height === 'undefined' + ? { + address: addr, + } + : { + address: addr, + height: height, + }, }, ); }