-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
chore: fetch currencyRates with price api #21523
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
chore: fetch currencyRates with price api #21523
Conversation
|
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. |
7722889 to
ac65a73
Compare
…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 -->
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
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. |
cf57277 to
8d91235
Compare
|
Not even one of the SonarCloud "issues" (they aren't) is new. |
a700c62 to
5ab6311
Compare
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. |
|
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.
LGTM



Description
PR to upgrade
@metamask/assets-controllerspackage. It introduces multiple breaking changes:@metamask/controller-utils.AccountTrackerController.Changelog
CHANGELOG entry: Fetch currency rates using price api and fallback to crypto compare
Related issues
Fixes:
Manual testing steps
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
Note
Switches currency rates to the Price API (with normalization), enables more EVM mainnets by default, and updates selectors/tests and configs accordingly.
CurrencyRateController: initialize withtokenPricesService(Price API) and normalize persistedcurrencyRates.NetworkControllerdefaults: add Infura failovers and names forarbitrum-mainnet,bsc-mainnet,optimism-mainnet,polygon-mainnet,sei-mainnet.NetworkEnablementController(patched): default-enableArbitrum,BNB Chain,OP,Polygon,Sei.AccountTrackerControllermessenger: listen toNetworkController:networkAddedandKeyringController:unlock.MultichainAssetsController.allIgnoredAssetsin calculations; wire through in selectors; convert multichain asset selectors to memoized selectors.AddressSelectortests/snapshots: expect new EVM networks in list/order.OnboardingSuccess: remove network auto-add side effects; drop associated test.price.api.cx.metamask.io; add Infura mock forsei-mainnet; update initial background state and snapshots with new networks and enabled map.@metamask/assets-controllersto^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.