import React, { useEffect } from 'react' import { Box, Text } from 'ink' import { Header } from '../components/index.js' import { theme } from '../theme.js' import type { ChainConfig } from '../../types/config.js' export interface ChainListScreenProps { /** * List of configured chains */ chains: ChainConfig[] /** * Optional callback when the screen is ready to exit */ onExit?: () => void } /** * ChainListScreen displays all configured chains. * This replaces the console.log implementation in commands/config/chains.ts * * Features: * - Shows all chain details * - Clean, consistent formatting */ export function ChainListScreen({ chains, onExit }: ChainListScreenProps): React.ReactElement { // Auto-exit after rendering useEffect(() => { if (onExit) { onExit() } }, [onExit]) if (chains.length === 0) { return (
No chains configured Use "safe config chains add" to add a chain ) } return (
{/* Chain list */} {chains.map((chain, index) => ( {chain.name} (Chain ID: {chain.chainId}) Short name: {chain.shortName} RPC: {chain.rpcUrl} {chain.explorer && ( Explorer: {chain.explorer} )} Currency: {chain.currency} ))} {/* Summary */} Total: {chains.length} chain(s) configured ) }