Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CLI returning zero required votes on proposals with no tx #10477

Merged
merged 2 commits into from
Aug 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions packages/sdk/contractkit/src/wrappers/Governance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,10 @@ export class GovernanceWrapper extends BaseWrapperForGoverning<Governance> {
* @param proposal Proposal to determine the constitution for running.
*/
async getConstitution(proposal: Proposal): Promise<BigNumber> {
let constitution = new BigNumber(0)
// Default value that is harcoded on Governance contract
// it's 0.5 in Fixidity
// https://github.com/celo-org/celo-monorepo/blob/3fffa158d67ffd6366e81ba7243eadede1974b1b/packages/protocol/contracts/governance/Governance.sol#L39
let constitution = fromFixed(new BigNumber('500000000000000000000000'))
for (const tx of proposal) {
constitution = BigNumber.max(await this.getTransactionConstitution(tx), constitution)
}
Expand All @@ -236,7 +239,7 @@ export class GovernanceWrapper extends BaseWrapperForGoverning<Governance> {
// in the total of yes votes required
async getSupportWithConstitutionThreshold(proposalID: BigNumber.Value, constitution: BigNumber) {
const support = await this.getSupport(proposalID)
support.required = support.required.times(constitution)
support.required = support.required.times(constitution).integerValue()
return support
}

Expand Down
Loading