Skip to content

Conversation

@sahar-fehri
Copy link
Contributor

@sahar-fehri sahar-fehri commented Oct 22, 2025

Description

PR to upgrade @metamask/assets-controllers package. It introduces multiple breaking changes:

  • Fetching exchangeRates from price api and fallback to crypto compare.
  • Changes to selector calls to ignore manually selected non-evm assets.
  • Changes to the number of networks enabled by default from @metamask/controller-utils.
    • This one makes a significant amount of changes to initial state and onboarding.
  • New events added to AccountTrackerController.

Changelog

CHANGELOG entry: Fetch currency rates using price api and fallback to crypto compare

Related issues

Fixes:

Manual testing steps

Feature: my feature name

  Scenario: user [verb for user action]
    Given [describe expected initial app state]

    When user [verb for user action]
    Then [describe expected outcome]

Screenshots/Recordings

Before

Screen.Recording.2025-10-22.at.14.19.13.mov

After

Screen.Recording.2025-10-22.at.14.00.22.mov

Pre-merge author checklist

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.

Note

Switches currency rates to the Price API (with normalization), enables more EVM mainnets by default, and updates selectors/tests and configs accordingly.

  • Engine/Controllers:
    • CurrencyRateController: initialize with tokenPricesService (Price API) and normalize persisted currencyRates.
    • NetworkController defaults: add Infura failovers and names for arbitrum-mainnet, bsc-mainnet, optimism-mainnet, polygon-mainnet, sei-mainnet.
    • NetworkEnablementController (patched): default-enable Arbitrum, BNB Chain, OP, Polygon, Sei.
    • AccountTrackerController messenger: listen to NetworkController:networkAdded and KeyringController:unlock.
  • Selectors:
    • Balances/Assets: include MultichainAssetsController.allIgnoredAssets in calculations; wire through in selectors; convert multichain asset selectors to memoized selectors.
  • UI/Tests:
    • AddressSelector tests/snapshots: expect new EVM networks in list/order.
    • OnboardingSuccess: remove network auto-add side effects; drop associated test.
  • E2E/Config:
    • Allowlist price.api.cx.metamask.io; add Infura mock for sei-mainnet; update initial background state and snapshots with new networks and enabled map.
  • Dependencies:
    • Bump @metamask/assets-controllers to ^86.0.0; use patched @metamask/network-enablement-controller.

Written by Cursor Bugbot for commit 5ab6311. This will update automatically on new commits. Configure here.

@github-actions
Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@sahar-fehri sahar-fehri force-pushed the chore/use-price-api-for-currencyRates-Fetching branch from 7722889 to ac65a73 Compare October 23, 2025 09:57
sahar-fehri added a commit to MetaMask/core that referenced this pull request Oct 28, 2025
…er (#6863)

## Explanation


PR to update the `CurrencyRatesController` so it uses the Price API for
exchange rates, with CryptoCompare as a fallback.

## References

* Related to extension:
MetaMask/metamask-extension#36986
* Related to mobile:
MetaMask/metamask-mobile#21523



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

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> CurrencyRateController now uses the Price API (with CryptoCompare
fallback) via a new required tokenPricesService, and
CodefiTokenPricesServiceV2 adds fetchExchangeRates.
> 
> - **Controllers**:
> - **CurrencyRateController**: Fetches exchange rates from Price API
via `tokenPricesService.fetchExchangeRates`, with fallback to
CryptoCompare; updates polling and state mapping; requires new
constructor arg `tokenPricesService` (BREAKING).
> - **Token Prices Service**:
> - **Abstract API**: Adds `ExchangeRate`/`ExchangeRatesByCurrency`
types and new `fetchExchangeRates(args)`.
> - **CodefiTokenPricesServiceV2**: Implements `fetchExchangeRates`
using `/v1/exchange-rates`, supports optional USD rate merging,
retries/circuit-breaker hooks, and filtering.
> - **Tests**:
> - Update `CurrencyRateController.test.ts` to assert Price API path,
fallback behavior, USD inclusion, and polling; adjust mocks across
related tests to include `fetchExchangeRates`.
> - **Docs/Meta**:
>   - Update `CHANGELOG.md` with breaking change and new functionality.
>   - Minor lint threshold updates.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
d22e0af. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
@sahar-fehri sahar-fehri marked this pull request as ready for review October 30, 2025 10:28
@sahar-fehri sahar-fehri requested review from a team as code owners October 30, 2025 10:28
@socket-security
Copy link

socket-security bot commented Oct 30, 2025

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

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatednpm/​@​metamask/​controller-utils@​11.14.1 ⏵ 11.15.099 +110077 +196 +3100
Updatednpm/​@​metamask/​assets-controllers@​84.0.0 ⏵ 86.0.098 +110091 +198100

View full report

@socket-security
Copy link

socket-security bot commented Oct 30, 2025

All alerts resolved. Learn more about Socket for GitHub.

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

View full report

cursor[bot]

This comment was marked as outdated.

@bergarces bergarces added the skip-sonar-cloud Only used for bypassing sonar cloud when failures are not relevant to the changes. label Nov 3, 2025
@bergarces bergarces force-pushed the chore/use-price-api-for-currencyRates-Fetching branch from cf57277 to 8d91235 Compare November 3, 2025 21:16
@bergarces
Copy link
Contributor

Not even one of the SonarCloud "issues" (they aren't) is new.

bergarces
bergarces previously approved these changes Nov 4, 2025
@bergarces bergarces force-pushed the chore/use-price-api-for-currencyRates-Fetching branch from a700c62 to 5ab6311 Compare November 4, 2025 10:07
@tommasini
Copy link
Contributor

Not even one of the SonarCloud "issues" (they aren't) is new.

We need to ignore them on the sonar cloud then, will talk with the team! Thanks @bergarces

@bergarces
Copy link
Contributor

bergarces commented Nov 4, 2025

Not even one of the SonarCloud "issues" (they aren't) is new.

We need to ignore them on the sonar cloud then, will talk with the team! Thanks @bergarces

The arrow function being too large warning is ok in general (better to use an object bag than too many arguments), but in this case it is the only reasonable way of doing it, since that's the interface for selectors.

The one about the useless assignment is also good in general, but that's because SonarCloud is not aware of our code fencing comments.

The rest are the usual "please complete your TODOs" (which sometimes makes sense, but other times they are there to split the PR in smaller ones) and one about a type assignment, which is not really part of this PR either.

My main beef with SonarCloud is that it adds issues as "New" when they were already there.

In general, I think it's best to let SonarCloud report freely, we can then make the call as to whether we want to ignore it or not.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 4, 2025

Copy link
Contributor

@grvgoel81 grvgoel81 left a comment

Choose a reason for hiding this comment

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

LGTM

@bergarces bergarces enabled auto-merge November 4, 2025 13:30
@bergarces bergarces added this pull request to the merge queue Nov 4, 2025
Merged via the queue into main with commit f18bfbf Nov 4, 2025
179 of 220 checks passed
@bergarces bergarces deleted the chore/use-price-api-for-currencyRates-Fetching branch November 4, 2025 15:12
@github-actions github-actions bot locked and limited conversation to collaborators Nov 4, 2025
@metamaskbot metamaskbot added the release-7.59.0 Issue or pull request that will be included in release 7.59.0 label Nov 4, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.59.0 Issue or pull request that will be included in release 7.59.0 size-M skip-sonar-cloud Only used for bypassing sonar cloud when failures are not relevant to the changes. team-assets

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: User balance showing $0.00 for native tokens

10 participants