Skip to content

refactor(connectors): metamask#4960

Merged
tmm merged 67 commits intomainfrom
tmm/mm-connector
Mar 20, 2026
Merged

refactor(connectors): metamask#4960
tmm merged 67 commits intomainfrom
tmm/mm-connector

Conversation

@tmm
Copy link
Copy Markdown
Member

@tmm tmm commented Jan 20, 2026

Migrates MetaMask connector to MetaMask Connect SDK. To continue using the MetaMask connector, install the @metamask/connect-evm package. Note this is a Breaking Change.

Please see documentation for the new expect params here

Related #4936

Here's a concise breaking changes section you can paste into the wagmi PR #4960 description:


Breaking Changes

The MetaMask connector now uses @metamask/connect-evm instead of @metamask/sdk.

Consumer action required

  1. Install the new peer dependency:

    npm install @metamask/connect-evm@~0.8.0
    npm uninstall @metamask/sdk
  2. Update connector configuration:

    Before (@metamask/sdk) After (@metamask/connect-evm)
    dappMetadata: { name, url } dapp: { name, url, iconUrl? }
    useDeeplink: boolean mobile: { useDeeplink: boolean }
    preferredOpenLink: fn mobile: { preferredOpenLink: fn }
    logging: { ... } debug: boolean
    forceDeleteProvider removed
    forceInjectProvider removed
    injectProvider removed
    readonlyRPCMap removed — auto-built from wagmi chains

    dappMetadata and logging still work but are deprecated.

  3. Minimal config example:

    import { metaMask } from '@wagmi/connectors'
    
    metaMask({
      dapp: { name: 'My Dapp', url: window.location.href },
    })

We're also publishing a cursor plugin to help guide AI assisted migrations here -> MetaMask/metamask-connect-cursor-plugin#3.


tmm and others added 3 commits March 19, 2026 16:14
…name

dappMetadata is typed with all-optional fields for backwards compat,
but the underlying connect-evm SDK requires `name`. Merge with
defaultDappParams instead of replacing so a partial dappMetadata
always gets a valid `name` filled in.
@tmm tmm force-pushed the tmm/mm-connector branch from 17ca37a to f28cac0 Compare March 19, 2026 21:08
Copy link
Copy Markdown
Collaborator

@adonesky1 adonesky1 left a comment

Choose a reason for hiding this comment

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

LGTM!

@tmm tmm merged commit 2a566ec into main Mar 20, 2026
13 of 14 checks passed
@tmm tmm deleted the tmm/mm-connector branch March 20, 2026 14:50
github-merge-queue bot pushed a commit to MetaMask/metamask-extension that referenced this pull request Mar 26, 2026
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**

<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->

Adds E2E tests for the Multichain API using [Metamask
Connect](connect-monorepo) (formerly SDK).

Five scenarios:
1. **Simultaneous multi-chain + Solana connection** — Verifies
`wallet_createSession` can grant 3 EVM chains + Solana scope
simultaneously and that all ScopeCards render.
2. **Per-chain `personal_sign` routing** — Confirms `personal_sign`
requests are routed to the correct chain scope and return valid
signatures.
3. **Per-chain `eth_chainId` isolation** — Validates that `eth_chainId`
returns the correct hex chain ID for each connected scope.
4. **Permission removal reflection** — Tests that removing a chain
permission via the extension UI immediately reflects in the dapp
(ScopeCard disappears).
5. **Full session termination** — Verifies `wallet_revokeSession` (via
`sdkDisconnect()`) clears session state on both dapp and wallet sides.

### New Test Dapp and Page Object
Adds the [MM Connect Test
Dapp](https://github.com/MetaMask/connect-monorepo/tree/main/playground/browser-playground)
(`test/e2e/page-objects/pages/test-dapp-mm-connect.ts`):
- The dapp exposes the MM Connect connectors.
- Replicates `@metamask/playground-ui` test ID logic in-tree for stable
selectors
- Provides clean abstraction: `selectNetworks()`, `clickConnect()`,
`triggerMethod()`, `checkMethodResult()`, `checkScopeCardVisible()`
- Handles async dialog flow correctly (trigger → approve → assert result
via `waitForSelector`)

### Infrastructure

- Added `DAPP_PATH.TEST_DAPP_MM_CONNECT` constant
- Added `MM_CONNECT_EVM_CHAINS` and `MM_CONNECT_FEATURED_CHAIN_IDS`
constants
- Added `@metamask/browser-playground@0.3.0` devDependency
- Updated `privacy-snapshot.json` with `eth.merkle.io` (RPC) and
`mm-sdk-analytics.api.cx.metamask.io` (telemetry)
- All tests use `FixtureBuilderV2`

### Privacy Changes

Adds two entries:

- **`https://eth.merkle.io`**: is the default RPC for Ethereum mainnet
chain definition at
[viem](https://github.com/wevm/viem/blob/0f7837ce96b5791b5ad45c2b2d2fe9cdabbe98b5/src/chains/definitions/mainnet.ts#L10),
the base library on top of which `wagmi` is built. `wagmi` is used by
the `browser-playground` to enable testing the new MM Connect [wagmi
connector](wevm/wagmi#4960).
- **`mm-sdk-analytics.api.cx.metamask.io`**: is the analytics endpoint
for SDK related metrics.


[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/40818?quickstart=1)
## **Changelog**

<!--
If this PR is not End-User-Facing and should not show up in the
CHANGELOG, you can choose to either:
1. Write `CHANGELOG entry: null`
2. Label with `no-changelog`

If this PR is End-User-Facing, please write a short User-Facing
description in the past tense like:
`CHANGELOG entry: Added a new tab for users to see their NFTs`
`CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker`

(This helps the Release Engineer do their job more quickly and
accurately)
-->

CHANGELOG entry:

## **Related issues**

Fixes:
[WAPI-1044](https://consensyssoftware.atlassian.net/browse/WAPI-1044)

## **Manual testing steps**

1. `yarn && yarn build:test`
2. `yarn test:e2e:single test/e2e/tests/sdk/connect-multichain.spec.ts
--browser=chrome`

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **Pre-merge author checklist**

- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I've included tests if applicable
- [x] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I've applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.


<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Primarily adds E2E tests and test infrastructure, but introduces a new
dev dependency (`@metamask/browser-playground`) and expands the privacy
allowlist, which can affect CI stability and policy expectations.
> 
> **Overview**
> Adds a new MM Connect multichain E2E suite
(`connect-multichain.spec.ts`) that exercises `wallet_createSession`
across multiple EVM chains plus Solana, per-scope signing/`eth_chainId`,
permission removal propagation, and `wallet_revokeSession` disconnect
behavior.
> 
> Introduces a dedicated page object (`test-dapp-mm-connect.ts`) and new
E2E constants (`DAPP_PATH.TEST_DAPP_MM_CONNECT`,
`MM_CONNECT_EVM_CHAINS`, `MM_CONNECT_FEATURED_CHAIN_IDS`) to drive the
`@metamask/browser-playground` dapp, and refactors permission-page
navigation by extracting `getPermissionsPageForHost` into
`permissions.flow.ts`.
> 
> Updates test tooling/config by adding
`@metamask/browser-playground@0.3.0` to dev deps and depcheck ignores,
plus extends `privacy-snapshot.json` with `eth.merkle.io` and
`mm-sdk-analytics.api.cx.metamask.io`.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
35ed097. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->



[WAPI-1044]:
https://consensyssoftware.atlassian.net/browse/WAPI-1044?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
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.

5 participants