Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,7 @@ class MetaMaskConnector extends BaseEvmConnector<void> {
// 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)
Copy link
Contributor Author

@tanguyenvn tanguyenvn Nov 28, 2025

Choose a reason for hiding this comment

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

MM connector doesn't support Solana atm, so excluding it

(x) => x.chainId === params.chainId && ([CHAIN_NAMESPACES.EIP155] as ChainNamespaceType[]).includes(x.chainNamespace)
);
await this.addChain(chainConfig);
await requestSwitchChain();
Expand Down
12 changes: 3 additions & 9 deletions packages/no-modal/src/noModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -694,9 +694,9 @@ export class Web3AuthNoModal extends SafeEventEmitter<Web3AuthNoModalEvents> 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));
}

Expand Down Expand Up @@ -730,12 +730,6 @@ export class Web3AuthNoModal extends SafeEventEmitter<Web3AuthNoModalEvents> 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));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • we already prioritize MM connector at the line 697-699 when EVM chain is available
  • if only Solana chain namespace available, we should not add MM connector.

}

// 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");
Expand Down