Skip to content

Commit

Permalink
Explorer update validator table on home page (MystenLabs#7769)
Browse files Browse the repository at this point in the history
Currently the validator table on the home page does not include
delegated stakes and rewards this address that.
  • Loading branch information
Jibz1 authored Jan 27, 2023
1 parent 10db0c4 commit d325a0a
Showing 1 changed file with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,20 @@ import { PlaceholderTable } from '~/ui/PlaceholderTable';
import { TableCard } from '~/ui/TableCard';
import { Text } from '~/ui/Text';
import { getName } from '~/utils/getName';
import { getStakedPercent } from '~/utils/getStakedPercent';

const NUMBER_OF_VALIDATORS = 10;

export function processValidators(set: ActiveValidator[], totalStake: bigint) {
export function processValidators(set: ActiveValidator[]) {
return set.map((av) => {
const rawName = av.fields.metadata.fields.name;
const delegatedStake =
+av.fields.delegation_staking_pool.fields.sui_balance;
const selfStake = +av.fields.stake_amount;
const totalValidatorStake = selfStake + delegatedStake;
return {
name: getName(rawName),
address: av.fields.metadata.fields.sui_address,
stake: av.fields.stake_amount,
stakePercent: getStakedPercent(av.fields.stake_amount, totalStake),
stake: totalValidatorStake,
logo:
typeof av.fields.metadata.fields.image_url === 'string'
? av.fields.metadata.fields.image_url
Expand All @@ -45,13 +47,8 @@ const validatorsTable = (
limit?: number,
showIcon?: boolean
) => {
const totalStake = BigInt(
validatorsData.validators.fields.total_validator_stake
);

const validators = processValidators(
validatorsData.validators.fields.active_validators,
totalStake
validatorsData.validators.fields.active_validators
).sort((a, b) =>
a.name.localeCompare(b.name, 'en', {
sensitivity: 'base',
Expand Down

0 comments on commit d325a0a

Please sign in to comment.