chore(runway): cherry-pick fix: remove currency rates multichain#22022
Merged
Conversation
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->
This PR removes the `RatesController` to reduce redundant CryptoCompare
API calls in the multichain architecture.
The `RatesController` was introduced for fetching cryptocurrency
conversion rates (primarily for BTC and SOL) to support non-EVM chains.
However, this resulted in duplicate API calls to CryptoCompare since we
already have `MultichainAssetsRatesController` and
`TokenRatesController` handling rate fetching functionality. This
redundancy increased API usage unnecessarily.
- Removed `RatesController` initialization and configuration from the
Engine
- Deleted `RatesController` messenger setup and related controller
initialization files
- Removed multichain selectors that depended on `RatesController` state
(`selectMultichainConversionRate`, `selectMultichainCoinRates`)
- Cleaned up type definitions and state management to remove
`RatesController` references
- Updated test snapshots and initial background state
The existing `MultichainAssetsRatesController` and
`TokenRatesController` will continue to handle all rate-fetching needs
without the additional overhead of `RatesController`.
CHANGELOG entry: Removed redundant RatesController to optimize API usage
Fixes: <!-- Add issue number if applicable -->
```gherkin
Feature: Multichain rate fetching
Scenario: User views portfolio balance with non-EVM accounts
Given user has Bitcoin and Solana accounts configured
And user is viewing their portfolio
When the app fetches cryptocurrency rates
Then rates should be fetched only through MultichainAssetsRatesController
And no redundant API calls should be made to CryptoCompare
And account balances should display with correct fiat conversions
Scenario: User switches between EVM and non-EVM accounts
Given user has both EVM and non-EVM accounts
And user is viewing their wallet
When user switches between different account types
Then appropriate conversion rates should display for each account
And rate updates should continue to work correctly
```
<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->
<!-- RatesController making redundant API calls alongside
MultichainAssetsRatesController -->
<!-- Single source of rate fetching through
MultichainAssetsRatesController, reducing API overhead -->
- [ ] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.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-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
- [ ] 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]
> Removes RatesController across Engine, messengers, selectors, and
types; adds migration 106 to purge its persisted state; updates tests
and fixtures.
>
> - **Engine/Core**:
> - Remove `RatesController` initialization, context exposure, polling,
and state-change subscriptions in `Engine.ts` and `constants.ts`.
> - Drop `rates-controller-init` and its tests; delete
`rates-controller-messenger` and references in `messengers/index.ts`.
> - **Selectors**:
> - Remove `selectMultichainConversionRate` and
`selectMultichainCoinRates`; update `multichain.ts` and related tests
accordingly.
> - **Types**:
> - Strip `RatesController` types and entries from `types.ts`
(controllers, state, actions/events, controller names).
> - **Migration**:
> - Add migration `106` to remove `backgroundState.RatesController`;
register in `migrations/index.ts` with tests.
> - **Tests/Fixtures**:
> - Update snapshots and `initial-background-state.json` to omit
`RatesController`.
> - Adjust `Engine.test.ts` assertions to no longer expect
`RatesController`.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
da413b8. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
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. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## release/7.57.2 #22022 +/- ##
=================================================
Coverage ? 76.78%
=================================================
Files ? 3445
Lines ? 85523
Branches ? 15951
=================================================
Hits ? 65669
Misses ? 15421
Partials ? 4433 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Collaborator
|
No release label on PR. Adding release label release-7.58.0 on PR, as PR was cherry-picked in branch 7.58.0. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
This PR removes the
RatesControllerto reduce redundant CryptoCompareAPI calls in the multichain architecture.
Reason for the change
The
RatesControllerwas introduced for fetching cryptocurrencyconversion rates (primarily for BTC and SOL) to support non-EVM chains.
However, this resulted in duplicate API calls to CryptoCompare since we
already have
MultichainAssetsRatesControllerandTokenRatesControllerhandling rate fetching functionality. Thisredundancy increased API usage unnecessarily.
Improvement/solution
RatesControllerinitialization and configuration from theEngine
RatesControllermessenger setup and related controllerinitialization files
RatesControllerstate(
selectMultichainConversionRate,selectMultichainCoinRates)RatesControllerreferencesThe existing
MultichainAssetsRatesControllerandTokenRatesControllerwill continue to handle all rate-fetching needswithout the additional overhead of
RatesController.Changelog
CHANGELOG entry: Removed redundant RatesController to optimize API usage
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Docs and MetaMask Mobile
Coding
Standards.
if applicable
guidelines).
Not required for external contributors.
Pre-merge reviewer checklist
app, test code being changed).
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
Note
Removes the legacy RatesController across Engine, selectors, types, and fixtures, and adds migration 106 to delete its persisted state.
RatesControllercreation, messenger setup, currency rate sync, andstart()call instartPolling.RatesControllerfromcontext, initialization, and state exposure.selectMultichainConversionRateandselectMultichainCoinRatesfromapp/selectors/multichain/multichain.tsand related tests.106to removebackgroundState.RatesControllerwith tests.RatesControllertypes, actions/events, and state fromapp/core/Engine/types.tsandconstants.ts.Engine.test.ts, multichain selector tests, snapshots, andinitial-background-state.jsonto excludeRatesController.Written by Cursor Bugbot for commit c676194. This will update automatically on new commits. Configure here.
43c399b