@@ -4,6 +4,8 @@ import GeneralTableWithButtons from '@/components/table/GeneralTableWithButtons'
44import WalletStatus from '@/components/walletStatus/WalletStatus'
55import { network_list } from '@/config/network'
66import { ParachainInfo , ParachainState } from '@/hooks/useParachainInfo'
7+ import { useCurrentRelayBlockNumber } from '@/hooks/useSubstrateQuery'
8+ import { blocksToTimeFormat } from '@/utils/broker/blockTime'
79import { useInkathon } from '@poppyseed/lastic-sdk'
810import { ChangeEvent , useState } from 'react'
911
@@ -14,14 +16,30 @@ const statusColors = {
1416 Reserved : 'bg-red-200' ,
1517 Onboarding : 'bg-purple-200' ,
1618 Parathread : 'bg-indigo-200' ,
17- 'Idle( In workplan) ' : 'bg-pink-200' ,
19+ 'Idle - In workplan' : 'bg-pink-200' ,
1820 'Holding Slot' : 'bg-orange-200' ,
1921}
2022
23+ const statusDescriptions = {
24+ 'System Chain' :
25+ 'A system chain is the main chain of a blockchain network, responsible for its core functionality.' ,
26+ 'Currently Active' :
27+ 'An active parachain is currently producing blocks and participating in the relay chain.' ,
28+ 'Idle Chain' : 'An idle chain is not currently active or producing blocks.' ,
29+ Reserved : 'Reserved parachains have slots that are reserved but not yet active.' ,
30+ Onboarding : 'Parachains that are currently in the process of onboarding to the network.' ,
31+ Parathread :
32+ 'Parathreads are parachains that are not continuously active but can participate in the network on demand.' ,
33+ 'Idle - In workplan' :
34+ 'Idle parachains that are included in a work plan but are not currently active.' ,
35+ 'Holding Slot' : 'Parachains that hold a slot but are not actively producing blocks.' ,
36+ }
37+
2138const ParaIdFetch = ( { parachains } : { parachains : ParachainInfo [ ] } ) => {
22- const { activeChain } = useInkathon ( )
39+ const { activeChain, relayApi } = useInkathon ( )
2340 const [ filter , setFilter ] = useState < string > ( 'all' )
2441 const [ paraIdSET , setParaId ] = useState < number | null > ( null )
42+ const currentBlockNumber = useCurrentRelayBlockNumber ( relayApi )
2543
2644 if ( ! activeChain ) {
2745 return (
@@ -57,6 +75,7 @@ const ParaIdFetch = ({ parachains }: { parachains: ParachainInfo[] }) => {
5775 < button
5876 onClick = { ( ) => setFilter ( 'all' ) }
5977 className = { `px-4 py-2 rounded-full text-black dark:text-white ${ filter === 'all' ? 'font-bold' : '' } ` }
78+ title = "Show all parachains"
6079 >
6180 All
6281 </ button >
@@ -65,6 +84,7 @@ const ParaIdFetch = ({ parachains }: { parachains: ParachainInfo[] }) => {
6584 key = { stateKey }
6685 onClick = { ( ) => setFilter ( stateValue ) }
6786 className = { `px-4 py-2 rounded-full text-black ${ statusColors [ stateValue ] } ${ filter === stateValue ? 'font-bold' : '' } ` }
87+ title = { statusDescriptions [ stateValue ] }
6888 >
6989 { stateValue }
7090 </ button >
@@ -74,17 +94,24 @@ const ParaIdFetch = ({ parachains }: { parachains: ParachainInfo[] }) => {
7494 { filteredParachains . length > 0 ? (
7595 < div className = "w-full overflow-x-auto" >
7696 < GeneralTableWithButtons
77- tableData = { filteredParachains . map ( ( { paraId, state, network } , idx ) => ( {
78- data : [
79- paraId . toString ( ) ,
80- network_list [ network ] ?. paraId [ paraId . toString ( ) ] ?. name ,
81- network_list [ network ] ?. paraId [ paraId . toString ( ) ] ?. description ,
82- < span key = { idx } className = { `${ statusColors [ state ] } px-4 py-1 rounded-full` } >
83- { state }
84- </ span > ,
85- network_list [ network ] ?. paraId [ paraId . toString ( ) ] ?. lease ?. toString ( ) ,
86- ] ,
87- } ) ) }
97+ tableData = { filteredParachains . map ( ( { paraId, state, network } , idx ) => {
98+ const leaseEndBlock = network_list [ network ] ?. paraId [ paraId . toString ( ) ] ?. lease
99+ const remainingBlocks =
100+ leaseEndBlock !== null && currentBlockNumber !== null
101+ ? leaseEndBlock - currentBlockNumber
102+ : null
103+ return {
104+ data : [
105+ paraId . toString ( ) ,
106+ network_list [ network ] ?. paraId [ paraId . toString ( ) ] ?. name ,
107+ network_list [ network ] ?. paraId [ paraId . toString ( ) ] ?. description ,
108+ < span key = { idx } className = { `${ statusColors [ state ] } px-4 py-1 rounded-full` } >
109+ { state }
110+ </ span > ,
111+ blocksToTimeFormat ( remainingBlocks , 'RELAY' ) ,
112+ ] ,
113+ }
114+ } ) }
88115 tableHeader = { [
89116 { title : 'ParaId' } ,
90117 { title : 'Name' } ,
0 commit comments