'use client' import Link from 'next/link' import { FC, useEffect, useState } from 'react' import { Card, CardContent, CardFooter } from '@/components/ui/card' import { Spinner } from '@/components/ui/spinner' import { useInkathon } from '@scio-labs/use-inkathon' import { HiOutlineExternalLink } from 'react-icons/hi' export const ChainInfo: FC = () => { const { api, activeChain } = useInkathon() const [chainInfo, setChainInfo] = useState<{ [_: string]: any }>() // Fetch Chain Info const fetchChainInfo = async () => { if (!api) { setChainInfo(undefined) return } const chain = (await api.rpc.system.chain())?.toString() || '' const version = (await api.rpc.system.version())?.toString() || '' const properties = ((await api.rpc.system.properties())?.toHuman() as any) || {} const tokenSymbol = properties?.tokenSymbol?.[0] || 'UNIT' const tokenDecimals = properties?.tokenDecimals?.[0] || 12 const chainInfo = { Chain: chain, Version: version, Token: `${tokenSymbol} (${tokenDecimals} Decimals)`, } setChainInfo(chainInfo) } useEffect(() => { fetchChainInfo() }, [api]) // Connection Loading Indicator if (!api) return (
Connecting to {activeChain?.name} ({activeChain?.rpcUrls?.[0]})
) return ( <>

Chain Info

{/* Metadata */} {Object.entries(chainInfo || {}).map(([key, value]) => (
{key}: {value}
))}
{/* Explorer Link */} {!!activeChain?.explorerUrls && !!Object.keys(activeChain.explorerUrls)?.length && ( Explorer )} {/* Faucet Link */} {!!activeChain?.faucetUrls?.length && ( Faucet )} {/* Contracts UI Link */} {!!activeChain?.rpcUrls?.length && ( Contracts UI )}
{/* Mainnet Security Disclaimer */} {!activeChain?.testnet && ( <>

Security Disclaimer

You are interacting with un-audited mainnet contracts and risk all your funds. Never transfer tokens to this contract. )}
) }