Display lifecycle in all tables (#4848)
This commit is contained in:
parent
062f8b30e9
commit
3a3b043d7d
@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Option, Vec } from '@polkadot/types';
|
||||
import type { AccountId, BlockNumber, HeadData, Header, ParaId } from '@polkadot/types/interfaces';
|
||||
import type { AccountId, BlockNumber, HeadData, Header, ParaId, ParaLifecycle } from '@polkadot/types/interfaces';
|
||||
import type { Codec } from '@polkadot/types/types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
@ -26,10 +26,11 @@ interface Props {
|
||||
validators?: AccountId[];
|
||||
}
|
||||
|
||||
type QueryResult = [Option<HeadData>, Option<BlockNumber>, Vec<Codec>, Vec<Codec>, Vec<Codec>, Vec<Codec>, Option<BlockNumber>];
|
||||
type QueryResult = [Option<HeadData>, Option<BlockNumber>, Option<ParaLifecycle>, Vec<Codec>, Vec<Codec>, Vec<Codec>, Vec<Codec>, Option<BlockNumber>];
|
||||
|
||||
interface QueryState {
|
||||
headHex: string | null;
|
||||
lifecycle: ParaLifecycle | null;
|
||||
updateAt: BlockNumber | null;
|
||||
qDmp: number;
|
||||
qUmp: number;
|
||||
@ -45,6 +46,7 @@ const transformHeader = {
|
||||
const optionsMulti = {
|
||||
defaultValue: {
|
||||
headHex: null,
|
||||
lifecycle: null,
|
||||
qDmp: 0,
|
||||
qHrmpE: 0,
|
||||
qHrmpI: 0,
|
||||
@ -52,10 +54,11 @@ const optionsMulti = {
|
||||
updateAt: null,
|
||||
watermark: null
|
||||
},
|
||||
transform: ([headData, optUp, dmp, ump, hrmpE, hrmpI, optWm]: QueryResult): QueryState => ({
|
||||
transform: ([headData, optUp, optLifecycle, dmp, ump, hrmpE, hrmpI, optWm]: QueryResult): QueryState => ({
|
||||
headHex: headData.isSome
|
||||
? sliceHex(headData.unwrap(), 12)
|
||||
? sliceHex(headData.unwrap())
|
||||
: null,
|
||||
lifecycle: optLifecycle.unwrapOr(null),
|
||||
qDmp: dmp.length,
|
||||
qHrmpE: hrmpE.length,
|
||||
qHrmpI: hrmpI.length,
|
||||
@ -73,6 +76,7 @@ function Parachain ({ bestNumber, className = '', id, isScheduled, lastBacked, l
|
||||
const paraInfo = useCallMulti<QueryState>([
|
||||
[api.query.paras.heads, id],
|
||||
[api.query.paras.futureCodeUpgrades, id],
|
||||
[api.query.paras.paraLifecycles, id],
|
||||
[api.query.dmp.downwardMessageQueues, id],
|
||||
[api.query.ump.relayDispatchQueues, id],
|
||||
[api.query.hrmp.hrmpEgressChannelsIndex, id],
|
||||
@ -119,7 +123,11 @@ function Parachain ({ bestNumber, className = '', id, isScheduled, lastBacked, l
|
||||
/>
|
||||
)}
|
||||
</td>
|
||||
<td className='all start together hash'>{paraInfo.headHex}</td>
|
||||
<td className='start together hash'>{paraInfo.headHex}</td>
|
||||
<td className='start media--1100'>
|
||||
{paraInfo.lifecycle && paraInfo.lifecycle.toString()}
|
||||
</td>
|
||||
<td className='all' />
|
||||
<td className='number'>{blockDelay && <BlockToTime blocks={blockDelay} />}</td>
|
||||
<td className='number'>
|
||||
{lastInclusion
|
||||
|
||||
@ -109,6 +109,8 @@ function ParachainList ({ ids, scheduled }: Props): React.ReactElement<Props> {
|
||||
[t('parachains'), 'start', 3],
|
||||
['', 'media--1500'],
|
||||
[t('heads'), 'start'],
|
||||
[t('lifecycle'), 'start media--1100'],
|
||||
[],
|
||||
[t('included'), undefined, 2],
|
||||
[t('backed')],
|
||||
[t('chain best'), 'media--900'],
|
||||
|
||||
@ -74,14 +74,15 @@ function Upcoming ({ currentPeriod, id }: Props): React.ReactElement<Props> {
|
||||
<tr key={id.toString()}>
|
||||
<td className='number'><h1>{formatNumber(id)}</h1></td>
|
||||
<td className='badge together'><ParaLink id={id} /></td>
|
||||
<td className='all start together hash'>
|
||||
<td className='start together hash'>
|
||||
{upcomingGenesis && (
|
||||
sliceHex(upcomingGenesis.genesisHead, 8)
|
||||
sliceHex(upcomingGenesis.genesisHead)
|
||||
)}
|
||||
</td>
|
||||
<td className='number'>
|
||||
<td className='start'>
|
||||
{lifecycle && lifecycle.toString()}
|
||||
</td>
|
||||
<td className='all' />
|
||||
<td className='start together'>
|
||||
{currentPeriod &&
|
||||
leases.map(({ period }) => formatNumber(currentPeriod.addn(period))).join(', ')
|
||||
|
||||
@ -21,8 +21,9 @@ function UpcomingList ({ currentPeriod, ids }: Props): React.ReactElement<Props>
|
||||
|
||||
const headerRef = useRef([
|
||||
[t('upcoming'), 'start', 2],
|
||||
[t('genesis'), 'start all'],
|
||||
[t('lifecycle'), 'number'],
|
||||
[t('genesis'), 'start'],
|
||||
[t('lifecycle'), 'start'],
|
||||
[],
|
||||
[t('leases'), 'start'],
|
||||
[t('parachain'), 'start']
|
||||
]);
|
||||
|
||||
@ -43,7 +43,7 @@ function Proposal ({ approvedIds, id, scheduled }: Props): React.ReactElement<Pr
|
||||
);
|
||||
|
||||
const initialHex = useMemo(
|
||||
() => proposal?.proposal && sliceHex(proposal.proposal.genesisHead, 8),
|
||||
() => proposal?.proposal && sliceHex(proposal.proposal.genesisHead),
|
||||
[proposal]
|
||||
);
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
|
||||
import type { Codec } from '@polkadot/types/types';
|
||||
|
||||
export function sliceHex (value: Codec, max: number): string {
|
||||
export function sliceHex (value: Codec, max = 8): string {
|
||||
const hex = value.toHex();
|
||||
|
||||
return hex.length > ((2 * max) + 2)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user