Skip to content

Conversation

bergarces
Copy link
Contributor

@bergarces bergarces commented Oct 13, 2025

Description

This PR concludes the migration to AccountsTrackerController from core. This is necessary in order to benefit from performance changes added and planned to the core controller.

Open in GitHub Codespaces

Changelog

CHANGELOG entry: null

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/ASSETS-1368

Manual testing steps

  1. Go to this page...

Screenshots/Recordings

Before

After

Pre-merge author checklist

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.

Note

Replaces legacy AccountTracker with core controller, updates state to checksummed accountsByChainId only, adjusts polling, selectors, and middleware, adds migration, and updates tests/fixtures and dependency.

  • Controllers/Init:
    • Replace local AccountTrackerController with @metamask/assets-controllers version; update init to use getStakedBalanceForChain, allowExternalServices, and feature-flagged API chain IDs.
    • Remove listeners and balance updates tied to transactions/network change; simplify transaction init listeners.
    • Update messengers and controller list/state types to new controller and actions/events.
  • State & Migration:
    • Remove accounts and block gas limit fields; rely on accountsByChainId only.
    • Add migration 182 to rebuild AccountTracker.accountsByChainId with checksummed addresses and balances.
    • Update sentry-state to stop tracking removed fields.
  • UI/Selectors/Hooks:
    • Adjust selectors to read from accountsByChainId and normalize addresses to lowercase for UI use.
    • Remove getters for block gas limit; update send flow to use existing field placeholder.
    • Change account tracker polling to accept batched { networkClientIds } and manage a single polling token.
  • Middleware/Controller usage:
    • Compute metrics number_of_accounts from accountsByChainId.
    • Update balance lookups to checksum addresses; remove keyring-driven sync and related handlers.
  • Tests/Fixtures:
    • Remove legacy controller and batch-utils tests; update fixtures/test data to checksummed keys and dropped fields.
  • Dependencies:
    • Upgrade to @metamask-previews/[email protected] and remove single-call-balance-checker-abi/contracts constants.

Written by Cursor Bugbot for commit 3fbd97d. This will update automatically on new commits. Configure here.

Copy link
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.

@metamaskbot
Copy link
Collaborator

metamaskbot commented Oct 13, 2025

✨ Files requiring CODEOWNER review ✨

@MetaMask/confirmations (1 files, +0 -15)
  • 📁 app/
    • 📁 scripts/
      • 📁 controller-init/
        • 📁 confirmations/
          • 📄 transaction-controller-init.ts +0 -15

🔄 @MetaMask/swaps-engineers (1 files, +4 -8)
  • 📁 test/
    • 📁 data/
      • 📁 bridge/
        • 📄 mock-token-data.ts +4 -8

👨‍🔧 @MetaMask/wallet-integrations (2 files, +6 -16)
  • 📁 app/
    • 📁 scripts/
      • 📁 lib/
        • 📁 rpc-method-middleware/
          • 📁 handlers/
            • 📄 request-accounts.test.ts +0 -14
            • 📄 request-accounts.ts +6 -2

useExternalServices: true,
// from core PreferencesController
isMultiAccountBalancesEnabled: true,
useMultiAccountBalanceChecker: true,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Putting them together as it'll be easier to remove one when we eventually migrate to the core PreferencesController. For now, and considering this PR is already big enough, we are keeping both.

*/
export function getKeyringControllerMessenger(
messenger: Messenger<AllowedActions, AllowedEvents>,
messenger: Messenger<never, never>,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was using the wrong types from a different controller. KeyringController does not require any AllowedActions or AllowedEvents

networkClientId,
);
},
includeStakedAssets: false,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not part of this PR to include staked assets in the assets list. When we want to enable them, we can do so.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just moved the properties together so it's easier to refactor them when the time comes.

