From 71c79e72a8a0592a5bf2479eda5df0b6e354c5a0 Mon Sep 17 00:00:00 2001 From: clawbot Date: Sun, 1 Mar 2026 11:10:02 -0800 Subject: [PATCH] feat: show estimated USD value for ETH in approve-tx view Use getPrice/formatUsd from shared/prices to display the USD estimate next to the ETH amount in the dapp transaction approval view, matching the behavior already present in the manual send confirmation view. closes #138 --- src/popup/views/approval.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/popup/views/approval.js b/src/popup/views/approval.js index 10de99b..b96ec57 100644 --- a/src/popup/views/approval.js +++ b/src/popup/views/approval.js @@ -9,6 +9,7 @@ const { } = require("./helpers"); const { state, saveState } = require("../../shared/state"); const { formatEther, formatUnits, Interface, toUtf8String } = require("ethers"); +const { getPrice, formatUsd } = require("../../shared/prices"); const { ERC20_ABI } = require("../../shared/constants"); const { TOKEN_BY_ADDRESS } = require("../../shared/tokenList"); const txStatus = require("./txStatus"); @@ -243,8 +244,14 @@ function showTxApproval(details) { $("approve-tx-to").innerHTML = escapeHtml("(contract creation)"); } + const ethValueFormatted = formatTxValue( + formatEther(details.txParams.value || "0"), + ); + const ethPrice = getPrice("ETH"); + const ethUsd = ethPrice ? parseFloat(ethValueFormatted) * ethPrice : null; + const usdStr = formatUsd(ethUsd); $("approve-tx-value").textContent = - formatTxValue(formatEther(details.txParams.value || "0")) + " ETH"; + ethValueFormatted + " ETH" + (usdStr ? " (" + usdStr + ")" : ""); // Decode calldata (reuse decoded from above) const decodedEl = $("approve-tx-decoded"); -- 2.49.1