@metamask/keyring-api 21.3.0 → 21.5.0

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.
Files changed (163) hide show
  1. package/CHANGELOG.md +49 -2
  2. package/README.md +4 -0
  3. package/dist/api/account-options.cjs +44 -7
  4. package/dist/api/account-options.cjs.map +1 -1
  5. package/dist/api/account-options.d.cts +41 -3
  6. package/dist/api/account-options.d.cts.map +1 -1
  7. package/dist/api/account-options.d.mts +41 -3
  8. package/dist/api/account-options.d.mts.map +1 -1
  9. package/dist/api/account-options.mjs +43 -6
  10. package/dist/api/account-options.mjs.map +1 -1
  11. package/dist/api/account.d.cts +4 -0
  12. package/dist/api/account.d.cts.map +1 -1
  13. package/dist/api/account.d.mts +4 -0
  14. package/dist/api/account.d.mts.map +1 -1
  15. package/dist/api/keyring.cjs +0 -2
  16. package/dist/api/keyring.cjs.map +1 -1
  17. package/dist/api/keyring.d.cts +13 -0
  18. package/dist/api/keyring.d.cts.map +1 -1
  19. package/dist/api/keyring.d.mts +13 -0
  20. package/dist/api/keyring.d.mts.map +1 -1
  21. package/dist/api/keyring.mjs +0 -2
  22. package/dist/api/keyring.mjs.map +1 -1
  23. package/dist/api/v2/create-account/bip44.cjs +27 -1
  24. package/dist/api/v2/create-account/bip44.cjs.map +1 -1
  25. package/dist/api/v2/create-account/bip44.d.cts +46 -0
  26. package/dist/api/v2/create-account/bip44.d.cts.map +1 -1
  27. package/dist/api/v2/create-account/bip44.d.mts +46 -0
  28. package/dist/api/v2/create-account/bip44.d.mts.map +1 -1
  29. package/dist/api/v2/create-account/bip44.mjs +26 -0
  30. package/dist/api/v2/create-account/bip44.mjs.map +1 -1
  31. package/dist/api/v2/create-account/custom.cjs +14 -0
  32. package/dist/api/v2/create-account/custom.cjs.map +1 -0
  33. package/dist/api/v2/create-account/custom.d.cts +25 -0
  34. package/dist/api/v2/create-account/custom.d.cts.map +1 -0
  35. package/dist/api/v2/create-account/custom.d.mts +25 -0
  36. package/dist/api/v2/create-account/custom.d.mts.map +1 -0
  37. package/dist/api/v2/create-account/custom.mjs +11 -0
  38. package/dist/api/v2/create-account/custom.mjs.map +1 -0
  39. package/dist/api/v2/create-account/index.cjs +55 -0
  40. package/dist/api/v2/create-account/index.cjs.map +1 -1
  41. package/dist/api/v2/create-account/index.d.cts +55 -1
  42. package/dist/api/v2/create-account/index.d.cts.map +1 -1
  43. package/dist/api/v2/create-account/index.d.mts +55 -1
  44. package/dist/api/v2/create-account/index.d.mts.map +1 -1
  45. package/dist/api/v2/create-account/index.mjs +55 -1
  46. package/dist/api/v2/create-account/index.mjs.map +1 -1
  47. package/dist/api/v2/index.cjs +1 -0
  48. package/dist/api/v2/index.cjs.map +1 -1
  49. package/dist/api/v2/index.d.cts +1 -0
  50. package/dist/api/v2/index.d.cts.map +1 -1
  51. package/dist/api/v2/index.d.mts +1 -0
  52. package/dist/api/v2/index.d.mts.map +1 -1
  53. package/dist/api/v2/index.mjs +1 -0
  54. package/dist/api/v2/index.mjs.map +1 -1
  55. package/dist/api/v2/keyring-capabilities.cjs +17 -3
  56. package/dist/api/v2/keyring-capabilities.cjs.map +1 -1
  57. package/dist/api/v2/keyring-capabilities.d.cts +31 -9
  58. package/dist/api/v2/keyring-capabilities.d.cts.map +1 -1
  59. package/dist/api/v2/keyring-capabilities.d.mts +31 -9
  60. package/dist/api/v2/keyring-capabilities.d.mts.map +1 -1
  61. package/dist/api/v2/keyring-capabilities.mjs +18 -4
  62. package/dist/api/v2/keyring-capabilities.mjs.map +1 -1
  63. package/dist/api/v2/wrapper/index.cjs +19 -0
  64. package/dist/api/v2/wrapper/index.cjs.map +1 -0
  65. package/dist/api/v2/wrapper/index.d.cts +3 -0
  66. package/dist/api/v2/wrapper/index.d.cts.map +1 -0
  67. package/dist/api/v2/wrapper/index.d.mts +3 -0
  68. package/dist/api/v2/wrapper/index.d.mts.map +1 -0
  69. package/dist/api/v2/wrapper/index.mjs +3 -0
  70. package/dist/api/v2/wrapper/index.mjs.map +1 -0
  71. package/dist/api/v2/wrapper/keyring-account-registry.cjs +135 -0
  72. package/dist/api/v2/wrapper/keyring-account-registry.cjs.map +1 -0
  73. package/dist/api/v2/wrapper/keyring-account-registry.d.cts +88 -0
  74. package/dist/api/v2/wrapper/keyring-account-registry.d.cts.map +1 -0
  75. package/dist/api/v2/wrapper/keyring-account-registry.d.mts +88 -0
  76. package/dist/api/v2/wrapper/keyring-account-registry.d.mts.map +1 -0
  77. package/dist/api/v2/wrapper/keyring-account-registry.mjs +131 -0
  78. package/dist/api/v2/wrapper/keyring-account-registry.mjs.map +1 -0
  79. package/dist/api/v2/wrapper/keyring-wrapper.cjs +134 -0
  80. package/dist/api/v2/wrapper/keyring-wrapper.cjs.map +1 -0
  81. package/dist/api/v2/wrapper/keyring-wrapper.d.cts +154 -0
  82. package/dist/api/v2/wrapper/keyring-wrapper.d.cts.map +1 -0
  83. package/dist/api/v2/wrapper/keyring-wrapper.d.mts +154 -0
  84. package/dist/api/v2/wrapper/keyring-wrapper.d.mts.map +1 -0
  85. package/dist/api/v2/wrapper/keyring-wrapper.mjs +130 -0
  86. package/dist/api/v2/wrapper/keyring-wrapper.mjs.map +1 -0
  87. package/dist/btc/types.d.cts +16 -0
  88. package/dist/btc/types.d.cts.map +1 -1
  89. package/dist/btc/types.d.mts +16 -0
  90. package/dist/btc/types.d.mts.map +1 -1
  91. package/dist/eth/index.cjs +2 -0
  92. package/dist/eth/index.cjs.map +1 -1
  93. package/dist/eth/index.d.cts +2 -0
  94. package/dist/eth/index.d.cts.map +1 -1
  95. package/dist/eth/index.d.mts +2 -0
  96. package/dist/eth/index.d.mts.map +1 -1
  97. package/dist/eth/index.mjs +2 -0
  98. package/dist/eth/index.mjs.map +1 -1
  99. package/dist/eth/rpc/index.cjs +18 -0
  100. package/dist/eth/rpc/index.cjs.map +1 -0
  101. package/dist/eth/rpc/index.d.cts +2 -0
  102. package/dist/eth/rpc/index.d.cts.map +1 -0
  103. package/dist/eth/rpc/index.d.mts +2 -0
  104. package/dist/eth/rpc/index.d.mts.map +1 -0
  105. package/dist/eth/rpc/index.mjs +2 -0
  106. package/dist/eth/rpc/index.mjs.map +1 -0
  107. package/dist/eth/rpc/params.cjs +151 -0
  108. package/dist/eth/rpc/params.cjs.map +1 -0
  109. package/dist/eth/rpc/params.d.cts +215 -0
  110. package/dist/eth/rpc/params.d.cts.map +1 -0
  111. package/dist/eth/rpc/params.d.mts +215 -0
  112. package/dist/eth/rpc/params.d.mts.map +1 -0
  113. package/dist/eth/rpc/params.mjs +148 -0
  114. package/dist/eth/rpc/params.mjs.map +1 -0
  115. package/dist/eth/types.cjs +5 -2
  116. package/dist/eth/types.cjs.map +1 -1
  117. package/dist/eth/types.d.cts +9 -0
  118. package/dist/eth/types.d.cts.map +1 -1
  119. package/dist/eth/types.d.mts +9 -0
  120. package/dist/eth/types.d.mts.map +1 -1
  121. package/dist/eth/types.mjs +4 -1
  122. package/dist/eth/types.mjs.map +1 -1
  123. package/dist/eth/v2/eth-keyring-wrapper.cjs +165 -0
  124. package/dist/eth/v2/eth-keyring-wrapper.cjs.map +1 -0
  125. package/dist/eth/v2/eth-keyring-wrapper.d.cts +54 -0
  126. package/dist/eth/v2/eth-keyring-wrapper.d.cts.map +1 -0
  127. package/dist/eth/v2/eth-keyring-wrapper.d.mts +54 -0
  128. package/dist/eth/v2/eth-keyring-wrapper.d.mts.map +1 -0
  129. package/dist/eth/v2/eth-keyring-wrapper.mjs +161 -0
  130. package/dist/eth/v2/eth-keyring-wrapper.mjs.map +1 -0
  131. package/dist/eth/v2/index.cjs +18 -0
  132. package/dist/eth/v2/index.cjs.map +1 -0
  133. package/dist/eth/v2/index.d.cts +2 -0
  134. package/dist/eth/v2/index.d.cts.map +1 -0
  135. package/dist/eth/v2/index.d.mts +2 -0
  136. package/dist/eth/v2/index.d.mts.map +1 -0
  137. package/dist/eth/v2/index.mjs +2 -0
  138. package/dist/eth/v2/index.mjs.map +1 -0
  139. package/dist/events.cjs +0 -2
  140. package/dist/events.cjs.map +1 -1
  141. package/dist/events.d.cts +16 -0
  142. package/dist/events.d.cts.map +1 -1
  143. package/dist/events.d.mts +16 -0
  144. package/dist/events.d.mts.map +1 -1
  145. package/dist/events.mjs +0 -2
  146. package/dist/events.mjs.map +1 -1
  147. package/dist/rpc.cjs +27 -12
  148. package/dist/rpc.cjs.map +1 -1
  149. package/dist/rpc.d.cts +200 -12
  150. package/dist/rpc.d.cts.map +1 -1
  151. package/dist/rpc.d.mts +200 -12
  152. package/dist/rpc.d.mts.map +1 -1
  153. package/dist/rpc.mjs +27 -12
  154. package/dist/rpc.mjs.map +1 -1
  155. package/dist/sol/types.d.cts +4 -0
  156. package/dist/sol/types.d.cts.map +1 -1
  157. package/dist/sol/types.d.mts +4 -0
  158. package/dist/sol/types.d.mts.map +1 -1
  159. package/dist/trx/types.d.cts +4 -0
  160. package/dist/trx/types.d.cts.map +1 -1
  161. package/dist/trx/types.d.mts +4 -0
  162. package/dist/trx/types.d.mts.map +1 -1
  163. package/package.json +9 -4
