-
-
Notifications
You must be signed in to change notification settings - Fork 275
feat!: Expose Accounts-owned controller/service methods through messenger #7976
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
Merged
+1,191
−724
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
d47974c
migrate `AccountsController` to use `registerMethodActionHandlers`
GuillaumeRx 30c0ddd
migrate `MultichainAccountService` to use `registerMethodActionHandlers`
GuillaumeRx 973c84f
migrate `AccountTreeController`, `AuthenticationController` and `User…
GuillaumeRx 6145994
fix action name
GuillaumeRx 19538b2
use `generate-method-action-types` in `account-tree-controller`
GuillaumeRx b1a94d3
use `generate-method-action-types` in `accounts-controller`
GuillaumeRx 2f75dca
use `generate-method-action-types` in `multichain-account-service`
GuillaumeRx e0c14b7
use `generate-method-action-types` in `profile-sync-controller`
GuillaumeRx bb9f0fd
revert typo
GuillaumeRx d746685
fix import
GuillaumeRx 1c14840
fix action name usage
GuillaumeRx beadfa9
fix lint and exports
GuillaumeRx 7596219
use type only imports
GuillaumeRx 8601993
fix `account-tree-controller` type imports
GuillaumeRx a44156c
fix lint, rename actions in other controllers
GuillaumeRx f4be972
fill coverage in `AccountsController`
GuillaumeRx 82db2cb
update CHANGELOGs
GuillaumeRx 8d63c02
fix `eslint-suppressions.json` lint
GuillaumeRx dda2768
fix `claims-controller` changelog
GuillaumeRx f6875a0
fix `multichain-account-service` tests
GuillaumeRx 1de02f4
remove direct call to method in test
GuillaumeRx 0731bd4
Address requested changes
GuillaumeRx f05f301
fix `multichain-account-service` CHANGELOG
GuillaumeRx 6a0f46a
fix CHANGELOGs and package.json after rebase
GuillaumeRx 73143ae
fix action types after rebase
GuillaumeRx 603df23
re-add comment
GuillaumeRx 5705479
fix CHANGELOG
GuillaumeRx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
196 changes: 196 additions & 0 deletions
196
packages/account-tree-controller/src/AccountTreeController-method-action-types.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,196 @@ | ||
| /** | ||
| * This file is auto generated by `scripts/generate-method-action-types.ts`. | ||
| * Do not edit manually. | ||
| */ | ||
|
|
||
| import type { AccountTreeController } from './AccountTreeController'; | ||
|
|
||
| /** | ||
| * Gets the account wallet object from its ID. | ||
| * | ||
| * @param walletId - Account wallet ID. | ||
| * @returns The account wallet object if found, undefined otherwise. | ||
| */ | ||
| export type AccountTreeControllerGetAccountWalletObjectAction = { | ||
| type: `AccountTreeController:getAccountWalletObject`; | ||
| handler: AccountTreeController['getAccountWalletObject']; | ||
| }; | ||
|
|
||
| /** | ||
| * Gets all account wallet objects. | ||
| * | ||
| * @returns All account wallet objects. | ||
| */ | ||
| export type AccountTreeControllerGetAccountWalletObjectsAction = { | ||
| type: `AccountTreeController:getAccountWalletObjects`; | ||
| handler: AccountTreeController['getAccountWalletObjects']; | ||
| }; | ||
|
|
||
| /** | ||
| * Gets all underlying accounts from the currently selected account | ||
| * group. | ||
| * | ||
| * It also support account selector, which allows to filter specific | ||
| * accounts given some criterias (account type, address, scopes, etc...). | ||
| * | ||
| * @param selector - Optional account selector. | ||
| * @returns Underlying accounts for the currently selected account (filtered | ||
| * by the selector if provided). | ||
| */ | ||
| export type AccountTreeControllerGetAccountsFromSelectedAccountGroupAction = { | ||
| type: `AccountTreeController:getAccountsFromSelectedAccountGroup`; | ||
| handler: AccountTreeController['getAccountsFromSelectedAccountGroup']; | ||
| }; | ||
|
|
||
| /** | ||
| * Gets the account group object from its ID. | ||
| * | ||
| * @param groupId - Account group ID. | ||
| * @returns The account group object if found, undefined otherwise. | ||
| */ | ||
| export type AccountTreeControllerGetAccountGroupObjectAction = { | ||
| type: `AccountTreeController:getAccountGroupObject`; | ||
| handler: AccountTreeController['getAccountGroupObject']; | ||
| }; | ||
|
|
||
| /** | ||
| * Gets the account's context which contains its wallet ID, group ID, and sort order. | ||
| * | ||
| * @param accountId - Account ID. | ||
| * @returns The account context if found, undefined otherwise. | ||
| */ | ||
| export type AccountTreeControllerGetAccountContextAction = { | ||
| type: `AccountTreeController:getAccountContext`; | ||
| handler: AccountTreeController['getAccountContext']; | ||
| }; | ||
|
|
||
| /** | ||
| * Gets the currently selected account group ID. | ||
| * | ||
| * @returns The selected account group ID or empty string if none selected. | ||
| */ | ||
| export type AccountTreeControllerGetSelectedAccountGroupAction = { | ||
| type: `AccountTreeController:getSelectedAccountGroup`; | ||
| handler: AccountTreeController['getSelectedAccountGroup']; | ||
| }; | ||
|
|
||
| /** | ||
| * Sets the selected account group and updates the AccountsController selectedAccount accordingly. | ||
| * | ||
| * @param groupId - The account group ID to select. | ||
| */ | ||
| export type AccountTreeControllerSetSelectedAccountGroupAction = { | ||
| type: `AccountTreeController:setSelectedAccountGroup`; | ||
| handler: AccountTreeController['setSelectedAccountGroup']; | ||
| }; | ||
|
|
||
| /** | ||
| * Sets a custom name for an account group. | ||
| * | ||
| * @param groupId - The account group ID. | ||
| * @param name - The custom name to set. | ||
| * @param autoHandleConflict - If true, automatically resolves name conflicts by adding a suffix. If false, throws on conflicts. | ||
| * @throws If the account group ID is not found in the current tree. | ||
| * @throws If the account group name already exists and autoHandleConflict is false. | ||
| */ | ||
| export type AccountTreeControllerSetAccountGroupNameAction = { | ||
| type: `AccountTreeController:setAccountGroupName`; | ||
| handler: AccountTreeController['setAccountGroupName']; | ||
| }; | ||
|
|
||
| /** | ||
| * Sets a custom name for an account wallet. | ||
| * | ||
| * @param walletId - The account wallet ID. | ||
| * @param name - The custom name to set. | ||
| * @throws If the account wallet ID is not found in the current tree. | ||
| */ | ||
| export type AccountTreeControllerSetAccountWalletNameAction = { | ||
| type: `AccountTreeController:setAccountWalletName`; | ||
| handler: AccountTreeController['setAccountWalletName']; | ||
| }; | ||
|
|
||
| /** | ||
| * Toggles the pinned state of an account group. | ||
| * | ||
| * @param groupId - The account group ID. | ||
| * @param pinned - Whether the group should be pinned. | ||
| * @throws If the account group ID is not found in the current tree. | ||
| */ | ||
| export type AccountTreeControllerSetAccountGroupPinnedAction = { | ||
| type: `AccountTreeController:setAccountGroupPinned`; | ||
| handler: AccountTreeController['setAccountGroupPinned']; | ||
| }; | ||
|
|
||
| /** | ||
| * Toggles the hidden state of an account group. | ||
| * | ||
| * @param groupId - The account group ID. | ||
| * @param hidden - Whether the group should be hidden. | ||
| * @throws If the account group ID is not found in the current tree. | ||
| */ | ||
| export type AccountTreeControllerSetAccountGroupHiddenAction = { | ||
| type: `AccountTreeController:setAccountGroupHidden`; | ||
| handler: AccountTreeController['setAccountGroupHidden']; | ||
| }; | ||
|
|
||
| /** | ||
| * Clears the controller state and resets to default values. | ||
| * Also clears the backup and sync service state. | ||
| */ | ||
| export type AccountTreeControllerClearStateAction = { | ||
| type: `AccountTreeController:clearState`; | ||
| handler: AccountTreeController['clearState']; | ||
| }; | ||
|
|
||
| /** | ||
| * Bi-directionally syncs the account tree with user storage. | ||
| * This will perform a full sync, including both pulling updates | ||
| * from user storage and pushing local changes to user storage. | ||
| * This also performs legacy account syncing if needed. | ||
| * | ||
| * IMPORTANT: | ||
| * If a full sync is already in progress, it will return the ongoing promise. | ||
| * | ||
| * @returns A promise that resolves when the sync is complete. | ||
| */ | ||
| export type AccountTreeControllerSyncWithUserStorageAction = { | ||
| type: `AccountTreeController:syncWithUserStorage`; | ||
| handler: AccountTreeController['syncWithUserStorage']; | ||
| }; | ||
|
|
||
| /** | ||
| * Bi-directionally syncs the account tree with user storage. | ||
| * This will ensure at least one full sync is ran, including both pulling updates | ||
| * from user storage and pushing local changes to user storage. | ||
| * This also performs legacy account syncing if needed. | ||
| * | ||
| * IMPORTANT: | ||
| * If the first ever full sync is already in progress, it will return the ongoing promise. | ||
| * If the first ever full sync was previously completed, it will NOT start a new sync, and will resolve immediately. | ||
| * | ||
| * @returns A promise that resolves when the first ever full sync is complete. | ||
| */ | ||
| export type AccountTreeControllerSyncWithUserStorageAtLeastOnceAction = { | ||
| type: `AccountTreeController:syncWithUserStorageAtLeastOnce`; | ||
| handler: AccountTreeController['syncWithUserStorageAtLeastOnce']; | ||
| }; | ||
|
|
||
| /** | ||
| * Union of all AccountTreeController action types. | ||
| */ | ||
| export type AccountTreeControllerMethodActions = | ||
| | AccountTreeControllerGetAccountWalletObjectAction | ||
| | AccountTreeControllerGetAccountWalletObjectsAction | ||
| | AccountTreeControllerGetAccountsFromSelectedAccountGroupAction | ||
| | AccountTreeControllerGetAccountGroupObjectAction | ||
| | AccountTreeControllerGetAccountContextAction | ||
| | AccountTreeControllerGetSelectedAccountGroupAction | ||
| | AccountTreeControllerSetSelectedAccountGroupAction | ||
| | AccountTreeControllerSetAccountGroupNameAction | ||
| | AccountTreeControllerSetAccountWalletNameAction | ||
| | AccountTreeControllerSetAccountGroupPinnedAction | ||
| | AccountTreeControllerSetAccountGroupHiddenAction | ||
| | AccountTreeControllerClearStateAction | ||
| | AccountTreeControllerSyncWithUserStorageAction | ||
| | AccountTreeControllerSyncWithUserStorageAtLeastOnceAction; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4575,21 +4575,18 @@ describe('AccountTreeController', () => { | |
| }); | ||
|
|
||
| // Test suffix resolution directly using the public method | ||
| const wallet = controller.state.accountTree.wallets[walletId]; | ||
| const resolvedName = controller.resolveNameConflict( | ||
| wallet, | ||
| groupId, | ||
| 'Suffix Test', | ||
| ); | ||
| expect(resolvedName).toBe('Suffix Test (3)'); | ||
| controller.setAccountGroupName(groupId, 'Suffix Test', true); | ||
|
|
||
| // Test with no conflicts: should return "Unique Name (2)" | ||
| const uniqueName = controller.resolveNameConflict( | ||
| wallet, | ||
| groupId, | ||
| 'Unique Name', | ||
| ); | ||
| expect(uniqueName).toBe('Unique Name (2)'); | ||
| const collidingGroupObject = controller.getAccountGroupObject(groupId); | ||
|
|
||
| expect(collidingGroupObject?.metadata.name).toBe('Suffix Test (3)'); | ||
|
|
||
| // Test with no conflicts: should return "Unique Name" | ||
| controller.setAccountGroupName(groupId, 'Unique Name', true); | ||
|
|
||
| const uniqueGroupObject = controller.getAccountGroupObject(groupId); | ||
|
|
||
| expect(uniqueGroupObject?.metadata.name).toBe('Unique Name'); | ||
|
Comment on lines
+4578
to
+4589
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This assertion was very misleading by the way. If there's no conflict the method shouldn't be called therefore no suffix should be added. |
||
| }); | ||
|
|
||
| it('throws error when group ID not found in tree', () => { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
resolveNameConflictis only internally used. It doesn't make sense to have it publicly only to test its behavior in unit tests. We can do that via the public methods that uses itThere 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.
I can confirm this is not used in either extension and mobile.