@metamask-previews/account-tree-controller 7.1.0-preview-1e3393b67 → 7.1.0-preview-e7ff8e76d
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 -5
- package/dist/AccountTreeController.d.cts +1 -1
- package/dist/AccountTreeController.d.mts +1 -1
- package/dist/group.cjs +0 -1
- package/dist/group.cjs.map +1 -1
- package/dist/group.d.cts.map +1 -1
- package/dist/group.d.mts.map +1 -1
- package/dist/group.mjs +1 -2
- package/dist/group.mjs.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -7,11 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
-
### Changed
|
|
11
|
-
|
|
12
|
-
- Bump `@metamask/keyring-api` from `^21.6.0` to `^23.0.1` ([#8464](https://github.com/MetaMask/core/pull/8464))
|
|
13
|
-
- Add Stellar sort-order support ([#8464](https://github.com/MetaMask/core/pull/8464))
|
|
14
|
-
|
|
15
10
|
## [7.1.0]
|
|
16
11
|
|
|
17
12
|
### Changed
|
|
@@ -85,7 +85,7 @@ export declare class AccountTreeController extends BaseController<typeof control
|
|
|
85
85
|
* by the selector if provided).
|
|
86
86
|
*/
|
|
87
87
|
getAccountsFromSelectedAccountGroup(selector?: AccountSelector<InternalAccount>): {
|
|
88
|
-
type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "
|
|
88
|
+
type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
|
|
89
89
|
id: string;
|
|
90
90
|
options: Record<string, import("@metamask/utils").Json> & {
|
|
91
91
|
entropy?: {
|
|
@@ -85,7 +85,7 @@ export declare class AccountTreeController extends BaseController<typeof control
|
|
|
85
85
|
* by the selector if provided).
|
|
86
86
|
*/
|
|
87
87
|
getAccountsFromSelectedAccountGroup(selector?: AccountSelector<InternalAccount>): {
|
|
88
|
-
type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "
|
|
88
|
+
type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
|
|
89
89
|
id: string;
|
|
90
90
|
options: Record<string, import("@metamask/utils").Json> & {
|
|
91
91
|
entropy?: {
|
package/dist/group.cjs
CHANGED
|
@@ -15,7 +15,6 @@ exports.ACCOUNT_TYPE_TO_SORT_ORDER = {
|
|
|
15
15
|
[keyring_api_1.BtcAccountType.P2wpkh]: 5,
|
|
16
16
|
[keyring_api_1.BtcAccountType.P2tr]: 6,
|
|
17
17
|
[keyring_api_1.TrxAccountType.Eoa]: 7,
|
|
18
|
-
[keyring_api_1.XlmAccountType.Account]: 8,
|
|
19
18
|
[keyring_api_1.AnyAccountType.Account]: exports.MAX_SORT_ORDER,
|
|
20
19
|
};
|
|
21
20
|
/**
|
package/dist/group.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"group.cjs","sourceRoot":"","sources":["../src/group.ts"],"names":[],"mappings":";;;AAMA,
|
|
1
|
+
{"version":3,"file":"group.cjs","sourceRoot":"","sources":["../src/group.ts"],"names":[],"mappings":";;;AAMA,uDAM+B;AAqBlB,QAAA,cAAc,GAAG,IAAI,CAAC;AAEnC;;GAEG;AACU,QAAA,0BAA0B,GAAuC;IAC5E,CAAC,4BAAc,CAAC,GAAG,CAAC,EAAE,CAAC;IACvB,CAAC,4BAAc,CAAC,OAAO,CAAC,EAAE,CAAC;IAC3B,CAAC,4BAAc,CA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AcC","sourcesContent":["import type {\n AccountGroupType,\n MultichainAccountGroupId,\n} from '@metamask/account-api';\nimport type { AccountGroupId } from '@metamask/account-api';\nimport type { AccountId } from '@metamask/accounts-controller';\nimport {\n AnyAccountType,\n BtcAccountType,\n EthAccountType,\n SolAccountType,\n TrxAccountType,\n} from '@metamask/keyring-api';\nimport type { KeyringAccountType } from '@metamask/keyring-api';\n\nimport type { UpdatableField, ExtractFieldValues } from './type-utils';\nimport type { AccountTreeControllerState } from './types';\nimport type { AccountWalletObject } from './wallet';\n\n/**\n * Persisted metadata for account groups (stored in controller state for persistence/sync).\n */\nexport type AccountTreeGroupPersistedMetadata = {\n /** Custom name set by user, overrides default naming logic */\n name?: UpdatableField<string>;\n /** Whether this group is pinned in the UI */\n pinned?: UpdatableField<boolean>;\n /** Whether this group is hidden in the UI */\n hidden?: UpdatableField<boolean>;\n /** Timestamp of the last time this group was selected (local-only, not synced) */\n lastSelected?: number;\n};\n\nexport const MAX_SORT_ORDER = 9999;\n\n/**\n * Order of account types.\n */\nexport const ACCOUNT_TYPE_TO_SORT_ORDER: Record<KeyringAccountType, number> = {\n [EthAccountType.Eoa]: 0,\n [EthAccountType.Erc4337]: 1,\n [SolAccountType.DataAccount]: 2,\n [BtcAccountType.P2pkh]: 3,\n [BtcAccountType.P2sh]: 4,\n [BtcAccountType.P2wpkh]: 5,\n [BtcAccountType.P2tr]: 6,\n [TrxAccountType.Eoa]: 7,\n [AnyAccountType.Account]: MAX_SORT_ORDER,\n};\n\nexport type AccountTypeOrderKey = keyof typeof ACCOUNT_TYPE_TO_SORT_ORDER;\n\n/**\n * Tree metadata for account groups (required plain values extracted from persisted metadata).\n */\nexport type AccountTreeGroupMetadata = Required<\n ExtractFieldValues<AccountTreeGroupPersistedMetadata>\n>;\n\n/**\n * Type constraint for a {@link AccountGroupObject}. If one of its union-members\n * does not match this contraint, {@link AccountGroupObject} will resolve\n * to `never`.\n */\ntype IsAccountGroupObject<\n Type extends {\n type: AccountGroupType;\n id: AccountGroupId;\n accounts: AccountId[];\n metadata: AccountTreeGroupMetadata;\n },\n> = Type;\n\n/**\n * Multichain-account group object.\n */\nexport type AccountGroupMultichainAccountObject = {\n type: AccountGroupType.MultichainAccount;\n id: MultichainAccountGroupId;\n // Blockchain Accounts (at least 1 account per multichain-accounts):\n accounts: [AccountId, ...AccountId[]];\n metadata: AccountTreeGroupMetadata & {\n entropy: {\n groupIndex: number;\n };\n };\n};\n\n/**\n * Multichain-account group object.\n */\nexport type AccountGroupSingleAccountObject = {\n type: AccountGroupType.SingleAccount;\n id: AccountGroupId;\n // Blockchain Accounts (1 account per group):\n accounts: [AccountId];\n metadata: AccountTreeGroupMetadata;\n};\n\n/**\n * Account group object.\n */\nexport type AccountGroupObject = IsAccountGroupObject<\n AccountGroupMultichainAccountObject | AccountGroupSingleAccountObject\n>;\n\nexport type AccountGroupObjectOf<GroupType extends AccountGroupType> = Extract<\n | {\n type: AccountGroupType.MultichainAccount;\n object: AccountGroupMultichainAccountObject;\n }\n | {\n type: AccountGroupType.SingleAccount;\n object: AccountGroupSingleAccountObject;\n },\n { type: GroupType }\n>['object'];\n\n/**\n * Checks if a group name is unique within a specific wallet.\n *\n * @param wallet - The wallet to check within.\n * @param groupId - The account group ID to exclude from the check.\n * @param name - The name to validate for uniqueness.\n * @returns True if the name is unique within the wallet, false otherwise.\n */\nexport function isAccountGroupNameUniqueFromWallet(\n wallet: AccountWalletObject,\n groupId: AccountGroupId,\n name: string,\n): boolean {\n const trimmedName = name.trim();\n\n // Check for duplicates within this wallet\n for (const group of Object.values(wallet.groups)) {\n if (group.id !== groupId && group.metadata.name.trim() === trimmedName) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * Checks if an account group name is unique within the same wallet.\n *\n * @param state - The account tree controller state.\n * @param groupId - The account group ID to exclude from the check.\n * @param name - The name to validate for uniqueness.\n * @returns True if the name is unique within the same wallet, false otherwise.\n * @throws Error if the group ID does not exist.\n */\nexport function isAccountGroupNameUnique(\n state: AccountTreeControllerState,\n groupId: AccountGroupId,\n name: string,\n): boolean {\n // Find the wallet that contains the group being validated\n for (const wallet of Object.values(state.accountTree.wallets)) {\n if (wallet.groups[groupId]) {\n // Use the wallet-specific function for consistency\n return isAccountGroupNameUniqueFromWallet(wallet, groupId, name);\n }\n }\n\n throw new Error('Account group not found in tree');\n}\n"]}
|
package/dist/group.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"group.d.cts","sourceRoot":"","sources":["../src/group.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,wBAAwB,EACzB,8BAA8B;AAC/B,OAAO,KAAK,EAAE,cAAc,EAAE,8BAA8B;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,sCAAsC;
|
|
1
|
+
{"version":3,"file":"group.d.cts","sourceRoot":"","sources":["../src/group.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,wBAAwB,EACzB,8BAA8B;AAC/B,OAAO,KAAK,EAAE,cAAc,EAAE,8BAA8B;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,sCAAsC;AAQ/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,8BAA8B;AAEhE,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,yBAAqB;AACvE,OAAO,KAAK,EAAE,0BAA0B,EAAE,oBAAgB;AAC1D,OAAO,KAAK,EAAE,mBAAmB,EAAE,qBAAiB;AAEpD;;GAEG;AACH,MAAM,MAAM,iCAAiC,GAAG;IAC9C,8DAA8D;IAC9D,IAAI,CAAC,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IAC9B,6CAA6C;IAC7C,MAAM,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC;IACjC,6CAA6C;IAC7C,MAAM,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC;IACjC,kFAAkF;IAClF,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;A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M,EAAE,mCAAmC,CAAC;CAC7C,GACD;IACE,IAAI,EAAE,gBAAgB,CAAC,aAAa,CAAC;IACrC,MAAM,EAAE,+BAA+B,CAAC;CACzC,EACH;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,CACpB,CAAC,QAAQ,CAAC,CAAC;AAEZ;;;;;;;GAOG;AACH,wBAAgB,kCAAkC,CAChD,MAAM,EAAE,mBAAmB,EAC3B,OAAO,EAAE,cAAc,EACvB,IAAI,EAAE,MAAM,GACX,OAAO,CAUT;AAED;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,0BAA0B,EACjC,OAAO,EAAE,cAAc,EACvB,IAAI,EAAE,MAAM,GACX,OAAO,CAUT"}
|
package/dist/group.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"group.d.mts","sourceRoot":"","sources":["../src/group.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,wBAAwB,EACzB,8BAA8B;AAC/B,OAAO,KAAK,EAAE,cAAc,EAAE,8BAA8B;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,sCAAsC;
|
|
1
|
+
{"version":3,"file":"group.d.mts","sourceRoot":"","sources":["../src/group.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,wBAAwB,EACzB,8BAA8B;AAC/B,OAAO,KAAK,EAAE,cAAc,EAAE,8BAA8B;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,sCAAsC;AAQ/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,8BAA8B;AAEhE,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,yBAAqB;AACvE,OAAO,KAAK,EAAE,0BAA0B,EAAE,oBAAgB;AAC1D,OAAO,KAAK,EAAE,mBAAmB,EAAE,qBAAiB;AAEpD;;GAEG;AACH,MAAM,MAAM,iCAAiC,GAAG;IAC9C,8DAA8D;IAC9D,IAAI,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BAAwB,CAAC;CACpC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,oBAAoB,CACnD,mCAAmC,GAAG,+BAA+B,CACtE,CAAC;AAEF,MAAM,MAAM,oBAAoB,CAAC,SAAS,SAAS,gBAAgB,IAAI,OAAO,CAC1E;IACE,IAAI,EAAE,gBAAgB,CAAC,iBAAiB,CAAC;IACzC,MAAM,EAAE,mCAAmC,CAAC;CAC7C,GACD;IACE,IAAI,EAAE,gBAAgB,CAAC,aAAa,CAAC;IACrC,MAAM,EAAE,+BAA+B,CAAC;CACzC,EACH;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,CACpB,CAAC,QAAQ,CAAC,CAAC;AAEZ;;;;;;;GAOG;AACH,wBAAgB,kCAAkC,CAChD,MAAM,EAAE,mBAAmB,EAC3B,OAAO,EAAE,cAAc,EACvB,IAAI,EAAE,MAAM,GACX,OAAO,CAUT;AAED;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,0BAA0B,EACjC,OAAO,EAAE,cAAc,EACvB,IAAI,EAAE,MAAM,GACX,OAAO,CAUT"}
|
package/dist/group.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnyAccountType, BtcAccountType, EthAccountType, SolAccountType, TrxAccountType
|
|
1
|
+
import { AnyAccountType, BtcAccountType, EthAccountType, SolAccountType, TrxAccountType } from "@metamask/keyring-api";
|
|
2
2
|
export const MAX_SORT_ORDER = 9999;
|
|
3
3
|
/**
|
|
4
4
|
* Order of account types.
|
|
@@ -12,7 +12,6 @@ export const ACCOUNT_TYPE_TO_SORT_ORDER = {
|
|
|
12
12
|
[BtcAccountType.P2wpkh]: 5,
|
|
13
13
|
[BtcAccountType.P2tr]: 6,
|
|
14
14
|
[TrxAccountType.Eoa]: 7,
|
|
15
|
-
[XlmAccountType.Account]: 8,
|
|
16
15
|
[AnyAccountType.Account]: MAX_SORT_ORDER,
|
|
17
16
|
};
|
|
18
17
|
/**
|
package/dist/group.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"group.mjs","sourceRoot":"","sources":["../src/group.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,cAAc,EACd,cAAc,EACd,cAAc,EACd,cAAc,EACd,cAAc,
|
|
1
|
+
{"version":3,"file":"group.mjs","sourceRoot":"","sources":["../src/group.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,cAAc,EACd,cAAc,EACd,cAAc,EACd,cAAc,EACd,cAAc,EACf,8BAA8B;AAqB/B,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,CAAC;AAEnC;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAuC;IAC5E,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC;IACvB,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC;IAC3B,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,CAAC;IAC/B,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC;IACzB,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC;IACxB,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC;IAC1B,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC;IACxB,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC;IACvB,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,cAAc;CACzC,CAAC;AAsEF;;;;;;;GAOG;AACH,MAAM,UAAU,kCAAkC,CAChD,MAA2B,EAC3B,OAAuB,EACvB,IAAY;IAEZ,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IAEhC,0CAA0C;IAC1C,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;QACjD,IAAI,KAAK,CAAC,EAAE,KAAK,OAAO,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,WAAW,EAAE,CAAC;YACvE,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,wBAAwB,CACtC,KAAiC,EACjC,OAAuB,EACvB,IAAY;IAEZ,0DAA0D;IAC1D,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC;QAC9D,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;YAC3B,mDAAmD;YACnD,OAAO,kCAAkC,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;AACrD,CAAC","sourcesContent":["import type {\n AccountGroupType,\n MultichainAccountGroupId,\n} from '@metamask/account-api';\nimport type { AccountGroupId } from '@metamask/account-api';\nimport type { AccountId } from '@metamask/accounts-controller';\nimport {\n AnyAccountType,\n BtcAccountType,\n EthAccountType,\n SolAccountType,\n TrxAccountType,\n} from '@metamask/keyring-api';\nimport type { KeyringAccountType } from '@metamask/keyring-api';\n\nimport type { UpdatableField, ExtractFieldValues } from './type-utils';\nimport type { AccountTreeControllerState } from './types';\nimport type { AccountWalletObject } from './wallet';\n\n/**\n * Persisted metadata for account groups (stored in controller state for persistence/sync).\n */\nexport type AccountTreeGroupPersistedMetadata = {\n /** Custom name set by user, overrides default naming logic */\n name?: UpdatableField<string>;\n /** Whether this group is pinned in the UI */\n pinned?: UpdatableField<boolean>;\n /** Whether this group is hidden in the UI */\n hidden?: UpdatableField<boolean>;\n /** Timestamp of the last time this group was selected (local-only, not synced) */\n lastSelected?: number;\n};\n\nexport const MAX_SORT_ORDER = 9999;\n\n/**\n * Order of account types.\n */\nexport const ACCOUNT_TYPE_TO_SORT_ORDER: Record<KeyringAccountType, number> = {\n [EthAccountType.Eoa]: 0,\n [EthAccountType.Erc4337]: 1,\n [SolAccountType.DataAccount]: 2,\n [BtcAccountType.P2pkh]: 3,\n [BtcAccountType.P2sh]: 4,\n [BtcAccountType.P2wpkh]: 5,\n [BtcAccountType.P2tr]: 6,\n [TrxAccountType.Eoa]: 7,\n [AnyAccountType.Account]: MAX_SORT_ORDER,\n};\n\nexport type AccountTypeOrderKey = keyof typeof ACCOUNT_TYPE_TO_SORT_ORDER;\n\n/**\n * Tree metadata for account groups (required plain values extracted from persisted metadata).\n */\nexport type AccountTreeGroupMetadata = Required<\n ExtractFieldValues<AccountTreeGroupPersistedMetadata>\n>;\n\n/**\n * Type constraint for a {@link AccountGroupObject}. If one of its union-members\n * does not match this contraint, {@link AccountGroupObject} will resolve\n * to `never`.\n */\ntype IsAccountGroupObject<\n Type extends {\n type: AccountGroupType;\n id: AccountGroupId;\n accounts: AccountId[];\n metadata: AccountTreeGroupMetadata;\n },\n> = Type;\n\n/**\n * Multichain-account group object.\n */\nexport type AccountGroupMultichainAccountObject = {\n type: AccountGroupType.MultichainAccount;\n id: MultichainAccountGroupId;\n // Blockchain Accounts (at least 1 account per multichain-accounts):\n accounts: [AccountId, ...AccountId[]];\n metadata: AccountTreeGroupMetadata & {\n entropy: {\n groupIndex: number;\n };\n };\n};\n\n/**\n * Multichain-account group object.\n */\nexport type AccountGroupSingleAccountObject = {\n type: AccountGroupType.SingleAccount;\n id: AccountGroupId;\n // Blockchain Accounts (1 account per group):\n accounts: [AccountId];\n metadata: AccountTreeGroupMetadata;\n};\n\n/**\n * Account group object.\n */\nexport type AccountGroupObject = IsAccountGroupObject<\n AccountGroupMultichainAccountObject | AccountGroupSingleAccountObject\n>;\n\nexport type AccountGroupObjectOf<GroupType extends AccountGroupType> = Extract<\n | {\n type: AccountGroupType.MultichainAccount;\n object: AccountGroupMultichainAccountObject;\n }\n | {\n type: AccountGroupType.SingleAccount;\n object: AccountGroupSingleAccountObject;\n },\n { type: GroupType }\n>['object'];\n\n/**\n * Checks if a group name is unique within a specific wallet.\n *\n * @param wallet - The wallet to check within.\n * @param groupId - The account group ID to exclude from the check.\n * @param name - The name to validate for uniqueness.\n * @returns True if the name is unique within the wallet, false otherwise.\n */\nexport function isAccountGroupNameUniqueFromWallet(\n wallet: AccountWalletObject,\n groupId: AccountGroupId,\n name: string,\n): boolean {\n const trimmedName = name.trim();\n\n // Check for duplicates within this wallet\n for (const group of Object.values(wallet.groups)) {\n if (group.id !== groupId && group.metadata.name.trim() === trimmedName) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * Checks if an account group name is unique within the same wallet.\n *\n * @param state - The account tree controller state.\n * @param groupId - The account group ID to exclude from the check.\n * @param name - The name to validate for uniqueness.\n * @returns True if the name is unique within the same wallet, false otherwise.\n * @throws Error if the group ID does not exist.\n */\nexport function isAccountGroupNameUnique(\n state: AccountTreeControllerState,\n groupId: AccountGroupId,\n name: string,\n): boolean {\n // Find the wallet that contains the group being validated\n for (const wallet of Object.values(state.accountTree.wallets)) {\n if (wallet.groups[groupId]) {\n // Use the wallet-specific function for consistency\n return isAccountGroupNameUniqueFromWallet(wallet, groupId, name);\n }\n }\n\n throw new Error('Account group not found in tree');\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask-previews/account-tree-controller",
|
|
3
|
-
"version": "7.1.0-preview-
|
|
3
|
+
"version": "7.1.0-preview-e7ff8e76d",
|
|
4
4
|
"description": "Controller to group account together based on some pre-defined rules",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Ethereum",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"build:docs": "typedoc",
|
|
45
45
|
"changelog:update": "../../scripts/update-changelog.sh @metamask/account-tree-controller",
|
|
46
46
|
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/account-tree-controller",
|
|
47
|
-
"messenger-action-types:check": "tsx ../../packages/messenger-cli/src/cli.ts --
|
|
48
|
-
"messenger-action-types:generate": "tsx ../../packages/messenger-cli/src/cli.ts --
|
|
47
|
+
"messenger-action-types:check": "tsx ../../packages/messenger-cli/src/cli.ts --check",
|
|
48
|
+
"messenger-action-types:generate": "tsx ../../packages/messenger-cli/src/cli.ts --generate",
|
|
49
49
|
"since-latest-release": "../../scripts/since-latest-release.sh",
|
|
50
50
|
"test": "NODE_OPTIONS=--experimental-vm-modules jest --reporters=jest-silent-reporter",
|
|
51
51
|
"test:clean": "NODE_OPTIONS=--experimental-vm-modules jest --clearCache",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"@metamask/accounts-controller": "^37.2.0",
|
|
57
57
|
"@metamask/base-controller": "^9.1.0",
|
|
58
|
-
"@metamask/keyring-api": "^
|
|
58
|
+
"@metamask/keyring-api": "^21.6.0",
|
|
59
59
|
"@metamask/keyring-controller": "^25.2.0",
|
|
60
60
|
"@metamask/messenger": "^1.1.1",
|
|
61
61
|
"@metamask/multichain-account-service": "^8.0.1",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"lodash": "^4.17.21"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
|
-
"@metamask/account-api": "^1.0.
|
|
72
|
+
"@metamask/account-api": "^1.0.0",
|
|
73
73
|
"@metamask/auto-changelog": "^6.1.0",
|
|
74
74
|
"@metamask/providers": "^22.1.0",
|
|
75
75
|
"@ts-bridge/cli": "^0.6.4",
|