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: add multichain assets controller #5138

Merged
merged 67 commits into from
Feb 5, 2025

Conversation

sahar-fehri
Copy link
Contributor

@sahar-fehri sahar-fehri commented Jan 13, 2025

Explanation

This PR adds the new MultichainAssetsController. This controller manages non-evm tokens and metadata.

  • Subscribing to AccountsController:accountAdded event and fetch assets for the account and update state accordingly
  • Subscribing to AccountsController:accountRemoved event and remove assets from state
  • Fetching assets metadata after fetching assets for a new account
  • Subscribing to AccountsController:accountAssetListUpdated and Update account assets with removed or added assets.
  • Update all assets metadata once a day (not part of V1 can be done on a separate PR to unblock other teams 🙏 )

References

Changelog

@metamask/assets-controllers

  • ADDED: Added the new MultichainAssetsController.

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

@sahar-fehri
Copy link
Contributor 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": "20.0.2-preview-62a75dc",
  "@metamask-previews/address-book-controller": "6.0.2-preview-62a75dc",
  "@metamask-previews/announcement-controller": "7.0.2-preview-62a75dc",
  "@metamask-previews/approval-controller": "7.1.2-preview-62a75dc",
  "@metamask-previews/assets-controllers": "45.1.2-preview-62a75dc",
  "@metamask-previews/base-controller": "7.1.1-preview-62a75dc",
  "@metamask-previews/build-utils": "3.0.2-preview-62a75dc",
  "@metamask-previews/chain-controller": "0.2.2-preview-62a75dc",
  "@metamask-previews/composable-controller": "10.0.0-preview-62a75dc",
  "@metamask-previews/controller-utils": "11.4.5-preview-62a75dc",
  "@metamask-previews/ens-controller": "15.0.1-preview-62a75dc",
  "@metamask-previews/eth-json-rpc-provider": "4.1.7-preview-62a75dc",
  "@metamask-previews/gas-fee-controller": "22.0.2-preview-62a75dc",
  "@metamask-previews/json-rpc-engine": "10.0.2-preview-62a75dc",
  "@metamask-previews/json-rpc-middleware-stream": "8.0.6-preview-62a75dc",
  "@metamask-previews/keyring-controller": "19.0.2-preview-62a75dc",
  "@metamask-previews/logging-controller": "6.0.3-preview-62a75dc",
  "@metamask-previews/message-manager": "11.0.3-preview-62a75dc",
  "@metamask-previews/multichain": "2.0.0-preview-62a75dc",
  "@metamask-previews/name-controller": "8.0.2-preview-62a75dc",
  "@metamask-previews/network-controller": "22.1.1-preview-62a75dc",
  "@metamask-previews/notification-services-controller": "0.15.0-preview-62a75dc",
  "@metamask-previews/permission-controller": "11.0.5-preview-62a75dc",
  "@metamask-previews/permission-log-controller": "3.0.2-preview-62a75dc",
  "@metamask-previews/phishing-controller": "12.3.1-preview-62a75dc",
  "@metamask-previews/polling-controller": "12.0.2-preview-62a75dc",
  "@metamask-previews/preferences-controller": "15.0.1-preview-62a75dc",
  "@metamask-previews/profile-sync-controller": "3.3.0-preview-62a75dc",
  "@metamask-previews/queued-request-controller": "8.0.2-preview-62a75dc",
  "@metamask-previews/rate-limit-controller": "6.0.2-preview-62a75dc",
  "@metamask-previews/remote-feature-flag-controller": "1.3.0-preview-62a75dc",
  "@metamask-previews/selected-network-controller": "20.0.2-preview-62a75dc",
  "@metamask-previews/signature-controller": "23.2.0-preview-62a75dc",
  "@metamask-previews/transaction-controller": "42.1.0-preview-62a75dc",
  "@metamask-previews/user-operation-controller": "21.0.0-preview-62a75dc"
}

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.

Hello! I did a quick review of this controller and it looks pretty good, just had a few comments to align it with other controllers.

@sahar-fehri sahar-fehri requested a review from a team as a code owner February 4, 2025 20:02
mcmire
mcmire previously approved these changes Feb 4, 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.

LGTM from my side! I had another question, but it's non-blocking.

@sahar-fehri
Copy link
Contributor Author

@metamaskbot publish-preview

Copy link
Contributor

