-
-
Notifications
You must be signed in to change notification settings - Fork 206
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
base: main
Are you sure you want to change the base?
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] |
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.
partialRequest: Partial<QuoteRequest>, | ||
requireAmount = true, | ||
): partialRequest is QuoteRequest => { | ||
const STRING_FIELDS = ['srcTokenAddress', 'destTokenAddress']; |
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.
⏭️ Maybe these should not be SCREAMING_SNAKE_CASE
, since they are not globals.
{ "path": "../base-controller" }, | ||
{ "path": "../controller-utils" }, | ||
{ "path": "../polling-controller" }, | ||
{ "path": "../network-controller" }, | ||
{ "path": "../transaction-controller" } |
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.
It looks like this file is out of sync with dependencies:
{ "path": "../base-controller" }, | |
{ "path": "../controller-utils" }, | |
{ "path": "../polling-controller" }, | |
{ "path": "../network-controller" }, | |
{ "path": "../transaction-controller" } | |
{ "path": "../accounts-controller" }, | |
{ "path": "../base-controller" }, | |
{ "path": "../controller-utils" }, | |
{ "path": "../network-controller" }, | |
{ "path": "../polling-controller" }, | |
{ "path": "../transaction-controller" } |
{ "path": "../accounts-controller/tsconfig.build.json" }, | ||
{ "path": "../approval-controller/tsconfig.build.json" }, | ||
{ "path": "../base-controller/tsconfig.build.json" }, | ||
{ "path": "../controller-utils/tsconfig.build.json" }, | ||
{ "path": "../keyring-controller/tsconfig.build.json" }, | ||
{ "path": "../network-controller/tsconfig.build.json" }, | ||
{ "path": "../preferences-controller/tsconfig.build.json" }, | ||
{ "path": "../polling-controller/tsconfig.build.json" } |
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.
It looks like this is out of date with the dependencies:
{ "path": "../accounts-controller/tsconfig.build.json" }, | |
{ "path": "../approval-controller/tsconfig.build.json" }, | |
{ "path": "../base-controller/tsconfig.build.json" }, | |
{ "path": "../controller-utils/tsconfig.build.json" }, | |
{ "path": "../keyring-controller/tsconfig.build.json" }, | |
{ "path": "../network-controller/tsconfig.build.json" }, | |
{ "path": "../preferences-controller/tsconfig.build.json" }, | |
{ "path": "../polling-controller/tsconfig.build.json" } | |
{ "path": "../accounts-controller/tsconfig.build.json" }, | |
{ "path": "../base-controller/tsconfig.build.json" }, | |
{ "path": "../controller-utils/tsconfig.build.json" }, | |
{ "path": "../network-controller/tsconfig.build.json" }, | |
{ "path": "../polling-controller/tsconfig.build.json" }, | |
{ "path": "../transaction-controller/tsconfig.build.json" } |
// 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.
Co-authored-by: Elliot Winkler <[email protected]>
Co-authored-by: Elliot Winkler <[email protected]>
This reverts commit ee8a1c8.
Co-authored-by: Elliot Winkler <[email protected]>
Co-authored-by: Elliot Winkler <[email protected]>
Co-authored-by: Elliot Winkler <[email protected]>
…evDeps, it's already in peerDeps
Co-authored-by: Elliot Winkler <[email protected]>
Co-authored-by: Elliot Winkler <[email protected]>
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