feat: replace assets state references in Engine#29727
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. |
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
Performance Test Selection: |
|
There was a problem hiding this comment.
For assets state, we are no longer reading data directly from the controller state, but we are using store.getState() instead. That's why the state changes have been moved to that function mock.



Description
The new
AssetsControlleris being introduced to replace most controllers from@metamask/assets-controllers. This is one of many PRs that replace direct access to legacy state with selectors that, using a feature flag, handle the transition between the legacy state and the new state when the flag is turned on.Changelog
CHANGELOG entry: null
Related issues
Fixes: https://consensyssoftware.atlassian.net/browse/ASSETS-2827
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Performance checks (if applicable)
trace()for usage andaddTokenfor an exampleFor performance guidelines and tooling, see the Performance Guide.
Pre-merge reviewer checklist
Note
Medium Risk
Updates a core balance-calculation path to source data from Redux selectors instead of controller state, which could change results depending on feature-flagged state shape. Risk is mitigated by updating unit tests, but errors would affect fiat balance display across networks.
Overview
Refactors
Engine.getTotalEvmFiatAccountBalanceto stop reading asset/currency/token data directly from Engine controller instances and instead pullaccountsByChainId, token lists/balances, market data, and currency rates viaassets-migrationselectors offstore.getState().Updates
Engine.test.tsto mockstore.getState()and provide the expectedengine.backgroundStateslices for the balance-calculation test cases (no balances, ETH only, ETH+tokens, ETH+staked ETH+tokens).Reviewed by Cursor Bugbot for commit 4993f4a. Bugbot is set up for automated code reviews on this repo. Configure here.