fix: reliable wallet connects — account switching + returning-user state cleanup - #18
Merged
Merged
Conversation
…urning users Two production UX failures after the v8 migration: 1. connect() caches the first approval, so switching accounts in the wallet and reconnecting silently returned the previously approved account. Fix: clear the cached approval and force the wallet chooser on every connect; read the address from the wallet's fresh response, never merged localStorage. 2. Returning visitors carry pre-v8 leftovers (legacy UserSession blob + a persisted 'connected' flag), so the UI claimed a connection that no longer existed. Fix: purge legacy keys on mount and reset the persisted state whenever there is no live v8 session. Also adds feedback on every connect path: success toast names the connected address so users can verify the right account; failures explain themselves; closing the popup is a graceful cancel. Verified on localhost against mainnet: sender -> recipient account switch connects the correct address.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
What
Follow-up to #17, fixing two wallet-connect failures that hit real users:
1. Account switching silently failed.
connect()caches the first approval; after switching accounts in the wallet, reconnecting returned the previously approved account — looked like "not connecting" with zero feedback. Anyone who both sends and receives streams (normal payroll usage) hits this.→ Cached approval cleared +
forceWalletSelect: trueon every connect; address read from the wallet's fresh response, never merged localStorage.2. Returning visitors carried pre-v8 leftovers. The legacy UserSession blob and a persisted
connectedflag from before the migration made the UI claim a connection that no longer existed.→ Legacy keys purged on mount; persisted state reset whenever there's no live v8 session.
Plus feedback on every path: success toast names the connected address (verify the right account at a glance), clear error toasts for locked wallet / missing STX address, graceful cancel when the popup is closed.
Verified
Localhost against mainnet with Leather: sender account → disconnect → switch to recipient in Leather → connect → correct second address, toast confirms. Typecheck + build clean.