feat: new assets controller aggregated balance#40239
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. |
✨ Files requiring CODEOWNER review ✨💎 @MetaMask/metamask-assets (2 files, +100 -4)
📜 @MetaMask/policy-reviewers (4 files, +48 -0)
Tip Follow the policy review process outlined in the LavaMoat Policy Review Process doc before expecting an approval from Policy Reviewers. |
8e9b42a to
08174b1
Compare
Builds ready [08174b1]
⚡ Performance Benchmarks (1375 ± 101 ms)
🌐 Dapp Page Load BenchmarksCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
|
@metamaskbot update-policies |
|
Policies updated. 🧠 Learn how: https://lavamoat.github.io/guides/policy-diff/#what-to-look-for-when-reviewing-a-policy-diff 👀 lavamoat/browserify/beta/policy.json changes differ from main/policy.json policy changes |
Builds ready [193a955]
⚡ Performance Benchmarks (1353 ± 98 ms)
🌐 Dapp Page Load BenchmarksCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [ee7fe0f]
⚡ Performance Benchmarks (1401 ± 113 ms)
🌐 Dapp Page Load BenchmarksCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
ui/components/app/assets/account-group-balance/account-group-balance.tsx
Show resolved
Hide resolved
ui/components/app/assets/account-group-balance/account-group-balance.test.tsx
Show resolved
Hide resolved
|
Builds ready [d683260]
⚡ Performance Benchmarks (1388 ± 118 ms)
🌐 Dapp Page Load BenchmarksCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
<!-- 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. --> ## **Description** use new state for aggregated balance <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> [](https://codespaces.new/MetaMask/metamask-extension/pull/40239?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: use new state for aggregated balance ## **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] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [ ] 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). - [ ] 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/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] > **Medium Risk** > Changes balance computation/display paths and introduces new state-derived selectors, which could affect shown totals across networks/accounts if inputs or aggregation assumptions differ from the legacy path. > > **Overview** > Updates the account group balance display to **prefer the new AssetsController aggregated fiat total** (`selectAggregatedBalanceForSelectedAccount`) when available, falling back to the legacy account-group total and keeping native/testnet display behavior unchanged. > > Adds new assets-state selectors (`getAssetsInfo`, `getAssetsBalance`, `getAssetsPrice`, `getAssetPreferences`, `getCustomAssets`) plus a memoized aggregated-balance selector that calls `getAggregatedBalanceForAccount`, and expands unit tests to cover the new selector and additional UI states (privacy masking, cached-balance styling, skeleton behavior, and aggregated-balance rendering). > > Updates LavaMoat MV3 policies to allow the new `@metamask/assets-controller` package (and its `bignumber.js` dependency) across `main`, `beta`, `flask`, and `experimental` builds. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit d683260. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com>



Description
use new state for aggregated balance
Changelog
CHANGELOG entry: use new state for aggregated balance
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Changes balance computation/display paths and introduces new state-derived selectors, which could affect shown totals across networks/accounts if inputs or aggregation assumptions differ from the legacy path.
Overview
Updates the account group balance display to prefer the new AssetsController aggregated fiat total (
selectAggregatedBalanceForSelectedAccount) when available, falling back to the legacy account-group total and keeping native/testnet display behavior unchanged.Adds new assets-state selectors (
getAssetsInfo,getAssetsBalance,getAssetsPrice,getAssetPreferences,getCustomAssets) plus a memoized aggregated-balance selector that callsgetAggregatedBalanceForAccount, and expands unit tests to cover the new selector and additional UI states (privacy masking, cached-balance styling, skeleton behavior, and aggregated-balance rendering).Updates LavaMoat MV3 policies to allow the new
@metamask/assets-controllerpackage (and itsbignumber.jsdependency) acrossmain,beta,flask, andexperimentalbuilds.Written by Cursor Bugbot for commit d683260. This will update automatically on new commits. Configure here.