-
-
Notifications
You must be signed in to change notification settings - Fork 258
feat(account-tree-controller): use multichain-account-service to build multichain account wallet/group nodes
#6646
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
@metamaskbot publish-preview |
|
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. |
…for bip-44 accounts
4390b9d to
c5de1f5
Compare
|
@metamaskbot publish-preview |
|
@metamaskbot publish-preview |
|
@metamaskbot publish-preview |
|
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. |
|
@metamaskbot publish-preview |
|
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. |
| }, | ||
| ); | ||
|
|
||
| this.messenger.subscribe( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if these 2 new handlers fire before the initialization completes?
Should we add a guard before each like if (!this.#initialized) return; ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a very good point, and IMO that make sense to add this !this.initialized check! I'll do this, thanks
| 'UserStorageController:performBatchSetStorage', | ||
| 'AuthenticationController:getSessionProfile', | ||
| 'MultichainAccountService:createMultichainAccountGroup', | ||
| 'MultichainAccountService:getMultichainAccountWallets', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we need to mock that action handler too in the test setup?
messenger.registerActionHandler(
'MultichainAccountService:getMultichainAccountWallets',
jest.fn().mockReturnValue([]),
);
fabiobozzo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM ✨
Finally, great separation of concerns, as you anticipated me long ago! Much cleaner than it was
|
@metamaskbot publish-previews |
|
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. |
Explanation
The
multichain-account-serviceis responsible of holding/grouping all BIP-44 accounts together (in wallets and groups).The
account-tree-controllerwas re-using a similar matching logic to build it's tree and match those wallets and groups. But... In reality, this is the responsibility of the service and thus, the controller should "consume" the wallets/groups from the service directly.Architecture wise, this is more correct, and other kind of wallets could follow the same pattern (having 1 wallet for each keyring types and 1 wallet for each other kind of account management Snaps).
References
N/A
Checklist
Note
Switches multichain (BIP-44) wallet/group construction to MultichainAccountService, listening to its events and skipping BIP-44 in AccountsController event handling.
MultichainAccountService:getMultichainAccountWalletsto buildAccountWalletType.Entropywallets andMultichainAccountgroups; remove entropy matching from controller.MultichainAccountService:{multichainAccountGroupCreated,multichainAccountGroupUpdated,walletStatusChange}to insert/update groups and wallet status post-init.AccountsController:account{Added,Removed}; only process non-BIP-44 (Snap/Keyring) accounts.getEntropyDefaultAccountWalletNameandgetEntropyDefaultAccountGroupPrefix; keep computed group names with EVM priority and conflict resolution.EntropyRuleclass with pure helpers:getEntropyDefaultAccountWalletName,getEntropyComputedAccountGroupName,getEntropyDefaultAccountGroupPrefix.MultichainAccountService.Written by Cursor Bugbot for commit 88cb1ba. This will update automatically on new commits. Configure here.