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 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:
@@ -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,14 +107,23 @@ 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);
|
||||
});
|
||||
|
||||
test("a missing address or missing fields do not", () => {
|
||||
test("a missing address does not", () => {
|
||||
expect(addressHoldsFunds(undefined)).toBe(false);
|
||||
expect(addressHoldsFunds({ address: "0x1" })).toBe(false);
|
||||
});
|
||||
|
||||
// It reads as unknown, as a null balance does.
|
||||
test("an address with no ETH balance field counts", () => {
|
||||
expect(addressHoldsFunds({ address: "0x1" })).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -140,6 +150,20 @@ describe("the balance warning on the removal confirmation", () => {
|
||||
expect(html).toContain("<span>0.0000</span>");
|
||||
});
|
||||
|
||||
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 may hold a balance.");
|
||||
expect(html).not.toContain("This address holds a balance.");
|
||||
expect(html).toContain("quantity unknown");
|
||||
expect(html).not.toContain("0.0000");
|
||||
});
|
||||
|
||||
test("an address with no ETH balance field reads the same", () => {
|
||||
expect(balanceWarningHtml({ address: "0x1" })).toContain(
|
||||
"This address may hold a balance.",
|
||||
);
|
||||
});
|
||||
|
||||
// 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.
|
||||
|
||||
Reference in New Issue
Block a user