Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Prevent network request when useCurrencyRateCheck is false (#24888)
## **Description** With MetaMask/core#1805, polling in the CurrencyRateController happens when the controller is initialized. Once the extension received an update to use the version containing those changes, we started making cryptocompare network requests even when the "Show balance and token price checker" toggle is off. This PR prevents those requests when that toggle is off by wrapping the `fetchExchangeRates` method of the CurrencyRateController with a function that will just return 0 values if that toggle is off. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/24888?quickstart=1) ## **Manual testing steps** 1. Install and build and onboard 2. See requests to cryptocompare in the background console 3. Toggle off "Show balance and token price checker" 4. Reload the extension, there should be no requests to cryptocompare 5. Switch networks, there should be no requests to cryptocompare 1, Install and onboard 2. Toggle off "Show balance and token price checker" in advanced settings during onboarding 3. There should be not requests to cryptocompare after onboarding For either of the above scenarios, toggle "Show balance and token price checker" back on. There should now be requests to cryptocompare ## **Pre-merge author checklist** - [ ] I’ve followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.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/develop/.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.
- Loading branch information