From 1df770d3b62d225626d29125c5b8edf548d676a3 Mon Sep 17 00:00:00 2001 From: user Date: Sat, 28 Feb 2026 11:30:44 -0800 Subject: [PATCH] fix: prevent double symbol display on swap tx broadcast/status views For Uniswap swaps, the decoded Amount value includes the token symbol (e.g. '2.0000 USDT'). The tx status view then appended 'ETH' because pendingTxDetails.token remained 'ETH' (router address is not a token). Fix: - Add rawValue (numeric-only) to uniswap decoder's Amount detail - Extract Token In address from decoded details in approval.js to set the correct token/tokenSymbol on pendingTxDetails for swaps - The existing d.rawValue || d.value pattern now picks up the clean numeric value, and symbol comes from tokenSymbol --- src/popup/views/approval.js | 13 ++++++++++++- src/shared/uniswap.js | 13 ++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/popup/views/approval.js b/src/popup/views/approval.js index 8641960..4422c43 100644 --- a/src/popup/views/approval.js +++ b/src/popup/views/approval.js @@ -167,9 +167,11 @@ function showTxApproval(details) { tokenSymbol: token ? token.symbol : null, }; - // If this is an ERC-20 call, try to extract the real recipient and amount + // If this is an ERC-20 call or a swap, extract the real recipient, amount, and token info const decoded = decodeCalldata(details.txParams.data, toAddr || ""); if (decoded && decoded.details) { + let decodedTokenSymbol = null; + let decodedTokenAddress = null; for (const d of decoded.details) { if (d.label === "Recipient" && d.address) { pendingTxDetails.to = d.address; @@ -177,10 +179,19 @@ function showTxApproval(details) { if (d.label === "Amount") { pendingTxDetails.amount = d.rawValue || d.value; } + if (d.label === "Token In" && !decodedTokenSymbol) { + // Extract token symbol and address from decoded details + decodedTokenSymbol = d.value; + if (d.address) decodedTokenAddress = d.address; + } } if (token) { pendingTxDetails.token = toAddr; pendingTxDetails.tokenSymbol = token.symbol; + } else if (decodedTokenAddress) { + // For swaps through routers: use the input token info + pendingTxDetails.token = decodedTokenAddress; + pendingTxDetails.tokenSymbol = decodedTokenSymbol; } } diff --git a/src/shared/uniswap.js b/src/shared/uniswap.js index 76b6372..3e8a5f6 100644 --- a/src/shared/uniswap.js +++ b/src/shared/uniswap.js @@ -445,12 +445,19 @@ function decode(data, toAddress) { const maxUint160 = BigInt( "0xffffffffffffffffffffffffffffffffffffffff", ); + const rawAmount = + inputAmount >= maxUint160 + ? "Unlimited" + : formatAmount(inputAmount, inInfo.decimals); const amountStr = inputAmount >= maxUint160 ? "Unlimited" - : formatAmount(inputAmount, inInfo.decimals) + - (inSymbol ? " " + inSymbol : ""); - details.push({ label: "Amount", value: amountStr }); + : rawAmount + (inSymbol ? " " + inSymbol : ""); + details.push({ + label: "Amount", + value: amountStr, + rawValue: rawAmount, + }); } if (outSymbol) {