fix: tracked tokens are kept per network, and bundled picks are offered on mainnet only (closes #523)
A network switch now puts the outgoing network's tracked tokens away in a new persisted field, networkTrackedTokens, and brings back the incoming network's list, or an empty one, the way endpoints are kept per network. trackedTokens stays the active network's list, so its readers are unchanged, and the background's switch goes through the same function. The two add-token screens offer their common-token picks, which are mainnet contracts, on Ethereum Mainnet only. After a switch in Settings, Back finds the screens beneath as a reopened popup does: it renders the one it lands on for the new network, and the stack is cut at the first screen that cannot be rendered from saved state. Model: opus-5-5
This commit is contained in:
@@ -204,17 +204,21 @@ describe("a chain switch on a worker that never loaded state", () => {
|
||||
expect(after.rpcUrl).toBe(SEPOLIA.defaultRpcUrl);
|
||||
|
||||
// And it took nothing else with it. Without the load these come back
|
||||
// as [], {}, [] and "system" from DEFAULT_STATE — every wallet in the
|
||||
// as [], {}, {} and "system" from DEFAULT_STATE — every wallet in the
|
||||
// extension gone, encrypted secrets included.
|
||||
expect(after.wallets).toEqual(walletFixture());
|
||||
expect(after.hasWallet).toBe(true);
|
||||
expect(after.activeAddress).toBe(ADDRESS);
|
||||
expect(after.allowedSites).toEqual({ [ADDRESS]: [CONNECTED_ORIGIN] });
|
||||
expect(after.trackedTokens).toEqual([
|
||||
{ address: TOKEN, symbol: "DAI", decimals: 18 },
|
||||
]);
|
||||
expect(after.networkTrackedTokens).toEqual({
|
||||
mainnet: [{ address: TOKEN, symbol: "DAI", decimals: 18 }],
|
||||
});
|
||||
expect(after.theme).toBe("dark");
|
||||
|
||||
// The mainnet token is tracked on mainnet only: Sepolia starts with
|
||||
// none of its own.
|
||||
expect(after.trackedTokens).toEqual([]);
|
||||
|
||||
// The user's mainnet endpoint is remembered rather than replaced by
|
||||
// the public default, so switching back returns it.
|
||||
expect(after.networkEndpoints.mainnet).toEqual({
|
||||
@@ -226,6 +230,9 @@ describe("a chain switch on a worker that never loaded state", () => {
|
||||
expect(bg.persisted().rpcUrl).toBe(CUSTOM_RPC);
|
||||
expect(bg.persisted().blockscoutUrl).toBe(CUSTOM_BLOCKSCOUT);
|
||||
expect(bg.persisted().wallets).toEqual(walletFixture());
|
||||
expect(bg.persisted().trackedTokens).toEqual([
|
||||
{ address: TOKEN, symbol: "DAI", decimals: 18 },
|
||||
]);
|
||||
});
|
||||
|
||||
test("compares the requested chain against the stored one, not the default", async () => {
|
||||
|
||||
Reference in New Issue
Block a user