Skip to content

Commit c4cbbe5

Browse files
committed
fix: skip adding MM connector for solana chain
1 parent 95eb8f7 commit c4cbbe5

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

packages/no-modal/src/connectors/metamask-connector/metamaskConnector.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,7 @@ class MetaMaskConnector extends BaseEvmConnector<void> {
241241
// If the error code is 4902, the network needs to be added
242242
if ((error as { code?: number })?.code === 4902) {
243243
const chainConfig = this.coreOptions.chains.find(
244-
(x) =>
245-
x.chainId === params.chainId && ([CHAIN_NAMESPACES.EIP155, CHAIN_NAMESPACES.SOLANA] as ChainNamespaceType[]).includes(x.chainNamespace)
244+
(x) => x.chainId === params.chainId && ([CHAIN_NAMESPACES.EIP155] as ChainNamespaceType[]).includes(x.chainNamespace)
246245
);
247246
await this.addChain(chainConfig);
248247
await requestSwitchChain();

packages/no-modal/src/noModal.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -694,9 +694,9 @@ export class Web3AuthNoModal extends SafeEventEmitter<Web3AuthNoModalEvents> imp
694694
const isMipdEnabled = isExternalWalletEnabled && (this.coreOptions.multiInjectedProviderDiscovery ?? true);
695695
const chainNamespaces = new Set(this.coreOptions.chains.map((chain) => chain.chainNamespace));
696696

697-
// it's safe to add it here as if there is a MetaMask injected provider, this won't override it
698-
// only set headless to true if modal SDK is used, otherwise just use the modal from native Metamask SDK
699-
if (isBrowser() && chainNamespaces.has(CHAIN_NAMESPACES.EIP155) && !chainNamespaces.has(CHAIN_NAMESPACES.SOLANA)) {
697+
// prioritize using MM connector over injected connector for EVM chains
698+
if (isBrowser() && chainNamespaces.has(CHAIN_NAMESPACES.EIP155)) {
699+
// only set headless to true if modal SDK is used, otherwise just use the modal from native Metamask SDK
700700
connectorFns.push(metaMaskConnector(modalMode ? { headless: true } : undefined));
701701
}
702702

@@ -730,12 +730,6 @@ export class Web3AuthNoModal extends SafeEventEmitter<Web3AuthNoModalEvents> imp
730730
}
731731
}
732732

733-
// it's safe to add it here as if there is a MetaMask injected provider, this won't override it
734-
// only set headless to true if modal SDK is used, otherwise just use the modal from native Metamask SDK
735-
if (isBrowser() && (chainNamespaces.has(CHAIN_NAMESPACES.SOLANA) || chainNamespaces.has(CHAIN_NAMESPACES.EIP155))) {
736-
connectorFns.push(metaMaskConnector(modalMode ? { headless: true } : undefined));
737-
}
738-
739733
// add WalletConnectV2 connector if external wallets are enabled
740734
if (isBrowser() && isExternalWalletEnabled && (chainNamespaces.has(CHAIN_NAMESPACES.SOLANA) || chainNamespaces.has(CHAIN_NAMESPACES.EIP155))) {
741735
const { walletConnectV2Connector } = await import("./connectors/wallet-connect-v2-connector");

0 commit comments

Comments
 (0)