@metamask-previews/account-tree-controller 7.3.0-preview-ccdc8dcd5 → 7.3.0-preview-beaf51362
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 +0 -9
- package/dist/AccountTreeController.cjs +10 -61
- package/dist/AccountTreeController.cjs.map +1 -1
- package/dist/AccountTreeController.d.cts +0 -6
- package/dist/AccountTreeController.d.cts.map +1 -1
- package/dist/AccountTreeController.d.mts +0 -6
- package/dist/AccountTreeController.d.mts.map +1 -1
- package/dist/AccountTreeController.mjs +10 -61
- package/dist/AccountTreeController.mjs.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +1 -28
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +1 -28
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,15 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
-
### Added
|
|
11
|
-
|
|
12
|
-
- Add `AccountTreeController:accountGroup{Created,Updated,Removed}` events ([#8766](https://github.com/MetaMask/core/pull/8766))
|
|
13
|
-
- None of these events fire during `init`/`reinit`, consumers should bootstrap from `:getState` or `:accountTreeChange`.
|
|
14
|
-
|
|
15
|
-
### Changed
|
|
16
|
-
|
|
17
|
-
- Bump `@metamask/accounts-controller` from `^38.0.0` to `^38.1.1` ([#8755](https://github.com/MetaMask/core/pull/8755), [#8774](https://github.com/MetaMask/core/pull/8774))
|
|
18
|
-
|
|
19
10
|
## [7.3.0]
|
|
20
11
|
|
|
21
12
|
### Added
|
|
@@ -10,7 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
10
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
11
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
12
|
};
|
|
13
|
-
var _AccountTreeController_instances, _AccountTreeController_accountIdToContext, _AccountTreeController_groupIdToWalletId, _AccountTreeController_backupAndSyncService, _AccountTreeController_rules, _AccountTreeController_trace, _AccountTreeController_backupAndSyncConfig, _AccountTreeController_accountOrderCallbacks, _AccountTreeController_initialized, _AccountTreeController_initTreeContext, _AccountTreeController_getEntropyRule, _AccountTreeController_getSnapRule, _AccountTreeController_getKeyringRule, _AccountTreeController_applyAccountWalletMetadata, _AccountTreeController_getRuleForWallet, _AccountTreeController_getComputedAccountGroupName, _AccountTreeController_getDefaultAccountGroupName, _AccountTreeController_applyAccountGroupMetadata, _AccountTreeController_handleAccountsAdded, _AccountTreeController_handleAccountsRemoved, _AccountTreeController_pruneEmptyGroupAndWallet,
|
|
13
|
+
var _AccountTreeController_instances, _AccountTreeController_accountIdToContext, _AccountTreeController_groupIdToWalletId, _AccountTreeController_backupAndSyncService, _AccountTreeController_rules, _AccountTreeController_trace, _AccountTreeController_backupAndSyncConfig, _AccountTreeController_accountOrderCallbacks, _AccountTreeController_initialized, _AccountTreeController_initTreeContext, _AccountTreeController_getEntropyRule, _AccountTreeController_getSnapRule, _AccountTreeController_getKeyringRule, _AccountTreeController_applyAccountWalletMetadata, _AccountTreeController_getRuleForWallet, _AccountTreeController_getComputedAccountGroupName, _AccountTreeController_getDefaultAccountGroupName, _AccountTreeController_applyAccountGroupMetadata, _AccountTreeController_handleAccountsAdded, _AccountTreeController_handleAccountsRemoved, _AccountTreeController_pruneEmptyGroupAndWallet, _AccountTreeController_insert, _AccountTreeController_listAccounts, _AccountTreeController_assertAccountGroupExists, _AccountTreeController_assertAccountWalletExists, _AccountTreeController_assertAccountGroupNameIsUnique, _AccountTreeController_setSelectedAccountGroup, _AccountTreeController_getDefaultSelectedAccountGroup, _AccountTreeController_handleSelectedAccountChange, _AccountTreeController_handleMultichainAccountWalletStatusChange, _AccountTreeController_getAccountGroup, _AccountTreeController_getDefaultAccountFromAccountGroupId, _AccountTreeController_getDefaultAccountGroupId, _AccountTreeController_hasEvmAccount, _AccountTreeController_resolveNameConflict, _AccountTreeController_createBackupAndSyncContext;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.AccountTreeController = exports.getDefaultAccountTreeControllerState = exports.controllerName = void 0;
|
|
16
16
|
const account_api_1 = require("@metamask/account-api");
|
|
@@ -410,7 +410,6 @@ class AccountTreeController extends base_controller_1.BaseController {
|
|
|
410
410
|
state.accountTree.wallets[walletId].groups[groupId].metadata.name =
|
|
411
411
|
finalName;
|
|
412
412
|
});
|
|
413
|
-
__classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_publishAccountGroupUpdated).call(this, walletId, groupId);
|
|
414
413
|
// Trigger atomic sync for group rename (only for groups from entropy wallets)
|
|
415
414
|
if (wallet.type === account_api_1.AccountWalletType.Entropy) {
|
|
416
415
|
__classPrivateFieldGet(this, _AccountTreeController_backupAndSyncService, "f").enqueueSingleGroupSync(groupId);
|
|
@@ -470,9 +469,6 @@ class AccountTreeController extends base_controller_1.BaseController {
|
|
|
470
469
|
pinned;
|
|
471
470
|
}
|
|
472
471
|
});
|
|
473
|
-
if (walletId) {
|
|
474
|
-
__classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_publishAccountGroupUpdated).call(this, walletId, groupId);
|
|
475
|
-
}
|
|
476
472
|
// Trigger atomic sync for group pinning (only for groups from entropy wallets)
|
|
477
473
|
if (walletId &&
|
|
478
474
|
this.state.accountTree.wallets[walletId].type ===
|
|
@@ -507,9 +503,6 @@ class AccountTreeController extends base_controller_1.BaseController {
|
|
|
507
503
|
hidden;
|
|
508
504
|
}
|
|
509
505
|
});
|
|
510
|
-
if (walletId) {
|
|
511
|
-
__classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_publishAccountGroupUpdated).call(this, walletId, groupId);
|
|
512
|
-
}
|
|
513
506
|
// Trigger atomic sync for group hiding (only for groups from entropy wallets)
|
|
514
507
|
if (walletId &&
|
|
515
508
|
this.state.accountTree.wallets[walletId].type ===
|
|
@@ -793,37 +786,21 @@ _AccountTreeController_accountIdToContext = new WeakMap(), _AccountTreeControlle
|
|
|
793
786
|
if (newAccounts.length === 0) {
|
|
794
787
|
return;
|
|
795
788
|
}
|
|
796
|
-
const createdGroups = new Map();
|
|
797
|
-
const updatedGroups = new Map();
|
|
798
789
|
this.update((state) => {
|
|
799
790
|
for (const account of newAccounts) {
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
// - Account 1 will create the group
|
|
810
|
-
// - Account 3 will update the group (but we only want to send a created event, not an updated one)
|
|
811
|
-
updatedGroups.set(groupId, walletId);
|
|
812
|
-
}
|
|
813
|
-
const wallet = state.accountTree.wallets[walletId];
|
|
814
|
-
if (wallet) {
|
|
815
|
-
__classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_applyAccountWalletMetadata).call(this, state, walletId);
|
|
816
|
-
__classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_applyAccountGroupMetadata).call(this, state, walletId, groupId);
|
|
791
|
+
__classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_insert).call(this, state.accountTree.wallets, account);
|
|
792
|
+
const context = __classPrivateFieldGet(this, _AccountTreeController_accountIdToContext, "f").get(account.id);
|
|
793
|
+
if (context) {
|
|
794
|
+
const { walletId, groupId } = context;
|
|
795
|
+
const wallet = state.accountTree.wallets[walletId];
|
|
796
|
+
if (wallet) {
|
|
797
|
+
__classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_applyAccountWalletMetadata).call(this, state, walletId);
|
|
798
|
+
__classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_applyAccountGroupMetadata).call(this, state, walletId, groupId);
|
|
799
|
+
}
|
|
817
800
|
}
|
|
818
801
|
}
|
|
819
802
|
});
|
|
820
803
|
this.messenger.publish(`${exports.controllerName}:accountTreeChange`, this.state.accountTree);
|
|
821
|
-
for (const [groupId, walletId] of createdGroups) {
|
|
822
|
-
__classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_publishAccountGroupCreated).call(this, walletId, groupId);
|
|
823
|
-
}
|
|
824
|
-
for (const [groupId, walletId] of updatedGroups) {
|
|
825
|
-
__classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_publishAccountGroupUpdated).call(this, walletId, groupId);
|
|
826
|
-
}
|
|
827
804
|
}, _AccountTreeController_handleAccountsRemoved = function _AccountTreeController_handleAccountsRemoved(accountIds) {
|
|
828
805
|
// We wait for the first `init` to be called to actually build up the tree and
|
|
829
806
|
// mutate it. We expect the caller to first update the `AccountsController` state
|
|
@@ -842,8 +819,6 @@ _AccountTreeController_accountIdToContext = new WeakMap(), _AccountTreeControlle
|
|
|
842
819
|
return;
|
|
843
820
|
}
|
|
844
821
|
const previousSelectedAccountGroup = this.state.selectedAccountGroup;
|
|
845
|
-
const updatedGroups = new Map();
|
|
846
|
-
const removedGroups = new Set();
|
|
847
822
|
this.update((state) => {
|
|
848
823
|
for (const { id: accountId, context } of knownAccounts) {
|
|
849
824
|
const { walletId, groupId } = context;
|
|
@@ -859,12 +834,6 @@ _AccountTreeController_accountIdToContext = new WeakMap(), _AccountTreeControlle
|
|
|
859
834
|
}
|
|
860
835
|
if (accounts.length === 0) {
|
|
861
836
|
__classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_pruneEmptyGroupAndWallet).call(this, state, walletId, groupId);
|
|
862
|
-
// If the group gets pruned, we should not consider it as updated.
|
|
863
|
-
updatedGroups.delete(groupId);
|
|
864
|
-
removedGroups.add(groupId);
|
|
865
|
-
}
|
|
866
|
-
else {
|
|
867
|
-
updatedGroups.set(groupId, walletId);
|
|
868
837
|
}
|
|
869
838
|
}
|
|
870
839
|
}
|
|
@@ -874,12 +843,6 @@ _AccountTreeController_accountIdToContext = new WeakMap(), _AccountTreeControlle
|
|
|
874
843
|
__classPrivateFieldGet(this, _AccountTreeController_accountIdToContext, "f").delete(id);
|
|
875
844
|
}
|
|
876
845
|
this.messenger.publish(`${exports.controllerName}:accountTreeChange`, this.state.accountTree);
|
|
877
|
-
for (const [groupId, walletId] of updatedGroups) {
|
|
878
|
-
__classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_publishAccountGroupUpdated).call(this, walletId, groupId);
|
|
879
|
-
}
|
|
880
|
-
for (const groupId of removedGroups) {
|
|
881
|
-
__classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_publishAccountGroupRemoved).call(this, groupId);
|
|
882
|
-
}
|
|
883
846
|
const newSelectedAccountGroup = this.state.selectedAccountGroup;
|
|
884
847
|
if (newSelectedAccountGroup !== previousSelectedAccountGroup) {
|
|
885
848
|
this.messenger.publish(`${exports.controllerName}:selectedAccountGroupChange`, newSelectedAccountGroup, previousSelectedAccountGroup);
|
|
@@ -896,18 +859,6 @@ _AccountTreeController_accountIdToContext = new WeakMap(), _AccountTreeControlle
|
|
|
896
859
|
delete state.accountWalletsMetadata[walletId];
|
|
897
860
|
}
|
|
898
861
|
return state;
|
|
899
|
-
}, _AccountTreeController_publishAccountGroupCreated = function _AccountTreeController_publishAccountGroupCreated(walletId, groupId) {
|
|
900
|
-
const group = this.state.accountTree.wallets[walletId]?.groups[groupId];
|
|
901
|
-
if (group) {
|
|
902
|
-
this.messenger.publish(`${exports.controllerName}:accountGroupCreated`, group);
|
|
903
|
-
}
|
|
904
|
-
}, _AccountTreeController_publishAccountGroupUpdated = function _AccountTreeController_publishAccountGroupUpdated(walletId, groupId) {
|
|
905
|
-
const group = this.state.accountTree.wallets[walletId]?.groups[groupId];
|
|
906
|
-
if (group) {
|
|
907
|
-
this.messenger.publish(`${exports.controllerName}:accountGroupUpdated`, group);
|
|
908
|
-
}
|
|
909
|
-
}, _AccountTreeController_publishAccountGroupRemoved = function _AccountTreeController_publishAccountGroupRemoved(groupId) {
|
|
910
|
-
this.messenger.publish(`${exports.controllerName}:accountGroupRemoved`, groupId);
|
|
911
862
|
}, _AccountTreeController_insert = function _AccountTreeController_insert(wallets, account) {
|
|
912
863
|
const result = __classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_getEntropyRule).call(this).match(account) ??
|
|
913
864
|
__classPrivateFieldGet(this, _AccountTreeController_instances, "m", _AccountTreeController_getSnapRule).call(this).match(account) ??
|
|
@@ -938,7 +889,6 @@ _AccountTreeController_accountIdToContext = new WeakMap(), _AccountTreeControlle
|
|
|
938
889
|
let group = wallet.groups[groupId];
|
|
939
890
|
const { type, id } = account;
|
|
940
891
|
const sortOrder = group_1.ACCOUNT_TYPE_TO_SORT_ORDER[type];
|
|
941
|
-
const created = !group;
|
|
942
892
|
if (!group) {
|
|
943
893
|
(0, logger_1.projectLogger)(`[${walletId}] Add new group: [${groupId}]`);
|
|
944
894
|
wallet.groups[groupId] = {
|
|
@@ -986,7 +936,6 @@ _AccountTreeController_accountIdToContext = new WeakMap(), _AccountTreeControlle
|
|
|
986
936
|
groupId: group.id,
|
|
987
937
|
sortOrder,
|
|
988
938
|
});
|
|
989
|
-
return { walletId: wallet.id, groupId: group.id, created };
|
|
990
939
|
}, _AccountTreeController_listAccounts = function _AccountTreeController_listAccounts() {
|
|
991
940
|
return this.messenger.call('AccountsController:listMultichainAccounts');
|
|
992
941
|
}, _AccountTreeController_assertAccountGroupExists = function _AccountTreeController_assertAccountGroupExists(groupId) {
|