Skip to content

Conversation

@adonesky1
Copy link

@adonesky1 adonesky1 commented Jan 7, 2026

Summary

  • Migrate MetaMask integration from @metamask/sdk to @metamask/connect-evm for improved connection handling
  • Refactor MetaMaskConnector to use the new SDK's createEVMClient() API with built-in event handlers and automatic chain management
  • Remove manual chain addition logic as the new SDK handles this internally during switchChain()
  • Update connector settings interface to align with the new SDK's configuration options

Videos

Extension:
https://drive.google.com/file/d/1r_lDBvwHWQhP-J4yFfqVHsqRR7bIS6Z1/view?usp=sharing

Mobile (native browser):
https://drive.google.com/file/d/1XECLgCOqa9VEeIK4gp1nUf0cs6RRg2V1/view?usp=sharing


Note

Migrates EVM MetaMask integration to the new @metamask/connect-evm SDK and wires it into Web3AuthNoModal.

  • New metamaskConnector using createEVMClient() with built-in event handlers, CAIP-2 supportedNetworks, connect, disconnect, and switchChain (auto add/switch)
  • Web3AuthNoModal.loadConnectors() now adds metaMaskConnector() for EIP-155 chains (preferred over injected)
  • Bumps @web3auth/no-modal to 10.13.2; replaces @metamask/sdk with @metamask/connect-evm in package.json; updates related deps/locks

Written by Cursor Bugbot for commit 87da4b7. This will update automatically on new commits. Configure here.

@vercel
Copy link

vercel bot commented Jan 7, 2026

@adonesky1 is attempting to deploy a commit to the Consensys Team on Vercel.

A member of the Team first needs to authorize it.

@adonesky1 adonesky1 marked this pull request as draft January 7, 2026 23:03
this.metamaskInstance = await this.metamaskPromise;
// TODO: Remove this hack
// Hack to ensure the ConnectEvm instance has fully resumed the connection
await new Promise((resolve) => setTimeout(resolve, 2000));
Copy link

Choose a reason for hiding this comment

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

Note this awful delay to ensure that this async call in the ConnectEvm constructor has fully resolved. We need to fix this on the connect-monorepo side

Copy link
Author

Choose a reason for hiding this comment

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

What is your understanding of how we resolve this on the connect-evm side of things?

Copy link
Author

Choose a reason for hiding this comment

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

Copy link

Choose a reason for hiding this comment

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

we need to release connect-evm again, bump the version in web3auth, and then remove this setTimeout

Copy link

Choose a reason for hiding this comment

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

done

Comment on lines +226 to +229
// if (options.autoConnect) {
// this.rehydrated = false;
// this.emit(CONNECTOR_EVENTS.REHYDRATION_ERROR, new Error("Failed to resume existing MetaMask Connect session.") as Web3AuthError);
// } else {
Copy link

Choose a reason for hiding this comment

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

i think this commented code can be dropped?.. Not sure if it's more appropriate to throw an error if we fail to resume a previous session OR if we just say the connector is ready for new connections

Copy link
Author

Choose a reason for hiding this comment

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

I would think it makes more sense to just say the connector is ready for new connections. But perhaps we should speak with @chaitanyapotti to see what patterns they recommend for their connectors

@jiexi
Copy link

jiexi commented Jan 20, 2026

Need: MetaMask/connect-monorepo#124

@adonesky1 adonesky1 changed the title Update metamask connector WIP Migrate MetaMask Connector to use new SDK (MMConnect) Jan 23, 2026
@adonesky1 adonesky1 marked this pull request as ready for review January 23, 2026 22:34
Comment on lines +34 to +48
/**
* Configuration options for the MetaMask connector using @metamask/connect-evm
*/
export interface MetaMaskConnectorSettings {
/** Dapp identification and branding settings */
dapp?: {
name?: string;
url?: string;
};
/** Enable debug logging for the MetaMask SDK */
debug?: boolean;
}

export interface MetaMaskConnectorOptions extends BaseConnectorSettings {
connectorSettings?: Partial<MetaMaskSDKOptions>;
connectorSettings?: MetaMaskConnectorSettings;
Copy link

@jiexi jiexi Jan 27, 2026

Choose a reason for hiding this comment

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

reminder to document this breaking change and include migration instructions where appropriate

Copy link

@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.

"eip155:5": "https://goerli.infura.io/v3/demo",
"eip155:11155111": "https://sepolia.infura.io/v3/demo",
"eip155:137": "https://polygon-rpc.com",
},
Copy link

Choose a reason for hiding this comment

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

User-configured RPC URLs are ignored in SDK initialization

High Severity

The code builds a supportedNetworks map from user-configured chains (lines 142-148) but this variable is never passed to createEVMClient(). Instead, hardcoded RPC endpoints are used (lines 167-174), meaning users' custom chain configurations and RPC URLs are silently ignored. Only mainnet, goerli, sepolia, and polygon will work with the hardcoded endpoints. The dynamically built supportedNetworks variable appears intended for use but was left as dead code.

Fix in Cursor Fix in Web

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.

2 participants