Skip to content

feat: calculate bridge quote metadata in @metamask/bridge-controller #5614

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

Merged
merged 70 commits into from
Apr 15, 2025

Conversation

micaelae
Copy link
Member

@micaelae micaelae commented Apr 9, 2025

Explanation

Refer to extension integration PR for usage examples: MetaMask/metamask-extension#31752

Added

  • BREAKING: Bump dependency bignumber.js to ^9.1.2 (#5614)
  • BREAKING: Bump dependency reselect to ^5.1.1 (#5614)
  • BREAKING: Bump dependency @metamask/assets-controllers to ^56.0.0 (#5614)
  • assetExchangeRates added to BridgeController state to support tokens which are not supported by assets controllers (#5614)
  • selectExchangeRateByChainIdAndAddress selector added, which looks up exchange rates from assets and bridge controller states (#5614)
  • selectBridgeQuotes selector added, which returns sorted quotes including their metadata (#5614)
  • selectIsQuoteExpired selector added, which returns whether quotes are expired or stale (#5614)

Changed

  • BREAKING: Change TokenAmountValues key types from BigNumber to string (#5614)
  • BREAKING: getState actions have been added to AllowedActions and clients need to update controller initializations (#5614)

References

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, highlighting breaking changes as necessary
  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes

@micaelae micaelae requested review from a team as code owners April 9, 2025 01:18
Copy link

socket-security bot commented Apr 9, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​metamask/​assets-controllers@​56.0.09010090100100

View full report

@micaelae micaelae requested a review from Copilot April 9, 2025 02:54
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 9 out of 12 changed files in this pull request and generated 2 comments.

Files not reviewed (3)
  • packages/bridge-controller/package.json: Language not supported
  • packages/bridge-controller/tsconfig.build.json: Language not supported
  • packages/bridge-controller/tsconfig.json: Language not supported

@micaelae micaelae requested a review from Copilot April 9, 2025 02:59
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 9 out of 12 changed files in this pull request and generated 1 comment.

Files not reviewed (3)
  • packages/bridge-controller/package.json: Language not supported
  • packages/bridge-controller/tsconfig.build.json: Language not supported
  • packages/bridge-controller/tsconfig.json: Language not supported
Comments suppressed due to low confidence (1)

packages/bridge-controller/src/bridge-controller.ts:254

  • Merging multiple state objects via the spread operator can lead to key collisions; consider explicitly mapping or namespacing the keys from each controller to ensure state values are not inadvertently overwritten.
const exchangeRateSources = { ...this.messagingSystem.call('MultichainAssetsRatesController:getState'), ...this.messagingSystem.call('CurrencyRateController:getState'), ...this.messagingSystem.call('TokenRatesController:getState'), ...this.state };

ghgoodreau
ghgoodreau previously approved these changes Apr 9, 2025
Copy link
Contributor

@amitabh94 amitabh94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small comments but otherwise looks good !

Would be great to see a pair PR for extension using these selectors even if it is a rough one.

@micaelae micaelae enabled auto-merge (squash) April 14, 2025 21:33
Co-authored-by: cryptodev-2s <[email protected]>
@micaelae micaelae dismissed stale reviews from ghgoodreau and amitabh94 via f9fd7f9 April 14, 2025 21:34
@mcmire
Copy link
Contributor

mcmire commented Apr 14, 2025

@micaelae

There appear to be some breaking changes in this PR. I noticed this item in the checklist was not checked:

  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes

Are there draft PRs that we've created on both extension and mobile, and if not, can we do that? That will help to ensure that we can upgrade to the new version quickly.

@micaelae
Copy link
Member Author

@metamaskbot publish-preview

Copy link
Contributor

Preview builds have been published. See these instructions for more information about preview builds.

Expand for full list of packages and versions.
{
  "@metamask-previews/accounts-controller": "27.0.0-preview-fa0d6d4b",
  "@metamask-previews/address-book-controller": "6.0.3-preview-fa0d6d4b",
  "@metamask-previews/announcement-controller": "7.0.3-preview-fa0d6d4b",
  "@metamask-previews/app-metadata-controller": "1.0.0-preview-fa0d6d4b",
  "@metamask-previews/approval-controller": "7.1.3-preview-fa0d6d4b",
  "@metamask-previews/assets-controllers": "56.0.0-preview-fa0d6d4b",
  "@metamask-previews/base-controller": "8.0.0-preview-fa0d6d4b",
  "@metamask-previews/bridge-controller": "13.0.0-preview-fa0d6d4b",
  "@metamask-previews/bridge-status-controller": "12.0.1-preview-fa0d6d4b",
  "@metamask-previews/build-utils": "3.0.3-preview-fa0d6d4b",
  "@metamask-previews/chain-agnostic-permission": "0.3.0-preview-fa0d6d4b",
  "@metamask-previews/composable-controller": "11.0.0-preview-fa0d6d4b",
  "@metamask-previews/controller-utils": "11.7.0-preview-fa0d6d4b",
  "@metamask-previews/earn-controller": "0.11.0-preview-fa0d6d4b",
  "@metamask-previews/eip1193-permission-middleware": "0.1.0-preview-fa0d6d4b",
  "@metamask-previews/ens-controller": "16.0.0-preview-fa0d6d4b",
  "@metamask-previews/eth-json-rpc-provider": "4.1.8-preview-fa0d6d4b",
  "@metamask-previews/gas-fee-controller": "23.0.0-preview-fa0d6d4b",
  "@metamask-previews/json-rpc-engine": "10.0.3-preview-fa0d6d4b",
  "@metamask-previews/json-rpc-middleware-stream": "8.0.7-preview-fa0d6d4b",
  "@metamask-previews/keyring-controller": "21.0.2-preview-fa0d6d4b",
  "@metamask-previews/logging-controller": "6.0.4-preview-fa0d6d4b",
  "@metamask-previews/message-manager": "12.0.1-preview-fa0d6d4b",
  "@metamask-previews/multichain": "4.0.0-preview-fa0d6d4b",
  "@metamask-previews/multichain-api-middleware": "0.1.1-preview-fa0d6d4b",
  "@metamask-previews/multichain-network-controller": "0.3.0-preview-fa0d6d4b",
  "@metamask-previews/multichain-transactions-controller": "0.9.0-preview-fa0d6d4b",
  "@metamask-previews/name-controller": "8.0.3-preview-fa0d6d4b",
  "@metamask-previews/network-controller": "23.2.0-preview-fa0d6d4b",
  "@metamask-previews/notification-services-controller": "5.0.1-preview-fa0d6d4b",
  "@metamask-previews/permission-controller": "11.0.6-preview-fa0d6d4b",
  "@metamask-previews/permission-log-controller": "3.0.3-preview-fa0d6d4b",
  "@metamask-previews/phishing-controller": "12.4.1-preview-fa0d6d4b",
  "@metamask-previews/polling-controller": "13.0.0-preview-fa0d6d4b",
  "@metamask-previews/preferences-controller": "17.0.0-preview-fa0d6d4b",
  "@metamask-previews/profile-sync-controller": "11.0.1-preview-fa0d6d4b",
  "@metamask-previews/queued-request-controller": "10.0.0-preview-fa0d6d4b",
  "@metamask-previews/rate-limit-controller": "6.0.3-preview-fa0d6d4b",
  "@metamask-previews/remote-feature-flag-controller": "1.6.0-preview-fa0d6d4b",
  "@metamask-previews/sample-controllers": "0.1.0-preview-fa0d6d4b",
  "@metamask-previews/selected-network-controller": "22.0.0-preview-fa0d6d4b",
  "@metamask-previews/signature-controller": "27.1.0-preview-fa0d6d4b",
  "@metamask-previews/token-search-discovery-controller": "2.1.0-preview-fa0d6d4b",
  "@metamask-previews/transaction-controller": "54.0.0-preview-fa0d6d4b",
  "@metamask-previews/user-operation-controller": "33.0.0-preview-fa0d6d4b"
}

@micaelae
Copy link
Member Author

@mcmire here's the PR for upgrading the package in extension: MetaMask/metamask-extension#31752

the logic for consuming the new functionality I introduced here doesn't exist in mobile yet and they plan to implement it this week

@mcmire
Copy link
Contributor

mcmire commented Apr 14, 2025

@micaelae Okay cool, thank you!

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.

Changes look good, thank you :)

@micaelae micaelae merged commit c669ea6 into main Apr 15, 2025
202 checks passed
@micaelae micaelae deleted the mms2136-bridge-quote-metadata branch April 15, 2025 23:32
@micaelae micaelae mentioned this pull request Apr 16, 2025
micaelae added a commit that referenced this pull request Apr 16, 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?
-->

Releasing @metamask/bridge-controller 14.0.0 which includes cross-chain
swaps quote metadata utilities added in
#5614

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

## Changelog

<!--
THIS SECTION IS NO LONGER NEEDED.

The process for updating changelogs has changed. Please consult the
"Updating changelogs" section of the Contributing doc for more.
-->

## 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 communicated my changes to consumers by [updating changelogs
for packages I've
changed](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs),
highlighting breaking changes as necessary
[X] I've prepared draft pull requests for clients and consumer packages
to resolve any breaking changes
micaelae added a commit that referenced this pull request Apr 16, 2025
## Explanation

Extension integration PR:
MetaMask/metamask-extension#31907

This adds a `submitTx` method to the bridge-status-controller that
submits a Solana tx to the Keyring/snap controller then starts polling
for transaction status

To use this in mobile/extension
- replace the confirmation and status polling calls with `submitTx`
- the new method needs to be bound
- the controller init needs to be updated with snap permissions (see
[extension
example](https://github.com/MetaMask/metamask-extension/pull/31907/files#diff-6fbff2cfe97ac01b77296ef2122c7e0a5b3ff6a84b584b4d1a87482f35eea3d6))
- this change depends on type updates included in
[bridge-controller](#5614)



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

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

## Changelog

<!--
THIS SECTION IS NO LONGER NEEDED.

The process for updating changelogs has changed. Please consult the
"Updating changelogs" section of the Contributing doc for more.
-->

## 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 communicated my changes to consumers by [updating changelogs
for packages I've
changed](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs),
highlighting breaking changes as necessary
- [X] I've prepared draft pull requests for clients and consumer
packages to resolve any breaking changes

---------

Co-authored-by: cryptodev-2s <[email protected]>
Co-authored-by: infiniteflower <[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.

6 participants