fix: the ETH line reads unknown at an address no refresh has read (closes #736)
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 keeps its warning. A refresh also deletes `balanceNotFetched` only when it read every address in the stored record. Model: opus-5-5
This commit is contained in:
@@ -33,6 +33,7 @@ const USDC = "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48";
|
||||
const EMPTY = { address: "0x1", balance: "0.0000", tokenBalances: [] };
|
||||
const ETH_ONLY = { address: "0x1", balance: "1.5", tokenBalances: [] };
|
||||
const DUST = { address: "0x1", balance: "0.00001", tokenBalances: [] };
|
||||
const NOT_READ = { address: "0x1", balance: null, tokenBalances: [] };
|
||||
const TOKEN_ONLY = {
|
||||
address: "0x1",
|
||||
balance: "0.0000",
|
||||
@@ -106,6 +107,11 @@ describe("whether an address holds anything", () => {
|
||||
expect(addressHoldsFunds(DUST)).toBe(true);
|
||||
});
|
||||
|
||||
// No refresh has read it, so the address may hold funds.
|
||||
test("an ETH balance no refresh has read counts", () => {
|
||||
expect(addressHoldsFunds(NOT_READ)).toBe(true);
|
||||
});
|
||||
|
||||
test("an address holding nothing does not", () => {
|
||||
expect(addressHoldsFunds(EMPTY)).toBe(false);
|
||||
expect(addressHoldsFunds(ZERO_TOKEN)).toBe(false);
|
||||
@@ -143,6 +149,13 @@ describe("the balance warning on the removal confirmation", () => {
|
||||
// The sentence must not assert an amount, because any amount it could
|
||||
// assert has been rounded: "This address holds 0.0000 ETH." is what the
|
||||
// rounded form produces for an address that holds real money.
|
||||
test("an ETH balance no refresh has read is warned about, and reads as unknown", () => {
|
||||
const html = balanceWarningHtml(NOT_READ);
|
||||
expect(html).toContain("This address holds a balance");
|
||||
expect(html).toContain("quantity unknown");
|
||||
expect(html).not.toContain("0.0000");
|
||||
});
|
||||
|
||||
test("the warning sentence asserts no rounded amount", () => {
|
||||
for (const addr of [DUST, ETH_ONLY, TOKEN_ONLY]) {
|
||||
expect(balanceWarningHtml(addr)).not.toMatch(
|
||||
|
||||
Reference in New Issue
Block a user