Skip to content

fix(wallet): derive the wrong-network banner from the live session chain - #196

Merged
Nic-dorman merged 1 commit into
mainfrom
nic/wrong-network-banner-live
Jul 30, 2026
Merged

fix(wallet): derive the wrong-network banner from the live session chain#196
Nic-dorman merged 1 commit into
mainfrom
nic/wrong-network-banner-live

Conversation

@Nic-dorman

Copy link
Copy Markdown
Member

Problem

The 'Your wallet is on a different network' banner over-shows. The flag behind it was a one-shot snapshot taken at connect time: the app silently requests a chain switch, and if that request fails or is declined the flag is set — and never re-evaluated. MetaMask mobile queues requests while backgrounded, so the common sequence was: switch request sits unseen → banner appears → user approves the queued request minutes later (or switches manually) → banner stays, now stale and non-actionable.

Change

Derive the flag from the live session chain (\useAppKitNetwork) instead of the connect-time snapshot:

  • The banner shows only while a mismatch actually exists — i.e. only when tapping Switch (or approving the pending request in the wallet) is a meaningful action.
  • It self-clears the moment the wallet lands on Arbitrum One by any route: our request, the late-approved queued one, or a manual switch in the wallet.
  • Balances refresh automatically when the mismatch resolves.
  • The silent one-shot switch attempt at connect is unchanged, so users whose wallets accept it still never see the banner at all.

Also: exclude .claude/\ from vitest sweeps — git worktrees kept there carry their own test-tree copies which produce phantom failures when run against this root's config.

Testing

  • 50/50 vitest, typecheck clean.
  • Manually: connect with MetaMask parked on Ethereum mainnet → banner appears after the unanswered switch request; approve the queued request in MetaMask later → banner clears itself and balances refresh.

🤖 Generated with Claude Code

The flag was a one-shot snapshot taken at connect: when the switch
request surfaced late in the wallet (MetaMask queues requests while
backgrounded) and the user approved it, the banner never cleared -
stale, and nothing the user could meaningfully act on. Watch the
session chain via useAppKitNetwork instead: the banner shows only
while a mismatch is real, self-clears on any route to the right chain,
and balances refresh when the mismatch resolves. The silent one-shot
switch attempt at connect is unchanged.

Also exclude .claude/ worktree copies from vitest sweeps.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Nic-dorman
Nic-dorman merged commit b4e36fb into main Jul 30, 2026
4 checks passed
@Nic-dorman
Nic-dorman deleted the nic/wrong-network-banner-live branch July 30, 2026 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant