import React, { useEffect } from 'react' import { Box, Text } from 'ink' import { Header } from '../components/index.js' import { theme } from '../theme.js' export interface TransactionPullResult { /** * Transaction hash (safeTxHash) */ safeTxHash: string /** * Status: 'imported', 'updated', or 'skipped' */ status: 'imported' | 'updated' | 'skipped' /** * Number of signatures (for imported) or new signatures (for updated) */ signatureCount: number } export interface TransactionPullSuccessScreenProps { /** * Safe address in EIP-3770 format */ safeEip3770: string /** * List of transaction results */ transactions: TransactionPullResult[] /** * Number of imported transactions */ imported: number /** * Number of updated transactions */ updated: number /** * Number of skipped transactions */ skipped: number /** * Optional callback when the screen is ready to exit */ onExit?: () => void } /** * TransactionPullSuccessScreen displays results after pulling transactions from Safe API. * This replaces the console.log implementation in commands/tx/pull.ts * * Features: * - Lists each transaction with its status (imported/updated/skipped) * - Shows signature counts * - Displays summary statistics * - Color-coded status indicators */ export function TransactionPullSuccessScreen({ safeEip3770, transactions, imported, updated, skipped, onExit, }: TransactionPullSuccessScreenProps): React.ReactElement { // Auto-exit after rendering useEffect(() => { if (onExit) { onExit() } }, [onExit]) const getStatusIcon = (status: TransactionPullResult['status']) => { switch (status) { case 'imported': return { icon: '✓', color: theme.colors.success } case 'updated': return { icon: '↻', color: theme.colors.info } case 'skipped': return { icon: '−', color: theme.colors.dim } } } const getStatusText = (result: TransactionPullResult) => { const hash = result.safeTxHash.slice(0, 10) + '...' switch (result.status) { case 'imported': return `Imported ${hash} (${result.signatureCount} signatures)` case 'updated': return `Updated ${hash} (+${result.signatureCount} signatures)` case 'skipped': return `Skipped ${hash} (already up to date)` } } return (
Safe: {safeEip3770} {/* Transaction list */} {transactions.length > 0 && ( Pending transactions: {transactions.map((result, index) => { const statusInfo = getStatusIcon(result.status) return ( {statusInfo.icon} {getStatusText(result)} ) })} )} {/* Summary */} Summary: Imported: {imported} Updated: {updated} Skipped: {skipped} ) }