github-actions bot commented Feb 5, 2025

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": "22.0.0-preview-59b4e66e",
  "@metamask-previews/address-book-controller": "6.0.2-preview-59b4e66e",
  "@metamask-previews/announcement-controller": "7.0.2-preview-59b4e66e",
  "@metamask-previews/approval-controller": "7.1.2-preview-59b4e66e",
  "@metamask-previews/assets-controllers": "47.0.0-preview-59b4e66e",
  "@metamask-previews/base-controller": "7.1.1-preview-59b4e66e",
  "@metamask-previews/build-utils": "3.0.2-preview-59b4e66e",
  "@metamask-previews/composable-controller": "10.0.0-preview-59b4e66e",
  "@metamask-previews/controller-utils": "11.5.0-preview-59b4e66e",
  "@metamask-previews/earn-controller": "0.1.0-preview-59b4e66e",
  "@metamask-previews/ens-controller": "15.0.1-preview-59b4e66e",
  "@metamask-previews/eth-json-rpc-provider": "4.1.8-preview-59b4e66e",
  "@metamask-previews/gas-fee-controller": "22.0.2-preview-59b4e66e",
  "@metamask-previews/json-rpc-engine": "10.0.3-preview-59b4e66e",
  "@metamask-previews/json-rpc-middleware-stream": "8.0.6-preview-59b4e66e",
  "@metamask-previews/keyring-controller": "19.0.5-preview-59b4e66e",
  "@metamask-previews/logging-controller": "6.0.3-preview-59b4e66e",
  "@metamask-previews/message-manager": "12.0.0-preview-59b4e66e",
  "@metamask-previews/multichain": "2.1.0-preview-59b4e66e",
  "@metamask-previews/multichain-transactions-controller": "0.1.0-preview-59b4e66e",
  "@metamask-previews/name-controller": "8.0.2-preview-59b4e66e",
  "@metamask-previews/network-controller": "22.2.0-preview-59b4e66e",
  "@metamask-previews/notification-services-controller": "0.18.0-preview-59b4e66e",
  "@metamask-previews/permission-controller": "11.0.5-preview-59b4e66e",
  "@metamask-previews/permission-log-controller": "3.0.2-preview-59b4e66e",
  "@metamask-previews/phishing-controller": "12.3.1-preview-59b4e66e",
  "@metamask-previews/polling-controller": "12.0.2-preview-59b4e66e",
  "@metamask-previews/preferences-controller": "15.0.1-preview-59b4e66e",
  "@metamask-previews/profile-sync-controller": "5.0.0-preview-59b4e66e",
  "@metamask-previews/queued-request-controller": "9.0.0-preview-59b4e66e",
  "@metamask-previews/rate-limit-controller": "6.0.2-preview-59b4e66e",
  "@metamask-previews/remote-feature-flag-controller": "1.3.0-preview-59b4e66e",
  "@metamask-previews/selected-network-controller": "21.0.0-preview-59b4e66e",
  "@metamask-previews/signature-controller": "23.2.0-preview-59b4e66e",
  "@metamask-previews/token-search-discovery-controller": "1.0.0-preview-59b4e66e",
  "@metamask-previews/transaction-controller": "44.1.0-preview-59b4e66e",
  "@metamask-previews/user-operation-controller": "23.0.0-preview-59b4e66e"
}

aganglada
aganglada previously approved these changes Feb 5, 2025
@sahar-fehri sahar-fehri dismissed stale reviews from aganglada and mcmire via 33809cc February 5, 2025 12:14
* @param permission - The permission to get the `chainIds` caveat from.
* @returns An array of `chainIds` that the snap supports.
*/
// istanbul ignore next
Copy link
Contributor

Choose a reason for hiding this comment

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

For other reviews: Since this function comes from the snaps-* packages, we decided to ignore the coverage for this one.

Copy link
Contributor

@ccharly ccharly left a comment

Choose a reason for hiding this comment

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

We made it 🥳 Thanks a lot for addressing everything! 😄

@ccharly ccharly dismissed GuillaumeRx’s stale review February 5, 2025 15:09

Everything has now been addressed.

@sahar-fehri sahar-fehri merged commit ba98b52 into main Feb 5, 2025
127 checks passed
@sahar-fehri sahar-fehri deleted the feat/multichain-assets-controller branch February 5, 2025 15:12
github-merge-queue bot pushed a commit to MetaMask/metamask-extension that referenced this pull request Feb 7, 2025
## **Description**

PR to integrate the new MultichainAssetsController into metamask
controller.

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/30059?quickstart=1)

## **Related issues**

Fixes:

Related: MetaMask/core#5138

## **Manual testing steps**

1. Go to this page...
2.
3.

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **Pre-merge author checklist**

- [ ] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
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.

8 participants