- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 252
 
chore: use price-api to fetch exchange rates in currencyRatesController #6863
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: use price-api to fetch exchange rates in currencyRatesController #6863
Conversation
748a952    to
    a7ce511      
    Compare
  
    …cryptocompare-in-currencyRatesController
| 
           @metamaskbot publish-preview  | 
    
…cryptocompare-in-currencyRatesController
| 
           @metamaskbot publish-preview  | 
    
…cryptocompare-in-currencyRatesController
| 
           @metamaskbot publish-preview  | 
    
| 
           Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. | 
    
| 
           @metamaskbot publish-preview  | 
    
| 
           Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. | 
    
…cryptocompare-in-currencyRatesController
…cryptocompare-in-currencyRatesController
| 
           @metamaskbot publish-preview  | 
    
| 
           Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. | 
    
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.
build tested , works as expected
…cryptocompare-in-currencyRatesController
…cryptocompare-in-currencyRatesController
db7ef9d    to
    d414925      
    Compare
  
    …cryptocompare-in-currencyRatesController
Merge commits are not allowed on this repository
#36986) ## **Description** PR to introduce fetching exchangeRates from price api and fallback to crypto compare. Do not merge until this goes in MetaMask/core#6863 [](https://codespaces.new/MetaMask/metamask-extension/pull/36986?quickstart=1) ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: null ## **Related issues** Fixes: ## **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] --> https://github.com/user-attachments/assets/a8dc4ac7-9810-48a5-8fdd-19f0bc9f8b92 ### **After** <!-- [screenshots/recordings] --> https://github.com/user-attachments/assets/dcb1c517-5b9c-464d-aa27-853c7c99a781 ## **Pre-merge author checklist** - [X] 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). - [X] I've completed the PR template to the best of my ability - [X] I’ve included tests if applicable - [X] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [X] 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. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Integrates Codefi price API into `CurrencyRateController` and includes multichain asset state in balance calculations; wires `allIgnoredAssets` across state/Sentry and bumps key deps. > > - **Rates/Controller Init**: > - Inject `CodefiTokenPricesServiceV2` into `CurrencyRateController` via `tokenPricesService`; update init and tests/mocks. > - **Selectors/Balances**: > - Add `getAllIgnoredAssets` and include `{ accountsAssets, assetsMetadata, allIgnoredAssets }` in balance and balance-change selectors (`selectBalanceForAllWallets`, etc.). > - **State/Telemetry**: > - Add `metamask.allIgnoredAssets` to app state, Sentry background/UI masks, mock states, and snapshots. > - **Dependencies**: > - Bump `@metamask/assets-controllers` to `^85.0.0` and `@metamask/controller-utils` to `^11.15.0`; remove yarn patch for controller-utils and lockfile updates. > - **Misc**: > - Update storybook test data and integration/e2e fixtures to include `allIgnoredAssets`. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 3ad4311. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Bernardo Garces Chapero <bernardo.chapero@consensys.net> Co-authored-by: juanmigdr <juanmi.gdr@gmail.com>
Explanation
PR to update the
CurrencyRatesControllerso it uses the Price API for exchange rates, with CryptoCompare as a fallback.References
Checklist
Note
CurrencyRateController now uses the Price API (with CryptoCompare fallback) via a new required tokenPricesService, and CodefiTokenPricesServiceV2 adds fetchExchangeRates.
tokenPricesService.fetchExchangeRates, with fallback to CryptoCompare; updates polling and state mapping; requires new constructor argtokenPricesService(BREAKING).ExchangeRate/ExchangeRatesByCurrencytypes and newfetchExchangeRates(args).fetchExchangeRatesusing/v1/exchange-rates, supports optional USD rate merging, retries/circuit-breaker hooks, and filtering.CurrencyRateController.test.tsto assert Price API path, fallback behavior, USD inclusion, and polling; adjust mocks across related tests to includefetchExchangeRates.CHANGELOG.mdwith breaking change and new functionality.Written by Cursor Bugbot for commit d22e0af. This will update automatically on new commits. Configure here.