@metamask-previews/account-api 0.5.0-0e28ac0 → 0.7.0-58aa483

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,30 @@ 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 `assertIsBip44Account` ([#339](https://github.com/MetaMask/accounts/pull/339))
13
+
14
+ ## [0.7.0]
15
+
16
+ ### Added
17
+
18
+ - Add `AccountProvider.{createAccounts,discoverAndCreateAccounts}` ([#337](https://github.com/MetaMask/accounts/pull/337))
19
+
20
+ ### Changed
21
+
22
+ - **BREAKING:** Rename `getGroupIndexFromMultichainAccountId` to `getGroupIndexFromMultichainAccountGroupId` ([#336](https://github.com/MetaMask/accounts/pull/336))
23
+ - This function was not following the same naming convention (this is an oversight from previous release).
24
+
25
+ ## [0.6.0]
26
+
27
+ ### Changed
28
+
29
+ - **BREAKING:** `MultichainAccount` is now an interface and has been renamed `MultichainAccountGroup` ([#333](https://github.com/MetaMask/accounts/pull/333))
30
+ - Its implementation will be moved to the [`MultichainAccountService`](https://github.com/MetaMask/core/tree/main/packages/multichain-account-service).
31
+ - **BREAKING:** `MultichainAccountWallet` is now an interface ([#333](https://github.com/MetaMask/accounts/pull/333))
32
+ - Its implementation will be moved to the [`MultichainAccountService`](https://github.com/MetaMask/core/tree/main/packages/multichain-account-service).
33
+
10
34
  ## [0.5.0]
11
35
 
12
36
  ### Added
@@ -59,7 +83,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
59
83
 
60
84
  - Add `AccountGroup` and `AccountWallet` ([#307](https://github.com/MetaMask/accounts/pull/307))
61
85
 
62
- [Unreleased]: https://github.com/MetaMask/accounts/compare/@metamask/account-api@0.5.0...HEAD
86
+ [Unreleased]: https://github.com/MetaMask/accounts/compare/@metamask/account-api@0.7.0...HEAD
87
+ [0.7.0]: https://github.com/MetaMask/accounts/compare/@metamask/account-api@0.6.0...@metamask/account-api@0.7.0
88
+ [0.6.0]: https://github.com/MetaMask/accounts/compare/@metamask/account-api@0.5.0...@metamask/account-api@0.6.0
63
89
  [0.5.0]: https://github.com/MetaMask/accounts/compare/@metamask/account-api@0.4.0...@metamask/account-api@0.5.0
64
90
  [0.4.0]: https://github.com/MetaMask/accounts/compare/@metamask/account-api@0.3.0...@metamask/account-api@0.4.0
65
91
  [0.3.0]: https://github.com/MetaMask/accounts/compare/@metamask/account-api@0.2.0...@metamask/account-api@0.3.0
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isBip44Account = isBip44Account;
4
+ exports.assertIsBip44Account = assertIsBip44Account;
4
5
  const keyring_api_1 = require("@metamask/keyring-api");
5
6
  const superstruct_1 = require("@metamask/superstruct");
6
7
  /**
@@ -13,4 +14,15 @@ function isBip44Account(account) {
13
14
  // To be BIP-44 compatible, you just need to use this set of options:
14
15
  return (0, superstruct_1.is)(account.options.entropy, keyring_api_1.KeyringAccountEntropyMnemonicOptionsStruct);
15
16
  }
17
+ /**
18
+ * Asserts a keyring account is BIP-44 compatible.
19
+ *
20
+ * @param account - Keyring account to check.
21
+ * @throws If the keyring account is not compatible.
22
+ */
23
+ function assertIsBip44Account(account) {
24
+ if (!isBip44Account(account)) {
25
+ throw new Error('Account is not BIP-44 compatible');
26
+ }
27
+ }
16
28
  //# sourceMappingURL=bip44.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"bip44.cjs","sourceRoot":"","sources":["../../src/api/bip44.ts"],"names":[],"mappings":";;AAwBA,wCAQC;AA5BD,uDAAmF;AACnF,uDAA2C;AAa3C;;;;;GAKG;AACH,SAAgB,cAAc,CAC5B,OAAgB;IAEhB,qEAAqE;IACrE,OAAO,IAAA,gBAAE,EACP,OAAO,CAAC,OAAO,CAAC,OAAO,EACvB,wDAA0C,CAC3C,CAAC;AACJ,CAAC","sourcesContent":["import type {\n KeyringAccount,\n KeyringAccountEntropyMnemonicOptions,\n} from '@metamask/keyring-api';\nimport { KeyringAccountEntropyMnemonicOptionsStruct } from '@metamask/keyring-api';\nimport { is } from '@metamask/superstruct';\n\n/**\n * BIP-44 compatible account type.\n */\nexport type Bip44Account<Account extends KeyringAccount> = Account & {\n // We force the option type for those accounts. (That's how we identify\n // if an account is BIP-44 compatible).\n options: {\n entropy: KeyringAccountEntropyMnemonicOptions;\n };\n};\n\n/**\n * Checks if an account is BIP-44 compatible.\n *\n * @param account - The account to be tested.\n * @returns True if the account is BIP-44 compatible.\n */\nexport function isBip44Account<Account extends KeyringAccount>(\n account: Account,\n): account is Bip44Account<Account> {\n // To be BIP-44 compatible, you just need to use this set of options:\n return is(\n account.options.entropy,\n KeyringAccountEntropyMnemonicOptionsStruct,\n );\n}\n"]}
1
+ {"version":3,"file":"bip44.cjs","sourceRoot":"","sources":["../../src/api/bip44.ts"],"names":[],"mappings":";;AAwBA,wCAQC;AAQD,oDAMC;AA1CD,uDAAmF;AACnF,uDAA2C;AAa3C;;;;;GAKG;AACH,SAAgB,cAAc,CAC5B,OAAgB;IAEhB,qEAAqE;IACrE,OAAO,IAAA,gBAAE,EACP,OAAO,CAAC,OAAO,CAAC,OAAO,EACvB,wDAA0C,CAC3C,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAgB,oBAAoB,CAClC,OAAgB;IAEhB,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;IACtD,CAAC;AACH,CAAC","sourcesContent":["import type {\n KeyringAccount,\n KeyringAccountEntropyMnemonicOptions,\n} from '@metamask/keyring-api';\nimport { KeyringAccountEntropyMnemonicOptionsStruct } from '@metamask/keyring-api';\nimport { is } from '@metamask/superstruct';\n\n/**\n * BIP-44 compatible account type.\n */\nexport type Bip44Account<Account extends KeyringAccount> = Account & {\n // We force the option type for those accounts. (That's how we identify\n // if an account is BIP-44 compatible).\n options: {\n entropy: KeyringAccountEntropyMnemonicOptions;\n };\n};\n\n/**\n * Checks if an account is BIP-44 compatible.\n *\n * @param account - The account to be tested.\n * @returns True if the account is BIP-44 compatible.\n */\nexport function isBip44Account<Account extends KeyringAccount>(\n account: Account,\n): account is Bip44Account<Account> {\n // To be BIP-44 compatible, you just need to use this set of options:\n return is(\n account.options.entropy,\n KeyringAccountEntropyMnemonicOptionsStruct,\n );\n}\n\n/**\n * Asserts a keyring account is BIP-44 compatible.\n *\n * @param account - Keyring account to check.\n * @throws If the keyring account is not compatible.\n */\nexport function assertIsBip44Account<Account extends KeyringAccount>(\n account: Account,\n): asserts account is Bip44Account<Account> {\n if (!isBip44Account(account)) {\n throw new Error('Account is not BIP-44 compatible');\n }\n}\n"]}
@@ -14,4 +14,11 @@ export type Bip44Account<Account extends KeyringAccount> = Account & {
14
14
  * @returns True if the account is BIP-44 compatible.
15
15
  */
16
16
  export declare function isBip44Account<Account extends KeyringAccount>(account: Account): account is Bip44Account<Account>;
17
+ /**
18
+ * Asserts a keyring account is BIP-44 compatible.
19
+ *
20
+ * @param account - Keyring account to check.
21
+ * @throws If the keyring account is not compatible.
22
+ */
23
+ export declare function assertIsBip44Account<Account extends KeyringAccount>(account: Account): asserts account is Bip44Account<Account>;
17
24
  //# sourceMappingURL=bip44.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bip44.d.cts","sourceRoot":"","sources":["../../src/api/bip44.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,oCAAoC,EACrC,8BAA8B;AAI/B;;GAEG;AACH,MAAM,MAAM,YAAY,CAAC,OAAO,SAAS,cAAc,IAAI,OAAO,GAAG;IAGnE,OAAO,EAAE;QACP,OAAO,EAAE,oCAAoC,CAAC;KAC/C,CAAC;CACH,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,OAAO,SAAS,cAAc,EAC3D,OAAO,EAAE,OAAO,GACf,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,CAMlC"}
1
+ {"version":3,"file":"bip44.d.cts","sourceRoot":"","sources":["../../src/api/bip44.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,oCAAoC,EACrC,8BAA8B;AAI/B;;GAEG;AACH,MAAM,MAAM,YAAY,CAAC,OAAO,SAAS,cAAc,IAAI,OAAO,GAAG;IAGnE,OAAO,EAAE;QACP,OAAO,EAAE,oCAAoC,CAAC;KAC/C,CAAC;CACH,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,OAAO,SAAS,cAAc,EAC3D,OAAO,EAAE,OAAO,GACf,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,CAMlC;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,SAAS,cAAc,EACjE,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,CAI1C"}
@@ -14,4 +14,11 @@ export type Bip44Account<Account extends KeyringAccount> = Account & {
14
14
  * @returns True if the account is BIP-44 compatible.
15
15
  */
16
16
  export declare function isBip44Account<Account extends KeyringAccount>(account: Account): account is Bip44Account<Account>;
17
+ /**
18
+ * Asserts a keyring account is BIP-44 compatible.
19
+ *
20
+ * @param account - Keyring account to check.
21
+ * @throws If the keyring account is not compatible.
22
+ */
23
+ export declare function assertIsBip44Account<Account extends KeyringAccount>(account: Account): asserts account is Bip44Account<Account>;
17
24
  //# sourceMappingURL=bip44.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bip44.d.mts","sourceRoot":"","sources":["../../src/api/bip44.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,oCAAoC,EACrC,8BAA8B;AAI/B;;GAEG;AACH,MAAM,MAAM,YAAY,CAAC,OAAO,SAAS,cAAc,IAAI,OAAO,GAAG;IAGnE,OAAO,EAAE;QACP,OAAO,EAAE,oCAAoC,CAAC;KAC/C,CAAC;CACH,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,OAAO,SAAS,cAAc,EAC3D,OAAO,EAAE,OAAO,GACf,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,CAMlC"}
1
+ {"version":3,"file":"bip44.d.mts","sourceRoot":"","sources":["../../src/api/bip44.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,oCAAoC,EACrC,8BAA8B;AAI/B;;GAEG;AACH,MAAM,MAAM,YAAY,CAAC,OAAO,SAAS,cAAc,IAAI,OAAO,GAAG;IAGnE,OAAO,EAAE;QACP,OAAO,EAAE,oCAAoC,CAAC;KAC/C,CAAC;CACH,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,OAAO,SAAS,cAAc,EAC3D,OAAO,EAAE,OAAO,GACf,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,CAMlC;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,SAAS,cAAc,EACjE,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,CAI1C"}
@@ -10,4 +10,15 @@ export function isBip44Account(account) {
10
10
  // To be BIP-44 compatible, you just need to use this set of options:
11
11
  return is(account.options.entropy, KeyringAccountEntropyMnemonicOptionsStruct);
12
12
  }
13
+ /**
14
+ * Asserts a keyring account is BIP-44 compatible.
15
+ *
16
+ * @param account - Keyring account to check.
17
+ * @throws If the keyring account is not compatible.
18
+ */
19
+ export function assertIsBip44Account(account) {
20
+ if (!isBip44Account(account)) {
21
+ throw new Error('Account is not BIP-44 compatible');
22
+ }
23
+ }
13
24
  //# sourceMappingURL=bip44.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"bip44.mjs","sourceRoot":"","sources":["../../src/api/bip44.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,0CAA0C,EAAE,8BAA8B;AACnF,OAAO,EAAE,EAAE,EAAE,8BAA8B;AAa3C;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAC5B,OAAgB;IAEhB,qEAAqE;IACrE,OAAO,EAAE,CACP,OAAO,CAAC,OAAO,CAAC,OAAO,EACvB,0CAA0C,CAC3C,CAAC;AACJ,CAAC","sourcesContent":["import type {\n KeyringAccount,\n KeyringAccountEntropyMnemonicOptions,\n} from '@metamask/keyring-api';\nimport { KeyringAccountEntropyMnemonicOptionsStruct } from '@metamask/keyring-api';\nimport { is } from '@metamask/superstruct';\n\n/**\n * BIP-44 compatible account type.\n */\nexport type Bip44Account<Account extends KeyringAccount> = Account & {\n // We force the option type for those accounts. (That's how we identify\n // if an account is BIP-44 compatible).\n options: {\n entropy: KeyringAccountEntropyMnemonicOptions;\n };\n};\n\n/**\n * Checks if an account is BIP-44 compatible.\n *\n * @param account - The account to be tested.\n * @returns True if the account is BIP-44 compatible.\n */\nexport function isBip44Account<Account extends KeyringAccount>(\n account: Account,\n): account is Bip44Account<Account> {\n // To be BIP-44 compatible, you just need to use this set of options:\n return is(\n account.options.entropy,\n KeyringAccountEntropyMnemonicOptionsStruct,\n );\n}\n"]}
1
+ {"version":3,"file":"bip44.mjs","sourceRoot":"","sources":["../../src/api/bip44.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,0CAA0C,EAAE,8BAA8B;AACnF,OAAO,EAAE,EAAE,EAAE,8BAA8B;AAa3C;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAC5B,OAAgB;IAEhB,qEAAqE;IACrE,OAAO,EAAE,CACP,OAAO,CAAC,OAAO,CAAC,OAAO,EACvB,0CAA0C,CAC3C,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAClC,OAAgB;IAEhB,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;IACtD,CAAC;AACH,CAAC","sourcesContent":["import type {\n KeyringAccount,\n KeyringAccountEntropyMnemonicOptions,\n} from '@metamask/keyring-api';\nimport { KeyringAccountEntropyMnemonicOptionsStruct } from '@metamask/keyring-api';\nimport { is } from '@metamask/superstruct';\n\n/**\n * BIP-44 compatible account type.\n */\nexport type Bip44Account<Account extends KeyringAccount> = Account & {\n // We force the option type for those accounts. (That's how we identify\n // if an account is BIP-44 compatible).\n options: {\n entropy: KeyringAccountEntropyMnemonicOptions;\n };\n};\n\n/**\n * Checks if an account is BIP-44 compatible.\n *\n * @param account - The account to be tested.\n * @returns True if the account is BIP-44 compatible.\n */\nexport function isBip44Account<Account extends KeyringAccount>(\n account: Account,\n): account is Bip44Account<Account> {\n // To be BIP-44 compatible, you just need to use this set of options:\n return is(\n account.options.entropy,\n KeyringAccountEntropyMnemonicOptionsStruct,\n );\n}\n\n/**\n * Asserts a keyring account is BIP-44 compatible.\n *\n * @param account - Keyring account to check.\n * @throws If the keyring account is not compatible.\n */\nexport function assertIsBip44Account<Account extends KeyringAccount>(\n account: Account,\n): asserts account is Bip44Account<Account> {\n if (!isBip44Account(account)) {\n throw new Error('Account is not BIP-44 compatible');\n }\n}\n"]}
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.toMultichainAccountGroupId = toMultichainAccountGroupId;
4
4
  exports.isMultichainAccountGroupId = isMultichainAccountGroupId;
5
- exports.getGroupIndexFromMultichainAccountId = getGroupIndexFromMultichainAccountId;
5
+ exports.getGroupIndexFromMultichainAccountGroupId = getGroupIndexFromMultichainAccountGroupId;
6
6
  const wallet_1 = require("../wallet.cjs");
7
7
  const MULTICHAIN_ACCOUNT_GROUP_ID_REGEX = new RegExp(`^${wallet_1.AccountWalletType.Entropy}:.*/(?<groupIndex>\\d+)$`, 'u');
8
8
  /**
@@ -30,7 +30,7 @@ function isMultichainAccountGroupId(value) {
30
30
  * @param id - Multichain account ID.
31
31
  * @returns The multichain account index if extractable, undefined otherwise.
32
32
  */
33
- function getGroupIndexFromMultichainAccountId(id) {
33
+ function getGroupIndexFromMultichainAccountGroupId(id) {
34
34
  const matched = id.match(MULTICHAIN_ACCOUNT_GROUP_ID_REGEX);
35
35
  if (matched?.groups?.groupIndex === undefined) {
36
36
  // Unable to extract group index, even though, type wise, this should not
@@ -1 +1 @@
1
- {"version":3,"file":"group.cjs","sourceRoot":"","sources":["../../../src/api/multichain/group.ts"],"names":[],"mappings":";;AAwEA,gEAKC;AAQD,gEAIC;AAQD,oFAWC;AAnGD,0CAA8C;AAE9C,MAAM,iCAAiC,GAAG,IAAI,MAAM,CAClD,IAAI,0BAAiB,CAAC,OAAO,0BAA0B,EACvD,GAAG,CACJ,CAAC;AAmDF;;;;;;GAMG;AACH,SAAgB,0BAA0B,CACxC,QAAmC,EACnC,UAAkB;IAElB,OAAO,GAAG,QAAQ,IAAI,UAAU,EAAE,CAAC;AACrC,CAAC;AAED;;;;;GAKG;AACH,SAAgB,0BAA0B,CACxC,KAAa;IAEb,OAAO,iCAAiC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACvD,CAAC;AAED;;;;;GAKG;AACH,SAAgB,oCAAoC,CAClD,EAA4B;IAE5B,MAAM,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC,iCAAiC,CAAC,CAAC;IAC5D,IAAI,OAAO,EAAE,MAAM,EAAE,UAAU,KAAK,SAAS,EAAE,CAAC;QAC9C,yEAAyE;QACzE,eAAe;QACf,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;IACnD,CAAC;IAED,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;AAC3C,CAAC","sourcesContent":["import { type KeyringAccount } from '@metamask/keyring-api';\n\nimport type {\n MultichainAccountWallet,\n MultichainAccountWalletId,\n} from './wallet';\nimport type { Bip44Account } from '../bip44';\nimport type { AccountGroup, AccountGroupType } from '../group';\nimport type { AccountSelector } from '../selector';\nimport { AccountWalletType } from '../wallet';\n\nconst MULTICHAIN_ACCOUNT_GROUP_ID_REGEX = new RegExp(\n `^${AccountWalletType.Entropy}:.*/(?<groupIndex>\\\\d+)$`,\n 'u',\n);\n\n/**\n * Multichain account ID.\n */\nexport type MultichainAccountGroupId = `${MultichainAccountWalletId}/${number}`; // Use number for the account group index.\n\n/**\n * A multichain account that holds multiple accounts.\n */\nexport type MultichainAccountGroup<\n Account extends Bip44Account<KeyringAccount>,\n> = AccountGroup<Account> & {\n /**\n * Multichain account group ID.\n */\n get id(): MultichainAccountGroupId;\n\n /**\n * Multichain account type.\n */\n get type(): AccountGroupType.MultichainAccount;\n\n /**\n * Multichain account's wallet reference (parent).\n */\n get wallet(): MultichainAccountWallet<Account>;\n\n /**\n * Multichain account group index.\n */\n get index(): number;\n\n /**\n * Query an account matching the selector.\n *\n * @param selector - Query selector.\n * @returns The account matching the selector or undefined if not matching.\n * @throws If multiple accounts match the selector.\n */\n get(selector: AccountSelector<Account>): Account | undefined;\n\n /**\n * Query accounts matching the selector.\n *\n * @param selector - Query selector.\n * @returns The accounts matching the selector.\n */\n select(selector: AccountSelector<Account>): Account[];\n};\n\n/**\n * Gets the multichain account group ID from its multichain account wallet ID and its index.\n *\n * @param walletId - Multichain account wallet ID.\n * @param groupIndex - Index of that multichain account.\n * @returns The multichain account ID.\n */\nexport function toMultichainAccountGroupId(\n walletId: MultichainAccountWalletId,\n groupIndex: number,\n): MultichainAccountGroupId {\n return `${walletId}/${groupIndex}`;\n}\n\n/**\n * Checks if the given value is {@link MultichainAccountGroupId}.\n *\n * @param value - The value to check.\n * @returns Whether the value is a {@link MultichainAccountGroupId}.\n */\nexport function isMultichainAccountGroupId(\n value: string,\n): value is MultichainAccountGroupId {\n return MULTICHAIN_ACCOUNT_GROUP_ID_REGEX.test(value);\n}\n\n/**\n * Gets the multichain account index from an account group ID.\n *\n * @param id - Multichain account ID.\n * @returns The multichain account index if extractable, undefined otherwise.\n */\nexport function getGroupIndexFromMultichainAccountId(\n id: MultichainAccountGroupId,\n): number {\n const matched = id.match(MULTICHAIN_ACCOUNT_GROUP_ID_REGEX);\n if (matched?.groups?.groupIndex === undefined) {\n // Unable to extract group index, even though, type wise, this should not\n // be possible!\n throw new Error('Unable to extract group index');\n }\n\n return Number(matched.groups.groupIndex);\n}\n"]}
1
+ {"version":3,"file":"group.cjs","sourceRoot":"","sources":["../../../src/api/multichain/group.ts"],"names":[],"mappings":";;AAwEA,gEAKC;AAQD,gEAIC;AAQD,8FAWC;AAnGD,0CAA8C;AAE9C,MAAM,iCAAiC,GAAG,IAAI,MAAM,CAClD,IAAI,0BAAiB,CAAC,OAAO,0BAA0B,EACvD,GAAG,CACJ,CAAC;AAmDF;;;;;;GAMG;AACH,SAAgB,0BAA0B,CACxC,QAAmC,EACnC,UAAkB;IAElB,OAAO,GAAG,QAAQ,IAAI,UAAU,EAAE,CAAC;AACrC,CAAC;AAED;;;;;GAKG;AACH,SAAgB,0BAA0B,CACxC,KAAa;IAEb,OAAO,iCAAiC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACvD,CAAC;AAED;;;;;GAKG;AACH,SAAgB,yCAAyC,CACvD,EAA4B;IAE5B,MAAM,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC,iCAAiC,CAAC,CAAC;IAC5D,IAAI,OAAO,EAAE,MAAM,EAAE,UAAU,KAAK,SAAS,EAAE,CAAC;QAC9C,yEAAyE;QACzE,eAAe;QACf,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;IACnD,CAAC;IAED,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;AAC3C,CAAC","sourcesContent":["import { type KeyringAccount } from '@metamask/keyring-api';\n\nimport type {\n MultichainAccountWallet,\n MultichainAccountWalletId,\n} from './wallet';\nimport type { Bip44Account } from '../bip44';\nimport type { AccountGroup, AccountGroupType } from '../group';\nimport type { AccountSelector } from '../selector';\nimport { AccountWalletType } from '../wallet';\n\nconst MULTICHAIN_ACCOUNT_GROUP_ID_REGEX = new RegExp(\n `^${AccountWalletType.Entropy}:.*/(?<groupIndex>\\\\d+)$`,\n 'u',\n);\n\n/**\n * Multichain account ID.\n */\nexport type MultichainAccountGroupId = `${MultichainAccountWalletId}/${number}`; // Use number for the account group index.\n\n/**\n * A multichain account that holds multiple accounts.\n */\nexport type MultichainAccountGroup<\n Account extends Bip44Account<KeyringAccount>,\n> = AccountGroup<Account> & {\n /**\n * Multichain account group ID.\n */\n get id(): MultichainAccountGroupId;\n\n /**\n * Multichain account type.\n */\n get type(): AccountGroupType.MultichainAccount;\n\n /**\n * Multichain account's wallet reference (parent).\n */\n get wallet(): MultichainAccountWallet<Account>;\n\n /**\n * Multichain account group index.\n */\n get index(): number;\n\n /**\n * Query an account matching the selector.\n *\n * @param selector - Query selector.\n * @returns The account matching the selector or undefined if not matching.\n * @throws If multiple accounts match the selector.\n */\n get(selector: AccountSelector<Account>): Account | undefined;\n\n /**\n * Query accounts matching the selector.\n *\n * @param selector - Query selector.\n * @returns The accounts matching the selector.\n */\n select(selector: AccountSelector<Account>): Account[];\n};\n\n/**\n * Gets the multichain account group ID from its multichain account wallet ID and its index.\n *\n * @param walletId - Multichain account wallet ID.\n * @param groupIndex - Index of that multichain account.\n * @returns The multichain account ID.\n */\nexport function toMultichainAccountGroupId(\n walletId: MultichainAccountWalletId,\n groupIndex: number,\n): MultichainAccountGroupId {\n return `${walletId}/${groupIndex}`;\n}\n\n/**\n * Checks if the given value is {@link MultichainAccountGroupId}.\n *\n * @param value - The value to check.\n * @returns Whether the value is a {@link MultichainAccountGroupId}.\n */\nexport function isMultichainAccountGroupId(\n value: string,\n): value is MultichainAccountGroupId {\n return MULTICHAIN_ACCOUNT_GROUP_ID_REGEX.test(value);\n}\n\n/**\n * Gets the multichain account index from an account group ID.\n *\n * @param id - Multichain account ID.\n * @returns The multichain account index if extractable, undefined otherwise.\n */\nexport function getGroupIndexFromMultichainAccountGroupId(\n id: MultichainAccountGroupId,\n): number {\n const matched = id.match(MULTICHAIN_ACCOUNT_GROUP_ID_REGEX);\n if (matched?.groups?.groupIndex === undefined) {\n // Unable to extract group index, even though, type wise, this should not\n // be possible!\n throw new Error('Unable to extract group index');\n }\n\n return Number(matched.groups.groupIndex);\n}\n"]}
@@ -64,5 +64,5 @@ export declare function isMultichainAccountGroupId(value: string): value is Mult
64
64
  * @param id - Multichain account ID.
65
65
  * @returns The multichain account index if extractable, undefined otherwise.
66
66
  */
67
- export declare function getGroupIndexFromMultichainAccountId(id: MultichainAccountGroupId): number;
67
+ export declare function getGroupIndexFromMultichainAccountGroupId(id: MultichainAccountGroupId): number;
68
68
  //# sourceMappingURL=group.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"group.d.cts","sourceRoot":"","sources":["../../../src/api/multichain/group.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,8BAA8B;AAE5D,OAAO,KAAK,EACV,uBAAuB,EACvB,yBAAyB,EAC1B,qBAAiB;AAClB,OAAO,KAAK,EAAE,YAAY,EAAE,qBAAiB;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,qBAAiB;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,wBAAoB;AAQnD;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,GAAG,yBAAyB,IAAI,MAAM,EAAE,CAAC;AAEhF;;GAEG;AACH,MAAM,MAAM,sBAAsB,CAChC,OAAO,SAAS,YAAY,CAAC,cAAc,CAAC,IAC1C,YAAY,CAAC,OAAO,CAAC,GAAG;IAC1B;;OAEG;IACH,IAAI,EAAE,IAAI,wBAAwB,CAAC;IAEnC;;OAEG;IACH,IAAI,IAAI,IAAI,gBAAgB,CAAC,iBAAiB,CAAC;IAE/C;;OAEG;IACH,IAAI,MAAM,IAAI,uBAAuB,CAAC,OAAO,CAAC,CAAC;IAE/C;;OAEG;IACH,IAAI,KAAK,IAAI,MAAM,CAAC;IAEpB;;;;;;OAMG;IACH,GAAG,CAAC,QAAQ,EAAE,e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;;;;;;OAMG;IACH,GAAG,CAAC,QAAQ,EAAE,eAAe,CAAC,OAAO,CAAC,GAAG,OAAO,GAAG,SAAS,CAAC;IAE7D;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,EAAE,eAAe,CAAC,OAAO,CAAC,GAAG,OAAO,EAAE,CAAC;CACvD,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,yBAAyB,EACnC,UAAU,EAAE,MAAM,GACjB,wBAAwB,CAE1B;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,MAAM,GACZ,KAAK,IAAI,wBAAwB,CAEnC;AAED;;;;;GAKG;AACH,wBAAgB,yCAAyC,CACvD,EAAE,EAAE,wBAAwB,GAC3B,MAAM,CASR"}
@@ -64,5 +64,5 @@ export declare function isMultichainAccountGroupId(value: string): value is Mult
64
64
  * @param id - Multichain account ID.
65
65
  * @returns The multichain account index if extractable, undefined otherwise.
66
66
  */
67
- export declare function getGroupIndexFromMultichainAccountId(id: MultichainAccountGroupId): number;
67
+ export declare function getGroupIndexFromMultichainAccountGroupId(id: MultichainAccountGroupId): number;
68
68
  //# sourceMappingURL=group.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"group.d.mts","sourceRoot":"","sources":["../../../src/api/multichain/group.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,8BAA8B;AAE5D,OAAO,KAAK,EACV,uBAAuB,EACvB,yBAAyB,EAC1B,qBAAiB;AAClB,OAAO,KAAK,EAAE,YAAY,EAAE,qBAAiB;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,qBAAiB;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,wBAAoB;AAQnD;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,GAAG,yBAAyB,IAAI,MAAM,EAAE,CAAC;AAEhF;;GAEG;AACH,MAAM,MAAM,sBAAsB,CAChC,OAAO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;;GAEG;AACH,MAAM,MAAM,sBAAsB,CAChC,OAAO,SAAS,YAAY,CAAC,cAAc,CAAC,IAC1C,YAAY,CAAC,OAAO,CAAC,GAAG;IAC1B;;OAEG;IACH,IAAI,EAAE,IAAI,wBAAwB,CAAC;IAEnC;;OAEG;IACH,IAAI,IAAI,IAAI,gBAAgB,CAAC,iBAAiB,CAAC;IAE/C;;OAEG;IACH,IAAI,MAAM,IAAI,uBAAuB,CAAC,OAAO,CAAC,CAAC;IAE/C;;OAEG;IACH,IAAI,KAAK,IAAI,MAAM,CAAC;IAEpB;;;;;;OAMG;IACH,GAAG,CAAC,QAAQ,EAAE,eAAe,CAAC,OAAO,CAAC,GAAG,OAAO,GAAG,SAAS,CAAC;IAE7D;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,EAAE,eAAe,CAAC,OAAO,CAAC,GAAG,OAAO,EAAE,CAAC;CACvD,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,yBAAyB,EACnC,UAAU,EAAE,MAAM,GACjB,wBAAwB,CAE1B;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,MAAM,GACZ,KAAK,IAAI,wBAAwB,CAEnC;AAED;;;;;GAKG;AACH,wBAAgB,yCAAyC,CACvD,EAAE,EAAE,wBAAwB,GAC3B,MAAM,CASR"}
@@ -25,7 +25,7 @@ export function isMultichainAccountGroupId(value) {
25
25
  * @param id - Multichain account ID.
26
26
  * @returns The multichain account index if extractable, undefined otherwise.
27
27
  */
28
- export function getGroupIndexFromMultichainAccountId(id) {
28
+ export function getGroupIndexFromMultichainAccountGroupId(id) {
29
29
  const matched = id.match(MULTICHAIN_ACCOUNT_GROUP_ID_REGEX);
30
30
  if (matched?.groups?.groupIndex === undefined) {
31
31
  // Unable to extract group index, even though, type wise, this should not
@@ -1 +1 @@
1
- {"version":3,"file":"group.mjs","sourceRoot":"","sources":["../../../src/api/multichain/group.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,iBAAiB,EAAE,sBAAkB;AAE9C,MAAM,iCAAiC,GAAG,IAAI,MAAM,CAClD,IAAI,iBAAiB,CAAC,OAAO,0BAA0B,EACvD,GAAG,CACJ,CAAC;AAmDF;;;;;;GAMG;AACH,MAAM,UAAU,0BAA0B,CACxC,QAAmC,EACnC,UAAkB;IAElB,OAAO,GAAG,QAAQ,IAAI,UAAU,EAAE,CAAC;AACrC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,0BAA0B,CACxC,KAAa;IAEb,OAAO,iCAAiC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACvD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oCAAoC,CAClD,EAA4B;IAE5B,MAAM,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC,iCAAiC,CAAC,CAAC;IAC5D,IAAI,OAAO,EAAE,MAAM,EAAE,UAAU,KAAK,SAAS,EAAE,CAAC;QAC9C,yEAAyE;QACzE,eAAe;QACf,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;IACnD,CAAC;IAED,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;AAC3C,CAAC","sourcesContent":["import { type KeyringAccount } from '@metamask/keyring-api';\n\nimport type {\n MultichainAccountWallet,\n MultichainAccountWalletId,\n} from './wallet';\nimport type { Bip44Account } from '../bip44';\nimport type { AccountGroup, AccountGroupType } from '../group';\nimport type { AccountSelector } from '../selector';\nimport { AccountWalletType } from '../wallet';\n\nconst MULTICHAIN_ACCOUNT_GROUP_ID_REGEX = new RegExp(\n `^${AccountWalletType.Entropy}:.*/(?<groupIndex>\\\\d+)$`,\n 'u',\n);\n\n/**\n * Multichain account ID.\n */\nexport type MultichainAccountGroupId = `${MultichainAccountWalletId}/${number}`; // Use number for the account group index.\n\n/**\n * A multichain account that holds multiple accounts.\n */\nexport type MultichainAccountGroup<\n Account extends Bip44Account<KeyringAccount>,\n> = AccountGroup<Account> & {\n /**\n * Multichain account group ID.\n */\n get id(): MultichainAccountGroupId;\n\n /**\n * Multichain account type.\n */\n get type(): AccountGroupType.MultichainAccount;\n\n /**\n * Multichain account's wallet reference (parent).\n */\n get wallet(): MultichainAccountWallet<Account>;\n\n /**\n * Multichain account group index.\n */\n get index(): number;\n\n /**\n * Query an account matching the selector.\n *\n * @param selector - Query selector.\n * @returns The account matching the selector or undefined if not matching.\n * @throws If multiple accounts match the selector.\n */\n get(selector: AccountSelector<Account>): Account | undefined;\n\n /**\n * Query accounts matching the selector.\n *\n * @param selector - Query selector.\n * @returns The accounts matching the selector.\n */\n select(selector: AccountSelector<Account>): Account[];\n};\n\n/**\n * Gets the multichain account group ID from its multichain account wallet ID and its index.\n *\n * @param walletId - Multichain account wallet ID.\n * @param groupIndex - Index of that multichain account.\n * @returns The multichain account ID.\n */\nexport function toMultichainAccountGroupId(\n walletId: MultichainAccountWalletId,\n groupIndex: number,\n): MultichainAccountGroupId {\n return `${walletId}/${groupIndex}`;\n}\n\n/**\n * Checks if the given value is {@link MultichainAccountGroupId}.\n *\n * @param value - The value to check.\n * @returns Whether the value is a {@link MultichainAccountGroupId}.\n */\nexport function isMultichainAccountGroupId(\n value: string,\n): value is MultichainAccountGroupId {\n return MULTICHAIN_ACCOUNT_GROUP_ID_REGEX.test(value);\n}\n\n/**\n * Gets the multichain account index from an account group ID.\n *\n * @param id - Multichain account ID.\n * @returns The multichain account index if extractable, undefined otherwise.\n */\nexport function getGroupIndexFromMultichainAccountId(\n id: MultichainAccountGroupId,\n): number {\n const matched = id.match(MULTICHAIN_ACCOUNT_GROUP_ID_REGEX);\n if (matched?.groups?.groupIndex === undefined) {\n // Unable to extract group index, even though, type wise, this should not\n // be possible!\n throw new Error('Unable to extract group index');\n }\n\n return Number(matched.groups.groupIndex);\n}\n"]}
1
+ {"version":3,"file":"group.mjs","sourceRoot":"","sources":["../../../src/api/multichain/group.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,iBAAiB,EAAE,sBAAkB;AAE9C,MAAM,iCAAiC,GAAG,IAAI,MAAM,CAClD,IAAI,iBAAiB,CAAC,OAAO,0BAA0B,EACvD,GAAG,CACJ,CAAC;AAmDF;;;;;;GAMG;AACH,MAAM,UAAU,0BAA0B,CACxC,QAAmC,EACnC,UAAkB;IAElB,OAAO,GAAG,QAAQ,IAAI,UAAU,EAAE,CAAC;AACrC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,0BAA0B,CACxC,KAAa;IAEb,OAAO,iCAAiC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACvD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,yCAAyC,CACvD,EAA4B;IAE5B,MAAM,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC,iCAAiC,CAAC,CAAC;IAC5D,IAAI,OAAO,EAAE,MAAM,EAAE,UAAU,KAAK,SAAS,EAAE,CAAC;QAC9C,yEAAyE;QACzE,eAAe;QACf,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;IACnD,CAAC;IAED,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;AAC3C,CAAC","sourcesContent":["import { type KeyringAccount } from '@metamask/keyring-api';\n\nimport type {\n MultichainAccountWallet,\n MultichainAccountWalletId,\n} from './wallet';\nimport type { Bip44Account } from '../bip44';\nimport type { AccountGroup, AccountGroupType } from '../group';\nimport type { AccountSelector } from '../selector';\nimport { AccountWalletType } from '../wallet';\n\nconst MULTICHAIN_ACCOUNT_GROUP_ID_REGEX = new RegExp(\n `^${AccountWalletType.Entropy}:.*/(?<groupIndex>\\\\d+)$`,\n 'u',\n);\n\n/**\n * Multichain account ID.\n */\nexport type MultichainAccountGroupId = `${MultichainAccountWalletId}/${number}`; // Use number for the account group index.\n\n/**\n * A multichain account that holds multiple accounts.\n */\nexport type MultichainAccountGroup<\n Account extends Bip44Account<KeyringAccount>,\n> = AccountGroup<Account> & {\n /**\n * Multichain account group ID.\n */\n get id(): MultichainAccountGroupId;\n\n /**\n * Multichain account type.\n */\n get type(): AccountGroupType.MultichainAccount;\n\n /**\n * Multichain account's wallet reference (parent).\n */\n get wallet(): MultichainAccountWallet<Account>;\n\n /**\n * Multichain account group index.\n */\n get index(): number;\n\n /**\n * Query an account matching the selector.\n *\n * @param selector - Query selector.\n * @returns The account matching the selector or undefined if not matching.\n * @throws If multiple accounts match the selector.\n */\n get(selector: AccountSelector<Account>): Account | undefined;\n\n /**\n * Query accounts matching the selector.\n *\n * @param selector - Query selector.\n * @returns The accounts matching the selector.\n */\n select(selector: AccountSelector<Account>): Account[];\n};\n\n/**\n * Gets the multichain account group ID from its multichain account wallet ID and its index.\n *\n * @param walletId - Multichain account wallet ID.\n * @param groupIndex - Index of that multichain account.\n * @returns The multichain account ID.\n */\nexport function toMultichainAccountGroupId(\n walletId: MultichainAccountWalletId,\n groupIndex: number,\n): MultichainAccountGroupId {\n return `${walletId}/${groupIndex}`;\n}\n\n/**\n * Checks if the given value is {@link MultichainAccountGroupId}.\n *\n * @param value - The value to check.\n * @returns Whether the value is a {@link MultichainAccountGroupId}.\n */\nexport function isMultichainAccountGroupId(\n value: string,\n): value is MultichainAccountGroupId {\n return MULTICHAIN_ACCOUNT_GROUP_ID_REGEX.test(value);\n}\n\n/**\n * Gets the multichain account index from an account group ID.\n *\n * @param id - Multichain account ID.\n * @returns The multichain account index if extractable, undefined otherwise.\n */\nexport function getGroupIndexFromMultichainAccountGroupId(\n id: MultichainAccountGroupId,\n): number {\n const matched = id.match(MULTICHAIN_ACCOUNT_GROUP_ID_REGEX);\n if (matched?.groups?.groupIndex === undefined) {\n // Unable to extract group index, even though, type wise, this should not\n // be possible!\n throw new Error('Unable to extract group index');\n }\n\n return Number(matched.groups.groupIndex);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"provider.cjs","sourceRoot":"","sources":["../../src/api/provider.ts"],"names":[],"mappings":"","sourcesContent":["import type { KeyringAccount } from '@metamask/keyring-api';\n\n/**\n * An account provider is reponsible of providing accounts to an account group.\n */\nexport type AccountProvider<Account extends KeyringAccount> = {\n /**\n * Gets an account for a given ID.\n *\n * @returns An account, or undefined if not found.\n */\n getAccount: (id: Account['id']) => Account | undefined;\n\n /**\n * Gets all accounts for a given entropy source and group index.\n *\n * @returns A list of all account for this provider.\n */\n getAccounts: () => Account[];\n};\n"]}
1
+ {"version":3,"file":"provider.cjs","sourceRoot":"","sources":["../../src/api/provider.ts"],"names":[],"mappings":"","sourcesContent":["import type { EntropySourceId, KeyringAccount } from '@metamask/keyring-api';\n\n/**\n * An account provider is reponsible of providing accounts to an account group.\n */\nexport type AccountProvider<Account extends KeyringAccount> = {\n /**\n * Gets an account for a given ID.\n *\n * @returns An account, or undefined if not found.\n */\n getAccount: (id: Account['id']) => Account | undefined;\n\n /**\n * Gets all accounts for this provider.\n *\n * @returns A list of all account for this provider.\n */\n getAccounts: () => Account[];\n\n /**\n * Creates accounts for a given entropy source and a given group\n * index.\n *\n * @param options - Options.\n * @param options.entropySource - Entropy source to use.\n * @param options.groupIndex - Group index to use.\n * @returns The list of created accounts.\n */\n createAccounts: (options: {\n entropySource: EntropySourceId;\n groupIndex: number;\n }) => Promise<Account[]>;\n\n /**\n * Discover accounts for a given entropy source and a given group\n * index.\n *\n * NOTE: This method needs to also create the discovered accounts.\n *\n * @param options - Options.\n * @param options.entropySource - Entropy source to use.\n * @param options.groupIndex - Group index to use.\n * @returns The list of discovered and created accounts.\n */\n discoverAndCreateAccounts: (options: {\n entropySource: EntropySourceId;\n groupIndex: number;\n }) => Promise<Account[]>;\n};\n"]}
@@ -1,4 +1,4 @@
1
- import type { KeyringAccount } from "@metamask/keyring-api";
1
+ import type { EntropySourceId, KeyringAccount } from "@metamask/keyring-api";
2
2
  /**
3
3
  * An account provider is reponsible of providing accounts to an account group.
4
4
  */
@@ -10,10 +10,38 @@ export type AccountProvider<Account extends KeyringAccount> = {
10
10
  */
11
11
  getAccount: (id: Account['id']) => Account | undefined;
12
12
  /**
13
- * Gets all accounts for a given entropy source and group index.
13
+ * Gets all accounts for this provider.
14
14
  *
15
15
  * @returns A list of all account for this provider.
16
16
  */
17
17
  getAccounts: () => Account[];
18
+ /**
19
+ * Creates accounts for a given entropy source and a given group
20
+ * index.
21
+ *
22
+ * @param options - Options.
23
+ * @param options.entropySource - Entropy source to use.
24
+ * @param options.groupIndex - Group index to use.
25
+ * @returns The list of created accounts.
26
+ */
27
+ createAccounts: (options: {
28
+ entropySource: EntropySourceId;
29
+ groupIndex: number;
30
+ }) => Promise<Account[]>;
31
+ /**
32
+ * Discover accounts for a given entropy source and a given group
33
+ * index.
34
+ *
35
+ * NOTE: This method needs to also create the discovered accounts.
36
+ *
37
+ * @param options - Options.
38
+ * @param options.entropySource - Entropy source to use.
39
+ * @param options.groupIndex - Group index to use.
40
+ * @returns The list of discovered and created accounts.
41
+ */
42
+ discoverAndCreateAccounts: (options: {
43
+ entropySource: EntropySourceId;
44
+ groupIndex: number;
45
+ }) => Promise<Account[]>;
18
46
  };
19
47
  //# sourceMappingURL=provider.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"provider.d.cts","sourceRoot":"","sources":["../../src/api/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,8BAA8B;AAE5D;;GAEG;AACH,MAAM,MAAM,eAAe,CAAC,OAAO,SAAS,cAAc,IAAI;IAC5D;;;;OAIG;IACH,UAAU,EAAE,CAAC,EAAE,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,OAAO,GAAG,SAAS,CAAC;IAEvD;;;;OAIG;IACH,WAAW,EAAE,MAAM,OAAO,EAAE,CAAC;CAC9B,CAAC"}
1
+ {"version":3,"file":"provider.d.cts","sourceRoot":"","sources":["../../src/api/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,8BAA8B;AAE7E;;GAEG;AACH,MAAM,MAAM,eAAe,CAAC,OAAO,SAAS,cAAc,IAAI;IAC5D;;;;OAIG;IACH,UAAU,EAAE,CAAC,EAAE,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,OAAO,GAAG,SAAS,CAAC;IAEvD;;;;OAIG;IACH,WAAW,EAAE,MAAM,OAAO,EAAE,CAAC;IAE7B;;;;;;;;OAQG;IACH,cAAc,EAAE,CAAC,OAAO,EAAE;QACxB,aAAa,EAAE,eAAe,CAAC;QAC/B,UAAU,EAAE,MAAM,CAAC;KACpB,KAAK,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IAEzB;;;;;;;;;;OAUG;IACH,yBAAyB,EAAE,CAAC,OAAO,EAAE;QACnC,aAAa,EAAE,eAAe,CAAC;QAC/B,UAAU,EAAE,MAAM,CAAC;KACpB,KAAK,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;CAC1B,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { KeyringAccount } from "@metamask/keyring-api";
1
+ import type { EntropySourceId, KeyringAccount } from "@metamask/keyring-api";
2
2
  /**
3
3
  * An account provider is reponsible of providing accounts to an account group.
4
4
  */
@@ -10,10 +10,38 @@ export type AccountProvider<Account extends KeyringAccount> = {
10
10
  */
11
11
  getAccount: (id: Account['id']) => Account | undefined;
12
12
  /**
13
- * Gets all accounts for a given entropy source and group index.
13
+ * Gets all accounts for this provider.
14
14
  *
15
15
  * @returns A list of all account for this provider.
16
16
  */
17
17
  getAccounts: () => Account[];
18
+ /**
19
+ * Creates accounts for a given entropy source and a given group
20
+ * index.
21
+ *
22
+ * @param options - Options.
23
+ * @param options.entropySource - Entropy source to use.
24
+ * @param options.groupIndex - Group index to use.
25
+ * @returns The list of created accounts.
26
+ */
27
+ createAccounts: (options: {
28
+ entropySource: EntropySourceId;
29
+ groupIndex: number;
30
+ }) => Promise<Account[]>;
31
+ /**
32
+ * Discover accounts for a given entropy source and a given group
33
+ * index.
34
+ *
35
+ * NOTE: This method needs to also create the discovered accounts.
36
+ *
37
+ * @param options - Options.
38
+ * @param options.entropySource - Entropy source to use.
39
+ * @param options.groupIndex - Group index to use.
40
+ * @returns The list of discovered and created accounts.
41
+ */
42
+ discoverAndCreateAccounts: (options: {
43
+ entropySource: EntropySourceId;
44
+ groupIndex: number;
45
+ }) => Promise<Account[]>;
18
46
  };
19
47
  //# sourceMappingURL=provider.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"provider.d.mts","sourceRoot":"","sources":["../../src/api/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,8BAA8B;AAE5D;;GAEG;AACH,MAAM,MAAM,eAAe,CAAC,OAAO,SAAS,cAAc,IAAI;IAC5D;;;;OAIG;IACH,UAAU,EAAE,CAAC,EAAE,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,OAAO,GAAG,SAAS,CAAC;IAEvD;;;;OAIG;IACH,WAAW,EAAE,MAAM,OAAO,EAAE,CAAC;CAC9B,CAAC"}
1
+ {"version":3,"file":"provider.d.mts","sourceRoot":"","sources":["../../src/api/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,8BAA8B;AAE7E;;GAEG;AACH,MAAM,MAAM,eAAe,CAAC,OAAO,SAAS,cAAc,IAAI;IAC5D;;;;OAIG;IACH,UAAU,EAAE,CAAC,EAAE,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,OAAO,GAAG,SAAS,CAAC;IAEvD;;;;OAIG;IACH,WAAW,EAAE,MAAM,OAAO,EAAE,CAAC;IAE7B;;;;;;;;OAQG;IACH,cAAc,EAAE,CAAC,OAAO,EAAE;QACxB,aAAa,EAAE,eAAe,CAAC;QAC/B,UAAU,EAAE,MAAM,CAAC;KACpB,KAAK,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IAEzB;;;;;;;;;;OAUG;IACH,yBAAyB,EAAE,CAAC,OAAO,EAAE;QACnC,aAAa,EAAE,eAAe,CAAC;QAC/B,UAAU,EAAE,MAAM,CAAC;KACpB,KAAK,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;CAC1B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"provider.mjs","sourceRoot":"","sources":["../../src/api/provider.ts"],"names":[],"mappings":"","sourcesContent":["import type { KeyringAccount } from '@metamask/keyring-api';\n\n/**\n * An account provider is reponsible of providing accounts to an account group.\n */\nexport type AccountProvider<Account extends KeyringAccount> = {\n /**\n * Gets an account for a given ID.\n *\n * @returns An account, or undefined if not found.\n */\n getAccount: (id: Account['id']) => Account | undefined;\n\n /**\n * Gets all accounts for a given entropy source and group index.\n *\n * @returns A list of all account for this provider.\n */\n getAccounts: () => Account[];\n};\n"]}
1
+ {"version":3,"file":"provider.mjs","sourceRoot":"","sources":["../../src/api/provider.ts"],"names":[],"mappings":"","sourcesContent":["import type { EntropySourceId, KeyringAccount } from '@metamask/keyring-api';\n\n/**\n * An account provider is reponsible of providing accounts to an account group.\n */\nexport type AccountProvider<Account extends KeyringAccount> = {\n /**\n * Gets an account for a given ID.\n *\n * @returns An account, or undefined if not found.\n */\n getAccount: (id: Account['id']) => Account | undefined;\n\n /**\n * Gets all accounts for this provider.\n *\n * @returns A list of all account for this provider.\n */\n getAccounts: () => Account[];\n\n /**\n * Creates accounts for a given entropy source and a given group\n * index.\n *\n * @param options - Options.\n * @param options.entropySource - Entropy source to use.\n * @param options.groupIndex - Group index to use.\n * @returns The list of created accounts.\n */\n createAccounts: (options: {\n entropySource: EntropySourceId;\n groupIndex: number;\n }) => Promise<Account[]>;\n\n /**\n * Discover accounts for a given entropy source and a given group\n * index.\n *\n * NOTE: This method needs to also create the discovered accounts.\n *\n * @param options - Options.\n * @param options.entropySource - Entropy source to use.\n * @param options.groupIndex - Group index to use.\n * @returns The list of discovered and created accounts.\n */\n discoverAndCreateAccounts: (options: {\n entropySource: EntropySourceId;\n groupIndex: number;\n }) => Promise<Account[]>;\n};\n"]}
package/dist/index.cjs CHANGED
@@ -15,4 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./api/index.cjs"), exports);
18
+ // NOTE: We do not export the test utilities as part of the public API, but they
19
+ // are still available through `@metamask/account-api/tests`.
18
20
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAsB","sourcesContent":["export * from './api';\n"]}
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAsB;AAEtB,gFAAgF;AAChF,6DAA6D","sourcesContent":["export * from './api';\n\n// NOTE: We do not export the test utilities as part of the public API, but they\n// are still available through `@metamask/account-api/tests`.\n"]}
package/dist/index.mjs CHANGED
@@ -1,2 +1,4 @@
1
1
  export * from "./api/index.mjs";
2
+ // NOTE: We do not export the test utilities as part of the public API, but they
3
+ // are still available through `@metamask/account-api/tests`.
2
4
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gCAAsB","sourcesContent":["export * from './api';\n"]}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gCAAsB;AAEtB,gFAAgF;AAChF,6DAA6D","sourcesContent":["export * from './api';\n\n// NOTE: We do not export the test utilities as part of the public API, but they\n// are still available through `@metamask/account-api/tests`.\n"]}
@@ -0,0 +1,199 @@
1
+ "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
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
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var _MockAccountBuilder_account;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.MOCK_WALLET_1_BTC_P2TR_ACCOUNT = exports.MOCK_WALLET_1_BTC_P2WPKH_ACCOUNT = exports.MOCK_WALLET_1_SOL_ACCOUNT = exports.MOCK_WALLET_1_EVM_ACCOUNT = exports.MOCK_WALLET_1_ENTROPY_SOURCE = exports.MockAccountBuilder = exports.MOCK_HARDWARE_ACCOUNT_1 = exports.MOCK_SNAP_ACCOUNT_4 = exports.MOCK_SNAP_ACCOUNT_3 = exports.MOCK_SNAP_ACCOUNT_2 = exports.MOCK_SNAP_ACCOUNT_1 = exports.MOCK_BTC_P2TR_ACCOUNT_1 = exports.MOCK_BTC_P2WPKH_ACCOUNT_1 = exports.MOCK_SOL_ACCOUNT_1 = exports.MOCK_HD_ACCOUNT_2 = exports.MOCK_HD_ACCOUNT_1 = exports.MOCK_ENTROPY_SOURCE_2 = exports.MOCK_ENTROPY_SOURCE_1 = exports.MOCK_SNAP_2 = exports.MOCK_SNAP_1 = void 0;
16
+ const keyring_api_1 = require("@metamask/keyring-api");
17
+ const uuid_1 = require("uuid");
18
+ const api_1 = require("../api/index.cjs");
19
+ const ETH_EOA_METHODS = [
20
+ keyring_api_1.EthMethod.PersonalSign,
21
+ keyring_api_1.EthMethod.Sign,
22
+ keyring_api_1.EthMethod.SignTransaction,
23
+ keyring_api_1.EthMethod.SignTypedDataV1,
24
+ keyring_api_1.EthMethod.SignTypedDataV3,
25
+ keyring_api_1.EthMethod.SignTypedDataV4,
26
+ ];
27
+ const SOL_METHODS = Object.values(keyring_api_1.SolMethod);
28
+ exports.MOCK_SNAP_1 = {
29
+ id: 'local:mock-snap-id-1',
30
+ name: 'Mock Snap 1',
31
+ enabled: true,
32
+ manifest: {
33
+ proposedName: 'Mock Snap 1',
34
+ },
35
+ };
36
+ exports.MOCK_SNAP_2 = {
37
+ id: 'local:mock-snap-id-2',
38
+ name: 'Mock Snap 2',
39
+ enabled: true,
40
+ manifest: {
41
+ proposedName: 'Mock Snap 2',
42
+ },
43
+ };
44
+ exports.MOCK_ENTROPY_SOURCE_1 = 'mock-keyring-id-1';
45
+ exports.MOCK_ENTROPY_SOURCE_2 = 'mock-keyring-id-2';
46
+ exports.MOCK_HD_ACCOUNT_1 = {
47
+ id: 'mock-id-1',
48
+ address: '0x123',
49
+ options: {
50
+ entropy: {
51
+ type: keyring_api_1.KeyringAccountEntropyTypeOption.Mnemonic,
52
+ id: exports.MOCK_ENTROPY_SOURCE_1,
53
+ groupIndex: 0,
54
+ derivationPath: '',
55
+ },
56
+ },
57
+ methods: [...ETH_EOA_METHODS],
58
+ type: keyring_api_1.EthAccountType.Eoa,
59
+ scopes: [keyring_api_1.EthScope.Eoa],
60
+ };
61
+ exports.MOCK_HD_ACCOUNT_2 = {
62
+ id: 'mock-id-2',
63
+ address: '0x456',
64
+ options: {
65
+ entropy: {
66
+ type: keyring_api_1.KeyringAccountEntropyTypeOption.Mnemonic,
67
+ id: exports.MOCK_ENTROPY_SOURCE_2,
68
+ groupIndex: 0,
69
+ derivationPath: '',
70
+ },
71
+ },
72
+ methods: [...ETH_EOA_METHODS],
73
+ type: keyring_api_1.EthAccountType.Eoa,
74
+ scopes: [keyring_api_1.EthScope.Eoa],
75
+ };
76
+ exports.MOCK_SOL_ACCOUNT_1 = {
77
+ id: 'mock-snap-id-1',
78
+ address: 'aabbccdd',
79
+ options: {
80
+ entropy: {
81
+ type: keyring_api_1.KeyringAccountEntropyTypeOption.Mnemonic,
82
+ // NOTE: shares entropy with MOCK_HD_ACCOUNT_2
83
+ id: exports.MOCK_ENTROPY_SOURCE_2,
84
+ groupIndex: 0,
85
+ derivationPath: '',
86
+ },
87
+ },
88
+ methods: SOL_METHODS,
89
+ type: keyring_api_1.SolAccountType.DataAccount,
90
+ scopes: [keyring_api_1.SolScope.Mainnet, keyring_api_1.SolScope.Testnet, keyring_api_1.SolScope.Devnet],
91
+ };
92
+ exports.MOCK_BTC_P2WPKH_ACCOUNT_1 = {
93
+ id: 'b0f030d8-e101-4b5a-a3dd-13f8ca8ec1db',
94
+ type: keyring_api_1.BtcAccountType.P2wpkh,
95
+ methods: [keyring_api_1.BtcMethod.SendBitcoin],
96
+ address: 'bc1qx8ls07cy8j8nrluy2u0xwn7gh8fxg0rg4s8zze',
97
+ options: {
98
+ entropy: {
99
+ type: keyring_api_1.KeyringAccountEntropyTypeOption.Mnemonic,
100
+ // NOTE: shares entropy with MOCK_HD_ACCOUNT_2
101
+ id: exports.MOCK_ENTROPY_SOURCE_2,
102
+ groupIndex: 0,
103
+ derivationPath: '',
104
+ },
105
+ },
106
+ scopes: [keyring_api_1.BtcScope.Mainnet],
107
+ };
108
+ exports.MOCK_BTC_P2TR_ACCOUNT_1 = {
109
+ id: 'a20c2e1a-6ff6-40ba-b8e0-ccdb6f9933bb',
110
+ type: keyring_api_1.BtcAccountType.P2tr,
111
+ methods: [keyring_api_1.BtcMethod.SendBitcoin],
112
+ address: 'tb1p5cyxnuxmeuwuvkwfem96lxx9wex9kkf4mt9ll6q60jfsnrzqg4sszkqjnh',
113
+ options: {
114
+ entropy: {
115
+ type: keyring_api_1.KeyringAccountEntropyTypeOption.Mnemonic,
116
+ // NOTE: shares entropy with MOCK_HD_ACCOUNT_2
117
+ id: exports.MOCK_ENTROPY_SOURCE_2,
118
+ groupIndex: 0,
119
+ derivationPath: '',
120
+ },
121
+ },
122
+ scopes: [keyring_api_1.BtcScope.Testnet],
123
+ };
124
+ exports.MOCK_SNAP_ACCOUNT_1 = exports.MOCK_SOL_ACCOUNT_1;
125
+ exports.MOCK_SNAP_ACCOUNT_2 = {
126
+ id: 'mock-snap-id-2',
127
+ address: '0x789',
128
+ options: {},
129
+ methods: [...ETH_EOA_METHODS],
130
+ type: keyring_api_1.EthAccountType.Eoa,
131
+ scopes: [keyring_api_1.EthScope.Eoa],
132
+ };
133
+ exports.MOCK_SNAP_ACCOUNT_3 = exports.MOCK_BTC_P2WPKH_ACCOUNT_1;
134
+ exports.MOCK_SNAP_ACCOUNT_4 = exports.MOCK_BTC_P2TR_ACCOUNT_1;
135
+ exports.MOCK_HARDWARE_ACCOUNT_1 = {
136
+ id: 'mock-hardware-id-1',
137
+ address: '0xABC',
138
+ options: {},
139
+ methods: [...ETH_EOA_METHODS],
140
+ type: keyring_api_1.EthAccountType.Eoa,
141
+ scopes: [keyring_api_1.EthScope.Eoa],
142
+ };
143
+ class MockAccountBuilder {
144
+ constructor(account) {
145
+ _MockAccountBuilder_account.set(this, void 0);
146
+ // Make a deep-copy to avoid mutating the same ref.
147
+ __classPrivateFieldSet(this, _MockAccountBuilder_account, JSON.parse(JSON.stringify(account)), "f");
148
+ }
149
+ static from(account) {
150
+ return new MockAccountBuilder(account);
151
+ }
152
+ withId(id) {
153
+ __classPrivateFieldGet(this, _MockAccountBuilder_account, "f").id = id;
154
+ return this;
155
+ }
156
+ withUuid() {
157
+ __classPrivateFieldGet(this, _MockAccountBuilder_account, "f").id = (0, uuid_1.v4)();
158
+ return this;
159
+ }
160
+ withAddressSuffix(suffix) {
161
+ __classPrivateFieldGet(this, _MockAccountBuilder_account, "f").address += suffix;
162
+ return this;
163
+ }
164
+ withEntropySource(entropySource) {
165
+ if ((0, api_1.isBip44Account)(__classPrivateFieldGet(this, _MockAccountBuilder_account, "f"))) {
166
+ __classPrivateFieldGet(this, _MockAccountBuilder_account, "f").options.entropy.id = entropySource;
167
+ }
168
+ return this;
169
+ }
170
+ withGroupIndex(groupIndex) {
171
+ if ((0, api_1.isBip44Account)(__classPrivateFieldGet(this, _MockAccountBuilder_account, "f"))) {
172
+ __classPrivateFieldGet(this, _MockAccountBuilder_account, "f").options.entropy.groupIndex = groupIndex;
173
+ }
174
+ return this;
175
+ }
176
+ get() {
177
+ return __classPrivateFieldGet(this, _MockAccountBuilder_account, "f");
178
+ }
179
+ }
180
+ exports.MockAccountBuilder = MockAccountBuilder;
181
+ _MockAccountBuilder_account = new WeakMap();
182
+ exports.MOCK_WALLET_1_ENTROPY_SOURCE = exports.MOCK_ENTROPY_SOURCE_1;
183
+ exports.MOCK_WALLET_1_EVM_ACCOUNT = MockAccountBuilder.from(exports.MOCK_HD_ACCOUNT_1)
184
+ .withEntropySource(exports.MOCK_WALLET_1_ENTROPY_SOURCE)
185
+ .withGroupIndex(0)
186
+ .get();
187
+ exports.MOCK_WALLET_1_SOL_ACCOUNT = MockAccountBuilder.from(exports.MOCK_SOL_ACCOUNT_1)
188
+ .withEntropySource(exports.MOCK_WALLET_1_ENTROPY_SOURCE)
189
+ .withGroupIndex(0)
190
+ .get();
191
+ exports.MOCK_WALLET_1_BTC_P2WPKH_ACCOUNT = MockAccountBuilder.from(exports.MOCK_BTC_P2WPKH_ACCOUNT_1)
192
+ .withEntropySource(exports.MOCK_WALLET_1_ENTROPY_SOURCE)
193
+ .withGroupIndex(0)
194
+ .get();
195
+ exports.MOCK_WALLET_1_BTC_P2TR_ACCOUNT = MockAccountBuilder.from(exports.MOCK_BTC_P2TR_ACCOUNT_1)
196
+ .withEntropySource(exports.MOCK_WALLET_1_ENTROPY_SOURCE)
197
+ .withGroupIndex(0)
198
+ .get();
199
+ //# sourceMappingURL=accounts.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accounts.cjs","sourceRoot":"","sources":["../../src/tests/accounts.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,uDAW+B;AAC/B,+BAAkC;AAElC,0CAA2D;AAE3D,MAAM,eAAe,GAAG;IACtB,uBAAS,CAAC,YAAY;IACt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IAAI,CACnE,+BAAuB,CACxB;KACE,iBAAiB,CAAC,oCAA4B,CAAC;KAC/C,cAAc,CAAC,CAAC,CAAC;KACjB,GAAG,EAAE,CAAC","sourcesContent":["import type { EntropySourceId, KeyringAccount } from '@metamask/keyring-api';\nimport {\n BtcAccountType,\n BtcMethod,\n BtcScope,\n EthAccountType,\n EthMethod,\n EthScope,\n KeyringAccountEntropyTypeOption,\n SolAccountType,\n SolMethod,\n SolScope,\n} from '@metamask/keyring-api';\nimport { v4 as uuid } from 'uuid';\n\nimport { isBip44Account, type Bip44Account } from '../api';\n\nconst ETH_EOA_METHODS = [\n EthMethod.PersonalSign,\n EthMethod.Sign,\n EthMethod.SignTransaction,\n EthMethod.SignTypedDataV1,\n EthMethod.SignTypedDataV3,\n EthMethod.SignTypedDataV4,\n] as const;\n\nconst SOL_METHODS = Object.values(SolMethod);\n\nexport const MOCK_SNAP_1 = {\n id: 'local:mock-snap-id-1',\n name: 'Mock Snap 1',\n enabled: true,\n manifest: {\n proposedName: 'Mock Snap 1',\n },\n};\n\nexport const MOCK_SNAP_2 = {\n id: 'local:mock-snap-id-2',\n name: 'Mock Snap 2',\n enabled: true,\n manifest: {\n proposedName: 'Mock Snap 2',\n },\n};\n\nexport const MOCK_ENTROPY_SOURCE_1 = 'mock-keyring-id-1';\nexport const MOCK_ENTROPY_SOURCE_2 = 'mock-keyring-id-2';\n\nexport const MOCK_HD_ACCOUNT_1: Bip44Account<KeyringAccount> = {\n id: 'mock-id-1',\n address: '0x123',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n id: MOCK_ENTROPY_SOURCE_1,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n};\n\nexport const MOCK_HD_ACCOUNT_2: Bip44Account<KeyringAccount> = {\n id: 'mock-id-2',\n address: '0x456',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n id: MOCK_ENTROPY_SOURCE_2,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n};\n\nexport const MOCK_SOL_ACCOUNT_1: Bip44Account<KeyringAccount> = {\n id: 'mock-snap-id-1',\n address: 'aabbccdd',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n // NOTE: shares entropy with MOCK_HD_ACCOUNT_2\n id: MOCK_ENTROPY_SOURCE_2,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n methods: SOL_METHODS,\n type: SolAccountType.DataAccount,\n scopes: [SolScope.Mainnet, SolScope.Testnet, SolScope.Devnet],\n};\n\nexport const MOCK_BTC_P2WPKH_ACCOUNT_1: Bip44Account<KeyringAccount> = {\n id: 'b0f030d8-e101-4b5a-a3dd-13f8ca8ec1db',\n type: BtcAccountType.P2wpkh,\n methods: [BtcMethod.SendBitcoin],\n address: 'bc1qx8ls07cy8j8nrluy2u0xwn7gh8fxg0rg4s8zze',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n // NOTE: shares entropy with MOCK_HD_ACCOUNT_2\n id: MOCK_ENTROPY_SOURCE_2,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n scopes: [BtcScope.Mainnet],\n};\n\nexport const MOCK_BTC_P2TR_ACCOUNT_1: Bip44Account<KeyringAccount> = {\n id: 'a20c2e1a-6ff6-40ba-b8e0-ccdb6f9933bb',\n type: BtcAccountType.P2tr,\n methods: [BtcMethod.SendBitcoin],\n address: 'tb1p5cyxnuxmeuwuvkwfem96lxx9wex9kkf4mt9ll6q60jfsnrzqg4sszkqjnh',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n // NOTE: shares entropy with MOCK_HD_ACCOUNT_2\n id: MOCK_ENTROPY_SOURCE_2,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n scopes: [BtcScope.Testnet],\n};\n\nexport const MOCK_SNAP_ACCOUNT_1 = MOCK_SOL_ACCOUNT_1;\n\nexport const MOCK_SNAP_ACCOUNT_2: KeyringAccount = {\n id: 'mock-snap-id-2',\n address: '0x789',\n options: {},\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n};\n\nexport const MOCK_SNAP_ACCOUNT_3 = MOCK_BTC_P2WPKH_ACCOUNT_1;\nexport const MOCK_SNAP_ACCOUNT_4 = MOCK_BTC_P2TR_ACCOUNT_1;\n\nexport const MOCK_HARDWARE_ACCOUNT_1: KeyringAccount = {\n id: 'mock-hardware-id-1',\n address: '0xABC',\n options: {},\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n};\n\nexport class MockAccountBuilder<Account extends KeyringAccount> {\n readonly #account: Account;\n\n constructor(account: Account) {\n // Make a deep-copy to avoid mutating the same ref.\n this.#account = JSON.parse(JSON.stringify(account));\n }\n\n static from<Account extends KeyringAccount>(\n account: Account,\n ): MockAccountBuilder<Account> {\n return new MockAccountBuilder(account);\n }\n\n withId(id: KeyringAccount['id']): MockAccountBuilder<Account> {\n this.#account.id = id;\n return this;\n }\n\n withUuid(): MockAccountBuilder<Account> {\n this.#account.id = uuid();\n return this;\n }\n\n withAddressSuffix(suffix: string): MockAccountBuilder<Account> {\n this.#account.address += suffix;\n return this;\n }\n\n withEntropySource(\n entropySource: EntropySourceId,\n ): MockAccountBuilder<Account> {\n if (isBip44Account(this.#account)) {\n this.#account.options.entropy.id = entropySource;\n }\n return this;\n }\n\n withGroupIndex(groupIndex: number): MockAccountBuilder<Account> {\n if (isBip44Account(this.#account)) {\n this.#account.options.entropy.groupIndex = groupIndex;\n }\n return this;\n }\n\n get(): Account {\n return this.#account;\n }\n}\n\nexport const MOCK_WALLET_1_ENTROPY_SOURCE = MOCK_ENTROPY_SOURCE_1;\n\nexport const MOCK_WALLET_1_EVM_ACCOUNT = MockAccountBuilder.from(\n MOCK_HD_ACCOUNT_1,\n)\n .withEntropySource(MOCK_WALLET_1_ENTROPY_SOURCE)\n .withGroupIndex(0)\n .get();\nexport const MOCK_WALLET_1_SOL_ACCOUNT = MockAccountBuilder.from(\n MOCK_SOL_ACCOUNT_1,\n)\n .withEntropySource(MOCK_WALLET_1_ENTROPY_SOURCE)\n .withGroupIndex(0)\n .get();\nexport const MOCK_WALLET_1_BTC_P2WPKH_ACCOUNT = MockAccountBuilder.from(\n MOCK_BTC_P2WPKH_ACCOUNT_1,\n)\n .withEntropySource(MOCK_WALLET_1_ENTROPY_SOURCE)\n .withGroupIndex(0)\n .get();\nexport const MOCK_WALLET_1_BTC_P2TR_ACCOUNT = MockAccountBuilder.from(\n MOCK_BTC_P2TR_ACCOUNT_1,\n)\n .withEntropySource(MOCK_WALLET_1_ENTROPY_SOURCE)\n .withGroupIndex(0)\n .get();\n"]}
@@ -0,0 +1,166 @@
1
+ import type { EntropySourceId, KeyringAccount } from "@metamask/keyring-api";
2
+ import { type Bip44Account } from "../api/index.cjs";
3
+ export declare const MOCK_SNAP_1: {
4
+ id: string;
5
+ name: string;
6
+ enabled: boolean;
7
+ manifest: {
8
+ proposedName: string;
9
+ };
10
+ };
11
+ export declare const MOCK_SNAP_2: {
12
+ id: string;
13
+ name: string;
14
+ enabled: boolean;
15
+ manifest: {
16
+ proposedName: string;
17
+ };
18
+ };
19
+ export declare const MOCK_ENTROPY_SOURCE_1 = "mock-keyring-id-1";
20
+ export declare const MOCK_ENTROPY_SOURCE_2 = "mock-keyring-id-2";
21
+ export declare const MOCK_HD_ACCOUNT_1: Bip44Account<KeyringAccount>;
22
+ export declare const MOCK_HD_ACCOUNT_2: Bip44Account<KeyringAccount>;
23
+ export declare const MOCK_SOL_ACCOUNT_1: Bip44Account<KeyringAccount>;
24
+ export declare const MOCK_BTC_P2WPKH_ACCOUNT_1: Bip44Account<KeyringAccount>;
25
+ export declare const MOCK_BTC_P2TR_ACCOUNT_1: Bip44Account<KeyringAccount>;
26
+ export declare const MOCK_SNAP_ACCOUNT_1: Bip44Account<{
27
+ type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
28
+ id: string;
29
+ options: Record<string, import("@metamask/utils").Json> & {
30
+ entropy?: {
31
+ type: "mnemonic";
32
+ id: string;
33
+ derivationPath: string;
34
+ groupIndex: number;
35
+ } | {
36
+ type: "private-key";
37
+ };
38
+ exportable?: boolean;
39
+ };
40
+ address: string;
41
+ scopes: `${string}:${string}`[];
42
+ methods: string[];
43
+ }>;
44
+ export declare const MOCK_SNAP_ACCOUNT_2: KeyringAccount;
45
+ export declare const MOCK_SNAP_ACCOUNT_3: Bip44Account<{
46
+ type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
47
+ id: string;
48
+ options: Record<string, import("@metamask/utils").Json> & {
49
+ entropy?: {
50
+ type: "mnemonic";
51
+ id: string;
52
+ derivationPath: string;
53
+ groupIndex: number;
54
+ } | {
55
+ type: "private-key";
56
+ };
57
+ exportable?: boolean;
58
+ };
59
+ address: string;
60
+ scopes: `${string}:${string}`[];
61
+ methods: string[];
62
+ }>;
63
+ export declare const MOCK_SNAP_ACCOUNT_4: Bip44Account<{
64
+ type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
65
+ id: string;
66
+ options: Record<string, import("@metamask/utils").Json> & {
67
+ entropy?: {
68
+ type: "mnemonic";
69
+ id: string;
70
+ derivationPath: string;
71
+ groupIndex: number;
72
+ } | {
73
+ type: "private-key";
74
+ };
75
+ exportable?: boolean;
76
+ };
77
+ address: string;
78
+ scopes: `${string}:${string}`[];
79
+ methods: string[];
80
+ }>;
81
+ export declare const MOCK_HARDWARE_ACCOUNT_1: KeyringAccount;
82
+ export declare class MockAccountBuilder<Account extends KeyringAccount> {
83
+ #private;
84
+ constructor(account: Account);
85
+ static from<Account extends KeyringAccount>(account: Account): MockAccountBuilder<Account>;
86
+ withId(id: KeyringAccount['id']): MockAccountBuilder<Account>;
87
+ withUuid(): MockAccountBuilder<Account>;
88
+ withAddressSuffix(suffix: string): MockAccountBuilder<Account>;
89
+ withEntropySource(entropySource: EntropySourceId): MockAccountBuilder<Account>;
90
+ withGroupIndex(groupIndex: number): MockAccountBuilder<Account>;
91
+ get(): Account;
92
+ }
93
+ export declare const MOCK_WALLET_1_ENTROPY_SOURCE = "mock-keyring-id-1";
94
+ export declare const MOCK_WALLET_1_EVM_ACCOUNT: Bip44Account<{
95
+ type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
96
+ id: string;
97
+ options: Record<string, import("@metamask/utils").Json> & {
98
+ entropy?: {
99
+ type: "mnemonic";
100
+ id: string;
101
+ derivationPath: string;
102
+ groupIndex: number;
103
+ } | {
104
+ type: "private-key";
105
+ };
106
+ exportable?: boolean;
107
+ };
108
+ address: string;
109
+ scopes: `${string}:${string}`[];
110
+ methods: string[];
111
+ }>;
112
+ export declare const MOCK_WALLET_1_SOL_ACCOUNT: Bip44Account<{
113
+ type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
114
+ id: string;
115
+ options: Record<string, import("@metamask/utils").Json> & {
116
+ entropy?: {
117
+ type: "mnemonic";
118
+ id: string;
119
+ derivationPath: string;
120
+ groupIndex: number;
121
+ } | {
122
+ type: "private-key";
123
+ };
124
+ exportable?: boolean;
125
+ };
126
+ address: string;
127
+ scopes: `${string}:${string}`[];
128
+ methods: string[];
129
+ }>;
130
+ export declare const MOCK_WALLET_1_BTC_P2WPKH_ACCOUNT: Bip44Account<{
131
+ type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
132
+ id: string;
133
+ options: Record<string, import("@metamask/utils").Json> & {
134
+ entropy?: {
135
+ type: "mnemonic";
136
+ id: string;
137
+ derivationPath: string;
138
+ groupIndex: number;
139
+ } | {
140
+ type: "private-key";
141
+ };
142
+ exportable?: boolean;
143
+ };
144
+ address: string;
145
+ scopes: `${string}:${string}`[];
146
+ methods: string[];
147
+ }>;
148
+ export declare const MOCK_WALLET_1_BTC_P2TR_ACCOUNT: Bip44Account<{
149
+ type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
150
+ id: string;
151
+ options: Record<string, import("@metamask/utils").Json> & {
152
+ entropy?: {
153
+ type: "mnemonic";
154
+ id: string;
155
+ derivationPath: string;
156
+ groupIndex: number;
157
+ } | {
158
+ type: "private-key";
159
+ };
160
+ exportable?: boolean;
161
+ };
162
+ address: string;
163
+ scopes: `${string}:${string}`[];
164
+ methods: string[];
165
+ }>;
166
+ //# sourceMappingURL=accounts.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accounts.d.cts","sourceRoot":"","sources":["../../src/tests/accounts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,8BAA8B;AAe7E,OAAO,EAAkB,KAAK,YAAY,EAAE,yBAAe;AAa3D,eAAO,MAAM,WAAW;;;;;;;CAOvB,CAAC;AAEF,eAAO,MAAM,WAAW;;;;;;;CAOvB,CAAC;AAEF,eAAO,MAAM,qBAAqB,sBAAsB,CAAC;AACzD,eAAO,MAAM,qBAAqB,sBAAsB,CAAC;AAEzD,eAAO,MAAM,iBAAiB,EAAE,YAAY,CAAC,cAAc,CAc1D,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,YAAY,CAAC,cAAc,CAc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AACT,eAAO,MAAM,yBAAyB;;;;eA/IR,CAAC;;;;;;;;kBAS/B,CAAC;;;;;EA2IO,CAAC;AACT,eAAO,MAAM,gCAAgC;;;;eArJf,CAAC;;;;;;;;kBAS/B,CAAC;;;;;EAiJO,CAAC;AACT,eAAO,MAAM,8BAA8B;;;;eA3Jb,CAAC;;;;;;;;kBAS/B,CAAC;;;;;EAuJO,CAAC"}
@@ -0,0 +1,166 @@
1
+ import type { EntropySourceId, KeyringAccount } from "@metamask/keyring-api";
2
+ import { type Bip44Account } from "../api/index.mjs";
3
+ export declare const MOCK_SNAP_1: {
4
+ id: string;
5
+ name: string;
6
+ enabled: boolean;
7
+ manifest: {
8
+ proposedName: string;
9
+ };
10
+ };
11
+ export declare const MOCK_SNAP_2: {
12
+ id: string;
13
+ name: string;
14
+ enabled: boolean;
15
+ manifest: {
16
+ proposedName: string;
17
+ };
18
+ };
19
+ export declare const MOCK_ENTROPY_SOURCE_1 = "mock-keyring-id-1";
20
+ export declare const MOCK_ENTROPY_SOURCE_2 = "mock-keyring-id-2";
21
+ export declare const MOCK_HD_ACCOUNT_1: Bip44Account<KeyringAccount>;
22
+ export declare const MOCK_HD_ACCOUNT_2: Bip44Account<KeyringAccount>;
23
+ export declare const MOCK_SOL_ACCOUNT_1: Bip44Account<KeyringAccount>;
24
+ export declare const MOCK_BTC_P2WPKH_ACCOUNT_1: Bip44Account<KeyringAccount>;
25
+ export declare const MOCK_BTC_P2TR_ACCOUNT_1: Bip44Account<KeyringAccount>;
26
+ export declare const MOCK_SNAP_ACCOUNT_1: Bip44Account<{
27
+ type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
28
+ id: string;
29
+ options: Record<string, import("@metamask/utils").Json> & {
30
+ entropy?: {
31
+ type: "mnemonic";
32
+ id: string;
33
+ derivationPath: string;
34
+ groupIndex: number;
35
+ } | {
36
+ type: "private-key";
37
+ };
38
+ exportable?: boolean;
39
+ };
40
+ address: string;
41
+ scopes: `${string}:${string}`[];
42
+ methods: string[];
43
+ }>;
44
+ export declare const MOCK_SNAP_ACCOUNT_2: KeyringAccount;
45
+ export declare const MOCK_SNAP_ACCOUNT_3: Bip44Account<{
46
+ type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
47
+ id: string;
48
+ options: Record<string, import("@metamask/utils").Json> & {
49
+ entropy?: {
50
+ type: "mnemonic";
51
+ id: string;
52
+ derivationPath: string;
53
+ groupIndex: number;
54
+ } | {
55
+ type: "private-key";
56
+ };
57
+ exportable?: boolean;
58
+ };
59
+ address: string;
60
+ scopes: `${string}:${string}`[];
61
+ methods: string[];
62
+ }>;
63
+ export declare const MOCK_SNAP_ACCOUNT_4: Bip44Account<{
64
+ type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
65
+ id: string;
66
+ options: Record<string, import("@metamask/utils").Json> & {
67
+ entropy?: {
68
+ type: "mnemonic";
69
+ id: string;
70
+ derivationPath: string;
71
+ groupIndex: number;
72
+ } | {
73
+ type: "private-key";
74
+ };
75
+ exportable?: boolean;
76
+ };
77
+ address: string;
78
+ scopes: `${string}:${string}`[];
79
+ methods: string[];
80
+ }>;
81
+ export declare const MOCK_HARDWARE_ACCOUNT_1: KeyringAccount;
82
+ export declare class MockAccountBuilder<Account extends KeyringAccount> {
83
+ #private;
84
+ constructor(account: Account);
85
+ static from<Account extends KeyringAccount>(account: Account): MockAccountBuilder<Account>;
86
+ withId(id: KeyringAccount['id']): MockAccountBuilder<Account>;
87
+ withUuid(): MockAccountBuilder<Account>;
88
+ withAddressSuffix(suffix: string): MockAccountBuilder<Account>;
89
+ withEntropySource(entropySource: EntropySourceId): MockAccountBuilder<Account>;
90
+ withGroupIndex(groupIndex: number): MockAccountBuilder<Account>;
91
+ get(): Account;
92
+ }
93
+ export declare const MOCK_WALLET_1_ENTROPY_SOURCE = "mock-keyring-id-1";
94
+ export declare const MOCK_WALLET_1_EVM_ACCOUNT: Bip44Account<{
95
+ type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
96
+ id: string;
97
+ options: Record<string, import("@metamask/utils").Json> & {
98
+ entropy?: {
99
+ type: "mnemonic";
100
+ id: string;
101
+ derivationPath: string;
102
+ groupIndex: number;
103
+ } | {
104
+ type: "private-key";
105
+ };
106
+ exportable?: boolean;
107
+ };
108
+ address: string;
109
+ scopes: `${string}:${string}`[];
110
+ methods: string[];
111
+ }>;
112
+ export declare const MOCK_WALLET_1_SOL_ACCOUNT: Bip44Account<{
113
+ type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
114
+ id: string;
115
+ options: Record<string, import("@metamask/utils").Json> & {
116
+ entropy?: {
117
+ type: "mnemonic";
118
+ id: string;
119
+ derivationPath: string;
120
+ groupIndex: number;
121
+ } | {
122
+ type: "private-key";
123
+ };
124
+ exportable?: boolean;
125
+ };
126
+ address: string;
127
+ scopes: `${string}:${string}`[];
128
+ methods: string[];
129
+ }>;
130
+ export declare const MOCK_WALLET_1_BTC_P2WPKH_ACCOUNT: Bip44Account<{
131
+ type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
132
+ id: string;
133
+ options: Record<string, import("@metamask/utils").Json> & {
134
+ entropy?: {
135
+ type: "mnemonic";
136
+ id: string;
137
+ derivationPath: string;
138
+ groupIndex: number;
139
+ } | {
140
+ type: "private-key";
141
+ };
142
+ exportable?: boolean;
143
+ };
144
+ address: string;
145
+ scopes: `${string}:${string}`[];
146
+ methods: string[];
147
+ }>;
148
+ export declare const MOCK_WALLET_1_BTC_P2TR_ACCOUNT: Bip44Account<{
149
+ type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "any:account";
150
+ id: string;
151
+ options: Record<string, import("@metamask/utils").Json> & {
152
+ entropy?: {
153
+ type: "mnemonic";
154
+ id: string;
155
+ derivationPath: string;
156
+ groupIndex: number;
157
+ } | {
158
+ type: "private-key";
159
+ };
160
+ exportable?: boolean;
161
+ };
162
+ address: string;
163
+ scopes: `${string}:${string}`[];
164
+ methods: string[];
165
+ }>;
166
+ //# sourceMappingURL=accounts.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accounts.d.mts","sourceRoot":"","sources":["../../src/tests/accounts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,8BAA8B;AAe7E,OAAO,EAAkB,KAAK,YAAY,EAAE,yBAAe;AAa3D,eAAO,MAAM,WAAW;;;;;;;CAOvB,CAAC;AAEF,eAAO,MAAM,WAAW;;;;;;;CAOvB,CAAC;AAEF,eAAO,MAAM,qBAAqB,sBAAsB,CAAC;AACzD,eAAO,MAAM,qBAAqB,sBAAsB,CAAC;AAEzD,eAAO,MAAM,iBAAiB,EAAE,YAAY,CAAC,cAAc,CAc1D,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,YAAY,CAAC,cAAc,CAc1D,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,YAAY,CAAC,cAAc,CAe3D,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,YAAY,CAAC,cAAc,CAelE,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,YAAY,CAAC,cAAc,CAehE,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;;eA9DF,CAAC;;;;;;;;kBAS/B,CAAC;;;;;EAqDoD,CAAC;AAEtD,eAAO,MAA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rivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ 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");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _MockAccountBuilder_account;
13
+ import { BtcAccountType, BtcMethod, BtcScope, EthAccountType, EthMethod, EthScope, KeyringAccountEntropyTypeOption, SolAccountType, SolMethod, SolScope } from "@metamask/keyring-api";
14
+ import { v4 as uuid } from "uuid";
15
+ import { isBip44Account } from "../api/index.mjs";
16
+ const ETH_EOA_METHODS = [
17
+ EthMethod.PersonalSign,
18
+ EthMethod.Sign,
19
+ EthMethod.SignTransaction,
20
+ EthMethod.SignTypedDataV1,
21
+ EthMethod.SignTypedDataV3,
22
+ EthMethod.SignTypedDataV4,
23
+ ];
24
+ const SOL_METHODS = Object.values(SolMethod);
25
+ export const MOCK_SNAP_1 = {
26
+ id: 'local:mock-snap-id-1',
27
+ name: 'Mock Snap 1',
28
+ enabled: true,
29
+ manifest: {
30
+ proposedName: 'Mock Snap 1',
31
+ },
32
+ };
33
+ export const MOCK_SNAP_2 = {
34
+ id: 'local:mock-snap-id-2',
35
+ name: 'Mock Snap 2',
36
+ enabled: true,
37
+ manifest: {
38
+ proposedName: 'Mock Snap 2',
39
+ },
40
+ };
41
+ export const MOCK_ENTROPY_SOURCE_1 = 'mock-keyring-id-1';
42
+ export const MOCK_ENTROPY_SOURCE_2 = 'mock-keyring-id-2';
43
+ export const MOCK_HD_ACCOUNT_1 = {
44
+ id: 'mock-id-1',
45
+ address: '0x123',
46
+ options: {
47
+ entropy: {
48
+ type: KeyringAccountEntropyTypeOption.Mnemonic,
49
+ id: MOCK_ENTROPY_SOURCE_1,
50
+ groupIndex: 0,
51
+ derivationPath: '',
52
+ },
53
+ },
54
+ methods: [...ETH_EOA_METHODS],
55
+ type: EthAccountType.Eoa,
56
+ scopes: [EthScope.Eoa],
57
+ };
58
+ export const MOCK_HD_ACCOUNT_2 = {
59
+ id: 'mock-id-2',
60
+ address: '0x456',
61
+ options: {
62
+ entropy: {
63
+ type: KeyringAccountEntropyTypeOption.Mnemonic,
64
+ id: MOCK_ENTROPY_SOURCE_2,
65
+ groupIndex: 0,
66
+ derivationPath: '',
67
+ },
68
+ },
69
+ methods: [...ETH_EOA_METHODS],
70
+ type: EthAccountType.Eoa,
71
+ scopes: [EthScope.Eoa],
72
+ };
73
+ export const MOCK_SOL_ACCOUNT_1 = {
74
+ id: 'mock-snap-id-1',
75
+ address: 'aabbccdd',
76
+ options: {
77
+ entropy: {
78
+ type: KeyringAccountEntropyTypeOption.Mnemonic,
79
+ // NOTE: shares entropy with MOCK_HD_ACCOUNT_2
80
+ id: MOCK_ENTROPY_SOURCE_2,
81
+ groupIndex: 0,
82
+ derivationPath: '',
83
+ },
84
+ },
85
+ methods: SOL_METHODS,
86
+ type: SolAccountType.DataAccount,
87
+ scopes: [SolScope.Mainnet, SolScope.Testnet, SolScope.Devnet],
88
+ };
89
+ export const MOCK_BTC_P2WPKH_ACCOUNT_1 = {
90
+ id: 'b0f030d8-e101-4b5a-a3dd-13f8ca8ec1db',
91
+ type: BtcAccountType.P2wpkh,
92
+ methods: [BtcMethod.SendBitcoin],
93
+ address: 'bc1qx8ls07cy8j8nrluy2u0xwn7gh8fxg0rg4s8zze',
94
+ options: {
95
+ entropy: {
96
+ type: KeyringAccountEntropyTypeOption.Mnemonic,
97
+ // NOTE: shares entropy with MOCK_HD_ACCOUNT_2
98
+ id: MOCK_ENTROPY_SOURCE_2,
99
+ groupIndex: 0,
100
+ derivationPath: '',
101
+ },
102
+ },
103
+ scopes: [BtcScope.Mainnet],
104
+ };
105
+ export const MOCK_BTC_P2TR_ACCOUNT_1 = {
106
+ id: 'a20c2e1a-6ff6-40ba-b8e0-ccdb6f9933bb',
107
+ type: BtcAccountType.P2tr,
108
+ methods: [BtcMethod.SendBitcoin],
109
+ address: 'tb1p5cyxnuxmeuwuvkwfem96lxx9wex9kkf4mt9ll6q60jfsnrzqg4sszkqjnh',
110
+ options: {
111
+ entropy: {
112
+ type: KeyringAccountEntropyTypeOption.Mnemonic,
113
+ // NOTE: shares entropy with MOCK_HD_ACCOUNT_2
114
+ id: MOCK_ENTROPY_SOURCE_2,
115
+ groupIndex: 0,
116
+ derivationPath: '',
117
+ },
118
+ },
119
+ scopes: [BtcScope.Testnet],
120
+ };
121
+ export const MOCK_SNAP_ACCOUNT_1 = MOCK_SOL_ACCOUNT_1;
122
+ export const MOCK_SNAP_ACCOUNT_2 = {
123
+ id: 'mock-snap-id-2',
124
+ address: '0x789',
125
+ options: {},
126
+ methods: [...ETH_EOA_METHODS],
127
+ type: EthAccountType.Eoa,
128
+ scopes: [EthScope.Eoa],
129
+ };
130
+ export const MOCK_SNAP_ACCOUNT_3 = MOCK_BTC_P2WPKH_ACCOUNT_1;
131
+ export const MOCK_SNAP_ACCOUNT_4 = MOCK_BTC_P2TR_ACCOUNT_1;
132
+ export const MOCK_HARDWARE_ACCOUNT_1 = {
133
+ id: 'mock-hardware-id-1',
134
+ address: '0xABC',
135
+ options: {},
136
+ methods: [...ETH_EOA_METHODS],
137
+ type: EthAccountType.Eoa,
138
+ scopes: [EthScope.Eoa],
139
+ };
140
+ export class MockAccountBuilder {
141
+ constructor(account) {
142
+ _MockAccountBuilder_account.set(this, void 0);
143
+ // Make a deep-copy to avoid mutating the same ref.
144
+ __classPrivateFieldSet(this, _MockAccountBuilder_account, JSON.parse(JSON.stringify(account)), "f");
145
+ }
146
+ static from(account) {
147
+ return new MockAccountBuilder(account);
148
+ }
149
+ withId(id) {
150
+ __classPrivateFieldGet(this, _MockAccountBuilder_account, "f").id = id;
151
+ return this;
152
+ }
153
+ withUuid() {
154
+ __classPrivateFieldGet(this, _MockAccountBuilder_account, "f").id = uuid();
155
+ return this;
156
+ }
157
+ withAddressSuffix(suffix) {
158
+ __classPrivateFieldGet(this, _MockAccountBuilder_account, "f").address += suffix;
159
+ return this;
160
+ }
161
+ withEntropySource(entropySource) {
162
+ if (isBip44Account(__classPrivateFieldGet(this, _MockAccountBuilder_account, "f"))) {
163
+ __classPrivateFieldGet(this, _MockAccountBuilder_account, "f").options.entropy.id = entropySource;
164
+ }
165
+ return this;
166
+ }
167
+ withGroupIndex(groupIndex) {
168
+ if (isBip44Account(__classPrivateFieldGet(this, _MockAccountBuilder_account, "f"))) {
169
+ __classPrivateFieldGet(this, _MockAccountBuilder_account, "f").options.entropy.groupIndex = groupIndex;
170
+ }
171
+ return this;
172
+ }
173
+ get() {
174
+ return __classPrivateFieldGet(this, _MockAccountBuilder_account, "f");
175
+ }
176
+ }
177
+ _MockAccountBuilder_account = new WeakMap();
178
+ export const MOCK_WALLET_1_ENTROPY_SOURCE = MOCK_ENTROPY_SOURCE_1;
179
+ export const MOCK_WALLET_1_EVM_ACCOUNT = MockAccountBuilder.from(MOCK_HD_ACCOUNT_1)
180
+ .withEntropySource(MOCK_WALLET_1_ENTROPY_SOURCE)
181
+ .withGroupIndex(0)
182
+ .get();
183
+ export const MOCK_WALLET_1_SOL_ACCOUNT = MockAccountBuilder.from(MOCK_SOL_ACCOUNT_1)
184
+ .withEntropySource(MOCK_WALLET_1_ENTROPY_SOURCE)
185
+ .withGroupIndex(0)
186
+ .get();
187
+ export const MOCK_WALLET_1_BTC_P2WPKH_ACCOUNT = MockAccountBuilder.from(MOCK_BTC_P2WPKH_ACCOUNT_1)
188
+ .withEntropySource(MOCK_WALLET_1_ENTROPY_SOURCE)
189
+ .withGroupIndex(0)
190
+ .get();
191
+ export const MOCK_WALLET_1_BTC_P2TR_ACCOUNT = MockAccountBuilder.from(MOCK_BTC_P2TR_ACCOUNT_1)
192
+ .withEntropySource(MOCK_WALLET_1_ENTROPY_SOURCE)
193
+ .withGroupIndex(0)
194
+ .get();
195
+ //# sourceMappingURL=accounts.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accounts.mjs","sourceRoot":"","sources":["../../src/tests/accounts.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,OAAO,EACL,cAAc,EACd,SAAS,EACT,QAAQ,EACR,cAAc,EACd,SAAS,EACT,QAAQ,EACR,+BAA+B,EAC/B,cAAc,EACd,SAAS,EACT,QAAQ,EACT,8BAA8B;AAC/B,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,aAAa;AAElC,OAAO,EAAE,cAAc,EAAqB,yBAAe;AAE3D,MAAM,eAAe,GAAG;IACtB,SAAS,CAAC,YAAY;IACtB,SAAS,CAAC,IAAI;IACd,SAAS,CAAC,eAAe;IACzB,SAAS,CAAC,eAAe;IACzB,SAAS,CAAC,eAAe;IACzB,SAAS,CAAC,eAAe;CACjB,CAAC;AAEX,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;AAE7C,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,EAAE,EAAE,sBAAsB;IAC1B,IAAI,EAAE,aAAa;IACnB,OAAO,EAAE,IAAI;IACb,QAAQ,EAAE;QACR,YAAY,EAAE,aAAa;KAC5B;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,EAAE,EAAE,sBAAsB;IAC1B,IAAI,EAAE,aAAa;IACnB,OAAO,EAAE,IAAI;IACb,QAAQ,EAAE;QACR,YAAY,EAAE,aAAa;KAC5B;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG,mBAAmB,CAAC;AACzD,MAAM,CAAC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AAA,IAAI,mCAAS,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,GAAG,UAAU,CAAC;QACxD,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,GAAG;QACD,OAAO,uBAAA,IAAI,mCAAS,CAAC;IACvB,CAAC;CACF;;AAED,MAAM,CAAC,MAAM,4BAA4B,GAAG,qBAAqB,CAAC;AAElE,MAAM,CAAC,MAAM,yBAAyB,GAAG,kBAAkB,CAAC,IAAI,CAC9D,iBAAiB,CAClB;KACE,iBAAiB,CAAC,4BAA4B,CAAC;KAC/C,cAAc,CAAC,CAAC,CAAC;KACjB,GAAG,EAAE,CAAC;AACT,MAAM,CAAC,MAAM,yBAAyB,GAAG,kBAAkB,CAAC,IAAI,CAC9D,kBAAkB,CACnB;KACE,iBAAiB,CAAC,4BAA4B,CAAC;KAC/C,cAAc,CAAC,CAAC,CAAC;KACjB,GAAG,EAAE,CAAC;AACT,MAAM,CAAC,MAAM,gCAAgC,GAAG,kBAAkB,CAAC,IAAI,CACrE,yBAAyB,CAC1B;KACE,iBAAiB,CAAC,4BAA4B,CAAC;KAC/C,cAAc,CAAC,CAAC,CAAC;KACjB,GAAG,EAAE,CAAC;AACT,MAAM,CAAC,MAAM,8BAA8B,GAAG,kBAAkB,CAAC,IAAI,CACnE,uBAAuB,CACxB;KACE,iBAAiB,CAAC,4BAA4B,CAAC;KAC/C,cAAc,CAAC,CAAC,CAAC;KACjB,GAAG,EAAE,CAAC","sourcesContent":["import type { EntropySourceId, KeyringAccount } from '@metamask/keyring-api';\nimport {\n BtcAccountType,\n BtcMethod,\n BtcScope,\n EthAccountType,\n EthMethod,\n EthScope,\n KeyringAccountEntropyTypeOption,\n SolAccountType,\n SolMethod,\n SolScope,\n} from '@metamask/keyring-api';\nimport { v4 as uuid } from 'uuid';\n\nimport { isBip44Account, type Bip44Account } from '../api';\n\nconst ETH_EOA_METHODS = [\n EthMethod.PersonalSign,\n EthMethod.Sign,\n EthMethod.SignTransaction,\n EthMethod.SignTypedDataV1,\n EthMethod.SignTypedDataV3,\n EthMethod.SignTypedDataV4,\n] as const;\n\nconst SOL_METHODS = Object.values(SolMethod);\n\nexport const MOCK_SNAP_1 = {\n id: 'local:mock-snap-id-1',\n name: 'Mock Snap 1',\n enabled: true,\n manifest: {\n proposedName: 'Mock Snap 1',\n },\n};\n\nexport const MOCK_SNAP_2 = {\n id: 'local:mock-snap-id-2',\n name: 'Mock Snap 2',\n enabled: true,\n manifest: {\n proposedName: 'Mock Snap 2',\n },\n};\n\nexport const MOCK_ENTROPY_SOURCE_1 = 'mock-keyring-id-1';\nexport const MOCK_ENTROPY_SOURCE_2 = 'mock-keyring-id-2';\n\nexport const MOCK_HD_ACCOUNT_1: Bip44Account<KeyringAccount> = {\n id: 'mock-id-1',\n address: '0x123',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n id: MOCK_ENTROPY_SOURCE_1,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n};\n\nexport const MOCK_HD_ACCOUNT_2: Bip44Account<KeyringAccount> = {\n id: 'mock-id-2',\n address: '0x456',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n id: MOCK_ENTROPY_SOURCE_2,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n};\n\nexport const MOCK_SOL_ACCOUNT_1: Bip44Account<KeyringAccount> = {\n id: 'mock-snap-id-1',\n address: 'aabbccdd',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n // NOTE: shares entropy with MOCK_HD_ACCOUNT_2\n id: MOCK_ENTROPY_SOURCE_2,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n methods: SOL_METHODS,\n type: SolAccountType.DataAccount,\n scopes: [SolScope.Mainnet, SolScope.Testnet, SolScope.Devnet],\n};\n\nexport const MOCK_BTC_P2WPKH_ACCOUNT_1: Bip44Account<KeyringAccount> = {\n id: 'b0f030d8-e101-4b5a-a3dd-13f8ca8ec1db',\n type: BtcAccountType.P2wpkh,\n methods: [BtcMethod.SendBitcoin],\n address: 'bc1qx8ls07cy8j8nrluy2u0xwn7gh8fxg0rg4s8zze',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n // NOTE: shares entropy with MOCK_HD_ACCOUNT_2\n id: MOCK_ENTROPY_SOURCE_2,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n scopes: [BtcScope.Mainnet],\n};\n\nexport const MOCK_BTC_P2TR_ACCOUNT_1: Bip44Account<KeyringAccount> = {\n id: 'a20c2e1a-6ff6-40ba-b8e0-ccdb6f9933bb',\n type: BtcAccountType.P2tr,\n methods: [BtcMethod.SendBitcoin],\n address: 'tb1p5cyxnuxmeuwuvkwfem96lxx9wex9kkf4mt9ll6q60jfsnrzqg4sszkqjnh',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n // NOTE: shares entropy with MOCK_HD_ACCOUNT_2\n id: MOCK_ENTROPY_SOURCE_2,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n scopes: [BtcScope.Testnet],\n};\n\nexport const MOCK_SNAP_ACCOUNT_1 = MOCK_SOL_ACCOUNT_1;\n\nexport const MOCK_SNAP_ACCOUNT_2: KeyringAccount = {\n id: 'mock-snap-id-2',\n address: '0x789',\n options: {},\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n};\n\nexport const MOCK_SNAP_ACCOUNT_3 = MOCK_BTC_P2WPKH_ACCOUNT_1;\nexport const MOCK_SNAP_ACCOUNT_4 = MOCK_BTC_P2TR_ACCOUNT_1;\n\nexport const MOCK_HARDWARE_ACCOUNT_1: KeyringAccount = {\n id: 'mock-hardware-id-1',\n address: '0xABC',\n options: {},\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n};\n\nexport class MockAccountBuilder<Account extends KeyringAccount> {\n readonly #account: Account;\n\n constructor(account: Account) {\n // Make a deep-copy to avoid mutating the same ref.\n this.#account = JSON.parse(JSON.stringify(account));\n }\n\n static from<Account extends KeyringAccount>(\n account: Account,\n ): MockAccountBuilder<Account> {\n return new MockAccountBuilder(account);\n }\n\n withId(id: KeyringAccount['id']): MockAccountBuilder<Account> {\n this.#account.id = id;\n return this;\n }\n\n withUuid(): MockAccountBuilder<Account> {\n this.#account.id = uuid();\n return this;\n }\n\n withAddressSuffix(suffix: string): MockAccountBuilder<Account> {\n this.#account.address += suffix;\n return this;\n }\n\n withEntropySource(\n entropySource: EntropySourceId,\n ): MockAccountBuilder<Account> {\n if (isBip44Account(this.#account)) {\n this.#account.options.entropy.id = entropySource;\n }\n return this;\n }\n\n withGroupIndex(groupIndex: number): MockAccountBuilder<Account> {\n if (isBip44Account(this.#account)) {\n this.#account.options.entropy.groupIndex = groupIndex;\n }\n return this;\n }\n\n get(): Account {\n return this.#account;\n }\n}\n\nexport const MOCK_WALLET_1_ENTROPY_SOURCE = MOCK_ENTROPY_SOURCE_1;\n\nexport const MOCK_WALLET_1_EVM_ACCOUNT = MockAccountBuilder.from(\n MOCK_HD_ACCOUNT_1,\n)\n .withEntropySource(MOCK_WALLET_1_ENTROPY_SOURCE)\n .withGroupIndex(0)\n .get();\nexport const MOCK_WALLET_1_SOL_ACCOUNT = MockAccountBuilder.from(\n MOCK_SOL_ACCOUNT_1,\n)\n .withEntropySource(MOCK_WALLET_1_ENTROPY_SOURCE)\n .withGroupIndex(0)\n .get();\nexport const MOCK_WALLET_1_BTC_P2WPKH_ACCOUNT = MockAccountBuilder.from(\n MOCK_BTC_P2WPKH_ACCOUNT_1,\n)\n .withEntropySource(MOCK_WALLET_1_ENTROPY_SOURCE)\n .withGroupIndex(0)\n .get();\nexport const MOCK_WALLET_1_BTC_P2TR_ACCOUNT = MockAccountBuilder.from(\n MOCK_BTC_P2TR_ACCOUNT_1,\n)\n .withEntropySource(MOCK_WALLET_1_ENTROPY_SOURCE)\n .withGroupIndex(0)\n .get();\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/account-api",
3
- "version": "0.5.0-0e28ac0",
3
+ "version": "0.7.0-58aa483",
4
4
  "description": "MetaMask Account API",
5
5
  "keywords": [
6
6
  "metamask",
@@ -47,7 +47,6 @@
47
47
  },
48
48
  "dependencies": {
49
49
  "@metamask/keyring-api": "19.1.0",
50
- "@metamask/keyring-utils": "3.1.0",
51
50
  "@metamask/superstruct": "^3.1.0"
52
51
  },
53
52
  "devDependencies": {
@@ -58,7 +57,6 @@
58
57
  "@ts-bridge/cli": "^0.6.3",
59
58
  "@types/jest": "^29.5.12",
60
59
  "@types/node": "^20.12.12",
61
- "@types/uuid": "^9.0.8",
62
60
  "deepmerge": "^4.2.2",
63
61
  "depcheck": "^1.4.7",
64
62
  "jest": "^29.5.0",
@@ -68,8 +66,7 @@
68
66
  "ts-node": "^10.9.2",
69
67
  "tsd": "^0.31.0",
70
68
  "typedoc": "^0.25.13",
71
- "typescript": "~5.6.3",
72
- "uuid": "^9.0.1"
69
+ "typescript": "~5.6.3"
73
70
  },
74
71
  "engines": {
75
72
  "node": "^18.18 || >=20"