fix(wallet): derive the wrong-network banner from the live session chain - #196
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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
🤖 Generated with Claude Code