@metamask-previews/utils 11.12.1-preview-c44fd50 → 11.12.1-preview-2caaa71

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 (282) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/{assert.d.mts → assert.d.ts} +2 -2
  3. package/dist/assert.d.ts.map +1 -0
  4. package/dist/{assert.mjs → assert.js} +4 -4
  5. package/dist/assert.js.map +1 -0
  6. package/dist/{base64.d.cts → base64.d.ts} +2 -2
  7. package/dist/base64.d.ts.map +1 -0
  8. package/dist/{base64.mjs → base64.js} +3 -3
  9. package/dist/base64.js.map +1 -0
  10. package/dist/{bytes.d.cts → bytes.d.ts} +2 -2
  11. package/dist/bytes.d.ts.map +1 -0
  12. package/dist/{bytes.mjs → bytes.js} +4 -4
  13. package/dist/bytes.js.map +1 -0
  14. package/dist/{caip-types.d.cts → caip-types.d.ts} +2 -2
  15. package/dist/caip-types.d.ts.map +1 -0
  16. package/dist/{caip-types.mjs → caip-types.js} +2 -2
  17. package/dist/caip-types.js.map +1 -0
  18. package/dist/{checksum.d.cts → checksum.d.ts} +1 -1
  19. package/dist/checksum.d.ts.map +1 -0
  20. package/dist/checksum.js +4 -0
  21. package/dist/checksum.js.map +1 -0
  22. package/dist/{coercers.d.cts → coercers.d.ts} +4 -4
  23. package/dist/coercers.d.ts.map +1 -0
  24. package/dist/{coercers.mjs → coercers.js} +5 -5
  25. package/dist/coercers.js.map +1 -0
  26. package/dist/{collections.d.cts → collections.d.ts} +9 -9
  27. package/dist/collections.d.ts.map +1 -0
  28. package/dist/collections.js +93 -0
  29. package/dist/collections.js.map +1 -0
  30. package/dist/{encryption-types.d.cts → encryption-types.d.ts} +1 -1
  31. package/dist/encryption-types.d.ts.map +1 -0
  32. package/dist/encryption-types.js +2 -0
  33. package/dist/encryption-types.js.map +1 -0
  34. package/dist/{errors.d.mts → errors.d.ts} +1 -1
  35. package/dist/errors.d.ts.map +1 -0
  36. package/dist/{errors.mjs → errors.js} +4 -10
  37. package/dist/errors.js.map +1 -0
  38. package/dist/{fs.d.cts → fs.d.ts} +2 -2
  39. package/dist/fs.d.ts.map +1 -0
  40. package/dist/{fs.mjs → fs.js} +7 -7
  41. package/dist/fs.js.map +1 -0
  42. package/dist/{hashing.d.cts → hashing.d.ts} +1 -1
  43. package/dist/hashing.d.ts.map +1 -0
  44. package/dist/{hashing.mjs → hashing.js} +8 -3
  45. package/dist/hashing.js.map +1 -0
  46. package/dist/{hex.d.cts → hex.d.ts} +5 -6
  47. package/dist/hex.d.ts.map +1 -0
  48. package/dist/{hex.mjs → hex.js} +5 -6
  49. package/dist/hex.js.map +1 -0
  50. package/dist/index.d.ts +26 -0
  51. package/dist/index.d.ts.map +1 -0
  52. package/dist/index.js +21 -0
  53. package/dist/index.js.map +1 -0
  54. package/dist/{json.d.cts → json.d.ts} +19 -29
  55. package/dist/json.d.ts.map +1 -0
  56. package/dist/{json.mjs → json.js} +5 -4
  57. package/dist/json.js.map +1 -0
  58. package/dist/{keyring.d.mts → keyring.d.ts} +5 -5
  59. package/dist/keyring.d.ts.map +1 -0
  60. package/dist/keyring.js +2 -0
  61. package/dist/keyring.js.map +1 -0
  62. package/dist/{logging.d.cts → logging.d.ts} +2 -2
  63. package/dist/logging.d.ts.map +1 -0
  64. package/dist/{logging.mjs → logging.js} +2 -9
  65. package/dist/logging.js.map +1 -0
  66. package/dist/{misc.d.mts → misc.d.ts} +1 -1
  67. package/dist/misc.d.ts.map +1 -0
  68. package/dist/{misc.mjs → misc.js} +1 -1
  69. package/dist/misc.js.map +1 -0
  70. package/dist/{mnemonic.d.cts → mnemonic.d.ts} +1 -1
  71. package/dist/mnemonic.d.ts.map +1 -0
  72. package/dist/{mnemonic.mjs → mnemonic.js} +2 -2
  73. package/dist/mnemonic.js.map +1 -0
  74. package/dist/node.d.ts +3 -0
  75. package/dist/node.d.ts.map +1 -0
  76. package/dist/node.js +3 -0
  77. package/dist/node.js.map +1 -0
  78. package/dist/{number.d.mts → number.d.ts} +2 -2
  79. package/dist/number.d.ts.map +1 -0
  80. package/dist/{number.mjs → number.js} +3 -3
  81. package/dist/number.js.map +1 -0
  82. package/dist/{opaque.d.cts → opaque.d.ts} +1 -1
  83. package/dist/opaque.d.ts.map +1 -0
  84. package/dist/opaque.js +2 -0
  85. package/dist/opaque.js.map +1 -0
  86. package/dist/{promise.d.cts → promise.d.ts} +1 -1
  87. package/dist/promise.d.ts.map +1 -0
  88. package/dist/{promise.mjs → promise.js} +1 -1
  89. package/dist/promise.js.map +1 -0
  90. package/dist/{superstruct.d.mts → superstruct.d.ts} +2 -2
  91. package/dist/superstruct.d.ts.map +1 -0
  92. package/dist/{superstruct.mjs → superstruct.js} +2 -2
  93. package/dist/superstruct.js.map +1 -0
  94. package/dist/{time.d.mts → time.d.ts} +1 -1
  95. package/dist/time.d.ts.map +1 -0
  96. package/dist/{time.mjs → time.js} +1 -1
  97. package/dist/time.js.map +1 -0
  98. package/dist/{transaction-types.d.cts → transaction-types.d.ts} +3 -3
  99. package/dist/transaction-types.d.ts.map +1 -0
  100. package/dist/transaction-types.js +2 -0
  101. package/dist/transaction-types.js.map +1 -0
  102. package/dist/{unitsConversion.d.cts → unitsConversion.d.ts} +28 -28
  103. package/dist/unitsConversion.d.ts.map +1 -0
  104. package/dist/{unitsConversion.mjs → unitsConversion.js} +1 -1
  105. package/dist/unitsConversion.js.map +1 -0
  106. package/dist/{versions.d.mts → versions.d.ts} +3 -3
  107. package/dist/versions.d.ts.map +1 -0
  108. package/dist/{versions.mjs → versions.js} +4 -4
  109. package/dist/versions.js.map +1 -0
  110. package/package.json +21 -30
  111. package/dist/assert.cjs +0 -122
  112. package/dist/assert.cjs.map +0 -1
  113. package/dist/assert.d.cts +0 -61
  114. package/dist/assert.d.cts.map +0 -1
  115. package/dist/assert.d.mts.map +0 -1
  116. package/dist/assert.mjs.map +0 -1
  117. package/dist/base64.cjs +0 -34
  118. package/dist/base64.cjs.map +0 -1
  119. package/dist/base64.d.cts.map +0 -1
  120. package/dist/base64.d.mts +0 -25
  121. package/dist/base64.d.mts.map +0 -1
  122. package/dist/base64.mjs.map +0 -1
  123. package/dist/bytes.cjs +0 -427
  124. package/dist/bytes.cjs.map +0 -1
  125. package/dist/bytes.d.cts.map +0 -1
  126. package/dist/bytes.d.mts +0 -198
  127. package/dist/bytes.d.mts.map +0 -1
  128. package/dist/bytes.mjs.map +0 -1
  129. package/dist/caip-types.cjs +0 -390
  130. package/dist/caip-types.cjs.map +0 -1
  131. package/dist/caip-types.d.cts.map +0 -1
  132. package/dist/caip-types.d.mts +0 -294
  133. package/dist/caip-types.d.mts.map +0 -1
  134. package/dist/caip-types.mjs.map +0 -1
  135. package/dist/checksum.cjs +0 -7
  136. package/dist/checksum.cjs.map +0 -1
  137. package/dist/checksum.d.cts.map +0 -1
  138. package/dist/checksum.d.mts +0 -2
  139. package/dist/checksum.d.mts.map +0 -1
  140. package/dist/checksum.mjs +0 -4
  141. package/dist/checksum.mjs.map +0 -1
  142. package/dist/coercers.cjs +0 -166
  143. package/dist/coercers.cjs.map +0 -1
  144. package/dist/coercers.d.cts.map +0 -1
  145. package/dist/coercers.d.mts +0 -97
  146. package/dist/coercers.d.mts.map +0 -1
  147. package/dist/coercers.mjs.map +0 -1
  148. package/dist/collections.cjs +0 -109
  149. package/dist/collections.cjs.map +0 -1
  150. package/dist/collections.d.cts.map +0 -1
  151. package/dist/collections.d.mts +0 -39
  152. package/dist/collections.d.mts.map +0 -1
  153. package/dist/collections.mjs +0 -105
  154. package/dist/collections.mjs.map +0 -1
  155. package/dist/encryption-types.cjs +0 -3
  156. package/dist/encryption-types.cjs.map +0 -1
  157. package/dist/encryption-types.d.cts.map +0 -1
  158. package/dist/encryption-types.d.mts +0 -7
  159. package/dist/encryption-types.d.mts.map +0 -1
  160. package/dist/encryption-types.mjs +0 -2
  161. package/dist/encryption-types.mjs.map +0 -1
  162. package/dist/errors.cjs +0 -129
  163. package/dist/errors.cjs.map +0 -1
  164. package/dist/errors.d.cts +0 -68
  165. package/dist/errors.d.cts.map +0 -1
  166. package/dist/errors.d.mts.map +0 -1
  167. package/dist/errors.mjs.map +0 -1
  168. package/dist/fs.cjs +0 -248
  169. package/dist/fs.cjs.map +0 -1
  170. package/dist/fs.d.cts.map +0 -1
  171. package/dist/fs.d.mts +0 -133
  172. package/dist/fs.d.mts.map +0 -1
  173. package/dist/fs.mjs.map +0 -1
  174. package/dist/hashing.cjs +0 -60
  175. package/dist/hashing.cjs.map +0 -1
  176. package/dist/hashing.d.cts.map +0 -1
  177. package/dist/hashing.d.mts +0 -28
  178. package/dist/hashing.d.mts.map +0 -1
  179. package/dist/hashing.mjs.map +0 -1
  180. package/dist/hex.cjs +0 -188
  181. package/dist/hex.cjs.map +0 -1
  182. package/dist/hex.d.cts.map +0 -1
  183. package/dist/hex.d.mts +0 -118
  184. package/dist/hex.d.mts.map +0 -1
  185. package/dist/hex.mjs.map +0 -1
  186. package/dist/index.cjs +0 -58
  187. package/dist/index.cjs.map +0 -1
  188. package/dist/index.d.cts +0 -26
  189. package/dist/index.d.cts.map +0 -1
  190. package/dist/index.d.mts +0 -26
  191. package/dist/index.d.mts.map +0 -1
  192. package/dist/index.mjs +0 -21
  193. package/dist/index.mjs.map +0 -1
  194. package/dist/json.cjs +0 -425
  195. package/dist/json.cjs.map +0 -1
  196. package/dist/json.d.cts.map +0 -1
  197. package/dist/json.d.mts +0 -398
  198. package/dist/json.d.mts.map +0 -1
  199. package/dist/json.mjs.map +0 -1
  200. package/dist/keyring.cjs +0 -3
  201. package/dist/keyring.cjs.map +0 -1
  202. package/dist/keyring.d.cts +0 -243
  203. package/dist/keyring.d.cts.map +0 -1
  204. package/dist/keyring.d.mts.map +0 -1
  205. package/dist/keyring.mjs +0 -2
  206. package/dist/keyring.mjs.map +0 -1
  207. package/dist/logging.cjs +0 -43
  208. package/dist/logging.cjs.map +0 -1
  209. package/dist/logging.d.cts.map +0 -1
  210. package/dist/logging.d.mts +0 -30
  211. package/dist/logging.d.mts.map +0 -1
  212. package/dist/logging.mjs.map +0 -1
  213. package/dist/misc.cjs +0 -154
  214. package/dist/misc.cjs.map +0 -1
  215. package/dist/misc.d.cts +0 -127
  216. package/dist/misc.d.cts.map +0 -1
  217. package/dist/misc.d.mts.map +0 -1
  218. package/dist/misc.mjs.map +0 -1
  219. package/dist/mnemonic.cjs +0 -53
  220. package/dist/mnemonic.cjs.map +0 -1
  221. package/dist/mnemonic.d.cts.map +0 -1
  222. package/dist/mnemonic.d.mts +0 -14
  223. package/dist/mnemonic.d.mts.map +0 -1
  224. package/dist/mnemonic.mjs.map +0 -1
  225. package/dist/node.cjs +0 -19
  226. package/dist/node.cjs.map +0 -1
  227. package/dist/node.d.cts +0 -3
  228. package/dist/node.d.cts.map +0 -1
  229. package/dist/node.d.mts +0 -3
  230. package/dist/node.d.mts.map +0 -1
  231. package/dist/node.mjs +0 -3
  232. package/dist/node.mjs.map +0 -1
  233. package/dist/number.cjs +0 -102
  234. package/dist/number.cjs.map +0 -1
  235. package/dist/number.d.cts +0 -74
  236. package/dist/number.d.cts.map +0 -1
  237. package/dist/number.d.mts.map +0 -1
  238. package/dist/number.mjs.map +0 -1
  239. package/dist/opaque.cjs +0 -3
  240. package/dist/opaque.cjs.map +0 -1
  241. package/dist/opaque.d.cts.map +0 -1
  242. package/dist/opaque.d.mts +0 -6
  243. package/dist/opaque.d.mts.map +0 -1
  244. package/dist/opaque.mjs +0 -2
  245. package/dist/opaque.mjs.map +0 -1
  246. package/dist/promise.cjs +0 -44
  247. package/dist/promise.cjs.map +0 -1
  248. package/dist/promise.d.cts.map +0 -1
  249. package/dist/promise.d.mts +0 -45
  250. package/dist/promise.d.mts.map +0 -1
  251. package/dist/promise.mjs.map +0 -1
  252. package/dist/superstruct.cjs +0 -28
  253. package/dist/superstruct.cjs.map +0 -1
  254. package/dist/superstruct.d.cts +0 -20
  255. package/dist/superstruct.d.cts.map +0 -1
  256. package/dist/superstruct.d.mts.map +0 -1
  257. package/dist/superstruct.mjs.map +0 -1
  258. package/dist/time.cjs +0 -67
  259. package/dist/time.cjs.map +0 -1
  260. package/dist/time.d.cts +0 -49
  261. package/dist/time.d.cts.map +0 -1
  262. package/dist/time.d.mts.map +0 -1
  263. package/dist/time.mjs.map +0 -1
  264. package/dist/transaction-types.cjs +0 -3
  265. package/dist/transaction-types.cjs.map +0 -1
  266. package/dist/transaction-types.d.cts.map +0 -1
  267. package/dist/transaction-types.d.mts +0 -117
  268. package/dist/transaction-types.d.mts.map +0 -1
  269. package/dist/transaction-types.mjs +0 -2
  270. package/dist/transaction-types.mjs.map +0 -1
  271. package/dist/unitsConversion.cjs +0 -217
  272. package/dist/unitsConversion.cjs.map +0 -1
  273. package/dist/unitsConversion.d.cts.map +0 -1
  274. package/dist/unitsConversion.d.mts +0 -80
  275. package/dist/unitsConversion.d.mts.map +0 -1
  276. package/dist/unitsConversion.mjs.map +0 -1
  277. package/dist/versions.cjs +0 -95
  278. package/dist/versions.cjs.map +0 -1
  279. package/dist/versions.d.cts +0 -101
  280. package/dist/versions.d.cts.map +0 -1
  281. package/dist/versions.d.mts.map +0 -1
  282. package/dist/versions.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyring.js","sourceRoot":"","sources":["../src/keyring.ts"],"names":[],"mappings":"","sourcesContent":["import type { TypedTransaction, LegacyTxData } from '@ethereumjs/tx';\n\nimport type { Eip1024EncryptedData } from './encryption-types.js';\nimport type { Hex } from './hex.js';\nimport type { Json } from './json.js';\n\n/**\n * A Keyring class.\n *\n * This type is used to validate the constructor signature and the `type`\n * static property on Keyring classes. See the {@link Keyring} type for more\n * information.\n *\n * @deprecated This type has been moved to the `@metamask/keyring-utils` package.\n * See {@link https://github.com/MetaMask/accounts/tree/main/packages/keyring-utils Keyring Utils}.\n */\nexport type KeyringClass<State extends Json> = {\n /**\n * The Keyring constructor. Takes a single parameter, an \"options\" object.\n * See the documentation for the specific keyring for more information about\n * what these options are.\n *\n * @param options - The constructor options. Differs between keyring\n * implementations.\n */\n new (options?: Record<string, unknown>): Keyring<State>;\n\n /**\n * The name of this type of keyring. This must uniquely identify the\n * keyring type.\n */\n type: string;\n};\n\n/**\n * A keyring is something that can sign messages. Keyrings are used to add new\n * signing strategies; each strategy is a new keyring.\n *\n * Each keyring manages a collection of key pairs, which we call \"accounts\".\n * Each account is referred to by its \"address\", which is a unique identifier\n * derived from the public key. The address is always a \"0x\"-prefixed\n * hexidecimal string.\n *\n * The keyring might store the private key for each account as well, but it's\n * not guaranteed. Some keyrings delegate signing, so they don't need the\n * private key directly. The keyring (and in particular the keyring state)\n * should be treated with care though, just in case it does contain sensitive\n * material such as a private key.\n *\n * @deprecated This type has been moved to the `@metamask/keyring-utils` package.\n * See {@link https://github.com/MetaMask/accounts/tree/main/packages/keyring-utils Keyring Utils}.\n */\nexport type Keyring<State extends Json> = {\n /**\n * The name of this type of keyring. This must match the `type` property of\n * the keyring class.\n */\n type: string;\n\n /**\n * Get the addresses for all accounts in this keyring.\n *\n * @returns A list of the account addresses for this keyring\n */\n getAccounts(): Promise<Hex[]>;\n\n /**\n * Add an account to the keyring.\n *\n * @param number - The number of accounts to add. Usually defaults to 1.\n * @returns A list of the newly added account addresses.\n */\n addAccounts(number: number): Promise<Hex[]>;\n\n /**\n * Serialize the keyring state as a JSON-serializable object.\n *\n * @returns A JSON-serializable representation of the keyring state.\n */\n serialize(): Promise<State>;\n\n /**\n * Deserialize the given keyring state, overwriting any existing state with\n * the serialized state provided.\n *\n * @param state - A JSON-serializable representation of the keyring state.\n */\n deserialize(state: State): Promise<void>;\n\n /**\n * Method to include asynchronous configuration.\n */\n init?(): Promise<void>;\n\n /**\n * Remove an account from the keyring.\n *\n * @param address - The address of the account to remove.\n */\n removeAccount?(address: Hex): void;\n\n /**\n * Export the private key for one of the keyring accounts.\n *\n * Some keyrings accept an \"options\" parameter as well. See the documentation\n * for the specific keyring for more information about what these options\n * are. For some keyrings, the options parameter is used to allow exporting a\n * private key that is derived from the given account, rather than exporting\n * that account's private key directly.\n *\n * @param address - The address of the account to export.\n * @param options - Export options; differs between keyrings.\n * @returns The non-prefixed, hex-encoded private key that was requested.\n */\n exportAccount?(\n address: Hex,\n options?: Record<string, unknown>,\n ): Promise<string>;\n\n /**\n * Get the \"app key\" address for the given account and origin. An app key is\n * an application-specific key pair. See {@link https://eips.ethereum.org/EIPS/eip-1775|EIP-1775}\n * for more information. The {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Origin|origin}\n * is used as the unique identifier for the application, and it's used as\n * part of the key derivation process.\n *\n * @param address - The address of the account the app key is derived from.\n * @param origin - The origin of the application.\n * @returns The address of the app key for the given account and origin.\n */\n getAppKeyAddress?(address: Hex, origin: string): Promise<Hex>;\n\n /**\n * Sign a transaction. This is equivalent to the `eth_signTransaction`\n * Ethereum JSON-RPC method. See the Ethereum JSON-RPC API documentation for\n * more details.\n *\n * Some keyrings accept an \"options\" parameter as well. See the documentation\n * for the specific keyring for more information about what these options\n * are. For some keyrings, the options parameter can even change which key is\n * used for signing (e.g. signing with app keys).\n *\n * @param address - The address of the account to use for signing.\n * @param transaction - The transaction to sign.\n * @param options - Signing options; differs between keyrings.\n * @returns The signed transaction.\n */\n signTransaction?(\n address: Hex,\n transaction: TypedTransaction,\n options?: Record<string, unknown>,\n ): Promise<LegacyTxData>;\n\n /**\n * Sign a message. This is equivalent to an older version of the the\n * `eth_sign` Ethereum JSON-RPC method. The message is signed using ECDSA,\n * using the curve secp256k1 the Keccak-256 hash function.\n *\n * For more information about this method and why we still support it, see\n * the {@link https://docs.metamask.io/guide/signing-data.html|MetaMask Docs}.\n *\n * Some keyrings accept an \"options\" parameter as well. See the documentation\n * for the specific keyring for more information about what these options\n * are. For some keyrings, the options parameter can even change which key is\n * used for signing (e.g. signing with app keys).\n *\n * @param address - The address of the account to use for signing.\n * @param message - The message to sign.\n * @param options - Signing options; differs between keyrings.\n * @returns The signed message.\n */\n signMessage?(\n address: Hex,\n message: string,\n options?: Record<string, unknown>,\n ): Promise<string>;\n\n /**\n * Sign an EIP-7702 authorization. This is a signing method for authorizing a\n * specific contract on a specific chain.\n *\n * @param address - The address of the account to use for signing.\n * @param authorization - An array containing the chain ID, contract address,\n * and nonce.\n * @param options - Signing options; differs between keyrings.\n * @returns The signed authorization as a hex string.\n */\n signEip7702Authorization?(\n address: Hex,\n authorization: [chainId: number, contractAddress: Hex, nonce: number],\n options?: Record<string, unknown>,\n ): Promise<string>;\n\n /**\n * Sign a message. This is equivalent to the `eth_sign` Ethereum JSON-RPC\n * method, which is exposed by MetaMask as the method `personal_sign`. See\n * the Ethereum JSON-RPC API documentation for more details.\n *\n * For more information about this method and why we call it `personal_sign`,\n * see the {@link https://docs.metamask.io/guide/signing-data.html|MetaMask Docs}.\n *\n * Some keyrings accept an \"options\" parameter as well. See the documentation\n * for the specific keyring for more information about what these options\n * are. For some keyrings, the options parameter can even change which key is\n * used for signing (e.g. signing with app keys).\n *\n * @param address - The address of the account to use for signing.\n * @param message - The message to sign.\n * @param options - Signing options; differs between keyrings.\n * @returns The signed message.\n */\n signPersonalMessage?(\n address: Hex,\n message: Hex,\n options?: { version?: string } & Record<string, unknown>,\n ): Promise<string>;\n\n /**\n * Sign a message. This is equivalent to the `eth_signTypedData` Ethereum\n * JSON-RPC method. See {@link https://github.com/ethereum/EIPs/blob/master/EIPS/eip-712.md|EIP-712}\n * for more details.\n *\n * The \"version\" option dictates which version of `eth_signTypedData` is\n * used. The latest version reflects the specification most closely, whereas\n * earlier versions reflect earlier drafts of the specification that are\n * still supported for backwards-compatibility reasons. For more information\n * about why we support multiple versions, see the {@link https://docs.metamask.io/guide/signing-data.html|MetaMask Docs}.\n *\n * Some keyrings accept additional options as well. See the documentation for\n * the specific keyring for more information about what these options are.\n * For some keyrings, the options parameter can even change which key is used\n * for signing (e.g. signing with app keys).\n *\n * @param address - The address of the account to use for signing.\n * @param typedData - The data to sign.\n * @param options - Signing options; differs between keyrings.\n * @returns The signed message.\n */\n signTypedData?(\n address: Hex,\n typedData: Record<string, unknown>,\n options?: Record<string, unknown>,\n ): Promise<string>;\n\n /**\n * Get a public key to use for encryption. This is equivalent to the\n * ` eth_getEncryptionPublicKey` JSON-RPC method. See the {@link https://docs.metamask.io/guide/rpc-api.html#eth-getencryptionpublickey|MetaMask Docs}\n * for more information.\n *\n * Some keyrings accept an \"options\" parameter as well. See the documentation\n * for the specific keyring for more information about what these options\n * are. For some keyrings, the options parameter can even change which key is\n * used (e.g. encrypting with app keys).\n *\n * @param account - The address of the account you want the encryption key for.\n * @param options - Options; differs between keyrings.\n */\n getEncryptionPublicKey?(\n account: Hex,\n options?: Record<string, unknown>,\n ): Promise<string>;\n\n /**\n * Decrypt an encrypted message. This is equivalent to the ` eth_decrypt`\n * JSON-RPC method. See the {@link https://docs.metamask.io/guide/rpc-api.html#eth-decrypt|MetaMask Docs}\n * for more information.\n *\n * @param account - The address of the account you want to use to decrypt\n * the message.\n * @param encryptedData - The encrypted data that you want to decrypt.\n * @returns The decrypted data.\n */\n decryptMessage?(\n account: Hex,\n encryptedData: Eip1024EncryptedData,\n ): Promise<string>;\n\n /**\n * Generates the properties for the keyring based on the given\n * BIP39-compliant mnemonic.\n *\n * @returns A promise resolving when the keyring has generated the properties.\n */\n generateRandomMnemonic?(): Promise<void>;\n\n /**\n * Destroy the keyring.\n */\n destroy?(): Promise<void>;\n};\n"]}
