fix: switching the network in Settings does not tell open pages (no chainChanged) #500

Closed
opened 2026-10-07 23:37:32 +02:00 by clawbot · 2 comments
Collaborator

Switching the network in Settings (the settings-network change handler in src/popup/views/settings.js, which calls onChainSwitch()) saves the new network but sends no chainChanged to open tabs. Only the background's broadcastChainChanged() sends that event, and only a site's approved wallet_switchEthereumChain request reaches it.

A connected page therefore keeps the old chain id in window.ethereum.chainId until it asks eth_chainId again, and can build a transaction for the old chain, which the wallet then refuses when it prepares it.

Definition of done

  • Switching the network in Settings sends chainChanged with the new chain id to every open tab, as an approved site request does.
  • A test shows it.

Model: opus-5-5

Switching the network in Settings (the `settings-network` change handler in `src/popup/views/settings.js`, which calls `onChainSwitch()`) saves the new network but sends no `chainChanged` to open tabs. Only the background's `broadcastChainChanged()` sends that event, and only a site's approved `wallet_switchEthereumChain` request reaches it. A connected page therefore keeps the old chain id in `window.ethereum.chainId` until it asks `eth_chainId` again, and can build a transaction for the old chain, which the wallet then refuses when it prepares it. **Definition of done** - Switching the network in Settings sends `chainChanged` with the new chain id to every open tab, as an approved site request does. - A test shows it. Model: opus-5-5
Author
Collaborator

Plan: the Settings switch sends chainChanged through the same background function an approved site request uses, so both paths tell open pages; a switch to the active network sends nothing. A jest test fails first on next.

Model: opus-5-5

Plan: the Settings switch sends `chainChanged` through the same background function an approved site request uses, so both paths tell open pages; a switch to the active network sends nothing. A jest test fails first on `next`. Model: opus-5-5
Author
Collaborator

Built in #503: once Settings has saved a switch, the background sends chainChanged with the new chain id to every open tab through the same function an approved site request uses. Choosing the network already active sends nothing.

Model: opus-5-5

Built in https://git.eeqj.de/sneak/AutistMask/pulls/503: once Settings has saved a switch, the background sends `chainChanged` with the new chain id to every open tab through the same function an approved site request uses. Choosing the network already active sends nothing. 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#500