Display validator group indexes (#5349)
This commit is contained in:
parent
ac03a4776d
commit
cfb7204999
@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Option, Vec } from '@polkadot/types';
|
||||
import type { AccountId, BalanceOf, BlockNumber, CandidatePendingAvailability, HeadData, HrmpChannel, HrmpChannelId, ParaId, ParaInfo, ParaLifecycle } from '@polkadot/types/interfaces';
|
||||
import type { AccountId, BalanceOf, BlockNumber, CandidatePendingAvailability, GroupIndex, HeadData, HrmpChannel, HrmpChannelId, ParaId, ParaInfo, ParaLifecycle } from '@polkadot/types/interfaces';
|
||||
import type { Codec, ITuple } from '@polkadot/types/types';
|
||||
import type { LeasePeriod, QueuedAction } from '../types';
|
||||
import type { EventMapInfo, ValidatorInfo } from './types';
|
||||
@ -34,7 +34,7 @@ interface Props {
|
||||
leasePeriod?: LeasePeriod;
|
||||
nextAction?: QueuedAction;
|
||||
sessionValidators?: AccountId[] | null;
|
||||
validators?: ValidatorInfo[];
|
||||
validators?: [GroupIndex, ValidatorInfo[]];
|
||||
}
|
||||
|
||||
type QueryResult = [Option<HeadData>, Option<BlockNumber>, Option<ParaLifecycle>, Vec<Codec>, Vec<Codec>, Vec<Codec>, Vec<Codec>, Option<BlockNumber>, Option<CandidatePendingAvailability>, Option<ParaInfo>, Option<ITuple<[AccountId, BalanceOf]>>[]];
|
||||
@ -134,7 +134,10 @@ function Parachain ({ bestNumber, channelDst, channelSrc, className = '', id, la
|
||||
);
|
||||
|
||||
const valRender = useCallback(
|
||||
() => renderAddresses(validators?.map(({ validatorId }) => validatorId), validators?.map(({ indexValidator }) => indexValidator)),
|
||||
() => renderAddresses(
|
||||
validators && validators[1].map(({ validatorId }) => validatorId),
|
||||
validators && validators[1].map(({ indexValidator }) => indexValidator)
|
||||
),
|
||||
[validators]
|
||||
);
|
||||
|
||||
@ -165,10 +168,15 @@ function Parachain ({ bestNumber, channelDst, channelSrc, className = '', id, la
|
||||
<td className='number'><h1>{formatNumber(id)}</h1></td>
|
||||
<td className='badge'><ParaLink id={id} /></td>
|
||||
<td className='number media--1400'>
|
||||
{validators && validators.length !== 0 && (
|
||||
{validators && validators[1].length !== 0 && (
|
||||
<Expander
|
||||
renderChildren={valRender}
|
||||
summary={t<string>('Validators ({{count}})', { replace: { count: formatNumber(validators.length) } })}
|
||||
summary={t<string>('Val. Group {{group}} ({{count}})', {
|
||||
replace: {
|
||||
count: formatNumber(validators[1].length),
|
||||
group: validators[0]
|
||||
}
|
||||
})}
|
||||
/>
|
||||
)}
|
||||
{nonBacked && (
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
|
||||
import type { ApiPromise } from '@polkadot/api';
|
||||
import type { SignedBlockExtended } from '@polkadot/api-derive/types';
|
||||
import type { AccountId, CandidateReceipt, CoreAssignment, Event, ParaId, ParaValidatorIndex } from '@polkadot/types/interfaces';
|
||||
import type { AccountId, CandidateReceipt, CoreAssignment, Event, GroupIndex, ParaId, ParaValidatorIndex } from '@polkadot/types/interfaces';
|
||||
import type { IEvent } from '@polkadot/types/types';
|
||||
import type { LeasePeriod, QueuedAction, ScheduledProposals } from '../types';
|
||||
import type { EventMapInfo, ValidatorInfo } from './types';
|
||||
@ -61,9 +61,9 @@ function extractScheduledIds (scheduled: ScheduledProposals[] = []): Record<stri
|
||||
}), all), {});
|
||||
}
|
||||
|
||||
function mapValidators (startWith: Record<string, ValidatorInfo[]>, ids: ParaId[] | undefined, validators: AccountId[] | null, validatorGroups: ParaValidatorIndex[][] | null, activeIndices: ParaValidatorIndex[] | null, assignments: CoreAssignment[] | null): Record<string, ValidatorInfo[]> {
|
||||
function mapValidators (startWith: Record<string, [GroupIndex, ValidatorInfo[]]>, ids: ParaId[] | undefined, validators: AccountId[] | null, validatorGroups: ParaValidatorIndex[][] | null, activeIndices: ParaValidatorIndex[] | null, assignments: CoreAssignment[] | null): Record<string, [GroupIndex, ValidatorInfo[]]> {
|
||||
return assignments && activeIndices && validators && validatorGroups && ids
|
||||
? ids.reduce((all: Record<string, ValidatorInfo[]>, id) => {
|
||||
? ids.reduce((all: Record<string, [GroupIndex, ValidatorInfo[]]>, id) => {
|
||||
const assignment = assignments.find(({ paraId }) => paraId.eq(id));
|
||||
|
||||
if (!assignment) {
|
||||
@ -72,14 +72,17 @@ function mapValidators (startWith: Record<string, ValidatorInfo[]>, ids: ParaId[
|
||||
|
||||
return {
|
||||
...all,
|
||||
[id.toString()]: validatorGroups[assignment.groupIdx.toNumber()]
|
||||
.map((indexActive) => [indexActive, activeIndices[indexActive.toNumber()]])
|
||||
.filter(([, a]) => a)
|
||||
.map(([indexActive, indexValidator]) => ({
|
||||
indexActive,
|
||||
indexValidator,
|
||||
validatorId: validators[indexValidator.toNumber()]
|
||||
}))
|
||||
[id.toString()]: [
|
||||
assignment.groupIdx,
|
||||
validatorGroups[assignment.groupIdx.toNumber()]
|
||||
.map((indexActive) => [indexActive, activeIndices[indexActive.toNumber()]])
|
||||
.filter(([, a]) => a)
|
||||
.map(([indexActive, indexValidator]) => ({
|
||||
indexActive,
|
||||
indexValidator,
|
||||
validatorId: validators[indexValidator.toNumber()]
|
||||
}))
|
||||
]
|
||||
};
|
||||
}, { ...startWith })
|
||||
: startWith;
|
||||
@ -163,7 +166,7 @@ function Parachains ({ actionsQueue, ids, leasePeriod, scheduled }: Props): Reac
|
||||
], optionsMulti);
|
||||
const hrmp = useHrmp();
|
||||
const hasLinksMap = useIsParasLinked(ids);
|
||||
const [validatorMap, setValidatorMap] = useState<Record<string, ValidatorInfo[]>>({});
|
||||
const [validatorMap, setValidatorMap] = useState<Record<string, [GroupIndex, ValidatorInfo[]]>>({});
|
||||
|
||||
const headerRef = useRef([
|
||||
[t('parachains'), 'start', 2],
|
||||
|
||||
Loading…
Reference in New Issue
Block a user