Skip to content

Commit 73969e1

Browse files
authored
feat: add multichain support to bridge-controller (#5486)
## 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? --> The `BridgeController` currently only works with EVM networks and addresses. In order to support Solana integration into mobile, this PR adds the multichain compatibility updates implemented in extension. **Specific changes** * Add support for solana in fetchBridgeTokens util * CAIP address and chainId support * Solana constants, quote fetching+validation and fee calculation logic * Replaces account used with multichain account * Tenderly quote override for e2e testing (this enables submitting bridge txs to a forked network so no real funds are spent) **Notes for upgrading mobile to this version** * Controller's allowed actions need to be updated (see `AllowedActions` type update) * There should be no functional differences until Solana is enabled * When Solana is enabled, quote fetching should ✨ just work ✨ ## 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 --> * Fixes https://consensyssoftware.atlassian.net/browse/MMS-2101 * Related to MetaMask/metamask-extension#30305 * Related to MetaMask/metamask-extension#29443 * Ports multichain functionality added in extension RC 12.14.0 PR [30617](MetaMask/metamask-extension#30617) ## 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-controller 8.0.0` **ADDED** - fetching Solana tokens and bridge/swap quotes, including tx validation and calculating Solana fees - chainId and address formatting utilities to make client side data compatible with the bridge-api's expected formats **CHANGED** - Updated BridgeController's constructor so the `fetchFn` can propagate parameters to the underlying fetch function - Set intervals for polling quotes based on a feature flag - Change `bridgeFeatureFlags.chains` keys from Hex to CAIP-formatted chainIds ## 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 - [X] I've highlighted breaking changes using the "BREAKING" category above as appropriate - [X] I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes
1 parent 8f91bc2 commit 73969e1

30 files changed

+1795
-370
lines changed

packages/bridge-controller/CHANGELOG.md

+18
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- BREAKING: Bump dependency @metamask/keyring-api to ^17.2.0 ([#5486](https://github.com/MetaMask/core/pull/5486))
13+
- BREAKING: Bump dependency @metamask/multichain-network-controller to ^0.3.0 ([#5486](https://github.com/MetaMask/core/pull/5486))
14+
- BREAKING: Bump dependency @metamask/snaps-utils to ^8.10.0 ([#5486](https://github.com/MetaMask/core/pull/5486))
15+
- BREAKING: Bump peer dependency @metamask/snaps-controllers to ^9.19.0 ([#5486](https://github.com/MetaMask/core/pull/5486))
16+
- Solana constants, utils, quote and token support ([#5486](https://github.com/MetaMask/core/pull/5486))
17+
- Utilities to convert chainIds between `ChainId`, `Hex`, `string` and `CaipChainId` ([#5486](https://github.com/MetaMask/core/pull/5486))
18+
- Add `refreshRate` feature flag to enable chain-specific quote refresh intervals ([#5486](https://github.com/MetaMask/core/pull/5486))
19+
- `isNativeAddress` and `isSolanaChainId` utilities that can be used by both the controller and clients ([#5486](https://github.com/MetaMask/core/pull/5486))
20+
21+
### Changed
22+
23+
- Replace QuoteRequest usages with `GenericQuoteRequest` to support both EVM and multichain input parameters ([#5486](https://github.com/MetaMask/core/pull/5486))
24+
- Make `QuoteRequest.slippage` optional ([#5486](https://github.com/MetaMask/core/pull/5486))
25+
- Deprecate `SwapsTokenObject` and replace usages with multichain BridgeAsset ([#5486](https://github.com/MetaMask/core/pull/5486))
26+
- Changed `bridgeFeatureFlags.extensionConfig.chains` to key configs by CAIP chainIds ([#5486](https://github.com/MetaMask/core/pull/5486))
27+
1028
## [10.0.0]
1129

1230
### Changed

packages/bridge-controller/package.json

+5
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,19 @@
5454
"@ethersproject/providers": "^5.7.0",
5555
"@metamask/base-controller": "^8.0.0",
5656
"@metamask/controller-utils": "^11.6.0",
57+
"@metamask/keyring-api": "^17.2.0",
5758
"@metamask/metamask-eth-abis": "^3.1.1",
59+
"@metamask/multichain-network-controller": "^0.3.0",
5860
"@metamask/polling-controller": "^13.0.0",
61+
"@metamask/snaps-utils": "^8.10.0",
5962
"@metamask/utils": "^11.2.0"
6063
},
6164
"devDependencies": {
6265
"@metamask/accounts-controller": "^27.0.0",
6366
"@metamask/auto-changelog": "^3.4.4",
6467
"@metamask/eth-json-rpc-provider": "^4.1.8",
6568
"@metamask/network-controller": "^23.1.0",
69+
"@metamask/snaps-controllers": "^9.19.0",
6670
"@metamask/superstruct": "^3.1.0",
6771
"@metamask/transaction-controller": "^52.0.0",
6872
"@types/jest": "^27.4.1",
@@ -79,6 +83,7 @@
7983
"peerDependencies": {
8084
"@metamask/accounts-controller": "^27.0.0",
8185
"@metamask/network-controller": "^23.0.0",
86+
"@metamask/snaps-controllers": "^9.19.0",
8287
"@metamask/transaction-controller": "^52.0.0"
8388
},
8489
"engines": {

0 commit comments

Comments
 (0)