-
-
Notifications
You must be signed in to change notification settings - Fork 208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: bridge controller #5276
feat: bridge controller #5276
Conversation
848122f
to
ff391cd
Compare
No dependency changes detected. Learn more about Socket for GitHub ↗︎ 👍 No dependency changes detected in pull request |
@SocketSecurity ignore npm/[email protected] Was Introduced by @metamask/[email protected] |
ea0e07a
to
4f2f31f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @infiniteflower! I've taken a good look at this PR. There are a number of items that would be great to fix to align with the rest of the controllers in this repo. However I recognize that the goal of this PR is probably just to port the controller from extension. So while I've made a lot of suggestions, I've marked the items I think we can could leave for another PR with ⏭️. Hope that helps.
* An object containing all of the chain ids for networks both built in and | ||
* those that we have added custom code to support our feature set. | ||
*/ | ||
export const CHAIN_IDS = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⏭️ We have multiple instances of chain IDs in this repo (name-controller
, preferences-controller
, transaction-controller
, etc.) and it'd be great if we could consolidate these.
We've been using controller-utils
as a shared location for constants like this. It has a ChainId
enum that I think could be a good candidate for copying this information to.
LINEA_MAINNET: 'linea-mainnet', | ||
} as const; | ||
|
||
export const MAINNET_DISPLAY_NAME = 'Ethereum Mainnet'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⏭️ controller-utils
has a NetworkNickname
enum, and I think these display names could be copied there.
// An object that configures minimum threshold enforcement for coverage results | ||
coverageThreshold: { | ||
global: { | ||
branches: 89, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⏭️ We should strive to hit 100% test coverage. Otherwise, if we are on a branch and we get errors from Jest saying that coverage has not been met, it is painful to figure out which lines have been added in that branch that we need to test.
bfbb6d9
to
573c179
Compare
…nation chains are the same
f2bcfd4
to
8cdc9eb
Compare
@mcmire Totally open to revisiting your ⏭️ comments in a future PR, I did handle a number of them that were more straightforward, but left some of the more involved ones for a future PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a couple more comments but they are non-blocking. LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything looks good here, thanks for your patience :)
## 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: `BridgeController`. This controller handles the quote 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 `BridgeController` from Extension: https://github.com/MetaMask/metamask-extension/tree/main/app/scripts/controllers/bridge 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-controller` package. ## 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` - **<ADDED>**: New `BridgeController`! ## 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]>
## 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]>
Explanation
This PR adds a new controller:
BridgeController
.This controller handles the quote fetching and polling from the Bridge API.
References
This is a port of the
BridgeController
from Extension: https://github.com/MetaMask/metamask-extension/tree/main/app/scripts/controllers/bridgeSome 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-controller
package.Changelog
@metamask/bridge-controller
BridgeController
!Checklist