Skip to content

Commit 935adeb

Browse files
Feat/bridge status controller (#5317)
## Explanation <!-- Thanks for your contribution! Take a moment to answer these questions so that reviewers have the information they need to properly understand your changes: * What is the current state of things and why does it need to change? * What is the solution your changes offer and how does it work? * Are there any changes whose purpose might not obvious to those unfamiliar with the domain? * If your primary goal was to update one package but you found you had to update another one along the way, why did you do so? * If you had to upgrade a dependency, why did you do so? --> This PR adds a new controller: `BridgeStatusController`. This controller handles the bridge transaction status fetching and polling from the Bridge API. ## References <!-- Are there any issues that this pull request is tied to? Are there other links that reviewers should consult to understand these changes better? Are there client or consumer pull requests to adopt any breaking changes? For example: * Fixes #12345 * Related to #67890 --> This is a port of the `BridgeStatusController` from Extension: https://github.com/MetaMask/metamask-extension/tree/main/app/scripts/controllers/bridge-status Some minor changes were needed to fill in the missing functions and variables from Extension. This package will be consumed initially by the Metamask Mobile application first. Eventually, we wish to migrate the Extension to use this `core/bridge-status-controller` package. Very closely related to the `BridgeController`: #5276 ## Changelog <!-- If you're making any consumer-facing changes, list those changes here as if you were updating a changelog, using the template below as a guide. (CATEGORY is one of BREAKING, ADDED, CHANGED, DEPRECATED, REMOVED, or FIXED. For security-related issues, follow the Security Advisory process.) Please take care to name the exact pieces of the API you've added or changed (e.g. types, interfaces, functions, or methods). If there are any breaking changes, make sure to offer a solution for consumers to follow once they upgrade to the changes. Finally, if you're only making changes to development scripts or tests, you may replace the template below with "None". --> ### `@metamask/bridge-status-controller` - ADDED: New `BridgeStatusController`! ### `@metamask/bridge-controller` - CHANGED: `BridgeController` `FeeType` enum now exported as an enum, not just a type ## Checklist - [x] I've updated the test suite for new or updated code as appropriate - [x] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [ ] I've highlighted breaking changes using the "BREAKING" category above as appropriate - [ ] I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes --------- Co-authored-by: Elliot Winkler <[email protected]>
1 parent d77ba9d commit 935adeb

26 files changed

+3131
-6
lines changed

.github/CODEOWNERS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939

4040
## Swaps-Bridge Team
4141
/packages/bridge-controller @MetaMask/swaps-engineers
42+
/packages/bridge-status-controller @MetaMask/swaps-engineers
4243

4344
## Portfolio Team
4445
/packages/token-search-discovery-controller @MetaMask/portfolio
@@ -124,3 +125,5 @@
124125
/packages/bridge-controller/CHANGELOG.md @MetaMask/swaps-engineers @MetaMask/wallet-framework-engineers
125126
/packages/remote-feature-flag-controller/package.json @MetaMask/extension-platform @MetaMask/mobile-platform @MetaMask/wallet-framework-engineers
126127
/packages/remote-feature-flag-controller/CHANGELOG.md @MetaMask/extension-platform @MetaMask/mobile-platform @MetaMask/wallet-framework-engineers
128+
/packages/bridge-status-controller/package.json @MetaMask/swaps-engineers @MetaMask/wallet-framework-engineers
129+
/packages/bridge-status-controller/CHANGELOG.md @MetaMask/swaps-engineers @MetaMask/wallet-framework-engineers

README.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Each package in this repository has its own README where you can find installati
2727
- [`@metamask/assets-controllers`](packages/assets-controllers)
2828
- [`@metamask/base-controller`](packages/base-controller)
2929
- [`@metamask/bridge-controller`](packages/bridge-controller)
30+
- [`@metamask/bridge-status-controller`](packages/bridge-status-controller)
3031
- [`@metamask/build-utils`](packages/build-utils)
3132
- [`@metamask/composable-controller`](packages/composable-controller)
3233
- [`@metamask/controller-utils`](packages/controller-utils)
@@ -74,6 +75,8 @@ linkStyle default opacity:0.5
7475
approval_controller(["@metamask/approval-controller"]);
7576
assets_controllers(["@metamask/assets-controllers"]);
7677
base_controller(["@metamask/base-controller"]);
78+
bridge_controller(["@metamask/bridge-controller"]);
79+
bridge_status_controller(["@metamask/bridge-status-controller"]);
7780
build_utils(["@metamask/build-utils"]);
7881
composable_controller(["@metamask/composable-controller"]);
7982
controller_utils(["@metamask/controller-utils"]);
@@ -107,8 +110,8 @@ linkStyle default opacity:0.5
107110
transaction_controller(["@metamask/transaction-controller"]);
108111
user_operation_controller(["@metamask/user-operation-controller"]);
109112
accounts_controller --> base_controller;
110-
accounts_controller --> keyring_controller;
111113
accounts_controller --> network_controller;
114+
accounts_controller --> keyring_controller;
112115
address_book_controller --> base_controller;
113116
address_book_controller --> controller_utils;
114117
announcement_controller --> base_controller;
@@ -123,6 +126,20 @@ linkStyle default opacity:0.5
123126
assets_controllers --> permission_controller;
124127
assets_controllers --> preferences_controller;
125128
base_controller --> json_rpc_engine;
129+
bridge_controller --> base_controller;
130+
bridge_controller --> controller_utils;
131+
bridge_controller --> polling_controller;
132+
bridge_controller --> transaction_controller;
133+
bridge_controller --> accounts_controller;
134+
bridge_controller --> eth_json_rpc_provider;
135+
bridge_controller --> network_controller;
136+
bridge_status_controller --> base_controller;
137+
bridge_status_controller --> controller_utils;
138+
bridge_status_controller --> polling_controller;
139+
bridge_status_controller --> accounts_controller;
140+
bridge_status_controller --> bridge_controller;
141+
bridge_status_controller --> network_controller;
142+
bridge_status_controller --> transaction_controller;
126143
composable_controller --> base_controller;
127144
composable_controller --> json_rpc_engine;
128145
earn_controller --> base_controller;
@@ -139,7 +156,6 @@ linkStyle default opacity:0.5
139156
gas_fee_controller --> network_controller;
140157
json_rpc_middleware_stream --> json_rpc_engine;
141158
keyring_controller --> base_controller;
142-
keyring_controller --> message_manager;
143159
logging_controller --> base_controller;
144160
logging_controller --> controller_utils;
145161
message_manager --> base_controller;
@@ -150,6 +166,7 @@ linkStyle default opacity:0.5
150166
multichain --> permission_controller;
151167
multichain_network_controller --> base_controller;
152168
multichain_network_controller --> keyring_controller;
169+
multichain_network_controller --> network_controller;
153170
multichain_transactions_controller --> base_controller;
154171
multichain_transactions_controller --> polling_controller;
155172
multichain_transactions_controller --> accounts_controller;
@@ -203,6 +220,7 @@ linkStyle default opacity:0.5
203220
token_search_discovery_controller --> base_controller;
204221
transaction_controller --> base_controller;
205222
transaction_controller --> controller_utils;
223+
transaction_controller --> remote_feature_flag_controller;
206224
transaction_controller --> accounts_controller;
207225
transaction_controller --> approval_controller;
208226
transaction_controller --> eth_json_rpc_provider;

packages/bridge-controller/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
"@metamask/accounts-controller": "^24.0.0",
5959
"@metamask/auto-changelog": "^3.4.4",
6060
"@metamask/eth-json-rpc-provider": "^4.1.8",
61-
"@metamask/json-rpc-engine": "^10.0.3",
6261
"@metamask/network-controller": "^22.2.1",
6362
"@metamask/transaction-controller": "^46.0.0",
6463
"@types/jest": "^27.4.1",

packages/bridge-controller/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ export type {
1919
Quote,
2020
QuoteResponse,
2121
ChainId,
22-
FeeType,
2322
FeeData,
2423
TxData,
2524
BridgeFeatureFlagsKey,
@@ -34,6 +33,8 @@ export type {
3433
BridgeControllerMessenger,
3534
} from './types';
3635

36+
export { FeeType } from './types';
37+
3738
export {
3839
ALLOWED_BRIDGE_CHAIN_IDS,
3940
BridgeClientId,
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
### Added
11+
12+
- Initial release
13+
14+
[Unreleased]: https://github.com/MetaMask/core/
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
MIT License
2+
3+
Copyright (c) 2025 MetaMask
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# `@metamask/bridge-status-controller`
2+
3+
Manages bridge-related status fetching functionality for MetaMask.
4+
5+
## Installation
6+
7+
`yarn add @metamask/bridge-status-controller`
8+
9+
or
10+
11+
`npm install @metamask/bridge-status-controller`
12+
13+
## Contributing
14+
15+
This package is part of a monorepo. Instructions for contributing can be found in the [monorepo README](https://github.com/MetaMask/core#readme).
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* For a detailed explanation regarding each configuration property and type check, visit:
3+
* https://jestjs.io/docs/configuration
4+
*/
5+
6+
const merge = require('deepmerge');
7+
const path = require('path');
8+
9+
const baseConfig = require('../../jest.config.packages');
10+
11+
const displayName = path.basename(__dirname);
12+
13+
module.exports = merge(baseConfig, {
14+
// The display name when running multiple projects
15+
displayName,
16+
17+
// An object that configures minimum threshold enforcement for coverage results
18+
coverageThreshold: {
19+
global: {
20+
branches: 94,
21+
functions: 100,
22+
lines: 100,
23+
statements: 100,
24+
},
25+
},
26+
});
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
{
2+
"name": "@metamask/bridge-status-controller",
3+
"version": "0.0.0",
4+
"description": "Manages bridge-related status fetching functionality for MetaMask",
5+
"keywords": [
6+
"MetaMask",
7+
"Ethereum"
8+
],
9+
"homepage": "https://github.com/MetaMask/core/tree/main/packages/bridge-status-controller#readme",
10+
"bugs": {
11+
"url": "https://github.com/MetaMask/core/issues"
12+
},
13+
"repository": {
14+
"type": "git",
15+
"url": "https://github.com/MetaMask/core.git"
16+
},
17+
"license": "MIT",
18+
"sideEffects": false,
19+
"exports": {
20+
".": {
21+
"import": {
22+
"types": "./dist/index.d.mts",
23+
"default": "./dist/index.mjs"
24+
},
25+
"require": {
26+
"types": "./dist/index.d.cts",
27+
"default": "./dist/index.cjs"
28+
}
29+
},
30+
"./package.json": "./package.json"
31+
},
32+
"main": "./dist/index.cjs",
33+
"types": "./dist/index.d.cts",
34+
"files": [
35+
"dist/"
36+
],
37+
"scripts": {
38+
"build": "ts-bridge --project tsconfig.build.json --verbose --clean --no-references",
39+
"build:docs": "typedoc",
40+
"changelog:update": "../../scripts/update-changelog.sh @metamask/bridge-status-controller",
41+
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/bridge-status-controller",
42+
"publish:preview": "yarn npm publish --tag preview",
43+
"since-latest-release": "../../scripts/since-latest-release.sh",
44+
"test": "NODE_OPTIONS=--experimental-vm-modules jest --reporters=jest-silent-reporter",
45+
"test:clean": "NODE_OPTIONS=--experimental-vm-modules jest --clearCache",
46+
"test:verbose": "NODE_OPTIONS=--experimental-vm-modules jest --verbose",
47+
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
48+
},
49+
"dependencies": {
50+
"@metamask/base-controller": "^8.0.0",
51+
"@metamask/bridge-controller": "^0.0.0",
52+
"@metamask/controller-utils": "^11.5.0",
53+
"@metamask/polling-controller": "^12.0.3",
54+
"@metamask/utils": "^11.2.0"
55+
},
56+
"devDependencies": {
57+
"@metamask/accounts-controller": "^24.0.0",
58+
"@metamask/auto-changelog": "^3.4.4",
59+
"@metamask/network-controller": "^22.2.1",
60+
"@metamask/transaction-controller": "^46.0.0",
61+
"@types/jest": "^27.4.1",
62+
"deepmerge": "^4.2.2",
63+
"jest": "^27.5.1",
64+
"jest-environment-jsdom": "^27.5.1",
65+
"lodash": "^4.17.21",
66+
"nock": "^13.3.1",
67+
"ts-jest": "^27.1.4",
68+
"typedoc": "^0.24.8",
69+
"typedoc-plugin-missing-exports": "^2.0.0",
70+
"typescript": "~5.2.2"
71+
},
72+
"peerDependencies": {
73+
"@metamask/accounts-controller": "^24.0.0",
74+
"@metamask/bridge-controller": "^0.0.0",
75+
"@metamask/network-controller": "^22.0.0",
76+
"@metamask/transaction-controller": "^46.0.0"
77+
},
78+
"engines": {
79+
"node": "^18.18 || >=20"
80+
},
81+
"publishConfig": {
82+
"access": "public",
83+
"registry": "https://registry.npmjs.org/"
84+
}
85+
}

0 commit comments

Comments
 (0)