From 066e5eca04208afbe3972b5434eb868e1d4bd86a Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Sun, 29 Nov 2020 18:34:19 +0100 Subject: [PATCH] Display last target payout (#4101) * Ensure identity filter applies to all targets * Name filter removes flags * Revert * Apply query filters to override toggles * Display last target payout --- packages/page-staking/src/Targets/Validator.tsx | 3 ++- packages/page-staking/src/Targets/index.tsx | 1 + packages/page-staking/src/types.ts | 1 + packages/page-staking/src/useSortedTargets.ts | 2 ++ 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/page-staking/src/Targets/Validator.tsx b/packages/page-staking/src/Targets/Validator.tsx index 66499c5e38..6ddfb29e7c 100644 --- a/packages/page-staking/src/Targets/Validator.tsx +++ b/packages/page-staking/src/Targets/Validator.tsx @@ -63,7 +63,7 @@ function Validator ({ allSlashes, canSelect, filterName, info, isNominated, isSe return null; } - const { accountId, bondOther, bondOwn, bondTotal, commissionPer, isCommission, isElected, isFavorite, key, numNominators, rankOverall, stakedReturnCmp, validatorPayment } = info; + const { accountId, bondOther, bondOwn, bondTotal, commissionPer, isCommission, isElected, isFavorite, key, lastPayout, numNominators, rankOverall, stakedReturnCmp, validatorPayment } = info; return ( @@ -108,6 +108,7 @@ function Validator ({ allSlashes, canSelect, filterName, info, isNominated, isSe + {lastPayout && formatNumber(lastPayout)} {numNominators || ''} { diff --git a/packages/page-staking/src/Targets/index.tsx b/packages/page-staking/src/Targets/index.tsx index 411a44db18..6888479cf7 100644 --- a/packages/page-staking/src/Targets/index.tsx +++ b/packages/page-staking/src/Targets/index.tsx @@ -221,6 +221,7 @@ function Targets ({ className = '', isInElection, ownStashes, targets: { avgStak const header = useMemo(() => [ [t('validators'), 'start', 3], + [t('paid'), 'media--1400'], ...(SORT_KEYS as (keyof typeof labelsRef.current)[]).map((header) => [ <>{labelsRef.current[header]}, `${sorted ? `isClickable ${sortBy === header ? 'highlight--border' : ''} number` : 'number'} ${CLASSES[header] || ''}`, diff --git a/packages/page-staking/src/types.ts b/packages/page-staking/src/types.ts index e8362acc80..673d565d69 100644 --- a/packages/page-staking/src/types.ts +++ b/packages/page-staking/src/types.ts @@ -53,6 +53,7 @@ export interface ValidatorInfo extends ValidatorInfoRank { isFavorite: boolean; isNominating: boolean; key: string; + lastPayout?: BN; numNominators: number; rewardSplit: BN; skipRewards: boolean; diff --git a/packages/page-staking/src/useSortedTargets.ts b/packages/page-staking/src/useSortedTargets.ts index 12bdbae3b2..3c0c2f8485 100644 --- a/packages/page-staking/src/useSortedTargets.ts +++ b/packages/page-staking/src/useSortedTargets.ts @@ -103,6 +103,7 @@ function extractSingle (allAccounts: string[], derive: DeriveStakingElected | De return isNominating || allAccounts.includes(nominator); }, allAccounts.includes(key)); const isElected = !isWaitingDerive(derive) && derive.nextElected.some((e) => e.eq(accountId)); + const lastPayout = stakingLedger.claimedRewards[stakingLedger.claimedRewards.length - 1]; return { accountId, @@ -118,6 +119,7 @@ function extractSingle (allAccounts: string[], derive: DeriveStakingElected | De isFavorite: favorites.includes(key), isNominating, key, + lastPayout, numNominators: (exposure.others || []).length, rankBondOther: 0, rankBondOwn: 0,