fix: the ETH line reads unknown at an address no refresh has read (closes #736)
check / check (push) Canceled after 0s
e2e / e2e-chrome (push) Canceled after 0s
e2e / e2e-firefox (push) Canceled after 0s

An address's ETH balance is now null until a refresh has read it. That covers
a new address, a new wallet, addresses a wallet scan finds, and every address
after a network switch.

Its line reads `quantity unknown`, Home's balance `unknown (ETH)`, and Send
`Current balance: unknown (ETH)`. Max says the balance is unknown. Send is no
longer refused as zero. The address has no total, and DeleteAddress warns that
it may hold a balance.

A refresh also deletes `balanceNotFetched` only when it read every address in
the stored record.

Model: opus-5-5
This commit was merged in pull request #741.
This commit is contained in:
2026-11-03 11:24:18 +01:00
parent 448afdb5ce
commit 9c691dfa6b
21 changed files with 470 additions and 67 deletions
+14 -6
View File
@@ -3,6 +3,7 @@ const {
showView,
showFlash,
balanceLinesForAddress,
unknownableAmount,
markTrackedTokensNotFetched,
isoDate,
timeAgo,
@@ -76,10 +77,16 @@ function renderTotalValue() {
if (subEl) subEl.innerHTML = " ";
return;
}
const ethBal = parseFloat(addr.balance || "0");
const ethStr = ethBal.toFixed(4) + " " + nativeCurrency();
const ethUsd = ethPrice ? " (" + formatUsd(ethBal * ethPrice) + ")" : "";
el.textContent = ethStr + ethUsd;
const ethBal = unknownableAmount(addr.balance);
if (ethBal === null) {
el.textContent = "unknown (" + nativeCurrency() + ")";
} else {
const ethStr = ethBal.toFixed(4) + " " + nativeCurrency();
const ethUsd = ethPrice
? " (" + formatUsd(ethBal * ethPrice) + ")"
: "";
el.textContent = ethStr + ethUsd;
}
if (subEl) {
subEl.innerHTML =
@@ -411,7 +418,7 @@ function render(ctx) {
wallet.addresses.push({
address: newAddr,
index: wallet.nextIndex,
balance: "0.0000",
balance: null,
tokenBalances: [],
});
wallet.nextIndex++;
@@ -498,7 +505,8 @@ function init(ctx) {
return;
}
const addr = currentAddress();
if (!addr.balance || parseFloat(addr.balance) === 0) {
// A null balance is one no refresh has read, so it is not refused.
if (parseFloat(addr.balance) === 0) {
showFlash("Cannot send \u2014 zero balance.");
return;
}