@metamask-previews/account-tree-controller 1.6.0-preview-77daf0c7 → 2.0.0-preview-46d2c977
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 +14 -1
- package/dist/AccountTreeController.cjs +34 -34
- package/dist/AccountTreeController.cjs.map +1 -1
- package/dist/AccountTreeController.d.cts +12 -0
- package/dist/AccountTreeController.d.cts.map +1 -1
- package/dist/AccountTreeController.d.mts +12 -0
- package/dist/AccountTreeController.d.mts.map +1 -1
- package/dist/AccountTreeController.mjs +34 -34
- package/dist/AccountTreeController.mjs.map +1 -1
- package/dist/backup-and-sync/types.d.cts +3 -3
- package/dist/backup-and-sync/types.d.mts +3 -3
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +3 -2
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +3 -2
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/package.json +11 -10
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [2.0.0]
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- **BREAKING:** Use new `Messenger` from `@metamask/messenger` ([#6380](https://github.com/MetaMask/core/pull/6380))
|
|
15
|
+
- Previously, `AccountTreeController` accepted a `RestrictedMessenger` instance from `@metamask/base-controller`.
|
|
16
|
+
- **BREAKING:** Bump `@metamask/accounts-controller` from `^33.0.0` to `^34.0.0` ([#6962](https://github.com/MetaMask/core/pull/6962))
|
|
17
|
+
- **BREAKING:** Bump `@metamask/keyring-controller` from `^23.0.0` to `^24.0.0` ([#6962](https://github.com/MetaMask/core/pull/6962))
|
|
18
|
+
- **BREAKING:** Bump `@metamask/multichain-account-service` from `^1.0.0` to `^2.0.0` ([#6962](https://github.com/MetaMask/core/pull/6962))
|
|
19
|
+
- **BREAKING:** Bump `@metamask/profile-sync-controller` from `^25.0.0` to `^26.0.0` ([#6962](https://github.com/MetaMask/core/pull/6962))
|
|
20
|
+
- Bump `@metamask/base-controller` from `^8.4.2` to `^9.0.0` ([#6962](https://github.com/MetaMask/core/pull/6962))
|
|
21
|
+
|
|
10
22
|
## [1.6.0]
|
|
11
23
|
|
|
12
24
|
### Changed
|
|
@@ -381,7 +393,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
381
393
|
- Initial release ([#5847](https://github.com/MetaMask/core/pull/5847))
|
|
382
394
|
- Grouping accounts into 3 main categories: Entropy source, Snap ID, keyring types.
|
|
383
395
|
|
|
384
|
-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/account-tree-controller@
|
|
396
|
+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/account-tree-controller@2.0.0...HEAD
|
|
397
|
+
[2.0.0]: https://github.com/MetaMask/core/compare/@metamask/account-tree-controller@1.6.0...@metamask/account-tree-controller@2.0.0
|
|
385
398
|
[1.6.0]: https://github.com/MetaMask/core/compare/@metamask/account-tree-controller@1.5.0...@metamask/account-tree-controller@1.6.0
|
|
386
399
|
[1.5.0]: https://github.com/MetaMask/core/compare/@metamask/account-tree-controller@1.4.2...@metamask/account-tree-controller@1.5.0
|
|
387
400
|
[1.4.2]: https://github.com/MetaMask/core/compare/@metamask/account-tree-controller@1.4.1...@metamask/account-tree-controller@1.4.2
|
|
@@ -29,31 +29,31 @@ const accountTreeControllerMetadata = {
|
|
|
29
29
|
accountTree: {
|
|
30
30
|
includeInStateLogs: true,
|
|
31
31
|
persist: false,
|
|
32
|
-
|
|
32
|
+
includeInDebugSnapshot: false,
|
|
33
33
|
usedInUi: true,
|
|
34
34
|
},
|
|
35
35
|
isAccountTreeSyncingInProgress: {
|
|
36
36
|
includeInStateLogs: false,
|
|
37
37
|
persist: false,
|
|
38
|
-
|
|
38
|
+
includeInDebugSnapshot: false,
|
|
39
39
|
usedInUi: true,
|
|
40
40
|
},
|
|
41
41
|
hasAccountTreeSyncingSyncedAtLeastOnce: {
|
|
42
42
|
includeInStateLogs: true,
|
|
43
43
|
persist: true,
|
|
44
|
-
|
|
44
|
+
includeInDebugSnapshot: false,
|
|
45
45
|
usedInUi: true,
|
|
46
46
|
},
|
|
47
47
|
accountGroupsMetadata: {
|
|
48
48
|
includeInStateLogs: true,
|
|
49
49
|
persist: true,
|
|
50
|
-
|
|
50
|
+
includeInDebugSnapshot: false,
|
|
51
51
|
usedInUi: true,
|
|
52
52
|
},
|
|
53
53
|
accountWalletsMetadata: {
|
|
54
54
|
includeInStateLogs: true,
|
|
55
55
|
persist: true,
|
|
56
|
-
|
|
56
|
+
includeInDebugSnapshot: false,
|
|
57
57
|
usedInUi: true,
|
|
58
58
|
},
|
|
59
59
|
};
|
|
@@ -118,11 +118,11 @@ class AccountTreeController extends base_controller_1.BaseController {
|
|
|
118
118
|
// Rules to apply to construct the wallets tree.
|
|
119
119
|
__classPrivateFieldSet(this, _AccountTreeController_rules, [
|
|
120
120
|
// 1. We group by entropy-source
|
|
121
|
-
new entropy_1.EntropyRule(this.
|
|
121
|
+
new entropy_1.EntropyRule(this.messenger),
|
|
122
122
|
// 2. We group by Snap ID
|
|
123
|
-
new snap_1.SnapRule(this.
|
|
123
|
+
new snap_1.SnapRule(this.messenger),
|
|
124
124
|
// 3. We group by wallet type (this rule cannot fail and will group all non-matching accounts)
|
|
125
|
-
new keyring_1.KeyringRule(this.
|
|
125
|
+
new keyring_1.KeyringRule(this.messenger),
|
|
126
126
|
], "f");
|
|
127
127
|
// Initialize trace function
|
|
128
128
|
__classPrivateFieldSet(this, _AccountTreeController_trace, config?.trace ?? analytics_1.traceFallback, "f");
|
|
@@ -137,19 +137,19 @@ class AccountTreeController extends base_controller_1.BaseController {
|
|
|
137
137
|
__classPrivateFieldSet(this, _AccountTreeController_accountOrderCallbacks, config?.accountOrderCallbacks, "f");
|
|
138
138
|
// Initialize the backup and sync service
|
|
139
139
|
__classPrivateFieldSet(this, _AccountTreeController_backupAndSyncService, new service_1.BackupAndSyncService(__classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_createBackupAndSyncContext).call(this)), "f");
|
|
140
|
-
this.
|
|
140
|
+
this.messenger.subscribe('AccountsController:accountAdded', (account) => {
|
|
141
141
|
__classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_handleAccountAdded).call(this, account);
|
|
142
142
|
});
|
|
143
|
-
this.
|
|
143
|
+
this.messenger.subscribe('AccountsController:accountRemoved', (accountId) => {
|
|
144
144
|
__classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_handleAccountRemoved).call(this, accountId);
|
|
145
145
|
});
|
|
146
|
-
this.
|
|
146
|
+
this.messenger.subscribe('AccountsController:selectedAccountChange', (account) => {
|
|
147
147
|
__classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_handleSelectedAccountChange).call(this, account);
|
|
148
148
|
});
|
|
149
|
-
this.
|
|
149
|
+
this.messenger.subscribe('UserStorageController:stateChange', (userStorageControllerState) => {
|
|
150
150
|
__classPrivateFieldGet(this, _AccountTreeController_backupAndSyncService, "f").handleUserStorageStateChange(userStorageControllerState);
|
|
151
151
|
});
|
|
152
|
-
this.
|
|
152
|
+
this.messenger.subscribe('MultichainAccountService:walletStatusChange', (walletId, status) => {
|
|
153
153
|
__classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_handleMultichainAccountWalletStatusChange).call(this, walletId, status);
|
|
154
154
|
});
|
|
155
155
|
__classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_registerMessageHandlers).call(this);
|
|
@@ -238,7 +238,7 @@ class AccountTreeController extends base_controller_1.BaseController {
|
|
|
238
238
|
if (previousSelectedAccountGroup !==
|
|
239
239
|
this.state.accountTree.selectedAccountGroup) {
|
|
240
240
|
(0, logger_1.projectLogger)(`Selected (initial) group is: [${this.state.accountTree.selectedAccountGroup}]`);
|
|
241
|
-
this.
|
|
241
|
+
this.messenger.publish(`${exports.controllerName}:selectedAccountGroupChange`, this.state.accountTree.selectedAccountGroup, previousSelectedAccountGroup);
|
|
242
242
|
}
|
|
243
243
|
(0, logger_1.projectLogger)('Initialized!');
|
|
244
244
|
__classPrivateFieldSet(this, _AccountTreeController_initialized, true, "f");
|
|
@@ -299,7 +299,7 @@ class AccountTreeController extends base_controller_1.BaseController {
|
|
|
299
299
|
}
|
|
300
300
|
const accounts = [];
|
|
301
301
|
for (const id of group.accounts) {
|
|
302
|
-
const account = this.
|
|
302
|
+
const account = this.messenger.call('AccountsController:getAccount', id);
|
|
303
303
|
// For now, we're filtering undefined account, but I believe
|
|
304
304
|
// throwing would be more appropriate here.
|
|
305
305
|
if (account) {
|
|
@@ -351,10 +351,10 @@ class AccountTreeController extends base_controller_1.BaseController {
|
|
|
351
351
|
state.accountTree.selectedAccountGroup = groupId;
|
|
352
352
|
});
|
|
353
353
|
(0, logger_1.projectLogger)(`Selected group is now: [${this.state.accountTree.selectedAccountGroup}]`);
|
|
354
|
-
this.
|
|
354
|
+
this.messenger.publish(`${exports.controllerName}:selectedAccountGroupChange`, groupId, previousSelectedAccountGroup);
|
|
355
355
|
// Update AccountsController - this will trigger selectedAccountChange event,
|
|
356
356
|
// but our handler is idempotent so it won't cause infinite loop
|
|
357
|
-
this.
|
|
357
|
+
this.messenger.call('AccountsController:setSelectedAccount', accountToSelect);
|
|
358
358
|
}
|
|
359
359
|
/**
|
|
360
360
|
* Resolves name conflicts by adding a suffix to make the name unique.
|
|
@@ -602,7 +602,7 @@ _AccountTreeController_accountIdToContext = new WeakMap(), _AccountTreeControlle
|
|
|
602
602
|
}, _AccountTreeController_getComputedAccountGroupName = function _AccountTreeController_getComputedAccountGroupName(wallet, group) {
|
|
603
603
|
let proposedName = ''; // Empty means there's no computed name for this group.
|
|
604
604
|
for (const id of group.accounts) {
|
|
605
|
-
const account = this.
|
|
605
|
+
const account = this.messenger.call('AccountsController:getAccount', id);
|
|
606
606
|
if (!account || !account.metadata.name.length) {
|
|
607
607
|
continue;
|
|
608
608
|
}
|
|
@@ -767,7 +767,7 @@ _AccountTreeController_accountIdToContext = new WeakMap(), _AccountTreeControlle
|
|
|
767
767
|
}
|
|
768
768
|
}
|
|
769
769
|
});
|
|
770
|
-
this.
|
|
770
|
+
this.messenger.publish(`${exports.controllerName}:accountTreeChange`, this.state.accountTree);
|
|
771
771
|
}
|
|
772
772
|
}, _AccountTreeController_handleAccountRemoved = function _AccountTreeController_handleAccountRemoved(accountId) {
|
|
773
773
|
// We wait for the first `init` to be called to actually build up the tree and
|
|
@@ -802,10 +802,10 @@ _AccountTreeController_accountIdToContext = new WeakMap(), _AccountTreeControlle
|
|
|
802
802
|
}
|
|
803
803
|
}
|
|
804
804
|
});
|
|
805
|
-
this.
|
|
805
|
+
this.messenger.publish(`${exports.controllerName}:accountTreeChange`, this.state.accountTree);
|
|
806
806
|
// Emit selectedAccountGroupChange event if the selected group changed
|
|
807
807
|
if (selectedAccountGroupChanged) {
|
|
808
|
-
this.
|
|
808
|
+
this.messenger.publish(`${exports.controllerName}:selectedAccountGroupChange`, this.state.accountTree.selectedAccountGroup, previousSelectedAccountGroup);
|
|
809
809
|
}
|
|
810
810
|
// Clear reverse-mapping for that account.
|
|
811
811
|
__classPrivateFieldGet(this, _AccountTreeController_accountIdToContext, "f").delete(accountId);
|
|
@@ -900,7 +900,7 @@ _AccountTreeController_accountIdToContext = new WeakMap(), _AccountTreeControlle
|
|
|
900
900
|
sortOrder,
|
|
901
901
|
});
|
|
902
902
|
}, _AccountTreeController_listAccounts = function _AccountTreeController_listAccounts() {
|
|
903
|
-
return this.
|
|
903
|
+
return this.messenger.call('AccountsController:listMultichainAccounts');
|
|
904
904
|
}, _AccountTreeController_assertAccountGroupExists = function _AccountTreeController_assertAccountGroupExists(groupId) {
|
|
905
905
|
const exists = __classPrivateFieldGet(this, _AccountTreeController_groupIdToWalletId, "f").has(groupId);
|
|
906
906
|
if (!exists) {
|
|
@@ -916,7 +916,7 @@ _AccountTreeController_accountIdToContext = new WeakMap(), _AccountTreeControlle
|
|
|
916
916
|
throw new Error('Account group name already exists');
|
|
917
917
|
}
|
|
918
918
|
}, _AccountTreeController_getDefaultSelectedAccountGroup = function _AccountTreeController_getDefaultSelectedAccountGroup(wallets) {
|
|
919
|
-
const selectedAccount = this.
|
|
919
|
+
const selectedAccount = this.messenger.call('AccountsController:getSelectedMultichainAccount');
|
|
920
920
|
if (selectedAccount && selectedAccount.id) {
|
|
921
921
|
const accountMapping = __classPrivateFieldGet(this, _AccountTreeController_accountIdToContext, "f").get(selectedAccount.id);
|
|
922
922
|
if (accountMapping) {
|
|
@@ -942,7 +942,7 @@ _AccountTreeController_accountIdToContext = new WeakMap(), _AccountTreeControlle
|
|
|
942
942
|
this.update((state) => {
|
|
943
943
|
state.accountTree.selectedAccountGroup = groupId;
|
|
944
944
|
});
|
|
945
|
-
this.
|
|
945
|
+
this.messenger.publish(`${exports.controllerName}:selectedAccountGroupChange`, groupId, previousSelectedAccountGroup);
|
|
946
946
|
}, _AccountTreeController_handleMultichainAccountWalletStatusChange = function _AccountTreeController_handleMultichainAccountWalletStatusChange(walletId, walletStatus) {
|
|
947
947
|
this.update((state) => {
|
|
948
948
|
const wallet = state.accountTree.wallets[walletId];
|
|
@@ -958,7 +958,7 @@ _AccountTreeController_accountIdToContext = new WeakMap(), _AccountTreeControlle
|
|
|
958
958
|
if (group) {
|
|
959
959
|
let candidate;
|
|
960
960
|
for (const id of group.accounts) {
|
|
961
|
-
const account = this.
|
|
961
|
+
const account = this.messenger.call('AccountsController:getAccount', id);
|
|
962
962
|
if (!candidate) {
|
|
963
963
|
candidate = id;
|
|
964
964
|
}
|
|
@@ -982,7 +982,7 @@ _AccountTreeController_accountIdToContext = new WeakMap(), _AccountTreeControlle
|
|
|
982
982
|
candidate = group.id;
|
|
983
983
|
}
|
|
984
984
|
for (const id of group.accounts) {
|
|
985
|
-
const account = this.
|
|
985
|
+
const account = this.messenger.call('AccountsController:getAccount', id);
|
|
986
986
|
if (account && (0, keyring_api_1.isEvmAccountType)(account.type)) {
|
|
987
987
|
// EVM accounts have a higher priority, so if we find any, we just
|
|
988
988
|
// use that group!
|
|
@@ -993,18 +993,18 @@ _AccountTreeController_accountIdToContext = new WeakMap(), _AccountTreeControlle
|
|
|
993
993
|
}
|
|
994
994
|
return candidate;
|
|
995
995
|
}, _AccountTreeController_registerMessageHandlers = function _AccountTreeController_registerMessageHandlers() {
|
|
996
|
-
this.
|
|
997
|
-
this.
|
|
998
|
-
this.
|
|
999
|
-
this.
|
|
1000
|
-
this.
|
|
1001
|
-
this.
|
|
1002
|
-
this.
|
|
996
|
+
this.messenger.registerActionHandler(`${exports.controllerName}:getSelectedAccountGroup`, this.getSelectedAccountGroup.bind(this));
|
|
997
|
+
this.messenger.registerActionHandler(`${exports.controllerName}:setSelectedAccountGroup`, this.setSelectedAccountGroup.bind(this));
|
|
998
|
+
this.messenger.registerActionHandler(`${exports.controllerName}:getAccountsFromSelectedAccountGroup`, this.getAccountsFromSelectedAccountGroup.bind(this));
|
|
999
|
+
this.messenger.registerActionHandler(`${exports.controllerName}:setAccountWalletName`, this.setAccountWalletName.bind(this));
|
|
1000
|
+
this.messenger.registerActionHandler(`${exports.controllerName}:setAccountGroupName`, this.setAccountGroupName.bind(this));
|
|
1001
|
+
this.messenger.registerActionHandler(`${exports.controllerName}:setAccountGroupPinned`, this.setAccountGroupPinned.bind(this));
|
|
1002
|
+
this.messenger.registerActionHandler(`${exports.controllerName}:setAccountGroupHidden`, this.setAccountGroupHidden.bind(this));
|
|
1003
1003
|
}, _AccountTreeController_createBackupAndSyncContext = function _AccountTreeController_createBackupAndSyncContext() {
|
|
1004
1004
|
return {
|
|
1005
1005
|
...__classPrivateFieldGet(this, _AccountTreeController_backupAndSyncConfig, "f"),
|
|
1006
1006
|
controller: this,
|
|
1007
|
-
messenger: this.
|
|
1007
|
+
messenger: this.messenger,
|
|
1008
1008
|
controllerStateUpdateFn: this.update.bind(this),
|
|
1009
1009
|
traceFn: __classPrivateFieldGet(this, _AccountTreeController_trace, "f").bind(this),
|
|
1010
1010
|
groupIdToWalletId: __classPrivateFieldGet(this, _AccountTreeController_groupIdToWalletId, "f"),
|