@@ -12,6 +12,7 @@ import type { Paginated, Pagination } from "./pagination.cjs";
12
12
  import type { KeyringRequest } from "./request.cjs";
13
13
  import type { KeyringResponse } from "./response.cjs";
14
14
  import type { Transaction } from "./transaction.cjs";
15
+ import type { CreateAccountOptions } from "./v2/index.cjs";
15
16
  /**
16
17
  * Keyring interface.
17
18
  *
@@ -49,6 +50,18 @@ export type Keyring = {
49
50
  * object without any private information.
50
51
  */
51
52
  createAccount(options?: Record<string, Json> & MetaMaskOptions): Promise<KeyringAccount>;
53
+ /**
54
+ * Creates one or more new accounts according to the provided options.
55
+ *
56
+ * Deterministic account creation MUST be idempotent, meaning that for
57
+ * deterministic algorithms, like BIP-44, calling this method with the same
58
+ * options should always return the same accounts, even if the accounts
59
+ * already exist in the keyring.
60
+ *
61
+ * @param options - Options describing how to create the account(s).
62
+ * @returns A promise that resolves to an array of the created account objects.
63
+ */
64
+ createAccounts?(options: CreateAccountOptions): Promise<KeyringAccount[]>;
52
65
  /**
53
66
  * Lists the assets of an account (fungibles and non-fungibles) represented
54
67
  * by their respective CAIP-19:
@@ -1 +1 @@
1
- {"version":3,"file":"keyring.d.cts","sourceRoot":"","sources":["../../src/api/keyring.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,gCAAgC;AACzE,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAE5C,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAkB;AAChD,OAAO,KAAK,EAAE,sBAAsB,EAAE,sBAAkB;AACxD,OAAO,KAAK,EAAE,OAAO,EAAE,sBAAkB;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,iBAAiB,EAAE,mBAAe;AAC5E,OAAO,KAAK,EAAE,iBAAiB,EAAE,wBAAoB;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAkB;AACjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,qBAAiB;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAkB;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,yBAAqB;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAkB;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,uBAAmB;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,0BAAsB;AAEjD;;;;;GAKG;AACH,MAAM,MAAM,OAAO,GAAG;IACpB;;;;;;;OAOG;IACH,YAAY,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;IAE1C;;;;;;;;OAQG;IACH,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,CAAC;IAE5D;;;;;;;;;OASG;IACH,aAAa,CACX,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,eAAe,GAC/C,OAAO,CAAC,cAAc,CAAC,CAAC;IAE3B;;;;;;;;OAQG;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Paginated, Pagination } from "./pagination.mjs";
12
12
  import type { KeyringRequest } from "./request.mjs";
13
13
  import type { KeyringResponse } from "./response.mjs";
14
14
  import type { Transaction } from "./transaction.mjs";
15
+ import type { CreateAccountOptions } from "./v2/index.mjs";
15
16
  /**
16
17
  * Keyring interface.
17
18
  *
@@ -49,6 +50,18 @@ export type Keyring = {
49
50
  * object without any private information.
50
51
  */
51
52
  createAccount(options?: Record<string, Json> & MetaMaskOptions): Promise<KeyringAccount>;
53
+ /**
54
+ * Creates one or more new accounts according to the provided options.
55
+ *
56
+ * Deterministic account creation MUST be idempotent, meaning that for
57
+ * deterministic algorithms, like BIP-44, calling this method with the same
58
+ * options should always return the same accounts, even if the accounts
59
+ * already exist in the keyring.
60
+ *
61
+ * @param options - Options describing how to create the account(s).
62
+ * @returns A promise that resolves to an array of the created account objects.
63
+ */
64
+ createAccounts?(options: CreateAccountOptions): Promise<KeyringAccount[]>;
52
65
  /**
53
66
  * Lists the assets of an account (fungibles and non-fungibles) represented
54
67
  * by their respective CAIP-19:
@@ -1 +1 @@
1
- {"version":3,"file":"keyring.d.mts","sourceRoot":"","sources":["../../src/api/keyring.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,gCAAgC;AACzE,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAE5C,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAkB;AAChD,OAAO,KAAK,EAAE,sBAAsB,EAAE,sBAAkB;AACxD,OAAO,KAAK,EAAE,OAAO,EAAE,sBAAkB;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,iBAAiB,EAAE,mBAAe;AAC5E,OAAO,KAAK,EAAE,iBAAiB,EAAE,wBAAoB;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAkB;AACjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,qBAAiB;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAkB;AACjD,OAA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;;;;;OAOG;IACH,YAAY,CAAC,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;IAE3C;;;;;;;;OAQG;IACH,UAAU,CAAC,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,CAAC;IAE7D;;;;;;;OAOG;IACH,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAEjE;;;;;;;;;OASG;IACH,cAAc,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAExE;;;;;;;;OAQG;IACH,aAAa,CAAC,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3C,CAAC"}
@@ -1,4 +1,2 @@
1
- /* eslint-disable @typescript-eslint/no-redundant-type-constituents */
2
- // This rule seems to be triggering a false positive on the `KeyringAccount`.
3
1
  export {};
4
2
  //# sourceMappingURL=keyring.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"keyring.mjs","sourceRoot":"","sources":["../../src/api/keyring.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,6EAA6E","sourcesContent":["/* eslint-disable @typescript-eslint/no-redundant-type-constituents */\n// This rule seems to be triggering a false positive on the `KeyringAccount`.\n\nimport type { AccountId, JsonRpcRequest } from '@metamask/keyring-utils';\nimport type { Json } from '@metamask/utils';\n\nimport type { KeyringAccount } from './account';\nimport type { ResolvedAccountAddress } from './address';\nimport type { Balance } from './balance';\nimport type { CaipChainId, CaipAssetType, CaipAssetTypeOrId } from './caip';\nimport type { DiscoveredAccount } from './discovery';\nimport type { EntropySourceId } from './entropy';\nimport type { KeyringAccountData } from './export';\nimport type { MetaMaskOptions } from './options';\nimport type { Paginated, Pagination } from './pagination';\nimport type { KeyringRequest } from './request';\nimport type { KeyringResponse } from './response';\nimport type { Transaction } from './transaction';\n\n/**\n * Keyring interface.\n *\n * Represents the functionality and operations related to managing accounts and\n * handling requests.\n */\nexport type Keyring = {\n /**\n * List accounts.\n *\n * Retrieves an array of KeyringAccount objects representing the available\n * accounts.\n *\n * @returns A promise that resolves to an array of KeyringAccount objects.\n */\n listAccounts(): Promise<KeyringAccount[]>;\n\n /**\n * Get an account.\n *\n * Retrieves the KeyringAccount object for the given account ID.\n *\n * @param id - The ID of the account to retrieve.\n * @returns A promise that resolves to the KeyringAccount object if found, or\n * undefined otherwise.\n */\n getAccount(id: string): Promise<KeyringAccount | undefined>;\n\n /**\n * Create an account.\n *\n * Creates a new account with optional, keyring-defined, account options.\n *\n * @param options - Keyring-defined options for the account (optional). The\n * 'metamask' internal options needs to be re-emitted during `notify:*` events.\n * @returns A promise that resolves to the newly created KeyringAccount\n * object without any private information.\n */\n createAccount(\n options?: Record<string, Json> & MetaMaskOptions,\n ): Promise<KeyringAccount>;\n\n /**\n * Lists the assets of an account (fungibles and non-fungibles) represented\n * by their respective CAIP-19:\n * - Asset types for fungibles assets.\n * - Asset IDs for non-fungible ones.\n *\n * @param id - The ID of the account to list the assets for.\n * @returns A promise that resolves to list of assets for that account.\n */\n listAccountAssets?(id: string): Promise<CaipAssetTypeOrId[]>;\n\n /**\n * Lists the transactions of an account, paginated and ordered by the most\n * recent first.\n *\n * The pagination options are used to limit the number of transactions in the\n * response and to iterate over the results.\n *\n * @param id - The ID of the account to list the transactions for.\n * @param pagination - The pagination options.\n * @returns A promise that resolves to the next page of transactions.\n */\n listAccountTransactions?(\n id: string,\n pagination: Pagination,\n ): Promise<Paginated<Transaction>>;\n\n /**\n * Discover accounts.\n *\n * This method is called by the client to allow the keyring to discover\n * existing accounts based on the provided scopes and entropy source ID. Are\n * considered existing accounts, accounts that have at least one transaction,\n * as per BIP-44.\n *\n * The `groupIndex` is used to group accounts with the same value. In\n * strictly BIP-44 wallets, it matches `account_index`, but in wallets that\n * deviate from BIP-44 recommendations, it may align with a different path\n * level for compatibility.\n *\n * @param scopes - The list of scopes for account discovery.\n * @param entropySource - The ID of the entropy source used to derive the accounts.\n * @param groupIndex - The group index that should be used to derive the accounts.\n * @returns A promise resolving to a list of discovered accounts.\n */\n discoverAccounts?(\n scopes: CaipChainId[],\n entropySource: EntropySourceId,\n groupIndex: number,\n ): Promise<DiscoveredAccount[]>;\n\n /**\n * Retrieve the balances of a given account.\n *\n * This method fetches the balances of specified assets for a given account\n * ID. It returns a promise that resolves to an object where the keys are\n * asset types and the values are balance objects containing the amount and\n * unit.\n *\n * @example\n * ```ts\n * await keyring.getAccountBalances(\n * '43550276-c7d6-4fac-87c7-00390ad0ce90',\n * ['bip122:000000000019d6689c085ae165831e93/slip44:0']\n * );\n * // Returns something similar to:\n * // {\n * // 'bip122:000000000019d6689c085ae165831e93/slip44:0': {\n * // amount: '0.0001',\n * // unit: 'BTC',\n * // }\n * // }\n * ```\n * @param id - ID of the account to retrieve the balances for.\n * @param assets - Array of asset types (CAIP-19) to retrieve balances for.\n * @returns A promise that resolves to an object mapping asset types to their\n * respective balances.\n */\n getAccountBalances?(\n id: string,\n assets: CaipAssetType[],\n ): Promise<Record<CaipAssetType, Balance>>;\n\n /**\n * Resolves the address of an account from a signing request.\n *\n * This is required by the routing system of MetaMask to dispatch\n * incoming non-EVM dapp signing requests.\n *\n * @param scope - Request's scope (CAIP-2).\n * @param request - Signing request object.\n * @returns A Promise that resolves to the account address that must\n * be used to process this signing request, or null if none candidates\n * could be found.\n */\n resolveAccountAddress?(\n scope: CaipChainId,\n request: JsonRpcRequest,\n ): Promise<ResolvedAccountAddress | null>;\n\n /**\n * Set the selected accounts.\n *\n * @param accounts - The accounts to set as selected.\n */\n setSelectedAccounts?(accounts: AccountId[]): Promise<void>;\n\n /**\n * Filter supported chains for a given account.\n *\n * @param id - ID of the account to be checked.\n * @param chains - List of chains (CAIP-2) to be checked.\n * @returns A Promise that resolves to a filtered list of CAIP-2 IDs\n * representing the supported chains.\n */\n filterAccountChains(id: string, chains: string[]): Promise<string[]>;\n\n /**\n * Update an account.\n *\n * Updates the account with the given account object. Does nothing if the\n * account does not exist.\n *\n * @param account - The updated account object.\n * @returns A promise that resolves when the account is successfully updated.\n */\n updateAccount(account: KeyringAccount): Promise<void>;\n\n /**\n * Delete an account from the keyring.\n *\n * Deletes the account with the given ID from the keyring.\n *\n * @param id - The ID of the account to delete.\n * @returns A promise that resolves when the account is successfully deleted.\n */\n deleteAccount(id: string): Promise<void>;\n\n /**\n * Exports an account's private key.\n *\n * If the keyring cannot export a private key, this function should throw an\n * error.\n *\n * @param id - The ID of the account to export.\n * @returns A promise that resolves to the exported account.\n */\n exportAccount?(id: string): Promise<KeyringAccountData>;\n\n /**\n * List all submitted requests.\n *\n * Retrieves an array of KeyringRequest objects representing the submitted\n * requests.\n *\n * @returns A promise that resolves to an array of KeyringRequest objects.\n */\n listRequests?(): Promise<KeyringRequest[]>;\n\n /**\n * Get a request.\n *\n * Retrieves the KeyringRequest object for the given request ID.\n *\n * @param id - The ID of the request to retrieve.\n * @returns A promise that resolves to the KeyringRequest object if found, or\n * undefined otherwise.\n */\n getRequest?(id: string): Promise<KeyringRequest | undefined>;\n\n /**\n * Submit a request.\n *\n * Submits the given KeyringRequest object.\n *\n * @param request - The KeyringRequest object to submit.\n * @returns A promise that resolves to the request response.\n */\n submitRequest(request: KeyringRequest): Promise<KeyringResponse>;\n\n /**\n * Approve a request.\n *\n * Approves the request with the given ID and sets the response if provided.\n *\n * @param id - The ID of the request to approve.\n * @param data - The response to the request (optional).\n * @returns A promise that resolves when the request is successfully\n * approved.\n */\n approveRequest?(id: string, data?: Record<string, Json>): Promise<void>;\n\n /**\n * Reject a request.\n *\n * Rejects the request with the given ID.\n *\n * @param id - The ID of the request to reject.\n * @returns A promise that resolves when the request is successfully\n * rejected.\n */\n rejectRequest?(id: string): Promise<void>;\n};\n"]}
