@metamask-previews/account-api 0.10.0-9fbf2ff → 0.12.0-ca7f2af

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,9 +7,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.12.0]
11
+
12
+ ### Changed
13
+
14
+ - **BREAKING:** Rename `AccountsProvider.discoverAndCreateAccounts` to `AccountsProvider.discoverAccounts` ([#371](https://github.com/MetaMask/accounts/pull/371))
15
+ - This aligns the method name with `MultichainAccountWallet.discoverAccounts`.
16
+
17
+ ## [0.11.0]
18
+
10
19
  ### Added
11
20
 
12
- - Add wallet `status` ([#367](https://github.com/MetaMask/accounts/pull/367))
21
+ - **BREAKING:** Add `MultichainAccountWallet.{align,discover}Accounts` methods ([#368](https://github.com/MetaMask/accounts/pull/368))
22
+ - **BREAKING:** Add `{Multichain,}AccountWallet.status` getter ([#367](https://github.com/MetaMask/accounts/pull/367))
23
+
24
+ ### Changed
25
+
26
+ - Make `isBip44Account` faster ([#369](https://github.com/MetaMask/accounts/pull/369))
27
+ - We mainly rely on the `options.entropy.type` now and no longer use `superstruct` for this function.
13
28
 
14
29
  ## [0.10.0]
15
30
 
@@ -115,7 +130,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
115
130
 
116
131
  - Add `AccountGroup` and `AccountWallet` ([#307](https://github.com/MetaMask/accounts/pull/307))
117
132
 
118
- [Unreleased]: https://github.com/MetaMask/accounts/compare/@metamask/account-api@0.10.0...HEAD
133
+ [Unreleased]: https://github.com/MetaMask/accounts/compare/@metamask/account-api@0.12.0...HEAD
134
+ [0.12.0]: https://github.com/MetaMask/accounts/compare/@metamask/account-api@0.11.0...@metamask/account-api@0.12.0
135
+ [0.11.0]: https://github.com/MetaMask/accounts/compare/@metamask/account-api@0.10.0...@metamask/account-api@0.11.0
119
136
  [0.10.0]: https://github.com/MetaMask/accounts/compare/@metamask/account-api@0.9.0...@metamask/account-api@0.10.0
120
137
  [0.9.0]: https://github.com/MetaMask/accounts/compare/@metamask/account-api@0.8.0...@metamask/account-api@0.9.0
121
138
  [0.8.0]: https://github.com/MetaMask/accounts/compare/@metamask/account-api@0.7.0...@metamask/account-api@0.8.0
@@ -2,8 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isBip44Account = isBip44Account;
4
4
  exports.assertIsBip44Account = assertIsBip44Account;
5
- const keyring_api_1 = require("@metamask/keyring-api");
6
- const superstruct_1 = require("@metamask/superstruct");
7
5
  /**
8
6
  * Checks if an account is BIP-44 compatible.
9
7
  *
@@ -11,8 +9,9 @@ const superstruct_1 = require("@metamask/superstruct");
11
9
  * @returns True if the account is BIP-44 compatible.
12
10
  */
13
11
  function isBip44Account(account) {
14
- // To be BIP-44 compatible, you just need to use this set of options:
15
- return (0, superstruct_1.is)(account.options.entropy, keyring_api_1.KeyringAccountEntropyMnemonicOptionsStruct);
12
+ // To be BIP-44 compatible, we just check for the entropy type (the
13
+ // the `entropy` shape will be inferred automatically).
14
+ return account.options.entropy?.type === 'mnemonic';
16
15
  }
17
16
  /**
18
17
  * Asserts a keyring account is BIP-44 compatible.
@@ -1 +1 @@
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"]}
1
+ {"version":3,"file":"bip44.cjs","sourceRoot":"","sources":["../../src/api/bip44.ts"],"names":[],"mappings":";;AAsBA,wCAMC;AAQD,oDAMC;AA1BD;;;;;GAKG;AACH,SAAgB,cAAc,CAC5B,OAAgB;IAEhB,mEAAmE;IACnE,uDAAuD;IACvD,OAAO,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,KAAK,UAAU,CAAC;AACtD,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';\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, we just check for the entropy type (the\n // the `entropy` shape will be inferred automatically).\n return account.options.entropy?.type === 'mnemonic';\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"]}
@@ -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;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,SAAS,cAAc,EACjE,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,CAI1C"}
1
+ {"version":3,"file":"bip44.d.cts","sourceRoot":"","sources":["../../src/api/bip44.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,oCAAoC,EACrC,8BAA8B;AAE/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,CAIlC;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,SAAS,cAAc,EACjE,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,CAI1C"}
@@ -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;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,SAAS,cAAc,EACjE,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,CAI1C"}
1
+ {"version":3,"file":"bip44.d.mts","sourceRoot":"","sources":["../../src/api/bip44.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,oCAAoC,EACrC,8BAA8B;AAE/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,CAIlC;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,SAAS,cAAc,EACjE,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,CAI1C"}
@@ -1,5 +1,3 @@
1
- import { KeyringAccountEntropyMnemonicOptionsStruct } from "@metamask/keyring-api";
2
- import { is } from "@metamask/superstruct";
3
1
  /**
4
2
  * Checks if an account is BIP-44 compatible.
5
3
  *
@@ -7,8 +5,9 @@ import { is } from "@metamask/superstruct";
7
5
  * @returns True if the account is BIP-44 compatible.
8
6
  */
9
7
  export function isBip44Account(account) {
10
- // To be BIP-44 compatible, you just need to use this set of options:
11
- return is(account.options.entropy, KeyringAccountEntropyMnemonicOptionsStruct);
8
+ // To be BIP-44 compatible, we just check for the entropy type (the
9
+ // the `entropy` shape will be inferred automatically).
10
+ return account.options.entropy?.type === 'mnemonic';
12
11
  }
13
12
  /**
14
13
  * Asserts a keyring account is BIP-44 compatible.
@@ -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;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"]}
1
+ {"version":3,"file":"bip44.mjs","sourceRoot":"","sources":["../../src/api/bip44.ts"],"names":[],"mappings":"AAgBA;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAC5B,OAAgB;IAEhB,mEAAmE;IACnE,uDAAuD;IACvD,OAAO,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,KAAK,UAAU,CAAC;AACtD,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';\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, we just check for the entropy type (the\n // the `entropy` shape will be inferred automatically).\n return account.options.entropy?.type === 'mnemonic';\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"]}
@@ -1 +1 @@
1
- {"version":3,"file":"wallet.cjs","sourceRoot":"","sources":["../../../src/api/multichain/wallet.ts"],"names":[],"mappings":";;;AA2GA,kEAIC;AAQD,kEAIC;AAUD,wEAYC;AAzID,0CAA8C;AAQ9C;;GAEG;AACU,QAAA,kCAAkC,GAC7C,2DAA2D,CAAC;AAiF9D;;;;;GAKG;AACH,SAAgB,2BAA2B,CACzC,aAA8B;IAE9B,OAAO,GAAG,0BAAiB,CAAC,OAAO,IAAI,aAAa,EAAE,CAAC;AACzD,CAAC;AAED;;;;;GAKG;AACH,SAAgB,2BAA2B,CACzC,KAAa;IAEb,OAAO,0CAAkC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACxD,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,8BAA8B,CAC5C,QAAgB;IAEhB,MAAM,KAAK,GAAG,0CAAkC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAChE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,0CAA0C,QAAQ,GAAG,CAAC,CAAC;IACzE,CAAC;IAED,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,UAAuC;QAC1D,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,WAAqB;KAC1C,CAAC;AACJ,CAAC","sourcesContent":["import {\n type EntropySourceId,\n type KeyringAccount,\n} from '@metamask/keyring-api';\n\nimport type { MultichainAccountGroup } from './group';\nimport type { Bip44Account } from '../bip44';\nimport type { AccountWalletStatus, BaseAccountWallet } from '../wallet';\nimport { AccountWalletType } from '../wallet';\n\n/**\n * Multichain account wallet ID.\n */\nexport type MultichainAccountWalletId =\n `${AccountWalletType.Entropy}:${EntropySourceId}`;\n\n/**\n * Regex to validate a valid multichain account wallet ID.\n */\nexport const MULTICHAIN_ACCOUNT_WALLET_ID_REGEX =\n /^(?<walletId>(?<walletType>entropy):(?<walletSubId>.+))$/u;\n\n/**\n * Parsed multichain account wallet ID with its wallet type and sub-ID.\n */\nexport type ParsedMultichainAccountWalletId = {\n type: AccountWalletType.Entropy;\n subId: string;\n};\n\n/**\n * Wallet status.\n *\n * Those status are used to report in which \"state\" the wallet is currently\n * in. All of those operations cannot run concurrently, thus, the wallet\n * cannot have multiple status at once.\n */\nexport type MultichainAccountWalletStatus =\n | AccountWalletStatus\n /**\n * Discovery is in progress for this wallet. New account groups will be\n * automatically added based on the account provider discovery result.\n */\n | 'in-progress:discovery'\n /**\n * Alignment is in progress for this wallet. Account groups will be\n * automatically updated based on the active account providers.\n */\n | 'in-progress:alignment'\n /**\n * An on-going operation (creating/deleting) is in progress for this\n * wallet. Account groups will either be created or deleted during\n * this operation.\n */\n | 'in-progress:operation';\n\n/**\n * A multichain account wallet that holds multiple multichain accounts (one multichain account per\n * group index).\n */\nexport type MultichainAccountWallet<\n Account extends Bip44Account<KeyringAccount>,\n> = BaseAccountWallet<Account> & {\n /**\n * Multichain account wallet ID.\n */\n get id(): MultichainAccountWalletId;\n\n /**\n * Multichain account wallet type, which is always {@link AccountWalletType.Entropy}.\n */\n get type(): AccountWalletType.Entropy;\n\n /**\n * Multichain account wallet entropy source.\n */\n get entropySource(): EntropySourceId;\n\n /**\n * Multichain account wallet status.\n */\n get status(): MultichainAccountWalletStatus;\n\n /**\n * Gets multichain account for a given index.\n *\n * @param groupIndex - Multichain account index.\n * @returns The multichain account associated with the given index.\n */\n getMultichainAccountGroup(\n groupIndex: number,\n ): MultichainAccountGroup<Account> | undefined;\n\n /**\n * Gets all multichain accounts.\n *\n * @returns The multichain accounts.\n */\n getMultichainAccountGroups(): MultichainAccountGroup<Account>[];\n};\n\n/**\n * Gets the multichain account wallet ID from its entropy source.\n *\n * @param entropySource - Entropy source ID of that wallet.\n * @returns The multichain account wallet ID.\n */\nexport function toMultichainAccountWalletId(\n entropySource: EntropySourceId,\n): MultichainAccountWalletId {\n return `${AccountWalletType.Entropy}:${entropySource}`;\n}\n\n/**\n * Checks if the given value is {@link MultichainAccountWalletId}.\n *\n * @param value - The value to check.\n * @returns Whether the value is a {@link MultichainAccountWalletId}.\n */\nexport function isMultichainAccountWalletId(\n value: string,\n): value is MultichainAccountWalletId {\n return MULTICHAIN_ACCOUNT_WALLET_ID_REGEX.test(value);\n}\n\n/**\n * Parse a multichain account wallet ID to an object containing wallet ID\n * information (wallet type and sub-ID).\n *\n * @param walletId - The account wallet ID to validate and parse.\n * @returns The parsed account wallet ID.\n * @throws When the wallet ID format is invalid.\n */\nexport function parseMultichainAccountWalletId(\n walletId: string,\n): ParsedMultichainAccountWalletId {\n const match = MULTICHAIN_ACCOUNT_WALLET_ID_REGEX.exec(walletId);\n if (!match?.groups) {\n throw new Error(`Invalid multichain account wallet ID: \"${walletId}\"`);\n }\n\n return {\n type: match.groups.walletType as AccountWalletType.Entropy,\n subId: match.groups.walletSubId as string,\n };\n}\n"]}
1
+ {"version":3,"file":"wallet.cjs","sourceRoot":"","sources":["../../../src/api/multichain/wallet.ts"],"names":[],"mappings":";;;AAsIA,kEAIC;AAQD,kEAIC;AAUD,wEAYC;AAnKD,0CAA8C;AAQ9C;;GAEG;AACU,QAAA,kCAAkC,GAC7C,2DAA2D,CAAC;AA2G9D;;;;;GAKG;AACH,SAAgB,2BAA2B,CACzC,aAA8B;IAE9B,OAAO,GAAG,0BAAiB,CAAC,OAAO,IAAI,aAAa,EAAE,CAAC;AACzD,CAAC;AAED;;;;;GAKG;AACH,SAAgB,2BAA2B,CACzC,KAAa;IAEb,OAAO,0CAAkC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACxD,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,8BAA8B,CAC5C,QAAgB;IAEhB,MAAM,KAAK,GAAG,0CAAkC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAChE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,0CAA0C,QAAQ,GAAG,CAAC,CAAC;IACzE,CAAC;IAED,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,UAAuC;QAC1D,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,WAAqB;KAC1C,CAAC;AACJ,CAAC","sourcesContent":["import {\n type EntropySourceId,\n type KeyringAccount,\n} from '@metamask/keyring-api';\n\nimport type { MultichainAccountGroup } from './group';\nimport type { Bip44Account } from '../bip44';\nimport type { AccountGroup, AccountGroupId } from '../group';\nimport type { AccountWalletStatus, BaseAccountWallet } from '../wallet';\nimport { AccountWalletType } from '../wallet';\n\n/**\n * Multichain account wallet ID.\n */\nexport type MultichainAccountWalletId =\n `${AccountWalletType.Entropy}:${EntropySourceId}`;\n\n/**\n * Regex to validate a valid multichain account wallet ID.\n */\nexport const MULTICHAIN_ACCOUNT_WALLET_ID_REGEX =\n /^(?<walletId>(?<walletType>entropy):(?<walletSubId>.+))$/u;\n\n/**\n * Parsed multichain account wallet ID with its wallet type and sub-ID.\n */\nexport type ParsedMultichainAccountWalletId = {\n type: AccountWalletType.Entropy;\n subId: string;\n};\n\n/**\n * Wallet status.\n *\n * Those status are used to report in which \"state\" the wallet is currently\n * in. All of those operations cannot run concurrently, thus, the wallet\n * cannot have multiple status at once.\n */\nexport type MultichainAccountWalletStatus =\n | AccountWalletStatus\n /**\n * Discovery is in progress for this wallet. New account groups will be\n * automatically added based on the account provider discovery result.\n */\n | 'in-progress:discovery'\n /**\n * Alignment is in progress for this wallet. Account groups will be\n * automatically updated based on the active account providers.\n */\n | 'in-progress:alignment'\n /**\n * The wallet is creating new accounts. New account groups will be\n * added to the wallet automatically.\n */\n | 'in-progress:create-accounts';\n\n/**\n * A multichain account wallet that holds multiple multichain accounts (one multichain account per\n * group index).\n */\nexport type MultichainAccountWallet<\n Account extends Bip44Account<KeyringAccount>,\n> = BaseAccountWallet<Account> & {\n /**\n * Multichain account wallet ID.\n */\n get id(): MultichainAccountWalletId;\n\n /**\n * Multichain account wallet type, which is always {@link AccountWalletType.Entropy}.\n */\n get type(): AccountWalletType.Entropy;\n\n /**\n * Multichain account wallet entropy source.\n */\n get entropySource(): EntropySourceId;\n\n /**\n * Multichain account wallet status.\n */\n get status(): MultichainAccountWalletStatus;\n\n /**\n * Gets account group for a given ID.\n *\n * @param id - Account group ID.\n * @returns Account group.\n */\n getAccountGroup(id: AccountGroupId): AccountGroup<Account> | undefined;\n\n /**\n * Gets all account groups.\n *\n * @returns Account groups.\n */\n getAccountGroups(): AccountGroup<Account>[];\n\n /**\n * Gets multichain account for a given index.\n *\n * @param groupIndex - Multichain account index.\n * @returns The multichain account associated with the given index.\n */\n getMultichainAccountGroup(\n groupIndex: number,\n ): MultichainAccountGroup<Account> | undefined;\n\n /**\n * Gets all multichain accounts.\n *\n * @returns The multichain accounts.\n */\n getMultichainAccountGroups(): MultichainAccountGroup<Account>[];\n\n /**\n * Discover and create accounts.\n *\n * @returns The discovered accounts.\n */\n discoverAccounts(): Promise<Account[]>;\n\n /**\n * Align all accounts accross existing multichain account groups.\n */\n alignAccounts(): Promise<void>;\n};\n\n/**\n * Gets the multichain account wallet ID from its entropy source.\n *\n * @param entropySource - Entropy source ID of that wallet.\n * @returns The multichain account wallet ID.\n */\nexport function toMultichainAccountWalletId(\n entropySource: EntropySourceId,\n): MultichainAccountWalletId {\n return `${AccountWalletType.Entropy}:${entropySource}`;\n}\n\n/**\n * Checks if the given value is {@link MultichainAccountWalletId}.\n *\n * @param value - The value to check.\n * @returns Whether the value is a {@link MultichainAccountWalletId}.\n */\nexport function isMultichainAccountWalletId(\n value: string,\n): value is MultichainAccountWalletId {\n return MULTICHAIN_ACCOUNT_WALLET_ID_REGEX.test(value);\n}\n\n/**\n * Parse a multichain account wallet ID to an object containing wallet ID\n * information (wallet type and sub-ID).\n *\n * @param walletId - The account wallet ID to validate and parse.\n * @returns The parsed account wallet ID.\n * @throws When the wallet ID format is invalid.\n */\nexport function parseMultichainAccountWalletId(\n walletId: string,\n): ParsedMultichainAccountWalletId {\n const match = MULTICHAIN_ACCOUNT_WALLET_ID_REGEX.exec(walletId);\n if (!match?.groups) {\n throw new Error(`Invalid multichain account wallet ID: \"${walletId}\"`);\n }\n\n return {\n type: match.groups.walletType as AccountWalletType.Entropy,\n subId: match.groups.walletSubId as string,\n };\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import { type EntropySourceId, type KeyringAccount } from "@metamask/keyring-api";
2
2
  import type { MultichainAccountGroup } from "./group.cjs";
3
3
  import type { Bip44Account } from "../bip44.cjs";
4
+ import type { AccountGroup, AccountGroupId } from "../group.cjs";
4
5
  import type { AccountWalletStatus, BaseAccountWallet } from "../wallet.cjs";
5
6
  import { AccountWalletType } from "../wallet.cjs";
6
7
  /**
@@ -37,11 +38,10 @@ export type MultichainAccountWalletStatus = AccountWalletStatus
37
38
  */
38
39
  | 'in-progress:alignment'
39
40
  /**
40
- * An on-going operation (creating/deleting) is in progress for this
41
- * wallet. Account groups will either be created or deleted during
42
- * this operation.
41
+ * The wallet is creating new accounts. New account groups will be
42
+ * added to the wallet automatically.
43
43
  */
44
- | 'in-progress:operation';
44
+ | 'in-progress:create-accounts';
45
45
  /**
46
46
  * A multichain account wallet that holds multiple multichain accounts (one multichain account per
47
47
  * group index).
@@ -63,6 +63,19 @@ export type MultichainAccountWallet<Account extends Bip44Account<KeyringAccount>
63
63
  * Multichain account wallet status.
64
64
  */
65
65
  get status(): MultichainAccountWalletStatus;
66
+ /**
67
+ * Gets account group for a given ID.
68
+ *
69
+ * @param id - Account group ID.
70
+ * @returns Account group.
71
+ */
72
+ getAccountGroup(id: AccountGroupId): AccountGroup<Account> | undefined;
73
+ /**
74
+ * Gets all account groups.
75
+ *
76
+ * @returns Account groups.
77
+ */
78
+ getAccountGroups(): AccountGroup<Account>[];
66
79
  /**
67
80
  * Gets multichain account for a given index.
68
81
  *
@@ -76,6 +89,16 @@ export type MultichainAccountWallet<Account extends Bip44Account<KeyringAccount>
76
89
  * @returns The multichain accounts.
77
90
  */
78
91
  getMultichainAccountGroups(): MultichainAccountGroup<Account>[];
92
+ /**
93
+ * Discover and create accounts.
94
+ *
95
+ * @returns The discovered accounts.
96
+ */
97
+ discoverAccounts(): Promise<Account[]>;
98
+ /**
99
+ * Align all accounts accross existing multichain account groups.
100
+ */
101
+ alignAccounts(): Promise<void>;
79
102
  };
80
103
  /**
81
104
  * Gets the multichain account wallet ID from its entropy source.
@@ -1 +1 @@
1
- {"version":3,"file":"wallet.d.cts","sourceRoot":"","sources":["../../../src/api/multichain/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,cAAc,EACpB,8BAA8B;AAE/B,OAAO,KAAK,EAAE,sBAAsB,EAAE,oBAAgB;AACtD,OAAO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,CAAC;IAErC;;OAEG;IACH,IAAI,MAAM,IAAI,6BAA6B,CAAC;IAE5C;;;;;OAKG;IACH,eAAe,CAAC,EAAE,EAAE,cAAc,GAAG,YAAY,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC;IAEvE;;;;OAIG;IACH,gBAAgB,IAAI,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC;IAE5C;;;;;OAKG;IACH,yBAAyB,CACvB,UAAU,EAAE,MAAM,GACjB,sBAAsB,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC;IAE/C;;;;OAIG;IACH,0BAA0B,IAAI,sBAAsB,CAAC,OAAO,CAAC,EAAE,CAAC;IAEhE;;;;OAIG;IACH,gBAAgB,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IAEvC;;OAEG;IACH,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAChC,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACzC,aAAa,EAAE,eAAe,GAC7B,yBAAyB,CAE3B;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,MAAM,GACZ,KAAK,IAAI,yBAAyB,CAEpC;AAED;;;;;;;GAOG;AACH,wBAAgB,8BAA8B,CAC5C,QAAQ,EAAE,MAAM,GACf,+BAA+B,CAUjC"}
@@ -1,6 +1,7 @@
1
1
  import { type EntropySourceId, type KeyringAccount } from "@metamask/keyring-api";
2
2
  import type { MultichainAccountGroup } from "./group.mjs";
3
3
  import type { Bip44Account } from "../bip44.mjs";
4
+ import type { AccountGroup, AccountGroupId } from "../group.mjs";
4
5
  import type { AccountWalletStatus, BaseAccountWallet } from "../wallet.mjs";
5
6
  import { AccountWalletType } from "../wallet.mjs";
6
7
  /**
@@ -37,11 +38,10 @@ export type MultichainAccountWalletStatus = AccountWalletStatus
37
38
  */
38
39
  | 'in-progress:alignment'
39
40
  /**
40
- * An on-going operation (creating/deleting) is in progress for this
41
- * wallet. Account groups will either be created or deleted during
42
- * this operation.
41
+ * The wallet is creating new accounts. New account groups will be
42
+ * added to the wallet automatically.
43
43
  */
44
- | 'in-progress:operation';
44
+ | 'in-progress:create-accounts';
45
45
  /**
46
46
  * A multichain account wallet that holds multiple multichain accounts (one multichain account per
47
47
  * group index).
@@ -63,6 +63,19 @@ export type MultichainAccountWallet<Account extends Bip44Account<KeyringAccount>
63
63
  * Multichain account wallet status.
64
64
  */
65
65
  get status(): MultichainAccountWalletStatus;
66
+ /**
67
+ * Gets account group for a given ID.
68
+ *
69
+ * @param id - Account group ID.
70
+ * @returns Account group.
71
+ */
72
+ getAccountGroup(id: AccountGroupId): AccountGroup<Account> | undefined;
73
+ /**
74
+ * Gets all account groups.
75
+ *
76
+ * @returns Account groups.
77
+ */
78
+ getAccountGroups(): AccountGroup<Account>[];
66
79
  /**
67
80
  * Gets multichain account for a given index.
68
81
  *
@@ -76,6 +89,16 @@ export type MultichainAccountWallet<Account extends Bip44Account<KeyringAccount>
76
89
  * @returns The multichain accounts.
77
90
  */
78
91
  getMultichainAccountGroups(): MultichainAccountGroup<Account>[];
92
+ /**
93
+ * Discover and create accounts.
94
+ *
95
+ * @returns The discovered accounts.
96
+ */
97
+ discoverAccounts(): Promise<Account[]>;
98
+ /**
99
+ * Align all accounts accross existing multichain account groups.
100
+ */
101
+ alignAccounts(): Promise<void>;
79
102
  };
80
103
  /**
81
104
  * Gets the multichain account wallet ID from its entropy source.
@@ -1 +1 @@
1
- {"version":3,"file":"wallet.d.mts","sourceRoot":"","sources":["../../../src/api/multichain/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,cAAc,EACpB,8BAA8B;AAE/B,OAAO,KAAK,EAAE,sBAAsB,EAAE,oBAAgB;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,qBAAiB;AAC7C,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,sBAAkB;AACxE,OAAO,EAAE,iBAAiB,EAAE,sBAAkB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AAkC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAChE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,0CAA0C,QAAQ,GAAG,CAAC,CAAC;IACzE,CAAC;IAED,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,UAAuC;QAC1D,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,WAAqB;KAC1C,CAAC;AACJ,CAAC","sourcesContent":["import {\n type EntropySourceId,\n type KeyringAccount,\n} from '@metamask/keyring-api';\n\nimport type { MultichainAccountGroup } from './group';\nimport type { Bip44Account } from '../bip44';\nimport type { AccountWalletStatus, BaseAccountWallet } from '../wallet';\nimport { AccountWalletType } from '../wallet';\n\n/**\n * Multichain account wallet ID.\n */\nexport type MultichainAccountWalletId =\n `${AccountWalletType.Entropy}:${EntropySourceId}`;\n\n/**\n * Regex to validate a valid multichain account wallet ID.\n */\nexport const MULTICHAIN_ACCOUNT_WALLET_ID_REGEX =\n /^(?<walletId>(?<walletType>entropy):(?<walletSubId>.+))$/u;\n\n/**\n * Parsed multichain account wallet ID with its wallet type and sub-ID.\n */\nexport type ParsedMultichainAccountWalletId = {\n type: AccountWalletType.Entropy;\n subId: string;\n};\n\n/**\n * Wallet status.\n *\n * Those status are used to report in which \"state\" the wallet is currently\n * in. All of those operations cannot run concurrently, thus, the wallet\n * cannot have multiple status at once.\n */\nexport type MultichainAccountWalletStatus =\n | AccountWalletStatus\n /**\n * Discovery is in progress for this wallet. New account groups will be\n * automatically added based on the account provider discovery result.\n */\n | 'in-progress:discovery'\n /**\n * Alignment is in progress for this wallet. Account groups will be\n * automatically updated based on the active account providers.\n */\n | 'in-progress:alignment'\n /**\n * An on-going operation (creating/deleting) is in progress for this\n * wallet. Account groups will either be created or deleted during\n * this operation.\n */\n | 'in-progress:operation';\n\n/**\n * A multichain account wallet that holds multiple multichain accounts (one multichain account per\n * group index).\n */\nexport type MultichainAccountWallet<\n Account extends Bip44Account<KeyringAccount>,\n> = BaseAccountWallet<Account> & {\n /**\n * Multichain account wallet ID.\n */\n get id(): MultichainAccountWalletId;\n\n /**\n * Multichain account wallet type, which is always {@link AccountWalletType.Entropy}.\n */\n get type(): AccountWalletType.Entropy;\n\n /**\n * Multichain account wallet entropy source.\n */\n get entropySource(): EntropySourceId;\n\n /**\n * Multichain account wallet status.\n */\n get status(): MultichainAccountWalletStatus;\n\n /**\n * Gets multichain account for a given index.\n *\n * @param groupIndex - Multichain account index.\n * @returns The multichain account associated with the given index.\n */\n getMultichainAccountGroup(\n groupIndex: number,\n ): MultichainAccountGroup<Account> | undefined;\n\n /**\n * Gets all multichain accounts.\n *\n * @returns The multichain accounts.\n */\n getMultichainAccountGroups(): MultichainAccountGroup<Account>[];\n};\n\n/**\n * Gets the multichain account wallet ID from its entropy source.\n *\n * @param entropySource - Entropy source ID of that wallet.\n * @returns The multichain account wallet ID.\n */\nexport function toMultichainAccountWalletId(\n entropySource: EntropySourceId,\n): MultichainAccountWalletId {\n return `${AccountWalletType.Entropy}:${entropySource}`;\n}\n\n/**\n * Checks if the given value is {@link MultichainAccountWalletId}.\n *\n * @param value - The value to check.\n * @returns Whether the value is a {@link MultichainAccountWalletId}.\n */\nexport function isMultichainAccountWalletId(\n value: string,\n): value is MultichainAccountWalletId {\n return MULTICHAIN_ACCOUNT_WALLET_ID_REGEX.test(value);\n}\n\n/**\n * Parse a multichain account wallet ID to an object containing wallet ID\n * information (wallet type and sub-ID).\n *\n * @param walletId - The account wallet ID to validate and parse.\n * @returns The parsed account wallet ID.\n * @throws When the wallet ID format is invalid.\n */\nexport function parseMultichainAccountWalletId(\n walletId: string,\n): ParsedMultichainAccountWalletId {\n const match = MULTICHAIN_ACCOUNT_WALLET_ID_REGEX.exec(walletId);\n if (!match?.groups) {\n throw new Error(`Invalid multichain account wallet ID: \"${walletId}\"`);\n }\n\n return {\n type: match.groups.walletType as AccountWalletType.Entropy,\n subId: match.groups.walletSubId as string,\n };\n}\n"]}
1
+ {"version":3,"file":"wallet.mjs","sourceRoot":"","sources":["../../../src/api/multichain/wallet.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,iBAAiB,EAAE,sBAAkB;AAQ9C;;GAEG;AACH,MAAM,CAAC,MAAM,kCAAkC,GAC7C,2DAA2D,CAAC;AA2G9D;;;;;GAKG;AACH,MAAM,UAAU,2BAA2B,CACzC,aAA8B;IAE9B,OAAO,GAAG,iBAAiB,CAAC,OAAO,IAAI,aAAa,EAAE,CAAC;AACzD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,2BAA2B,CACzC,KAAa;IAEb,OAAO,kCAAkC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACxD,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,8BAA8B,CAC5C,QAAgB;IAEhB,MAAM,KAAK,GAAG,kCAAkC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAChE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,0CAA0C,QAAQ,GAAG,CAAC,CAAC;IACzE,CAAC;IAED,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,UAAuC;QAC1D,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,WAAqB;KAC1C,CAAC;AACJ,CAAC","sourcesContent":["import {\n type EntropySourceId,\n type KeyringAccount,\n} from '@metamask/keyring-api';\n\nimport type { MultichainAccountGroup } from './group';\nimport type { Bip44Account } from '../bip44';\nimport type { AccountGroup, AccountGroupId } from '../group';\nimport type { AccountWalletStatus, BaseAccountWallet } from '../wallet';\nimport { AccountWalletType } from '../wallet';\n\n/**\n * Multichain account wallet ID.\n */\nexport type MultichainAccountWalletId =\n `${AccountWalletType.Entropy}:${EntropySourceId}`;\n\n/**\n * Regex to validate a valid multichain account wallet ID.\n */\nexport const MULTICHAIN_ACCOUNT_WALLET_ID_REGEX =\n /^(?<walletId>(?<walletType>entropy):(?<walletSubId>.+))$/u;\n\n/**\n * Parsed multichain account wallet ID with its wallet type and sub-ID.\n */\nexport type ParsedMultichainAccountWalletId = {\n type: AccountWalletType.Entropy;\n subId: string;\n};\n\n/**\n * Wallet status.\n *\n * Those status are used to report in which \"state\" the wallet is currently\n * in. All of those operations cannot run concurrently, thus, the wallet\n * cannot have multiple status at once.\n */\nexport type MultichainAccountWalletStatus =\n | AccountWalletStatus\n /**\n * Discovery is in progress for this wallet. New account groups will be\n * automatically added based on the account provider discovery result.\n */\n | 'in-progress:discovery'\n /**\n * Alignment is in progress for this wallet. Account groups will be\n * automatically updated based on the active account providers.\n */\n | 'in-progress:alignment'\n /**\n * The wallet is creating new accounts. New account groups will be\n * added to the wallet automatically.\n */\n | 'in-progress:create-accounts';\n\n/**\n * A multichain account wallet that holds multiple multichain accounts (one multichain account per\n * group index).\n */\nexport type MultichainAccountWallet<\n Account extends Bip44Account<KeyringAccount>,\n> = BaseAccountWallet<Account> & {\n /**\n * Multichain account wallet ID.\n */\n get id(): MultichainAccountWalletId;\n\n /**\n * Multichain account wallet type, which is always {@link AccountWalletType.Entropy}.\n */\n get type(): AccountWalletType.Entropy;\n\n /**\n * Multichain account wallet entropy source.\n */\n get entropySource(): EntropySourceId;\n\n /**\n * Multichain account wallet status.\n */\n get status(): MultichainAccountWalletStatus;\n\n /**\n * Gets account group for a given ID.\n *\n * @param id - Account group ID.\n * @returns Account group.\n */\n getAccountGroup(id: AccountGroupId): AccountGroup<Account> | undefined;\n\n /**\n * Gets all account groups.\n *\n * @returns Account groups.\n */\n getAccountGroups(): AccountGroup<Account>[];\n\n /**\n * Gets multichain account for a given index.\n *\n * @param groupIndex - Multichain account index.\n * @returns The multichain account associated with the given index.\n */\n getMultichainAccountGroup(\n groupIndex: number,\n ): MultichainAccountGroup<Account> | undefined;\n\n /**\n * Gets all multichain accounts.\n *\n * @returns The multichain accounts.\n */\n getMultichainAccountGroups(): MultichainAccountGroup<Account>[];\n\n /**\n * Discover and create accounts.\n *\n * @returns The discovered accounts.\n */\n discoverAccounts(): Promise<Account[]>;\n\n /**\n * Align all accounts accross existing multichain account groups.\n */\n alignAccounts(): Promise<void>;\n};\n\n/**\n * Gets the multichain account wallet ID from its entropy source.\n *\n * @param entropySource - Entropy source ID of that wallet.\n * @returns The multichain account wallet ID.\n */\nexport function toMultichainAccountWalletId(\n entropySource: EntropySourceId,\n): MultichainAccountWalletId {\n return `${AccountWalletType.Entropy}:${entropySource}`;\n}\n\n/**\n * Checks if the given value is {@link MultichainAccountWalletId}.\n *\n * @param value - The value to check.\n * @returns Whether the value is a {@link MultichainAccountWalletId}.\n */\nexport function isMultichainAccountWalletId(\n value: string,\n): value is MultichainAccountWalletId {\n return MULTICHAIN_ACCOUNT_WALLET_ID_REGEX.test(value);\n}\n\n/**\n * Parse a multichain account wallet ID to an object containing wallet ID\n * information (wallet type and sub-ID).\n *\n * @param walletId - The account wallet ID to validate and parse.\n * @returns The parsed account wallet ID.\n * @throws When the wallet ID format is invalid.\n */\nexport function parseMultichainAccountWalletId(\n walletId: string,\n): ParsedMultichainAccountWalletId {\n const match = MULTICHAIN_ACCOUNT_WALLET_ID_REGEX.exec(walletId);\n if (!match?.groups) {\n throw new Error(`Invalid multichain account wallet ID: \"${walletId}\"`);\n }\n\n return {\n type: match.groups.walletType as AccountWalletType.Entropy,\n subId: match.groups.walletSubId as string,\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"provider.cjs","sourceRoot":"","sources":["../../src/api/provider.ts"],"names":[],"mappings":"","sourcesContent":["import type { EntropySourceId, KeyringAccount } from '@metamask/keyring-api';\n\nimport type { Bip44Account } from './bip44';\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\n/**\n * A BIP-44 provider is a provider that can provide BIP-44 compatible accounts.\n *\n * Note: This is an alias for the `AccountProvider` type, but with a more specific\n * type for the account.\n */\nexport type Bip44AccountProvider = AccountProvider<\n Bip44Account<KeyringAccount>\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\nimport type { Bip44Account } from './bip44';\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 discoverAccounts: (options: {\n entropySource: EntropySourceId;\n groupIndex: number;\n }) => Promise<Account[]>;\n};\n\n/**\n * A BIP-44 provider is a provider that can provide BIP-44 compatible accounts.\n *\n * Note: This is an alias for the `AccountProvider` type, but with a more specific\n * type for the account.\n */\nexport type Bip44AccountProvider = AccountProvider<\n Bip44Account<KeyringAccount>\n>;\n"]}
@@ -40,7 +40,7 @@ export type AccountProvider<Account extends KeyringAccount> = {
40
40
  * @param options.groupIndex - Group index to use.
41
41
  * @returns The list of discovered and created accounts.
42
42
  */
43
- discoverAndCreateAccounts: (options: {
43
+ discoverAccounts: (options: {
44
44
  entropySource: EntropySourceId;
45
45
  groupIndex: number;
46
46
  }) => Promise<Account[]>;
@@ -1 +1 @@
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,OAAO,KAAK,EAAE,YAAY,EAAE,oBAAgB;AAE5C;;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;AAEF;;;;;GAKG;AACH,MAAM,MAAM,oBAAoB,GAAG,eAAe,CAChD,YAAY,CAAC,cAAc,CAAC,CAC7B,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,OAAO,KAAK,EAAE,YAAY,EAAE,oBAAgB;AAE5C;;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,gBAAgB,EAAE,CAAC,OAAO,EAAE;QAC1B,aAAa,EAAE,eAAe,CAAC;QAC/B,UAAU,EAAE,MAAM,CAAC;KACpB,KAAK,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;CAC1B,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,oBAAoB,GAAG,eAAe,CAChD,YAAY,CAAC,cAAc,CAAC,CAC7B,CAAC"}
@@ -40,7 +40,7 @@ export type AccountProvider<Account extends KeyringAccount> = {
40
40
  * @param options.groupIndex - Group index to use.
41
41
  * @returns The list of discovered and created accounts.
42
42
  */
43
- discoverAndCreateAccounts: (options: {
43
+ discoverAccounts: (options: {
44
44
  entropySource: EntropySourceId;
45
45
  groupIndex: number;
46
46
  }) => Promise<Account[]>;
@@ -1 +1 @@
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,OAAO,KAAK,EAAE,YAAY,EAAE,oBAAgB;AAE5C;;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;AAEF;;;;;GAKG;AACH,MAAM,MAAM,oBAAoB,GAAG,eAAe,CAChD,YAAY,CAAC,cAAc,CAAC,CAC7B,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,OAAO,KAAK,EAAE,YAAY,EAAE,oBAAgB;AAE5C;;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,gBAAgB,EAAE,CAAC,OAAO,EAAE;QAC1B,aAAa,EAAE,eAAe,CAAC;QAC/B,UAAU,EAAE,MAAM,CAAC;KACpB,KAAK,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;CAC1B,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,oBAAoB,GAAG,eAAe,CAChD,YAAY,CAAC,cAAc,CAAC,CAC7B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"provider.mjs","sourceRoot":"","sources":["../../src/api/provider.ts"],"names":[],"mappings":"","sourcesContent":["import type { EntropySourceId, KeyringAccount } from '@metamask/keyring-api';\n\nimport type { Bip44Account } from './bip44';\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\n/**\n * A BIP-44 provider is a provider that can provide BIP-44 compatible accounts.\n *\n * Note: This is an alias for the `AccountProvider` type, but with a more specific\n * type for the account.\n */\nexport type Bip44AccountProvider = AccountProvider<\n Bip44Account<KeyringAccount>\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\nimport type { Bip44Account } from './bip44';\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 discoverAccounts: (options: {\n entropySource: EntropySourceId;\n groupIndex: number;\n }) => Promise<Account[]>;\n};\n\n/**\n * A BIP-44 provider is a provider that can provide BIP-44 compatible accounts.\n *\n * Note: This is an alias for the `AccountProvider` type, but with a more specific\n * type for the account.\n */\nexport type Bip44AccountProvider = AccountProvider<\n Bip44Account<KeyringAccount>\n>;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"wallet.cjs","sourceRoot":"","sources":["../../src/api/wallet.ts"],"names":[],"mappings":";;;AAwJA,8CAKC;AAQD,8CAEC;AAUD,oDAUC;AASD,wDAEC;AA/LD;;;;GAIG;AACH,IAAY,iBASX;AATD,WAAY,iBAAiB;IAC3B,8DAA8D;IAC9D,wCAAmB,CAAA;IAEnB,8DAA8D;IAC9D,wCAAmB,CAAA;IAEnB,2EAA2E;IAC3E,kCAAa,CAAA;AACf,CAAC,EATW,iBAAiB,iCAAjB,iBAAiB,QAS5B;AAOD;;GAEG;AACU,QAAA,uBAAuB,GAClC,2DAA2D,CAAC;AAiH9D;;;;;;GAMG;AACH,SAAgB,iBAAiB,CAC/B,IAAgB,EAChB,EAAU;IAEV,OAAO,GAAG,IAAI,IAAI,EAAE,EAAE,CAAC;AACzB,CAAC;AAED;;;;;GAKG;AACH,SAAgB,iBAAiB,CAAC,KAAa;IAC7C,OAAO,+BAAuB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC7C,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,oBAAoB,CAAC,QAAgB;IACnD,MAAM,KAAK,GAAG,+BAAuB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACrD,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,+BAA+B,QAAQ,GAAG,CAAC,CAAC;IAC9D,CAAC;IAED,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,UAA+B;QAClD,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,WAAqB;KAC1C,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,sBAAsB,CAAC,QAAgB;IACrD,OAAO,oBAAoB,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC;AAC9C,CAAC","sourcesContent":["import type { KeyringAccount } from '@metamask/keyring-api';\n\n// Circular import are allowed when using `import type`.\nimport type { Bip44Account } from './bip44';\nimport type { AccountGroup, AccountGroupId } from './group';\nimport type { MultichainAccountWallet } from './multichain';\n\n/**\n * Wallet type.\n *\n * Each wallet types groups accounts using different criterias.\n */\nexport enum AccountWalletType {\n /** Wallet grouping accounts based on their entropy source. */\n Entropy = 'entropy',\n\n /** Wallet grouping accounts based on their keyring's type. */\n Keyring = 'keyring',\n\n /** Wallet grouping accounts associated with an account management Snap. */\n Snap = 'snap',\n}\n\n/**\n * Account wallet ID.\n */\nexport type AccountWalletId = `${AccountWalletType}:${string}`;\n\n/**\n * Regex to validate an account wallet ID.\n */\nexport const ACCOUNT_WALLET_ID_REGEX =\n /^(?<walletType>entropy|keyring|snap):(?<walletSubId>.+)$/u;\n\n/**\n * Wallet status.\n *\n * Those status are used to report in which \"state\" the wallet is currently\n * in. All of those operations cannot run concurrently, thus, the wallet\n * cannot have multiple status at once.\n */\nexport type AccountWalletStatus =\n /**\n * The wallet is not initialized yet.\n */\n | 'uninitialized'\n /**\n * The wallet is ready to run any operation.\n */\n | 'ready';\n\n/**\n * Parsed account wallet ID with its wallet type and sub-ID.\n */\nexport type ParsedAccountWalletId = {\n type: AccountWalletType;\n subId: string;\n};\n\n/**\n * Keyring account wallet that can hold multiple account groups.\n */\nexport type BaseAccountWallet<Account extends KeyringAccount> = {\n /**\n * Account wallet ID.\n */\n get id(): AccountWalletId;\n\n /**\n * Keyring account wallet type.\n */\n get type(): AccountWalletType;\n\n /**\n * Account wallet status.\n */\n get status(): AccountWalletStatus;\n\n /**\n * Gets account group for a given ID.\n *\n * @param id - Account group ID.\n * @returns Account group.\n */\n getAccountGroup(id: AccountGroupId): AccountGroup<Account> | undefined;\n\n /**\n * Gets all account groups.\n *\n * @returns Account groups.\n */\n getAccountGroups(): AccountGroup<Account>[];\n};\n\n/**\n * Keyring account wallet that can hold multiple account groups.\n */\nexport type KeyringAccountWallet<Account extends KeyringAccount> =\n BaseAccountWallet<Account> & {\n /**\n * Keyring account wallet type.\n */\n get type(): AccountWalletType.Keyring;\n };\n\n/**\n * Snap keyring account wallet that can hold multiple account groups.\n */\nexport type SnapAccountWallet<Account extends KeyringAccount> =\n BaseAccountWallet<Account> & {\n /**\n * Snap account wallet type.\n */\n get type(): AccountWalletType.Snap;\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 IsAccountWallet<\n Wallet extends BaseAccountWallet<Account> & {\n get type(): AccountWalletType;\n },\n Account extends KeyringAccount,\n> = Wallet;\n\n/**\n * Account wallet that can hold multiple account groups.\n */\nexport type AccountWallet<Account extends KeyringAccount> = IsAccountWallet<\n | KeyringAccountWallet<Account>\n | SnapAccountWallet<Account>\n | MultichainAccountWallet<Bip44Account<Account>>,\n Account\n>;\n\n/**\n * Type utility to compute a constrained {@link AccountWalletId} type given a\n * specifc {@link AccountWalletType}.\n */\nexport type AccountWalletIdOf<WalletType extends AccountWalletType> =\n `${WalletType}:${string}`;\n\n/**\n * Convert a unique ID to a wallet ID for a given type.\n *\n * @param type - A wallet type.\n * @param id - A unique ID.\n * @returns A wallet ID.\n */\nexport function toAccountWalletId<WalletType extends AccountWalletType>(\n type: WalletType,\n id: string,\n): AccountWalletIdOf<WalletType> {\n return `${type}:${id}`;\n}\n\n/**\n * Checks if the given value is {@link AccountWalletId}.\n *\n * @param value - The value to check.\n * @returns Whether the value is a {@link AccountWalletId}.\n */\nexport function isAccountWalletId(value: string): value is AccountWalletId {\n return ACCOUNT_WALLET_ID_REGEX.test(value);\n}\n\n/**\n * Parse an account wallet ID to an object containing a wallet ID information\n * (wallet type and wallet sub-ID).\n *\n * @param walletId - The account wallet ID to validate and parse.\n * @returns The parsed account wallet ID.\n * @throws When the wallet ID format is invalid.\n */\nexport function parseAccountWalletId(walletId: string): ParsedAccountWalletId {\n const match = ACCOUNT_WALLET_ID_REGEX.exec(walletId);\n if (!match?.groups) {\n throw new Error(`Invalid account wallet ID: \"${walletId}\"`);\n }\n\n return {\n type: match.groups.walletType as AccountWalletType,\n subId: match.groups.walletSubId as string,\n };\n}\n\n/**\n * Strip the account wallet type from an account wallet ID.\n *\n * @param walletId - Account wallet ID.\n * @returns Account wallet sub-ID.\n * @throws When the wallet ID format is invalid.\n */\nexport function stripAccountWalletType(walletId: string): string {\n return parseAccountWalletId(walletId).subId;\n}\n"]}
1
+ {"version":3,"file":"wallet.cjs","sourceRoot":"","sources":["../../src/api/wallet.ts"],"names":[],"mappings":";;;AAgKA,8CAKC;AAQD,8CAEC;AAUD,oDAUC;AASD,wDAEC;AAvMD;;;;GAIG;AACH,IAAY,iBASX;AATD,WAAY,iBAAiB;IAC3B,8DAA8D;IAC9D,wCAAmB,CAAA;IAEnB,8DAA8D;IAC9D,wCAAmB,CAAA;IAEnB,2EAA2E;IAC3E,kCAAa,CAAA;AACf,CAAC,EATW,iBAAiB,iCAAjB,iBAAiB,QAS5B;AAOD;;GAEG;AACU,QAAA,uBAAuB,GAClC,2DAA2D,CAAC;AAyH9D;;;;;;GAMG;AACH,SAAgB,iBAAiB,CAC/B,IAAgB,EAChB,EAAU;IAEV,OAAO,GAAG,IAAI,IAAI,EAAE,EAAE,CAAC;AACzB,CAAC;AAED;;;;;GAKG;AACH,SAAgB,iBAAiB,CAAC,KAAa;IAC7C,OAAO,+BAAuB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC7C,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,oBAAoB,CAAC,QAAgB;IACnD,MAAM,KAAK,GAAG,+BAAuB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACrD,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,+BAA+B,QAAQ,GAAG,CAAC,CAAC;IAC9D,CAAC;IAED,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,UAA+B;QAClD,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,WAAqB;KAC1C,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,sBAAsB,CAAC,QAAgB;IACrD,OAAO,oBAAoB,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC;AAC9C,CAAC","sourcesContent":["import type { KeyringAccount } from '@metamask/keyring-api';\n\n// Circular import are allowed when using `import type`.\nimport type { Bip44Account } from './bip44';\nimport type { AccountGroup, AccountGroupId } from './group';\nimport type { MultichainAccountWallet } from './multichain';\n\n/**\n * Wallet type.\n *\n * Each wallet types groups accounts using different criterias.\n */\nexport enum AccountWalletType {\n /** Wallet grouping accounts based on their entropy source. */\n Entropy = 'entropy',\n\n /** Wallet grouping accounts based on their keyring's type. */\n Keyring = 'keyring',\n\n /** Wallet grouping accounts associated with an account management Snap. */\n Snap = 'snap',\n}\n\n/**\n * Account wallet ID.\n */\nexport type AccountWalletId = `${AccountWalletType}:${string}`;\n\n/**\n * Regex to validate an account wallet ID.\n */\nexport const ACCOUNT_WALLET_ID_REGEX =\n /^(?<walletType>entropy|keyring|snap):(?<walletSubId>.+)$/u;\n\n/**\n * Wallet status.\n *\n * Those status are used to report in which \"state\" the wallet is currently\n * in. All of those operations cannot run concurrently, thus, the wallet\n * cannot have multiple status at once.\n */\nexport type AccountWalletStatus =\n /**\n * The wallet is not initialized yet.\n */\n | 'uninitialized'\n /**\n * The wallet is ready to run any operation.\n */\n | 'ready';\n\n/**\n * Parsed account wallet ID with its wallet type and sub-ID.\n */\nexport type ParsedAccountWalletId = {\n type: AccountWalletType;\n subId: string;\n};\n\n/**\n * Keyring account wallet that can hold multiple account groups.\n */\nexport type BaseAccountWallet<Account extends KeyringAccount> = {\n /**\n * Account wallet ID.\n */\n get id(): AccountWalletId;\n\n /**\n * Account wallet type.\n */\n get type(): AccountWalletType;\n\n /**\n * Account wallet status.\n */\n get status(): string; // Has to be refined by the type extending this base type.\n\n /**\n * Gets account group for a given ID.\n *\n * @param id - Account group ID.\n * @returns Account group.\n */\n getAccountGroup(id: AccountGroupId): AccountGroup<Account> | undefined;\n\n /**\n * Gets all account groups.\n *\n * @returns Account groups.\n */\n getAccountGroups(): AccountGroup<Account>[];\n};\n\n/**\n * Keyring account wallet that can hold multiple account groups.\n */\nexport type KeyringAccountWallet<Account extends KeyringAccount> =\n BaseAccountWallet<Account> & {\n /**\n * Keyring account wallet type, which is always {@link AccountWalletType.Keyring}.\n */\n get type(): AccountWalletType.Keyring;\n\n /**\n * Account wallet status.\n */\n get status(): AccountWalletStatus;\n };\n\n/**\n * Snap keyring account wallet that can hold multiple account groups.\n */\nexport type SnapAccountWallet<Account extends KeyringAccount> =\n BaseAccountWallet<Account> & {\n /**\n * Snap account wallet type, which is always {@link AccountWalletType.Snap}.\n */\n get type(): AccountWalletType.Snap;\n\n /**\n * Account wallet status.\n */\n get status(): AccountWalletStatus;\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 IsAccountWallet<\n Wallet extends BaseAccountWallet<Account>,\n Account extends KeyringAccount,\n> = Wallet;\n\n/**\n * Account wallet that can hold multiple account groups.\n */\nexport type AccountWallet<Account extends KeyringAccount> = IsAccountWallet<\n | KeyringAccountWallet<Account>\n | SnapAccountWallet<Account>\n | MultichainAccountWallet<Bip44Account<Account>>,\n Account\n>;\n\n/**\n * Type utility to compute a constrained {@link AccountWalletId} type given a\n * specifc {@link AccountWalletType}.\n */\nexport type AccountWalletIdOf<WalletType extends AccountWalletType> =\n `${WalletType}:${string}`;\n\n/**\n * Convert a unique ID to a wallet ID for a given type.\n *\n * @param type - A wallet type.\n * @param id - A unique ID.\n * @returns A wallet ID.\n */\nexport function toAccountWalletId<WalletType extends AccountWalletType>(\n type: WalletType,\n id: string,\n): AccountWalletIdOf<WalletType> {\n return `${type}:${id}`;\n}\n\n/**\n * Checks if the given value is {@link AccountWalletId}.\n *\n * @param value - The value to check.\n * @returns Whether the value is a {@link AccountWalletId}.\n */\nexport function isAccountWalletId(value: string): value is AccountWalletId {\n return ACCOUNT_WALLET_ID_REGEX.test(value);\n}\n\n/**\n * Parse an account wallet ID to an object containing a wallet ID information\n * (wallet type and wallet sub-ID).\n *\n * @param walletId - The account wallet ID to validate and parse.\n * @returns The parsed account wallet ID.\n * @throws When the wallet ID format is invalid.\n */\nexport function parseAccountWalletId(walletId: string): ParsedAccountWalletId {\n const match = ACCOUNT_WALLET_ID_REGEX.exec(walletId);\n if (!match?.groups) {\n throw new Error(`Invalid account wallet ID: \"${walletId}\"`);\n }\n\n return {\n type: match.groups.walletType as AccountWalletType,\n subId: match.groups.walletSubId as string,\n };\n}\n\n/**\n * Strip the account wallet type from an account wallet ID.\n *\n * @param walletId - Account wallet ID.\n * @returns Account wallet sub-ID.\n * @throws When the wallet ID format is invalid.\n */\nexport function stripAccountWalletType(walletId: string): string {\n return parseAccountWalletId(walletId).subId;\n}\n"]}
@@ -55,13 +55,13 @@ export type BaseAccountWallet<Account extends KeyringAccount> = {
55
55
  */
56
56
  get id(): AccountWalletId;
57
57
  /**
58
- * Keyring account wallet type.
58
+ * Account wallet type.
59
59
  */
60
60
  get type(): AccountWalletType;
61
61
  /**
62
62
  * Account wallet status.
63
63
  */
64
- get status(): AccountWalletStatus;
64
+ get status(): string;
65
65
  /**
66
66
  * Gets account group for a given ID.
67
67
  *
@@ -81,27 +81,33 @@ export type BaseAccountWallet<Account extends KeyringAccount> = {
81
81
  */
82
82
  export type KeyringAccountWallet<Account extends KeyringAccount> = BaseAccountWallet<Account> & {
83
83
  /**
84
- * Keyring account wallet type.
84
+ * Keyring account wallet type, which is always {@link AccountWalletType.Keyring}.
85
85
  */
86
86
  get type(): AccountWalletType.Keyring;
87
+ /**
88
+ * Account wallet status.
89
+ */
90
+ get status(): AccountWalletStatus;
87
91
  };
88
92
  /**
89
93
  * Snap keyring account wallet that can hold multiple account groups.
90
94
  */
91
95
  export type SnapAccountWallet<Account extends KeyringAccount> = BaseAccountWallet<Account> & {
92
96
  /**
93
- * Snap account wallet type.
97
+ * Snap account wallet type, which is always {@link AccountWalletType.Snap}.
94
98
  */
95
99
  get type(): AccountWalletType.Snap;
100
+ /**
101
+ * Account wallet status.
102
+ */
103
+ get status(): AccountWalletStatus;
96
104
  };
97
105
  /**
98
106
  * Type constraint for a {@link AccountGroupObject}. If one of its union-members
99
107
  * does not match this contraint, {@link AccountGroupObject} will resolve
100
108
  * to `never`.
101
109
  */
102
- type IsAccountWallet<Wallet extends BaseAccountWallet<Account> & {
103
- get type(): AccountWalletType;
104
- }, Account extends KeyringAccount> = Wallet;
110
+ type IsAccountWallet<Wallet extends BaseAccountWallet<Account>, Account extends KeyringAccount> = Wallet;
105
111
  /**
106
112
  * Account wallet that can hold multiple account groups.
107
113
  */
@@ -1 +1 @@
1
- {"version":3,"file":"wallet.d.cts","sourceRoot":"","sources":["../../src/api/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,8BAA8B;AAG5D,OAAO,KAAK,EAAE,YAAY,EAAE,oBAAgB;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,oBAAgB;AAC5D,OAAO,KAAK,EAAE,uBAAuB,EAAE,+BAAqB;AAE5D;;;;GAIG;AACH,oBAAY,iBAAiB;IAC3B,8DAA8D;IAC9D,OAAO,YAAY;IAEnB,8DAA8D;IAC9D,OAAO,YAAY;IAEnB,2EAA2E;IAC3E,IAAI,SAAS;CACd;AAED;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,GAAG,iBAAiB,IAAI,MAAM,EAAE,CAAC;AAE/D;;GAEG;AACH,eAAO,MAAM,uBAAuB,QACyB,CAAC;AAE9D;;;;;;GAMG;AACH,MAAM,MAAM,mBAAmB;AAC7B;;GAEG;AACD,eAAe;AACjB;;GAEG;GACD,OAAO,CAAC;AAEZ;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,iBAAiB,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,iBAAiB,CAAC,OAAO,SAAS,cAAc,IAAI;IAC9D;;OAEG;IACH,IAAI,EAAE,IAAI,eAAe,CAAC;IAE1B;;OAEG;IACH,IAAI,I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U,EAChB,EAAE,EAAE,MAAM,GACT,iBAAiB,CAAC,UAAU,CAAC,CAE/B;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,eAAe,CAEzE;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,qBAAqB,CAU5E;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE/D"}
@@ -55,13 +55,13 @@ export type BaseAccountWallet<Account extends KeyringAccount> = {
55
55
  */
56
56
  get id(): AccountWalletId;
57
57
  /**
58
- * Keyring account wallet type.
58
+ * Account wallet type.
59
59
  */
60
60
  get type(): AccountWalletType;
61
61
  /**
62
62
  * Account wallet status.
63
63
  */
64
- get status(): AccountWalletStatus;
64
+ get status(): string;
65
65
  /**
66
66
  * Gets account group for a given ID.
67
67
  *
@@ -81,27 +81,33 @@ export type BaseAccountWallet<Account extends KeyringAccount> = {
81
81
  */
82
82
  export type KeyringAccountWallet<Account extends KeyringAccount> = BaseAccountWallet<Account> & {
83
83
  /**
84
- * Keyring account wallet type.
84
+ * Keyring account wallet type, which is always {@link AccountWalletType.Keyring}.
85
85
  */
86
86
  get type(): AccountWalletType.Keyring;
87
+ /**
88
+ * Account wallet status.
89
+ */
90
+ get status(): AccountWalletStatus;
87
91
  };
88
92
  /**
89
93
  * Snap keyring account wallet that can hold multiple account groups.
90
94
  */
91
95
  export type SnapAccountWallet<Account extends KeyringAccount> = BaseAccountWallet<Account> & {
92
96
  /**
93
- * Snap account wallet type.
97
+ * Snap account wallet type, which is always {@link AccountWalletType.Snap}.
94
98
  */
95
99
  get type(): AccountWalletType.Snap;
100
+ /**
101
+ * Account wallet status.
102
+ */
103
+ get status(): AccountWalletStatus;
96
104
  };
97
105
  /**
98
106
  * Type constraint for a {@link AccountGroupObject}. If one of its union-members
99
107
  * does not match this contraint, {@link AccountGroupObject} will resolve
100
108
  * to `never`.
101
109
  */
102
- type IsAccountWallet<Wallet extends BaseAccountWallet<Account> & {
103
- get type(): AccountWalletType;
104
- }, Account extends KeyringAccount> = Wallet;
110
+ type IsAccountWallet<Wallet extends BaseAccountWallet<Account>, Account extends KeyringAccount> = Wallet;
105
111
  /**
106
112
  * Account wallet that can hold multiple account groups.
107
113
  */
@@ -1 +1 @@
1
- {"version":3,"file":"wallet.d.mts","sourceRoot":"","sources":["../../src/api/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,8BAA8B;AAG5D,OAAO,KAAK,EAAE,YAAY,EAAE,oBAAgB;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,oBAAgB;AAC5D,OAAO,KAAK,EAAE,uBAAuB,EAAE,+BAAqB;AAE5D;;;;GAIG;AACH,oBAAY,iBAAiB;IAC3B,8DAA8D;IAC9D,OAAO,YAAY;IAEnB,8DAA8D;IAC9D,OAAO,YAAY;IAEnB,2EAA2E;IAC3E,IAAI,SAAS;CACd;AAED;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,GAAG,iBAAiB,IAAI,MAAM,EAAE,CAAC;AAE/D;;GAEG;AACH,eAAO,MAAM,uBAAuB,QACyB,CAAC;AAE9D;;;;;;GAMG;AACH,MAAM,MAAM,mBAAmB;AAC7B;;GAEG;AACD,eAAe;AACjB;;GAEG;GACD,OAAO,CAAC;AAEZ;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,iBAAiB,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,iBAAiB,CAAC,OAAO,SAAS,cAAc,IAAI;IAC9D;;OAEG;IACH,IAAI,EAAE,IAAI,eAAe,CAAC;IAE1B;;OAEG;IACH,IAAI,IAAI,IAAI,iBAAiB,CAAC;IAE9B;;OAEG;IACH,IAAI,MAAM,IAAI,mBAAmB,CAAC;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,WAAqB;KAC1C,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CAAC,QAAgB;IACrD,OAAO,oBAAoB,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC;AAC9C,CAAC","sourcesContent":["import type { KeyringAccount } from '@metamask/keyring-api';\n\n// Circular import are allowed when using `import type`.\nimport type { Bip44Account } from './bip44';\nimport type { AccountGroup, AccountGroupId } from './group';\nimport type { MultichainAccountWallet } from './multichain';\n\n/**\n * Wallet type.\n *\n * Each wallet types groups accounts using different criterias.\n */\nexport enum AccountWalletType {\n /** Wallet grouping accounts based on their entropy source. */\n Entropy = 'entropy',\n\n /** Wallet grouping accounts based on their keyring's type. */\n Keyring = 'keyring',\n\n /** Wallet grouping accounts associated with an account management Snap. */\n Snap = 'snap',\n}\n\n/**\n * Account wallet ID.\n */\nexport type AccountWalletId = `${AccountWalletType}:${string}`;\n\n/**\n * Regex to validate an account wallet ID.\n */\nexport const ACCOUNT_WALLET_ID_REGEX =\n /^(?<walletType>entropy|keyring|snap):(?<walletSubId>.+)$/u;\n\n/**\n * Wallet status.\n *\n * Those status are used to report in which \"state\" the wallet is currently\n * in. All of those operations cannot run concurrently, thus, the wallet\n * cannot have multiple status at once.\n */\nexport type AccountWalletStatus =\n /**\n * The wallet is not initialized yet.\n */\n | 'uninitialized'\n /**\n * The wallet is ready to run any operation.\n */\n | 'ready';\n\n/**\n * Parsed account wallet ID with its wallet type and sub-ID.\n */\nexport type ParsedAccountWalletId = {\n type: AccountWalletType;\n subId: string;\n};\n\n/**\n * Keyring account wallet that can hold multiple account groups.\n */\nexport type BaseAccountWallet<Account extends KeyringAccount> = {\n /**\n * Account wallet ID.\n */\n get id(): AccountWalletId;\n\n /**\n * Keyring account wallet type.\n */\n get type(): AccountWalletType;\n\n /**\n * Account wallet status.\n */\n get status(): AccountWalletStatus;\n\n /**\n * Gets account group for a given ID.\n *\n * @param id - Account group ID.\n * @returns Account group.\n */\n getAccountGroup(id: AccountGroupId): AccountGroup<Account> | undefined;\n\n /**\n * Gets all account groups.\n *\n * @returns Account groups.\n */\n getAccountGroups(): AccountGroup<Account>[];\n};\n\n/**\n * Keyring account wallet that can hold multiple account groups.\n */\nexport type KeyringAccountWallet<Account extends KeyringAccount> =\n BaseAccountWallet<Account> & {\n /**\n * Keyring account wallet type.\n */\n get type(): AccountWalletType.Keyring;\n };\n\n/**\n * Snap keyring account wallet that can hold multiple account groups.\n */\nexport type SnapAccountWallet<Account extends KeyringAccount> =\n BaseAccountWallet<Account> & {\n /**\n * Snap account wallet type.\n */\n get type(): AccountWalletType.Snap;\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 IsAccountWallet<\n Wallet extends BaseAccountWallet<Account> & {\n get type(): AccountWalletType;\n },\n Account extends KeyringAccount,\n> = Wallet;\n\n/**\n * Account wallet that can hold multiple account groups.\n */\nexport type AccountWallet<Account extends KeyringAccount> = IsAccountWallet<\n | KeyringAccountWallet<Account>\n | SnapAccountWallet<Account>\n | MultichainAccountWallet<Bip44Account<Account>>,\n Account\n>;\n\n/**\n * Type utility to compute a constrained {@link AccountWalletId} type given a\n * specifc {@link AccountWalletType}.\n */\nexport type AccountWalletIdOf<WalletType extends AccountWalletType> =\n `${WalletType}:${string}`;\n\n/**\n * Convert a unique ID to a wallet ID for a given type.\n *\n * @param type - A wallet type.\n * @param id - A unique ID.\n * @returns A wallet ID.\n */\nexport function toAccountWalletId<WalletType extends AccountWalletType>(\n type: WalletType,\n id: string,\n): AccountWalletIdOf<WalletType> {\n return `${type}:${id}`;\n}\n\n/**\n * Checks if the given value is {@link AccountWalletId}.\n *\n * @param value - The value to check.\n * @returns Whether the value is a {@link AccountWalletId}.\n */\nexport function isAccountWalletId(value: string): value is AccountWalletId {\n return ACCOUNT_WALLET_ID_REGEX.test(value);\n}\n\n/**\n * Parse an account wallet ID to an object containing a wallet ID information\n * (wallet type and wallet sub-ID).\n *\n * @param walletId - The account wallet ID to validate and parse.\n * @returns The parsed account wallet ID.\n * @throws When the wallet ID format is invalid.\n */\nexport function parseAccountWalletId(walletId: string): ParsedAccountWalletId {\n const match = ACCOUNT_WALLET_ID_REGEX.exec(walletId);\n if (!match?.groups) {\n throw new Error(`Invalid account wallet ID: \"${walletId}\"`);\n }\n\n return {\n type: match.groups.walletType as AccountWalletType,\n subId: match.groups.walletSubId as string,\n };\n}\n\n/**\n * Strip the account wallet type from an account wallet ID.\n *\n * @param walletId - Account wallet ID.\n * @returns Account wallet sub-ID.\n * @throws When the wallet ID format is invalid.\n */\nexport function stripAccountWalletType(walletId: string): string {\n return parseAccountWalletId(walletId).subId;\n}\n"]}
1
+ {"version":3,"file":"wallet.mjs","sourceRoot":"","sources":["../../src/api/wallet.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,MAAM,CAAN,IAAY,iBASX;AATD,WAAY,iBAAiB;IAC3B,8DAA8D;IAC9D,wCAAmB,CAAA;IAEnB,8DAA8D;IAC9D,wCAAmB,CAAA;IAEnB,2EAA2E;IAC3E,kCAAa,CAAA;AACf,CAAC,EATW,iBAAiB,KAAjB,iBAAiB,QAS5B;AAOD;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAClC,2DAA2D,CAAC;AAyH9D;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAC/B,IAAgB,EAChB,EAAU;IAEV,OAAO,GAAG,IAAI,IAAI,EAAE,EAAE,CAAC;AACzB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAa;IAC7C,OAAO,uBAAuB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC7C,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAAC,QAAgB;IACnD,MAAM,KAAK,GAAG,uBAAuB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACrD,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,+BAA+B,QAAQ,GAAG,CAAC,CAAC;IAC9D,CAAC;IAED,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,UAA+B;QAClD,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,WAAqB;KAC1C,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CAAC,QAAgB;IACrD,OAAO,oBAAoB,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC;AAC9C,CAAC","sourcesContent":["import type { KeyringAccount } from '@metamask/keyring-api';\n\n// Circular import are allowed when using `import type`.\nimport type { Bip44Account } from './bip44';\nimport type { AccountGroup, AccountGroupId } from './group';\nimport type { MultichainAccountWallet } from './multichain';\n\n/**\n * Wallet type.\n *\n * Each wallet types groups accounts using different criterias.\n */\nexport enum AccountWalletType {\n /** Wallet grouping accounts based on their entropy source. */\n Entropy = 'entropy',\n\n /** Wallet grouping accounts based on their keyring's type. */\n Keyring = 'keyring',\n\n /** Wallet grouping accounts associated with an account management Snap. */\n Snap = 'snap',\n}\n\n/**\n * Account wallet ID.\n */\nexport type AccountWalletId = `${AccountWalletType}:${string}`;\n\n/**\n * Regex to validate an account wallet ID.\n */\nexport const ACCOUNT_WALLET_ID_REGEX =\n /^(?<walletType>entropy|keyring|snap):(?<walletSubId>.+)$/u;\n\n/**\n * Wallet status.\n *\n * Those status are used to report in which \"state\" the wallet is currently\n * in. All of those operations cannot run concurrently, thus, the wallet\n * cannot have multiple status at once.\n */\nexport type AccountWalletStatus =\n /**\n * The wallet is not initialized yet.\n */\n | 'uninitialized'\n /**\n * The wallet is ready to run any operation.\n */\n | 'ready';\n\n/**\n * Parsed account wallet ID with its wallet type and sub-ID.\n */\nexport type ParsedAccountWalletId = {\n type: AccountWalletType;\n subId: string;\n};\n\n/**\n * Keyring account wallet that can hold multiple account groups.\n */\nexport type BaseAccountWallet<Account extends KeyringAccount> = {\n /**\n * Account wallet ID.\n */\n get id(): AccountWalletId;\n\n /**\n * Account wallet type.\n */\n get type(): AccountWalletType;\n\n /**\n * Account wallet status.\n */\n get status(): string; // Has to be refined by the type extending this base type.\n\n /**\n * Gets account group for a given ID.\n *\n * @param id - Account group ID.\n * @returns Account group.\n */\n getAccountGroup(id: AccountGroupId): AccountGroup<Account> | undefined;\n\n /**\n * Gets all account groups.\n *\n * @returns Account groups.\n */\n getAccountGroups(): AccountGroup<Account>[];\n};\n\n/**\n * Keyring account wallet that can hold multiple account groups.\n */\nexport type KeyringAccountWallet<Account extends KeyringAccount> =\n BaseAccountWallet<Account> & {\n /**\n * Keyring account wallet type, which is always {@link AccountWalletType.Keyring}.\n */\n get type(): AccountWalletType.Keyring;\n\n /**\n * Account wallet status.\n */\n get status(): AccountWalletStatus;\n };\n\n/**\n * Snap keyring account wallet that can hold multiple account groups.\n */\nexport type SnapAccountWallet<Account extends KeyringAccount> =\n BaseAccountWallet<Account> & {\n /**\n * Snap account wallet type, which is always {@link AccountWalletType.Snap}.\n */\n get type(): AccountWalletType.Snap;\n\n /**\n * Account wallet status.\n */\n get status(): AccountWalletStatus;\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 IsAccountWallet<\n Wallet extends BaseAccountWallet<Account>,\n Account extends KeyringAccount,\n> = Wallet;\n\n/**\n * Account wallet that can hold multiple account groups.\n */\nexport type AccountWallet<Account extends KeyringAccount> = IsAccountWallet<\n | KeyringAccountWallet<Account>\n | SnapAccountWallet<Account>\n | MultichainAccountWallet<Bip44Account<Account>>,\n Account\n>;\n\n/**\n * Type utility to compute a constrained {@link AccountWalletId} type given a\n * specifc {@link AccountWalletType}.\n */\nexport type AccountWalletIdOf<WalletType extends AccountWalletType> =\n `${WalletType}:${string}`;\n\n/**\n * Convert a unique ID to a wallet ID for a given type.\n *\n * @param type - A wallet type.\n * @param id - A unique ID.\n * @returns A wallet ID.\n */\nexport function toAccountWalletId<WalletType extends AccountWalletType>(\n type: WalletType,\n id: string,\n): AccountWalletIdOf<WalletType> {\n return `${type}:${id}`;\n}\n\n/**\n * Checks if the given value is {@link AccountWalletId}.\n *\n * @param value - The value to check.\n * @returns Whether the value is a {@link AccountWalletId}.\n */\nexport function isAccountWalletId(value: string): value is AccountWalletId {\n return ACCOUNT_WALLET_ID_REGEX.test(value);\n}\n\n/**\n * Parse an account wallet ID to an object containing a wallet ID information\n * (wallet type and wallet sub-ID).\n *\n * @param walletId - The account wallet ID to validate and parse.\n * @returns The parsed account wallet ID.\n * @throws When the wallet ID format is invalid.\n */\nexport function parseAccountWalletId(walletId: string): ParsedAccountWalletId {\n const match = ACCOUNT_WALLET_ID_REGEX.exec(walletId);\n if (!match?.groups) {\n throw new Error(`Invalid account wallet ID: \"${walletId}\"`);\n }\n\n return {\n type: match.groups.walletType as AccountWalletType,\n subId: match.groups.walletSubId as string,\n };\n}\n\n/**\n * Strip the account wallet type from an account wallet ID.\n *\n * @param walletId - Account wallet ID.\n * @returns Account wallet sub-ID.\n * @throws When the wallet ID format is invalid.\n */\nexport function stripAccountWalletType(walletId: string): string {\n return parseAccountWalletId(walletId).subId;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/account-api",
3
- "version": "0.10.0-9fbf2ff",
3
+ "version": "0.12.0-ca7f2af",
4
4
  "description": "MetaMask Account API",
5
5
  "keywords": [
6
6
  "metamask",
@@ -58,7 +58,6 @@
58
58
  "dependencies": {
59
59
  "@metamask/keyring-api": "21.0.0",
60
60
  "@metamask/keyring-utils": "3.1.0",
61
- "@metamask/superstruct": "^3.1.0",
62
61
  "uuid": "^9.0.1"
63
62
  },
64
63
  "devDependencies": {