fix: switch chainnamespace/network#2472
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
803e657 to
4e11a15
Compare
| } | ||
|
|
||
| get isAccountReady(): boolean { | ||
| if (this.status !== CONNECTOR_STATUS.CONNECTED && this.status !== CONNECTOR_STATUS.AUTHORIZED) { |
There was a problem hiding this comment.
use !connected_statuses.includes
| log.debug("initializing auth connector"); | ||
| await authInstancePromise; | ||
|
|
||
| if (this.wsEmbedInstancePromise) { |
There was a problem hiding this comment.
this will slow down the app by a lot.
there's a reason we made this async
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit fb385d4. Configure here.
|
|
||
| this.bindWsEmbedProviderEvents(); | ||
| if (this.providerStateSyncPromise) { | ||
| return this.providerStateSyncPromise; |
There was a problem hiding this comment.
Race condition drops chain changes during sync
Medium Severity
The syncProviderState deduplication returns the existing in-flight promise when called while a sync is already running. If handleWsEmbedChainChanged fires during an active sync (e.g., rapid chain A→B→C), the second call is silently absorbed into the first promise. When that promise resolves (potentially with chain B's state), providerStateSyncPromise is cleared in finally, but no fresh sync is scheduled for the latest chain C state. The provider state can end up stale until another event triggers a new sync.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit fb385d4. Configure here.
| if (this.wsEmbedInstance?.provider) { | ||
| return this.wsEmbedInstance.provider as IProvider; | ||
| if (this.getWsEmbedProvider()) { | ||
| return this.getWsEmbedProvider(); |
There was a problem hiding this comment.
Provider getter calls getWsEmbedProvider() twice unnecessarily
Low Severity
The provider getter calls getWsEmbedProvider() twice — once for the truthiness check and once for the return value. While the method has no side effects today, this pattern is fragile: if the underlying wsEmbedInstance reference changes between the two calls (e.g., nulled by an event between evaluations), the getter could theoretically return null despite passing the initial check. Storing the result in a local variable avoids both the redundancy and the potential inconsistency.
Reviewed by Cursor Bugbot for commit fb385d4. Configure here.


Jira Link
Description
vue-app-newdemo with Web3Auth’s multichain chain state for both "Get Connected Chain ID" and the demo switch-chain action.Problem
vue-app-newdemo relied on wagmi’s EVM chain state for chain display/switching, which could drift from Web3Auth after chain changes triggered from the wallet-services UI.Changes
useChain()for connected-chain display.useSwitchChain()for the embedded wallet switch flow.How has this been tested?
Screenshots (if appropriate)
Types of changes
Checklist
Note
Medium Risk
Touches core
AUTHconnector chain switching and adds new provider/account readiness state that gates React/Vue wagmi/solana bindings, so regressions could affect connection lifecycle and chain/account availability across namespaces.Overview
Fixes multichain switching by teaching the
AUTHconnector to sync embedded provider state (accounts/chain/unlocked) viaGET_PROVIDER_STATE, exposeisProviderStateSyncing/isAccountReady, and react tochainChanged/accountsChangedwith proper cleanup/disconnect.Updates React/Vue hook contexts and wagmi/Solana providers to gate binding until accounts are ready, avoid stale bindings during namespace changes, and dispose/recreate Solana clients only when the active chain is Solana (with race-safe reconnect handling).
Updates the
vue-app-newdashboard to switch chain namespaces viaweb3Auth.switchChain(with loading state) and only show EVM/Solana service panels based onchainNamespace. Also bumps@web3auth/ws-embedand related deps/lockfiles.Reviewed by Cursor Bugbot for commit fb385d4. Bugbot is set up for automated code reviews on this repo. Configure here.