import { formatEther } from 'ethers'; import React from 'react'; export interface TransactionReceiptProps { txHash: string; from: string; to: string; value: string; gasUsed: string; blockNumber: number; status: 'success' | 'failure' | 'pending'; timestamp: number; containerProps?: React.HTMLAttributes; headerProps?: React.HTMLAttributes; contentProps?: React.HTMLAttributes; rowProps?: React.HTMLAttributes; labelProps?: React.HTMLAttributes; valueProps?: React.HTMLAttributes; statusProps?: React.HTMLAttributes; } export const TransactionReceipt: React.FC = ({ txHash, from, to, value, gasUsed, blockNumber, status, timestamp, containerProps, headerProps, contentProps, rowProps, labelProps, valueProps, statusProps, }) => { const formatAddress = (address: string) => `${address.slice(0, 6)}...${address.slice(-4)}`; const formatTimestamp = (timestamp: number) => new Date(timestamp * 1000).toLocaleString(); return (
Transaction Receipt
Status:
{status.charAt(0).toUpperCase() + status.slice(1)}
Transaction Hash: {txHash}
From: {formatAddress(from)}
To: {formatAddress(to)}
Value: {formatEther(value)} ETH
Gas Used: {gasUsed}
Block Number: {blockNumber}
Timestamp: {formatTimestamp(timestamp)}
); };