From 28f03a6b93c86a0f06eabc16dd02fff34e1a6b06 Mon Sep 17 00:00:00 2001 From: lwin Date: Mon, 18 May 2026 17:27:45 +0800 Subject: [PATCH 1/5] fix: do not chain switch on account switch if on the same chain namespace --- .../auth-connector/authConnector.ts | 9 +- .../metamask-connector/metamaskConnector.ts | 12 +++ packages/no-modal/src/noModal.ts | 30 +++++-- packages/no-modal/test/noModal.test.ts | 82 +++++++++++++++++++ 4 files changed, 124 insertions(+), 9 deletions(-) diff --git a/packages/no-modal/src/connectors/auth-connector/authConnector.ts b/packages/no-modal/src/connectors/auth-connector/authConnector.ts index 03c1da7cc..fd1f6e699 100644 --- a/packages/no-modal/src/connectors/auth-connector/authConnector.ts +++ b/packages/no-modal/src/connectors/auth-connector/authConnector.ts @@ -590,16 +590,17 @@ class AuthConnector extends BaseConnector implements IAuthConne account: Pick, preferredChainId?: string | null ): string { + const accountChainNamespace = account.chainNamespace ? parseChainNamespaceFromCitadelResponse(account.chainNamespace) : null; + if (preferredChainId) { const preferredChain = this.coreOptions.chains.find((chain) => chain.chainId === preferredChainId); - if (preferredChain && (!account.chainNamespace || preferredChain.chainNamespace === account.chainNamespace)) { + if (preferredChain && (!accountChainNamespace || preferredChain.chainNamespace === accountChainNamespace)) { return preferredChainId; } } - if (account.chainNamespace) { - const parsedChainNamespace = parseChainNamespaceFromCitadelResponse(account.chainNamespace); - const namespaceChain = this.coreOptions.chains.find((chain) => chain.chainNamespace === parsedChainNamespace); + if (accountChainNamespace) { + const namespaceChain = this.coreOptions.chains.find((chain) => chain.chainNamespace === accountChainNamespace); if (namespaceChain) { return namespaceChain.chainId; } diff --git a/packages/no-modal/src/connectors/metamask-connector/metamaskConnector.ts b/packages/no-modal/src/connectors/metamask-connector/metamaskConnector.ts index 482f295a6..0a8f90572 100644 --- a/packages/no-modal/src/connectors/metamask-connector/metamaskConnector.ts +++ b/packages/no-modal/src/connectors/metamask-connector/metamaskConnector.ts @@ -264,6 +264,18 @@ class MetaMaskConnector extends BaseConnector { } async connect({ chainId, getAuthTokenInfo, caipAccountIds: caipAccountIdsFromParams }: BaseConnectorLoginParams): Promise { + // if (this.connected && caipAccountIdsFromParams.length > 0) { + // const currentSession = await this.multichainClient?.provider.getSession(); + // const scope: Scope = getCaipChainId(this.coreOptions.chains.find((x) => x.chainId === chainId)) as Scope; + // // if the scope is already in the connected session + // if (scope && Object.keys(currentSession?.sessionScopes ?? {}).includes(scope)) { + // const caipAccountId = caipAccountIdsFromParams[0]; + // if (caipAccountId && currentSession.sessionScopes[scope]?.accounts.includes(caipAccountId)) { + // this.switchChain({ chainId }); + // } + // } + // } + super.checkConnectionRequirements(); await this.ensureInitialized(); diff --git a/packages/no-modal/src/noModal.ts b/packages/no-modal/src/noModal.ts index 47a6996f3..3942fa7e7 100644 --- a/packages/no-modal/src/noModal.ts +++ b/packages/no-modal/src/noModal.ts @@ -1354,6 +1354,24 @@ export class Web3AuthNoModal extends SafeEventEmitter imp return finalChainId; } + /** + * Resolves the chain ID for a switch account operation. + * If the account's chain namespace is the same as the current chain namespace, return the current chain ID. + * If the account's chain namespace is different from the current chain namespace, return the chainId the account was linked in. + * + * @param account - The account to switch to. + * @param activeChainId - The current active chain ID. + * @returns The resolved chain ID. + */ + protected resolveSwitchAccountChainId(account: Pick, activeChainId: string): string { + const targetChainNamespace = account.chainNamespace ? parseChainNamespaceFromCitadelResponse(account.chainNamespace) : null; + if (targetChainNamespace && this.currentChain.chainNamespace === targetChainNamespace) { + return this.currentChain.chainId; + } + + return activeChainId; + } + protected async createLinkingWalletConnector( connectorName: WALLET_CONNECTOR_TYPE | string, chainId: string, @@ -1527,6 +1545,8 @@ export class Web3AuthNoModal extends SafeEventEmitter imp switchResult: AuthConnectorSwitchAccountResult, options: { walletConnector?: IConnector; projectConfig?: ProjectConfig } = {} ): Promise { + const resolvedSwitchChainId = this.resolveSwitchAccountChainId(switchResult.targetAccount, switchResult.activeChainId); + if (switchResult.kind === "primary") { const existingPrimaryConnectedWalletState = this.getConnectedWalletConnectorState(); const primaryConnectedWalletState = @@ -1551,17 +1571,17 @@ export class Web3AuthNoModal extends SafeEventEmitter imp const walletConnector = options.walletConnector ?? this.getConnectedWalletConnector(switchResult.targetAccount) ?? - (await this.createSwitchingWalletConnector(switchResult.targetAccount.connector, switchResult.activeChainId, options.projectConfig)); + (await this.createSwitchingWalletConnector(switchResult.targetAccount.connector, resolvedSwitchChainId, options.projectConfig)); let linkedAccountConnection: Connection | null = null; try { if (!this.hasUsableConnectedSwitchConnector(walletConnector)) { - const switchChainConfig = this.coreOptions.chains.find((c) => c.chainId === switchResult.activeChainId); + const switchChainConfig = this.coreOptions.chains.find((c) => c.chainId === resolvedSwitchChainId); if (!switchChainConfig) { - throw WalletLoginError.connectionError(`Chain config is not available for chain ${switchResult.activeChainId}`); + throw WalletLoginError.connectionError(`Chain config is not available for chain ${resolvedSwitchChainId}`); } const caipChainId = getCaipChainId(switchChainConfig); const caipAccountId = `${caipChainId}:${switchResult.targetAccount.eoaAddress}` as CaipAccountId; - linkedAccountConnection = await walletConnector.connect({ chainId: switchResult.activeChainId, caipAccountIds: [caipAccountId] }); + linkedAccountConnection = await walletConnector.connect({ chainId: resolvedSwitchChainId, caipAccountIds: [caipAccountId] }); if (!linkedAccountConnection) { throw AccountLinkingError.requestFailed( `Failed to connect isolated connector "${switchResult.targetAccount.connector}" for account switch.` @@ -1583,7 +1603,7 @@ export class Web3AuthNoModal extends SafeEventEmitter imp } } - await this.setCurrentChain(switchResult.activeChainId); + await this.setCurrentChain(resolvedSwitchChainId); await this.setState({ activeAccount: switchResult.activeAccount }); const connection = this.connection; if (!connection) { diff --git a/packages/no-modal/test/noModal.test.ts b/packages/no-modal/test/noModal.test.ts index 957284d6a..1d6b2be4b 100644 --- a/packages/no-modal/test/noModal.test.ts +++ b/packages/no-modal/test/noModal.test.ts @@ -16,6 +16,7 @@ import { WalletLoginError, WEB3AUTH_STATE_STORAGE_KEY, } from "../src/base"; +import { authConnector } from "../src/connectors/auth-connector"; import { Web3AuthNoModal } from "../src/noModal"; import { createChain, createMockStorage, createProjectConfig, MockConnector, MULTICHAIN_CONNECTOR_NAMESPACE } from "./helpers"; @@ -224,6 +225,32 @@ describe("Web3AuthNoModal", () => { }); }); + it("keeps the preferred chain when the linked account stays in the same namespace", () => { + const connector = authConnector()({ + projectConfig: createProjectConfig(), + coreOptions: { + clientId: "test-client-id", + web3AuthNetwork: "sapphire_devnet", + chains: [ + createChain({ + chainId: "0xaa36a7", + rpcTarget: "https://rpc.ankr.com/eth_sepolia", + displayName: "Ethereum Sepolia", + }), + createChain(), + ], + } as never, + analytics: { track: vi.fn() } as never, + }) as unknown as { + getChainIdForConnectedAccount: ( + account: Pick, + preferredChainId?: string | null + ) => string; + }; + + expect(connector.getChainIdForConnectedAccount(createExternalAccount({ chainNamespace: "evm" }), "0xaa36a7")).toBe("0xaa36a7"); + }); + it("switches back to the primary account without rebinding the AUTH provider proxy", async () => { const activeAccount = createExternalAccount(); const sdk = createSdk( @@ -301,6 +328,61 @@ describe("Web3AuthNoModal", () => { }); }); + it("reuses the current chain when switching linked accounts within the same namespace", async () => { + const sdk = createSdk( + { + chains: [ + createChain({ + chainId: "0xaa36a7", + rpcTarget: "https://rpc.ankr.com/eth_sepolia", + displayName: "Ethereum Sepolia", + }), + createChain(), + ], + }, + { + connectedConnectorName: WALLET_CONNECTORS.AUTH, + currentChainId: "0xaa36a7", + } + ); + await Promise.resolve(); + + const targetAccount = createExternalAccount({ chainNamespace: "evm" }); + const linkedProvider = { request: vi.fn() }; + const walletConnector = new MockConnector({ + name: WALLET_CONNECTORS.METAMASK, + status: CONNECTOR_STATUS.READY, + } as never); + walletConnector.connect = vi.fn().mockResolvedValue({ + connectorName: WALLET_CONNECTORS.METAMASK, + ethereumProvider: linkedProvider as never, + solanaWallet: null, + }); + + const authConnector = { + assertSwitchAccountConnectorMatchesTarget: vi.fn().mockResolvedValue(undefined), + toSwitchAccountConnectorError: vi.fn((_: unknown, error: unknown) => error), + } as never; + + await sdk.exposeProcessSwitchAccountResult( + authConnector, + { + kind: "external", + targetAccount, + activeAccount: targetAccount, + activeChainId: "0x1", + }, + { walletConnector } + ); + + expect(walletConnector.connect).toHaveBeenCalledWith( + expect.objectContaining({ + chainId: "0xaa36a7", + }) + ); + expect(sdk.currentChainId).toBe("0xaa36a7"); + }); + it("rehydrates an active linked account without rebinding the AUTH proxy to the linked wallet", async () => { const activeAccount = createExternalAccount(); const sdk = createSdk( From 27c2e0a2f973fa01385e8dbeaf39506ba36f69b6 Mon Sep 17 00:00:00 2001 From: lwin Date: Mon, 18 May 2026 17:32:02 +0800 Subject: [PATCH 2/5] chore: update demo --- demo/vue-app-new/src/components/AppDashboard.vue | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/demo/vue-app-new/src/components/AppDashboard.vue b/demo/vue-app-new/src/components/AppDashboard.vue index 4442d19fd..192dfff1b 100644 --- a/demo/vue-app-new/src/components/AppDashboard.vue +++ b/demo/vue-app-new/src/components/AppDashboard.vue @@ -17,15 +17,7 @@ import { CONNECTOR_INITIAL_AUTHENTICATION_MODE } from "@web3auth/no-modal"; import { useI18n } from "petite-vue-i18n"; import { useSignMessage as useSolanaSignMessage, useSolanaWallet, useSolanaClient } from "@web3auth/modal/vue/solana"; -import { - useConnection, - useBalance, - useChainId, - useSignMessage, - useSignTypedData, - useSwitchChain as useWagmiSwitchChain, - useConfig, -} from "@wagmi/vue"; +import { useConnection, useBalance, useSignMessage, useSignTypedData, useSwitchChain as useWagmiSwitchChain, useConfig } from "@wagmi/vue"; import { getCapabilities, getCallsStatus, sendCalls, showCallsStatus } from "@wagmi/core"; import { parseEther } from "viem"; import { createWalletTransactionSigner, toAddress } from "@solana/client"; @@ -56,7 +48,6 @@ const { getAuthTokenInfo, loading: getAuthTokenInfoLoading } = useAuthTokenInfo( const { status, address } = useConnection(); const { mutateAsync: signTypedDataAsync } = useSignTypedData(); const { mutateAsync: signMessageAsync } = useSignMessage(); -const wagmiChainId = useChainId(); const balance = useBalance({ address: address, }); @@ -182,7 +173,7 @@ const onGetPrivateKey = async () => { }; const getConnectedChainId = async () => { - printToConsole("chainId", wagmiChainId.value); + printToConsole("chainId", web3Auth.value?.currentChain?.chainId); }; const onGetBalance = async () => { From 4e1a921e77e1bad0b9e400b75d2846fd920838aa Mon Sep 17 00:00:00 2001 From: lwin Date: Mon, 18 May 2026 17:35:27 +0800 Subject: [PATCH 3/5] chore: removed unused codes --- .../metamask-connector/metamaskConnector.ts | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/packages/no-modal/src/connectors/metamask-connector/metamaskConnector.ts b/packages/no-modal/src/connectors/metamask-connector/metamaskConnector.ts index 0a8f90572..482f295a6 100644 --- a/packages/no-modal/src/connectors/metamask-connector/metamaskConnector.ts +++ b/packages/no-modal/src/connectors/metamask-connector/metamaskConnector.ts @@ -264,18 +264,6 @@ class MetaMaskConnector extends BaseConnector { } async connect({ chainId, getAuthTokenInfo, caipAccountIds: caipAccountIdsFromParams }: BaseConnectorLoginParams): Promise { - // if (this.connected && caipAccountIdsFromParams.length > 0) { - // const currentSession = await this.multichainClient?.provider.getSession(); - // const scope: Scope = getCaipChainId(this.coreOptions.chains.find((x) => x.chainId === chainId)) as Scope; - // // if the scope is already in the connected session - // if (scope && Object.keys(currentSession?.sessionScopes ?? {}).includes(scope)) { - // const caipAccountId = caipAccountIdsFromParams[0]; - // if (caipAccountId && currentSession.sessionScopes[scope]?.accounts.includes(caipAccountId)) { - // this.switchChain({ chainId }); - // } - // } - // } - super.checkConnectionRequirements(); await this.ensureInitialized(); From ca4a1fbbd89b8a30b5766714ef1b02e004408d49 Mon Sep 17 00:00:00 2001 From: lwin Date: Mon, 18 May 2026 18:00:42 +0800 Subject: [PATCH 4/5] fix: fixed tests --- packages/modal/src/modalManager.ts | 6 ++--- packages/modal/test/modalManager.test.ts | 14 +++++------ packages/no-modal/test/noModal.test.ts | 31 +++++++++++------------- 3 files changed, 24 insertions(+), 27 deletions(-) diff --git a/packages/modal/src/modalManager.ts b/packages/modal/src/modalManager.ts index 48bb03061..1e4cd7897 100644 --- a/packages/modal/src/modalManager.ts +++ b/packages/modal/src/modalManager.ts @@ -12,6 +12,7 @@ import { cloneDeep, type CONNECTED_EVENT_DATA, CONNECTED_STATUSES, + type ConnectedAccountInfo, type Connection, CONNECTOR_CATEGORY, CONNECTOR_EVENTS, @@ -29,7 +30,6 @@ import { IWeb3AuthState, type LinkAccountParams, type LinkAccountResult, - type LinkedAccountInfo, log, LOGIN_MODE, type LoginMethodConfig, @@ -215,7 +215,7 @@ export class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal { public async connect(): Promise { if (!this.loginModal) throw WalletInitializationError.notReady("Login modal is not initialized"); // if already connected return connection - if (this.connectedConnectorName && CONNECTED_STATUSES.includes(this.status) && this.connection) return this.connection; + if (CONNECTED_STATUSES.includes(this.status) && this.connection) return this.connection; this.loginModal.open(); return new Promise((resolve, reject) => { // remove all listeners when promise is resolved or rejected. @@ -266,7 +266,7 @@ export class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal { await super.completeConsentAcceptance(); } - public async switchAccount(account: LinkedAccountInfo): Promise { + public async switchAccount(account: ConnectedAccountInfo): Promise { const authConnector = this.getMainAuthConnector(); const switchResult = await authConnector.switchAccount(account, { activeAccount: this.activeAccount, diff --git a/packages/modal/test/modalManager.test.ts b/packages/modal/test/modalManager.test.ts index 4888043a8..678d0e565 100644 --- a/packages/modal/test/modalManager.test.ts +++ b/packages/modal/test/modalManager.test.ts @@ -23,12 +23,12 @@ vi.mock("@web3auth/no-modal", async () => { import { CHAIN_NAMESPACES, CONNECTED_STATUSES, + type ConnectedAccountInfo, Connection, CONNECTOR_EVENTS, CONNECTOR_INITIAL_AUTHENTICATION_MODE, type IConnector, type LinkAccountResult, - type LinkedAccountInfo, type ProjectConfig, WALLET_CONNECTORS, WalletInitializationError, @@ -49,11 +49,11 @@ class TestWeb3Auth extends Web3Auth { return this.getInitializationTrackData(); } - public exposeSetConnectedWalletConnector(connector: IConnector, account?: LinkedAccountInfo | null) { + public exposeSetConnectedWalletConnector(connector: IConnector, account?: ConnectedAccountInfo | null) { this.setConnectedWalletConnector(connector, account); } - public exposeSetActiveWalletConnectorKey(account?: LinkedAccountInfo | null) { + public exposeSetActiveWalletConnectorKey(account?: ConnectedAccountInfo | null) { this.setActiveWalletConnectorKey(account); } } @@ -85,7 +85,7 @@ function createSdk(overrides: Partial = {}) { } as never); } -function createConnectedWalletAccount(overrides: Partial = {}): LinkedAccountInfo { +function createConnectedWalletAccount(overrides: Partial = {}): ConnectedAccountInfo { return { id: "wallet-1", accountType: "external_wallet", @@ -131,7 +131,7 @@ describe("Web3Auth (modal)", () => { const open = vi.fn(); (sdk as unknown as { loginModal: { open: () => void } }).loginModal = { open }; (sdk as unknown as { state: Record }).state = { - connectedConnectorName: WALLET_CONNECTORS.AUTH, + primaryConnectorName: WALLET_CONNECTORS.AUTH, cachedConnector: null, currentChainId: "0x1", idToken: null, @@ -258,7 +258,7 @@ describe("Web3Auth (modal)", () => { vi.spyOn(sdk as unknown as { getMainAuthConnector: () => unknown }, "getMainAuthConnector").mockReturnValue(authConnector as never); vi.spyOn( - sdk as unknown as { getConnectedWalletConnector: (account?: LinkedAccountInfo | null) => unknown }, + sdk as unknown as { getConnectedWalletConnector: (account?: ConnectedAccountInfo | null) => unknown }, "getConnectedWalletConnector" ).mockReturnValue(existingConnector as never); @@ -342,7 +342,7 @@ describe("Web3Auth (modal)", () => { vi.spyOn(sdk as unknown as { getMainAuthConnector: () => unknown }, "getMainAuthConnector").mockReturnValue(authConnector as never); vi.spyOn( - sdk as unknown as { getConnectedWalletConnector: (account?: LinkedAccountInfo | null) => unknown }, + sdk as unknown as { getConnectedWalletConnector: (account?: ConnectedAccountInfo | null) => unknown }, "getConnectedWalletConnector" ).mockReturnValue(null); diff --git a/packages/no-modal/test/noModal.test.ts b/packages/no-modal/test/noModal.test.ts index 7e829e2fe..8316eaafd 100644 --- a/packages/no-modal/test/noModal.test.ts +++ b/packages/no-modal/test/noModal.test.ts @@ -92,7 +92,7 @@ describe("Web3AuthNoModal", () => { const sdk = createSdk( {}, { - connectedConnectorName: WALLET_CONNECTORS.AUTH, + primaryConnectorName: WALLET_CONNECTORS.AUTH, cachedConnector: WALLET_CONNECTORS.AUTH, currentChainId: "0x1", idToken: "id-token", @@ -140,7 +140,7 @@ describe("Web3AuthNoModal", () => { const sdk = createSdk( {}, { - connectedConnectorName: WALLET_CONNECTORS.AUTH, + primaryConnectorName: WALLET_CONNECTORS.AUTH, currentChainId: "0x1", activeAccount, } @@ -167,7 +167,7 @@ describe("Web3AuthNoModal", () => { const sdk = createSdk( {}, { - connectedConnectorName: WALLET_CONNECTORS.AUTH, + primaryConnectorName: WALLET_CONNECTORS.AUTH, currentChainId: "0x1", } ); @@ -242,13 +242,10 @@ describe("Web3AuthNoModal", () => { } as never, analytics: { track: vi.fn() } as never, }) as unknown as { - getChainIdForConnectedAccount: ( - account: Pick, - preferredChainId?: string | null - ) => string; + getChainIdForLinkedAccount: (account: Pick, preferredChainId?: string | null) => string; }; - expect(connector.getChainIdForConnectedAccount(createExternalAccount({ chainNamespace: "evm" }), "0xaa36a7")).toBe("0xaa36a7"); + expect(connector.getChainIdForLinkedAccount(createExternalAccount({ chainNamespace: "evm" }), "0xaa36a7")).toBe("0xaa36a7"); }); it("switches back to the primary account without rebinding the AUTH provider proxy", async () => { @@ -256,7 +253,7 @@ describe("Web3AuthNoModal", () => { const sdk = createSdk( {}, { - connectedConnectorName: WALLET_CONNECTORS.AUTH, + primaryConnectorName: WALLET_CONNECTORS.AUTH, currentChainId: "0x1", } ); @@ -341,7 +338,7 @@ describe("Web3AuthNoModal", () => { ], }, { - connectedConnectorName: WALLET_CONNECTORS.AUTH, + primaryConnectorName: WALLET_CONNECTORS.AUTH, currentChainId: "0xaa36a7", } ); @@ -388,7 +385,7 @@ describe("Web3AuthNoModal", () => { const sdk = createSdk( {}, { - connectedConnectorName: WALLET_CONNECTORS.AUTH, + primaryConnectorName: WALLET_CONNECTORS.AUTH, cachedConnector: WALLET_CONNECTORS.AUTH, currentChainId: "0x1", activeAccount, @@ -446,7 +443,7 @@ describe("Web3AuthNoModal", () => { it("clearCache resets persisted state fields", async () => { const sdk = createSdk(); (sdk as unknown as { state: Record }).state = { - connectedConnectorName: WALLET_CONNECTORS.AUTH, + primaryConnectorName: WALLET_CONNECTORS.AUTH, cachedConnector: WALLET_CONNECTORS.AUTH, currentChainId: "0x1", idToken: "id-token", @@ -456,7 +453,7 @@ describe("Web3AuthNoModal", () => { await sdk.clearCache(); const state = (sdk as unknown as { state: Record }).state; - expect(state.connectedConnectorName).toBeNull(); + expect(state.primaryConnectorName).toBeNull(); expect(state.cachedConnector).toBeNull(); expect(state.currentChainId).toBeNull(); expect(state.idToken).toBeNull(); @@ -468,7 +465,7 @@ describe("Web3AuthNoModal", () => { const sdk = createSdk( {}, { - connectedConnectorName: WALLET_CONNECTORS.AUTH, + primaryConnectorName: WALLET_CONNECTORS.AUTH, cachedConnector: WALLET_CONNECTORS.AUTH, currentChainId: "0x1", idToken: "id-token", @@ -516,7 +513,7 @@ describe("Web3AuthNoModal", () => { const sdk = createSdk( {}, { - connectedConnectorName: WALLET_CONNECTORS.AUTH, + primaryConnectorName: WALLET_CONNECTORS.AUTH, cachedConnector: WALLET_CONNECTORS.AUTH, currentChainId: "0x1", idToken: "id-token", @@ -604,7 +601,7 @@ describe("Web3AuthNoModal", () => { } as never); (sdk as unknown as { connectors: MockConnector[] }).connectors = [connector]; (sdk as unknown as { state: Record }).state = { - connectedConnectorName: WALLET_CONNECTORS.METAMASK, + primaryConnectorName: WALLET_CONNECTORS.METAMASK, cachedConnector: null, currentChainId: "0x1", idToken: null, @@ -837,7 +834,7 @@ describe("Web3AuthNoModal", () => { it("checkIfAutoConnect returns true only for cached matching connector", () => { const sdk = createSdk(); (sdk as unknown as { state: Record }).state = { - connectedConnectorName: null, + primaryConnectorName: null, cachedConnector: WALLET_CONNECTORS.METAMASK, currentChainId: "0x1", idToken: null, From dc6724f9389b1a885f56d306c9a0024397bcfa72 Mon Sep 17 00:00:00 2001 From: lwin Date: Mon, 18 May 2026 18:06:04 +0800 Subject: [PATCH 5/5] fix: fixed build --- demo/vue-app-new/src/components/AppDashboard.vue | 2 +- packages/modal/src/modalManager.ts | 4 ++-- packages/no-modal/src/noModal.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/demo/vue-app-new/src/components/AppDashboard.vue b/demo/vue-app-new/src/components/AppDashboard.vue index 192dfff1b..c5f850554 100644 --- a/demo/vue-app-new/src/components/AppDashboard.vue +++ b/demo/vue-app-new/src/components/AppDashboard.vue @@ -96,7 +96,7 @@ const isDisplay = (name: "dashboard" | "ethServices" | "solServices" | "walletSe return Boolean(conn?.solanaWallet); case "walletServices": - return web3Auth.value?.connectedConnectorName === WALLET_CONNECTORS.AUTH && Boolean(conn?.ethereumProvider || conn?.solanaWallet); + return web3Auth.value?.primaryConnectorName === WALLET_CONNECTORS.AUTH && Boolean(conn?.ethereumProvider || conn?.solanaWallet); default: { return false; diff --git a/packages/modal/src/modalManager.ts b/packages/modal/src/modalManager.ts index 1e4cd7897..261469a74 100644 --- a/packages/modal/src/modalManager.ts +++ b/packages/modal/src/modalManager.ts @@ -12,7 +12,6 @@ import { cloneDeep, type CONNECTED_EVENT_DATA, CONNECTED_STATUSES, - type ConnectedAccountInfo, type Connection, CONNECTOR_CATEGORY, CONNECTOR_EVENTS, @@ -30,6 +29,7 @@ import { IWeb3AuthState, type LinkAccountParams, type LinkAccountResult, + type LinkedAccountInfo, log, LOGIN_MODE, type LoginMethodConfig, @@ -266,7 +266,7 @@ export class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal { await super.completeConsentAcceptance(); } - public async switchAccount(account: ConnectedAccountInfo): Promise { + public async switchAccount(account: LinkedAccountInfo): Promise { const authConnector = this.getMainAuthConnector(); const switchResult = await authConnector.switchAccount(account, { activeAccount: this.activeAccount, diff --git a/packages/no-modal/src/noModal.ts b/packages/no-modal/src/noModal.ts index 329f88515..8bb0b2413 100644 --- a/packages/no-modal/src/noModal.ts +++ b/packages/no-modal/src/noModal.ts @@ -1368,7 +1368,7 @@ export class Web3AuthNoModal extends SafeEventEmitter imp * @param activeChainId - The current active chain ID. * @returns The resolved chain ID. */ - protected resolveSwitchAccountChainId(account: Pick, activeChainId: string): string { + protected resolveSwitchAccountChainId(account: Pick, activeChainId: string): string { const targetChainNamespace = account.chainNamespace ? parseChainNamespaceFromCitadelResponse(account.chainNamespace) : null; if (targetChainNamespace && this.currentChain.chainNamespace === targetChainNamespace) { return this.currentChain.chainId;