Skip to content

Conversation

@GuillaumeRx
Copy link
Contributor

@GuillaumeRx GuillaumeRx commented Nov 18, 2025

Description

This PR refactors the SnapBridge to use SelectedNetworkController to create a provider proxy. It also removes a lot of unnecessary logic. This fixes an issue where the snap couldn't switch the network.

Changelog

CHANGELOG entry: Fix snap wallet_switchEthereumChain

Related issues

Fixes: #22419

Manual testing steps

  1. Set the selected network to any other network than ethereum mainnet (like polygon, base,...)
  2. Go to the send flow
  3. Expect a valid ENS name to be resolved when trying to send ETH on mainnet

Screenshots/Recordings

Before

After

Pre-merge author checklist

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.

Note

Refactors SnapBridge to source provider/block tracker from SelectedNetworkController, streamlines the JSON-RPC middleware stack and stream wiring, and types snapId as SnapId in init.

  • Snaps:
    • SnapBridge refactor:
      • Use SelectedNetworkController.getProviderAndBlockTracker(snapId) and add createSelectedNetworkMiddleware.
      • Rebuild JSON-RPC engine: origin middleware → selected network → filter/subscription polyfills → preinstalled snaps middleware (when applicable) → permission middleware → snaps method middleware → user RPC middleware (with #getProviderState) → forward via providerAsMiddleware(proxy.provider).
      • Replace custom multiplexing with setupMultiplex and pump; add concise logging; adopt strong typings (SnapId, JsonRpcMiddleware, InternalAccount); remove legacy proxy/network-version logic.
  • Engine:
    • In controllers/snaps/execution-service-init.ts, pass snapId as SnapId when creating SnapBridge.

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

@GuillaumeRx GuillaumeRx requested a review from a team as a code owner November 18, 2025 14:01
@github-actions
Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@metamaskbot metamaskbot added the team-core-platform Core Platform team label Nov 18, 2025
@FrederikBolding FrederikBolding self-requested a review November 18, 2025 14:10
@FrederikBolding FrederikBolding added the run-android-flask-e2e-smoke Run Android flask E2E tests on next CI run label Nov 18, 2025
@FrederikBolding FrederikBolding added the skip-sonar-cloud Only used for bypassing sonar cloud when failures are not relevant to the changes. label Nov 19, 2025
@GuillaumeRx GuillaumeRx force-pushed the gr/fix-snap-bridge-provider branch from 62fb698 to 78ef601 Compare November 19, 2025 15:17
@github-actions
Copy link
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeAccounts, SmokeCore, SmokeConfirmationsRedesigned, SmokeIdentity, SmokeNetworkAbstractions, SmokeNetworkExpansion, SmokeTrade, SmokeWalletPlatform, SmokeWalletUX, SmokeAssets, SmokeSwaps, SmokeStake, SmokeCard, SmokeNotifications, SmokeRewards, SmokePerps, SmokeRamps, SmokeMultiChainPermissions, SmokeAnalytics, SmokeMultiChainAPI, SmokePredictions
  • Risk Level: high
  • AI Confidence: %
click to see 🤖 AI reasoning details

Fallback: AI analysis did not complete successfully. Running all tests.

View GitHub Actions results

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@GuillaumeRx GuillaumeRx added this pull request to the merge queue Nov 19, 2025
Merged via the queue into main with commit 0858b71 Nov 19, 2025
72 of 74 checks passed
@GuillaumeRx GuillaumeRx deleted the gr/fix-snap-bridge-provider branch November 19, 2025 16:15
@github-actions github-actions bot locked and limited conversation to collaborators Nov 19, 2025
@metamaskbot metamaskbot added the release-7.61.0 Issue or pull request that will be included in release 7.61.0 label Nov 19, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.61.0 Issue or pull request that will be included in release 7.61.0 run-android-flask-e2e-smoke Run Android flask E2E tests on next CI run size-M skip-sonar-cloud Only used for bypassing sonar cloud when failures are not relevant to the changes. team-core-platform Core Platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Couldn't resolve ENS when network manager selection is different than Ethereum Mainnet

4 participants