Skip to content
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

Merged
merged 95 commits into from
Feb 13, 2025
Merged

feat: bridge controller #5276

merged 95 commits into from
Feb 13, 2025

Conversation

infiniteflower
Copy link
Contributor

@infiniteflower infiniteflower commented Feb 4, 2025

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/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

@metamask/bridge-controller

  • ADDED: New BridgeController!

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 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

@infiniteflower infiniteflower marked this pull request as ready for review February 5, 2025 20:48
Copy link

socket-security bot commented Feb 5, 2025

No dependency changes detected. Learn more about Socket for GitHub ↗︎

👍 No dependency changes detected in pull request

@infiniteflower
Copy link
Contributor Author

@SocketSecurity ignore npm/[email protected]

Was Introduced by @metamask/[email protected]

@infiniteflower infiniteflower requested a review from a team February 6, 2025 21:41
@infiniteflower infiniteflower changed the title chore: WIP bridge controller, most tests passing feat: bridge controller Feb 6, 2025
micaelae
micaelae previously approved these changes Feb 6, 2025
Copy link
Contributor

@mcmire mcmire left a 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 = {
Copy link
Contributor

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';
Copy link
Contributor

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,
Copy link
Contributor

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.

@infiniteflower
Copy link
Contributor Author

@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.

mcmire
mcmire previously approved these changes Feb 13, 2025
Copy link
Contributor

@mcmire mcmire left a 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!

Copy link
Contributor

@mcmire mcmire left a 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 :)

@infiniteflower infiniteflower enabled auto-merge (squash) February 13, 2025 22:23
@infiniteflower infiniteflower merged commit d931ffa into main Feb 13, 2025
133 checks passed
@infiniteflower infiniteflower deleted the feat/bridge-controller branch February 13, 2025 22:28
salimtb pushed a commit that referenced this pull request Feb 17, 2025
## 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]>
infiniteflower added a commit that referenced this pull request Feb 20, 2025
## 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants