From 2a8c0513772376e6ffb97051d07d6655676ab805 Mon Sep 17 00:00:00 2001 From: sneak Date: Wed, 25 Feb 2026 18:44:29 +0700 Subject: [PATCH] Add total portfolio value, cached prices and balances MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Total USD value displayed in 2x type above wallet list on Home. Value aggregation: getAddressValueUsd (ETH + all tokens) → getWalletValueUsd → getTotalValueUsd. Price API cached for 5 minutes, balance fetches cached for 60 seconds. Both caches are app-wide — repeated calls to refreshPrices/refreshBalances are no-ops within the TTL. --- src/popup/index.html | 3 ++ src/popup/index.js | 72 ++++++++++++++++++++++++++++++++++++-------- 2 files changed, 62 insertions(+), 13 deletions(-) diff --git a/src/popup/index.html b/src/popup/index.html index 7361124..15bc326 100644 --- a/src/popup/index.html +++ b/src/popup/index.html @@ -173,6 +173,9 @@ `; }); @@ -285,6 +331,8 @@ function renderWalletList() { renderWalletList(); }); }); + + renderTotalValue(); } function showAddressDetail() { @@ -294,9 +342,7 @@ function showAddressDetail() { $("address-full").textContent = addr.address; $("address-copied-msg").textContent = ""; $("address-eth-balance").textContent = addr.balance; - const ethUsd = prices.ETH ? parseFloat(addr.balance) * prices.ETH : null; - $("address-usd-value").textContent = - ethUsd !== null ? formatUsd(ethUsd) : ""; + $("address-usd-value").textContent = formatUsd(getAddressValueUsd(addr)); const ensEl = $("address-ens"); if (addr.ensName) { ensEl.textContent = addr.ensName;