setUseMultiAccountBalanceChecker(val: boolean): void {
this.update((state) => {
state.useMultiAccountBalanceChecker = val;
state.isMultiAccountBalancesEnabled = val;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making sure isMultiAccountBalancesEnabled gets updated as well. Before this, it was always kept as true and not being used at all.

@metamaskbot
Copy link
Collaborator

Builds ready [73b667c]
UI Startup Metrics (1256 ± 75 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup1256112715697512841409
load107295713436910971228
domContentLoaded106695213376810911221
domInteractive18134661729
firstPaint64099131643010851153
backgroundConnect2532392777258266
firstReactRender29195273246
getState2074872430
initialActions51314611
loadScripts819717106866842973
setupStore951721014
BrowserifyPower User HomeuiStartup22841957364550228943645
load1105946173023713631730
domContentLoaded1091940169023013261690
domInteractive271570195170
firstPaint62616914904579851490
backgroundConnect27325034424284344
firstReactRender30253623136
getState21118326925218269
initialActions52112611
loadScripts836686138821510591388
setupStore1482971929
WebpackStandard HomeuiStartup------
load------
domContentLoaded------
domInteractive------
firstPaint------
backgroundConnect------
firstReactRender------
getState------
initialActions------
loadScripts------
setupStore------
WebpackPower User HomeuiStartup------
load------
domContentLoaded------
domInteractive------
firstPaint------
backgroundConnect------
firstReactRender------
getState------
initialActions------
loadScripts------
setupStore------
FirefoxBrowserifyStandard HomeuiStartup14531259176310515031674
load1232107914308112901383
domContentLoaded1231107914298112901383
domInteractive1163435756129251
firstPaint------
backgroundConnect3723172183866
firstReactRender26214652638
getState74446711
initialActions3144436
loadScripts1208106213998112661362
setupStore13772111244
BrowserifyPower User HomeuiStartup25572263342229526673422
load13501172161012014431610
domContentLoaded13501172161012014431610
domInteractive1414232977200329
firstPaint------
backgroundConnect16431680202178680
firstReactRender463272104872
getState1477721540176215
initialActions1014914949
loadScripts13121150156311213821563
setupStore3272445630244
WebpackStandard HomeuiStartup------
load------
domContentLoaded------
domInteractive------
firstPaint------
backgroundConnect------
firstReactRender------
getState------
initialActions------
loadScripts------
setupStore------
WebpackPower User HomeuiStartup------
load------
domContentLoaded------
domInteractive------
firstPaint------
backgroundConnect------
firstReactRender------
getState------
initialActions------
loadScripts------
setupStore------
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -1.16 KiB (-0.03%)
  • ui: 661 Bytes (0.01%)
  • common: -15.06 KiB (-0.18%)

@bergarces bergarces force-pushed the account-tracker-controller-migration branch from 73b667c to 2df6aa5 Compare October 21, 2025 14:00
@bergarces bergarces requested a review from a team as a code owner October 21, 2025 14:11
@metamaskbot
Copy link
Collaborator

📊 Page Load Benchmark Results

Current Commit: 6047fba | Date: 10/21/2025

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.04s (±73ms) 🟡 | historical mean value: 1.06s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 729ms (±70ms) 🟢 | historical mean value: 741ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 75ms (±16ms) 🟢 | historical mean value: 77ms ⬇️ (historical data)
📈 Detailed Results
Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.04s 73ms 1.00s 1.35s 1.26s 1.35s
domContentLoaded 729ms 70ms 691ms 1.02s 932ms 1.02s
firstPaint 75ms 16ms 56ms 228ms 84ms 228ms
firstContentfulPaint 75ms 16ms 56ms 228ms 84ms 228ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms

Results generated automatically by MetaMask CI

@metamaskbot
Copy link
Collaborator

Builds ready [6047fba]
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -1.12 KiB (-0.02%)
  • ui: 1.16 KiB (0.02%)
  • common: -15.07 KiB (-0.18%)

bergarces added a commit to MetaMask/core that referenced this pull request Oct 21, 2025
## Explanation

<!--
Thanks for your contribution! Take a moment to answer these questions so
that reviewers have the information they need to properly understand
your changes:

* What is the current state of things and why does it need to change?
* What is the solution your changes offer and how does it work?
* Are there any changes whose purpose might not obvious to those
unfamiliar with the domain?
* If your primary goal was to update one package but you found you had
to update another one along the way, why did you do so?
* If you had to upgrade a dependency, why did you do so?
-->

Adds single address balance refresh based on transaction events to make
up for removing them on extension client side during migration.

Previews:
MetaMask/metamask-extension#36808
MetaMask/metamask-mobile#21465

## References

<!--
Are there any issues that this pull request is tied to?
Are there other links that reviewers should consult to understand these
changes better?
Are there client or consumer pull requests to adopt any breaking
changes?

For example:

* Fixes #12345
* Related to #67890
-->

* Related to https://consensyssoftware.atlassian.net/browse/ASSETS-1368

## Checklist

- [X] I've updated the test suite for new or updated code as appropriate
- [X] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [X] I've communicated my changes to consumers by [updating changelogs
for packages I've
changed](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs),
highlighting breaking changes as necessary
- [X] I've prepared draft pull requests for clients and consumer
packages to resolve any breaking changes


<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> AccountTrackerController now listens to transaction events to refresh
the originating address balance, with internal refresh refactor, tests,
and changelog updates.
> 
> - **AccountTrackerController**:
> - **New listeners**: Subscribes to
`TransactionController:unapprovedTransactionAdded` and
`TransactionController:transactionConfirmed` to refresh the
`txParams.from` address balance.
> - **Refactor**: Extracts `#refreshAccounts` and `#refreshAddress`;
`refresh` delegates to these helpers.
> - **Types/Events**: Extends `AllowedEvents` to include the above
transaction events; imports `TransactionStatus`/`TransactionMeta`.
> - **Tests**:
> - Add cases ensuring balances refresh on unapproved and confirmed
transaction events.
> - Expand test messenger `allowedEvents`; expose `messenger` from test
harness.
> - **Changelog**:
> - Notes BREAKING requirement to allow new transaction events in the
controller messenger.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
8504447. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
@metamaskbot
Copy link
Collaborator

📊 Page Load Benchmark Results

Current Commit: fd8906f | Date: 10/21/2025

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.04s (±74ms) 🟡 | historical mean value: 1.05s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 732ms (±72ms) 🟢 | historical mean value: 739ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 76ms (±16ms) 🟢 | historical mean value: 77ms ⬇️ (historical data)
📈 Detailed Results
Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.04s 74ms 1.00s 1.34s 1.28s 1.34s
domContentLoaded 732ms 72ms 695ms 1.01s 960ms 1.01s
firstPaint 76ms 16ms 56ms 212ms 84ms 212ms
firstContentfulPaint 76ms 16ms 56ms 212ms 84ms 212ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms

Results generated automatically by MetaMask CI

@metamaskbot
Copy link
Collaborator

Builds ready [fd8906f]
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -688 Bytes (-0.01%)
  • ui: 1.41 KiB (0.02%)
  • common: -8.96 KiB (-0.11%)

@bergarces bergarces requested a review from a team as a code owner October 21, 2025 20:11
cursor[bot]

This comment was marked as outdated.

@bergarces bergarces mentioned this pull request Oct 21, 2025
4 tasks
@metamaskbot
Copy link
Collaborator

📊 Page Load Benchmark Results

Current Commit: b96ae8e | Date: 10/21/2025

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.03s (±69ms) 🟡 | historical mean value: 1.05s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 725ms (±67ms) 🟢 | historical mean value: 738ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 75ms (±11ms) 🟢 | historical mean value: 77ms ⬇️ (historical data)
📈 Detailed Results
Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.03s 69ms 1.00s 1.30s 1.26s 1.30s
domContentLoaded 725ms 67ms 694ms 986ms 937ms 986ms
firstPaint 75ms 11ms 56ms 160ms 88ms 160ms
firstContentfulPaint 75ms 11ms 56ms 160ms 88ms 160ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms

Results generated automatically by MetaMask CI

@metamaskbot
Copy link
Collaborator

Builds ready [b96ae8e]
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -1.13 KiB (-0.02%)
  • ui: 641 Bytes (0.01%)
  • common: -15.08 KiB (-0.17%)

bergarces added a commit to MetaMask/core that referenced this pull request Oct 21, 2025
## Explanation

<!--
Thanks for your contribution! Take a moment to answer these questions so
that reviewers have the information they need to properly understand
your changes:

* What is the current state of things and why does it need to change?
* What is the solution your changes offer and how does it work?
* Are there any changes whose purpose might not obvious to those
unfamiliar with the domain?
* If your primary goal was to update one package but you found you had
to update another one along the way, why did you do so?
* If you had to upgrade a dependency, why did you do so?
-->

Assets controller major release.

Preview PRs:
MetaMask/metamask-mobile#21465
MetaMask/metamask-extension#36808

## References

<!--
Are there any issues that this pull request is tied to?
Are there other links that reviewers should consult to understand these
changes better?
Are there client or consumer pull requests to adopt any breaking
changes?

For example:

* Fixes #12345
* Related to #67890
-->

## Checklist

- [ ] I've updated the test suite for new or updated code as appropriate
- [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [ ] I've communicated my changes to consumers by [updating changelogs
for packages I've
changed](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs),
highlighting breaking changes as necessary
- [ ] I've prepared draft pull requests for clients and consumer
packages to resolve any breaking changes


<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Releases core 632 with @metamask/assets-controllers v82 (breaking
event listeners, multicall additions, Snap request batching) and aligns
bridge packages with breaking peer bumps.
> 
> - **Packages**:
>   - `@metamask/[email protected]`:
> - **BREAKING:** Add balance refresh listeners for
`TransactionControllerUnapprovedTransactionAddedEvent` and
`TransactionControllerTransactionConfirmedEvent`.
> - Add multicall addresses for additional chains; batch
`OnAssetConversion` and `OnAssetsMarketData` requests to non‑EVM Snaps.
>   - `@metamask/[email protected]`:
> - **BREAKING:** Bump peer `@metamask/assets-controllers` to `^82.0.0`.
>   - `@metamask/[email protected]`:
> - **BREAKING:** Bump peer `@metamask/bridge-controller` to `^54.0.0`.
> - **Repo**: Bump monorepo version to `632.0.0` and update lockfile.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
45f4843. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
@metamaskbot
Copy link
Collaborator

📊 Page Load Benchmark Results

Current Commit: 105d8af | Date: 10/21/2025

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.01s (±75ms) 🟡 | historical mean value: 1.05s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 703ms (±85ms) 🟢 | historical mean value: 739ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 88ms (±124ms) 🟢 | historical mean value: 77ms ⬆️ (historical data)
📈 Detailed Results
Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.01s 75ms 965ms 1.36s 1.24s 1.36s
domContentLoaded 703ms 85ms 664ms 1.26s 921ms 1.26s
firstPaint 88ms 124ms 64ms 1.32s 88ms 1.32s
firstContentfulPaint 88ms 124ms 64ms 1.32s 88ms 1.32s
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms

Results generated automatically by MetaMask CI

@metamaskbot
Copy link
Collaborator

Builds ready [105d8af]
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -1.13 KiB (-0.02%)
  • ui: 641 Bytes (0.01%)
  • common: -15.08 KiB (-0.17%)

@metamaskbot
Copy link
Collaborator

📊 Page Load Benchmark Results

Current Commit: 3fbd97d | Date: 10/21/2025

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.05s (±72ms) 🟡 | historical mean value: 1.05s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 735ms (±69ms) 🟢 | historical mean value: 739ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 76ms (±12ms) 🟢 | historical mean value: 77ms ⬇️ (historical data)
📈 Detailed Results
Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.05s 72ms 1.01s 1.35s 1.25s 1.35s
domContentLoaded 735ms 69ms 697ms 1.01s 930ms 1.01s
firstPaint 76ms 12ms 60ms 168ms 92ms 168ms
firstContentfulPaint 76ms 12ms 60ms 168ms 92ms 168ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms

Results generated automatically by MetaMask CI

@metamaskbot
Copy link
Collaborator

Builds ready [3fbd97d]
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -882 Bytes (-0.02%)
  • ui: 641 Bytes (0.01%)
  • common: -15.08 KiB (-0.17%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants