fix(ethers,ethers5): resolve walletProvider after account switch in modal#5663
Open
Khizr97 wants to merge 3 commits into
Open
fix(ethers,ethers5): resolve walletProvider after account switch in modal#5663Khizr97 wants to merge 3 commits into
Khizr97 wants to merge 3 commits into
Conversation
…in connect early-return path When switching accounts in the modal, connect() takes an early-return path for existing connections but never initialised connector.provider. This caused the base-client's accountChanged handler to skip syncProvider() (which guards on connector?.provider), leaving useAppKitProvider stale. Fix: resolve connector.provider from ethersProviders before emitting the event when it is not yet set. Applies to both ethers and ethers5 adapters. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…tch fix Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
9 Skipped Deployments
|
🦋 Changeset detectedLatest commit: 3301083 The changes in this PR will be included in the next version bump. This PR includes changesets to release 26 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
enesozturk
approved these changes
May 11, 2026
Comment on lines
+465
to
+467
| if (ethersProvider) { | ||
| await ethersProvider.initialize() | ||
| connector.provider = (await ethersProvider.getProvider()) as Provider | undefined |
Contributor
There was a problem hiding this comment.
Isn't the initialize returns the provider? If so it could be like:
Suggested change
| if (ethersProvider) { | |
| await ethersProvider.initialize() | |
| connector.provider = (await ethersProvider.getProvider()) as Provider | undefined | |
| if (ethersProvider) { | |
| connector.provider = await ethersProvider.initialize() |
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.
Summary
connect()'s early-return path (used when switching accounts in the modal),connector.providerwas never initialised for connectors backed byethersProviders(injected, coinbaseWallet, baseAccount, safe)accountChangedhandler to skipsyncProvider()— leavinguseAppKitProviderreturning a stale providerconnector.providerfromethersProvidersbefore emittingaccountChanged, when it is not already set@reown/appkit-adapter-ethersand@reown/appkit-adapter-ethers5Root Cause
appkit-base-client.tsonly callssyncProvider()in theaccountChangedhandler whenconnector?.provideris truthy. The early-return path inconnect()emits the event before initialising the provider, so the guard is never satisfied.Test plan
ethersProviderswhenconnector.providerisundefinedin early-return pathconnector.provideris preserved (no re-initialisation) when already setFixes: REOWN-4657
🤖 Generated with Claude Code