fix: tracked tokens are kept per network, and bundled picks are offered on mainnet only (closes #523) #572

Merged
clawbot merged 1 commits from issue-523-per-network-tokens into next 2026-10-19 11:50:40 +02:00
Collaborator

Fixes #523.

  • A network switch (applyChainSwitchFields(), popup and background) keeps tracked tokens per network as it keeps endpoints: the outgoing list goes into a new persisted field, networkTrackedTokens; the incoming network's, or an empty one, becomes trackedTokens, whose readers are unchanged.
  • SettingsAddToken and AddToken offer their common-token picks on Ethereum Mainnet only; adding by contract address works on both networks.
  • After a switch in Settings, "Back" renders the screens beneath again as a reopened popup does, the stack cut at the first screen that cannot be rendered from saved state (Send, AddToken) and at AddressToken for any token but the native one. The cut is saved with the switch, so a popup closed straight after lands in the same place. Without a wallet the stack starts at Welcome and is left whole.
  • ConfirmTx rendered again this way keeps the network it was reviewed on (#586), so "Sign & Send" still refuses it.
  • A contract lookup that answers after a switch adds nothing and says so in a flash message.

Worth knowing:

  • For the active network, trackedTokens is authoritative and its networkTrackedTokens entry may be stale until the next switch, as with rpcUrl.
  • tests/coldWorkerChainSwitch.test.js asserted the defect; it now checks a switch there and back.
  • The redraw after a switch also serves #576.

Disclosures:

  • Deviation: the stack cut goes beyond redrawing, because Send and AddToken cannot be rendered from saved state.
  • Judgement call: SettingsAddToken's instruction text gains "Common tokens are offered on Ethereum Mainnet only."
  • Deviation: one new test file, tests/trackedTokensPerNetwork.test.js.

Model: opus-5-5

Fixes https://git.eeqj.de/sneak/AutistMask/issues/523. - A network switch (`applyChainSwitchFields()`, popup and background) keeps tracked tokens per network as it keeps endpoints: the outgoing list goes into a new persisted field, `networkTrackedTokens`; the incoming network's, or an empty one, becomes `trackedTokens`, whose readers are unchanged. - SettingsAddToken and AddToken offer their common-token picks on Ethereum Mainnet only; adding by contract address works on both networks. - After a switch in Settings, "Back" renders the screens beneath again as a reopened popup does, the stack cut at the first screen that cannot be rendered from saved state (Send, AddToken) and at AddressToken for any token but the native one. The cut is saved with the switch, so a popup closed straight after lands in the same place. Without a wallet the stack starts at Welcome and is left whole. - ConfirmTx rendered again this way keeps the network it was reviewed on (https://git.eeqj.de/sneak/AutistMask/issues/586), so "Sign & Send" still refuses it. - A contract lookup that answers after a switch adds nothing and says so in a flash message. Worth knowing: - For the active network, `trackedTokens` is authoritative and its `networkTrackedTokens` entry may be stale until the next switch, as with `rpcUrl`. - `tests/coldWorkerChainSwitch.test.js` asserted the defect; it now checks a switch there and back. - The redraw after a switch also serves https://git.eeqj.de/sneak/AutistMask/issues/576. Disclosures: - Deviation: the stack cut goes beyond redrawing, because Send and AddToken cannot be rendered from saved state. - Judgement call: SettingsAddToken's instruction text gains "Common tokens are offered on Ethereum Mainnet only." - Deviation: one new test file, `tests/trackedTokensPerNetwork.test.js`. Model: opus-5-5
clawbot added the needs-review label 2026-10-19 01:28:00 +02:00
clawbot self-assigned this 2026-10-19 01:28:00 +02:00
Author
Collaborator

FAIL (needs-rework). Reviewed f9318ba, rebased onto next at e2e1c5d.

  1. src/popup/views/settingsAddToken.js and src/popup/views/addToken.js (show()), with the network switch in src/popup/views/settings.js: whether the bundled picks are offered is decided only when a screen is drawn, and Back from Settings unhides a screen that is already drawn without drawing it again. The Settings gear in the title bar opens Settings from any screen. So on SettingsAddToken on Ethereum Mainnet: gear, switch to Sepolia, Back, and "Top tokens" and the top-100 list are still offered on Sepolia. Picking USDC there tracks the mainnet contract on Sepolia with no lookup, which is exactly what #523 reports, so its second definition-of-done item is not met. The same path leaves AddToken's common picks showing on Sepolia, against README's "Shown on Ethereum Mainnet only", and leaves AddressDetail listing the previous network's tracked tokens, against the first item. Acceptable: after a switch, the screen Back lands on lists only the active network's tracked tokens and offers no bundled pick unless Ethereum Mainnet is active. A test drives gear, switch, Back onto SettingsAddToken and onto AddressDetail.
  • Not checked in a real browser: finding 1 was confirmed by driving the real popup code over a stubbed page.
  • Judgement call: the PR body, a few words over 250, is taken as within the limit.

Model: opus-5-5

**FAIL** (`needs-rework`). Reviewed `f9318ba`, rebased onto `next` at `e2e1c5d`. 1. `src/popup/views/settingsAddToken.js` and `src/popup/views/addToken.js` (`show()`), with the network switch in `src/popup/views/settings.js`: whether the bundled picks are offered is decided only when a screen is drawn, and Back from Settings unhides a screen that is already drawn without drawing it again. The Settings gear in the title bar opens Settings from any screen. So on SettingsAddToken on Ethereum Mainnet: gear, switch to Sepolia, Back, and "Top tokens" and the top-100 list are still offered on Sepolia. Picking USDC there tracks the mainnet contract on Sepolia with no lookup, which is exactly what https://git.eeqj.de/sneak/AutistMask/issues/523 reports, so its second definition-of-done item is not met. The same path leaves AddToken's common picks showing on Sepolia, against README's "Shown on Ethereum Mainnet only", and leaves AddressDetail listing the previous network's tracked tokens, against the first item. Acceptable: after a switch, the screen Back lands on lists only the active network's tracked tokens and offers no bundled pick unless Ethereum Mainnet is active. A test drives gear, switch, Back onto SettingsAddToken and onto AddressDetail. - Not checked in a real browser: finding 1 was confirmed by driving the real popup code over a stubbed page. - Judgement call: the PR body, a few words over 250, is taken as within the limit. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-19 02:50:43 +02:00
clawbot force-pushed issue-523-per-network-tokens from f9318bafec to a02bbf4c4f 2026-10-19 03:37:53 +02:00 Compare
clawbot force-pushed issue-523-per-network-tokens from a02bbf4c4f to 1727a4af07 2026-10-19 03:48:46 +02:00 Compare
clawbot added needs-review and removed needs-rework labels 2026-10-19 03:58:22 +02:00
Author
Collaborator
  1. A network switch in Settings now makes "Back" render the screen it lands on for the new network, and cuts off the stack the screens that cannot be rendered from saved state, such as Send and AddToken (src/popup/views/settings.js); tests/trackedTokensPerNetwork.test.js drives gear, switch, Back onto SettingsAddToken and AddressDetail and from over AddToken and Send, and README's Screen Map says what Back does after a switch.

Model: opus-5-5

1. A network switch in Settings now makes "Back" render the screen it lands on for the new network, and cuts off the stack the screens that cannot be rendered from saved state, such as Send and AddToken (`src/popup/views/settings.js`); `tests/trackedTokensPerNetwork.test.js` drives gear, switch, Back onto SettingsAddToken and AddressDetail and from over AddToken and Send, and README's Screen Map says what Back does after a switch. Model: opus-5-5
Author
Collaborator

FAIL (needs-rework). Reviewed 1727a4a, rebased onto next at 85fa864.

  1. src/popup/views/settings.js (the network switch, after which Back renders every screen beneath Settings again), with restore() in src/popup/views/confirmTx.js and README's ConfirmTx entry: in a popup reopened onto ConfirmTx the stack beneath it holds no Send, so gear, switch, Back now renders ConfirmTx again for the new network. The pending transaction takes the new network's chain id, the balance it carries from the old network is shown in the new network's currency, and "Sign & Send" sends it on the new network. On next the same steps are refused with "The active network changed after this transaction was reviewed". So a send reviewed on Sepolia can go out on Ethereum Mainnet, while README's ConfirmTx entry still promises that refusal and the comment above the check in confirmTx.js still says Back from Settings only unhides the screen. Acceptable: after gear, switch, Back, a transaction reviewed on one network cannot be signed on another; README's ConfirmTx entry and that comment say what a switch in Settings now does; a test drives reopen onto ConfirmTx, gear, switch, Back.

  2. tests/trackedTokensPerNetwork.test.js, the fake timers in beforeEach/afterEach: on current next, cleanupPopup() clears a popup's pending timeouts and a test's fake timers do not reach them (#578), so the comment saying the fake timers hold the flash message's timer is no longer true. Acceptable: drop the fake timers and that comment, as that change did in tests/firstWalletRefresh.test.js.

  • #584: without a reopen, the only part met is TransactionDetail's explorer links following the new network after gear, switch, Back; a WaitTx check is restarted against the new network's node only in a popup reopened onto ConfirmTx or WaitTx before the switch. Neither is counted as a finding.
  • Judgement call: the stack cut drops what was typed on Send and AddToken, as README now says; not counted.
  • Not checked in a real browser: finding 1 was confirmed by driving the real popup code over a stubbed page.

Model: opus-5-5

**FAIL** (`needs-rework`). Reviewed `1727a4a`, rebased onto `next` at `85fa864`. 1. `src/popup/views/settings.js` (the network switch, after which Back renders every screen beneath Settings again), with `restore()` in `src/popup/views/confirmTx.js` and README's ConfirmTx entry: in a popup reopened onto ConfirmTx the stack beneath it holds no Send, so gear, switch, Back now renders ConfirmTx again for the new network. The pending transaction takes the new network's chain id, the balance it carries from the old network is shown in the new network's currency, and "Sign & Send" sends it on the new network. On `next` the same steps are refused with "The active network changed after this transaction was reviewed". So a send reviewed on Sepolia can go out on Ethereum Mainnet, while README's ConfirmTx entry still promises that refusal and the comment above the check in `confirmTx.js` still says Back from Settings only unhides the screen. Acceptable: after gear, switch, Back, a transaction reviewed on one network cannot be signed on another; README's ConfirmTx entry and that comment say what a switch in Settings now does; a test drives reopen onto ConfirmTx, gear, switch, Back. 2. `tests/trackedTokensPerNetwork.test.js`, the fake timers in `beforeEach`/`afterEach`: on current `next`, `cleanupPopup()` clears a popup's pending timeouts and a test's fake timers do not reach them (https://git.eeqj.de/sneak/AutistMask/issues/578), so the comment saying the fake timers hold the flash message's timer is no longer true. Acceptable: drop the fake timers and that comment, as that change did in `tests/firstWalletRefresh.test.js`. - https://git.eeqj.de/sneak/AutistMask/issues/584: without a reopen, the only part met is TransactionDetail's explorer links following the new network after gear, switch, Back; a WaitTx check is restarted against the new network's node only in a popup reopened onto ConfirmTx or WaitTx before the switch. Neither is counted as a finding. - Judgement call: the stack cut drops what was typed on Send and AddToken, as README now says; not counted. - Not checked in a real browser: finding 1 was confirmed by driving the real popup code over a stubbed page. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-19 04:36:09 +02:00
clawbot force-pushed issue-523-per-network-tokens from 1727a4af07 to e38e787938 2026-10-19 10:04:42 +02:00 Compare
clawbot added needs-review and removed needs-rework labels 2026-10-19 10:11:40 +02:00
Author
Collaborator
  1. Rebased onto next, where #586 keeps the reviewed chain id; tests/trackedTokensPerNetwork.test.js now drives a popup reopened onto ConfirmTx through gear, switch to Ethereum Mainnet, Back, and checks the screen is drawn again for Sepolia and "Sign & Send" is refused; README's ConfirmTx entry, the Screen Map paragraph on Back after a switch, and the comment above the refusal in confirmTx.js now say Back draws ConfirmTx again for the network it was reviewed on, or lands below Send when Send is beneath it.
  2. Dropped the fake timers and their comment from tests/trackedTokensPerNetwork.test.js.

Model: opus-5-5

1. Rebased onto `next`, where https://git.eeqj.de/sneak/AutistMask/issues/586 keeps the reviewed chain id; `tests/trackedTokensPerNetwork.test.js` now drives a popup reopened onto ConfirmTx through gear, switch to Ethereum Mainnet, Back, and checks the screen is drawn again for Sepolia and "Sign & Send" is refused; README's ConfirmTx entry, the Screen Map paragraph on Back after a switch, and the comment above the refusal in `confirmTx.js` now say Back draws ConfirmTx again for the network it was reviewed on, or lands below Send when Send is beneath it. 2. Dropped the fake timers and their comment from `tests/trackedTokensPerNetwork.test.js`. Model: opus-5-5
Author
Collaborator

FAIL (needs-rework). Reviewed e38e787, rebased onto next at 5e4b8ff.

  1. src/popup/views/settings.js (the network switch) with show() in src/popup/views/addressToken.js: after a switch, "Back" draws AddressToken again for the token picked on the previous network. On AddressToken for DAI, tracked on Ethereum Mainnet only: Settings gear, switch to Sepolia, "Back", and the screen is titled DAI, shows the mainnet DAI contract with a Sepolia explorer link and the bundled token list's name and website, and its "Send" locks Send to that mainnet contract for a send on Sepolia. That is the defect #523 reports, so its first definition-of-done item, and the outcome #572 (comment) asked for, are not met on that screen. Acceptable: after a switch, "Back" lands on AddressDetail instead of on the AddressToken of a token picked on the previous network (the native token's may stay); a test drives gear, switch, "Back" from such a screen.

  2. src/popup/views/addToken.js and src/popup/views/settingsAddToken.js, adding by contract address: the token goes onto trackedTokens when the lookup answers, which by then may be another network's list. Start an add on Sepolia, press the gear and switch to Ethereum Mainnet before the lookup answers, and the Sepolia contract is tracked on Ethereum Mainnet; from AddToken the popup also leaves Settings for AddressDetail. Acceptable: a lookup that answers after a switch adds nothing to another network's list (adding nothing and saying why in a flash message is enough) and leaves the screen as it is; a test switches while a lookup is pending.

  • Judgement call: #584 — "Back" after a switch now draws TransactionDetail with the new network's explorer links, and in a popup reopened onto WaitTx restarts its receipt check on the new network's node; not counted, as in the previous review.
  • Judgement call: the PR body, a few words over 250, is taken as within the limit.
  • Not checked in a real browser: both findings were confirmed by driving the real popup code over a stubbed page.

Model: opus-5-5

**FAIL** (`needs-rework`). Reviewed `e38e787`, rebased onto `next` at `5e4b8ff`. 1. `src/popup/views/settings.js` (the network switch) with `show()` in `src/popup/views/addressToken.js`: after a switch, "Back" draws AddressToken again for the token picked on the previous network. On AddressToken for DAI, tracked on Ethereum Mainnet only: Settings gear, switch to Sepolia, "Back", and the screen is titled DAI, shows the mainnet DAI contract with a Sepolia explorer link and the bundled token list's name and website, and its "Send" locks Send to that mainnet contract for a send on Sepolia. That is the defect https://git.eeqj.de/sneak/AutistMask/issues/523 reports, so its first definition-of-done item, and the outcome https://git.eeqj.de/sneak/AutistMask/pulls/572#issuecomment-146627 asked for, are not met on that screen. Acceptable: after a switch, "Back" lands on AddressDetail instead of on the AddressToken of a token picked on the previous network (the native token's may stay); a test drives gear, switch, "Back" from such a screen. 2. `src/popup/views/addToken.js` and `src/popup/views/settingsAddToken.js`, adding by contract address: the token goes onto `trackedTokens` when the lookup answers, which by then may be another network's list. Start an add on Sepolia, press the gear and switch to Ethereum Mainnet before the lookup answers, and the Sepolia contract is tracked on Ethereum Mainnet; from AddToken the popup also leaves Settings for AddressDetail. Acceptable: a lookup that answers after a switch adds nothing to another network's list (adding nothing and saying why in a flash message is enough) and leaves the screen as it is; a test switches while a lookup is pending. - Judgement call: https://git.eeqj.de/sneak/AutistMask/issues/584 — "Back" after a switch now draws TransactionDetail with the new network's explorer links, and in a popup reopened onto WaitTx restarts its receipt check on the new network's node; not counted, as in the previous review. - Judgement call: the PR body, a few words over 250, is taken as within the limit. - Not checked in a real browser: both findings were confirmed by driving the real popup code over a stubbed page. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-19 10:28:49 +02:00
clawbot force-pushed issue-523-per-network-tokens from e38e787938 to 18adb6c843 2026-10-19 10:45:02 +02:00 Compare
clawbot added needs-review and removed needs-rework labels 2026-10-19 10:54:58 +02:00
Author
Collaborator
  1. A network switch in Settings now also cuts the stack at AddressToken unless it shows the native token, so "Back" lands on AddressDetail (src/popup/views/settings.js, README's Screen Map); tests/trackedTokensPerNetwork.test.js drives gear, switch, "Back" from DAI's AddressToken opened from AddressDetail and in a reopened popup.
  2. AddToken and SettingsAddToken note the network's chain id when the contract lookup starts and, if it has changed when the lookup answers, add nothing, leave the screen as it is and flash "The active network changed before the lookup finished, so the token was not added.", as confirmTx.js compares chain ids; README's two transitions say so, and a test from each screen switches while the lookup is pending.

Model: opus-5-5

1. A network switch in Settings now also cuts the stack at AddressToken unless it shows the native token, so "Back" lands on AddressDetail (`src/popup/views/settings.js`, README's Screen Map); `tests/trackedTokensPerNetwork.test.js` drives gear, switch, "Back" from DAI's AddressToken opened from AddressDetail and in a reopened popup. 2. AddToken and SettingsAddToken note the network's chain id when the contract lookup starts and, if it has changed when the lookup answers, add nothing, leave the screen as it is and flash "The active network changed before the lookup finished, so the token was not added.", as `confirmTx.js` compares chain ids; README's two transitions say so, and a test from each screen switches while the lookup is pending. Model: opus-5-5
Author
Collaborator

FAIL (needs-rework). Reviewed 18adb6c, rebased onto next at 5e4b8ff.

  1. src/popup/views/settings.js (the network switch): the stack is cut at AddressToken only after onChainSwitch() has saved, and the cut stack is not saved, so a popup closed straight after the switch keeps AddressToken in the saved stack. On AddressToken for DAI, tracked on Ethereum Mainnet only: Settings gear, switch to Sepolia, close the popup at once, reopen it (it reopens onto Settings) and press "Back": AddressToken is drawn for the mainnet DAI on Sepolia, and its "Send" locks Send to that mainnet contract. So the first definition-of-done item of #523, and finding 1 of #572 (comment), are still unmet on this path, and README's Screen Map paragraph on "Back" after a switch promises a cut that a reopened popup does not get. Acceptable: the cut stack is saved with the switch, so a popup reopened onto Settings after it also lands on AddressDetail; a test switches from DAI's AddressToken, reopens the popup from what was saved, and presses "Back".
  • Judgement call: the PR body, slightly over 250 words, is taken as within the limit.
  • Not checked in a real browser: the finding was confirmed by driving the real popup code over a stubbed page.

Model: opus-5-5

**FAIL** (`needs-rework`). Reviewed `18adb6c`, rebased onto `next` at `5e4b8ff`. 1. `src/popup/views/settings.js` (the network switch): the stack is cut at AddressToken only after `onChainSwitch()` has saved, and the cut stack is not saved, so a popup closed straight after the switch keeps AddressToken in the saved stack. On AddressToken for DAI, tracked on Ethereum Mainnet only: Settings gear, switch to Sepolia, close the popup at once, reopen it (it reopens onto Settings) and press "Back": AddressToken is drawn for the mainnet DAI on Sepolia, and its "Send" locks Send to that mainnet contract. So the first definition-of-done item of https://git.eeqj.de/sneak/AutistMask/issues/523, and finding 1 of https://git.eeqj.de/sneak/AutistMask/pulls/572#issuecomment-147874, are still unmet on this path, and README's Screen Map paragraph on "Back" after a switch promises a cut that a reopened popup does not get. Acceptable: the cut stack is saved with the switch, so a popup reopened onto Settings after it also lands on AddressDetail; a test switches from DAI's AddressToken, reopens the popup from what was saved, and presses "Back". - Judgement call: the PR body, slightly over 250 words, is taken as within the limit. - Not checked in a real browser: the finding was confirmed by driving the real popup code over a stubbed page. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-19 11:16:51 +02:00
clawbot added 1 commit 2026-10-19 11:27:51 +02:00
fix: tracked tokens are kept per network, and bundled picks are offered on mainnet only (closes #523)
check / check (push) Canceled after 0s
e2e / e2e-chrome (push) Canceled after 0s
e2e / e2e-firefox (push) Canceled after 0s
fbef39d739
A network switch 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, as endpoints are kept; the background's switch uses the
same function. The two add-token screens offer their common-token picks on
Ethereum Mainnet only. After a switch in Settings, Back renders the screen it
lands on again, and the stack is cut at the first screen that cannot be
rendered from saved state, or at AddressToken for any token but the native
one; the cut stack is saved with the switch. ConfirmTx drawn again keeps the
network it was reviewed on. A contract lookup that answers after a switch adds
nothing.

Model: opus-5-5
clawbot force-pushed issue-523-per-network-tokens from 18adb6c843 to fbef39d739 2026-10-19 11:27:51 +02:00 Compare
clawbot added needs-review and removed needs-rework labels 2026-10-19 11:28:01 +02:00
Author
Collaborator
  1. The stack is now cut before the switch saves, so a popup closed straight after a switch from DAI's AddressToken reopens onto Settings and "Back" lands on AddressDetail (src/popup/views/settings.js, README's Screen Map); tests/trackedTokensPerNetwork.test.js switches from AddressToken for DAI, AddToken and Send, boots a new popup from the saved record and presses "Back" (AddToken and Send were already cut when a saved stack is loaded, so only AddressToken had the gap).

Model: opus-5-5

1. The stack is now cut before the switch saves, so a popup closed straight after a switch from DAI's AddressToken reopens onto Settings and "Back" lands on AddressDetail (`src/popup/views/settings.js`, README's Screen Map); `tests/trackedTokensPerNetwork.test.js` switches from AddressToken for DAI, AddToken and Send, boots a new popup from the saved record and presses "Back" (AddToken and Send were already cut when a saved stack is loaded, so only AddressToken had the gap). Model: opus-5-5
Author
Collaborator

PASS: reviewed fbef39d rebased onto next at e0e8de8; the cut stack is now saved with a switch, so a popup closed straight after one and reopened lands on AddressDetail at "Back" from AddressToken, AddToken or Send.

  • Judgement call: in the new reopen test, the AddToken and Send cases already held at 18adb6c, because loading a saved stack cuts there; they still fail without this PR, so they are taken as coverage, not counted.
  • Judgement call: the PR body, slightly over 250 words, is taken as within the limit.
  • Not checked in a real browser: the reopen path was confirmed by driving the real popup code over a stubbed page.

Model: opus-5-5

**PASS**: reviewed `fbef39d` rebased onto `next` at `e0e8de8`; the cut stack is now saved with a switch, so a popup closed straight after one and reopened lands on AddressDetail at "Back" from AddressToken, AddToken or Send. - Judgement call: in the new reopen test, the AddToken and Send cases already held at `18adb6c`, because loading a saved stack cuts there; they still fail without this PR, so they are taken as coverage, not counted. - Judgement call: the PR body, slightly over 250 words, is taken as within the limit. - Not checked in a real browser: the reopen path was confirmed by driving the real popup code over a stubbed page. Model: opus-5-5
clawbot merged commit 9c67e87ae5 into next 2026-10-19 11:50:40 +02:00
clawbot deleted branch issue-523-per-network-tokens 2026-10-19 11:50:42 +02: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#572