Skip to content

Conversation

@micaelae
Copy link
Member

@micaelae micaelae commented Mar 17, 2025

Description

This PR removes the BridgeController class and shared bridge utils from the extension repo, and replaces them with @metamask/bridge-controller imports

See Copilot summary for more details

Open in GitHub Codespaces

Related issues

Fixes:

Manual testing steps

  1. Bridge and swap functionality for EVM and Solana should be unchanged, just updating imports
  2. Compare behavior to latest released prod/builds

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.

@metamaskbot metamaskbot added the team-swaps-and-bridge Swaps and Bridge team label Mar 17, 2025
@micaelae micaelae requested a review from Copilot March 19, 2025 22:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the bridge-related functionality to use the centralized "@metamask/bridge-controller" library, removing legacy implementations and updating import paths throughout the codebase.

  • Updated imports in metamask-controller and other modules to reference "@metamask/bridge-controller".
  • Removed legacy bridge constants, types, and utility files/tests no longer needed with the consolidation.
  • Adjusted configuration for the new BridgeController instantiation.

Reviewed Changes

Copilot reviewed 76 out of 77 changed files in this pull request and generated no comments.

Show a summary per file
File Description
app/scripts/metamask-controller.js Updated controller to import and instantiate BridgeController with new clientId and fetchFn.
shared/constants/bridge.ts Removed local definitions in favor of importing constant values from the new bridge controller.
app/scripts/lib/bridge-status/metrics.ts Revised import paths to use new utilities from "@metamask/bridge-controller".
.eslintrc.js Removed obsolete test file reference for bridge tests.
app/scripts/controllers/bridge/constants.ts,
app/scripts/controllers/bridge/types.ts
Entirely removed as part of deprecating the legacy bridge logic.
shared/modules/bridge-utils/*,
shared/types/bridge.ts
Legacy bridge utilities and types removed in favor of the external library.
Files not reviewed (1)
  • package.json: Language not supported
Comments suppressed due to low confidence (4)

app/scripts/metamask-controller.js:1777

  • Verify that replacing 'NetworkController:getSelectedNetworkClient' with 'NetworkController:getState' aligns with the updated messaging API and does not break existing message handling.
'NetworkController:getState',

.eslintrc.js:355

  • Confirm that the removal of the bridge test file reference is intentional and that appropriate tests exist for the new bridge controller integration.
    -        'app/scripts/controllers/bridge.test.ts',

app/scripts/controllers/bridge/constants.ts:1

  • Ensure that removing the legacy bridge constants file does not leave orphaned references or unintended side effects in the codebase.
Entire file removal

app/scripts/controllers/bridge/types.ts:1

  • Verify that eliminating the legacy bridge controller types is safe and that all type references have been updated to use the types from '@metamask/bridge-controller'.
Entire file removal

@micaelae micaelae force-pushed the mms2102-bridge-migration branch from 9c06c19 to 1e00869 Compare March 19, 2025 22:30
@socket-security
Copy link

socket-security bot commented Mar 20, 2025

New and updated dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@metamask/bridge-controller@11.0.0 None 0 445 kB metamaskbot
npm/@metamask/multichain-network-controller@0.1.10.3.0 None 0 111 kB metamaskbot

View full report↗︎

ghgoodreau
ghgoodreau previously approved these changes Mar 27, 2025
MajorLift
MajorLift previously approved these changes Mar 27, 2025
itsyoboieltr
itsyoboieltr previously approved these changes Mar 27, 2025
@dbrans dbrans disabled auto-merge March 27, 2025 17:08
@dbrans
Copy link
Contributor

dbrans commented Mar 27, 2025

Nice work, @micaelae. I left a little feedback here.

@micaelae micaelae enabled auto-merge March 27, 2025 17:19
darkwing
darkwing previously approved these changes Mar 27, 2025
<!--
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**
Some components use hex and some use caip so adding network name
mappings for both chainId formats

<!--
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?
-->

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

## **Related issues**

Fixes:

## **Manual testing steps**

1. Go to this page...
2.
3.

## **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**

- [ ] 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).
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] 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.
@metamaskbot
Copy link
Collaborator

✨ Files requiring CODEOWNER review ✨

🧩 @MetaMask/extension-devs

  • lavamoat/browserify/beta/policy.json
  • lavamoat/browserify/flask/policy.json
  • lavamoat/browserify/main/policy.json
  • lavamoat/browserify/mmi/policy.json

📜 @MetaMask/policy-reviewers

  • lavamoat/browserify/beta/policy.json
  • lavamoat/browserify/flask/policy.json
  • lavamoat/browserify/main/policy.json
  • lavamoat/browserify/mmi/policy.json

🔗 @MetaMask/supply-chain

  • lavamoat/browserify/beta/policy.json
  • lavamoat/browserify/flask/policy.json
  • lavamoat/browserify/main/policy.json
  • lavamoat/browserify/mmi/policy.json

🔄 @MetaMask/swaps-engineers

  • app/scripts/controllers/bridge-status/__snapshots__/bridge-status-controller.test.ts.snap
  • app/scripts/controllers/bridge-status/bridge-status-controller.test.ts
  • app/scripts/controllers/bridge-status/mocks.ts
  • app/scripts/controllers/bridge-status/utils.ts
  • app/scripts/controllers/bridge/bridge-controller.test.ts
  • app/scripts/controllers/bridge/bridge-controller.ts
  • app/scripts/controllers/bridge/constants.ts
  • app/scripts/controllers/bridge/types.ts
  • app/scripts/lib/bridge-status/metrics.ts
  • shared/lib/bridge-status/metrics.ts
  • shared/lib/bridge-status/utils.ts
  • shared/lib/bridge/metrics.ts

Copy link
Contributor

@dbrans dbrans left a comment

Choose a reason for hiding this comment

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

Approving since this needs to make the release cut.

@metamaskbot
Copy link
Collaborator

Builds ready [51f0f2d]
UI Startup Metrics (1174 ± 52 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyHomeuiStartup1174107414005212081260
load1021908120752937990
domContentLoaded1015900119452945995
domInteractive16137681528
firstPaint6921461204399244962
backgroundConnect106557910
firstReactRender20154562035
getState10428668
initialActions001000
loadScripts80469794950843880
setupStore8529479
WebpackHomeuiStartup958752122773968985
load81560692963847890
domContentLoaded80959391663842886
domInteractive15123761435
firstPaint56056904333841883
backgroundConnect16115291540
firstReactRender14123041326
getState7413278
initialActions001000
loadScripts80758290664839885
setupStore7518279
FirefoxBrowserifyHomeuiStartup13381153188614313661731
load12011037173812912241520
domContentLoaded12001037173712912241519
domInteractive9741176239096
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect2416106122447
firstReactRender22193332226
getState7341468
initialActions001001
loadScripts11771020169612412081475
setupStore7359667
WebpackHomeuiStartup9798291523168884955
load8587281312148812978
domContentLoaded8577271312148812977
domInteractive118342362614796
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect191290102131
firstReactRender18162721824
getState104801279
initialActions001001
loadScripts8427091295144798956
setupStore85811078
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: -9.73 KiB (-0.16%)
  • ui: -2.47 KiB (-0.04%)
  • common: 107.51 KiB (1.16%)

@micaelae micaelae added this pull request to the merge queue Mar 27, 2025
Merged via the queue into main with commit 69c802f Mar 27, 2025
147 checks passed
@micaelae micaelae deleted the mms2102-bridge-migration branch March 27, 2025 21:07
@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 2025
@metamaskbot metamaskbot added the release-12.17.0 Issue or pull request that will be included in release 12.17.0 label Mar 27, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-12.17.0 Issue or pull request that will be included in release 12.17.0 team-swaps-and-bridge Swaps and Bridge team

Projects

None yet

Development

Successfully merging this pull request may close these issues.