1
+ {"version":3,"file":"keyring.mjs","sourceRoot":"","sources":["../../src/api/keyring.ts"],"names":[],"mappings":"","sourcesContent":["import type { AccountId, JsonRpcRequest } from '@metamask/keyring-utils';\nimport type { Json } from '@metamask/utils';\n\nimport type { KeyringAccount } from './account';\nimport type { ResolvedAccountAddress } from './address';\nimport type { Balance } from './balance';\nimport type { CaipChainId, CaipAssetType, CaipAssetTypeOrId } from './caip';\nimport type { DiscoveredAccount } from './discovery';\nimport type { EntropySourceId } from './entropy';\nimport type { KeyringAccountData } from './export';\nimport type { MetaMaskOptions } from './options';\nimport type { Paginated, Pagination } from './pagination';\nimport type { KeyringRequest } from './request';\nimport type { KeyringResponse } from './response';\nimport type { Transaction } from './transaction';\nimport type { CreateAccountOptions } from './v2';\n\n/**\n * Keyring interface.\n *\n * Represents the functionality and operations related to managing accounts and\n * handling requests.\n */\nexport type Keyring = {\n /**\n * List accounts.\n *\n * Retrieves an array of KeyringAccount objects representing the available\n * accounts.\n *\n * @returns A promise that resolves to an array of KeyringAccount objects.\n */\n listAccounts(): Promise<KeyringAccount[]>;\n\n /**\n * Get an account.\n *\n * Retrieves the KeyringAccount object for the given account ID.\n *\n * @param id - The ID of the account to retrieve.\n * @returns A promise that resolves to the KeyringAccount object if found, or\n * undefined otherwise.\n */\n getAccount(id: string): Promise<KeyringAccount | undefined>;\n\n /**\n * Create an account.\n *\n * Creates a new account with optional, keyring-defined, account options.\n *\n * @param options - Keyring-defined options for the account (optional). The\n * 'metamask' internal options needs to be re-emitted during `notify:*` events.\n * @returns A promise that resolves to the newly created KeyringAccount\n * object without any private information.\n */\n createAccount(\n options?: Record<string, Json> & MetaMaskOptions,\n ): Promise<KeyringAccount>;\n\n /**\n * Creates one or more new accounts according to the provided options.\n *\n * Deterministic account creation MUST be idempotent, meaning that for\n * deterministic algorithms, like BIP-44, calling this method with the same\n * options should always return the same accounts, even if the accounts\n * already exist in the keyring.\n *\n * @param options - Options describing how to create the account(s).\n * @returns A promise that resolves to an array of the created account objects.\n */\n createAccounts?(options: CreateAccountOptions): Promise<KeyringAccount[]>;\n\n /**\n * Lists the assets of an account (fungibles and non-fungibles) represented\n * by their respective CAIP-19:\n * - Asset types for fungibles assets.\n * - Asset IDs for non-fungible ones.\n *\n * @param id - The ID of the account to list the assets for.\n * @returns A promise that resolves to list of assets for that account.\n */\n listAccountAssets?(id: string): Promise<CaipAssetTypeOrId[]>;\n\n /**\n * Lists the transactions of an account, paginated and ordered by the most\n * recent first.\n *\n * The pagination options are used to limit the number of transactions in the\n * response and to iterate over the results.\n *\n * @param id - The ID of the account to list the transactions for.\n * @param pagination - The pagination options.\n * @returns A promise that resolves to the next page of transactions.\n */\n listAccountTransactions?(\n id: string,\n pagination: Pagination,\n ): Promise<Paginated<Transaction>>;\n\n /**\n * Discover accounts.\n *\n * This method is called by the client to allow the keyring to discover\n * existing accounts based on the provided scopes and entropy source ID. Are\n * considered existing accounts, accounts that have at least one transaction,\n * as per BIP-44.\n *\n * The `groupIndex` is used to group accounts with the same value. In\n * strictly BIP-44 wallets, it matches `account_index`, but in wallets that\n * deviate from BIP-44 recommendations, it may align with a different path\n * level for compatibility.\n *\n * @param scopes - The list of scopes for account discovery.\n * @param entropySource - The ID of the entropy source used to derive the accounts.\n * @param groupIndex - The group index that should be used to derive the accounts.\n * @returns A promise resolving to a list of discovered accounts.\n */\n discoverAccounts?(\n scopes: CaipChainId[],\n entropySource: EntropySourceId,\n groupIndex: number,\n ): Promise<DiscoveredAccount[]>;\n\n /**\n * Retrieve the balances of a given account.\n *\n * This method fetches the balances of specified assets for a given account\n * ID. It returns a promise that resolves to an object where the keys are\n * asset types and the values are balance objects containing the amount and\n * unit.\n *\n * @example\n * ```ts\n * await keyring.getAccountBalances(\n * '43550276-c7d6-4fac-87c7-00390ad0ce90',\n * ['bip122:000000000019d6689c085ae165831e93/slip44:0']\n * );\n * // Returns something similar to:\n * // {\n * // 'bip122:000000000019d6689c085ae165831e93/slip44:0': {\n * // amount: '0.0001',\n * // unit: 'BTC',\n * // }\n * // }\n * ```\n * @param id - ID of the account to retrieve the balances for.\n * @param assets - Array of asset types (CAIP-19) to retrieve balances for.\n * @returns A promise that resolves to an object mapping asset types to their\n * respective balances.\n */\n getAccountBalances?(\n id: string,\n assets: CaipAssetType[],\n ): Promise<Record<CaipAssetType, Balance>>;\n\n /**\n * Resolves the address of an account from a signing request.\n *\n * This is required by the routing system of MetaMask to dispatch\n * incoming non-EVM dapp signing requests.\n *\n * @param scope - Request's scope (CAIP-2).\n * @param request - Signing request object.\n * @returns A Promise that resolves to the account address that must\n * be used to process this signing request, or null if none candidates\n * could be found.\n */\n resolveAccountAddress?(\n scope: CaipChainId,\n request: JsonRpcRequest,\n ): Promise<ResolvedAccountAddress | null>;\n\n /**\n * Set the selected accounts.\n *\n * @param accounts - The accounts to set as selected.\n */\n setSelectedAccounts?(accounts: AccountId[]): Promise<void>;\n\n /**\n * Filter supported chains for a given account.\n *\n * @param id - ID of the account to be checked.\n * @param chains - List of chains (CAIP-2) to be checked.\n * @returns A Promise that resolves to a filtered list of CAIP-2 IDs\n * representing the supported chains.\n */\n filterAccountChains(id: string, chains: string[]): Promise<string[]>;\n\n /**\n * Update an account.\n *\n * Updates the account with the given account object. Does nothing if the\n * account does not exist.\n *\n * @param account - The updated account object.\n * @returns A promise that resolves when the account is successfully updated.\n */\n updateAccount(account: KeyringAccount): Promise<void>;\n\n /**\n * Delete an account from the keyring.\n *\n * Deletes the account with the given ID from the keyring.\n *\n * @param id - The ID of the account to delete.\n * @returns A promise that resolves when the account is successfully deleted.\n */\n deleteAccount(id: string): Promise<void>;\n\n /**\n * Exports an account's private key.\n *\n * If the keyring cannot export a private key, this function should throw an\n * error.\n *\n * @param id - The ID of the account to export.\n * @returns A promise that resolves to the exported account.\n */\n exportAccount?(id: string): Promise<KeyringAccountData>;\n\n /**\n * List all submitted requests.\n *\n * Retrieves an array of KeyringRequest objects representing the submitted\n * requests.\n *\n * @returns A promise that resolves to an array of KeyringRequest objects.\n */\n listRequests?(): Promise<KeyringRequest[]>;\n\n /**\n * Get a request.\n *\n * Retrieves the KeyringRequest object for the given request ID.\n *\n * @param id - The ID of the request to retrieve.\n * @returns A promise that resolves to the KeyringRequest object if found, or\n * undefined otherwise.\n */\n getRequest?(id: string): Promise<KeyringRequest | undefined>;\n\n /**\n * Submit a request.\n *\n * Submits the given KeyringRequest object.\n *\n * @param request - The KeyringRequest object to submit.\n * @returns A promise that resolves to the request response.\n */\n submitRequest(request: KeyringRequest): Promise<KeyringResponse>;\n\n /**\n * Approve a request.\n *\n * Approves the request with the given ID and sets the response if provided.\n *\n * @param id - The ID of the request to approve.\n * @param data - The response to the request (optional).\n * @returns A promise that resolves when the request is successfully\n * approved.\n */\n approveRequest?(id: string, data?: Record<string, Json>): Promise<void>;\n\n /**\n * Reject a request.\n *\n * Rejects the request with the given ID.\n *\n * @param id - The ID of the request to reject.\n * @returns A promise that resolves when the request is successfully\n * rejected.\n */\n rejectRequest?(id: string): Promise<void>;\n};\n"]}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CreateAccountBip44DiscoverOptionsStruct = exports.CreateAccountBip44DeriveIndexOptionsStruct = exports.CreateAccountBip44DerivePathOptionsStruct = void 0;
3
+ exports.CreateAccountBip44DeriveIndexRangeOptionsStruct = exports.CreateAccountBip44DiscoverOptionsStruct = exports.CreateAccountBip44DeriveIndexOptionsStruct = exports.CreateAccountBip44DerivePathOptionsStruct = void 0;
4
4
  const superstruct_1 = require("@metamask/superstruct");
