| … | … | @@ -2225,9 +2225,18 @@ async function loadTransactions() { |
| 2225 | 2225 | const dirClass = tx.direction === 'sent' ? 'sent' : 'received' |
| 2226 | 2226 | const statusIcon = tx.status === 'confirmed' ? '✅' : '⏳' |
| 2227 | 2227 | |
| 2228 | | // Format amount using chain config |
| 2229 | | const chain = SUPPORTED_CHAINS[tx.chain] |
| 2230 | | const amount = chain ? chain.formatBalance(tx.amount) : tx.amount |
| 2228 | // Format amount - handle tokens specially |
| 2229 | const baseChain = tx.chain.replace(/-usdt$/, '').replace(/-usdc$/, '') |
| 2230 | const chain = SUPPORTED_CHAINS[baseChain] |
| 2231 | let amount |
| 2232 | if (tx.token || tx.chain.includes('-usdt') || tx.chain.includes('-usdc')) { |
| 2233 | const tokenSymbol = tx.token || (tx.chain.includes('-usdt') ? 'USDT' : 'USDC') |
| 2234 | const decimals = tx.decimals || 6 |
| 2235 | const tokenAmount = Number(tx.amount) / Math.pow(10, decimals) |
| 2236 | amount = `${tokenAmount.toFixed(2)} ${tokenSymbol}` |
| 2237 | } else { |
| 2238 | amount = chain ? chain.formatBalance(tx.amount) : tx.amount |
| 2239 | } |
| 2231 | 2240 | |
| 2232 | 2241 | // Look up contact for the to/from address |
| 2233 | 2242 | const relevantAddress = tx.direction === 'sent' ? tx.to : tx.from |
| … | … | @@ -2706,17 +2715,30 @@ function showTxDetails(index) { |
| 2706 | 2715 | const directionIcon = tx.direction === 'sent' ? '📤' : '📥' |
| 2707 | 2716 | const statusIcon = tx.status === 'confirmed' ? '✅' : '⏳' |
| 2708 | 2717 | |
| 2709 | | // Format using chain config |
| 2710 | | const chain = SUPPORTED_CHAINS[tx.chain] |
| 2711 | | const amount = chain ? chain.formatBalance(tx.amount) : tx.amount |
| 2712 | | const fee = chain ? chain.formatSmallUnit(tx.fee) : tx.fee |
| 2718 | // Format amount based on chain/token |
| 2719 | let amount, fee |
| 2720 | const baseChain = tx.chain.replace(/-usdt$/, '').replace(/-usdc$/, '') |
| 2721 | const chain = SUPPORTED_CHAINS[baseChain] |
| 2722 | |
| 2723 | // Check if this is a token transaction |
| 2724 | if (tx.token || tx.chain.includes('-usdt') || tx.chain.includes('-usdc')) { |
| 2725 | const tokenSymbol = tx.token || (tx.chain.includes('-usdt') ? 'USDT' : 'USDC') |
| 2726 | const decimals = tx.decimals || 6 // USDT/USDC have 6 decimals |
| 2727 | const tokenAmount = Number(tx.amount) / Math.pow(10, decimals) |
| 2728 | amount = `${tokenAmount.toFixed(decimals > 6 ? 6 : decimals)} ${tokenSymbol}` |
| 2729 | // Fee is still in ETH (wei) |
| 2730 | fee = chain ? chain.formatSmallUnit(tx.fee) : `${tx.fee} wei` |
| 2731 | } else { |
| 2732 | amount = chain ? chain.formatBalance(tx.amount) : tx.amount |
| 2733 | fee = chain ? chain.formatSmallUnit(tx.fee) : tx.fee |
| 2734 | } |
| 2713 | 2735 | |
| 2714 | 2736 | // Explorer links (chain-specific URLs) |
| 2715 | 2737 | let explorerLink = '' |
| 2716 | | if (tx.chain === 'bitcoin') { |
| 2738 | if (baseChain === 'bitcoin') { |
| 2717 | 2739 | const network = tx.network === 'testnet' ? 'testnet/' : '' |
| 2718 | 2740 | explorerLink = `https://blockstream.info/${network}tx/${tx.hash}` |
| 2719 | | } else if (tx.chain === 'ethereum') { |
| 2741 | } else if (baseChain === 'ethereum') { |
| 2720 | 2742 | const network = tx.network === 'testnet' ? 'sepolia.' : '' |
| 2721 | 2743 | explorerLink = `https://${network}etherscan.io/tx/${tx.hash}` |
| 2722 | 2744 | } |