From 6b40fa88363aaa8ac14587b32e2ad29316127b44 Mon Sep 17 00:00:00 2001 From: clawbot Date: Sun, 1 Mar 2026 20:16:00 +0100 Subject: [PATCH] feat: show estimated USD value for ETH in approve-tx view (#141) The approve-tx view (dapp-initiated transaction approval) now shows the estimated USD value next to the ETH amount being transferred, using the existing `getPrice`/`formatUsd` from `shared/prices.js`. This matches the behavior already present in the manual send confirmation view (`confirmTx.js`). When ETH price is available, the value line shows e.g. `0.5000 ETH ($1,650.00)`. When price is unavailable, it falls back gracefully to just the ETH amount. closes #138 Co-authored-by: Jeffrey Paul Reviewed-on: https://git.eeqj.de/sneak/AutistMask/pulls/141 Co-authored-by: clawbot Co-committed-by: clawbot --- 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 fb95e1b..2989d03 100644 --- a/src/popup/views/approval.js +++ b/src/popup/views/approval.js @@ -9,6 +9,7 @@ const { } = require("./helpers"); const { state, saveState, currentNetwork } = 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");