diff --git a/packages/page-staking/src/Overview/SummaryNominators.tsx b/packages/page-staking/src/Overview/SummaryNominators.tsx index 4546484bad24..e0b2398f3f0d 100644 --- a/packages/page-staking/src/Overview/SummaryNominators.tsx +++ b/packages/page-staking/src/Overview/SummaryNominators.tsx @@ -4,6 +4,7 @@ import React from 'react'; import { Card, CardSummary, MarkWarning, SummaryBox } from '@polkadot/react-components'; +import { useApi } from '@polkadot/react-hooks'; import { FormatBalance } from '@polkadot/react-query'; import { formatNumber } from '@polkadot/util'; @@ -23,6 +24,12 @@ function SummaryNominators ({ targets: { maxNominatorsCount, nominatorMinActiveThreshold } }: Props) { const { t } = useTranslation(); + const { api } = useApi(); + + const maxElectingVotersDefined = !!api.consts.electionProviderMultiPhase?.maxElectingVoters; + const maxNominatorDefined = !!api.query.staking.maxNominatorsCount; + const minNominatorBondDefined = !!api.query.staking.minNominatorBond; + return ( <> @@ -33,9 +40,11 @@ function SummaryNominators ({ targets: { maxNominatorsCount, help={t('Maximum number of nominator intentions.')} label={t('maximum')} > - - {formatNumber(maxNominatorsCount?.toNumber())} - + {maxNominatorDefined + ? + {formatNumber(maxNominatorsCount?.toNumber())} + + : '-'}
@@ -43,11 +52,11 @@ function SummaryNominators ({ targets: { maxNominatorsCount, help={t('Number of electing nominators.')} label={t('electing')} > - {nominatorMaxElectingCount === null - ? <>- - : + {maxElectingVotersDefined + ? {formatNumber(nominatorMaxElectingCount)} - } + + : '-'}
@@ -67,12 +76,14 @@ function SummaryNominators ({ targets: { maxNominatorsCount, help={t('Threshold stake to intend nomination.')} label={t('intention thrs')} > - - - + {minNominatorBondDefined + ? + + + : '-'}
diff --git a/packages/page-staking/src/Overview/SummaryValidators.tsx b/packages/page-staking/src/Overview/SummaryValidators.tsx index 18934cc7f310..b2517cca25e2 100644 --- a/packages/page-staking/src/Overview/SummaryValidators.tsx +++ b/packages/page-staking/src/Overview/SummaryValidators.tsx @@ -4,6 +4,7 @@ import React from 'react'; import { Card, CardSummary, SummaryBox } from '@polkadot/react-components'; +import { useApi } from '@polkadot/react-hooks'; import { FormatBalance } from '@polkadot/react-query'; import { formatNumber } from '@polkadot/util'; @@ -24,6 +25,10 @@ function SummaryValidators ({ targets: validatorMinActiveThreshold, waitingIds } }: Props) { const { t } = useTranslation(); + const { api } = useApi(); + + const maxValidatorDefined = !!api.query.staking.maxValidatorsCount; + const minValidatorBondDefined = !!api.query.staking.minValidatorBond; return ( @@ -34,9 +39,11 @@ function SummaryValidators ({ targets: help={t('Maximum number of validator intentions.')} label={t('max intention')} > - - {maxValidatorsCount?.toNumber()} - + {maxValidatorDefined + ? + {maxValidatorsCount?.toNumber()} + + : '-'}
@@ -66,12 +73,14 @@ function SummaryValidators ({ targets: help={t('Threshold stake among intended validators.')} label={t('intention thrs')} > - - - + {minValidatorBondDefined + ? + + + : '-'}
diff --git a/packages/page-staking/src/useSortedTargets.ts b/packages/page-staking/src/useSortedTargets.ts index 38cee952f7b9..a6151a1f9b9c 100644 --- a/packages/page-staking/src/useSortedTargets.ts +++ b/packages/page-staking/src/useSortedTargets.ts @@ -288,13 +288,14 @@ function useSortedTargetsImpl (favorites: string[], withLedger: boolean): Sorted api.query.staking.minValidatorBond, api.query.balances?.totalIssuance ], OPT_MULTI); + const electedInfo = useCall(api.derive.staking.electedInfo, [{ ...DEFAULT_FLAGS_ELECTED, withLedger }]); const waitingInfo = useCall(api.derive.staking.waitingInfo, [{ ...DEFAULT_FLAGS_WAITING, withLedger }]); const lastEraInfo = useCall(api.derive.session.info, undefined, OPT_ERA); const [stakers, setStakers] = useState<[StorageKey<[u32, AccountId32]>, PalletStakingExposure][]>([]); const [stakersTotal, setStakersTotal] = useState(); const [nominatorMinActiveThreshold, setNominatorMinActiveThreshold] = useState(''); - const [nominatorMaxElectingCount, setNominatorMaxElectingCount] = useState(); + const [nominatorMaxElectingCount, setNominatorMaxElectingCount] = useState(); const [nominatorElectingCount, setNominatorElectingCount] = useState(); const [nominatorActiveCount, setNominatorActiveCount] = useState(); const [validatorActiveCount, setValidatorActiveCount] = useState(); @@ -323,7 +324,7 @@ function useSortedTargetsImpl (favorites: string[], withLedger: boolean): Sorted nominatorStakes.sort((a, b) => a[1].cmp(b[1])); - setNominatorMaxElectingCount(api.consts.electionProviderMultiPhase?.maxElectingVoters || null); + setNominatorMaxElectingCount(api.consts.electionProviderMultiPhase?.maxElectingVoters); setNominatorElectingCount(assignments.size); setNominatorActiveCount(assignments.size);