Skip to content

Commit d6ce6e1

Browse files
authored
chore: Update bridge controllers to expose all methods through messenger (#8367)
## Explanation This updates the following controllers to expose all methods through the messenger in a standardised way: - `BridgeController`. - `BridgeStatusController`. ## 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 --> ## Checklist - [ ] I've updated the test suite for new or updated code as appropriate - [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [ ] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md) - [ ] I've introduced [breaking changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md) in this PR and have prepared draft pull requests for clients and consumer packages to resolve them <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Low risk: changes are limited to new TypeScript action type exports, a build-time generation script dependency, and test refactoring; no bridge runtime logic is modified. > > **Overview** > Adds an auto-generated `bridge-controller-method-action-types.ts` that defines and exports **per-method** messenger action types (e.g., `BridgeControllerFetchQuotesAction`) for all public `BridgeController` methods, and documents/deprecates the older aggregated action types in the changelog. > > Updates `package.json` to support generating these types via a new `generate-method-action-types` script (adding `tsx`), and refactors the `BridgeController` SSE tests to exercise the controller through a real `@metamask/messenger` instance (`rootMessenger.call(...)`) instead of a hand-rolled messenger mock. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 56740c7. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 23c22bd commit d6ce6e1

20 files changed

Lines changed: 7167 additions & 6173 deletions

packages/bridge-controller/CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,27 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- Add action types for all public `BridgeController` methods ([#8367](https://github.com/MetaMask/core/pull/8367))
13+
- The following types are now available:
14+
- `BridgeControllerUpdateBridgeQuoteRequestParamsAction`
15+
- `BridgeControllerFetchQuotesAction`
16+
- `BridgeControllerStopPollingForQuotesAction`
17+
- `BridgeControllerSetLocationAction`
18+
- `BridgeControllerResetStateAction`
19+
- `BridgeControllerSetChainIntervalLengthAction`
20+
- `BridgeControllerTrackUnifiedSwapBridgeEventAction`
21+
1022
### Changed
1123

1224
- Bump `@metamask/accounts-controller` from `^37.1.1` to `^37.2.0` ([#8363](https://github.com/MetaMask/core/pull/8363))
1325
- Bump `@metamask/messenger` from `^1.0.0` to `^1.1.1` ([#8364](https://github.com/MetaMask/core/pull/8364), [#8373](https://github.com/MetaMask/core/pull/8373))
1426

27+
### Deprecated
28+
29+
- Deprecate `BridgeControllerAction`, `BridgeUserAction` and `BridgeBackgroundAction` in favor of separate action types ([#8367](https://github.com/MetaMask/core/pull/8367))
30+
1531
## [70.0.1]
1632

1733
### Changed

packages/bridge-controller/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"build:docs": "typedoc",
4141
"changelog:update": "../../scripts/update-changelog.sh @metamask/bridge-controller",
4242
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/bridge-controller",
43+
"generate-method-action-types": "tsx ../../packages/messenger/src/generate-action-types/cli.ts",
4344
"since-latest-release": "../../scripts/since-latest-release.sh",
4445
"test": "NODE_OPTIONS=--experimental-vm-modules jest --reporters=jest-silent-reporter",
4546
"test:clean": "NODE_OPTIONS=--experimental-vm-modules jest --clearCache",
@@ -85,6 +86,7 @@
8586
"lodash": "^4.17.21",
8687
"nock": "^13.3.1",
8788
"ts-jest": "^29.2.5",
89+
"tsx": "^4.20.5",
8890
"typedoc": "^0.25.13",
8991
"typedoc-plugin-missing-exports": "^2.0.0",
9092
"typescript": "~5.3.3"
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/**
2+
* This file is auto generated.
3+
* Do not edit manually.
4+
*/
5+
6+
import type { BridgeController } from './bridge-controller';
7+
8+
export type BridgeControllerUpdateBridgeQuoteRequestParamsAction = {
9+
type: `BridgeController:updateBridgeQuoteRequestParams`;
10+
handler: BridgeController['updateBridgeQuoteRequestParams'];
11+
};
12+
13+
export type BridgeControllerFetchQuotesAction = {
14+
type: `BridgeController:fetchQuotes`;
15+
handler: BridgeController['fetchQuotes'];
16+
};
17+
18+
export type BridgeControllerStopPollingForQuotesAction = {
19+
type: `BridgeController:stopPollingForQuotes`;
20+
handler: BridgeController['stopPollingForQuotes'];
21+
};
22+
23+
export type BridgeControllerSetLocationAction = {
24+
type: `BridgeController:setLocation`;
25+
handler: BridgeController['setLocation'];
26+
};
27+
28+
export type BridgeControllerResetStateAction = {
29+
type: `BridgeController:resetState`;
30+
handler: BridgeController['resetState'];
31+
};
32+
33+
export type BridgeControllerSetChainIntervalLengthAction = {
34+
type: `BridgeController:setChainIntervalLength`;
35+
handler: BridgeController['setChainIntervalLength'];
36+
};
37+
38+
export type BridgeControllerTrackUnifiedSwapBridgeEventAction = {
39+
type: `BridgeController:trackUnifiedSwapBridgeEvent`;
40+
handler: BridgeController['trackUnifiedSwapBridgeEvent'];
41+
};
42+
43+
/**
44+
* Union of all BridgeController action types.
45+
*/
46+
export type BridgeControllerMethodActions =
47+
| BridgeControllerUpdateBridgeQuoteRequestParamsAction
48+
| BridgeControllerFetchQuotesAction
49+
| BridgeControllerStopPollingForQuotesAction
50+
| BridgeControllerSetLocationAction
51+
| BridgeControllerResetStateAction
52+
| BridgeControllerSetChainIntervalLengthAction
53+
| BridgeControllerTrackUnifiedSwapBridgeEventAction;

0 commit comments

Comments
 (0)