fix: a tracked token reads quantity unknown at an address no refresh has read (closes #720)
A new address, a new wallet and a network switch each leave tracked tokens with no balance entry, so their lines read 0.0000 before any refresh had read them. Each of these now sets `balanceNotFetched` on the tracked tokens, and a refresh already clears it. Their lines read `quantity unknown` until then. Addresses that the wallet scan finds get the same. A refresh that did not read every address the page now holds leaves the field set. Model: opus-5-5
This commit was merged in pull request #735.
This commit is contained in:
@@ -180,7 +180,10 @@ test("a token added by contract address on Sepolia is tracked on Sepolia only",
|
||||
await boot.click("btn-settings");
|
||||
await chooseNetwork(boot, "mainnet");
|
||||
expect(stored().networkId).toBe("mainnet");
|
||||
expect(stored().trackedTokens).toEqual([MAINNET_TOKEN]);
|
||||
// No refresh has read a balance on this network since the switch.
|
||||
expect(stored().trackedTokens).toEqual([
|
||||
{ ...MAINNET_TOKEN, balanceNotFetched: true },
|
||||
]);
|
||||
const onMainnet = boot.node("settings-tracked-tokens").innerHTML;
|
||||
expect(onMainnet).toContain("DAI");
|
||||
expect(onMainnet).not.toContain("TST");
|
||||
@@ -276,7 +279,9 @@ test("a token tracked on Sepolia when another page switched there is not tracked
|
||||
|
||||
const stored = boot.storage.read("autistmask");
|
||||
expect(stored.networkId).toBe("sepolia");
|
||||
expect(stored.trackedTokens).toEqual([SEPOLIA_TOKEN]);
|
||||
expect(stored.trackedTokens).toEqual([
|
||||
{ ...SEPOLIA_TOKEN, balanceNotFetched: true },
|
||||
]);
|
||||
expect(stored.networkTrackedTokens.mainnet).toEqual([]);
|
||||
});
|
||||
|
||||
@@ -441,7 +446,10 @@ test("a token another page added on Ethereum Mainnet is tracked when this page s
|
||||
|
||||
const stored = boot.storage.read("autistmask");
|
||||
expect(stored.networkId).toBe("mainnet");
|
||||
expect(stored.trackedTokens).toEqual([MAINNET_TOKEN, newToken]);
|
||||
expect(stored.trackedTokens).toEqual([
|
||||
{ ...MAINNET_TOKEN, balanceNotFetched: true },
|
||||
{ ...newToken, balanceNotFetched: true },
|
||||
]);
|
||||
});
|
||||
|
||||
// This page tracks DAI on Ethereum Mainnet and switches to Sepolia. Another
|
||||
@@ -489,7 +497,10 @@ test("a token another page added on Ethereum Mainnet stays when this page adds a
|
||||
const stored = boot.storage.read("autistmask");
|
||||
expect(stored.networkTrackedTokens.mainnet).toEqual([MAINNET_TOKEN]);
|
||||
expect(stored.networkTrackedTokens.sepolia).toEqual([SEPOLIA_TOKEN]);
|
||||
expect(stored.trackedTokens).toEqual([SEPOLIA_TOKEN, added]);
|
||||
expect(stored.trackedTokens).toEqual([
|
||||
{ ...SEPOLIA_TOKEN, balanceNotFetched: true },
|
||||
added,
|
||||
]);
|
||||
});
|
||||
|
||||
// This page tracks DAI on Ethereum Mainnet and switches to Sepolia, where TST is
|
||||
@@ -513,7 +524,10 @@ test("a token another page removed on Ethereum Mainnet stays removed when this p
|
||||
const stored = boot.storage.read("autistmask");
|
||||
expect(stored.networkTrackedTokens.mainnet).toEqual([]);
|
||||
expect(stored.networkTrackedTokens.sepolia).toEqual([SEPOLIA_TOKEN]);
|
||||
expect(stored.trackedTokens).toEqual([SEPOLIA_TOKEN, added]);
|
||||
expect(stored.trackedTokens).toEqual([
|
||||
{ ...SEPOLIA_TOKEN, balanceNotFetched: true },
|
||||
added,
|
||||
]);
|
||||
});
|
||||
|
||||
// Another popup page records a fraud contract on Ethereum Mainnet after this
|
||||
@@ -1031,7 +1045,9 @@ describe("a contract lookup that answers after a switch adds nothing", () => {
|
||||
await addAcrossSwitch(boot, "btn-settings-addtoken-manual", "mainnet");
|
||||
expect(boot.visibleViews()).toEqual(["settings"]);
|
||||
expect(boot.text("flash-msg")).toBe(NETWORK_CHANGED_FLASH);
|
||||
expect(stored().trackedTokens).toEqual([MAINNET_TOKEN]);
|
||||
expect(stored().trackedTokens).toEqual([
|
||||
{ ...MAINNET_TOKEN, balanceNotFetched: true },
|
||||
]);
|
||||
expect(stored().networkTrackedTokens.sepolia).toEqual([]);
|
||||
});
|
||||
|
||||
@@ -1044,7 +1060,9 @@ describe("a contract lookup that answers after a switch adds nothing", () => {
|
||||
await addAcrossSwitch(boot, "btn-add-token-confirm", "sepolia");
|
||||
expect(boot.visibleViews()).toEqual(["settings"]);
|
||||
expect(boot.text("flash-msg")).toBe(NETWORK_CHANGED_FLASH);
|
||||
expect(stored().trackedTokens).toEqual([SEPOLIA_TOKEN]);
|
||||
expect(stored().trackedTokens).toEqual([
|
||||
{ ...SEPOLIA_TOKEN, balanceNotFetched: true },
|
||||
]);
|
||||
expect(stored().networkTrackedTokens.mainnet).toEqual([MAINNET_TOKEN]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user