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) {