import React, { useEffect } from 'react' import { Box, Text } from 'ink' import { Header, List } from '../components/index.js' import { theme } from '../theme.js' export interface TransactionImportBuilderSuccessScreenProps { /** * Safe address in EIP-3770 format */ safeEip3770: string /** * Chain ID */ chainId: string /** * Batch name (if provided) */ batchName?: string /** * Batch description (if provided) */ batchDescription?: string /** * List of imported transaction hashes */ importedTxHashes: string[] /** * Optional callback when the screen is ready to exit */ onExit?: () => void } /** * TransactionImportBuilderSuccessScreen displays success after importing from Transaction Builder. * This replaces the console.log implementation in commands/tx/import.ts * * Features: * - Shows batch metadata (name, description) * - Lists all imported transaction hashes * - Displays next steps for signing */ export function TransactionImportBuilderSuccessScreen({ safeEip3770, chainId, batchName, batchDescription, importedTxHashes, onExit, }: TransactionImportBuilderSuccessScreenProps): React.ReactElement { // Auto-exit after rendering useEffect(() => { if (onExit) { onExit() } }, [onExit]) const isSingle = importedTxHashes.length === 1 return (
{/* Batch metadata */} {batchName && ( Batch: {batchName} )} {batchDescription && ( Description: {batchDescription} )} Safe: {safeEip3770} Chain: {chainId} {/* Imported transactions */} Successfully imported {importedTxHashes.length} transaction{isSingle ? '' : 's'} {importedTxHashes.length <= 5 && ( ({ label: hash, icon: theme.icons.success, iconColor: theme.colors.success, }))} renderItem={(item) => ( {item.icon} {item.label} )} /> )} {/* Next steps */} Next steps: {isSingle ? ( <> safe tx sign {importedTxHashes[0]} (sign the transaction) safe tx status {importedTxHashes[0]} (check status) ) : ( <> safe tx list (view all transactions) safe tx sign {''} (sign each transaction) )} ) }