import React, { useEffect } from 'react' import { Box, Text } from 'ink' import type { Address } from 'viem' import { Header, KeyValue, List } from '../components/index.js' import { theme } from '../theme.js' export interface TransactionStatusScreenProps { /** * Safe transaction hash */ safeTxHash: string /** * Safe address (EIP-3770 format) */ safeEip3770: string /** * Transaction destination address */ to: string /** * Transaction value in wei */ value: string /** * Transaction nonce */ nonce: number | undefined /** * Transaction status */ status: string /** * Signatures collected */ signaturesCollected: number /** * Signatures required */ signaturesRequired: number /** * List of signers */ signers: Address[] /** * Safe owners */ owners: Address[] /** * Blockchain transaction hash (if executed) */ txHash?: string /** * Explorer URL (if available) */ explorerUrl?: string /** * Optional callback when the screen is ready to exit */ onExit?: () => void } /** * TransactionStatusScreen displays detailed transaction status information. * This replaces the console.log implementation in commands/tx/status.ts * * Features: * - Shows transaction details and signature progress * - Lists signers and awaiting owners * - Displays next steps based on status * - Shows execution details if available */ export function TransactionStatusScreen({ safeTxHash, safeEip3770, to, value, nonce, status, signaturesCollected, signaturesRequired, signers, owners, txHash, explorerUrl, onExit, }: TransactionStatusScreenProps): React.ReactElement { // Auto-exit after rendering useEffect(() => { if (onExit) { onExit() } }, [onExit]) const isReadyToExecute = signaturesCollected >= signaturesRequired const unsignedOwners = owners.filter( (owner) => !signers.some((signer) => signer.toLowerCase() === owner.toLowerCase()) ) return (
{/* Transaction details */} Transaction Details: {/* Signature status */} Signature Status: {isReadyToExecute ? ( ✓ {signaturesCollected}/{signaturesRequired} signatures collected - Ready to execute! ) : ( ⚠ {signaturesCollected}/{signaturesRequired} signatures collected - Need{' '} {signaturesRequired - signaturesCollected} more )} {/* Signatures collected */} {signers.length > 0 && ( Signatures: { const isOwner = owners.some((owner) => owner.toLowerCase() === signer.toLowerCase()) return { label: signer, marker: isOwner ? '✓' : '✗', markerColor: isOwner ? theme.colors.success : theme.colors.error, } })} renderItem={(item) => ( {item.marker} {item.label} )} /> )} {/* Awaiting signatures */} {unsignedOwners.length > 0 && ( Awaiting signatures from: ({ label: owner, marker: '○', markerColor: theme.colors.dim, }))} renderItem={(item) => ( {item.marker} {item.label} )} /> )} {/* Next steps */} Next steps: {isReadyToExecute ? ( safe tx execute {safeTxHash} ) : ( <> safe tx sign {safeTxHash} (if you're an owner) safe tx export {safeTxHash} (share with other owners) )} {/* Execution details */} {txHash && ( Execution: )} {/* Success message */} Status displayed ) }