Skip to content

Commit

Permalink
Note bug with voting power (#94)
Browse files Browse the repository at this point in the history
* Note bug with voting power

* Update pages/[proposalKey].tsx

Co-authored-by: Abhay Kumar <[email protected]>

---------

Co-authored-by: Abhay Kumar <[email protected]>
  • Loading branch information
ChewingGlass and abhay authored Dec 6, 2023
1 parent 9391d7c commit eb46f03
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion components/VoteBreakdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export function VoteBreakdown({ proposalKey }: { proposalKey: PublicKey }) {
const choices = marker.choices
.map((c) => proposal.choices[c].name)
.join(", ");

const voteWeight = humanReadable(marker.totalWeight, decimals);
const percentage = (
marker.totalWeight.mul(new BN(100000)).div(totalVotes).toNumber() / 1000
Expand All @@ -72,7 +73,9 @@ export function VoteBreakdown({ proposalKey }: { proposalKey: PublicKey }) {
rows.push([owner, choices, voteWeight, percentage]);
});

const csvContent = rows.map((row) => row.map(r => `"${r.toString()}"`).join(",")).join("\n");
const csvContent = rows
.map((row) => row.map((r) => `"${r.toString()}"`).join(","))
.join("\n");
return csvContent;
}, [groupedSortedMarkers]);
const displayedMarkers = useMemo(
Expand Down
4 changes: 4 additions & 0 deletions pages/[proposalKey].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,10 @@ const VoteDetailsPage = ({ name: initName, content }: { name: string, content: s
<p className="mb-4 text-xl sm:text-3xl text-white font-semibold tracking-tighter">
Voter Breakdown
</p>
<p className="text-white mb-s">
NOTE: For MOBILE / IOT Subnetworks this is shown as 1/10 of your vote weight because the underlying contracts
in spl-governance only support 64-bits of precision.
</p>
{!showBreakdown && (
<button
className="px-6 py-3 hover:bg-hv-gray-500 transition-all duration-200 rounded-lg text-lg text-hv-green-500 whitespace-nowrap outline-none border border-solid border-transparent focus:border-hv-green-500 mx-auto mt-4 block text-center"
Expand Down

0 comments on commit eb46f03

Please sign in to comment.