diff --git a/src/popup/views/home.js b/src/popup/views/home.js index 7e22d5b..c456832 100644 --- a/src/popup/views/home.js +++ b/src/popup/views/home.js @@ -12,14 +12,32 @@ const QRCode = require("qrcode"); const { deriveAddressFromXpub } = require("../../shared/wallet"); const { formatUsd, + getPrice, getAddressValueUsd, - getTotalValueUsd, } = require("../../shared/prices"); +function findActiveAddr() { + for (const w of state.wallets) { + for (const a of w.addresses) { + if (a.address === state.activeAddress) return a; + } + } + return null; +} + function renderTotalValue() { const el = $("total-value"); if (!el) return; - el.textContent = formatUsd(getTotalValueUsd(state.wallets)); + const addr = findActiveAddr(); + if (!addr) { + el.textContent = ""; + return; + } + const ethBal = parseFloat(addr.balance || "0"); + const ethStr = ethBal.toFixed(4) + " ETH"; + const usd = getAddressValueUsd(addr); + const usdStr = usd !== null ? " (" + formatUsd(usd) + " USD)" : ""; + el.textContent = ethStr + usdStr; } const EXT_ICON =