@@ -166,6 +166,22 @@ const CopyableAddress = ({
166166 )
167167}
168168
169+ const getNetworkStatusUrl = ( network : NetworkData ) : string | null => {
170+ if ( network . networkStatus ) {
171+ return network . networkStatus
172+ }
173+
174+ if ( network . mainnet ?. explorerUrl ) {
175+ try {
176+ return new URL ( network . mainnet . explorerUrl . replace ( "%s" , "" ) ) . origin
177+ } catch {
178+ return null
179+ }
180+ }
181+
182+ return null
183+ }
184+
169185const DefaultTHead = ( { showExtraDetails, networkName } : { showExtraDetails : boolean ; networkName : string } ) => {
170186 const isAptosNetwork = networkName === "Aptos Mainnet" || networkName === "Aptos Testnet"
171187
@@ -495,6 +511,7 @@ export const StreamsNetworkAddressesTable = () => {
495511 </ thead >
496512 < tbody >
497513 { filteredNetworks . map ( ( network : NetworkData , index : number ) => {
514+ const statusUrl = getNetworkStatusUrl ( network )
498515 return (
499516 < Fragment key = { network . network } >
500517 { network . mainnet &&
@@ -598,42 +615,22 @@ export const StreamsNetworkAddressesTable = () => {
598615 </ td >
599616 </ tr >
600617 ) }
601-
602- { ( ( ) => {
603- // If network.networkStatus is available, use it
604- // otherwise, fall back to the explorer URL
605- const statusUrl = network . networkStatus
606- ? network . networkStatus
607- : network . mainnet ?. explorerUrl
608- ? ( ( ) => {
609- try {
610- const url = new URL ( network . mainnet . explorerUrl . replace ( "%s" , "" ) )
611- return `${ url . protocol } //${ url . host } `
612- } catch {
613- return null
614- }
615- } ) ( )
616- : null
617-
618- if ( ! statusUrl ) return null
619-
620- return (
621- < tr key = { `${ network . network } -status-explorer` } className = { tableStyles . statusRow } >
622- < td colSpan = { 3 } className = { tableStyles . statusCell } >
623- < div style = { { display : "flex" , gap : "1rem" , justifyContent : "flex-end" } } >
624- < a
625- href = { statusUrl }
626- target = "_blank"
627- rel = "noopener noreferrer"
628- className = { tableStyles . statusLink }
629- >
630- View { network . network } Network Status →
631- </ a >
632- </ div >
633- </ td >
634- </ tr >
635- )
636- } ) ( ) }
618+ { statusUrl && (
619+ < tr key = { `${ network . network } -status-explorer` } className = { tableStyles . statusRow } >
620+ < td colSpan = { 3 } className = { tableStyles . statusCell } >
621+ < div style = { { display : "flex" , gap : "1rem" , justifyContent : "flex-end" } } >
622+ < a
623+ href = { statusUrl }
624+ target = "_blank"
625+ rel = "noopener noreferrer"
626+ className = { tableStyles . statusLink }
627+ >
628+ View { network . network } Network Status →
629+ </ a >
630+ </ div >
631+ </ td >
632+ </ tr >
633+ ) }
637634 </ Fragment >
638635 )
639636 } ) }
0 commit comments