@@ -1,4 +1,4 @@
1
- import type { Debugger } from "debug";
1
+ import type { Debugger } from 'debug';
2
2
  /**
3
3
  * Creates a logger via the `debug` library whose log messages will be tagged
4
4
  * using the name of your project. By default, such messages will be
@@ -27,4 +27,4 @@ export declare function createProjectLogger(projectName: string): Debugger;
27
27
  * @returns An instance of `debug`.
28
28
  */
29
29
  export declare function createModuleLogger(projectLogger: Debugger, moduleName: string): Debugger;
30
- //# sourceMappingURL=logging.d.cts.map
30
+ //# sourceMappingURL=logging.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logging.d.ts","sourceRoot":"","sources":["../src/logging.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAKtC;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,QAAQ,CAEjE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,CAChC,aAAa,EAAE,QAAQ,EACvB,UAAU,EAAE,MAAM,GACjB,QAAQ,CAEV"}
@@ -1,11 +1,4 @@
1
- function $importDefault(module) {
2
- if (module?.__esModule) {
3
- return module.default;
4
- }
5
- return module;
6
- }
7
- import $debug from "debug";
8
- const debug = $importDefault($debug);
1
+ import debug from 'debug';
9
2
  const globalLogger = debug('metamask');
10
3
  /**
11
4
  * Creates a logger via the `debug` library whose log messages will be tagged
@@ -39,4 +32,4 @@ export function createProjectLogger(projectName) {
39
32
  export function createModuleLogger(projectLogger, moduleName) {
40
33
  return projectLogger.extend(moduleName);
41
34
  }
42
- //# sourceMappingURL=logging.mjs.map
35
+ //# sourceMappingURL=logging.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logging.js","sourceRoot":"","sources":["../src/logging.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,YAAY,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC;AAEvC;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,mBAAmB,CAAC,WAAmB;IACrD,OAAO,YAAY,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;AAC1C,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,kBAAkB,CAChC,aAAuB,EACvB,UAAkB;IAElB,OAAO,aAAa,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["import type { Debugger } from 'debug';\nimport debug from 'debug';\n\nconst globalLogger = debug('metamask');\n\n/**\n * Creates a logger via the `debug` library whose log messages will be tagged\n * using the name of your project. By default, such messages will be\n * suppressed, but you can reveal them by setting the `DEBUG` environment\n * variable to `metamask:<projectName>`. You can also set this variable to\n * `metamask:*` if you want to see log messages from all MetaMask projects that\n * are also using this function to create their loggers.\n *\n * @param projectName - The name of your project. This should be the name of\n * your NPM package if you're developing one.\n * @returns An instance of `debug`.\n */\nexport function createProjectLogger(projectName: string): Debugger {\n return globalLogger.extend(projectName);\n}\n\n/**\n * Creates a logger via the `debug` library which is derived from the logger for\n * the whole project whose log messages will be tagged using the name of your\n * module. By default, such messages will be suppressed, but you can reveal them\n * by setting the `DEBUG` environment variable to\n * `metamask:<projectName>:<moduleName>`. You can also set this variable to\n * `metamask:<projectName>:*` if you want to see log messages from the project,\n * or `metamask:*` if you want to see log messages from all MetaMask projects.\n *\n * @param projectLogger - The logger created via {@link createProjectLogger}.\n * @param moduleName - The name of your module. You could use the name of the\n * file where you're using this logger or some other name.\n * @returns An instance of `debug`.\n */\nexport function createModuleLogger(\n projectLogger: Debugger,\n moduleName: string,\n): Debugger {\n return projectLogger.extend(moduleName);\n}\n"]}
@@ -124,4 +124,4 @@ export declare function calculateStringSize(value: string): number;
124
124
  * @returns Number of bytes used to store whole number in JSON.
