diff --git a/packages/page-staking-async/src/Validators/SummarySession.tsx b/packages/page-staking-async/src/Validators/SummarySession.tsx index dcbd63b69b..f7760ea23f 100644 --- a/packages/page-staking-async/src/Validators/SummarySession.tsx +++ b/packages/page-staking-async/src/Validators/SummarySession.tsx @@ -53,10 +53,12 @@ function SummarySession ({ className, withEra = true, withSession = true }: Prop const eraDuration = useMemo( () => { - // default to 1800 blocks i.e. 6 hours - return new BN(6 * 60 * 60 * 1000).div(blockTime); + const epochDuration = rcApi?.consts.babe?.epochDuration; + const sessionsPerEra = api?.consts.staking?.sessionsPerEra; + + return epochDuration?.mul(sessionsPerEra); }, - [blockTime] + [api?.consts.staking?.sessionsPerEra, rcApi?.consts.babe?.epochDuration] ); return ( @@ -91,6 +93,7 @@ function SummarySession ({ className, withEra = true, withSession = true }: Prop ) )} , t: TFunction, { address, balanceDisplay, balancesAll, bestNumber, convictionLocks, democracyLocks, isAllLocked, otherBonded, ownBonded, stakingInfo, votingOf, withBalanceToggle, withLabel }: { address: string; balanceDisplay: BalanceActiveType; balancesAll?: DeriveBalancesAll | DeriveBalancesAccountData; bestNumber?: BlockNumber; convictionLocks?: RefLock[]; democracyLocks?: DeriveDemocracyLock[]; isAllLocked: boolean; otherBonded: BN[]; ownBonded: BN; stakingInfo?: DeriveStakingAccount; votingOf?: Voting; withBalanceToggle: boolean, withLabel: boolean }): React.ReactNode { +function createBalanceItems (formatIndex: number, lookup: Record, t: TFunction, { address, apiOverride, balanceDisplay, balancesAll, bestNumber, convictionLocks, democracyLocks, isAllLocked, otherBonded, ownBonded, stakingInfo, votingOf, withBalanceToggle, withLabel }: { address: string; apiOverride: ApiPromise | undefined, balanceDisplay: BalanceActiveType; balancesAll?: DeriveBalancesAll | DeriveBalancesAccountData; bestNumber?: BlockNumber; convictionLocks?: RefLock[]; democracyLocks?: DeriveDemocracyLock[]; isAllLocked: boolean; otherBonded: BN[]; ownBonded: BN; stakingInfo?: DeriveStakingAccount; votingOf?: Voting; withBalanceToggle: boolean, withLabel: boolean }): React.ReactNode { const allItems: React.ReactNode[] = []; const deriveBalances = balancesAll as DeriveBalancesAll; @@ -293,7 +295,10 @@ function createBalanceItems (formatIndex: number, lookup: Record >

{formatBalance(locked, { forceUnit: '-' })} {t('fully vested in')}

- +
(Block {formatNumber(endBlock)} @ {formatBalance(perBlock)}/block) @@ -526,7 +531,7 @@ function createBalanceItems (formatIndex: number, lookup: Record ); } -function renderBalances (props: Props, lookup: Record, bestNumber: BlockNumber | undefined, t: TFunction): React.ReactNode[] { +function renderBalances (props: Props, lookup: Record, bestNumber: BlockNumber | undefined, apiOverride: ApiPromise | undefined, t: TFunction): React.ReactNode[] { const { address, balancesAll, convictionLocks, democracyLocks, stakingInfo, votingOf, withBalance = true, withBalanceToggle = false, withLabel = false } = props; const balanceDisplay = withBalance === true ? DEFAULT_BALANCES @@ -538,7 +543,7 @@ function renderBalances (props: Props, lookup: Record, bestNumbe const [ownBonded, otherBonded] = calcBonded(stakingInfo, balanceDisplay.bonded); const isAllLocked = !!balancesAll && balancesAll.lockedBreakdown.some(({ amount }): boolean => amount?.isMax()); - const baseOpts = { address, balanceDisplay, bestNumber, convictionLocks, democracyLocks, isAllLocked, otherBonded, ownBonded, votingOf, withBalanceToggle, withLabel }; + const baseOpts = { address, apiOverride, balanceDisplay, bestNumber, convictionLocks, democracyLocks, isAllLocked, otherBonded, ownBonded, votingOf, withBalanceToggle, withLabel }; const items = [createBalanceItems(0, lookup, t, { ...baseOpts, balancesAll, stakingInfo })]; withBalanceToggle && balancesAll?.additional.length && balancesAll.additional.forEach((balancesAll, index): void => { @@ -551,6 +556,7 @@ function renderBalances (props: Props, lookup: Record, bestNumbe function AddressInfo (props: Props): React.ReactElement { const { t } = useTranslation(); const bestNumber = useBestNumberRelay(); + const { isStakingAsync, rcApi } = useStakingAsyncApis(); const { children, className = '', extraInfo, withBalanceToggle, withHexSessionId } = props; const lookup = useRef>({ @@ -564,7 +570,7 @@ function AddressInfo (props: Props): React.ReactElement { return (
- {renderBalances(props, lookup.current, bestNumber, t)} + {renderBalances(props, lookup.current, bestNumber, isStakingAsync ? rcApi : undefined, t)} {withHexSessionId?.[0] && ( <>