Skip to content

Migrate MM SDK to MM Connect EVM on MetaMask docs#2779

Draft
shahbaz17 wants to merge 4 commits intosdk-new-structurefrom
feat/migrate-sdk-to-mm-connect-evm
Draft

Migrate MM SDK to MM Connect EVM on MetaMask docs#2779
shahbaz17 wants to merge 4 commits intosdk-new-structurefrom
feat/migrate-sdk-to-mm-connect-evm

Conversation

@shahbaz17
Copy link
Member

@shahbaz17 shahbaz17 commented Mar 19, 2026

Description

Issue(s) fixed

Fixes #

Preview

Checklist

  • If this PR updates or adds documentation content that changes or adds technical meaning, it has received an approval from an engineer or DevRel from the relevant team.
  • If this PR updates or adds documentation content, it has received an approval from a technical writer.

External contributor checklist

  • I've read the contribution guidelines.
  • I've created a new issue (or assigned myself to an existing issue) describing what this PR addresses.

Note

Medium Risk
Replaces the site’s wallet connection/client initialization and provider types, which can affect login, disconnect, and network selection flows. Also introduces a large dependency graph update via @metamask/connect-evm, increasing build/compatibility risk.

Overview
Migrates the docs site’s wallet-connect/login implementation from @metamask/sdk to @metamask/connect-evm, including new client initialization in Root.tsx, updated connect/disconnect calls, and switching provider typing to an EIP-1193 provider.

Adds optional Infura-backed RPC configuration via INFURA_API_KEY (wired through Docusaurus customFields) and updates the auth helper to accept a generic request-capable provider.

Simplifies Faucet and Navbar wallet CTAs by removing the “install MetaMask” branch and always presenting connect/link flows, and adds a TS module shim in globals.d.ts for the createEVMClient export/type mismatch. Dependency lockfile is updated substantially to reflect the new Connect EVM package and transitive upgrades/removals.

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

@shahbaz17 shahbaz17 requested review from a team as code owners March 19, 2026 18:32
@vercel
Copy link

vercel bot commented Mar 19, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
metamask-docs Ready Ready Preview, Comment Mar 19, 2026 7:07pm

Request Review

@shahbaz17 shahbaz17 requested a review from alexandratran March 19, 2026 18:32
@socket-security
Copy link

socket-security bot commented Mar 19, 2026

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​metamask/​connect-evm@​0.8.07710010096100

View full report

@socket-security
Copy link

socket-security bot commented Mar 19, 2026

All alerts resolved. Learn more about Socket for GitHub.

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