5
5
  const derivation_1 = require("../../derivation.cjs");
6
6
  /**
@@ -54,4 +54,30 @@ exports.CreateAccountBip44DiscoverOptionsStruct = (0, superstruct_1.object)({
54
54
  */
55
55
  groupIndex: (0, superstruct_1.number)(),
56
56
  });
57
+ /**
58
+ * Struct for {@link CreateAccountBip44DeriveIndexRangeOptions}.
59
+ */
60
+ exports.CreateAccountBip44DeriveIndexRangeOptionsStruct = (0, superstruct_1.object)({
61
+ /**
62
+ * The type of the options.
63
+ */
64
+ type: (0, superstruct_1.literal)('bip44:derive-index-range'),
65
+ /**
66
+ * ID of the entropy source to be used to derive the accounts.
67
+ */
68
+ entropySource: (0, superstruct_1.string)(),
69
+ /**
70
+ * The range of account group indices to derive (inclusive on both ends).
71
+ */
72
+ range: (0, superstruct_1.object)({
73
+ /**
74
+ * The starting index of the account group range (inclusive).
75
+ */
76
+ from: (0, superstruct_1.number)(),
77
+ /**
78
+ * The ending index of the account group range (inclusive).
79
+ */
80
+ to: (0, superstruct_1.number)(),
81
+ }),
82
+ });
57
83
  //# sourceMappingURL=bip44.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"bip44.cjs","sourceRoot":"","sources":["../../../../src/api/v2/create-account/bip44.ts"],"names":[],"mappings":";;;AAAA,uDAM+B;AAE/B,qDAAwD;AAExD;;GAEG;AACU,QAAA,yCAAyC,GAAG,IAAA,oBAAM,EAAC;IAC9D;;OAEG;IACH,IAAI,EAAE,IAAA,qBAAO,EAAC,mBAAmB,CAAC;IAClC;;OAEG;IACH,aAAa,EAAE,IAAA,oBAAM,GAAE;IACvB;;OAEG;IACH,cAAc,EAAE,iCAAoB;CACrC,CAAC,CAAC;AASH;;GAEG;AACU,QAAA,0CAA0C,GAAG,IAAA,oBAAM,EAAC;IAC/D;;OAEG;IACH,IAAI,EAAE,IAAA,qBAAO,EAAC,oBAAoB,CAAC;IACnC;;OAEG;IACH,aAAa,EAAE,IAAA,oBAAM,GAAE;IACvB;;OAEG;IACH,UAAU,EAAE,IAAA,oBAAM,GAAE;CACrB,CAAC,CAAC;AAYH;;GAEG;AACU,QAAA,uCAAuC,GAAG,IAAA,oBAAM,EAAC;IAC5D;;OAEG;IACH,IAAI,EAAE,IAAA,qBAAO,EAAC,gBAAgB,CAAC;IAC/B;;OAEG;IACH,aAAa,EAAE,IAAA,oBAAM,GAAE;IACvB;;OAEG;IACH,UAAU,EAAE,IAAA,oBAAM,GAAE;CACrB,CAAC,CAAC","sourcesContent":["import {\n literal,\n number,\n object,\n string,\n type Infer,\n} from '@metamask/superstruct';\n\nimport { DerivationPathStruct } from '../../derivation';\n\n/**\n * Struct for {@link CreateAccountBip44DerivePathOptions}.\n */\nexport const CreateAccountBip44DerivePathOptionsStruct = object({\n /**\n * Type of the options.\n */\n type: literal('bip44:derive-path'),\n /**\n * ID of the entropy source to be used to derive the account.\n */\n entropySource: string(),\n /**\n * BIP-44 derivation path to be used to derive the account.\n */\n derivationPath: DerivationPathStruct,\n});\n\n/**\n * Options for creating an account using the given BIP-44 derivation path.\n */\nexport type CreateAccountBip44DerivePathOptions = Infer<\n typeof CreateAccountBip44DerivePathOptionsStruct\n>;\n\n/**\n * Struct for {@link CreateAccountBip44DeriveIndexOptions}.\n */\nexport const CreateAccountBip44DeriveIndexOptionsStruct = object({\n /**\n * The type of the options.\n */\n type: literal('bip44:derive-index'),\n /**\n * ID of the entropy source to be used to derive the account.\n */\n entropySource: string(),\n /**\n * The index of the account group to be derived.\n */\n groupIndex: number(),\n});\n\n/**\n * Options for creating an account using the given BIP-44 account group index.\n *\n * Note that the keyring can support non-standard BIP-44 paths for\n * compatibility with other wallets.\n */\nexport type CreateAccountBip44DeriveIndexOptions = Infer<\n typeof CreateAccountBip44DeriveIndexOptionsStruct\n>;\n\n/**\n * Struct for {@link CreateAccountBip44DiscoverOptions}.\n */\nexport const CreateAccountBip44DiscoverOptionsStruct = object({\n /**\n * The type of the options.\n */\n type: literal('bip44:discover'),\n /**\n * ID of the entropy source to be used to derive the account.\n */\n entropySource: string(),\n /**\n * The index of the account group to be derived.\n */\n groupIndex: number(),\n});\n\n/**\n * Options for creating accounts by performing a BIP-44 account discovery.\n *\n * Note that the keyring can support non-standard BIP-44 paths for\n * compatibility with other wallets.\n */\nexport type CreateAccountBip44DiscoverOptions = Infer<\n typeof CreateAccountBip44DiscoverOptionsStruct\n>;\n"]}
