Skip to content

Commit

Permalink
[frenemies] sort by live stake info instead of voting power
Browse files Browse the repository at this point in the history
  • Loading branch information
sblackshear committed Feb 8, 2023
1 parent 8ae924c commit 04624a2
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions dapps/frenemies/src/components/Validators/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,11 @@ export function Table({ validators }: Props) {
currentAccount
);

// sort validators by their voting power in DESC order (not by stake - these are different)
// TODO: using `OR "0"` since voting power is an optional field;
// sort validators by their live stake info in DESC order
const sorted = [...validators].sort((a, b) =>
Number(
BigInt(b.fields.voting_power || "0") -
BigInt(a.fields.voting_power || "0")
BigInt(b.fields.metatadata.fields.next_epoch_stake) + BigInt(b.fields.metadata.fields.next_epoch_delegation) -
BigInt(a.fields.metatadata.fields.next_epoch_stake) + BigInt(a.fields.metadata.fields.next_epoch_delegation) -
)
);

Expand Down

0 comments on commit 04624a2

Please sign in to comment.