@metamask-previews/account-tree-controller 4.0.0-preview-d01b2f93d → 4.1.0-preview-cbcea9611

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [4.1.0]
11
+
10
12
  ### Added
11
13
 
12
14
  - Add `getAccountContext` method and `AccountTreeController:getAccountContext` action ([#7741](https://github.com/MetaMask/core/pull/7741))
@@ -17,11 +19,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
17
19
  - Bump `@metamask/snaps-sdk` from `^9.0.0` to `^10.3.0` ([#7550](https://github.com/MetaMask/core/pull/7550))
18
20
  - Bump `@metamask/snaps-utils` from `^11.0.0` to `^11.7.0` ([#7550](https://github.com/MetaMask/core/pull/7550))
19
21
  - Upgrade `@metamask/utils` from `^11.8.1` to `^11.9.0` ([#7511](https://github.com/MetaMask/core/pull/7511))
20
- - Move peer dependencies for controller and service packages to direct dependencies ([#7209](https://github.com/MetaMask/core/pull/7209), [#7437](https://github.com/MetaMask/core/pull/7437), [#7515](https://github.com/MetaMask/core/pull/7515), [#7594](https://github.com/MetaMask/core/pull/7594), [#7550](https://github.com/MetaMask/core/pull/7550), [#7604](https://github.com/MetaMask/core/pull/7604), [#7642](https://github.com/MetaMask/core/pull/7642), [#7678](https://github.com/MetaMask/core/pull/7678), [#7713](https://github.com/MetaMask/core/pull/7713), [#7849](https://github.com/MetaMask/core/pull/7849))
22
+ - Move peer dependencies for controller and service packages to direct dependencies ([#7209](https://github.com/MetaMask/core/pull/7209), [#7437](https://github.com/MetaMask/core/pull/7437), [#7515](https://github.com/MetaMask/core/pull/7515), [#7594](https://github.com/MetaMask/core/pull/7594), [#7550](https://github.com/MetaMask/core/pull/7550), [#7604](https://github.com/MetaMask/core/pull/7604), [#7642](https://github.com/MetaMask/core/pull/7642), [#7678](https://github.com/MetaMask/core/pull/7678), [#7713](https://github.com/MetaMask/core/pull/7713), [#7849](https://github.com/MetaMask/core/pull/7849)), ([#7869](https://github.com/MetaMask/core/pull/7869))
21
23
  - The dependencies moved are:
22
24
  - `@metamask/accounts-controller` (^35.0.2)
23
25
  - `@metamask/keyring-controller` (^25.1.0)
24
- - `@metamask/multichain-account-service` (^5.1.0)
26
+ - `@metamask/multichain-account-service` (^6.0.0)
25
27
  - `@metamask/profile-sync-controller` (^27.1.0)
26
28
  - `@metamask/snaps-controllers` (^17.2.0)
27
29
  - In clients, it is now possible for multiple versions of these packages to exist in the dependency tree.
@@ -429,7 +431,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
429
431
  - Initial release ([#5847](https://github.com/MetaMask/core/pull/5847))
430
432
  - Grouping accounts into 3 main categories: Entropy source, Snap ID, keyring types.
431
433
 
432
- [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/account-tree-controller@4.0.0...HEAD
434
+ [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/account-tree-controller@4.1.0...HEAD
435
+ [4.1.0]: https://github.com/MetaMask/core/compare/@metamask/account-tree-controller@4.0.0...@metamask/account-tree-controller@4.1.0
433
436
  [4.0.0]: https://github.com/MetaMask/core/compare/@metamask/account-tree-controller@3.0.0...@metamask/account-tree-controller@4.0.0
434
437
  [3.0.0]: https://github.com/MetaMask/core/compare/@metamask/account-tree-controller@2.0.0...@metamask/account-tree-controller@3.0.0
435
438
  [2.0.0]: https://github.com/MetaMask/core/compare/@metamask/account-tree-controller@1.6.0...@metamask/account-tree-controller@2.0.0
@@ -95,6 +95,8 @@ export declare class AccountTreeController extends BaseController<typeof control
95
95
  groupIndex: number;
96
96
  } | {
97
97
  type: "private-key";
98
+ } | {
99
+ type: "custom";
98
100
  } | undefined;
99
101
  exportable?: boolean | undefined;
100
102
  };
@@ -104,23 +106,12 @@ export declare class AccountTreeController extends BaseController<typeof control
104
106
  keyring: {
105
107
  type: string;
106
108
  };
107
- nameLastUpdatedAt?: number | undefined;
108
109
  snap?: {
109
110
  name: string;
110
- id: string; /**
111
- * Helper method to prune a group if it holds no accounts and additionally
112
- * prune the wallet if it holds no groups. This action should take place
113
- * after a singular account removal.
114
- *
115
- * NOTE: This method should only be used for a group that we know to be empty.
116
- *
117
- * @param state - The AccountTreeController state to prune.
118
- * @param walletId - The wallet ID to prune, the wallet should be the parent of the associated group that holds the removed account.
119
- * @param groupId - The group ID to prune, the group should be the parent of the associated account that was removed.
120
- * @returns The updated state.
121
- */
111
+ id: string;
122
112
  enabled: boolean;
123
113
  } | undefined;
114
+ nameLastUpdatedAt?: number | undefined;
124
115
  lastSelected?: number | undefined;
125
116
  };
126
117
  address: string;
@@ -1 +1 @@
1
- {"version":3,"file":"AccountTreeController.d.cts","sourceRoot":"","sources":["../src/AccountTreeController.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EACf,eAAe,EAGhB,8BAA8B;AAE/B,OAAO,KAAK,EAAE,SAAS,EAAE,sCAAsC;AAE/D,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAG3D,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAUtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,oBAAgB;AACvE,OAAO,EACL,0BAA0B,EAI3B,oBAAgB;AAMjB,OAAO,KAAK,EACV,2BAA2B,EAE3B,8BAA8B,EAC9B,0BAA0B,EAC3B,oBAAgB;AACjB,OAAO,KAAK,EAAE,mBAAmB,EAAyB,qBAAiB;AAE3E,eAAO,MAAM,cAAc,0BAA0B,CAAC;AAoCtD;;;;GAIG;AACH,wBAAgB,oCAAoC,IAAI,0BAA0B,CAWjF;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B;;OAEG;IACH,QAAQ,EAAE,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAEpC;;OAEG;IACH,OAAO,EAAE,k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AAO,EAAE,cAAc,EACvB,IAAI,EAAE,MAAM,EACZ,kBAAkB,GAAE,OAAe,GAClC,IAAI;IAgDP;;;;;;OAMG;IACH,oBAAoB,CAAC,QAAQ,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAyBnE;;;;;;OAMG;IACH,qBAAqB,CAAC,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI;IAmCrE;;;;;;OAMG;IACH,qBAAqB,CAAC,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI;IAmCrE;;;OAGG;IACH,UAAU,IAAI,IAAI;IA2DlB;;;;;;;;;;OAUG;IACG,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAI1C;;;;;;;;;;;OAWG;IACG,8BAA8B,IAAI,OAAO,CAAC,IAAI,CAAC;CAoBtD"}
@@ -95,6 +95,8 @@ export declare class AccountTreeController extends BaseController<typeof control
95
95
  groupIndex: number;
96
96
  } | {
97
97
  type: "private-key";
98
+ } | {
99
+ type: "custom";
98
100
  } | undefined;
99
101
  exportable?: boolean | undefined;
100
102
  };
@@ -104,23 +106,12 @@ export declare class AccountTreeController extends BaseController<typeof control
104
106
  keyring: {
105
107
  type: string;
106
108
  };
107
- nameLastUpdatedAt?: number | undefined;
108
109
  snap?: {
109
110
  name: string;
110
- id: string; /**
111
- * Helper method to prune a group if it holds no accounts and additionally
112
- * prune the wallet if it holds no groups. This action should take place
113
- * after a singular account removal.
114
- *
115
- * NOTE: This method should only be used for a group that we know to be empty.
116
- *
117
- * @param state - The AccountTreeController state to prune.
118
- * @param walletId - The wallet ID to prune, the wallet should be the parent of the associated group that holds the removed account.
119
- * @param groupId - The group ID to prune, the group should be the parent of the associated account that was removed.
120
- * @returns The updated state.
121
- */
111
+ id: string;
122
112
  enabled: boolean;
123
113
  } | undefined;
114
+ nameLastUpdatedAt?: number | undefined;
124
115
  lastSelected?: number | undefined;
125
116
  };
126
117
  address: string;
@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C;;;;;;;;;;;OAWG;IACG,8BAA8B,IAAI,OAAO,CAAC,IAAI,CAAC;CAoBtD"}
@@ -24,7 +24,7 @@ exports.getLocalEntropyWallets = getLocalEntropyWallets;
24
24
  const getLocalGroupForEntropyWallet = (context, entropySourceId, groupIndex) => {
25
25
  const walletId = (0, account_api_1.toMultichainAccountWalletId)(entropySourceId);
26
26
  const wallet = context.controller.state.accountTree.wallets[walletId];
27
- if (!wallet || wallet.type !== account_api_1.AccountWalletType.Entropy) {
27
+ if (wallet?.type !== account_api_1.AccountWalletType.Entropy) {
28
28
  (0, logger_1.backupAndSyncLogger)(`Wallet ${walletId} not found or is not an entropy wallet`);
29
29
  return undefined;
30
30
  }
@@ -41,7 +41,7 @@ exports.getLocalGroupForEntropyWallet = getLocalGroupForEntropyWallet;
41
41
  */
42
42
  function getLocalGroupsForEntropyWallet(context, walletId) {
43
43
  const wallet = context.controller.state.accountTree.wallets[walletId];
44
- if (!wallet || wallet.type !== account_api_1.AccountWalletType.Entropy) {
44
+ if (wallet?.type !== account_api_1.AccountWalletType.Entropy) {
45
45
  (0, logger_1.backupAndSyncLogger)(`Wallet ${walletId} not found or is not an entropy wallet`);
46
46
  return [];
47
47
  }
@@ -1 +1 @@
1
- {"version":3,"file":"controller.cjs","sourceRoot":"","sources":["../../../src/backup-and-sync/utils/controller.ts"],"names":[],"mappings":";;;AAAA,uDAI+B;AAI/B,6CAAmD;AAKnD;;;;;GAKG;AACH,SAAgB,sBAAsB,CACpC,OAA6B;IAE7B,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,MAAM,CACvE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,+BAAiB,CAAC,OAAO,CACtB,CAAC;AACpC,CAAC;AAND,wDAMC;AAED;;;;;;;GAOG;AACI,MAAM,6BAA6B,GAAG,CAC3C,OAA6B,EAC7B,eAAuB,EACvB,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IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAChE;QACD,oBAAoB,EAClB,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,WAAW,CAAC,oBAAoB;QAC3D,kBAAkB,EAAE,IAAI,CAAC,KAAK,CAC5B,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,CAC7D;KACF,CAAC;AACJ,CAAC;AAhBD,kDAgBC;AAED;;;;;;;GAOG;AACH,SAAgB,wBAAwB,CACtC,OAA6B,EAC7B,QAAuB;IAEvB,OAAO,CAAC,uBAAuB,CAAC,CAAC,KAAK,EAAE,EAAE;QACxC,KAAK,CAAC,qBAAqB,GAAG,QAAQ,CAAC,qBAAqB,CAAC;QAC7D,KAAK,CAAC,sBAAsB,GAAG,QAAQ,CAAC,sBAAsB,CAAC;QAC/D,KAAK,CAAC,WAAW,CAAC,oBAAoB,GAAG,QAAQ,CAAC,oBAAoB,CAAC;QACvE,KAAK,CAAC,WAAW,CAAC,OAAO,GAAG,QAAQ,CAAC,kBAAkB,CAAC;IAC1D,CAAC,CAAC,CAAC;IAEH,+EAA+E;IAC/E,mFAAmF;IACnF,sEAAsE;IACtE,OAAO,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;AAC5B,CAAC;AAfD,4DAeC","sourcesContent":["import {\n AccountWalletType,\n toMultichainAccountGroupId,\n toMultichainAccountWalletId,\n} from '@metamask/account-api';\nimport type { AccountWalletId } from '@metamask/account-api';\n\nimport type { AccountGroupMultichainAccountObject } from '../../group';\nimport { backupAndSyncLogger } from '../../logger';\nimport type { AccountTreeControllerState } from '../../types';\nimport type { AccountWalletEntropyObject } from '../../wallet';\nimport type { BackupAndSyncContext } from '../types';\n\n/**\n * Gets all local entropy wallets that can be synced.\n *\n * @param context - The backup and sync context.\n * @returns Array of entropy wallet objects.\n */\nexport function getLocalEntropyWallets(\n context: BackupAndSyncContext,\n): AccountWalletEntropyObject[] {\n return Object.values(context.controller.state.accountTree.wallets).filter(\n (wallet) => wallet.type === AccountWalletType.Entropy,\n ) as AccountWalletEntropyObject[];\n}\n\n/**\n * Gets the local group for a specific entropy wallet by its source ID and group index.\n *\n * @param context - The backup and sync context.\n * @param entropySourceId - The entropy source ID.\n * @param groupIndex - The group index.\n * @returns The local group object if it exists, undefined otherwise.\n */\nexport const getLocalGroupForEntropyWallet = (\n context: BackupAndSyncContext,\n entropySourceId: string,\n groupIndex: number,\n): AccountGroupMultichainAccountObject | undefined => {\n const walletId = toMultichainAccountWalletId(entropySourceId);\n const wallet = context.controller.state.accountTree.wallets[walletId];\n\n if (!wallet || wallet.type !== AccountWalletType.Entropy) {\n backupAndSyncLogger(\n `Wallet ${walletId} not found or is not an entropy wallet`,\n );\n return undefined;\n }\n\n const groupId = toMultichainAccountGroupId(walletId, groupIndex);\n\n return wallet.groups[groupId];\n};\n\n/**\n * Gets all groups for a specific entropy wallet.\n *\n * @param context - The backup and sync context.\n * @param walletId - The wallet ID to get groups for.\n * @returns Array of multichain account group objects.\n */\nexport function getLocalGroupsForEntropyWallet(\n context: BackupAndSyncContext,\n walletId: AccountWalletId,\n): AccountGroupMultichainAccountObject[] {\n const wallet = context.controller.state.accountTree.wallets[walletId];\n if (!wallet || wallet.type !== AccountWalletType.Entropy) {\n backupAndSyncLogger(\n `Wallet ${walletId} not found or is not an entropy wallet`,\n );\n return [];\n }\n\n return Object.values(wallet.groups);\n}\n\n/**\n * State snapshot type for rollback operations.\n * Captures all the state that needs to be restored in case of sync failures.\n */\nexport type StateSnapshot = {\n accountGroupsMetadata: AccountTreeControllerState['accountGroupsMetadata'];\n accountWalletsMetadata: AccountTreeControllerState['accountWalletsMetadata'];\n selectedAccountGroup: AccountTreeControllerState['accountTree']['selectedAccountGroup'];\n accountTreeWallets: AccountTreeControllerState['accountTree']['wallets'];\n};\n\n/**\n * Creates a snapshot of the current controller state for rollback purposes.\n * Captures all state including the account tree structure.\n *\n * @param context - The backup and sync context containing controller and messenger.\n * @returns A deep copy of relevant state that can be restored later.\n */\nexport function createStateSnapshot(\n context: BackupAndSyncContext,\n): StateSnapshot {\n return {\n accountGroupsMetadata: JSON.parse(\n JSON.stringify(context.controller.state.accountGroupsMetadata),\n ),\n accountWalletsMetadata: JSON.parse(\n JSON.stringify(context.controller.state.accountWalletsMetadata),\n ),\n selectedAccountGroup:\n context.controller.state.accountTree.selectedAccountGroup,\n accountTreeWallets: JSON.parse(\n JSON.stringify(context.controller.state.accountTree.wallets),\n ),\n };\n}\n\n/**\n * Restores state using an update callback.\n * Restores both persisted metadata and the complete account tree structure.\n * Uses the controller's init() method to rebuild internal maps correctly.\n *\n * @param context - The backup and sync context containing controller and messenger.\n * @param snapshot - The state snapshot to restore.\n */\nexport function restoreStateFromSnapshot(\n context: BackupAndSyncContext,\n snapshot: StateSnapshot,\n): void {\n context.controllerStateUpdateFn((state) => {\n state.accountGroupsMetadata = snapshot.accountGroupsMetadata;\n state.accountWalletsMetadata = snapshot.accountWalletsMetadata;\n state.accountTree.selectedAccountGroup = snapshot.selectedAccountGroup;\n state.accountTree.wallets = snapshot.accountTreeWallets;\n });\n\n // Use init() to rebuild the internal maps from the restored account tree state\n // This ensures that the internal maps (#accountIdToContext and #groupIdToWalletId)\n // are correctly synchronized with the restored account tree structure\n context.controller.init();\n}\n"]}
1
+ {"version":3,"file":"controller.cjs","sourceRoot":"","sources":["../../../src/backup-and-sync/utils/controller.ts"],"names":[],"mappings":";;;AAAA,uDAI+B;AAI/B,6CAAmD;AAKnD;;;;;GAKG;AACH,SAAgB,sBAAsB,CACpC,OAA6B;IAE7B,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,MAAM,CACvE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,+BAAiB,CAAC,OAAO,CACtB,CAAC;AACpC,CAA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B,CAAC,CAC/D;QACD,sBAAsB,EAAE,IAAI,CAAC,KAAK,CAChC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAChE;QACD,oBAAoB,EAClB,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,WAAW,CAAC,oBAAoB;QAC3D,kBAAkB,EAAE,IAAI,CAAC,KAAK,CAC5B,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,CAC7D;KACF,CAAC;AACJ,CAAC;AAhBD,kDAgBC;AAED;;;;;;;GAOG;AACH,SAAgB,wBAAwB,CACtC,OAA6B,EAC7B,QAAuB;IAEvB,OAAO,CAAC,uBAAuB,CAAC,CAAC,KAAK,EAAE,EAAE;QACxC,KAAK,CAAC,qBAAqB,GAAG,QAAQ,CAAC,qBAAqB,CAAC;QAC7D,KAAK,CAAC,sBAAsB,GAAG,QAAQ,CAAC,sBAAsB,CAAC;QAC/D,KAAK,CAAC,WAAW,CAAC,oBAAoB,GAAG,QAAQ,CAAC,oBAAoB,CAAC;QACvE,KAAK,CAAC,WAAW,CAAC,OAAO,GAAG,QAAQ,CAAC,kBAAkB,CAAC;IAC1D,CAAC,CAAC,CAAC;IAEH,+EAA+E;IAC/E,mFAAmF;IACnF,sEAAsE;IACtE,OAAO,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;AAC5B,CAAC;AAfD,4DAeC","sourcesContent":["import {\n AccountWalletType,\n toMultichainAccountGroupId,\n toMultichainAccountWalletId,\n} from '@metamask/account-api';\nimport type { AccountWalletId } from '@metamask/account-api';\n\nimport type { AccountGroupMultichainAccountObject } from '../../group';\nimport { backupAndSyncLogger } from '../../logger';\nimport type { AccountTreeControllerState } from '../../types';\nimport type { AccountWalletEntropyObject } from '../../wallet';\nimport type { BackupAndSyncContext } from '../types';\n\n/**\n * Gets all local entropy wallets that can be synced.\n *\n * @param context - The backup and sync context.\n * @returns Array of entropy wallet objects.\n */\nexport function getLocalEntropyWallets(\n context: BackupAndSyncContext,\n): AccountWalletEntropyObject[] {\n return Object.values(context.controller.state.accountTree.wallets).filter(\n (wallet) => wallet.type === AccountWalletType.Entropy,\n ) as AccountWalletEntropyObject[];\n}\n\n/**\n * Gets the local group for a specific entropy wallet by its source ID and group index.\n *\n * @param context - The backup and sync context.\n * @param entropySourceId - The entropy source ID.\n * @param groupIndex - The group index.\n * @returns The local group object if it exists, undefined otherwise.\n */\nexport const getLocalGroupForEntropyWallet = (\n context: BackupAndSyncContext,\n entropySourceId: string,\n groupIndex: number,\n): AccountGroupMultichainAccountObject | undefined => {\n const walletId = toMultichainAccountWalletId(entropySourceId);\n const wallet = context.controller.state.accountTree.wallets[walletId];\n\n if (wallet?.type !== AccountWalletType.Entropy) {\n backupAndSyncLogger(\n `Wallet ${walletId} not found or is not an entropy wallet`,\n );\n return undefined;\n }\n\n const groupId = toMultichainAccountGroupId(walletId, groupIndex);\n\n return wallet.groups[groupId];\n};\n\n/**\n * Gets all groups for a specific entropy wallet.\n *\n * @param context - The backup and sync context.\n * @param walletId - The wallet ID to get groups for.\n * @returns Array of multichain account group objects.\n */\nexport function getLocalGroupsForEntropyWallet(\n context: BackupAndSyncContext,\n walletId: AccountWalletId,\n): AccountGroupMultichainAccountObject[] {\n const wallet = context.controller.state.accountTree.wallets[walletId];\n if (wallet?.type !== AccountWalletType.Entropy) {\n backupAndSyncLogger(\n `Wallet ${walletId} not found or is not an entropy wallet`,\n );\n return [];\n }\n\n return Object.values(wallet.groups);\n}\n\n/**\n * State snapshot type for rollback operations.\n * Captures all the state that needs to be restored in case of sync failures.\n */\nexport type StateSnapshot = {\n accountGroupsMetadata: AccountTreeControllerState['accountGroupsMetadata'];\n accountWalletsMetadata: AccountTreeControllerState['accountWalletsMetadata'];\n selectedAccountGroup: AccountTreeControllerState['accountTree']['selectedAccountGroup'];\n accountTreeWallets: AccountTreeControllerState['accountTree']['wallets'];\n};\n\n/**\n * Creates a snapshot of the current controller state for rollback purposes.\n * Captures all state including the account tree structure.\n *\n * @param context - The backup and sync context containing controller and messenger.\n * @returns A deep copy of relevant state that can be restored later.\n */\nexport function createStateSnapshot(\n context: BackupAndSyncContext,\n): StateSnapshot {\n return {\n accountGroupsMetadata: JSON.parse(\n JSON.stringify(context.controller.state.accountGroupsMetadata),\n ),\n accountWalletsMetadata: JSON.parse(\n JSON.stringify(context.controller.state.accountWalletsMetadata),\n ),\n selectedAccountGroup:\n context.controller.state.accountTree.selectedAccountGroup,\n accountTreeWallets: JSON.parse(\n JSON.stringify(context.controller.state.accountTree.wallets),\n ),\n };\n}\n\n/**\n * Restores state using an update callback.\n * Restores both persisted metadata and the complete account tree structure.\n * Uses the controller's init() method to rebuild internal maps correctly.\n *\n * @param context - The backup and sync context containing controller and messenger.\n * @param snapshot - The state snapshot to restore.\n */\nexport function restoreStateFromSnapshot(\n context: BackupAndSyncContext,\n snapshot: StateSnapshot,\n): void {\n context.controllerStateUpdateFn((state) => {\n state.accountGroupsMetadata = snapshot.accountGroupsMetadata;\n state.accountWalletsMetadata = snapshot.accountWalletsMetadata;\n state.accountTree.selectedAccountGroup = snapshot.selectedAccountGroup;\n state.accountTree.wallets = snapshot.accountTreeWallets;\n });\n\n // Use init() to rebuild the internal maps from the restored account tree state\n // This ensures that the internal maps (#accountIdToContext and #groupIdToWalletId)\n // are correctly synchronized with the restored account tree structure\n context.controller.init();\n}\n"]}
@@ -20,7 +20,7 @@ export function getLocalEntropyWallets(context) {
20
20
  export const getLocalGroupForEntropyWallet = (context, entropySourceId, groupIndex) => {
21
21
  const walletId = toMultichainAccountWalletId(entropySourceId);
22
22
  const wallet = context.controller.state.accountTree.wallets[walletId];
23
- if (!wallet || wallet.type !== AccountWalletType.Entropy) {
23
+ if (wallet?.type !== AccountWalletType.Entropy) {
24
24
  backupAndSyncLogger(`Wallet ${walletId} not found or is not an entropy wallet`);
25
25
  return undefined;
26
26
  }
@@ -36,7 +36,7 @@ export const getLocalGroupForEntropyWallet = (context, entropySourceId, groupInd
36
36
  */
37
37
  export function getLocalGroupsForEntropyWallet(context, walletId) {
38
38
  const wallet = context.controller.state.accountTree.wallets[walletId];
39
- if (!wallet || wallet.type !== AccountWalletType.Entropy) {
39
+ if (wallet?.type !== AccountWalletType.Entropy) {
40
40
  backupAndSyncLogger(`Wallet ${walletId} not found or is not an entropy wallet`);
41
41
  return [];
42
42
  }
@@ -1 +1 @@
1
- {"version":3,"file":"controller.mjs","sourceRoot":"","sources":["../../../src/backup-and-sync/utils/controller.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,0BAA0B,EAC1B,2BAA2B,EAC5B,8BAA8B;AAI/B,OAAO,EAAE,mBAAmB,EAAE,yBAAqB;AAKnD;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CACpC,OAA6B;IAE7B,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,MAAM,CACvE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,iBAAiB,CAAC,OAAO,CACtB,CAAC;AACpC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAC3C,OAA6B,EAC7B,eAAuB,EACvB,UAAkB,EAC+B,EAAE;IACnD,MAAM,QAAQ,GAAG,2BAA2B,CAAC,eAAe,CAAC,CAAC;IAC9D,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAEtE,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,KAAK,iBAAiB,CAAC,OAAO,EAAE,CAAC;QACzD,mBAAmB,CACjB,UAAU,QAAQ,wCAAwC,CAC3D,CAAC;QACF,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,OAAO,GAAG,0BAA0B,C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KAAK,CAAC,qBAAqB,GAAG,QAAQ,CAAC,qBAAqB,CAAC;QAC7D,KAAK,CAAC,sBAAsB,GAAG,QAAQ,CAAC,sBAAsB,CAAC;QAC/D,KAAK,CAAC,WAAW,CAAC,oBAAoB,GAAG,QAAQ,CAAC,oBAAoB,CAAC;QACvE,KAAK,CAAC,WAAW,CAAC,OAAO,GAAG,QAAQ,CAAC,kBAAkB,CAAC;IAC1D,CAAC,CAAC,CAAC;IAEH,+EAA+E;IAC/E,mFAAmF;IACnF,sEAAsE;IACtE,OAAO,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;AAC5B,CAAC","sourcesContent":["import {\n AccountWalletType,\n toMultichainAccountGroupId,\n toMultichainAccountWalletId,\n} from '@metamask/account-api';\nimport type { AccountWalletId } from '@metamask/account-api';\n\nimport type { AccountGroupMultichainAccountObject } from '../../group';\nimport { backupAndSyncLogger } from '../../logger';\nimport type { AccountTreeControllerState } from '../../types';\nimport type { AccountWalletEntropyObject } from '../../wallet';\nimport type { BackupAndSyncContext } from '../types';\n\n/**\n * Gets all local entropy wallets that can be synced.\n *\n * @param context - The backup and sync context.\n * @returns Array of entropy wallet objects.\n */\nexport function getLocalEntropyWallets(\n context: BackupAndSyncContext,\n): AccountWalletEntropyObject[] {\n return Object.values(context.controller.state.accountTree.wallets).filter(\n (wallet) => wallet.type === AccountWalletType.Entropy,\n ) as AccountWalletEntropyObject[];\n}\n\n/**\n * Gets the local group for a specific entropy wallet by its source ID and group index.\n *\n * @param context - The backup and sync context.\n * @param entropySourceId - The entropy source ID.\n * @param groupIndex - The group index.\n * @returns The local group object if it exists, undefined otherwise.\n */\nexport const getLocalGroupForEntropyWallet = (\n context: BackupAndSyncContext,\n entropySourceId: string,\n groupIndex: number,\n): AccountGroupMultichainAccountObject | undefined => {\n const walletId = toMultichainAccountWalletId(entropySourceId);\n const wallet = context.controller.state.accountTree.wallets[walletId];\n\n if (!wallet || wallet.type !== AccountWalletType.Entropy) {\n backupAndSyncLogger(\n `Wallet ${walletId} not found or is not an entropy wallet`,\n );\n return undefined;\n }\n\n const groupId = toMultichainAccountGroupId(walletId, groupIndex);\n\n return wallet.groups[groupId];\n};\n\n/**\n * Gets all groups for a specific entropy wallet.\n *\n * @param context - The backup and sync context.\n * @param walletId - The wallet ID to get groups for.\n * @returns Array of multichain account group objects.\n */\nexport function getLocalGroupsForEntropyWallet(\n context: BackupAndSyncContext,\n walletId: AccountWalletId,\n): AccountGroupMultichainAccountObject[] {\n const wallet = context.controller.state.accountTree.wallets[walletId];\n if (!wallet || wallet.type !== AccountWalletType.Entropy) {\n backupAndSyncLogger(\n `Wallet ${walletId} not found or is not an entropy wallet`,\n );\n return [];\n }\n\n return Object.values(wallet.groups);\n}\n\n/**\n * State snapshot type for rollback operations.\n * Captures all the state that needs to be restored in case of sync failures.\n */\nexport type StateSnapshot = {\n accountGroupsMetadata: AccountTreeControllerState['accountGroupsMetadata'];\n accountWalletsMetadata: AccountTreeControllerState['accountWalletsMetadata'];\n selectedAccountGroup: AccountTreeControllerState['accountTree']['selectedAccountGroup'];\n accountTreeWallets: AccountTreeControllerState['accountTree']['wallets'];\n};\n\n/**\n * Creates a snapshot of the current controller state for rollback purposes.\n * Captures all state including the account tree structure.\n *\n * @param context - The backup and sync context containing controller and messenger.\n * @returns A deep copy of relevant state that can be restored later.\n */\nexport function createStateSnapshot(\n context: BackupAndSyncContext,\n): StateSnapshot {\n return {\n accountGroupsMetadata: JSON.parse(\n JSON.stringify(context.controller.state.accountGroupsMetadata),\n ),\n accountWalletsMetadata: JSON.parse(\n JSON.stringify(context.controller.state.accountWalletsMetadata),\n ),\n selectedAccountGroup:\n context.controller.state.accountTree.selectedAccountGroup,\n accountTreeWallets: JSON.parse(\n JSON.stringify(context.controller.state.accountTree.wallets),\n ),\n };\n}\n\n/**\n * Restores state using an update callback.\n * Restores both persisted metadata and the complete account tree structure.\n * Uses the controller's init() method to rebuild internal maps correctly.\n *\n * @param context - The backup and sync context containing controller and messenger.\n * @param snapshot - The state snapshot to restore.\n */\nexport function restoreStateFromSnapshot(\n context: BackupAndSyncContext,\n snapshot: StateSnapshot,\n): void {\n context.controllerStateUpdateFn((state) => {\n state.accountGroupsMetadata = snapshot.accountGroupsMetadata;\n state.accountWalletsMetadata = snapshot.accountWalletsMetadata;\n state.accountTree.selectedAccountGroup = snapshot.selectedAccountGroup;\n state.accountTree.wallets = snapshot.accountTreeWallets;\n });\n\n // Use init() to rebuild the internal maps from the restored account tree state\n // This ensures that the internal maps (#accountIdToContext and #groupIdToWalletId)\n // are correctly synchronized with the restored account tree structure\n context.controller.init();\n}\n"]}
1
+ {"version":3,"file":"controller.mjs","sourceRoot":"","sources":["../../../src/backup-and-sync/utils/controller.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,0BAA0B,EAC1B,2BAA2B,EAC5B,8BAA8B;AAI/B,OAAO,EAAE,mBAAmB,EAAE,yBAAqB;AAKnD;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CACpC,OAA6B;IAE7B,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,MAAM,CACvE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,iBAAiB,CAAC,OAAO,CACtB,CAAC;AACpC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAC3C,OAA6B,EAC7B,eAAuB,EACvB,UAAkB,EAC+B,EAAE;IACnD,MAAM,QAAQ,GAAG,2BAA2B,CAAC,eAAe,CAAC,CAAC;IAC9D,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAEtE,IAAI,MAAM,EAAE,IAAI,KAAK,iBAAiB,CAAC,OAAO,EAAE,CAAC;QAC/C,mBAAmB,CACjB,UAAU,QAAQ,wCAAwC,CA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EvB,OAAO,CAAC,uBAAuB,CAAC,CAAC,KAAK,EAAE,EAAE;QACxC,KAAK,CAAC,qBAAqB,GAAG,QAAQ,CAAC,qBAAqB,CAAC;QAC7D,KAAK,CAAC,sBAAsB,GAAG,QAAQ,CAAC,sBAAsB,CAAC;QAC/D,KAAK,CAAC,WAAW,CAAC,oBAAoB,GAAG,QAAQ,CAAC,oBAAoB,CAAC;QACvE,KAAK,CAAC,WAAW,CAAC,OAAO,GAAG,QAAQ,CAAC,kBAAkB,CAAC;IAC1D,CAAC,CAAC,CAAC;IAEH,+EAA+E;IAC/E,mFAAmF;IACnF,sEAAsE;IACtE,OAAO,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;AAC5B,CAAC","sourcesContent":["import {\n AccountWalletType,\n toMultichainAccountGroupId,\n toMultichainAccountWalletId,\n} from '@metamask/account-api';\nimport type { AccountWalletId } from '@metamask/account-api';\n\nimport type { AccountGroupMultichainAccountObject } from '../../group';\nimport { backupAndSyncLogger } from '../../logger';\nimport type { AccountTreeControllerState } from '../../types';\nimport type { AccountWalletEntropyObject } from '../../wallet';\nimport type { BackupAndSyncContext } from '../types';\n\n/**\n * Gets all local entropy wallets that can be synced.\n *\n * @param context - The backup and sync context.\n * @returns Array of entropy wallet objects.\n */\nexport function getLocalEntropyWallets(\n context: BackupAndSyncContext,\n): AccountWalletEntropyObject[] {\n return Object.values(context.controller.state.accountTree.wallets).filter(\n (wallet) => wallet.type === AccountWalletType.Entropy,\n ) as AccountWalletEntropyObject[];\n}\n\n/**\n * Gets the local group for a specific entropy wallet by its source ID and group index.\n *\n * @param context - The backup and sync context.\n * @param entropySourceId - The entropy source ID.\n * @param groupIndex - The group index.\n * @returns The local group object if it exists, undefined otherwise.\n */\nexport const getLocalGroupForEntropyWallet = (\n context: BackupAndSyncContext,\n entropySourceId: string,\n groupIndex: number,\n): AccountGroupMultichainAccountObject | undefined => {\n const walletId = toMultichainAccountWalletId(entropySourceId);\n const wallet = context.controller.state.accountTree.wallets[walletId];\n\n if (wallet?.type !== AccountWalletType.Entropy) {\n backupAndSyncLogger(\n `Wallet ${walletId} not found or is not an entropy wallet`,\n );\n return undefined;\n }\n\n const groupId = toMultichainAccountGroupId(walletId, groupIndex);\n\n return wallet.groups[groupId];\n};\n\n/**\n * Gets all groups for a specific entropy wallet.\n *\n * @param context - The backup and sync context.\n * @param walletId - The wallet ID to get groups for.\n * @returns Array of multichain account group objects.\n */\nexport function getLocalGroupsForEntropyWallet(\n context: BackupAndSyncContext,\n walletId: AccountWalletId,\n): AccountGroupMultichainAccountObject[] {\n const wallet = context.controller.state.accountTree.wallets[walletId];\n if (wallet?.type !== AccountWalletType.Entropy) {\n backupAndSyncLogger(\n `Wallet ${walletId} not found or is not an entropy wallet`,\n );\n return [];\n }\n\n return Object.values(wallet.groups);\n}\n\n/**\n * State snapshot type for rollback operations.\n * Captures all the state that needs to be restored in case of sync failures.\n */\nexport type StateSnapshot = {\n accountGroupsMetadata: AccountTreeControllerState['accountGroupsMetadata'];\n accountWalletsMetadata: AccountTreeControllerState['accountWalletsMetadata'];\n selectedAccountGroup: AccountTreeControllerState['accountTree']['selectedAccountGroup'];\n accountTreeWallets: AccountTreeControllerState['accountTree']['wallets'];\n};\n\n/**\n * Creates a snapshot of the current controller state for rollback purposes.\n * Captures all state including the account tree structure.\n *\n * @param context - The backup and sync context containing controller and messenger.\n * @returns A deep copy of relevant state that can be restored later.\n */\nexport function createStateSnapshot(\n context: BackupAndSyncContext,\n): StateSnapshot {\n return {\n accountGroupsMetadata: JSON.parse(\n JSON.stringify(context.controller.state.accountGroupsMetadata),\n ),\n accountWalletsMetadata: JSON.parse(\n JSON.stringify(context.controller.state.accountWalletsMetadata),\n ),\n selectedAccountGroup:\n context.controller.state.accountTree.selectedAccountGroup,\n accountTreeWallets: JSON.parse(\n JSON.stringify(context.controller.state.accountTree.wallets),\n ),\n };\n}\n\n/**\n * Restores state using an update callback.\n * Restores both persisted metadata and the complete account tree structure.\n * Uses the controller's init() method to rebuild internal maps correctly.\n *\n * @param context - The backup and sync context containing controller and messenger.\n * @param snapshot - The state snapshot to restore.\n */\nexport function restoreStateFromSnapshot(\n context: BackupAndSyncContext,\n snapshot: StateSnapshot,\n): void {\n context.controllerStateUpdateFn((state) => {\n state.accountGroupsMetadata = snapshot.accountGroupsMetadata;\n state.accountWalletsMetadata = snapshot.accountWalletsMetadata;\n state.accountTree.selectedAccountGroup = snapshot.selectedAccountGroup;\n state.accountTree.wallets = snapshot.accountTreeWallets;\n });\n\n // Use init() to rebuild the internal maps from the restored account tree state\n // This ensures that the internal maps (#accountIdToContext and #groupIdToWalletId)\n // are correctly synchronized with the restored account tree structure\n context.controller.init();\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/account-tree-controller",
3
- "version": "4.0.0-preview-d01b2f93d",
3
+ "version": "4.1.0-preview-cbcea9611",
4
4
  "description": "Controller to group account together based on some pre-defined rules",
5
5
  "keywords": [
6
6
  "MetaMask",
@@ -52,7 +52,7 @@
52
52
  "@metamask/base-controller": "^9.0.0",
53
53
  "@metamask/keyring-controller": "^25.1.0",
54
54
  "@metamask/messenger": "^0.3.0",
55
- "@metamask/multichain-account-service": "^5.1.0",
55
+ "@metamask/multichain-account-service": "^6.0.0",
56
56
  "@metamask/profile-sync-controller": "^27.1.0",
57
57
  "@metamask/snaps-controllers": "^17.2.0",
58
58
  "@metamask/snaps-sdk": "^10.3.0",
@@ -63,9 +63,9 @@
63
63
  "lodash": "^4.17.21"
64
64
  },
65
65
  "devDependencies": {
66
- "@metamask/account-api": "^0.12.0",
66
+ "@metamask/account-api": "^1.0.0",
67
67
  "@metamask/auto-changelog": "^3.4.4",
68
- "@metamask/keyring-api": "^21.0.0",
68
+ "@metamask/keyring-api": "^21.5.0",
69
69
  "@metamask/providers": "^22.1.0",
70
70
  "@ts-bridge/cli": "^0.6.4",
71
71
  "@types/jest": "^27.5.2",