Ignoring alerts on:

  • @metamask/analytics@0.4.0
  • @metamask/api-specs@0.14.0
  • @metamask/chain-agnostic-permission@1.4.0
  • @metamask/connect-evm@0.8.0
  • @metamask/connect-multichain@0.10.0
  • @react-native-async-storage/async-storage@1.24.0
  • @metamask/messenger@0.3.0
  • @metamask/mobile-wallet-protocol-core@0.4.0
  • @metamask/mobile-wallet-protocol-dapp-client@0.3.0
  • @metamask/multichain-api-client@0.10.1
  • @metamask/multichain-ui@0.4.0
  • @protobufjs/aspromise@1.1.2
  • @protobufjs/base64@1.1.2
  • @protobufjs/codegen@2.0.4
  • @protobufjs/eventemitter@1.1.0
  • @protobufjs/fetch@1.1.0
  • @protobufjs/float@1.0.2
  • @protobufjs/inquire@1.1.0
  • @protobufjs/path@1.1.2
  • @protobufjs/pool@1.1.0
  • @protobufjs/utf8@1.1.0
  • @react-native/debugger-shell@0.84.1
  • @types/lodash@4.17.24
  • centrifuge@5.5.3
  • fb-dotslash@0.5.8
  • hermes-compiler@250829098.0.9
  • long@5.3.2
  • merge-options@3.0.4
  • protobufjs@7.5.4
  • qr-code-styling@1.9.2
  • qrcode-generator@1.5.2
  • tinyglobby@0.2.15
  • fdir@6.5.0
  • @babel/traverse@7.29.0
  • @metamask/utils@11.10.0
  • @metamask/approval-controller@9.0.0
  • @metamask/base-controller@9.0.0
  • @metamask/permission-controller@12.2.1
  • @react-native/assets-registry@0.84.1
  • @react-native/codegen@0.84.1
  • @react-native/community-cli-plugin@0.84.1
  • @react-native/debugger-frontend@0.84.1
  • @react-native/dev-middleware@0.84.1
  • ws@8.19.0
  • @react-native/gradle-plugin@0.84.1
  • @react-native/js-polyfills@0.84.1
  • @react-native/normalize-colors@0.84.1
  • @types/react@19.2.14
  • accepts@2.0.0
  • babel-plugin-syntax-hermes-parser@0.32.0
  • negotiator@1.0.0
  • csstype@3.2.3
  • eventemitter3@5.0.4
  • hermes-estree@0.33.3
  • hermes-parser@0.33.3
  • is-plain-obj@2.1.0
  • metro@0.83.5
  • metro-babel-transformer@0.83.5
  • metro-cache@0.83.5
  • metro-cache-key@0.83.5
  • metro-config@0.83.5
  • metro-core@0.83.5
  • metro-file-map@0.83.5
  • metro-minify-terser@0.83.5
  • metro-resolver@0.83.5
  • metro-runtime@0.83.5
  • metro-source-map@0.83.5
  • metro-symbolicate@0.83.5
  • metro-transform-plugins@0.83.5
  • metro-transform-worker@0.83.5
  • mime-types@3.0.2
  • ob1@0.83.5
  • pako@2.1.0
  • picomatch@4.0.3
  • react@19.2.4
  • scheduler@0.27.0
  • react-native@0.84.1
  • @react-native/virtualized-lists@0.84.1
  • @babel/code-frame@7.29.0
  • @babel/generator@7.29.1
  • @babel/helper-validator-identifier@7.28.5
  • @babel/parser@7.29.2
  • @babel/template@7.28.6
  • @babel/types@7.29.0
  • @metamask/rpc-errors@7.0.3
  • @metamask/controller-utils@11.19.0
  • @metamask/json-rpc-engine@10.2.3
  • bowser@2.14.1
  • eciesjs@0.4.17
  • @ecies/ciphers@0.2.5

View full report

@shahbaz17
Copy link
Member Author

@SocketSecurity ignore-all

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 2 potential issues.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

: {}),
'0xaa36a7': 'https://rpc.sepolia.org',
'0xe705': 'https://rpc.sepolia.linea.build',
},
Copy link

Choose a reason for hiding this comment

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

Hardcoded RPC URLs override Infura URLs for key chains

Medium Severity

In the supportedNetworks configuration, the Infura RPC URLs from getInfuraRpcUrls are spread first, then hardcoded public RPC URLs for 0xaa36a7 (Sepolia) and 0xe705 (Linea Sepolia) are placed after. Due to JavaScript object spread semantics, the hardcoded public endpoints always override any Infura-provided URLs for these same chain IDs. Since these are the two primary chains used by the faucet, the INFURA_API_KEY effectively provides no benefit for the most critical networks. The spread order likely needs to be reversed so the public URLs serve as defaults and Infura URLs override them when a key is available.

Fix in Cursor Fix in Web

console.error('MetaMask Connect EVM initialization failed:', error)
setClientError(error?.message || 'Failed to initialize wallet connection')
clientInitialized.current = false
})
Copy link

Choose a reason for hiding this comment

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

Failed client init prevents retry despite resetting flag

Low Severity

When createEVMClient fails, the catch block resets clientInitialized.current = false to allow a retry, but the useEffect has an empty [] dependency array and will never re-run. The client remains null permanently, causing all wallet operations (login, getStaleDate, disconnect) to silently no-op. The retry logic is effectively dead code.

Fix in Cursor Fix in Web

@shahbaz17 shahbaz17 marked this pull request as draft March 19, 2026 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant