fix: Prevent network request when useCurrencyRateCheck is false#24888
fix: Prevent network request when useCurrencyRateCheck is false#24888
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. |
app/scripts/metamask-controller.js
Outdated
| conversionRate: 0, | ||
| usdConversionRate: 0, |
There was a problem hiding this comment.
| conversionRate: 0, | |
| usdConversionRate: 0, | |
| conversionRate: null, | |
| usdConversionRate: null, |
Can we handle non-numeric values? Anything to allow differentiating rates not being available from actual 0 would be useful? "Your tokens are worth 0" is different from "No price data for your tokens available"
null/undefined/NaN.
There was a problem hiding this comment.
Yes, good suggestion. And it looks like it can be null: https://github.com/MetaMask/core/blob/f522918bace3ab98978d2b10cb15d84293b52a7d/packages/assets-controllers/src/CurrencyRateController.ts#L27-L37
legobeat
left a comment
There was a problem hiding this comment.
Good catch and thanks for preparing a fix!
How involved would it be to couple this with a regression test?
…nt requests when useCurrencyRateCheck is false
04ae9fd to
4ebb97d
Compare
|
@legobeat I added a regression test as well |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #24888 +/- ##
===========================================
+ Coverage 65.74% 65.78% +0.04%
===========================================
Files 1363 1363
Lines 54272 54244 -28
Branches 14109 14109
===========================================
+ Hits 35676 35680 +4
+ Misses 18596 18564 -32 ☔ View full report in Codecov by Sentry. |
Builds ready [4ebb97d]
Page Load Metrics (875 ± 526 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
|
Missing release label release-11.16.6 on PR. Adding release label release-11.16.6 on PR and removing other release labels(release-11.18.0), as PR was cherry-picked in branch 11.16.6. |
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
fetchExchangeRatesmethod of the CurrencyRateController with a function that will just return 0 values if that toggle is off.Manual testing steps
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
Pre-merge reviewer checklist