Skip to content

Commit

Permalink
add optional height param to voting power queries
Browse files Browse the repository at this point in the history
  • Loading branch information
sotnikov-s committed Aug 26, 2023
1 parent e69a8c0 commit 12124ec
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/helpers/dao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,22 +392,34 @@ export class Dao {
);
}

async queryTotalVotingPower(): Promise<TotalPowerAtHeightResponse> {
async queryTotalVotingPower(
height?: number,
): Promise<TotalPowerAtHeightResponse> {
return await this.chain.queryContract<TotalPowerAtHeightResponse>(
this.contracts.core.address,
{
total_power_at_height: {},
total_power_at_height:
typeof height === 'undefined' ? {} : { height: height },
},
);
}

async queryVotingPower(addr: string): Promise<VotingPowerAtHeightResponse> {
async queryVotingPower(
addr: string,
height?: number,
): Promise<VotingPowerAtHeightResponse> {
return await this.chain.queryContract<VotingPowerAtHeightResponse>(
this.contracts.core.address,
{
voting_power_at_height: {
address: addr,
},
voting_power_at_height:
typeof height === 'undefined'
? {
address: addr,
}
: {
address: addr,
height: height,
},
},
);
}
Expand Down

0 comments on commit 12124ec

Please sign in to comment.