Skip to content

Commit

Permalink
Fix jank (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChewingGlass committed Jan 20, 2024
1 parent f85e079 commit 996c340
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions components/ProposalVoteCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,14 @@ export const ProposalVoteCard = ({
...r,
index,
percent: totalVotes?.isZero()
? BigInt(100) / BigInt(proposal?.choices.length)
: (BigInt(r.weight.toString()) / BigInt(totalVotes.toString())) * BigInt(100),
? 100 / proposal?.choices.length
: // Calculate with 4 decimals of precision
r.weight.mul(new BN(10000)).div(totalVotes).toNumber() *
(100 / 10000),
}))
.sort((a, b) => (a.percent < b.percent) ? -1 : ((a.percent > b.percent) ? 1 : 0));
.sort((a, b) =>
a.percent < b.percent ? -1 : a.percent > b.percent ? 1 : 0
);
return { results, totalVotes };
}, [proposal?.choices]);

Expand Down

0 comments on commit 996c340

Please sign in to comment.