1
+ {"version":3,"file":"bip44.cjs","sourceRoot":"","sources":["../../../../src/api/v2/create-account/bip44.ts"],"names":[],"mappings":";;;AAAA,uDAM+B;AAE/B,qDAAwD;AAExD;;GAEG;AACU,QAAA,yCAAyC,GAAG,IAAA,oBAAM,EAAC;IAC9D;;OAEG;IACH,IAAI,EAAE,IAAA,qBAAO,EAAC,mBAAmB,CAAC;IAClC;;OAEG;IACH,aAAa,EAAE,IAAA,oBAAM,GAAE;IACvB;;OAEG;IACH,cAAc,EAAE,iCAAoB;CACrC,CAAC,CAAC;AASH;;GAEG;AACU,QAAA,0CAA0C,GAAG,IAAA,oBAAM,EAAC;IAC/D;;OAEG;IACH,IAAI,EAAE,IAAA,qBAAO,EAAC,oBAAoB,CAAC;IACnC;;OAEG;IACH,aAAa,EAAE,IAAA,oBAAM,GAAE;IACvB;;OAEG;IACH,UAAU,EAAE,IAAA,oBAAM,GAAE;CACrB,CAAC,CAAC;AAYH;;GAEG;AACU,QAAA,uCAAuC,GAAG,IAAA,oBAAM,EAAC;IAC5D;;OAEG;IACH,IAAI,EAAE,IAAA,qBAAO,EAAC,gBAAgB,CAAC;IAC/B;;OAEG;IACH,aAAa,EAAE,IAAA,oBAAM,GAAE;IACvB;;OAEG;IACH,UAAU,EAAE,IAAA,oBAAM,GAAE;CACrB,CAAC,CAAC;AAYH;;GAEG;AACU,QAAA,+CAA+C,GAAG,IAAA,oBAAM,EAAC;IACpE;;OAEG;IACH,IAAI,EAAE,IAAA,qBAAO,EAAC,0BAA0B,CAAC;IACzC;;OAEG;IACH,aAAa,EAAE,IAAA,oBAAM,GAAE;IACvB;;OAEG;IACH,KAAK,EAAE,IAAA,oBAAM,EAAC;QACZ;;WAEG;QACH,IAAI,EAAE,IAAA,oBAAM,GAAE;QACd;;WAEG;QACH,EAAE,EAAE,IAAA,oBAAM,GAAE;KACb,CAAC;CACH,CAAC,CAAC","sourcesContent":["import {\n literal,\n number,\n object,\n string,\n type Infer,\n} from '@metamask/superstruct';\n\nimport { DerivationPathStruct } from '../../derivation';\n\n/**\n * Struct for {@link CreateAccountBip44DerivePathOptions}.\n */\nexport const CreateAccountBip44DerivePathOptionsStruct = object({\n /**\n * Type of the options.\n */\n type: literal('bip44:derive-path'),\n /**\n * ID of the entropy source to be used to derive the account.\n */\n entropySource: string(),\n /**\n * BIP-44 derivation path to be used to derive the account.\n */\n derivationPath: DerivationPathStruct,\n});\n\n/**\n * Options for creating an account using the given BIP-44 derivation path.\n */\nexport type CreateAccountBip44DerivePathOptions = Infer<\n typeof CreateAccountBip44DerivePathOptionsStruct\n>;\n\n/**\n * Struct for {@link CreateAccountBip44DeriveIndexOptions}.\n */\nexport const CreateAccountBip44DeriveIndexOptionsStruct = object({\n /**\n * The type of the options.\n */\n type: literal('bip44:derive-index'),\n /**\n * ID of the entropy source to be used to derive the account.\n */\n entropySource: string(),\n /**\n * The index of the account group to be derived.\n */\n groupIndex: number(),\n});\n\n/**\n * Options for creating an account using the given BIP-44 account group index.\n *\n * Note that the keyring can support non-standard BIP-44 paths for\n * compatibility with other wallets.\n */\nexport type CreateAccountBip44DeriveIndexOptions = Infer<\n typeof CreateAccountBip44DeriveIndexOptionsStruct\n>;\n\n/**\n * Struct for {@link CreateAccountBip44DiscoverOptions}.\n */\nexport const CreateAccountBip44DiscoverOptionsStruct = object({\n /**\n * The type of the options.\n */\n type: literal('bip44:discover'),\n /**\n * ID of the entropy source to be used to derive the account.\n */\n entropySource: string(),\n /**\n * The index of the account group to be derived.\n */\n groupIndex: number(),\n});\n\n/**\n * Options for creating accounts by performing a BIP-44 account discovery.\n *\n * Note that the keyring can support non-standard BIP-44 paths for\n * compatibility with other wallets.\n */\nexport type CreateAccountBip44DiscoverOptions = Infer<\n typeof CreateAccountBip44DiscoverOptionsStruct\n>;\n\n/**\n * Struct for {@link CreateAccountBip44DeriveIndexRangeOptions}.\n */\nexport const CreateAccountBip44DeriveIndexRangeOptionsStruct = object({\n /**\n * The type of the options.\n */\n type: literal('bip44:derive-index-range'),\n /**\n * ID of the entropy source to be used to derive the accounts.\n */\n entropySource: string(),\n /**\n * The range of account group indices to derive (inclusive on both ends).\n */\n range: object({\n /**\n * The starting index of the account group range (inclusive).\n */\n from: number(),\n /**\n * The ending index of the account group range (inclusive).\n */\n to: number(),\n }),\n});\n\n/**\n * Options for creating accounts by deriving a range of BIP-44 account indices.\n *\n * The range is inclusive on both ends, meaning range.from=0 and range.to=5\n * will create accounts for group indices 0, 1, 2, 3, 4, and 5.\n *\n * Note that the keyring can support non-standard BIP-44 paths for\n * compatibility with other wallets.\n */\nexport type CreateAccountBip44DeriveIndexRangeOptions = Infer<\n typeof CreateAccountBip44DeriveIndexRangeOptionsStruct\n>;\n"]}
@@ -80,4 +80,50 @@ export declare const CreateAccountBip44DiscoverOptionsStruct: import("@metamask/
80
80
  * compatibility with other wallets.
81
81
  */
82
82
  export type CreateAccountBip44DiscoverOptions = Infer<typeof CreateAccountBip44DiscoverOptionsStruct>;
83
+ /**
84
+ * Struct for {@link CreateAccountBip44DeriveIndexRangeOptions}.
85
+ */
86
+ export declare const CreateAccountBip44DeriveIndexRangeOptionsStruct: import("@metamask/superstruct").Struct<{
87
+ type: "bip44:derive-index-range";
88
+ range: {
89
+ from: number;
90
+ to: number;
91
+ };
92
+ entropySource: string;
93
+ }, {
94
+ /**
95
+ * The type of the options.
96
+ */
97
+ type: import("@metamask/superstruct").Struct<"bip44:derive-index-range", "bip44:derive-index-range">;
98
+ /**
99
+ * ID of the entropy source to be used to derive the accounts.
100
+ */
101
+ entropySource: import("@metamask/superstruct").Struct<string, null>;
102
+ /**
103
+ * The range of account group indices to derive (inclusive on both ends).
104
+ */
105
+ range: import("@metamask/superstruct").Struct<{
106
+ from: number;
107
+ to: number;
108
+ }, {
109
+ /**
110
+ * The starting index of the account group range (inclusive).
111
+ */
112
+ from: import("@metamask/superstruct").Struct<number, null>;
113
+ /**
114
+ * The ending index of the account group range (inclusive).
115
+ */
116
+ to: import("@metamask/superstruct").Struct<number, null>;
117
+ }>;
118
+ }>;
119
+ /**
120
+ * Options for creating accounts by deriving a range of BIP-44 account indices.
121
+ *
122
+ * The range is inclusive on both ends, meaning range.from=0 and range.to=5
123
+ * will create accounts for group indices 0, 1, 2, 3, 4, and 5.
124
+ *
125
+ * Note that the keyring can support non-standard BIP-44 paths for
126
+ * compatibility with other wallets.
127
+ */
128
+ export type CreateAccountBip44DeriveIndexRangeOptions = Infer<typeof CreateAccountBip44DeriveIndexRangeOptionsStruct>;
83
129
  //# sourceMappingURL=bip44.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bip44.d.cts","sourceRoot":"","sources":["../../../../src/api/v2/create-account/bip44.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,KAAK,EACX,8BAA8B;AAI/B;;GAEG;AACH,eAAO,MAAM,yCAAyC;;;;;IACpD;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;EAEH,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,mCAAmC,GAAG,KAAK,CACrD,OAAO,yCAAyC,CACjD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,0CAA0C;;;;;IACrD;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;EAEH,CAAC;AAEH;;;;;GAKG;AACH,MAAM,MAAM,oCAAoC,GAAG,KAAK,CACtD,OAAO,0CAA0C,CAClD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uCAAuC;;;;;IAClD;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;EAEH,CAAC;AAEH;;;;;GAKG;AACH,MAAM,MAAM,iCAAiC,GAAG,KAAK,CACnD,OAAO,uCAAuC,CAC/C,CAAC"}
1
+ {"version":3,"file":"bip44.d.cts","sourceRoot":"","sources":["../../../../src/api/v2/create-account/bip44.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,KAAK,EACX,8BAA8B;AAI/B;;GAEG;AACH,eAAO,MAAM,yCAAyC;;;;;IACpD;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;EAEH,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,mCAAmC,GAAG,KAAK,CACrD,OAAO,yCAAyC,CACjD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,0CAA0C;;;;;IACrD;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;EAEH,CAAC;AAEH;;;;;GAKG;AACH,MAAM,MAAM,oCAAoC,GAAG,KAAK,CACtD,OAAO,0CAA0C,CAClD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uCAAuC;;;;;IAClD;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;EAEH,CAAC;AAEH;;;;;GAKG;AACH,MAAM,MAAM,iCAAiC,GAAG,KAAK,CACnD,OAAO,uCAAuC,CAC/C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,+CAA+C;;;;;;;;IAC1D;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;;;;QAED;;WAEG;;QAEH;;WAEG;;;EAGL,CAAC;AAEH;;;;;;;;GAQG;AACH,MAAM,MAAM,yCAAyC,GAAG,KAAK,CAC3D,OAAO,+CAA+C,CACvD,CAAC"}
@@ -80,4 +80,50 @@ export declare const CreateAccountBip44DiscoverOptionsStruct: import("@metamask/
80
80
  * compatibility with other wallets.
81
81
  */
82
82
  export type CreateAccountBip44DiscoverOptions = Infer<typeof CreateAccountBip44DiscoverOptionsStruct>;
83
+ /**
84
+ * Struct for {@link CreateAccountBip44DeriveIndexRangeOptions}.
85
+ */
86
+ export declare const CreateAccountBip44DeriveIndexRangeOptionsStruct: import("@metamask/superstruct").Struct<{
87
+ type: "bip44:derive-index-range";
88
+ range: {
89
+ from: number;
90
+ to: number;
91
+ };
92
+ entropySource: string;
93
+ }, {
94
+ /**
95
+ * The type of the options.
96
+ */
97
+ type: import("@metamask/superstruct").Struct<"bip44:derive-index-range", "bip44:derive-index-range">;
98
+ /**
99
+ * ID of the entropy source to be used to derive the accounts.
100
+ */
101
+ entropySource: import("@metamask/superstruct").Struct<string, null>;
102
+ /**
103
+ * The range of account group indices to derive (inclusive on both ends).
104
+ */
105
+ range: import("@metamask/superstruct").Struct<{
106
+ from: number;
107
+ to: number;
108
+ }, {
109
+ /**
110
+ * The starting index of the account group range (inclusive).
111
+ */
112
+ from: import("@metamask/superstruct").Struct<number, null>;
113
+ /**
114
+ * The ending index of the account group range (inclusive).
115
+ */
116
+ to: import("@metamask/superstruct").Struct<number, null>;
117
+ }>;
118
+ }>;
119
+ /**
120
+ * Options for creating accounts by deriving a range of BIP-44 account indices.
121
+ *
122
+ * The range is inclusive on both ends, meaning range.from=0 and range.to=5
123
+ * will create accounts for group indices 0, 1, 2, 3, 4, and 5.
124
+ *
125
+ * Note that the keyring can support non-standard BIP-44 paths for
126
+ * compatibility with other wallets.
127
+ */
128
+ export type CreateAccountBip44DeriveIndexRangeOptions = Infer<typeof CreateAccountBip44DeriveIndexRangeOptionsStruct>;
83
129
  //# sourceMappingURL=bip44.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bip44.d.mts","sourceRoot":"","sources":["../../../../src/api/v2/create-account/bip44.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,KAAK,EACX,8BAA8B;AAI/B;;GAEG;AACH,eAAO,MAAM,yCAAyC;;;;;IACpD;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;EAEH,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,mCAAmC,GAAG,KAAK,CACrD,OAAO,yCAAyC,CACjD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,0CAA0C;;;;;IACrD;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;EAEH,CAAC;AAEH;;;;;GAKG;AACH,MAAM,MAAM,oCAAoC,GAAG,KAAK,CACtD,OAAO,0CAA0C,CAClD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uCAAuC;;;;;IAClD;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;EAEH,CAAC;AAEH;;;;;GAKG;AACH,MAAM,MAAM,iCAAiC,GAAG,KAAK,CACnD,OAAO,uCAAuC,CAC/C,CAAC"}
1
+ {"version":3,"file":"bip44.d.mts","sourceRoot":"","sources":["../../../../src/api/v2/create-account/bip44.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,KAAK,EACX,8BAA8B;AAI/B;;GAEG;AACH,eAAO,MAAM,yCAAyC;;;;;IACpD;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;EAEH,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,mCAAmC,GAAG,KAAK,CACrD,OAAO,yCAAyC,CACjD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,0CAA0C;;;;;IACrD;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;EAEH,CAAC;AAEH;;;;;GAKG;AACH,MAAM,MAAM,oCAAoC,GAAG,KAAK,CACtD,OAAO,0CAA0C,CAClD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uCAAuC;;;;;IAClD;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;EAEH,CAAC;AAEH;;;;;GAKG;AACH,MAAM,MAAM,iCAAiC,GAAG,KAAK,CACnD,OAAO,uCAAuC,CAC/C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,+CAA+C;;;;;;;;IAC1D;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;;;;QAED;;WAEG;;QAEH;;WAEG;;;EAGL,CAAC;AAEH;;;;;;;;GAQG;AACH,MAAM,MAAM,yCAAyC,GAAG,KAAK,CAC3D,OAAO,+CAA+C,CACvD,CAAC"}
@@ -51,4 +51,30 @@ export const CreateAccountBip44DiscoverOptionsStruct = object({
51
51
  */
52
52
  groupIndex: number(),
53
53
  });
54
+ /**
55
+ * Struct for {@link CreateAccountBip44DeriveIndexRangeOptions}.
56
+ */
57
+ export const CreateAccountBip44DeriveIndexRangeOptionsStruct = object({
58
+ /**
59
+ * The type of the options.
60
+ */
61
+ type: literal('bip44:derive-index-range'),
62
+ /**
63
+ * ID of the entropy source to be used to derive the accounts.
64
+ */
65
+ entropySource: string(),
66
+ /**
67
+ * The range of account group indices to derive (inclusive on both ends).
68
+ */
69
+ range: object({
70
+ /**
71
+ * The starting index of the account group range (inclusive).
72
+ */
73
+ from: number(),
74
+ /**
75
+ * The ending index of the account group range (inclusive).
76
+ */
77
+ to: number(),
78
+ }),
79
+ });
54
80
  //# sourceMappingURL=bip44.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"bip44.mjs","sourceRoot":"","sources":["../../../../src/api/v2/create-account/bip44.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,MAAM,EACN,MAAM,EACN,MAAM,EAEP,8BAA8B;AAE/B,OAAO,EAAE,oBAAoB,EAAE,6BAAyB;AAExD;;GAEG;AACH,MAAM,CAAC,MAAM,yCAAyC,GAAG,MAAM,CAAC;IAC9D;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC,mBAAmB,CAAC;IAClC;;OAEG;IACH,aAAa,EAAE,MAAM,EAAE;IACvB;;OAEG;IACH,cAAc,EAAE,oBAAoB;CACrC,CAAC,CAAC;AASH;;GAEG;AACH,MAAM,CAAC,MAAM,0CAA0C,GAAG,MAAM,CAAC;IAC/D;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC,oBAAoB,CAAC;IACnC;;OAEG;IACH,aAAa,EAAE,MAAM,EAAE;IACvB;;OAEG;IACH,UAAU,EAAE,MAAM,EAAE;CACrB,CAAC,CAAC;AAYH;;GAEG;AACH,MAAM,CAAC,MAAM,uCAAuC,GAAG,MAAM,CAAC;IAC5D;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC,gBAAgB,CAAC;IAC/B;;OAEG;IACH,aAAa,EAAE,MAAM,EAAE;IACvB;;OAEG;IACH,UAAU,EAAE,MAAM,EAAE;CACrB,CAAC,CAAC","sourcesContent":["import {\n literal,\n number,\n object,\n string,\n type Infer,\n} from '@metamask/superstruct';\n\nimport { DerivationPathStruct } from '../../derivation';\n\n/**\n * Struct for {@link CreateAccountBip44DerivePathOptions}.\n */\nexport const CreateAccountBip44DerivePathOptionsStruct = object({\n /**\n * Type of the options.\n */\n type: literal('bip44:derive-path'),\n /**\n * ID of the entropy source to be used to derive the account.\n */\n entropySource: string(),\n /**\n * BIP-44 derivation path to be used to derive the account.\n */\n derivationPath: DerivationPathStruct,\n});\n\n/**\n * Options for creating an account using the given BIP-44 derivation path.\n */\nexport type CreateAccountBip44DerivePathOptions = Infer<\n typeof CreateAccountBip44DerivePathOptionsStruct\n>;\n\n/**\n * Struct for {@link CreateAccountBip44DeriveIndexOptions}.\n */\nexport const CreateAccountBip44DeriveIndexOptionsStruct = object({\n /**\n * The type of the options.\n */\n type: literal('bip44:derive-index'),\n /**\n * ID of the entropy source to be used to derive the account.\n */\n entropySource: string(),\n /**\n * The index of the account group to be derived.\n */\n groupIndex: number(),\n});\n\n/**\n * Options for creating an account using the given BIP-44 account group index.\n *\n * Note that the keyring can support non-standard BIP-44 paths for\n * compatibility with other wallets.\n */\nexport type CreateAccountBip44DeriveIndexOptions = Infer<\n typeof CreateAccountBip44DeriveIndexOptionsStruct\n>;\n\n/**\n * Struct for {@link CreateAccountBip44DiscoverOptions}.\n */\nexport const CreateAccountBip44DiscoverOptionsStruct = object({\n /**\n * The type of the options.\n */\n type: literal('bip44:discover'),\n /**\n * ID of the entropy source to be used to derive the account.\n */\n entropySource: string(),\n /**\n * The index of the account group to be derived.\n */\n groupIndex: number(),\n});\n\n/**\n * Options for creating accounts by performing a BIP-44 account discovery.\n *\n * Note that the keyring can support non-standard BIP-44 paths for\n * compatibility with other wallets.\n */\nexport type CreateAccountBip44DiscoverOptions = Infer<\n typeof CreateAccountBip44DiscoverOptionsStruct\n>;\n"]}
1
+ {"version":3,"file":"bip44.mjs","sourceRoot":"","sources":["../../../../src/api/v2/create-account/bip44.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,MAAM,EACN,MAAM,EACN,MAAM,EAEP,8BAA8B;AAE/B,OAAO,EAAE,oBAAoB,EAAE,6BAAyB;AAExD;;GAEG;AACH,MAAM,CAAC,MAAM,yCAAyC,GAAG,MAAM,CAAC;IAC9D;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC,mBAAmB,CAAC;IAClC;;OAEG;IACH,aAAa,EAAE,MAAM,EAAE;IACvB;;OAEG;IACH,cAAc,EAAE,oBAAoB;CACrC,CAAC,CAAC;AASH;;GAEG;AACH,MAAM,CAAC,MAAM,0CAA0C,GAAG,MAAM,CAAC;IAC/D;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC,oBAAoB,CAAC;IACnC;;OAEG;IACH,aAAa,EAAE,MAAM,EAAE;IACvB;;OAEG;IACH,UAAU,EAAE,MAAM,EAAE;CACrB,CAAC,CAAC;AAYH;;GAEG;AACH,MAAM,CAAC,MAAM,uCAAuC,GAAG,MAAM,CAAC;IAC5D;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC,gBAAgB,CAAC;IAC/B;;OAEG;IACH,aAAa,EAAE,MAAM,EAAE;IACvB;;OAEG;IACH,UAAU,EAAE,MAAM,EAAE;CACrB,CAAC,CAAC;AAYH;;GAEG;AACH,MAAM,CAAC,MAAM,+CAA+C,GAAG,MAAM,CAAC;IACpE;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC,0BAA0B,CAAC;IACzC;;OAEG;IACH,aAAa,EAAE,MAAM,EAAE;IACvB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;QACZ;;WAEG;QACH,IAAI,EAAE,MAAM,EAAE;QACd;;WAEG;QACH,EAAE,EAAE,MAAM,EAAE;KACb,CAAC;CACH,CAAC,CAAC","sourcesContent":["import {\n literal,\n number,\n object,\n string,\n type Infer,\n} from '@metamask/superstruct';\n\nimport { DerivationPathStruct } from '../../derivation';\n\n/**\n * Struct for {@link CreateAccountBip44DerivePathOptions}.\n */\nexport const CreateAccountBip44DerivePathOptionsStruct = object({\n /**\n * Type of the options.\n */\n type: literal('bip44:derive-path'),\n /**\n * ID of the entropy source to be used to derive the account.\n */\n entropySource: string(),\n /**\n * BIP-44 derivation path to be used to derive the account.\n */\n derivationPath: DerivationPathStruct,\n});\n\n/**\n * Options for creating an account using the given BIP-44 derivation path.\n */\nexport type CreateAccountBip44DerivePathOptions = Infer<\n typeof CreateAccountBip44DerivePathOptionsStruct\n>;\n\n/**\n * Struct for {@link CreateAccountBip44DeriveIndexOptions}.\n */\nexport const CreateAccountBip44DeriveIndexOptionsStruct = object({\n /**\n * The type of the options.\n */\n type: literal('bip44:derive-index'),\n /**\n * ID of the entropy source to be used to derive the account.\n */\n entropySource: string(),\n /**\n * The index of the account group to be derived.\n */\n groupIndex: number(),\n});\n\n/**\n * Options for creating an account using the given BIP-44 account group index.\n *\n * Note that the keyring can support non-standard BIP-44 paths for\n * compatibility with other wallets.\n */\nexport type CreateAccountBip44DeriveIndexOptions = Infer<\n typeof CreateAccountBip44DeriveIndexOptionsStruct\n>;\n\n/**\n * Struct for {@link CreateAccountBip44DiscoverOptions}.\n */\nexport const CreateAccountBip44DiscoverOptionsStruct = object({\n /**\n * The type of the options.\n */\n type: literal('bip44:discover'),\n /**\n * ID of the entropy source to be used to derive the account.\n */\n entropySource: string(),\n /**\n * The index of the account group to be derived.\n */\n groupIndex: number(),\n});\n\n/**\n * Options for creating accounts by performing a BIP-44 account discovery.\n *\n * Note that the keyring can support non-standard BIP-44 paths for\n * compatibility with other wallets.\n */\nexport type CreateAccountBip44DiscoverOptions = Infer<\n typeof CreateAccountBip44DiscoverOptionsStruct\n>;\n\n/**\n * Struct for {@link CreateAccountBip44DeriveIndexRangeOptions}.\n */\nexport const CreateAccountBip44DeriveIndexRangeOptionsStruct = object({\n /**\n * The type of the options.\n */\n type: literal('bip44:derive-index-range'),\n /**\n * ID of the entropy source to be used to derive the accounts.\n */\n entropySource: string(),\n /**\n * The range of account group indices to derive (inclusive on both ends).\n */\n range: object({\n /**\n * The starting index of the account group range (inclusive).\n */\n from: number(),\n /**\n * The ending index of the account group range (inclusive).\n */\n to: number(),\n }),\n});\n\n/**\n * Options for creating accounts by deriving a range of BIP-44 account indices.\n *\n * The range is inclusive on both ends, meaning range.from=0 and range.to=5\n * will create accounts for group indices 0, 1, 2, 3, 4, and 5.\n *\n * Note that the keyring can support non-standard BIP-44 paths for\n * compatibility with other wallets.\n */\nexport type CreateAccountBip44DeriveIndexRangeOptions = Infer<\n typeof CreateAccountBip44DeriveIndexRangeOptionsStruct\n>;\n"]}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CreateAccountCustomOptionsStruct = void 0;
4
+ const superstruct_1 = require("@metamask/superstruct");
5
+ /**
6
+ * Struct for {@link CreateAccountCustomOptions}.
7
+ */
8
+ exports.CreateAccountCustomOptionsStruct = (0, superstruct_1.type)({
9
+ /**
10
+ * The type of the options.
11
+ */
12
+ type: (0, superstruct_1.literal)('custom'),
13
+ });
14
+ //# sourceMappingURL=custom.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom.cjs","sourceRoot":"","sources":["../../../../src/api/v2/create-account/custom.ts"],"names":[],"mappings":";;;AAAA,uDAAkE;AAElE;;GAEG;AACU,QAAA,gCAAgC,GAAG,IAAA,kBAAI,EAAC;IACnD;;OAEG;IACH,IAAI,EAAE,IAAA,qBAAO,EAAC,QAAQ,CAAC;CACxB,CAAC,CAAC","sourcesContent":["import { literal, type, type Infer } from '@metamask/superstruct';\n\n/**\n * Struct for {@link CreateAccountCustomOptions}.\n */\nexport const CreateAccountCustomOptionsStruct = type({\n /**\n * The type of the options.\n */\n type: literal('custom'),\n});\n\n/**\n * Options for creating an account using a custom, keyring-specific method.\n *\n * This is an opaque type that allows keyrings with non-standard account\n * creation flows to define their own options. Keyrings using this type\n * should declare `custom.createAccounts: true` in their capabilities.\n *\n * The actual options accepted by the keyring are implementation-specific\n * and not validated by this struct beyond the `type` field. Adaptors should\n * handle any additional options as needed and add type intersections as necessary.\n */\nexport type CreateAccountCustomOptions = Infer<\n typeof CreateAccountCustomOptionsStruct\n>;\n"]}
@@ -0,0 +1,25 @@
1
+ import { type Infer } from "@metamask/superstruct";
2
+ /**
3
+ * Struct for {@link CreateAccountCustomOptions}.
4
+ */
5
+ export declare const CreateAccountCustomOptionsStruct: import("@metamask/superstruct").Struct<{
6
+ type: "custom";
7
+ }, {
8
+ /**
9
+ * The type of the options.
10
+ */
11
+ type: import("@metamask/superstruct").Struct<"custom", "custom">;
12
+ }>;
13
+ /**
14
+ * Options for creating an account using a custom, keyring-specific method.
15
+ *
16
+ * This is an opaque type that allows keyrings with non-standard account
17
+ * creation flows to define their own options. Keyrings using this type
18
+ * should declare `custom.createAccounts: true` in their capabilities.
19
+ *
20
+ * The actual options accepted by the keyring are implementation-specific
21
+ * and not validated by this struct beyond the `type` field. Adaptors should
22
+ * handle any additional options as needed and add type intersections as necessary.
23
+ */
24
+ export type CreateAccountCustomOptions = Infer<typeof CreateAccountCustomOptionsStruct>;
25
+ //# sourceMappingURL=custom.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom.d.cts","sourceRoot":"","sources":["../../../../src/api/v2/create-account/custom.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,KAAK,EAAE,8BAA8B;AAElE;;GAEG;AACH,eAAO,MAAM,gCAAgC;;;IAC3C;;OAEG;;EAEH,CAAC;AAEH;;;;;;;;;;GAUG;AACH,MAAM,MAAM,0BAA0B,GAAG,KAAK,CAC5C,OAAO,gCAAgC,CACxC,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { type Infer } from "@metamask/superstruct";
2
+ /**
3
+ * Struct for {@link CreateAccountCustomOptions}.
4
+ */
5
+ export declare const CreateAccountCustomOptionsStruct: import("@metamask/superstruct").Struct<{
6
+ type: "custom";
7
+ }, {
8
+ /**
9
+ * The type of the options.
10
+ */
11
+ type: import("@metamask/superstruct").Struct<"custom", "custom">;
12
+ }>;
13
+ /**
14
+ * Options for creating an account using a custom, keyring-specific method.
15
+ *
16
+ * This is an opaque type that allows keyrings with non-standard account
17
+ * creation flows to define their own options. Keyrings using this type
18
+ * should declare `custom.createAccounts: true` in their capabilities.
19
+ *
20
+ * The actual options accepted by the keyring are implementation-specific
21
+ * and not validated by this struct beyond the `type` field. Adaptors should
22
+ * handle any additional options as needed and add type intersections as necessary.
23
+ */
24
+ export type CreateAccountCustomOptions = Infer<typeof CreateAccountCustomOptionsStruct>;
25
+ //# sourceMappingURL=custom.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom.d.mts","sourceRoot":"","sources":["../../../../src/api/v2/create-account/custom.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,KAAK,EAAE,8BAA8B;AAElE;;GAEG;AACH,eAAO,MAAM,gCAAgC;;;IAC3C;;OAEG;;EAEH,CAAC;AAEH;;;;;;;;;;GAUG;AACH,MAAM,MAAM,0BAA0B,GAAG,KAAK,CAC5C,OAAO,gCAAgC,CACxC,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { literal, type } from "@metamask/superstruct";
2
+ /**
3
+ * Struct for {@link CreateAccountCustomOptions}.
4
+ */
5
+ export const CreateAccountCustomOptionsStruct = type({
6
+ /**
7
+ * The type of the options.
8
+ */
9
+ type: literal('custom'),
10
+ });
11
+ //# sourceMappingURL=custom.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom.mjs","sourceRoot":"","sources":["../../../../src/api/v2/create-account/custom.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAc,8BAA8B;AAElE;;GAEG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,IAAI,CAAC;IACnD;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC;CACxB,CAAC,CAAC","sourcesContent":["import { literal, type, type Infer } from '@metamask/superstruct';\n\n/**\n * Struct for {@link CreateAccountCustomOptions}.\n */\nexport const CreateAccountCustomOptionsStruct = type({\n /**\n * The type of the options.\n */\n type: literal('custom'),\n});\n\n/**\n * Options for creating an account using a custom, keyring-specific method.\n *\n * This is an opaque type that allows keyrings with non-standard account\n * creation flows to define their own options. Keyrings using this type\n * should declare `custom.createAccounts: true` in their capabilities.\n *\n * The actual options accepted by the keyring are implementation-specific\n * and not validated by this struct beyond the `type` field. Adaptors should\n * handle any additional options as needed and add type intersections as necessary.\n */\nexport type CreateAccountCustomOptions = Infer<\n typeof CreateAccountCustomOptionsStruct\n>;\n"]}
@@ -15,10 +15,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.CreateAccountOptionsStruct = exports.AccountCreationType = void 0;
18
+ exports.assertCreateAccountOptionIsSupported = assertCreateAccountOptionIsSupported;
18
19
  const keyring_utils_1 = require("@metamask/keyring-utils");
19
20
  const bip44_1 = require("./bip44.cjs");
21
+ const custom_1 = require("./custom.cjs");
20
22
  const private_key_1 = require("./private-key.cjs");
21
23
  __exportStar(require("./bip44.cjs"), exports);
24
+ __exportStar(require("./custom.cjs"), exports);
22
25
  __exportStar(require("./private-key.cjs"), exports);
23
26
  /**
24
27
  * Enum representing the different ways an account can be created.
@@ -37,6 +40,14 @@ var AccountCreationType;
37
40
  * index.
38
41
  */
39
42
  AccountCreationType["Bip44DeriveIndex"] = "bip44:derive-index";
43
+ /**
44
+ * Represents accounts created by deriving a range of BIP-44 account indices.
45
+ *
46
+ * More than one account can be created per index, for example, the keyring
47
+ * can create multiple account types (e.g., P2PKH, P2TR, P2WPKH) for each
48
+ * account index in the range.
49
+ */
50
+ AccountCreationType["Bip44DeriveIndexRange"] = "bip44:derive-index-range";
40
51
  /**
41
52
  * Represents accounts created through BIP-44 account discovery.
42
53
  *
@@ -49,6 +60,13 @@ var AccountCreationType;
49
60
  * Represents an account imported from a private key.
50
61
  */
51
62
  AccountCreationType["PrivateKeyImport"] = "private-key:import";
63
+ /**
64
+ * Represents an account created using a custom, keyring-specific method.
65
+ *
66
+ * This is used by keyrings that have non-standard account creation flows
67
+ * and declare `custom.createAccounts: true` in their capabilities.
68
+ */
69
+ AccountCreationType["Custom"] = "custom";
52
70
  })(AccountCreationType || (exports.AccountCreationType = AccountCreationType = {}));
53
71
  /**
54
72
  * Struct for {@link CreateAccountOptions}.
@@ -60,13 +78,50 @@ exports.CreateAccountOptionsStruct = (0, keyring_utils_1.selectiveUnion)((value)
60
78
  return bip44_1.CreateAccountBip44DerivePathOptionsStruct;
61
79
  case AccountCreationType.Bip44DeriveIndex:
62
80
  return bip44_1.CreateAccountBip44DeriveIndexOptionsStruct;
81
+ case AccountCreationType.Bip44DeriveIndexRange:
82
+ return bip44_1.CreateAccountBip44DeriveIndexRangeOptionsStruct;
63
83
  case AccountCreationType.Bip44Discover:
64
84
  return bip44_1.CreateAccountBip44DiscoverOptionsStruct;
65
85
  case AccountCreationType.PrivateKeyImport:
66
86
  return private_key_1.CreateAccountPrivateKeyOptionsStruct;
87
+ case AccountCreationType.Custom:
88
+ return custom_1.CreateAccountCustomOptionsStruct;
67
89
  default:
68
90
  // Return first struct as fallback - validation will fail with proper error indicating the type mismatch
69
91
  return bip44_1.CreateAccountBip44DerivePathOptionsStruct;
70
92
  }
71
93
  });
94
+ /**
95
+ * Asserts that a given create account option type is supported by the keyring.
96
+ *
97
+ * @example
98
+ * ```ts
99
+ * createAccounts(options: CreateAccountOptions) {
100
+ * assertCreateAccountOptionIsSupported(options, [
101
+ * ${AccountCreationType.Bip44DeriveIndex},
102
+ * ${AccountCreationType.Bip44DeriveIndexRange},
103
+ * ] as const);
104
+ *
105
+ * // At this point, TypeScript knows that options.type is either Bip44DeriveIndex or Bip44DeriveIndexRange.
106
+ * if (options.type === AccountCreationType.Bip44DeriveIndex) {
107
+ * ... // Handle Bip44DeriveIndex case.
108
+ * } else {
109
+ * ... // Handle Bip44DeriveIndexRange case.
110
+ * }
111
+ * ...
112
+ * return accounts;
113
+ * }
114
+ * ```
115
+ *
116
+ * @param options - The create account option object to check.
117
+ * @param supportedTypes - The list of supported create account option types for this keyring.
118
+ * @throws Will throw an error if the provided options are not supported.
119
+ */
120
+ function assertCreateAccountOptionIsSupported(options, supportedTypes) {
121
+ const { type } = options;
122
+ const types = supportedTypes;
123
+ if (!types.includes(type)) {
124
+ throw new Error(`Unsupported create account option type: ${type}`);
125
+ }
126
+ }
72
127
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../../src/api/v2/create-account/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2DAAyD;AAGzD,uCAIiB;AACjB,mDAAqE;AAErE,8CAAwB;AACxB,oDAA8B;AAE9B;;GAEG;AACH,IAAY,mBA4BX;AA5BD,WAAY,mBAAmB;IAC7B;;OAEG;IACH,4DAAqC,CAAA;IAErC;;;;;;OAMG;IACH,8DAAuC,CAAA;IAEvC;;;;;;OAMG;IACH,uDAAgC,CAAA;IAEhC;;OAEG;IACH,8DAAuC,CAAA;AACzC,CAAC,EA5BW,mBAAmB,mCAAnB,mBAAmB,QA4B9B;AAED;;GAEG;AACU,QAAA,0BAA0B,GAAG,IAAA,8BAAc,EAAC,CAAC,KAAU,EAAE,EAAE;IACtE,MAAM,mBAAmB,GAAG,KAAK,EAAE,IAA2B,CAAC;IAC/D,QAAQ,mBAAmB,EAAE,CAAC;QAC5B,KAAK,mBAAmB,CAAC,eAAe;YACtC,OAAO,iDAAyC,CAAC;QACnD,KAAK,mBAAmB,CAAC,gBAAgB;YACvC,OAAO,kDAA0C,CAAC;QACpD,KAAK,mBAAmB,CAAC,aAAa;YACpC,OAAO,+CAAuC,CAAC;QACjD,KAAK,mBAAmB,CAAC,gBAAgB;YACvC,OAAO,kDAAoC,CAAC;QAC9C;YACE,wGAAwG;YACxG,OAAO,iDAAyC,CAAC;IACrD,CAAC;AACH,CAAC,CAAC,CAAC","sourcesContent":["import { selectiveUnion } from '@metamask/keyring-utils';\nimport { type Infer } from '@metamask/superstruct';\n\nimport {\n CreateAccountBip44DiscoverOptionsStruct,\n CreateAccountBip44DeriveIndexOptionsStruct,\n CreateAccountBip44DerivePathOptionsStruct,\n} from './bip44';\nimport { CreateAccountPrivateKeyOptionsStruct } from './private-key';\n\nexport * from './bip44';\nexport * from './private-key';\n\n/**\n * Enum representing the different ways an account can be created.\n */\nexport enum AccountCreationType {\n /**\n * Represents an account created using a BIP-44 derivation path.\n */\n Bip44DerivePath = 'bip44:derive-path',\n\n /**\n * Represents accounts created using a BIP-44 account index.\n *\n * More than one account can be created, for example, the keyring can create\n * multiple account types (e.g., P2PKH, P2TR, P2WPKH) for the same account\n * index.\n */\n Bip44DeriveIndex = 'bip44:derive-index',\n\n /**\n * Represents accounts created through BIP-44 account discovery.\n *\n * More than one account can be created, for example, the keyring can create\n * multiple account types (e.g., P2PKH, P2TR, P2WPKH) for the same account\n * index.\n */\n Bip44Discover = 'bip44:discover',\n\n /**\n * Represents an account imported from a private key.\n */\n PrivateKeyImport = 'private-key:import',\n}\n\n/**\n * Struct for {@link CreateAccountOptions}.\n */\nexport const CreateAccountOptionsStruct = selectiveUnion((value: any) => {\n const accountCreationType = value?.type as AccountCreationType;\n switch (accountCreationType) {\n case AccountCreationType.Bip44DerivePath:\n return CreateAccountBip44DerivePathOptionsStruct;\n case AccountCreationType.Bip44DeriveIndex:\n return CreateAccountBip44DeriveIndexOptionsStruct;\n case AccountCreationType.Bip44Discover:\n return CreateAccountBip44DiscoverOptionsStruct;\n case AccountCreationType.PrivateKeyImport:\n return CreateAccountPrivateKeyOptionsStruct;\n default:\n // Return first struct as fallback - validation will fail with proper error indicating the type mismatch\n return CreateAccountBip44DerivePathOptionsStruct;\n }\n});\n\n/**\n * Represents the available options for creating a new account.\n */\nexport type CreateAccountOptions = Infer<typeof CreateAccountOptionsStruct>;\n"]}
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../../src/api/v2/create-account/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAyHA,oFAeC;AAxID,2DAAyD;AAGzD,uCAKiB;AACjB,yCAA4D;AAC5D,mDAAqE;AAErE,8CAAwB;AACxB,+CAAyB;AACzB,oDAA8B;AAE9B;;GAEG;AACH,IAAY,mBA6CX;AA7CD,WAAY,mBAAm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selectiveUnion } from '@metamask/keyring-utils';\nimport { type Infer } from '@metamask/superstruct';\n\nimport {\n CreateAccountBip44DiscoverOptionsStruct,\n CreateAccountBip44DeriveIndexOptionsStruct,\n CreateAccountBip44DeriveIndexRangeOptionsStruct,\n CreateAccountBip44DerivePathOptionsStruct,\n} from './bip44';\nimport { CreateAccountCustomOptionsStruct } from './custom';\nimport { CreateAccountPrivateKeyOptionsStruct } from './private-key';\n\nexport * from './bip44';\nexport * from './custom';\nexport * from './private-key';\n\n/**\n * Enum representing the different ways an account can be created.\n */\nexport enum AccountCreationType {\n /**\n * Represents an account created using a BIP-44 derivation path.\n */\n Bip44DerivePath = 'bip44:derive-path',\n\n /**\n * Represents accounts created using a BIP-44 account index.\n *\n * More than one account can be created, for example, the keyring can create\n * multiple account types (e.g., P2PKH, P2TR, P2WPKH) for the same account\n * index.\n */\n Bip44DeriveIndex = 'bip44:derive-index',\n\n /**\n * Represents accounts created by deriving a range of BIP-44 account indices.\n *\n * More than one account can be created per index, for example, the keyring\n * can create multiple account types (e.g., P2PKH, P2TR, P2WPKH) for each\n * account index in the range.\n */\n Bip44DeriveIndexRange = 'bip44:derive-index-range',\n\n /**\n * Represents accounts created through BIP-44 account discovery.\n *\n * More than one account can be created, for example, the keyring can create\n * multiple account types (e.g., P2PKH, P2TR, P2WPKH) for the same account\n * index.\n */\n Bip44Discover = 'bip44:discover',\n\n /**\n * Represents an account imported from a private key.\n */\n PrivateKeyImport = 'private-key:import',\n\n /**\n * Represents an account created using a custom, keyring-specific method.\n *\n * This is used by keyrings that have non-standard account creation flows\n * and declare `custom.createAccounts: true` in their capabilities.\n */\n Custom = 'custom',\n}\n\n/**\n * Struct for {@link CreateAccountOptions}.\n */\nexport const CreateAccountOptionsStruct = selectiveUnion((value: any) => {\n const accountCreationType = value?.type as AccountCreationType;\n switch (accountCreationType) {\n case AccountCreationType.Bip44DerivePath:\n return CreateAccountBip44DerivePathOptionsStruct;\n case AccountCreationType.Bip44DeriveIndex:\n return CreateAccountBip44DeriveIndexOptionsStruct;\n case AccountCreationType.Bip44DeriveIndexRange:\n return CreateAccountBip44DeriveIndexRangeOptionsStruct;\n case AccountCreationType.Bip44Discover:\n return CreateAccountBip44DiscoverOptionsStruct;\n case AccountCreationType.PrivateKeyImport:\n return CreateAccountPrivateKeyOptionsStruct;\n case AccountCreationType.Custom:\n return CreateAccountCustomOptionsStruct;\n default:\n // Return first struct as fallback - validation will fail with proper error indicating the type mismatch\n return CreateAccountBip44DerivePathOptionsStruct;\n }\n});\n\n/**\n * Represents the available options for creating a new account.\n */\nexport type CreateAccountOptions = Infer<typeof CreateAccountOptionsStruct>;\n\n/**\n * Asserts that a given create account option type is supported by the keyring.\n *\n * @example\n * ```ts\n * createAccounts(options: CreateAccountOptions) {\n * assertCreateAccountOptionIsSupported(options, [\n * ${AccountCreationType.Bip44DeriveIndex},\n * ${AccountCreationType.Bip44DeriveIndexRange},\n * ] as const);\n *\n * // At this point, TypeScript knows that options.type is either Bip44DeriveIndex or Bip44DeriveIndexRange.\n * if (options.type === AccountCreationType.Bip44DeriveIndex) {\n * ... // Handle Bip44DeriveIndex case.\n * } else {\n * ... // Handle Bip44DeriveIndexRange case.\n * }\n * ...\n * return accounts;\n * }\n * ```\n *\n * @param options - The create account option object to check.\n * @param supportedTypes - The list of supported create account option types for this keyring.\n * @throws Will throw an error if the provided options are not supported.\n */\nexport function assertCreateAccountOptionIsSupported<\n Options extends CreateAccountOptions,\n // We use template literal types to enforce string-literal over strict enum values.\n Type extends `${CreateAccountOptions['type']}`,\n>(\n options: Options,\n supportedTypes: readonly `${Type}`[],\n // Use intersection to avoid widening `type` beyond `Options['type']`.\n): asserts options is Options & { type: `${Type}` & `${Options['type']}` } {\n const { type } = options;\n const types: readonly CreateAccountOptions['type'][] = supportedTypes;\n\n if (!types.includes(type)) {\n throw new Error(`Unsupported create account option type: ${type}`);\n }\n}\n"]}