Skip to content

Commit

Permalink
Add GenesisProtocol.getBoostedProposalsCount (#333)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkent600 authored Aug 15, 2018
1 parent 62c56a7 commit 2a5b00a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
15 changes: 15 additions & 0 deletions lib/wrappers/genesisProtocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,21 @@ export class GenesisProtocolWrapper extends IntVoteInterfaceWrapper implements S
return this.contract.threshold(gpParametersHash, options.avatar);
}

/**
* Returns a promise of the number of boosted proposals, not including those
* that have expired but have not yet been executed to update their status.
*/
public async getBoostedProposalsCount(avatar: Address): Promise<BigNumber> {

if (!avatar) {
throw new Error("avatar is not defined");
}

this.logContractFunctionCall("GenesisProtocol.getBoostedProposalsCount", { avatar });

return this.contract.getBoostedProposalsCount(avatar);
}

/**
* Return the current balances on this GenesisProtocol's staking and the given avatar's native tokens.
* This can be useful, for example, if you want to know in advance whether the avatar has enough funds
Expand Down
11 changes: 10 additions & 1 deletion test/genesisProtocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,16 @@ describe("GenesisProtocol", () => {
assert.isOk(result.tx);
});

it("can call getBoostedProposalsCount", async () => {
const proposalId = await createProposal();

await stakeProposalVote(proposalId, BinaryVoteResult.Yes, 10);

const count = await genesisProtocol.getBoostedProposalsCount(dao.avatar.address);
assert(typeof count !== "undefined");
assert(count.eq(1));
});

it("can call getScore", async () => {
const proposalId = await createProposal();
const result = await genesisProtocol.getScore({
Expand All @@ -546,7 +556,6 @@ describe("GenesisProtocol", () => {
});

it("can call getThreshold", async () => {
const proposalId = await createProposal();
const result = await genesisProtocol.getThreshold({
avatar: dao.avatar.address,
});
Expand Down

0 comments on commit 2a5b00a

Please sign in to comment.