From 2fbed343dbaf6cfa27f9019b3ccc7621cf3c95f6 Mon Sep 17 00:00:00 2001 From: user Date: Sat, 28 Feb 2026 13:36:19 -0800 Subject: [PATCH] fix: make success-tx addresses clickable, fix USDT ETH bug, nest decoded details (closes #80) - Add underline + click-to-copy (data-copy) to addresses in toAddressHtml() so they match the style used everywhere else in the extension - Fix 'USDT ETH' display: add rawValue to Uniswap decoder Amount details and extract Token In info for proper symbol resolution in approval.js - Hide redundant top-level Amount/To when decoded details are present (they already show the same info inside the decoded section) - Wrap decoded calldata details in a bordered well for visual separation --- src/popup/views/approval.js | 12 ++++++++++++ src/popup/views/txStatus.js | 29 +++++++++++++++++++++++------ src/shared/uniswap.js | 18 ++++++++++++------ 3 files changed, 47 insertions(+), 12 deletions(-) diff --git a/src/popup/views/approval.js b/src/popup/views/approval.js index 9f99020..0d25552 100644 --- a/src/popup/views/approval.js +++ b/src/popup/views/approval.js @@ -172,6 +172,8 @@ function showTxApproval(details) { // If this is an ERC-20 call, try to extract the real recipient and amount const decoded = decodeCalldata(details.txParams.data, toAddr || ""); if (decoded && decoded.details) { + let decodedTokenAddr = null; + let decodedTokenSymbol = null; for (const d of decoded.details) { if (d.label === "Recipient" && d.address) { pendingTxDetails.to = d.address; @@ -179,10 +181,20 @@ function showTxApproval(details) { if (d.label === "Amount") { pendingTxDetails.amount = d.rawValue || d.value; } + if (d.label === "Token In" && d.isToken && d.address) { + const t = TOKEN_BY_ADDRESS.get(d.address.toLowerCase()); + if (t) { + decodedTokenAddr = d.address; + decodedTokenSymbol = t.symbol; + } + } } if (token) { pendingTxDetails.token = toAddr; pendingTxDetails.tokenSymbol = token.symbol; + } else if (decodedTokenAddr) { + pendingTxDetails.token = decodedTokenAddr; + pendingTxDetails.tokenSymbol = decodedTokenSymbol; } } diff --git a/src/popup/views/txStatus.js b/src/popup/views/txStatus.js index b8e408a..e8dee6e 100644 --- a/src/popup/views/txStatus.js +++ b/src/popup/views/txStatus.js @@ -43,10 +43,11 @@ function toAddressHtml(address) { if (title) { return ( `
${dot}${escapeHtml(title)}
` + - `
${escapeHtml(address)}${extLink}
` + `
${escapeHtml(address)}
` + + extLink ); } - return `
${dot}${escapeHtml(address)}${extLink}
`; + return `
${dot}${escapeHtml(address)}${extLink}
`; } function txHashHtml(hash) { @@ -139,7 +140,7 @@ function etherscanTokenLink(address) { function decodedDetailsHtml(decoded) { if (!decoded || !decoded.details) return ""; - let html = ""; + let html = `
`; if (decoded.name) { html += `
Action
`; html += `
${escapeHtml(decoded.name)}
`; @@ -164,20 +165,36 @@ function decodedDetailsHtml(decoded) { } html += `
`; } + html += ``; return html; } function renderSuccess() { const d = state.viewData; if (!d || !d.hash) return; - $("success-tx-summary").textContent = d.amount + " " + d.symbol; - $("success-tx-to").innerHTML = toAddressHtml(d.to); + + const hasDecoded = d.decoded && d.decoded.details; + + // When decoded details are present, the Amount and To are already + // shown inside the decoded well — hide the top-level duplicates. + const summarySection = $("success-tx-summary").parentElement; + const toSection = $("success-tx-to").parentElement; + if (hasDecoded) { + summarySection.classList.add("hidden"); + toSection.classList.add("hidden"); + } else { + summarySection.classList.remove("hidden"); + toSection.classList.remove("hidden"); + $("success-tx-summary").textContent = d.amount + " " + d.symbol; + $("success-tx-to").innerHTML = toAddressHtml(d.to); + } + $("success-tx-block").textContent = String(d.blockNumber); $("success-tx-hash").innerHTML = txHashHtml(d.hash); // Show decoded calldata details if present const decodedEl = $("success-tx-decoded"); - if (decodedEl && d.decoded) { + if (decodedEl && hasDecoded) { decodedEl.innerHTML = decodedDetailsHtml(d.decoded); decodedEl.classList.remove("hidden"); } else if (decodedEl) { diff --git a/src/shared/uniswap.js b/src/shared/uniswap.js index 76b6372..1374477 100644 --- a/src/shared/uniswap.js +++ b/src/shared/uniswap.js @@ -445,12 +445,18 @@ function decode(data, toAddress) { const maxUint160 = BigInt( "0xffffffffffffffffffffffffffffffffffffffff", ); - const amountStr = - inputAmount >= maxUint160 - ? "Unlimited" - : formatAmount(inputAmount, inInfo.decimals) + - (inSymbol ? " " + inSymbol : ""); - details.push({ label: "Amount", value: amountStr }); + const isUnlimited = inputAmount >= maxUint160; + const amountRaw = isUnlimited + ? "Unlimited" + : formatAmount(inputAmount, inInfo.decimals); + const amountStr = isUnlimited + ? "Unlimited" + : amountRaw + (inSymbol ? " " + inSymbol : ""); + details.push({ + label: "Amount", + value: amountStr, + rawValue: amountRaw, + }); } if (outSymbol) {