// WalletDetailPane — right pane of the Wallet section. Either the // selected tx's detail or a placeholder when nothing is selected. import React, { useEffect, useState } from 'react'; import { useStore } from '@/lib/store'; import { getTxDetail, type TxDetail } from '@/lib/api'; import { shortAddr } from '@/lib/crypto'; function formatT(ut: number | string): string { const n = typeof ut === 'string' ? parseInt(ut, 10) : ut; if (!Number.isFinite(n)) return '—'; return (n / 1_000_000).toLocaleString(undefined, { maximumFractionDigits: 6 }); } export function WalletDetailPane(): React.ReactElement { const sel = useStore(s => s.walletSel); const keyFile = useStore(s => s.keyFile); const [tx, setTx] = useState(null); const [loading, setLoading] = useState(false); useEffect(() => { if (sel.kind !== 'tx') { setTx(null); return; } let cancelled = false; setLoading(true); getTxDetail(sel.id) .then(t => { if (!cancelled) setTx(t); }) .catch(() => { if (!cancelled) setTx(null); }) .finally(() => { if (!cancelled) setLoading(false); }); return () => { cancelled = true; }; }, [sel]); if (sel.kind !== 'tx') { return (
Pick a transaction from the list on the left to see its details.
); } if (loading) return ; if (!tx) return ; const outgoing = !!keyFile && tx.from === keyFile.pub_key; const amountUT = tx.amount_ut; const amountColor = amountUT === 0 ? '#8b8b8b' : outgoing ? '#f0b35a' : '#3ba55d'; return (
{tx.type.replace(/_/g, ' ')}
{amountUT === 0 ? '—' : `${outgoing ? '−' : '+'}${formatT(amountUT)} T`}
{tx.memo && (
“{tx.memo}”
)}
{tx.id} {tx.from_addr ?? shortAddr(tx.from, 8)} {tx.to && {tx.to_addr ?? shortAddr(tx.to, 8)}} {formatT(tx.amount_ut)} T {formatT(tx.fee_ut)} T {new Date(tx.time).toLocaleString()} #{tx.block_index} · {shortAddr(tx.block_hash, 8)} {typeof tx.gas_used === 'number' && tx.gas_used > 0 && ( {tx.gas_used.toLocaleString()} )}
{Boolean(tx.payload) && (
Payload
{JSON.stringify(tx.payload, null, 2)}
          
)} {tx.payload_hex && (
Payload (hex)
{tx.payload_hex}
)}
); } function Cell({ label, children }: { label: string; children: React.ReactNode }) { return ( <>
{label}
{children}
); } function Placeholder({ note }: { note: string }) { return (
{note}
); }