Skip to content

fix: switch chainnamespace/network#2472

Open
lwin-kyaw wants to merge 20 commits into
masterfrom
fix/switch-chain
Open

fix: switch chainnamespace/network#2472
lwin-kyaw wants to merge 20 commits into
masterfrom
fix/switch-chain

Conversation

@lwin-kyaw
Copy link
Copy Markdown
Contributor

@lwin-kyaw lwin-kyaw commented May 7, 2026

Jira Link

Description

  • Fix the Vue Solana provider so it only initializes a Solana client when the active embedded-wallet chain is Solana.
  • Sync the vue-app-new demo with Web3Auth’s multichain chain state for both "Get Connected Chain ID" and the demo switch-chain action.
  • Add safer cleanup/loading behavior around Vue chain transitions.

Problem

  • The Vue Solana provider eagerly tried to connect a Solana client whenever a Solana wallet was present, even if the embedded provider was still on an EVM chain.
  • The vue-app-new demo 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

  • Guard Solana client initialization behind the active Web3Auth chain namespace in the Vue Solana provider.
  • Re-run the Vue Solana provider setup on chain changes and dispose stale clients safely.
  • Update the demo to use Web3Auth useChain() for connected-chain display.
  • Update the demo to use Web3Auth useSwitchChain() for the embedded wallet switch flow.
  • Add loading state to the demo switch-chain button.

How has this been tested?

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

  • My code follows the code style of this project. (run lint)
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Note

Medium Risk
Touches multichain switching, consent-state transitions, and provider event handling across @web3auth/no-modal and the Vue/Wagmi/Solana adapters, so regressions could affect connection stability and chain/account state. Changes are localized and include new tests for key race conditions and wallet-services disconnect behavior.

Overview
Improves multichain correctness when switching between EVM and Solana. The Vue demo and adapters now gate EVM/Solana features by the active chainNamespace, add an explicit switch chain namespace action via web3Auth.switchChain, and sanitize persisted session config (namespaces/chains/default chain and AA chain configs) when restoring from storage.

Hardens provider syncing and lifecycle handling. The Vue Solana provider only instantiates a Framework Kit client when the active Web3Auth chain is Solana, re-syncs on chain changes, and safely disposes stale clients to avoid async race overwrites. Wagmi providers (React/Vue) now bind/unbind based on EIP-155 namespace, track the last bound provider/connector, and suppress spurious disconnect cascades during rebinds.

Fixes no-modal connector edge cases. AuthConnector now binds/unbinds ws-embed accountsChanged listeners with cleanup, switches chains using hex chainId formatting, and renames link-account params (walletConnectorconnectorToLink) with safer disconnect-on-failure. Web3AuthNoModal avoids downgrading status during CONNECTED/AUTHORIZED consent races, delays plugin connection until consent is resolved, emits pendingUserConsent on CONNECTED, and uses stored currentChainId during rehydration.

Updates deps and adds coverage. Bumps @web3auth/ws-embed (and related @web3auth/auth, @toruslabs/base-controllers, viem/ox/ws) and adds tests for ws-embed zero-account disconnect handling, Solana chain preservation, and consent race behavior.

Reviewed by Cursor Bugbot for commit 97eb7ca. Bugbot is set up for automated code reviews on this repo. Configure here.

@lwin-kyaw lwin-kyaw requested review from a team as code owners May 7, 2026 13:06
@vercel
Copy link
Copy Markdown

vercel Bot commented May 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
web3auth-web Error Error May 23, 2026 5:05am

Request Review

Comment thread demo/vue-app-new/src/components/AppDashboard.vue Outdated
arch1995
arch1995 previously approved these changes May 7, 2026
Comment thread demo/vue-app-new/src/components/AppDashboard.vue Outdated
Comment thread demo/vue-app-new/src/components/AppDashboard.vue Outdated
Comment thread packages/no-modal/src/connectors/auth-connector/authConnector.ts
Comment thread demo/vue-app-new/src/components/AppDashboard.vue Outdated
Comment thread packages/no-modal/src/react/wagmi/provider.ts Outdated
Comment thread packages/no-modal/src/vue/solana/provider.ts Outdated
Comment thread packages/no-modal/src/connectors/auth-connector/authConnector.ts Outdated
Comment thread packages/no-modal/src/connectors/auth-connector/authConnector.ts Outdated
Comment thread packages/no-modal/src/connectors/auth-connector/authConnector.ts
Comment thread packages/no-modal/src/connectors/auth-connector/authConnector.ts Outdated
Comment thread packages/no-modal/src/connectors/auth-connector/authConnector.ts Outdated
Comment thread demo/vue-app-new/src/components/AppSettings.vue
Comment thread packages/no-modal/src/vue/solana/provider.ts Outdated
Comment thread packages/no-modal/src/connectors/auth-connector/interface.ts
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ 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 ba6d624. Configure here.

Comment thread packages/no-modal/src/react/context/useWeb3AuthInnerContextValue.ts
if (isConnected && connection?.ethereumProvider) {
const shouldBindToWagmi = isConnected && chainNamespace === CHAIN_NAMESPACES.EIP155 && Boolean(connection?.ethereumProvider);

if (shouldBindToWagmi && connection?.ethereumProvider) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

already present in should


function Web3AuthWagmiProvider({ children }: PropsWithChildren) {
const { isConnected, connection } = useWeb3Auth();
const { isConnected, connection, chainNamespace } = useWeb3Auth();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there no change in solana react provider?

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.

3 participants