diff --git a/packages/no-modal/src/connectors/metamask-connector/metamaskConnector.ts b/packages/no-modal/src/connectors/metamask-connector/metamaskConnector.ts index eb55e0c6d..566e7feb5 100644 --- a/packages/no-modal/src/connectors/metamask-connector/metamaskConnector.ts +++ b/packages/no-modal/src/connectors/metamask-connector/metamaskConnector.ts @@ -241,8 +241,7 @@ class MetaMaskConnector extends BaseEvmConnector { // If the error code is 4902, the network needs to be added if ((error as { code?: number })?.code === 4902) { const chainConfig = this.coreOptions.chains.find( - (x) => - x.chainId === params.chainId && ([CHAIN_NAMESPACES.EIP155, CHAIN_NAMESPACES.SOLANA] as ChainNamespaceType[]).includes(x.chainNamespace) + (x) => x.chainId === params.chainId && ([CHAIN_NAMESPACES.EIP155] as ChainNamespaceType[]).includes(x.chainNamespace) ); await this.addChain(chainConfig); await requestSwitchChain(); diff --git a/packages/no-modal/src/noModal.ts b/packages/no-modal/src/noModal.ts index aa7bff1bb..e2334e492 100644 --- a/packages/no-modal/src/noModal.ts +++ b/packages/no-modal/src/noModal.ts @@ -694,9 +694,9 @@ export class Web3AuthNoModal extends SafeEventEmitter imp const isMipdEnabled = isExternalWalletEnabled && (this.coreOptions.multiInjectedProviderDiscovery ?? true); const chainNamespaces = new Set(this.coreOptions.chains.map((chain) => chain.chainNamespace)); - // it's safe to add it here as if there is a MetaMask injected provider, this won't override it - // only set headless to true if modal SDK is used, otherwise just use the modal from native Metamask SDK - if (isBrowser() && chainNamespaces.has(CHAIN_NAMESPACES.EIP155) && !chainNamespaces.has(CHAIN_NAMESPACES.SOLANA)) { + // prioritize using MM connector over injected connector for EVM chains + if (isBrowser() && chainNamespaces.has(CHAIN_NAMESPACES.EIP155)) { + // only set headless to true if modal SDK is used, otherwise just use the modal from native Metamask SDK connectorFns.push(metaMaskConnector(modalMode ? { headless: true } : undefined)); } @@ -730,12 +730,6 @@ export class Web3AuthNoModal extends SafeEventEmitter imp } } - // it's safe to add it here as if there is a MetaMask injected provider, this won't override it - // only set headless to true if modal SDK is used, otherwise just use the modal from native Metamask SDK - if (isBrowser() && (chainNamespaces.has(CHAIN_NAMESPACES.SOLANA) || chainNamespaces.has(CHAIN_NAMESPACES.EIP155))) { - connectorFns.push(metaMaskConnector(modalMode ? { headless: true } : undefined)); - } - // add WalletConnectV2 connector if external wallets are enabled if (isBrowser() && isExternalWalletEnabled && (chainNamespaces.has(CHAIN_NAMESPACES.SOLANA) || chainNamespaces.has(CHAIN_NAMESPACES.EIP155))) { const { walletConnectV2Connector } = await import("./connectors/wallet-connect-v2-connector");