Skip to content

Commit

Permalink
Hotfix for gsc vote counting
Browse files Browse the repository at this point in the history
Added a conditional that checks if the voting contract is gsc we use 1e18 as the decimals for vote counting
  • Loading branch information
cashd committed Oct 10, 2023
1 parent 92ed36e commit 21afad0
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions apps/council-ui/pages/proposals/details.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Ballot, getBlockDate, Proposal, Vote } from "@council/sdk";
import { useQuery } from "@tanstack/react-query";
import { parseUnits } from "ethers/lib/utils";
import { useRouter } from "next/router";
import { ReactElement, useMemo, useState } from "react";
import Skeleton from "react-loading-skeleton";
Expand Down Expand Up @@ -304,18 +305,31 @@ function useProposalDetailsPageData(
})
: null;

const votes = await proposal.getVotes();
let votes = await proposal.getVotes();
const voterEnsRecords = await getBulkEnsRecords(
Array.from(new Set(votes.map((vote) => vote.voter.address))),
provider,
);

const currentQuorum = await proposal.getCurrentQuorum();
const requiredQuorum = await proposal.getRequiredQuorum();
let currentQuorum = await proposal.getCurrentQuorum();
let requiredQuorum = await proposal.getRequiredQuorum();
const results = await proposal.getResults();

const proposalConfig = proposalConfigs[id];

// Hotfix for correct vote display of gsc
// TODO @cashd: add parameter to voting vault configs for voting power decimals
if (type === "gsc") {
currentQuorum = parseUnits(currentQuorum).toString();
requiredQuorum = requiredQuorum
? parseUnits(requiredQuorum).toString()
: null;
votes = votes.map((vote) => ({
...vote,
power: parseUnits(vote.power).toString(),
}));
}

return {
type,
votingContractName,
Expand All @@ -335,7 +349,7 @@ function useProposalDetailsPageData(
endsAtDate,
unlockedAtDate,
lastCallAtDate: lastCallAtDate,
votes: await proposal.getVotes(),
votes,
voterEnsRecords,
createdTransactionHash,
accountBallot: account
Expand Down

0 comments on commit 21afad0

Please sign in to comment.