import React, { useEffect } from 'react' import { Box, Text } from 'ink' import { Header, KeyValue, List } from '../components/index.js' import { theme } from '../theme.js' import type { Address } from 'viem' export interface TransactionImportSuccessScreenProps { /** * Transaction hash (safeTxHash) */ safeTxHash: string /** * Safe address or name */ safe: string /** * Target address of the transaction */ to: Address /** * Import mode: 'new' for new transaction, 'merged' for signature merge */ mode: 'new' | 'merged' /** * Number of signatures in the transaction */ signatureCount: number /** * Safe threshold (if known) */ threshold?: number /** * List of newly imported signers (for merged mode) */ newSigners?: Address[] /** * Whether transaction is ready to execute */ readyToExecute: boolean /** * Optional callback when the screen is ready to exit */ onExit?: () => void } /** * TransactionImportSuccessScreen displays success after importing CLI format transaction. * This replaces the console.log implementation in commands/tx/import.ts * * Features: * - Shows transaction details (hash, safe, target) * - Displays mode (new import or signature merge) * - Lists newly imported signers (for merged mode) * - Shows signature progress and execution readiness * - Displays appropriate next steps */ export function TransactionImportSuccessScreen({ safeTxHash, safe, to, mode, signatureCount, threshold, newSigners, readyToExecute, onExit, }: TransactionImportSuccessScreenProps): React.ReactElement { // Auto-exit after rendering useEffect(() => { if (onExit) { onExit() } }, [onExit]) const title = mode === 'new' ? 'Transaction Imported' : 'Signatures Merged' const modeColor = mode === 'new' ? theme.colors.success : theme.colors.info return (
{/* Transaction details */} {/* New signers (for merged mode) */} {mode === 'merged' && newSigners && newSigners.length > 0 && ( Imported {newSigners.length} new signature{newSigners.length !== 1 ? 's' : ''}: ({ label: signer, icon: theme.icons.success, iconColor: theme.colors.success, }))} renderItem={(item) => ( {item.icon} {item.label} )} /> )} {/* Signature status */} Signatures: {signatureCount} {threshold !== undefined && ` / ${threshold}`} {/* Ready to execute indicator */} {readyToExecute && ( ✓ Transaction ready to execute! )} {/* Next steps */} {readyToExecute ? 'To execute this transaction, run:' : 'Next steps:'} {readyToExecute ? ( safe tx execute {safeTxHash} ) : ( <> safe tx status {safeTxHash} (check status) safe tx sign {safeTxHash} (add your signature) )} ) }