fix: a chain switch gives trackedTokens its own copy of the network's list (closes #719) #730

Merged
clawbot merged 1 commits from issue-719-tracked-tokens-own-copy into next 2026-11-03 07:10:34 +01:00
Collaborator

After a switch, trackedTokens and that network's list in networkTrackedTokens were one array. So a page's next add or removal also changed networkTrackedTokens, and the save wrote that page's older copy over the stored one. Another page's add on the previous network was lost, and its removal was undone.

applyChainSwitchFields() now gives trackedTokens a copy of the incoming network's list. An add or removal on the active network changes only trackedTokens.

The active network's entry in networkTrackedTokens now stays as it was at the switch until the page switches away. Nothing reads that entry for the active network: tokenSourcesByChainId() uses trackedTokens there, and the next switch overwrites the entry.

The two new tests follow the issue's example. The other page's save is a direct write to the stored record, as in the neighbouring tests.

Closes #719

Model: opus-5-5

After a switch, `trackedTokens` and that network's list in `networkTrackedTokens` were one array. So a page's next add or removal also changed `networkTrackedTokens`, and the save wrote that page's older copy over the stored one. Another page's add on the previous network was lost, and its removal was undone. `applyChainSwitchFields()` now gives `trackedTokens` a copy of the incoming network's list. An add or removal on the active network changes only `trackedTokens`. The active network's entry in `networkTrackedTokens` now stays as it was at the switch until the page switches away. Nothing reads that entry for the active network: `tokenSourcesByChainId()` uses `trackedTokens` there, and the next switch overwrites the entry. The two new tests follow the issue's example. The other page's save is a direct write to the stored record, as in the neighbouring tests. Closes https://git.eeqj.de/sneak/AutistMask/issues/719 Model: opus-5-5
clawbot added the needs-review label 2026-11-03 06:41:26 +01:00
clawbot self-assigned this 2026-11-03 06:41:26 +01:00
clawbot added 1 commit 2026-11-03 06:41:27 +01:00
fix: a chain switch gives trackedTokens its own copy of the network's list (closes #719)
check / check (push) Waiting to run
e2e / e2e-chrome (push) Waiting to run
e2e / e2e-firefox (push) Waiting to run
b39110544d
After a switch, `trackedTokens` and that network's list in
`networkTrackedTokens` were one array. So a page's next add or removal also
changed `networkTrackedTokens`, and the save wrote that page's older copy over
the stored one. Another page's add on the previous network was lost, and its
removal was undone.

`applyChainSwitchFields()` now copies the incoming network's list. An add or
removal on the active network changes only `trackedTokens`.

Model: opus-5-5
Author
Collaborator

PASS: a chain switch now gives trackedTokens its own copy of the incoming network's list, as #719 asks.

Follow-up note: no test covers this page's own removal on Sepolia after a switch (state.trackedTokens.splice() in src/popup/views/settings.js). Acceptable is a test shaped like the two new ones that removes TST instead of adding a token, and asserts that networkTrackedTokens.mainnet keeps what the other page stored and that TST stays gone after a switch to Ethereum Mainnet and back.

Judgement call: I read "the removal in the example" in the definition of done as the other page's removal, which the second new test covers.

Not run: the browser end-to-end suites (make test-e2e, make test-e2e-firefox).

Model: opus-5-5

PASS: a chain switch now gives `trackedTokens` its own copy of the incoming network's list, as https://git.eeqj.de/sneak/AutistMask/issues/719 asks. Follow-up note: no test covers this page's own removal on Sepolia after a switch (`state.trackedTokens.splice()` in `src/popup/views/settings.js`). Acceptable is a test shaped like the two new ones that removes TST instead of adding a token, and asserts that `networkTrackedTokens.mainnet` keeps what the other page stored and that TST stays gone after a switch to Ethereum Mainnet and back. Judgement call: I read "the removal in the example" in the definition of done as the other page's removal, which the second new test covers. Not run: the browser end-to-end suites (`make test-e2e`, `make test-e2e-firefox`). Model: opus-5-5
clawbot merged commit ba61bedaaf into next 2026-11-03 07:10:34 +01:00
clawbot deleted branch issue-719-tracked-tokens-own-copy 2026-11-03 07:10:34 +01:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/AutistMask#730