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");