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 is contained in:
2026-11-03 09:46:50 +00:00
parent 448afdb5ce
commit 617bd91688
21 changed files with 470 additions and 67 deletions
+17 -6
View File
@@ -230,11 +230,14 @@ function updateSendBalance() {
attachCopyHandlers($("send-from"));
const token = state.selectedToken || $("send-token").value;
if (token === "ETH") {
// A null balance is one no refresh has read.
$("send-balance").textContent =
"Current balance: " +
truncateAmountNeverZero(addr.balance || "0") +
" " +
nativeCurrency();
addr.balance == null
? "Current balance: unknown (" + nativeCurrency() + ")"
: "Current balance: " +
truncateAmountNeverZero(addr.balance) +
" " +
nativeCurrency();
} else {
const symbol = resolveSymbol(
token,
@@ -289,6 +292,12 @@ async function fillMaxAmount() {
return;
}
// A null balance is one no refresh has read.
if (addr.balance == null) {
showFlash("This token's balance is unknown.");
return;
}
// The fee is estimated for this recipient, as the confirmation screen
// estimates it: sending to a contract can cost more gas.
const to = $("send-to").value.trim();
@@ -306,7 +315,7 @@ async function fillMaxAmount() {
provider.estimateGas({
from: addr.address,
to,
value: parseEther(addr.balance || "0"),
value: parseEther(addr.balance),
}),
]);
feeWei = feeReserveWei(gasLimit, feeData);
@@ -321,8 +330,10 @@ async function fillMaxAmount() {
}
// While the estimate was in flight the user left the screen (and perhaps
// opened it again), typed an amount, or changed the address, the holding
// or the recipient: what they did wins.
// or the recipient: what they did wins. A network switch in that time
// leaves no balance to fill in from.
if (
addr.balance == null ||
state.currentView !== "send" ||
sendScreenOpenings !== opening ||
currentAddress()?.address !== addr.address ||