125
125
  */
126
126
  export declare function calculateNumberSize(value: number): number;
127
- //# sourceMappingURL=misc.d.mts.map
127
+ //# sourceMappingURL=misc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"misc.d.ts","sourceRoot":"","sources":["../src/misc.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,MAAM,MAAM,OAAO,CACjB,WAAW,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC3C,SAAS,SAAS,MAAM,WAAW,IACjC;IACF,CAAC,UAAU,GAAG,IAAI,MAAM,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC;CACxE,GAAG;KACD,GAAG,IAAI,MAAM,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC;CAC9D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AAM,EAAE,OAAO,CAAC,CAAC;AAEpE;;GAEG;AAKH,oBAAY,QAAQ;IAClB,IAAI,IAAI;IACR,KAAK,IAAI;IACT,OAAO,IAAI;IACX,IAAI,IAAI;IACR,KAAK,IAAI;IACT,KAAK,IAAI;IACT,KAAK,IAAI;IAET,IAAI,KAAK;CACV;AAGD;;GAEG;AACH,eAAO,MAAM,wBAAwB,QAAoB,CAAC;AAE1D;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAelE;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,SAAS,EAAE,MAAM,WAExC;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAUzD;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEzD"}
@@ -139,4 +139,4 @@ export function calculateStringSize(value) {
139
139
  export function calculateNumberSize(value) {
140
140
  return value.toString().length;
141
141
  }
142
- //# sourceMappingURL=misc.mjs.map
142
+ //# sourceMappingURL=misc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"misc.js","sourceRoot":"","sources":["../src/misc.ts"],"names":[],"mappings":"AAAA,EAAE;AACF,QAAQ;AACR,EAAE;AA6CF,EAAE;AACF,cAAc;AACd,EAAE;AAEF;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAC7B,KAAgB;IAEhB,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;AAClD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAC9C,OAAO,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,CAAC;AAC/C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,CAAC,K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AC;IAChD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,OAAO,CAAC,SAAiB;IACvC,OAAO,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC;AACxC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAa;IAC/C,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE;QACvD,IAAI,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;YACvB,OAAO,KAAK,GAAG,CAAC,CAAC;QACnB,CAAC;QACD,OAAO,KAAK,GAAG,CAAC,CAAC;IACnB,CAAC,EAAE,CAAC,CAAC,CAAC;IAEN,oDAAoD;IACpD,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,wBAAwB,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;AACrE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAa;IAC/C,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC;AACjC,CAAC","sourcesContent":["//\n// Types\n//\n\n/**\n * Makes every specified property of the specified object type mutable.\n *\n * @template ObjectValue - The object whose readonly properties to make mutable.\n * @template TargetKey - The property key(s) to make mutable.\n */\nexport type Mutable<\n ObjectValue extends Record<string, unknown>,\n TargetKey extends keyof ObjectValue,\n> = {\n -readonly [Key in keyof Pick<ObjectValue, TargetKey>]: ObjectValue[Key];\n} & {\n [Key in keyof Omit<ObjectValue, TargetKey>]: ObjectValue[Key];\n};\n\n/**\n * Get a type representing the public interface of the given type. The\n * returned type will have all public properties, but will omit private\n * properties.\n *\n * @template Interface - The interface to return a public representation of.\n */\nexport type PublicInterface<Interface> = Pick<Interface, keyof Interface>;\n\n/**\n * Useful for representing some value that _might_ be present and / or complete.\n *\n * @template Value - The value that might be present or complete.\n */\nexport type PartialOrAbsent<Value> = Partial<Value> | null | undefined;\n\n/**\n * Like {@link Array}, but always non-empty.\n *\n * @template Element - The non-empty array member type.\n */\nexport type NonEmptyArray<Element> = [Element, ...Element[]];\n\n/**\n * A JavaScript object that is not `null`, a function, or an array.\n */\nexport type RuntimeObject = Record<PropertyKey, unknown>;\n\n//\n// Type Guards\n//\n\n/**\n * A {@link NonEmptyArray} type guard.\n *\n * @template Element - The non-empty array member type.\n * @param value - The value to check.\n * @returns Whether the value is a non-empty array.\n */\nexport function isNonEmptyArray<Element>(\n value: Element[],\n): value is NonEmptyArray<Element> {\n return Array.isArray(value) && value.length > 0;\n}\n\n/**\n * Type guard for \"nullishness\".\n *\n * @param value - Any value.\n * @returns `true` if the value is null or undefined, `false` otherwise.\n */\nexport function isNullOrUndefined(value: unknown): value is null | undefined {\n return value === null || value === undefined;\n}\n\n/**\n * A type guard for {@link RuntimeObject}.\n *\n * @param value - The value to check.\n * @returns Whether the specified value has a runtime type of `object` and is\n * neither `null` nor an `Array`.\n */\nexport function isObject(value: unknown): value is RuntimeObject {\n return Boolean(value) && typeof value === 'object' && !Array.isArray(value);\n}\n\n//\n// Other utility functions\n//\n\n/**\n * A type guard for ensuring an object has a property.\n *\n * @param objectToCheck - The object to check.\n * @param name - The property name to check for.\n * @returns Whether the specified object has an own property with the specified\n * name, regardless of whether it is enumerable or not.\n */\nexport const hasProperty = <\n // eslint-disable-next-line @typescript-eslint/no-wrapper-object-types -- `Object` is deliberate: it accepts boxed primitives, so callers can pass a string or number. Narrowing to `object` would be a breaking change.\n ObjectToCheck extends Object,\n Property extends PropertyKey,\n>(\n objectToCheck: ObjectToCheck,\n name: Property,\n): objectToCheck is ObjectToCheck &\n Record<\n Property,\n Property extends keyof ObjectToCheck ? ObjectToCheck[Property] : unknown\n > => Object.hasOwnProperty.call(objectToCheck, name);\n\n/**\n * `Object.getOwnPropertyNames()` is intentionally generic: it returns the\n * immediate property names of an object, but it cannot make guarantees about\n * the contents of that object, so the type of the property names is merely\n * `string[]`. While this is technically accurate, it is also unnecessary if we\n * have an object with a type that we own (such as an enum).\n *\n * @param object - The plain object.\n * @returns The own property names of the object which are assigned a type\n * derived from the object itself.\n */\nexport function getKnownPropertyNames<Key extends PropertyKey>(\n object: Partial<Record<Key, any>>,\n): Key[] {\n return Object.getOwnPropertyNames(object) as Key[];\n}\n\nexport type PlainObject = Record<number | string | symbol, unknown>;\n\n/**\n * Predefined sizes (in Bytes) of specific parts of JSON structure.\n */\n/* eslint-disable @typescript-eslint/no-duplicate-enum-values --\n These are byte sizes, so collisions are meaningful rather than mistakes:\n a comma, a brace, a quote and a colon are all one byte, and `null` and\n `true` are both four characters. */\nexport enum JsonSize {\n Null = 4,\n Comma = 1,\n Wrapper = 1,\n True = 4,\n False = 5,\n Quote = 1,\n Colon = 1,\n // eslint-disable-next-line @typescript-eslint/no-shadow\n Date = 24,\n}\n/* eslint-enable @typescript-eslint/no-duplicate-enum-values */\n\n/**\n * Regular expression with pattern matching for (special) escaped characters.\n */\nexport const ESCAPE_CHARACTERS_REGEXP = /\"|\\\\|\\n|\\r|\\t/gu;\n\n/**\n * Check if the value is plain object.\n *\n * @param value - Value to be checked.\n * @returns True if an object is the plain JavaScript object,\n * false if the object is not plain (e.g. function).\n */\nexport function isPlainObject(value: unknown): value is PlainObject {\n if (typeof value !== 'object' || value === null) {\n return false;\n }\n\n try {\n let proto = value;\n while (Object.getPrototypeOf(proto) !== null) {\n proto = Object.getPrototypeOf(proto);\n }\n\n return Object.getPrototypeOf(value) === proto;\n } catch {\n return false;\n }\n}\n\n/**\n * Check if character is ASCII.\n *\n * @param character - Character.\n * @returns True if a character code is ASCII, false if not.\n */\nexport function isASCII(character: string) {\n return character.charCodeAt(0) <= 127;\n}\n\n/**\n * Calculate string size.\n *\n * @param value - String value to calculate size.\n * @returns Number of bytes used to store whole string value.\n */\nexport function calculateStringSize(value: string): number {\n const size = value.split('').reduce((total, character) => {\n if (isASCII(character)) {\n return total + 1;\n }\n return total + 2;\n }, 0);\n\n // Also detect characters that need backslash escape\n return size + (value.match(ESCAPE_CHARACTERS_REGEXP) ?? []).length;\n}\n\n/**\n * Calculate size of a number ofter JSON serialization.\n *\n * @param value - Number value to calculate size.\n * @returns Number of bytes used to store whole number in JSON.\n */\nexport function calculateNumberSize(value: number): number {\n return value.toString().length;\n}\n"]}
@@ -11,4 +11,4 @@ export declare function uint8ArrayToMnemonic(uint8Array: Uint8Array): string;
11
11
  * @returns The Unicode code points for the seed phrase formed from the words in the wordlist.
12
12
  */
13
13
  export declare function convertMnemonicToWordlistIndices(mnemonic: string): Uint8Array;
14
- //# sourceMappingURL=mnemonic.d.cts.map
14
+ //# sourceMappingURL=mnemonic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mnemonic.d.ts","sourceRoot":"","sources":["../src/mnemonic.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,CAYnE;AAED;;;;;GAKG;AACH,wBAAgB,gCAAgC,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,CAG7E"}
@@ -1,4 +1,4 @@
1
- import * as englishWordlist from "@metamask/scure-bip39/dist/wordlists/english.js";
1
+ import * as englishWordlist from '@metamask/scure-bip39/dist/wordlists/english.js';
2
2
  const { wordlist } = englishWordlist;
3
3
  /**
4
4
  * Transform a typed array containing mnemonic data to the seed phrase.
@@ -22,4 +22,4 @@ export function convertMnemonicToWordlistIndices(mnemonic) {
22
22
  const indices = mnemonic.split(' ').map((word) => wordlist.indexOf(word));
23
23
  return new Uint8Array(new Uint16Array(indices).buffer);
24
24
  }
25
- //# sourceMappingURL=mnemonic.mjs.map
25
+ //# sourceMappingURL=mnemonic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mnemonic.js","sourceRoot":"","sources":["../src/mnemonic.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,eAAe,MAAM,iDAAiD,CAAC;AAEnF,MAAM,EAAE,QAAQ,EAAE,GAAG,eAAe,CAAC;AAErC;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,UAAsB;IACzD,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CACb,2DAA2D,CAC5D,CAAC;IACJ,CAAC;IAED,MAAM,gBAAgB,GAAG,KAAK,CAAC,IAAI,CACjC,IAAI,WAAW,CAAC,IAAI,UAAU,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CACnD,CAAC;IAEF,OAAO,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC5D,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gCAAgC,CAAC,QAAgB;IAC/D,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1E,OAAO,IAAI,UAAU,CAAC,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;AACzD,CAAC","sourcesContent":["import * as englishWordlist from '@metamask/scure-bip39/dist/wordlists/english.js';\n\nconst { wordlist } = englishWordlist;\n\n/**\n * Transform a typed array containing mnemonic data to the seed phrase.\n * @param uint8Array - Typed array containing mnemonic data.\n * @returns The seed phrase.\n */\nexport function uint8ArrayToMnemonic(uint8Array: Uint8Array): string {\n if (uint8Array.length === 0) {\n throw new Error(\n 'The method uint8ArrayToMnemonic expects a non-empty array',\n );\n }\n\n const recoveredIndices = Array.from(\n new Uint16Array(new Uint8Array(uint8Array).buffer),\n );\n\n return recoveredIndices.map((i) => wordlist[i]).join(' ');\n}\n\n/**\n * Encodes a BIP-39 mnemonic as the indices of words in the English BIP-39 wordlist.\n *\n * @param mnemonic - The BIP-39 mnemonic.\n * @returns The Unicode code points for the seed phrase formed from the words in the wordlist.\n */\nexport function convertMnemonicToWordlistIndices(mnemonic: string): Uint8Array {\n const indices = mnemonic.split(' ').map((word) => wordlist.indexOf(word));\n return new Uint8Array(new Uint16Array(indices).buffer);\n}\n"]}
package/dist/node.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from './index.js';
2
+ export * from './fs.js';
3
+ //# sourceMappingURL=node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC"}
package/dist/node.js ADDED
@@ -0,0 +1,3 @@
1
+ export * from './index.js';
2
+ export * from './fs.js';
3
+ //# sourceMappingURL=node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.js","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC","sourcesContent":["export * from './index.js';\nexport * from './fs.js';\n"]}
@@ -1,4 +1,4 @@
1
- import type { Hex } from "./hex.mjs";
1
+ import type { Hex } from './hex.js';
2
2
  /**
3
3
  * Convert a number to a hexadecimal string. This verifies that the number is a
4
4
  * non-negative safe integer.
@@ -71,4 +71,4 @@ export declare const hexToNumber: (value: string) => number;
71
71
  * @throws If the value is not a valid hexadecimal string.
72
72
  */
73
73
  export declare const hexToBigInt: (value: string) => bigint;
74
- //# sourceMappingURL=number.d.mts.map
74
+ //# sourceMappingURL=number.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"number.d.ts","sourceRoot":"","sources":["../src/number.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAGpC;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,WAAW,UAAW,MAAM,KAAG,GAS3C,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,WAAW,UAAW,MAAM,KAAG,GAK3C,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,WAAW,UAAW,MAAM,KAAG,MAa3C,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,WAAW,UAAW,MAAM,KAAG,MAK3C,CAAC"}
@@ -1,5 +1,5 @@
1
- import { assert } from "./assert.mjs";
2
- import { add0x, assertIsHexString } from "./hex.mjs";
1
+ import { assert } from './assert.js';
2
+ import { add0x, assertIsHexString } from './hex.js';
3
3
  /**
4
4
  * Convert a number to a hexadecimal string. This verifies that the number is a
5
5
  * non-negative safe integer.
@@ -92,4 +92,4 @@ export const hexToBigInt = (value) => {
92
92
  // The `BigInt` constructor requires the "0x"-prefix to parse a hex string.
93
93
  return BigInt(add0x(value));
94
94
  };
95
- //# sourceMappingURL=number.mjs.map
95
+ //# sourceMappingURL=number.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"number.js","sourceRoot":"","sources":["../src/number.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAEpD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAa,EAAO,EAAE;IAChD,MAAM,CAAC,OAAO,KAAK,KAAK,QAAQ,EAAE,yBAAyB,CAAC,CAAC;IAC7D,MAAM,CAAC,KAAK,IAAI,CAAC,EAAE,sCAAsC,CAAC,CAAC;IAC3D,MAAM,CACJ,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,EAC3B,yDAAyD,CAC1D,CAAC;IAEF,OAAO,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;AACnC,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAa,EAAO,EAAE;IAChD,MAAM,CAAC,OAAO,KAAK,KAAK,QAAQ,EAAE,yBAAyB,CAAC,CAAC;IAC7D,MAAM,CAAC,KAAK,IAAI,CAAC,EAAE,sCAAsC,CAAC,CAAC;IAE3D,OAAO,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;AACnC,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAa,EAAU,EAAE;IACnD,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAEzB,2EAA2E;IAC3E,kEAAkE;IAClE,MAAM,WAAW,GAAG,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAExC,MAAM,CACJ,MAAM,CAAC,aAAa,CAAC,WAAW,CAAC,EACjC,yDAAyD,CAC1D,CAAC;IAEF,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAa,EAAU,EAAE;IACnD,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAEzB,2EAA2E;IAC3E,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;AAC9B,CAAC,CAAC","sourcesContent":["import { assert } from './assert.js';\nimport type { Hex } from './hex.js';\nimport { add0x, assertIsHexString } from './hex.js';\n\n/**\n * Convert a number to a hexadecimal string. This verifies that the number is a\n * non-negative safe integer.\n *\n * To convert a `bigint` to a hexadecimal string instead, use\n * {@link bigIntToHex}.\n *\n * @example\n * ```typescript\n * numberToHex(0); // '0x0'\n * numberToHex(1); // '0x1'\n * numberToHex(16); // '0x10'\n * ```\n * @param value - The number to convert to a hexadecimal string.\n * @returns The hexadecimal string, with the \"0x\"-prefix.\n * @throws If the number is not a non-negative safe integer.\n */\nexport const numberToHex = (value: number): Hex => {\n assert(typeof value === 'number', 'Value must be a number.');\n assert(value >= 0, 'Value must be a non-negative number.');\n assert(\n Number.isSafeInteger(value),\n 'Value is not a safe integer. Use `bigIntToHex` instead.',\n );\n\n return add0x(value.toString(16));\n};\n\n/**\n * Convert a `bigint` to a hexadecimal string. This verifies that the `bigint`\n * is a non-negative integer.\n *\n * To convert a number to a hexadecimal string instead, use {@link numberToHex}.\n *\n * @example\n * ```typescript\n * bigIntToHex(0n); // '0x0'\n * bigIntToHex(1n); // '0x1'\n * bigIntToHex(16n); // '0x10'\n * ```\n * @param value - The `bigint` to convert to a hexadecimal string.\n * @returns The hexadecimal string, with the \"0x\"-prefix.\n * @throws If the `bigint` is not a non-negative integer.\n */\nexport const bigIntToHex = (value: bigint): Hex => {\n assert(typeof value === 'bigint', 'Value must be a bigint.');\n assert(value >= 0, 'Value must be a non-negative bigint.');\n\n return add0x(value.toString(16));\n};\n\n/**\n * Convert a hexadecimal string to a number. This verifies that the string is a\n * valid hex string, and that the resulting number is a safe integer. Both\n * \"0x\"-prefixed and unprefixed strings are supported.\n *\n * To convert a hexadecimal string to a `bigint` instead, use\n * {@link hexToBigInt}.\n *\n * @example\n * ```typescript\n * hexToNumber('0x0'); // 0\n * hexToNumber('0x1'); // 1\n * hexToNumber('0x10'); // 16\n * ```\n * @param value - The hexadecimal string to convert to a number.\n * @returns The number.\n * @throws If the value is not a valid hexadecimal string, or if the resulting\n * number is not a safe integer.\n */\nexport const hexToNumber = (value: string): number => {\n assertIsHexString(value);\n\n // `parseInt` accepts values without the \"0x\"-prefix, whereas `Number` does\n // not. Using this is slightly faster than `Number(add0x(value))`.\n const numberValue = parseInt(value, 16);\n\n assert(\n Number.isSafeInteger(numberValue),\n 'Value is not a safe integer. Use `hexToBigInt` instead.',\n );\n\n return numberValue;\n};\n\n/**\n * Convert a hexadecimal string to a `bigint`. This verifies that the string is\n * a valid hex string. Both \"0x\"-prefixed and unprefixed strings are supported.\n *\n * To convert a hexadecimal string to a number instead, use {@link hexToNumber}.\n *\n * @example\n * ```typescript\n * hexToBigInt('0x0'); // 0n\n * hexToBigInt('0x1'); // 1n\n * hexToBigInt('0x10'); // 16n\n * ```\n * @param value - The hexadecimal string to convert to a `bigint`.\n * @returns The `bigint`.\n * @throws If the value is not a valid hexadecimal string.\n */\nexport const hexToBigInt = (value: string): bigint => {\n assertIsHexString(value);\n\n // The `BigInt` constructor requires the \"0x\"-prefix to parse a hex string.\n return BigInt(add0x(value));\n};\n"]}
@@ -3,4 +3,4 @@ export type Opaque<Base, Brand extends symbol> = Base & {
3
3
  [brand]: Brand;
4
4
  };
5
5
  export {};
6
- //# sourceMappingURL=opaque.d.cts.map
6
+ //# sourceMappingURL=opaque.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opaque.d.ts","sourceRoot":"","sources":["../src/opaque.ts"],"names":[],"mappings":"AAEA,OAAO,CAAC,MAAM,KAAK,EAAE,OAAO,MAAM,CAAC;AACnC,MAAM,MAAM,MAAM,CAAC,IAAI,EAAE,KAAK,SAAS,MAAM,IAAI,IAAI,GAAG;IAAE,CAAC,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC"}
package/dist/opaque.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=opaque.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opaque.js","sourceRoot":"","sources":["../src/opaque.ts"],"names":[],"mappings":"","sourcesContent":["// We use a symbol property name instead of { _type: Brand }, because that would show up in IDE suggestions,\n// while internal symbols do not.\ndeclare const brand: unique symbol;\nexport type Opaque<Base, Brand extends symbol> = Base & { [brand]: Brand };\n"]}
@@ -42,4 +42,4 @@ export type DeferredPromise<Result = void> = {
42
42
  export declare function createDeferredPromise<Result = void>({ suppressUnhandledRejection, }?: {
43
43
  suppressUnhandledRejection?: boolean;
44
44
  }): DeferredPromise<Result>;
45
- //# sourceMappingURL=promise.d.cts.map
45
+ //# sourceMappingURL=promise.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promise.d.ts","sourceRoot":"","sources":["../src/promise.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,MAAM,eAAe,CAAC,MAAM,GAAG,IAAI,IAAI;IAC3C;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACzB;;OAEG;IACH,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC;;OAEG;IACH,MAAM,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CAClC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,GAAG,IAAI,EAAE,EACnD,0BAAkC,GACnC,GAAE;IACD,0BAA0B,CAAC,EAAE,OAAO,CAAC;CACjC,GAAG,eAAe,CAAC,MAAM,CAAC,CAyB/B"}
@@ -37,4 +37,4 @@ export function createDeferredPromise({ suppressUnhandledRejection = false, } =
37
37
  // @ts-expect-error We know that these are assigned, but TypeScript doesn't
38
38
  return { promise, resolve, reject };
39
39
  }
40
- //# sourceMappingURL=promise.mjs.map
40
+ //# sourceMappingURL=promise.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promise.js","sourceRoot":"","sources":["../src/promise.ts"],"names":[],"mappings":"AAsBA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,qBAAqB,CAAgB,EACnD,0BAA0B,GAAG,KAAK,GACnC,GAEG,EAAE;IACJ,IAAI,OAA2C,CAAC;IAChD,IAAI,MAAyC,CAAC;IAC9C;;qBAEiB;IACjB,MAAM,OAAO,GAAG,IAAI,OAAO,CACzB,CACE,YAAgD,EAChD,WAA8C,EAC9C,EAAE;QACF,OAAO,GAAG,YAAY,CAAC;QACvB,MAAM,GAAG,WAAW,CAAC;IACvB,CAAC,CACF,CAAC;IACF,uCAAuC;IAEvC,IAAI,0BAA0B,EAAE,CAAC;QAC/B,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE;YACvB,uEAAuE;QACzE,CAAC,CAAC,CAAC;IACL,CAAC;IAED,2EAA2E;IAC3E,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AACtC,CAAC","sourcesContent":["/**\n * A deferred Promise.\n *\n * A deferred Promise is one that can be resolved or rejected independently of\n * the Promise construction.\n * @template Result - The result type of the Promise.\n */\nexport type DeferredPromise<Result = void> = {\n /**\n * The Promise that has been deferred.\n */\n promise: Promise<Result>;\n /**\n * A function that resolves the Promise.\n */\n resolve: (result: Result) => void;\n /**\n * A function that rejects the Promise.\n */\n reject: (error: unknown) => void;\n};\n\n/**\n * Create a defered Promise.\n *\n * If the Promise is rejected prior to a handler being added, this can result in an\n * `UnhandledPromiseRejection` error. Optionally this can be suppressed with the\n * `suppressUnhandledRejection` flag, as it's common to belatedly handle deferred Promises, or to\n * ignore them if they're no longer relevant (e.g. related to a cancelled request).\n *\n * However, be very careful that you have handled the Promise if you do this. Suppressing these\n * errors is dangerous, they exist for good reason. An unhandled rejection can hide errors, making\n * debugging extremely difficult. They should only be suppressed if you're confident that the\n * Promise is always handled correctly, in both the success and failure cases.\n *\n * @param args - The arguments.\n * @param args.suppressUnhandledRejection - This option adds an empty error handler\n * to the Promise to suppress the UnhandledPromiseRejection error. This can be\n * useful if the deferred Promise is sometimes intentionally not used.\n * @returns A deferred Promise.\n * @template Result - The result type of the Promise.\n */\nexport function createDeferredPromise<Result = void>({\n suppressUnhandledRejection = false,\n}: {\n suppressUnhandledRejection?: boolean;\n} = {}): DeferredPromise<Result> {\n let resolve: DeferredPromise<Result>['resolve'];\n let reject: DeferredPromise<Result>['reject'];\n /* eslint-disable promise/param-names -- Deliberately not named\n 'resolve'/'reject' so they do not shadow the outer bindings assigned\n just below. */\n const promise = new Promise<Result>(\n (\n innerResolve: DeferredPromise<Result>['resolve'],\n innerReject: DeferredPromise<Result>['reject'],\n ) => {\n resolve = innerResolve;\n reject = innerReject;\n },\n );\n /* eslint-enable promise/param-names */\n\n if (suppressUnhandledRejection) {\n promise.catch((_error) => {\n // This handler is used to suppress the UnhandledPromiseRejection error\n });\n }\n\n // @ts-expect-error We know that these are assigned, but TypeScript doesn't\n return { promise, resolve, reject };\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { Struct } from "@metamask/superstruct";
1
+ import type { Struct } from '@metamask/superstruct';
2
2
  /**
3
3
  * Defines a new string-struct matching a regular expression.
4
4
  *
@@ -17,4 +17,4 @@ import type { Struct } from "@metamask/superstruct";
17
17
  * @returns A new string-struct that matches the given pattern.
18
18
  */
19
19
  export declare function definePattern<Pattern extends string = string>(name: string, pattern: RegExp): Struct<Pattern, null>;
20
- //# sourceMappingURL=superstruct.d.mts.map
20
+ //# sourceMappingURL=superstruct.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"superstruct.d.ts","sourceRoot":"","sources":["../src/superstruct.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAGpD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,aAAa,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,EAC3D,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GACd,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAIvB"}
@@ -1,4 +1,4 @@
1
- import { define } from "@metamask/superstruct";
1
+ import { define } from '@metamask/superstruct';
2
2
  /**
3
3
  * Defines a new string-struct matching a regular expression.
4
4
  *
@@ -21,4 +21,4 @@ export function definePattern(name, pattern) {
21
21
  return typeof value === 'string' && pattern.test(value);
22
22
  });
23
23
  }
24
- //# sourceMappingURL=superstruct.mjs.map
24
+ //# sourceMappingURL=superstruct.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"superstruct.js","sourceRoot":"","sources":["../src/superstruct.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,aAAa,CAC3B,IAAY,EACZ,OAAe;IAEf,OAAO,MAAM,CAAU,IAAI,EAAE,CAAC,KAAc,EAAoB,EAAE;QAChE,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Struct } from '@metamask/superstruct';\nimport { define } from '@metamask/superstruct';\n\n/**\n * Defines a new string-struct matching a regular expression.\n *\n * @example\n * const EthAddressStruct = definePattern('EthAddress', /^0x[0-9a-f]{40}$/iu);\n * type EthAddress = Infer<typeof EthAddressStruct>; // string\n *\n * const CaipChainIdStruct = defineTypedPattern<`${string}:${string}`>(\n * 'CaipChainId',\n * /^[-a-z0-9]{3,8}:[-_a-zA-Z0-9]{1,32}$/u;\n * );\n * type CaipChainId = Infer<typeof CaipChainIdStruct>; // `${string}:${string}`\n * @param name - Type name.\n * @param pattern - Regular expression to match.\n * @template Pattern - The pattern type, defaults to `string`.\n * @returns A new string-struct that matches the given pattern.\n */\nexport function definePattern<Pattern extends string = string>(\n name: string,\n pattern: RegExp,\n): Struct<Pattern, null> {\n return define<Pattern>(name, (value: unknown): boolean | string => {\n return typeof value === 'string' && pattern.test(value);\n });\n}\n"]}
@@ -46,4 +46,4 @@ export declare function inMilliseconds(count: number, duration: Duration): numbe
46
46
  * @returns The number of milliseconds elapsed since the specified timestamp.
47
47
  */
48
48
  export declare function timeSince(timestamp: number): number;
49
- //# sourceMappingURL=time.d.mts.map
49
+ //# sourceMappingURL=time.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,QAAQ;IAClB;;OAEG;IACH,WAAW,IAAI;IAEf;;OAEG;IACH,MAAM,OAAO,CAAE,qBAAqB;IAEpC;;OAEG;IACH,MAAM,QAAS,CAAE,cAAc;IAE/B;;OAEG;IACH,IAAI,UAAY,CAAE,cAAc;IAEhC;;OAEG;IACH,GAAG,WAAa,CAAE,YAAY;IAE9B;;OAEG;IACH,IAAI,YAAc,CAAE,UAAU;IAE9B;;OAEG;IACH,IAAI,cAAiB;CACtB;AAaD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAGxE;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAGnD"}
@@ -59,4 +59,4 @@ export function timeSince(timestamp) {
59
59
  assertIsNonNegativeInteger(timestamp, 'timestamp');
60
60
  return Date.now() - timestamp;
61
61
  }
62
- //# sourceMappingURL=time.mjs.map
62
+ //# sourceMappingURL=time.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"time.js","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAN,IAAY,QAmCX;AAnCD,WAAY,QAAQ;IAClB;;OAEG;IACH,qDAAe,CAAA;IAEf;;OAEG;IACH,8CAAa,CAAA;IAEb;;OAEG;IACH,+CAAe,CAAA;IAEf;;OAEG;IACH,6CAAgB,CAAA;IAEhB;;OAEG;IACH,4CAAgB,CAAA;IAEhB;;OAEG;IACH,+CAAkB,CAAA;IAElB;;OAEG;IACH,iDAAqB,CAAA;AACvB,CAAC,EAnCW,QAAQ,KAAR,QAAQ,QAmCnB;AAED,MAAM,oBAAoB,GAAG,CAAC,MAAc,EAAE,EAAE,CAC9C,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,MAAM,IAAI,CAAC,CAAC;AAE1C,MAAM,0BAA0B,GAAG,CAAC,MAAc,EAAE,IAAY,EAAE,EAAE;IAClE,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CACb,IAAI,IAAI,gDAAgD,MAAM,IAAI,CACnE,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,KAAa,EAAE,QAAkB;IAC9D,0BAA0B,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC3C,OAAO,KAAK,GAAG,QAAQ,CAAC;AAC1B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,SAAiB;IACzC,0BAA0B,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;IACnD,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;AAChC,CAAC","sourcesContent":["/**\n * Common duration constants, in milliseconds.\n */\nexport enum Duration {\n /**\n * A millisecond.\n */\n Millisecond = 1,\n\n /**\n * A second, in milliseconds.\n */\n Second = 1000, // Millisecond * 1000\n\n /**\n * A minute, in milliseconds.\n */\n Minute = 60_000, // Second * 60\n\n /**\n * An hour, in milliseconds.\n */\n Hour = 3_600_000, // Minute * 60\n\n /**\n * A day, in milliseconds.\n */\n Day = 86_400_000, // Hour * 24\n\n /**\n * A week, in milliseconds.\n */\n Week = 604_800_000, // Day * 7\n\n /**\n * A year, in milliseconds.\n */\n Year = 31_536_000_000, // Day * 365\n}\n\nconst isNonNegativeInteger = (number: number) =>\n Number.isInteger(number) && number >= 0;\n\nconst assertIsNonNegativeInteger = (number: number, name: string) => {\n if (!isNonNegativeInteger(number)) {\n throw new Error(\n `\"${name}\" must be a non-negative integer. Received: \"${number}\".`,\n );\n }\n};\n\n/**\n * Calculates the millisecond value of the specified number of units of time.\n *\n * @param count - The number of units of time.\n * @param duration - The unit of time to count.\n * @returns The count multiplied by the specified duration.\n */\nexport function inMilliseconds(count: number, duration: Duration): number {\n assertIsNonNegativeInteger(count, 'count');\n return count * duration;\n}\n\n/**\n * Gets the milliseconds since a particular Unix epoch timestamp.\n *\n * @param timestamp - A Unix millisecond timestamp.\n * @returns The number of milliseconds elapsed since the specified timestamp.\n */\nexport function timeSince(timestamp: number): number {\n assertIsNonNegativeInteger(timestamp, 'timestamp');\n return Date.now() - timestamp;\n}\n"]}
@@ -1,5 +1,5 @@
1
- import type { Bytes } from "./bytes.cjs";
2
- import type { Hex } from "./hex.cjs";
1
+ import type { Bytes } from './bytes.js';
2
+ import type { Hex } from './hex.js';
3
3
  export type Transaction = LegacyTransaction | EIP2930Transaction | EIP1559Transaction;
4
4
  export type SignedTransaction = Transaction & Signature;
5
5
  export type Signature = {
@@ -114,4 +114,4 @@ export type EIP1559Transaction = TypedTransaction & {
114
114
  */
115
115
  maxFeePerGas: Bytes;
116
116
  };
117
- //# sourceMappingURL=transaction-types.d.cts.map
117
+ //# sourceMappingURL=transaction-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction-types.d.ts","sourceRoot":"","sources":["../src/transaction-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAEpC,MAAM,MAAM,WAAW,GACnB,iBAAiB,GACjB,kBAAkB,GAClB,kBAAkB,CAAC;AAEvB,MAAM,MAAM,iBAAiB,GAAG,WAAW,GAAG,SAAS,CAAC;AAExD,MAAM,MAAM,SAAS,GAAG;IACtB;;;OAGG;IACH,CAAC,EAAE,KAAK,CAAC;IAET;;;;OAIG;IACH,CAAC,EAAE,KAAK,CAAC;IAET;;;OAGG;IACH,OAAO,EAAE,KAAK,CAAC;CAChB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B;;;OAGG;IACH,KAAK,EAAE,KAAK,CAAC;IAEb;;OAEG;IACH,IAAI,EAAE,GAAG,GAAG,UAAU,CAAC;IAEvB;;;;OAIG;IACH,EAAE,EAAE,GAAG,GAAG,UAAU,CAAC;IAErB;;OAEG;IACH,KAAK,EAAE,KAAK,CAAC;IAEb;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC;IAEhB;;OAEG;IACH,IAAI,CAAC,EAAE,KAAK,CAAC;CACd,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,eAAe,GAAG;IAC/C;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,eAAe,GAAG;IAChD;;OAEG;IACH,QAAQ,EAAE,KAAK,GAAG,IAAI,CAAC;CACxB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG,gBAAgB,GAAG;IAClD;;OAEG;IACH,IAAI,EAAE,CAAC,CAAC;IAER;;OAEG;IACH,OAAO,EAAE,KAAK,CAAC;IAEf;;OAEG;IACH,UAAU,EACN;QAAE,OAAO,EAAE,GAAG,CAAC;QAAC,WAAW,EAAE,GAAG,EAAE,CAAA;KAAE,EAAE,GACtC;QAAE,OAAO,EAAE,UAAU,CAAC;QAAC,WAAW,EAAE,UAAU,EAAE,CAAA;KAAE,EAAE,CAAC;CAC1D,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,gBAAgB,GAAG;IAClD;;OAEG;IACH,IAAI,EAAE,CAAC,CAAC;IAER;;OAEG;IACH,oBAAoB,EAAE,KAAK,CAAC;IAE5B;;OAEG;IACH,YAAY,EAAE,KAAK,CAAC;CACrB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=transaction-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction-types.js","sourceRoot":"","sources":["../src/transaction-types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Bytes } from './bytes.js';\nimport type { Hex } from './hex.js';\n\nexport type Transaction =\n | LegacyTransaction\n | EIP2930Transaction\n | EIP1559Transaction;\n\nexport type SignedTransaction = Transaction & Signature;\n\nexport type Signature = {\n /**\n * EC signature parameter\n * 32 bytes long sequence.\n */\n r: Bytes;\n\n /**\n * EC signature parameter\n * Signature proof.\n * 32 bytes long sequence\n */\n s: Bytes;\n\n /**\n * Recovery identifier. It can be either 0x1b or 0x1c\n * 1 byte long sequence\n */\n yParity: Bytes;\n};\n\n/**\n * Base Ethereum Transaction\n */\nexport type BaseTransaction = {\n /**\n * Sequentially incrementing counter which indicates the transaction\n * number from the account\n */\n nonce: Bytes;\n\n /**\n * The address of the sender, that will be signing the transaction\n */\n from: Hex | Uint8Array;\n\n /**\n * The receiving address.\n * If an externally-owned account, the transaction will transfer value.\n * If a contract account, the transaction will execute the contract code.\n */\n to: Hex | Uint8Array;\n\n /**\n * The amount of Ether sent.\n */\n value: Bytes;\n\n /**\n * Maximum amount of gas units that this transaction can consume.\n */\n gasLimit: Bytes;\n\n /**\n * Arbitrary data.\n */\n data?: Bytes;\n};\n\n/**\n * Typed Ethereum Transaction\n */\nexport type TypedTransaction = BaseTransaction & {\n /**\n * Transaction type.\n */\n type: number;\n};\n\n/**\n * Ethereum Legacy Transaction\n * Reference: https://ethereum.org/en/developers/docs/transactions/\n */\nexport type LegacyTransaction = BaseTransaction & {\n /**\n * Transaction's gas price.\n */\n gasPrice: Bytes | null;\n};\n\n/**\n * EIP-2930 Transaction: Optional Access Lists\n * Reference: https://eips.ethereum.org/EIPS/eip-2930\n */\nexport type EIP2930Transaction = TypedTransaction & {\n /**\n * Transaction type.\n */\n type: 1;\n\n /**\n * Transaction chain ID\n */\n chainId: Bytes;\n\n /**\n * List of addresses and storage keys that the transaction plans to access\n */\n accessList:\n | { address: Hex; storageKeys: Hex[] }[]\n | { address: Uint8Array; storageKeys: Uint8Array[] }[];\n};\n\n/**\n * EIP-1559 Transaction: Fee market change for ETH 1.0 chain (Type-2)\n *\n * Reference: https://eips.ethereum.org/EIPS/eip-1559\n */\nexport type EIP1559Transaction = TypedTransaction & {\n /**\n * Transaction type.\n */\n type: 2;\n\n /**\n * Maximum fee to give to the miner\n */\n maxPriorityFeePerGas: Bytes;\n\n /**\n * Maximum total fee\n */\n maxFeePerGas: Bytes;\n};\n"]}
@@ -7,33 +7,33 @@
7
7
  */
8
8
  export declare function numericToBigInt(arg: string | number | bigint): bigint;
9
9
  export declare const unitMap: {
10
- readonly noether: "0";
11
- readonly wei: "1";
12
- readonly kwei: "1000";
13
- readonly Kwei: "1000";
14
- readonly babbage: "1000";
15
- readonly femtoether: "1000";
16
- readonly mwei: "1000000";
17
- readonly Mwei: "1000000";
18
- readonly lovelace: "1000000";
19
- readonly picoether: "1000000";
20
- readonly gwei: "1000000000";
21
- readonly Gwei: "1000000000";
22
- readonly shannon: "1000000000";
23
- readonly nanoether: "1000000000";
24
- readonly nano: "1000000000";
25
- readonly szabo: "1000000000000";
26
- readonly microether: "1000000000000";
27
- readonly micro: "1000000000000";
28
- readonly finney: "1000000000000000";
29
- readonly milliether: "1000000000000000";
30
- readonly milli: "1000000000000000";
31
- readonly ether: "1000000000000000000";
32
- readonly kether: "1000000000000000000000";
33
- readonly grand: "1000000000000000000000";
34
- readonly mether: "1000000000000000000000000";
35
- readonly gether: "1000000000000000000000000000";
36
- readonly tether: "1000000000000000000000000000000";
10
+ readonly noether: '0';
11
+ readonly wei: '1';
12
+ readonly kwei: '1000';
13
+ readonly Kwei: '1000';
14
+ readonly babbage: '1000';
15
+ readonly femtoether: '1000';
16
+ readonly mwei: '1000000';
17
+ readonly Mwei: '1000000';
18
+ readonly lovelace: '1000000';
19
+ readonly picoether: '1000000';
20
+ readonly gwei: '1000000000';
21
+ readonly Gwei: '1000000000';
22
+ readonly shannon: '1000000000';
23
+ readonly nanoether: '1000000000';
24
+ readonly nano: '1000000000';
25
+ readonly szabo: '1000000000000';
26
+ readonly microether: '1000000000000';
27
+ readonly micro: '1000000000000';
28
+ readonly finney: '1000000000000000';
29
+ readonly milliether: '1000000000000000';
30
+ readonly milli: '1000000000000000';
31
+ readonly ether: '1000000000000000000';
32
+ readonly kether: '1000000000000000000000';
33
+ readonly grand: '1000000000000000000000';
34
+ readonly mether: '1000000000000000000000000';
35
+ readonly gether: '1000000000000000000000000000';
36
+ readonly tether: '1000000000000000000000000000000';
37
37
  };
38
38
  type EthereumUnit = keyof typeof unitMap;
39
39
  /**
@@ -77,4 +77,4 @@ export declare function fromWei(weiInput: string | number | bigint, unit: Ethere
77
77
  */
78
78
  export declare function toWei(etherInput: string | number | bigint, unit: EthereumUnit): bigint;
79
79
  export {};
80
- //# sourceMappingURL=unitsConversion.d.cts.map
80
+ //# sourceMappingURL=unitsConversion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unitsConversion.d.ts","sourceRoot":"","sources":["../src/unitsConversion.ts"],"names":[],"mappings":"AAYA;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAYrE;AAGD,eAAO,MAAM,OAAO;aAClB,OAAO,EAAE,GAAG;aACZ,GAAG,EAAE,GAAG;aACR,IAAI,EAAE,MAAM;aACZ,IAAI,EAAE,MAAM;aACZ,OAAO,EAAE,MAAM;aACf,UAAU,EAAE,MAAM;aAClB,IAAI,EAAE,SAAS;aACf,IAAI,EAAE,SAAS;aACf,QAAQ,EAAE,SAAS;aACnB,SAAS,EAAE,SAAS;aACpB,IAAI,EAAE,YAAY;aAClB,IAAI,EAAE,YAAY;aAClB,OAAO,EAAE,YAAY;aACrB,SAAS,EAAE,YAAY;aACvB,IAAI,EAAE,YAAY;aAClB,KAAK,EAAE,eAAe;aACtB,UAAU,EAAE,eAAe;aAC3B,KAAK,EAAE,eAAe;aACtB,MAAM,EAAE,kBAAkB;aAC1B,UAAU,EAAE,kBAAkB;aAC9B,KAAK,EAAE,kBAAkB;aACzB,KAAK,EAAE,qBAAqB;aAC5B,MAAM,EAAE,wBAAwB;aAChC,KAAK,EAAE,wBAAwB;aAC/B,MAAM,EAAE,2BAA2B;aACnC,MAAM,EAAE,8BAA8B;aACtC,MAAM,EAAE,iCAAiC;CACjC,CAAC;AAeX,KAAK,YAAY,GAAG,MAAM,OAAO,OAAO,CAAC;AAEzC;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,SAAS,GAAE,YAAsB,GAAG,MAAM,CAexE;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,UAoB3D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,OAAO,CACrB,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAClC,IAAI,EAAE,YAAY,EAClB,YAAY,CAAC,EAAE;IAAE,GAAG,CAAC,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,UAmDpD;AAED;;;;;;;GAOG;AACH,wBAAgB,KAAK,CACnB,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EACpC,IAAI,EAAE,YAAY,GACjB,MAAM,CA8ER"}
@@ -206,4 +206,4 @@ export function toWei(etherInput, unit) {
206
206
  }
207
207
  return wei;
208
208
  }
209
- //# sourceMappingURL=unitsConversion.mjs.map
209
+ //# sourceMappingURL=unitsConversion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unitsConversion.js","sourceRoot":"","sources":["../src/unitsConversion.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC;;;;;;EAME;AAEF,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AACvB,MAAM,SAAS,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AAE7B;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,GAA6B;IAC3D,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC5B,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC;IACD,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC5B,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC;IACD,IAAI,OAAO,GAAG,KAAK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ACb,CAAC","sourcesContent":["/* eslint-disable operator-assignment */\n/*\nPrimary Attribution\nRichard Moore <ricmoo@me.com>\nhttps://github.com/ethers-io\n\nNote, Richard is a god of ether gods. Follow and respect him, and use Ethers.io!\n*/\n\nconst zero = BigInt(0);\nconst negative1 = BigInt(-1);\n\n/**\n * Converts a string, number, or bigint to a bigint.\n *\n * @param arg - The value to convert to bigint.\n * @returns The bigint representation of the input.\n * @throws Error if the input type cannot be converted to bigint.\n */\nexport function numericToBigInt(arg: string | number | bigint): bigint {\n if (typeof arg === 'string') {\n return BigInt(arg);\n }\n if (typeof arg === 'number') {\n return BigInt(arg);\n }\n if (typeof arg === 'bigint') {\n return arg;\n }\n\n throw new Error(`Cannot convert ${typeof arg} to BigInt`);\n}\n\n// complete ethereum unit map\nexport const unitMap = {\n noether: '0',\n wei: '1',\n kwei: '1000',\n Kwei: '1000',\n babbage: '1000',\n femtoether: '1000',\n mwei: '1000000',\n Mwei: '1000000',\n lovelace: '1000000',\n picoether: '1000000',\n gwei: '1000000000',\n Gwei: '1000000000',\n shannon: '1000000000',\n nanoether: '1000000000',\n nano: '1000000000',\n szabo: '1000000000000',\n microether: '1000000000000',\n micro: '1000000000000',\n finney: '1000000000000000',\n milliether: '1000000000000000',\n milli: '1000000000000000',\n ether: '1000000000000000000',\n kether: '1000000000000000000000',\n grand: '1000000000000000000000',\n mether: '1000000000000000000000000',\n gether: '1000000000000000000000000000',\n tether: '1000000000000000000000000000000',\n} as const;\n\n// Pre-computed unit values as BigInt for performance\nconst unitMapBigInt = Object.fromEntries(\n Object.entries(unitMap).map(([key, value]) => [key, BigInt(value)]),\n) as Record<EthereumUnit, bigint>;\n\nconst unitLengths = Object.fromEntries(\n Object.entries(unitMap).map(([key, value]) => [key, value.length - 1 || 1]),\n) as Record<EthereumUnit, number>;\n\nconst NUMBER_REGEX = /^-?[0-9.]+$/u;\nconst FRACTION_REGEX = /^([0-9]*[1-9]|0)(0*)/u;\nconst COMMIFY_REGEX = /\\B(?=(\\d{3})+(?!\\d))/gu;\n\ntype EthereumUnit = keyof typeof unitMap;\n\n/**\n * Returns value of unit in Wei.\n *\n * @param unitInput - The unit to convert to, default ether.\n * @returns Value of the unit (in Wei).\n * @throws Error if the unit is not correct.\n */\nexport function getValueOfUnit(unitInput: EthereumUnit = 'ether'): bigint {\n const unit = unitInput.toLowerCase() as EthereumUnit;\n const unitValue = unitMapBigInt[unit];\n\n if (unitValue === undefined) {\n throw new Error(\n `The unit provided ${unitInput} doesn't exist, please use the one of the following units ${JSON.stringify(\n unitMap,\n null,\n 2,\n )}`,\n );\n }\n\n return unitValue;\n}\n\n/**\n * Converts a number to a string.\n *\n * @param arg - The number to convert to a string.\n * @returns The string representation of the number.\n * @throws Error if the number is invalid.\n */\nexport function numberToString(arg: string | number | bigint) {\n if (typeof arg === 'string') {\n if (!NUMBER_REGEX.test(arg)) {\n throw new Error(\n `while converting number to string, invalid number value '${arg}', should be a number matching (^-?[0-9.]+).`,\n );\n }\n return arg;\n }\n if (typeof arg === 'number') {\n return String(arg);\n }\n if (typeof arg === 'bigint') {\n return arg.toString();\n }\n throw new Error(\n `while converting number to string, invalid number value '${String(\n arg,\n )}' type ${typeof arg}.`,\n );\n}\n\n/**\n * Converts a number from Wei to a string.\n *\n * @param weiInput - The number to convert from Wei.\n * @param unit - The unit to convert to, default ether.\n * @param optionsInput - The options to use for the conversion.\n * @param optionsInput.pad - Whether to pad the fractional part with zeros.\n * @param optionsInput.commify - Whether to add commas to separate thousands.\n * @returns The string representation of the number.\n * @throws Error if the number is invalid.\n */\nexport function fromWei(\n weiInput: string | number | bigint,\n unit: EthereumUnit,\n optionsInput?: { pad?: boolean; commify?: boolean },\n) {\n let wei = numericToBigInt(weiInput);\n const negative = wei < zero;\n const unitLower = unit.toLowerCase() as EthereumUnit;\n const base = unitMapBigInt[unitLower];\n const baseLength = unitLengths[unitLower];\n const options = optionsInput ?? {};\n\n if (base === undefined) {\n throw new Error(\n `The unit provided ${unit} doesn't exist, please use the one of the following units ${JSON.stringify(\n unitMap,\n null,\n 2,\n )}`,\n );\n }\n\n // Handle special case of noether (base = 0)\n if (base === zero) {\n return negative ? '-0' : '0';\n }\n\n if (negative) {\n wei = wei * negative1;\n }\n\n let fraction = (wei % base).toString();\n\n fraction = fraction.padStart(baseLength, '0');\n\n if (!options.pad) {\n const fractionMatch = fraction.match(FRACTION_REGEX);\n // istanbul ignore next: defensive fallback that's never reachable but necessary to satisfy TS\n fraction = fractionMatch?.[1] ?? '0';\n }\n\n let whole = (wei / base).toString();\n\n if (options.commify) {\n whole = whole.replace(COMMIFY_REGEX, ',');\n }\n\n let value = `${whole}${fraction === '0' ? '' : `.${fraction}`}`;\n\n if (negative) {\n value = `-${value}`;\n }\n\n return value;\n}\n\n/**\n * Converts a number to Wei.\n *\n * @param etherInput - The number to convert to Wei.\n * @param unit - The unit to convert to, default ether.\n * @returns The number in Wei.\n * @throws Error if the number is invalid.\n */\nexport function toWei(\n etherInput: string | number | bigint,\n unit: EthereumUnit,\n): bigint {\n const unitLower = unit.toLowerCase() as EthereumUnit;\n const base = unitMapBigInt[unitLower];\n const baseLength = unitLengths[unitLower];\n\n if (base === undefined) {\n throw new Error(\n `The unit provided ${unit} doesn't exist, please use the one of the following units ${JSON.stringify(\n unitMap,\n null,\n 2,\n )}`,\n );\n }\n\n // Handle special case of noether (base = 0)\n if (base === zero) {\n return zero;\n }\n\n // Fast path for bigint inputs when unit is wei (no conversion needed)\n if (typeof etherInput === 'bigint' && unitLower === 'wei') {\n return etherInput;\n }\n\n // Fast path for bigint inputs with whole units (no fractional part)\n if (typeof etherInput === 'bigint') {\n return etherInput * base;\n }\n\n let ether = numberToString(etherInput);\n\n // Is it negative?\n const negative = ether.startsWith('-');\n if (negative) {\n ether = ether.substring(1);\n }\n\n if (ether === '.') {\n throw new Error(\n `While converting number ${etherInput} to wei, invalid value`,\n );\n }\n\n // Split it into a whole and fractional part\n const comps = ether.split('.');\n if (comps.length > 2) {\n throw new Error(\n `While converting number ${etherInput} to wei, too many decimal points`,\n );\n }\n\n let whole = comps[0];\n let fraction = comps[1];\n\n if (!whole) {\n whole = '0';\n }\n if (!fraction) {\n fraction = '0';\n }\n if (fraction.length > baseLength) {\n throw new Error(\n `While converting number ${etherInput} to wei, too many decimal places`,\n );\n }\n\n fraction = fraction.padEnd(baseLength, '0');\n\n const wholeBigInt = BigInt(whole);\n const fractionBigInt = BigInt(fraction);\n let wei = wholeBigInt * base + fractionBigInt;\n\n if (negative) {\n wei = wei * negative1;\n }\n\n return wei;\n}\n"]}
@@ -1,5 +1,5 @@
1
- import type { Struct } from "@metamask/superstruct";
2
- import type { Opaque } from "./opaque.mjs";
1
+ import type { Struct } from '@metamask/superstruct';
2
+ import type { Opaque } from './opaque.js';
3
3
  /**
4
4
  * {@link https://codemix.com/opaque-types-in-javascript/ Opaque} type for SemVer ranges.
5
5
  *
@@ -98,4 +98,4 @@ export declare function gtRange(version: SemVerVersion, range: SemVerRange): boo
98
98
  */
99
99
  export declare function satisfiesVersionRange(version: SemVerVersion, versionRange: SemVerRange): boolean;
100
100
  export {};
101
- //# sourceMappingURL=versions.d.mts.map
101
+ //# sourceMappingURL=versions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"versions.d.ts","sourceRoot":"","sources":["../src/versions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAWpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,WAAW,CAAC,CAAC;AAE7D,OAAO,CAAC,MAAM,WAAW,EAAE,OAAO,MAAM,CAAC;AAEzC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,aAAa,CAAC,CAAC;AAEjE,OAAO,CAAC,MAAM,aAAa,EAAE,OAAO,MAAM,CAAC;AAE3C;;GAEG;AACH,eAAO,MAAM,aAAa,6BASzB,CAAC;AAEF,eAAO,MAAM,kBAAkB,2BAS9B,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,OAAO,GACf,OAAO,IAAI,aAAa,CAE1B;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,YAAY,EAAE,OAAO,GACpB,YAAY,IAAI,WAAW,CAE7B;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,OAAO,IAAI,aAAa,CAElC;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,KAAK,IAAI,WAAW,CAE9B;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CACvB,QAAQ,EAAE,aAAa,EACvB,QAAQ,EAAE,aAAa,GACtB,OAAO,CAET;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,WAAW,GAAG,OAAO,CAE3E;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,aAAa,EACtB,YAAY,EAAE,WAAW,GACxB,OAAO,CAIT"}
@@ -1,6 +1,6 @@
1
- import { is, refine, string } from "@metamask/superstruct";
2
- import { gt as gtSemver, gtr as gtrSemver, satisfies as satisfiesSemver, valid as validSemVerVersion, validRange as validSemVerRange } from "semver";
3
- import { assertStruct } from "./assert.mjs";
1
+ import { is, refine, string } from '@metamask/superstruct';
2
+ import { gt as gtSemver, gtr as gtrSemver, satisfies as satisfiesSemver, valid as validSemVerVersion, validRange as validSemVerRange, } from 'semver';
3
+ import { assertStruct } from './assert.js';
4
4
  /**
5
5
  * A struct for validating a version string.
6
6
  */
@@ -82,4 +82,4 @@ export function satisfiesVersionRange(version, versionRange) {
82
82
  includePrerelease: true,
83
83
  });
84
84
  }
85
- //# sourceMappingURL=versions.mjs.map
85
+ //# sourceMappingURL=versions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"versions.js","sourceRoot":"","sources":["../src/versions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EACL,EAAE,IAAI,QAAQ,EACd,GAAG,IAAI,SAAS,EAChB,SAAS,IAAI,eAAe,EAC5B,KAAK,IAAI,kBAAkB,EAC3B,UAAU,IAAI,gBAAgB,GAC/B,MAAM,QAAQ,CAAC;AAEhB,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAiD3C;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CACjC,MAAM,EAA4C,EAClD,SAAS,EACT,CAAC,KAAK,EAAE,EAAE;IACR,IAAI,kBAAkB,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC;QACvC,OAAO,iCAAiC,KAAK,GAAG,CAAC;IACnD,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CACF,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CACtC,MAAM,EAA0C,EAChD,eAAe,EACf,CAAC,KAAK,EAAE,EAAE;IACR,IAAI,gBAAgB,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC;QACrC,OAAO,+BAA+B,KAAK,GAAG,CAAC;IACjD,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CACF,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAClC,OAAgB;IAEhB,OAAO,EAAE,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;AACpC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAChC,YAAqB;IAErB,OAAO,EAAE,CAAC,YAAY,EAAE,kBAAkB,CAAC,CAAC;AAC9C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CACnC,OAAgB;IAEhB,YAAY,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;AACvC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CACjC,KAAc;IAEd,YAAY,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC;AAC1C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CACvB,QAAuB,EACvB,QAAuB;IAEvB,OAAO,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AACtC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,OAAO,CAAC,OAAsB,EAAE,KAAkB;IAChE,OAAO,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AACnC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CACnC,OAAsB,EACtB,YAAyB;IAEzB,OAAO,eAAe,CAAC,OAAO,EAAE,YAAY,EAAE;QAC5C,iBAAiB,EAAE,IAAI;KACxB,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Struct } from '@metamask/superstruct';\nimport { is, refine, string } from '@metamask/superstruct';\nimport {\n gt as gtSemver,\n gtr as gtrSemver,\n satisfies as satisfiesSemver,\n valid as validSemVerVersion,\n validRange as validSemVerRange,\n} from 'semver';\n\nimport { assertStruct } from './assert.js';\nimport type { Opaque } from './opaque.js';\n\n/**\n * {@link https://codemix.com/opaque-types-in-javascript/ Opaque} type for SemVer ranges.\n *\n * @example Use {@link assertIsSemVerRange} and {@link isValidSemVerRange} to cast to proper type.\n * ```typescript\n * const unsafeRange: string = dataFromUser();\n * assertIsSemVerRange(unsafeRange);\n * unsafeRange\n * // ^? SemVerRange\n * ```\n * @example If you know what you're doing and want to side-step type safety, casting from a string works correctly.\n * ```typescript\n * const unsafeRange: string = dataFromUser();\n * unsafeRange as SemVerRange;\n * // ^? SemVerRange\n * ```\n * @see {@link assertIsSemVerRange}\n * @see {@link isValidSemVerRange}\n */\nexport type SemVerRange = Opaque<string, typeof semVerRange>;\n// eslint-disable-next-line @typescript-eslint/no-unused-vars -- Branding symbol for the opaque type; used only via `typeof`.\ndeclare const semVerRange: unique symbol;\n\n/**\n * {@link https://codemix.com/opaque-types-in-javascript/ Opaque} type for singular SemVer version.\n *\n * @example Use {@link assertIsSemVerVersion} and {@link isValidSemVerVersion} to cast to proper type.\n * ```typescript\n * const unsafeVersion: string = dataFromUser();\n * assertIsSemVerVersion(unsafeRange);\n * unsafeVersion\n * // ^? SemVerVersion\n * ```\n * @example If you know what you're doing and want to side-step type safety, casting from a string works correctly.\n * ```typescript\n * const unsafeVersion: string = dataFromUser();\n * unsafeRange as SemVerVersion;\n * // ^? SemVerVersion\n * ```\n * @see {@link assertIsSemVerVersion}\n * @see {@link isValidSemVerVersion}\n */\nexport type SemVerVersion = Opaque<string, typeof semVerVersion>;\n// eslint-disable-next-line @typescript-eslint/no-unused-vars -- Branding symbol for the opaque type; used only via `typeof`.\ndeclare const semVerVersion: unique symbol;\n\n/**\n * A struct for validating a version string.\n */\nexport const VersionStruct = refine<SemVerVersion, null>(\n string() as unknown as Struct<SemVerVersion, null>,\n 'Version',\n (value) => {\n if (validSemVerVersion(value) === null) {\n return `Expected SemVer version, got \"${value}\"`;\n }\n return true;\n },\n);\n\nexport const VersionRangeStruct = refine<SemVerRange, null>(\n string() as unknown as Struct<SemVerRange, null>,\n 'Version range',\n (value) => {\n if (validSemVerRange(value) === null) {\n return `Expected SemVer range, got \"${value}\"`;\n }\n return true;\n },\n);\n\n/**\n * Checks whether a SemVer version is valid.\n *\n * @param version - A potential version.\n * @returns `true` if the version is valid, and `false` otherwise.\n */\nexport function isValidSemVerVersion(\n version: unknown,\n): version is SemVerVersion {\n return is(version, VersionStruct);\n}\n\n/**\n * Checks whether a SemVer version range is valid.\n *\n * @param versionRange - A potential version range.\n * @returns `true` if the version range is valid, and `false` otherwise.\n */\nexport function isValidSemVerRange(\n versionRange: unknown,\n): versionRange is SemVerRange {\n return is(versionRange, VersionRangeStruct);\n}\n\n/**\n * Asserts that a value is a valid concrete SemVer version.\n *\n * @param version - A potential SemVer concrete version.\n */\nexport function assertIsSemVerVersion(\n version: unknown,\n): asserts version is SemVerVersion {\n assertStruct(version, VersionStruct);\n}\n\n/**\n * Asserts that a value is a valid SemVer range.\n *\n * @param range - A potential SemVer range.\n */\nexport function assertIsSemVerRange(\n range: unknown,\n): asserts range is SemVerRange {\n assertStruct(range, VersionRangeStruct);\n}\n\n/**\n * Checks whether a SemVer version is greater than another.\n *\n * @param version1 - The left-hand version.\n * @param version2 - The right-hand version.\n * @returns `version1 > version2`.\n */\nexport function gtVersion(\n version1: SemVerVersion,\n version2: SemVerVersion,\n): boolean {\n return gtSemver(version1, version2);\n}\n\n/**\n * Checks whether a SemVer version is greater than all possibilities in a range.\n *\n * @param version - A SemvVer version.\n * @param range - The range to check against.\n * @returns `version > range`.\n */\nexport function gtRange(version: SemVerVersion, range: SemVerRange): boolean {\n return gtrSemver(version, range);\n}\n\n/**\n * Returns whether a SemVer version satisfies a SemVer range.\n *\n * @param version - The SemVer version to check.\n * @param versionRange - The SemVer version range to check against.\n * @returns Whether the version satisfied the version range.\n */\nexport function satisfiesVersionRange(\n version: SemVerVersion,\n versionRange: SemVerRange,\n): boolean {\n return satisfiesSemver(version, versionRange, {\n includePrerelease: true,\n });\n}\n"]}