Repository navigation
feat(assets): construct AssetsController via @metamask/wallet - #47269
dawnseeker8 wants to merge 10 commits into
Conversation
Use the opt-in wallet assetsController init/getMessenger helpers while keeping messenger-client-init ordering after NetworkEnablementController. Co-authored-by: Cursor <cursoragent@cursor.com>
|
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/core-platform (1 files, +21 -7)
👨🔧 @MetaMask/extension-platform (1 files, +21 -7)
💎 @MetaMask/metamask-assets (5 files, +0 -585)
📜 @MetaMask/policy-reviewers (8 files, +296 -40)
Tip Follow the policy review process outlined in the LavaMoat Policy Review Process doc before expecting an approval from Policy Reviewers. |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
Builds ready [005f385]
⚡ Performance Benchmarks (Total: 🟢 6 pass · 🟡 5 warn · 🔴 2 fail)
Bundle Size Diffs [🚨 Warning! Bundle size has increased!]
|
Point the wallet preview at 20.0.0-preview-bbbbbb9f2 so AssetsController init stays available on wallet 20, and keep NetworkEnablementController on the extension init path. Co-authored-by: Cursor <cursoragent@cursor.com>
Builds ready [bd0e3c5]
⚡ Performance Benchmarks (Total: 🟢 6 pass · 🟡 4 warn · 🔴 3 fail)
Bundle Size Diffs [🚨 Warning! Bundle size has increased!]
|
The wallet preview now owns both controllers, so the extension no longer builds a second copy in messenger-client-init. Co-authored-by: Cursor <cursoragent@cursor.com>
…r-wallet-hybrid-init Keep the assets-controller 20.0.2 preview pin and wallet preview while taking main's bridge-controller and transaction-pay-controller bumps. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 4c7137e. Configure here.
| assetsController: getAssetsControllerInstanceOptions({ | ||
| getIsUiOpen: () => | ||
| walletRef.current?.getInstance('ClientController').state.isUiOpen ?? | ||
| false, |
There was a problem hiding this comment.
UI-open fallback throws instead
Medium Severity
getIsUiOpen uses walletRef.current?.getInstance('ClientController').state.isUiOpen, so optional chaining stops at getInstance. When walletRef.current is unset, that expression becomes a property read on undefined and throws before ?? false can apply. isEnabled is built during new Wallet(), so a constructor-time call crashes instead of treating the UI as closed.
Reviewed by Cursor Bugbot for commit 4c7137e. Configure here.
The published preview is 20.0.1, so the assets-controller range has to match that preview. Co-authored-by: Cursor <cursoragent@cursor.com>
Builds ready [7e5f627]
⚡ Performance Benchmarks (Total: 🟢 9 pass · 🟡 2 warn · 🔴 1 fail)
Bundle Size Diffs [🚨 Warning! Bundle size has increased!]
|
Prithpal-Sooriya
left a comment
There was a problem hiding this comment.
Policy changes look good. So are the network enablement controller and asset controller changes (awesome to see these in the wallet package!)
Builds ready [5d2871a]
⚡ Performance Benchmarks (Total: 🟢 9 pass · 🟡 2 warn · 🔴 1 fail)
Bundle Size Diffs [🚨 Warning! Bundle size has increased!]
|
Pin @metamask/assets-controller and @metamask/wallet to the fbb37663c preview builds so the wallet hybrid init can be tested against the latest core preview. Co-authored-by: Cursor <cursoragent@cursor.com>
Builds ready [2680302]
⚡ Performance Benchmarks (Total: 🟢 11 pass · 🟡 0 warn · 🔴 0 fail)
Bundle Size Diffs [🚨 Warning! Bundle size has increased!]
|
- Bump @metamask/wallet and @metamask/assets-controller previews to 713f7d759 - Bump @metamask/core-backend to ^13.0.0 to match assets-controller - Drop the AssetsController opt-in from Wallet initialization - Call AssetsController.start() after SnapController is initialized - Update LavaMoat policies Co-authored-by: Cursor <cursoragent@cursor.com>
Builds ready [53cdd0d]
⚡ Performance Benchmarks (Total: 🟢 8 pass · 🟡 3 warn · 🔴 2 fail)
Bundle Size Diffs [🚨 Warning! Bundle size has increased!]
|
The wallet now constructs NetworkEnablementController, so remove the messenger-client init entry and call setupNetworkEnablementController from MetamaskController before AssetsController.start(). Co-authored-by: Cursor <cursoragent@cursor.com>
Builds ready [182137b]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 4 warn · 🔴 2 fail)
Bundle Size Diffs [🚨 Warning! Bundle size has increased!]
|
|





Description
Context
@metamask/walletPR #10885 adds an opt-inassetsControllerinitialization configuration. The extension still cannot register AssetsController insidenew Wallet()because that runs beforeNetworkEnablementController, and AssetsController readsNetworkEnablementController:getStatein its constructor.Problem
AssetsController was constructed directly with
new AssetsController(...)from@metamask/assets-controllerin messenger-client-init, instead of going through the shared wallet initialization helpers that own messenger delegation and option validation (queryApiClientrequired).Solution
Hybrid adoption of the wallet API:
@metamask/walletto preview18.0.1-preview-55fcf3ef7viapreviewBuilds.wallet-init/instance-options/assets-controller.ts.assetsController.init(...)from messenger-client-init (keeps late init order after NetworkEnablementController).getAssetsControllerMessengertoassetsController.getMessenger; keep the extension init messenger for auth/preferences/onboarding.AssetsController remains on
messengerClientsByName/this.assetsController(notwallet.getInstance('AssetsController')).Changelog
CHANGELOG entry: null
Related issues
Related: ASSETS-3641, MetaMask/core#10885
Manual testing steps
yarn start).Pre-merge author checklist
Pre-merge reviewer checklist
Made with Cursor
Note
Medium Risk
Changes startup ownership and persistence boundaries for network enablement and asset loading, but largely relocates existing logic rather than introducing new product behavior.
Reviewed by Cursor Bugbot for commit 4c7137e. Bugbot is set up for automated code reviews on this repo. Configure here.