After a switch, a page's next add can overwrite the tracked tokens another page stored #719

Closed
opened 2026-11-03 00:04:24 +01:00 by clawbot · 1 comment
Collaborator

Where

applyChainSwitchFields() in src/shared/chainSwitchFields.js, and the save in saveStateOnce() (src/shared/state.js).

What happens

Found by the review of #704, outside its scope; the same on next before that PR.

After a switch, trackedTokens and that network's list in networkTrackedTokens are one array. So when a page has switched to a network that already has a list, its next add or removal also changes networkTrackedTokens, and the save writes that page's older copy of networkTrackedTokens over the stored one.

Example: page A switches to Sepolia. Page B adds NEW before it takes that switch, and "Added NEW" shows. A then adds a token on Sepolia. NEW is now on neither network. A removal by B is undone the same way.

What should happen

No tracked token is lost and none comes back. A page's add or removal on the active network changes only trackedTokens.

Severity: minor

Definition of done

  • applyChainSwitchFields() gives trackedTokens its own copy of the incoming network's list.
  • A test for the add and a test for the removal in the example, each failing on next.

Model: opus-5-5

## Where `applyChainSwitchFields()` in `src/shared/chainSwitchFields.js`, and the save in `saveStateOnce()` (`src/shared/state.js`). ## What happens Found by the review of https://git.eeqj.de/sneak/AutistMask/pulls/704, outside its scope; the same on `next` before that PR. After a switch, `trackedTokens` and that network's list in `networkTrackedTokens` are one array. So when a page has switched to a network that already has a list, its next add or removal also changes `networkTrackedTokens`, and the save writes that page's older copy of `networkTrackedTokens` over the stored one. Example: page A switches to Sepolia. Page B adds NEW before it takes that switch, and "Added NEW" shows. A then adds a token on Sepolia. NEW is now on neither network. A removal by B is undone the same way. ## What should happen No tracked token is lost and none comes back. A page's add or removal on the active network changes only `trackedTokens`. Severity: minor ## Definition of done - [ ] `applyChainSwitchFields()` gives `trackedTokens` its own copy of the incoming network's list. - [ ] A test for the add and a test for the removal in the example, each failing on `next`. Model: opus-5-5
clawbot self-assigned this 2026-11-03 00:04:24 +01:00
Author
Collaborator

Plan: one PR to next, after #717, which shares the test file. In applyChainSwitchFields() in src/shared/chainSwitchFields.js, s.trackedTokens becomes a structuredClone() of the incoming network's list, or an empty list. Tests as in the definition of done.

Model: opus-5-5

Plan: one PR to `next`, after https://git.eeqj.de/sneak/AutistMask/issues/717, which shares the test file. In `applyChainSwitchFields()` in `src/shared/chainSwitchFields.js`, `s.trackedTokens` becomes a `structuredClone()` of the incoming network's list, or an empty list. Tests as in the definition of done. Model: opus-5-5
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/AutistMask#719