@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
@@ -1,5 +1,5 @@
1
- import { ErrorWithCause } from "pony-cause";
2
- import { isNullOrUndefined, isObject } from "./misc.mjs";
1
+ import { ErrorWithCause } from 'pony-cause';
2
+ import { isNullOrUndefined, isObject } from './misc.js';
3
3
  /**
4
4
  * Type guard for determining whether the given value is an instance of Error.
5
5
  * For errors generated via `fs.promises`, `error instanceof Error` won't work,
@@ -59,6 +59,7 @@ export function getErrorMessage(error) {
59
59
  if (isNullOrUndefined(error)) {
60
60
  return '';
61
61
  }
62
+ // eslint-disable-next-line @typescript-eslint/no-base-to-string -- Stringifying an arbitrary value is the documented fallback here, so `[object Object]` is an accepted result rather than a mistake.
62
63
  return String(error);
63
64
  }
64
65
  /**
@@ -78,16 +79,9 @@ export function wrapError(originalError, message) {
78
79
  if (isError(originalError)) {
79
80
  let error;
80
81
  if (Error.length === 2) {
81
- // for some reason `tsserver` is not complaining that the
82
- // Error constructor doesn't support a second argument in the editor,
83
- // but `tsc` does. Error causes are not supported by our current tsc target (ES2020, we need ES2022 to make this work)
84
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
85
- // @ts-ignore
86
82
  error = new Error(message, { cause: originalError });
87
83
  }
88
84
  else {
89
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
90
- // @ts-ignore
91
85
  error = new ErrorWithCause(message, { cause: originalError });
92
86
  }
93
87
  if (isErrorWithCode(originalError)) {
@@ -117,4 +111,4 @@ export function ensureError(error) {
117
111
  newError.cause = error;
118
112
  return newError;
119
113
  }
120
- //# sourceMappingURL=errors.mjs.map
114
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAExD;;;;;;;GAOG;AACH,SAAS,OAAO,CAAC,KAAc;IAC7B,OAAO,CACL,KAAK,YAAY,KAAK;QACtB,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,WAAW,CAAC,IAAI,KAAK,OAAO,CAAC,CACxD,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,MAAM,IAAI,KAAK,CAAC;AACxE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAChC,KAAc;IAEd,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,SAAS,IAAI,KAAK,CAAC;AAC3E,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,K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,CAAC,CAAC;AAC1C,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,WAAW,CAAC,KAAc;IACxC,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACnB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,QAAQ,GAAgC,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;IACzE,QAAQ,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import { ErrorWithCause } from 'pony-cause';\n\nimport { isNullOrUndefined, isObject } from './misc.js';\n\n/**\n * Type guard for determining whether the given value is an instance of Error.\n * For errors generated via `fs.promises`, `error instanceof Error` won't work,\n * so we have to come up with another way of testing.\n *\n * @param error - The object to check.\n * @returns A boolean.\n */\nfunction isError(error: unknown): error is Error {\n return (\n error instanceof Error ||\n (isObject(error) && error.constructor.name === 'Error')\n );\n}\n\n/**\n * Type guard for determining whether the given value is an error object with a\n * `code` property such as the type of error that Node throws for filesystem\n * operations, etc.\n *\n * @param error - The object to check.\n * @returns A boolean.\n */\nexport function isErrorWithCode(error: unknown): error is { code: string } {\n return typeof error === 'object' && error !== null && 'code' in error;\n}\n\n/**\n * Type guard for determining whether the given value is an error object with a\n * `message` property, such as an instance of Error.\n *\n * @param error - The object to check.\n * @returns A boolean.\n */\nexport function isErrorWithMessage(\n error: unknown,\n): error is { message: string } {\n return typeof error === 'object' && error !== null && 'message' in error;\n}\n\n/**\n * Type guard for determining whether the given value is an error object with a\n * `stack` property, such as an instance of Error.\n *\n * @param error - The object to check.\n * @returns A boolean.\n */\nexport function isErrorWithStack(error: unknown): error is { stack: string } {\n return typeof error === 'object' && error !== null && 'stack' in error;\n}\n\n/**\n * Attempts to obtain the message from a possible error object, defaulting to an\n * empty string if it is impossible to do so.\n *\n * @param error - The possible error to get the message from.\n * @returns The message if `error` is an object with a `message` property;\n * the string version of `error` if it is not `undefined` or `null`; otherwise\n * an empty string.\n */\nexport function getErrorMessage(error: unknown): string {\n if (isErrorWithMessage(error) && typeof error.message === 'string') {\n return error.message;\n }\n\n if (isNullOrUndefined(error)) {\n return '';\n }\n\n // eslint-disable-next-line @typescript-eslint/no-base-to-string -- Stringifying an arbitrary value is the documented fallback here, so `[object Object]` is an accepted result rather than a mistake.\n return String(error);\n}\n\n/**\n * Builds a new error object, linking it to the original error via the `cause`\n * property if it is an Error.\n *\n * This function is useful to reframe error messages in general, but is\n * _critical_ when interacting with any of Node's filesystem functions as\n * provided via `fs.promises`, because these do not produce stack traces in the\n * case of an I/O error (see <https://github.com/nodejs/node/issues/30944>).\n *\n * @param originalError - The error to be wrapped (something throwable).\n * @param message - The desired message of the new error.\n * @returns A new error object.\n */\nexport function wrapError<Throwable>(\n originalError: Throwable,\n message: string,\n): Error & { code?: string } {\n if (isError(originalError)) {\n let error: Error & { code?: string };\n if (Error.length === 2) {\n error = new Error(message, { cause: originalError });\n } else {\n error = new ErrorWithCause(message, { cause: originalError });\n }\n\n if (isErrorWithCode(originalError)) {\n error.code = originalError.code;\n }\n\n return error;\n }\n\n if (message.length > 0) {\n return new Error(`${String(originalError)}: ${message}`);\n }\n\n return new Error(String(originalError));\n}\n\n/**\n * Ensures we have a proper Error object.\n * If the input is already an Error, returns it unchanged.\n * Otherwise, converts to an Error with an appropriate message and preserves\n * the original value as the cause.\n *\n * @param error - The caught error (could be Error, string, or unknown).\n * @returns A proper Error instance.\n */\nexport function ensureError(error: unknown): Error {\n if (isError(error)) {\n return error;\n }\n\n const newError: Error & { cause?: unknown } = new Error('Unknown error');\n newError.cause = error;\n return newError;\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { Json } from "./json.cjs";
1
+ import type { Json } from './json.js';
2
2
  /**
3
3
  * Information about the file sandbox provided to tests that need temporary
4
4
  * access to the filesystem.
@@ -130,4 +130,4 @@ export declare function forceRemove(entryPath: string): Promise<void>;
130
130
  * ```
131
131
  */
132
132
  export declare function createSandbox(projectName: string): FileSandbox;
133
- //# sourceM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AAQ,CAAC,EAAE,OAAO,CAAC;CACf,GACL,OAAO,CAAC,IAAI,CAAC,CAUf;AAED;;;;;;GAMG;AACH,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAWnE;AAED;;;;;;GAMG;AACH,wBAAsB,eAAe,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAc7E;AAED;;;;;;GAMG;AACH,wBAAsB,8BAA8B,CAClD,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,IAAI,CAAC,CASf;AAED;;;;;;GAMG;AACH,wBAAsB,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CASlE;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,WAAW,CAqB9D"}
@@ -1,10 +1,10 @@
1
1
  // This file is intended to be used only in a Node.js context.
2
2
  /* eslint-disable import-x/no-nodejs-modules */
3
- import fs from "fs";
4
- import os from "os";
5
- import path from "path";
6
- import * as uuid from "uuid";
7
- import { isErrorWithCode, wrapError } from "./errors.mjs";
3
+ import fs from 'fs';
4
+ import os from 'os';
5
+ import path from 'path';
6
+ import { v4 as uuidV4 } from 'uuid';
7
+ import { isErrorWithCode, wrapError } from './errors.js';
8
8
  /**
9
9
  * Read the file at the given path, assuming its content is encoded as UTF-8.
10
10
  *
@@ -190,7 +190,7 @@ export async function forceRemove(entryPath) {
190
190
  * ```
191
191
  */
192
192
  export function createSandbox(projectName) {
193
- const directoryPath = path.join(os.tmpdir(), projectName, uuid.v4());
193
+ const directoryPath = path.join(os.tmpdir(), projectName, uuidV4());
194
194
  return {
195
195
  directoryPath,
196
196
  async withinSandbox(test) {
@@ -207,4 +207,4 @@ export function createSandbox(projectName) {
207
207
  },
208
208
  };
209
209
  }
210
- //# sourceMappingURL=fs.mjs.map
210
+ //# sourceMappingURL=fs.js.map
package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AAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,SAAS,CAAC,KAAK,EAAE,uCAAuC,SAAS,GAAG,CAAC,CAAC;IAC9E,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,aAAa,CAAC,WAAmB;IAC/C,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,CAAC;IAEpE,OAAO;QACL,aAAa;QACb,KAAK,CAAC,aAAa,CACjB,IAAwD;YAExD,IAAI,MAAM,eAAe,CAAC,aAAa,CAAC,EAAE,CAAC;gBACzC,MAAM,IAAI,KAAK,CAAC,GAAG,aAAa,mCAAmC,CAAC,CAAC;YACvE,CAAC;YAED,MAAM,8BAA8B,CAAC,aAAa,CAAC,CAAC;YAEpD,IAAI,CAAC;gBACH,MAAM,IAAI,CAAC,EAAE,aAAa,EAAE,CAAC,CAAC;YAChC,CAAC;oBAAS,CAAC;gBACT,MAAM,WAAW,CAAC,aAAa,CAAC,CAAC;YACnC,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// This file is intended to be used only in a Node.js context.\n/* eslint-disable import-x/no-nodejs-modules */\n\nimport fs from 'fs';\nimport os from 'os';\nimport path from 'path';\nimport { v4 as uuidV4 } from 'uuid';\n\nimport { isErrorWithCode, wrapError } from './errors.js';\nimport type { Json } from './json.js';\n\n/**\n * Information about the file sandbox provided to tests that need temporary\n * access to the filesystem.\n */\nexport type FileSandbox = {\n directoryPath: string;\n withinSandbox: (\n test: (args: { directoryPath: string }) => Promise<void>,\n ) => Promise<void>;\n};\n\n/**\n * Read the file at the given path, assuming its content is encoded as UTF-8.\n *\n * @param filePath - The path to the file.\n * @returns The content of the file.\n * @throws An error with a stack trace if reading fails in any way.\n */\nexport async function readFile(filePath: string): Promise<string> {\n try {\n return await fs.promises.readFile(filePath, 'utf8');\n } catch (error) {\n throw wrapError(error, `Could not read file '${filePath}'`);\n }\n}\n\n/**\n * Write content to the file at the given path, creating the directory structure\n * for the file automatically if necessary.\n *\n * @param filePath - The path to the file.\n * @param content - The new content of the file.\n * @throws An error with a stack trace if writing fails in any way.\n */\nexport async function writeFile(\n filePath: string,\n content: string,\n): Promise<void> {\n try {\n await fs.promises.mkdir(path.dirname(filePath), { recursive: true });\n await fs.promises.writeFile(filePath, content);\n } catch (error) {\n throw wrapError(error, `Could not write file '${filePath}'`);\n }\n}\n\n/**\n * Read the assumed JSON file at the given path, attempts to parse it, and\n * get the resulting object. Supports a custom parser (in case you want to\n * use the [JSON5](https://www.npmjs.com/package/json5) package instead).\n *\n * @param filePath - The path segments pointing to the JSON file. Will be passed\n * to path.join().\n * @param options - Options to this function.\n * @param options.parser - The parser object to use. Defaults to `JSON`.\n * @param options.parser.parse - A function that parses JSON data.\n * @returns The object corresponding to the parsed JSON file, typed against the\n * struct.\n * @throws An error with a stack trace if reading fails in any way, or if the\n * parsed value is not a plain object.\n */\nexport async function readJsonFile<Value extends Json>(\n filePath: string,\n {\n parser = JSON,\n }: {\n parser?: {\n parse: (\n text: Parameters<typeof JSON.parse>[0],\n ) => ReturnType<typeof JSON.parse>;\n };\n } = {},\n): Promise<Value> {\n try {\n const content = await fs.promises.readFile(filePath, 'utf8');\n return parser.parse(content);\n } catch (error) {\n throw wrapError(error, `Could not read JSON file '${filePath}'`);\n }\n}\n\n/**\n * Attempt to write the given JSON-like value to the file at the given path,\n * creating the directory structure for the file automatically if necessary.\n * Adds a newline to the end of the file. Supports a custom parser (in case you\n * want to use the [JSON5](https://www.npmjs.com/package/json5) package\n * instead).\n *\n * @param filePath - The path to write the JSON file to, including the file\n * itself.\n * @param jsonValue - The JSON-like value to write to the file. Make sure that\n * JSON.stringify can handle it.\n * @param options - The options to this function.\n * @param options.prettify - Whether to format the JSON as it is turned into a\n * string such that it is broken up into separate lines (using 2 spaces as\n * indentation).\n * @param options.stringifier - The stringifier to use. Defaults to `JSON`.\n * @param options.stringifier.stringify - A function that stringifies JSON.\n * @returns The object corresponding to the parsed JSON file, typed against the\n * struct.\n * @throws An error with a stack trace if writing fails in any way.\n */\nexport async function writeJsonFile(\n filePath: string,\n jsonValue: Json,\n {\n stringifier = JSON,\n prettify = false,\n }: {\n stringifier?: {\n stringify: typeof JSON.stringify;\n };\n prettify?: boolean;\n } = {},\n): Promise<void> {\n try {\n await fs.promises.mkdir(path.dirname(filePath), { recursive: true });\n const json = prettify\n ? stringifier.stringify(jsonValue, null, ' ')\n : stringifier.stringify(jsonValue);\n await fs.promises.writeFile(filePath, json);\n } catch (error) {\n throw wrapError(error, `Could not write JSON file '${filePath}'`);\n }\n}\n\n/**\n * Test the given path to determine whether it represents a file.\n *\n * @param filePath - The path to a (supposed) file on the filesystem.\n * @returns A promise for true if the file exists or false otherwise.\n * @throws An error with a stack trace if reading fails in any way.\n */\nexport async function fileExists(filePath: string): Promise<boolean> {\n try {\n const stats = await fs.promises.stat(filePath);\n return stats.isFile();\n } catch (error) {\n if (isErrorWithCode(error) && error.code === 'ENOENT') {\n return false;\n }\n\n throw wrapError(error, `Could not determine if file exists '${filePath}'`);\n }\n}\n\n/**\n * Test the given path to determine whether it represents a directory.\n *\n * @param directoryPath - The path to a (supposed) directory on the filesystem.\n * @returns A promise for true if the file exists or false otherwise.\n * @throws An error with a stack trace if reading fails in any way.\n */\nexport async function directoryExists(directoryPath: string): Promise<boolean> {\n try {\n const stats = await fs.promises.stat(directoryPath);\n return stats.isDirectory();\n } catch (error) {\n if (isErrorWithCode(error) && error.code === 'ENOENT') {\n return false;\n }\n\n throw wrapError(\n error,\n `Could not determine if directory exists '${directoryPath}'`,\n );\n }\n}\n\n/**\n * Create the given directory along with any directories leading up to the\n * directory, or do nothing if the directory already exists.\n *\n * @param directoryPath - The path to the desired directory.\n * @throws An error with a stack trace if reading fails in any way.\n */\nexport async function ensureDirectoryStructureExists(\n directoryPath: string,\n): Promise<void> {\n try {\n await fs.promises.mkdir(directoryPath, { recursive: true });\n } catch (error) {\n throw wrapError(\n error,\n `Could not create directory structure '${directoryPath}'`,\n );\n }\n}\n\n/**\n * Remove the given file or directory if it exists, or do nothing if it does\n * not.\n *\n * @param entryPath - The path to the file or directory.\n * @throws An error with a stack trace if removal fails in any way.\n */\nexport async function forceRemove(entryPath: string): Promise<void> {\n try {\n return await fs.promises.rm(entryPath, {\n recursive: true,\n force: true,\n });\n } catch (error) {\n throw wrapError(error, `Could not remove file or directory '${entryPath}'`);\n }\n}\n\n/**\n * Construct a sandbox object which can be used in tests that need temporary\n * access to the filesystem.\n *\n * @param projectName - The name of the project.\n * @returns The sandbox object. This contains a `withinSandbox` function which\n * can be used in tests (see example).\n * @example\n * ```typescript\n * const { withinSandbox } = createSandbox('utils');\n *\n * // ... later ...\n *\n * it('does something with the filesystem', async () => {\n * await withinSandbox(async ({ directoryPath }) => {\n * await fs.promises.writeFile(\n * path.join(directoryPath, 'some-file'),\n * 'some content',\n * 'utf8'\n * );\n * })\n * });\n * ```\n */\nexport function createSandbox(projectName: string): FileSandbox {\n const directoryPath = path.join(os.tmpdir(), projectName, uuidV4());\n\n return {\n directoryPath,\n async withinSandbox(\n test: (args: { directoryPath: string }) => Promise<void>,\n ) {\n if (await directoryExists(directoryPath)) {\n throw new Error(`${directoryPath} already exists. Cannot continue.`);\n }\n\n await ensureDirectoryStructureExists(directoryPath);\n\n try {\n await test({ directoryPath });\n } finally {\n await forceRemove(directoryPath);\n }\n },\n };\n}\n"]}
@@ -25,4 +25,4 @@ export declare function sha512(bytes: Uint8Array): Promise<Uint8Array>;
25
25
  * @returns The SHA-384 hash as a byte array.
26
26
  */
27
27
  export declare function sha384(bytes: Uint8Array): Promise<Uint8Array>;
28
- //# sourceMappingURL=hashing.d.cts.map
28
+ //# sourceMappingURL=hashing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hashing.d.ts","sourceRoot":"","sources":["../src/hashing.ts"],"names":[],"mappings":"AAMA;;;;;;;GAOG;AAMH,wBAAsB,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAYnE;AAED;;;;;;;GAOG;AACH,wBAAsB,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAYnE;AAED;;;;;;;GAOG;AACH,wBAAsB,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAYnE"}
@@ -1,5 +1,5 @@
1
- import { sha256 as nobleSha256 } from "@noble/hashes/sha256";
2
- import { sha512 as nobleSha512, sha384 as nobleSha384 } from "@noble/hashes/sha512";
1
+ import { sha256 as nobleSha256 } from '@noble/hashes/sha256';
2
+ import { sha512 as nobleSha512, sha384 as nobleSha384, } from '@noble/hashes/sha512';
3
3
  /**
4
4
  * Compute a SHA-256 digest for a given byte array.
5
5
  *
@@ -8,6 +8,11 @@ import { sha512 as nobleSha512, sha384 as nobleSha384 } from "@noble/hashes/sha5
8
8
  * @param bytes - A byte array.
9
9
  * @returns The SHA-256 hash as a byte array.
10
10
  */
11
+ // `crypto.subtle.digest` takes a `BufferSource`, which TypeScript 7 will not
12
+ // accept a plain `Uint8Array` for: it is now generic over the buffer, so it
13
+ // could be backed by a `SharedArrayBuffer`. Runtimes accept those, and
14
+ // narrowing the exported signatures below would break callers, so the
15
+ // assertion is kept at the call sites.
11
16
  export async function sha256(bytes) {
12
17
  // Use crypto.subtle.digest whenever possible as it is faster.
13
18
  if ('crypto' in globalThis &&
@@ -51,4 +56,4 @@ export async function sha384(bytes) {
51
56
  }
52
57
  return nobleSha384(bytes);
53
58
  }
54
- //# sourceMappingURL=hashing.mjs.map
59
+ //# sourceMappingURL=hashing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hashing.js","sourceRoot":"","sources":["../src/hashing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC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AM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,KAAqB,CAAC,CACxE,CAAC;IACJ,CAAC;IACD,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC;AAC5B,CAAC","sourcesContent":["import { sha256 as nobleSha256 } from '@noble/hashes/sha256';\nimport {\n sha512 as nobleSha512,\n sha384 as nobleSha384,\n} from '@noble/hashes/sha512';\n\n/**\n * Compute a SHA-256 digest for a given byte array.\n *\n * Uses the native crypto implementation and falls back to noble.\n *\n * @param bytes - A byte array.\n * @returns The SHA-256 hash as a byte array.\n */\n// `crypto.subtle.digest` takes a `BufferSource`, which TypeScript 7 will not\n// accept a plain `Uint8Array` for: it is now generic over the buffer, so it\n// could be backed by a `SharedArrayBuffer`. Runtimes accept those, and\n// narrowing the exported signatures below would break callers, so the\n// assertion is kept at the call sites.\nexport async function sha256(bytes: Uint8Array): Promise<Uint8Array> {\n // Use crypto.subtle.digest whenever possible as it is faster.\n if (\n 'crypto' in globalThis &&\n typeof globalThis.crypto === 'object' &&\n globalThis.crypto.subtle?.digest\n ) {\n return new Uint8Array(\n await globalThis.crypto.subtle.digest('SHA-256', bytes as BufferSource),\n );\n }\n return nobleSha256(bytes);\n}\n\n/**\n * Compute a SHA-512 digest for a given byte array.\n *\n * Uses the native crypto implementation and falls back to noble.\n *\n * @param bytes - A byte array.\n * @returns The SHA-512 hash as a byte array.\n */\nexport async function sha512(bytes: Uint8Array): Promise<Uint8Array> {\n // Use crypto.subtle.digest whenever possible as it is faster.\n if (\n 'crypto' in globalThis &&\n typeof globalThis.crypto === 'object' &&\n globalThis.crypto.subtle?.digest\n ) {\n return new Uint8Array(\n await globalThis.crypto.subtle.digest('SHA-512', bytes as BufferSource),\n );\n }\n return nobleSha512(bytes);\n}\n\n/**\n * Compute a SHA-384 digest for a given byte array.\n *\n * Uses the native crypto implementation and falls back to noble.\n *\n * @param bytes - A byte array.\n * @returns The SHA-384 hash as a byte array.\n */\nexport async function sha384(bytes: Uint8Array): Promise<Uint8Array> {\n // Use crypto.subtle.digest whenever possible as it is faster.\n if (\n 'crypto' in globalThis &&\n typeof globalThis.crypto === 'object' &&\n globalThis.crypto.subtle?.digest\n ) {\n return new Uint8Array(\n await globalThis.crypto.subtle.digest('SHA-384', bytes as BufferSource),\n );\n }\n return nobleSha384(bytes);\n}\n"]}
@@ -1,10 +1,9 @@
1
- /// <reference types="lodash" />
2
- import type { Struct } from "@metamask/superstruct";
1
+ import type { Struct } from '@metamask/superstruct';
3
2
  export type Hex = `0x${string}`;
4
3
  export declare const HexStruct: Struct<string, null>;
5
- export declare const StrictHexStruct: Struct<`0x${string}`, null>;
6
- export declare const HexAddressStruct: Struct<`0x${string}`, null>;
7
- export declare const HexChecksumAddressStruct: Struct<`0x${string}`, null>;
4
+ export declare const StrictHexStruct: Struct<Hex, null>;
5
+ export declare const HexAddressStruct: Struct<Hex, null>;
6
+ export declare const HexChecksumAddressStruct: Struct<Hex, null>;
8
7
  /**
9
8
  * Check if a string is a valid hex string.
10
9
  *
@@ -115,4 +114,4 @@ export declare function add0x(hexadecimal: string): Hex;
115
114
  * @returns The un-prefixed hexadecimal string.
116
115
  */
117
116
  export declare function remove0x(hexadecimal: string): string;
118
- //# sourceMappingURL=hex.d.cts.map
117
+ //# sourceMappingURL=hex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hex.d.ts","sourceRoot":"","sources":["../src/hex.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAMpD,MAAM,MAAM,GAAG,GAAG,KAAK,MAAM,EAAE,CAAC;AAShC,eAAO,MAAM,SAAS,sBAA+B,CAAC;AACtD,eAAO,MAAM,eAAe,EAA0C,MAAM,CAC1E,GAAG,EACH,IAAI,CACL,CAAC;AACF,eAAO,MAAM,gBAAgB,EAA2C,MAAM,CAC5E,GAAG,EACH,IAAI,CACL,CAAC;AACF,eAAO,MAAM,wBAAwB,EAGhC,MAAM,CAAC,GAAG,E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ccak256 } from "@noble/hashes/sha3";
3
- import $lodash from "lodash";
4
- const { memoize } = $lodash;
5
- import { assert } from "./assert.mjs";
1
+ import { pattern, string } from '@metamask/superstruct';
2
+ import { keccak_256 as keccak256 } from '@noble/hashes/sha3';
3
+ import memoize from 'lodash/memoize.js';
4
+ import { assert } from './assert.js';
6
5
  // Use native regexes instead of superstruct for maximum performance.
7
6
  // Pre-compiled regex for maximum performance - avoids recompilation on each call
8
7
  const HEX_REGEX = /^(?:0x)?[0-9a-f]+$/iu;
@@ -172,4 +171,4 @@ export function remove0x(hexadecimal) {
172
171
  }
173
172
  return hexadecimal;
174
173
  }
175
- //# sourceMappingURL=hex.mjs.map
174
+ //# sourceMappingURL=hex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hex.js","sourceRoot":"","sources":["../src/hex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,EAAE,UAAU,IAAI,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,OAAO,MAAM,mBAAmB,CAAC;AAExC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAIrC,qEAAqE;AACrE,iFAAiF;AACjF,MAAM,SAAS,GAAG,sBAAsB,CAAC;AACzC,MAAM,gBAAgB,GAAG,iBAAiB,CAAC;AAC3C,MAAM,iBAAiB,GAAG,mBAAmB,CAAC;AAC9C,MAAM,0BAA0B,GAAG,sBAAsB,CAAC;AAE1D,MAAM,CAAC,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,EAAE,EAAE,SAAS,CAAC,CAAC;AACtD,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAC,MAAM,EAAE,EAAE,gBAAgB,CAGhE,CAAC;AACF,MAAM,CAAC,MAAM,gBAAgB,GAAG,OAAO,CAAC,MAAM,EAAE,EAAE,iBAAiB,CAGlE,CAAC;AACF,MAAM,CAAC,MAAM,wBAAwB,GAA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CAAgC,CAAC,CAAC;AAEhF;;;;;;GAMG;AACH,MAAM,UAAU,2BAA2B,CAAC,eAAoB;IAC9D,OAAO,CACL,YAAY,CAAC,eAAe,CAAC,IAAI,sBAAsB,CAAC,eAAe,CAAC,CACzE,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAAC;AAEtE;;;;;;GAMG;AACH,MAAM,UAAU,KAAK,CAAC,WAAmB;IACvC,IAAI,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACjC,OAAO,WAAkB,CAAC;IAC5B,CAAC;IAED,IAAI,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACjC,OAAO,KAAK,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;IACzC,CAAC;IAED,OAAO,KAAK,WAAW,EAAE,CAAC;AAC5B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CAAC,WAAmB;IAC1C,IAAI,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACjE,OAAO,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAClC,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["import { pattern, string } from '@metamask/superstruct';\nimport type { Struct } from '@metamask/superstruct';\nimport { keccak_256 as keccak256 } from '@noble/hashes/sha3';\nimport memoize from 'lodash/memoize.js';\n\nimport { assert } from './assert.js';\n\nexport type Hex = `0x${string}`;\n\n// Use native regexes instead of superstruct for maximum performance.\n// Pre-compiled regex for maximum performance - avoids recompilation on each call\nconst HEX_REGEX = /^(?:0x)?[0-9a-f]+$/iu;\nconst STRICT_HEX_REGEX = /^0x[0-9a-f]+$/iu;\nconst HEX_ADDRESS_REGEX = /^0x[0-9a-f]{40}$/u;\nconst HEX_CHECKSUM_ADDRESS_REGEX = /^0x[0-9a-fA-F]{40}$/u;\n\nexport const HexStruct = pattern(string(), HEX_REGEX);\nexport const StrictHexStruct = pattern(string(), STRICT_HEX_REGEX) as Struct<\n Hex,\n null\n>;\nexport const HexAddressStruct = pattern(string(), HEX_ADDRESS_REGEX) as Struct<\n Hex,\n null\n>;\nexport const HexChecksumAddressStruct = pattern(\n string(),\n HEX_CHECKSUM_ADDRESS_REGEX,\n) as Struct<Hex, null>;\n\nconst isString = (value: unknown): value is string => typeof value === 'string';\n\n/**\n * Check if a string is a valid hex string.\n *\n * @param value - The value to check.\n * @returns Whether the value is a valid hex string.\n */\nexport function isHexString(value: unknown): value is string {\n return isString(value) && HEX_REGEX.test(value);\n}\n\n/**\n * Strictly check if a string is a valid hex string. A valid hex string must\n * start with the \"0x\"-prefix.\n *\n * @param value - The value to check.\n * @returns Whether the value is a valid hex string.\n */\nexport function isStrictHexString(value: unknown): value is Hex {\n return isString(value) && STRICT_HEX_REGEX.test(value);\n}\n\n/**\n * Check if a string is a valid hex address.\n *\n * @param value - The value to check.\n * @returns Whether the value is a valid hex address.\n */\nexport function isHexAddress(value: unknown): value is Hex {\n return isString(value) && HEX_ADDRESS_REGEX.test(value);\n}\n\n/**\n * Check if a string is a valid hex checksum address.\n *\n * @param value - The value to check.\n * @returns Whether the value is a valid hex checksum address.\n */\nexport function isHexChecksumAddress(value: unknown): value is Hex {\n return isString(value) && HEX_CHECKSUM_ADDRESS_REGEX.test(value);\n}\n\n/**\n * Assert that a value is a valid hex string.\n *\n * @param value - The value to check.\n * @throws If the value is not a valid hex string.\n */\nexport function assertIsHexString(value: unknown): asserts value is string {\n assert(isHexString(value), 'Value must be a hexadecimal string.');\n}\n\n/**\n * Assert that a value is a valid hex string. A valid hex string must start with\n * the \"0x\"-prefix.\n *\n * @param value - The value to check.\n * @throws If the value is not a valid hex string.\n */\nexport function assertIsStrictHexString(value: unknown): asserts value is Hex {\n assert(\n isStrictHexString(value),\n 'Value must be a hexadecimal string, starting with \"0x\".',\n );\n}\n\n/**\n * Encode a passed hex string as an ERC-55 mixed-case checksum address.\n * This is the unmemoized version, primarily used for testing.\n *\n * @param hexAddress - The hex address to encode.\n * @returns The address encoded according to ERC-55.\n * @see https://eips.ethereum.org/EIPS/eip-55\n */\nexport function getChecksumAddressUnmemoized(hexAddress: Hex): Hex {\n assert(isHexChecksumAddress(hexAddress), 'Invalid hex address.');\n const address = remove0x(hexAddress).toLowerCase();\n\n const hashBytes = keccak256(address);\n const { length } = address;\n const result = new Array(length); // Pre-allocate array\n\n for (let i = 0; i < length; i++) {\n /* eslint-disable no-bitwise */\n const byteIndex = i >> 1; // Faster than Math.floor(i / 2)\n const nibbleIndex = i & 1; // Faster than i % 2\n const byte = hashBytes[byteIndex] as number;\n const nibble = nibbleIndex === 0 ? byte >> 4 : byte & 0x0f;\n /* eslint-enable no-bitwise */\n\n result[i] = nibble >= 8 ? (address[i] as string).toUpperCase() : address[i];\n }\n\n return `0x${result.join('')}`;\n}\n\n/**\n * Encode a passed hex string as an ERC-55 mixed-case checksum address.\n * This function is memoized for performance.\n *\n * @param hexAddress - The hex address to encode.\n * @returns The address encoded according to ERC-55.\n * @see https://eips.ethereum.org/EIPS/eip-55\n */\nexport const getChecksumAddress = memoize(getChecksumAddressUnmemoized);\n\n/**\n * Validate that the passed hex string is a valid ERC-55 mixed-case\n * checksum address.\n *\n * @param possibleChecksum - The hex address to check.\n * @returns True if the address is a checksum address.\n */\nexport function isValidChecksumAddressUnmemoized(possibleChecksum: Hex) {\n if (!isHexChecksumAddress(possibleChecksum)) {\n return false;\n }\n\n return getChecksumAddress(possibleChecksum) === possibleChecksum;\n}\n\n/**\n * Validate that the passed hex string is a valid ERC-55 mixed-case\n * checksum address.\n *\n * @param possibleChecksum - The hex address to check.\n * @returns True if the address is a checksum address.\n */\nexport const isValidChecksumAddress = memoize(isValidChecksumAddressUnmemoized);\n\n/**\n * Validate that the passed prefixed hex string is an all-lowercase\n * hex address, or a valid mixed-case checksum address.\n *\n * @param possibleAddress - Input parameter to check against.\n * @returns Whether or not the input is a valid hex address.\n */\nexport function isValidHexAddressUnmemoized(possibleAddress: Hex) {\n return (\n isHexAddress(possibleAddress) || isValidChecksumAddress(possibleAddress)\n );\n}\n\n/**\n * Validate that the passed prefixed hex string is an all-lowercase\n * hex address, or a valid mixed-case checksum address.\n *\n * @param possibleAddress - Input parameter to check against.\n * @returns Whether or not the input is a valid hex address.\n */\nexport const isValidHexAddress = memoize(isValidHexAddressUnmemoized);\n\n/**\n * Add the `0x`-prefix to a hexadecimal string. If the string already has the\n * prefix, it is returned as-is.\n *\n * @param hexadecimal - The hexadecimal string to add the prefix to.\n * @returns The prefixed hexadecimal string.\n */\nexport function add0x(hexadecimal: string): Hex {\n if (hexadecimal.startsWith('0x')) {\n return hexadecimal as Hex;\n }\n\n if (hexadecimal.startsWith('0X')) {\n return `0x${hexadecimal.substring(2)}`;\n }\n\n return `0x${hexadecimal}`;\n}\n\n/**\n * Remove the `0x`-prefix from a hexadecimal string. If the string doesn't have\n * the prefix, it is returned as-is.\n *\n * @param hexadecimal - The hexadecimal string to remove the prefix from.\n * @returns The un-prefixed hexadecimal string.\n */\nexport function remove0x(hexadecimal: string): string {\n if (hexadecimal.startsWith('0x') || hexadecimal.startsWith('0X')) {\n return hexadecimal.substring(2);\n }\n\n return hexadecimal;\n}\n"]}
@@ -0,0 +1,26 @@
1
+ export * from './assert.js';
2
+ export * from './base64.js';
3
+ export * from './bytes.js';
4
+ export * from './caip-types.js';
5
+ export * from './checksum.js';
6
+ export * from './coercers.js';
7
+ export * from './collections.js';
8
+ export type * from './encryption-types.js';
9
+ export * from './errors.js';
10
+ export * from './hashing.js';
11
+ export type { Hex } from './hex.js';
12
+ export { HexStruct, StrictHexStruct, HexAddressStruct, HexChecksumAddressStruct, isHexString, isStrictHexString, isHexAddress, isHexChecksumAddress, assertIsHexString, assertIsStrictHexString, isValidHexAddress, getChecksumAddress, isValidChecksumAddress, add0x, remove0x, } from './hex.js';
13
+ export * from './json.js';
14
+ export type * from './keyring.js';
15
+ export * from './logging.js';
16
+ export * from './misc.js';
17
+ export * from './mnemonic.js';
18
+ export * from './number.js';
19
+ export type * from './opaque.js';
20
+ export * from './promise.js';
21
+ export * from './superstruct.js';
22
+ export * from './time.js';
23
+ export type * from './transaction-types.js';
24
+ export * from './versions.js';
25
+ export { toWei, fromWei, numberToString, getValueOfUnit, unitMap, } from './unitsConversion.js';
26
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,mBAAmB,uBAAuB,CAAC;AAC3C,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,YAAY,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EACL,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,wBAAwB,EACxB,WAAW,EACX,iBAAiB,EACjB,YAAY,EACZ,oBAAoB,EACpB,iBAAiB,EACjB,uBAAuB,EACvB,iBAAiB,EACjB,kBAAkB,EAClB,sBAAsB,EACtB,KAAK,EACL,QAAQ,GACT,MAAM,UAAU,CAAC;AAClB,cAAc,WAAW,CAAC;AAC1B,mBAAmB,cAAc,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,mBAAmB,aAAa,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,mBAAmB,wBAAwB,CAAC;AAC5C,cAAc,eAAe,CAAC;AAC9B,OAAO,EACL,KAAK,EACL,OAAO,EACP,cAAc,EACd,cAAc,EACd,OAAO,GACR,MAAM,sBAAsB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,21 @@
1
+ export * from './assert.js';
2
+ export * from './base64.js';
3
+ export * from './bytes.js';
4
+ export * from './caip-types.js';
5
+ export * from './checksum.js';
6
+ export * from './coercers.js';
7
+ export * from './collections.js';
8
+ export * from './errors.js';
9
+ export * from './hashing.js';
10
+ export { HexStruct, StrictHexStruct, HexAddressStruct, HexChecksumAddressStruct, isHexString, isStrictHexString, isHexAddress, isHexChecksumAddress, assertIsHexString, assertIsStrictHexString, isValidHexAddress, getChecksumAddress, isValidChecksumAddress, add0x, remove0x, } from './hex.js';
11
+ export * from './json.js';
12
+ export * from './logging.js';
13
+ export * from './misc.js';
14
+ export * from './mnemonic.js';
15
+ export * from './number.js';
16
+ export * from './promise.js';
17
+ export * from './superstruct.js';
18
+ export * from './time.js';
19
+ export * from './versions.js';
20
+ export { toWei, fromWei, numberToString, getValueOfUnit, unitMap, } from './unitsConversion.js';
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AAEjC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAE7B,OAAO,EACL,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,wBAAwB,EACxB,WAAW,EACX,iBAAiB,EACjB,YAAY,EACZ,oBAAoB,EACpB,iBAAiB,EACjB,uBAAuB,EACvB,iBAAiB,EACjB,kBAAkB,EAClB,sBAAsB,EACtB,KAAK,EACL,QAAQ,GACT,MAAM,UAAU,CAAC;AAClB,cAAc,WAAW,CAAC;AAE1B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAE5B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAE1B,cAAc,eAAe,CAAC;AAC9B,OAAO,EACL,KAAK,EACL,OAAO,EACP,cAAc,EACd,cAAc,EACd,OAAO,GACR,MAAM,sBAAsB,CAAC","sourcesContent":["export * from './assert.js';\nexport * from './base64.js';\nexport * from './bytes.js';\nexport * from './caip-types.js';\nexport * from './checksum.js';\nexport * from './coercers.js';\nexport * from './collections.js';\nexport type * from './encryption-types.js';\nexport * from './errors.js';\nexport * from './hashing.js';\nexport type { Hex } from './hex.js';\nexport {\n HexStruct,\n StrictHexStruct,\n HexAddressStruct,\n HexChecksumAddressStruct,\n isHexString,\n isStrictHexString,\n isHexAddress,\n isHexChecksumAddress,\n assertIsHexString,\n assertIsStrictHexString,\n isValidHexAddress,\n getChecksumAddress,\n isValidChecksumAddress,\n add0x,\n remove0x,\n} from './hex.js';\nexport * from './json.js';\nexport type * from './keyring.js';\nexport * from './logging.js';\nexport * from './misc.js';\nexport * from './mnemonic.js';\nexport * from './number.js';\nexport type * from './opaque.js';\nexport * from './promise.js';\nexport * from './superstruct.js';\nexport * from './time.js';\nexport type * from './transaction-types.js';\nexport * from './versions.js';\nexport {\n toWei,\n fromWei,\n numberToString,\n getValueOfUnit,\n unitMap,\n} from './unitsConversion.js';\n"]}
@@ -1,6 +1,6 @@
1
- import { Struct } from "@metamask/superstruct";
2
- import type { Infer, ObjectSchema, Simplify, Optionalize } from "@metamask/superstruct";
3
- import type { AssertionErrorConstructor } from "./assert.cjs";
1
+ import { Struct } from '@metamask/superstruct';
2
+ import type { Infer, ObjectSchema, Simplify, Optionalize } from '@metamask/superstruct';
3
+ import type { AssertionErrorConstructor } from './assert.js';
4
4
  /**
5
5
  * Any JSON-compatible value.
6
6
  */
@@ -41,7 +41,7 @@ export type ObjectType<Schema extends ObjectSchema> = Simplify<ObjectOptional<Op
41
41
  * @param schema - The schema of the object.
42
42
  * @returns A struct to check if the given value is an object.
43
43
  */
44
- export declare const object: <Schema extends ObjectSchema>(schema: Schema) => Struct<Simplify<ObjectOptional<Optionalize<{ [Key in keyof Schema]: Infer<Schema[Key]>; }>>>, unknown>;
44
+ export declare const object: <Schema extends ObjectSchema>(schema: Schema) => Struct<ObjectType<Schema>>;
45
45
  declare const exactOptionalSymbol: unique symbol;
46
46
  type ExactOptionalGuard = {
47
47
  _exactOptionalGuard?: typeof exactOptionalSymbol;
@@ -120,7 +120,7 @@ export declare function getJsonSize(value: unknown): number;
120
120
  /**
121
121
  * The string '2.0'.
122
122
  */
123
- export declare const jsonrpc2: "2.0";
123
+ export declare const jsonrpc2: '2.0';
124
124
  export declare const JsonRpcVersionStruct: Struct<"2.0", "2.0">;
125
125
  /**
126
126
  * A String specifying the version of the JSON-RPC protocol.
@@ -136,10 +136,10 @@ export declare const JsonRpcIdStruct: Struct<string | number | null, null>;
136
136
  */
137
137
  export type JsonRpcId = Infer<typeof JsonRpcIdStruct>;
138
138
  export declare const JsonRpcErrorStruct: Struct<{
139
- data?: Json & ExactOptionalGuard;
140
- stack?: string;
141
139
  code: number;
142
140
  message: string;
141
+ data?: Json & ExactOptionalGuard;
142
+ stack?: string;
143
143
  }, unknown>;
144
144
  /**
145
145
  * Mark a certain key of a type as optional.
@@ -156,10 +156,10 @@ export type JsonRpcError = OptionalField<Infer<typeof JsonRpcErrorStruct>, 'data
156
156
  export declare const JsonRpcParamsStruct: Struct<Json[] | Record<string, Json>, null>;
157
157
  export type JsonRpcParams = Json[] | Record<string, Json>;
158
158
  export declare const JsonRpcRequestStruct: Struct<{
159
- params?: (Json[] | Record<string, Json>) & ExactOptionalGuard;
160
159
  id: string | number | null;
161
- method: string;
162
160
  jsonrpc: "2.0";
161
+ method: string;
162
+ params?: (Json[] | Record<string, Json>) & ExactOptionalGuard;
163
163
  }, unknown>;
164
164
  export type InferWithParams<Type extends Struct<any>, Params extends JsonRpcParams> = Infer<Type> & {
165
165
  params?: Params;
@@ -169,9 +169,9 @@ export type InferWithParams<Type extends Struct<any>, Params extends JsonRpcPara
169
169
  */
170
170
  export type JsonRpcRequest<Params extends JsonRpcParams = JsonRpcParams> = InferWithParams<typeof JsonRpcRequestStruct, Params>;
171
171
  export declare const JsonRpcNotificationStruct: Struct<{
172
- params?: (Json[] | Record<string, Json>) & ExactOptionalGuard;
173
- method: string;
174
172
  jsonrpc: "2.0";
173
+ method: string;
174
+ params?: (Json[] | Record<string, Json>) & ExactOptionalGuard;
175
175
  }, unknown>;
176
176
  /**
177
177
  * A JSON-RPC notification object.
@@ -215,20 +215,20 @@ export declare const PendingJsonRpcResponseStruct: Struct<{
215
215
  jsonrpc: "2.0";
216
216
  result: unknown;
217
217
  error?: {
218
- data?: Json & ExactOptionalGuard;
219
- stack?: string;
220
218
  code: number;
221
219
  message: string;
220
+ data?: Json & ExactOptionalGuard;
221
+ stack?: string;
222
222
  } | undefined;
223
223
  }, {
224
224
  id: Struct<string | number | null, null>;
225
225
  jsonrpc: Struct<"2.0", "2.0">;
226
226
  result: Struct<unknown, null>;
227
227
  error: Struct<{
228
- data?: Json & ExactOptionalGuard;
229
- stack?: string;
230
228
  code: number;
231
229
  message: string;
230
+ data?: Json & ExactOptionalGuard;
231
+ stack?: string;
232
232
  } | undefined, unknown>;
233
233
  }>;
234
234
  /**
@@ -249,14 +249,9 @@ export type JsonRpcSuccess<Result extends Json = Json> = Omit<Infer<typeof JsonR
249
249
  result: Result;
250
250
  };
251
251
  export declare const JsonRpcFailureStruct: Struct<{
252
- error: {
253
- data?: Json & ExactOptionalGuard;
254
- stack?: string;
255
- code: number;
256
- message: string;
257
- };
258
252
  id: string | number | null;
259
253
  jsonrpc: "2.0";
254
+ error: JsonRpcError;
260
255
  }, unknown>;
261
256
  /**
262
257
  * A failed JSON-RPC response object.
@@ -267,14 +262,9 @@ export declare const JsonRpcResponseStruct: Struct<{
267
262
  jsonrpc: "2.0";
268
263
  result: Json;
269
264
  } | {
270
- error: {
271
- data?: Json & ExactOptionalGuard;
272
- stack?: string;
273
- code: number;
274
- message: string;
275
- };
276
265
  id: string | number | null;
277
266
  jsonrpc: "2.0";
267
+ error: JsonRpcError;
278
268
  }, null>;
279
269
  /**
280
270
  * A JSON-RPC response object. Must be checked to determine whether it's a
@@ -393,6 +383,6 @@ type JsonRpcValidatorOptions = {
393
383
  * Default: `true`
394
384
  * @returns The JSON-RPC ID validator function.
395
385
  */
396
- export declare function getJsonRpcIdValidator(options?: JsonRpcValidatorOptions): (id: unknown) => id is string | number | null;
386
+ export declare function getJsonRpcIdValidator(options?: JsonRpcValidatorOptions): (id: unknown) => id is JsonRpcId;
397
387
  export {};
398
- //# sourceMappingURL=json.d.cts.map
388
+ //# sourceMappingURL=json.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../src/json.ts"],"names":[],"mappings":"AAAA,OAAO,EAiBL,MAAM,EAEP,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAEV,KAAK,EACL,YAAY,EACZ,QAAQ,EACR,WAAW,EACZ,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAI7D;;GAEG;AACH,MAAM,MAAM,IAAI,GACZ,IAAI,GACJ,OAAO,GACP,MAAM,GACN,MAAM,GACN,IAAI,EAAE,GACN;IAAE,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC;AAE7B;;;;;;;;;;GAUG;AACH,MAAM,MAAM,cAAc,CAAC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI;KAClE,GAAG,IAAI,MAAM,MAAM,IAAI,MAAM,CAAC,GAAG,CAAC,SAAS,kBAAkB,GAC1D,GAAG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AAO,EACd,YAAY,CAAC,EAAE,yBAAyB,GACvC,OAAO,CAAC,KAAK,IAAI,cAAc,CAOjC;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAEpE;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,OAAO,EACd,YAAY,CAAC,EAAE,yBAAyB,GACvC,OAAO,CAAC,KAAK,IAAI,YAAY,CAO/B;AAED,KAAK,uBAAuB,GAAG;IAC7B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,CAAC,EAAE,uBAAuB,QAevC,OAAO,KAAG,EAAE,IAAI,SAAS,CASxD"}
@@ -1,6 +1,6 @@
1
- import { any, array, coerce, create, define, integer, is, literal, nullable, number, object as superstructObject, optional, record, string, union, unknown, Struct, refine } from "@metamask/superstruct";
2
- import { assertStruct } from "./assert.mjs";
3
- import { hasProperty } from "./misc.mjs";
1
+ import { any, array, coerce, create, define, integer, is, literal, nullable, number, object as superstructObject, optional, record, string, union, unknown, Struct, refine, } from '@metamask/superstruct';
2
+ import { assertStruct } from './assert.js';
3
+ import { hasProperty } from './misc.js';
4
4
  /**
5
5
  * A struct to check if the given value is a valid object, with support for
6
6
  * {@link exactOptional} types.
@@ -247,6 +247,7 @@ export const JsonRpcSuccessStruct = object({
247
247
  export const JsonRpcFailureStruct = object({
248
248
  id: JsonRpcIdStruct,
249
249
  jsonrpc: JsonRpcVersionStruct,
250
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion -- The assertion does not change assignability, but it does pin the emitted declaration to the named `JsonRpcError`. Without it TypeScript inlines the structure and leaks the unexported `ExactOptionalGuard` into the published types.
250
251
  error: JsonRpcErrorStruct,
251
252
  });
252
253
  export const JsonRpcResponseStruct = union([
@@ -399,4 +400,4 @@ export function getJsonRpcIdValidator(options) {
399
400
  };
400
401
  return isValidJsonRpcId;
401
402
  }
402
- //# sourceMappingURL=json.mjs.map
403
+ //# sourceMappingURL=json.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json.js","sourceRoot":"","sources":["../src/json.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,GAAG,EACH,KAAK,EACL,MAAM,EACN,MAAM,EACN,MAAM,EACN,OAAO,EACP,EAAE,EACF,OAAO,EACP,QAAQ,EACR,MAAM,EACN,MAAM,IAAI,iBAAiB,EAC3B,QAAQ,EACR,MAAM,EACN,MAAM,EACN,KAAK,EACL,OAAO,EACP,MAAM,EACN,MAAM,GACP,MAAM,uBAAuB,CAAC;AAU/B,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAmDxC;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CACpB,MAAc,EACc,EAAE;AAC9B,0EAA0E;AAC1E,2EAA2E;AAC3E,2DAA2D;AAC3D,iBAAiB,CAAC,MAAM,CAA0C,CAAC;AAQrE;;;;;;;GAOG;AACH,SAAS,WAAW,CAAC,EAAE,IAAI,EAAE,MAAM,EAAW;IAC5C,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACpC,OAAO,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;AACvD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,aAAa,CAC3B,MAA4B;IAE5B,OAAO,IAAI,MAAM,CAAoC;QACnD,GAAG,MAAM;QAET,IAAI,EAAE,YAAY,MAAM,CAAC,IAAI,EAAE;QAC/B,SAAS,EAA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AACH,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,OAAO,EAAE,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC;AACvC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAClC,KAAc,EACd,YAAwC;IAExC,YAAY,CACV,KAAK,EACL,kBAAkB,EAClB,wBAAwB,EACxB,YAAY,CACb,CAAC;AACJ,CAAC;AAQD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAAiC;IACrE,MAAM,EAAE,iBAAiB,EAAE,eAAe,EAAE,UAAU,EAAE,GAAG;QACzD,iBAAiB,EAAE,IAAI;QACvB,eAAe,EAAE,KAAK;QACtB,UAAU,EAAE,IAAI;QAChB,GAAG,OAAO;KACX,CAAC;IAEF;;;;;;OAMG;IACH,MAAM,gBAAgB,GAAG,CAAC,EAAW,EAAmB,EAAE;QACxD,OAAO,OAAO,CACZ,CAAC,OAAO,EAAE,KAAK,QAAQ,IAAI,CAAC,eAAe,IAAI,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;YACrE,CAAC,OAAO,EAAE,KAAK,QAAQ,IAAI,CAAC,iBAAiB,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YAChE,CAAC,UAAU,IAAI,EAAE,KAAK,IAAI,CAAC,CAC5B,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,gBAAgB,CAAC;AAC1B,CAAC","sourcesContent":["import {\n any,\n array,\n coerce,\n create,\n define,\n integer,\n is,\n literal,\n nullable,\n number,\n object as superstructObject,\n optional,\n record,\n string,\n union,\n unknown,\n Struct,\n refine,\n} from '@metamask/superstruct';\nimport type {\n Context,\n Infer,\n ObjectSchema,\n Simplify,\n Optionalize,\n} from '@metamask/superstruct';\n\nimport type { AssertionErrorConstructor } from './assert.js';\nimport { assertStruct } from './assert.js';\nimport { hasProperty } from './misc.js';\n\n/**\n * Any JSON-compatible value.\n */\nexport type Json =\n | null\n | boolean\n | number\n | string\n | Json[]\n | { [prop: string]: Json };\n\n/**\n * A helper type to make properties with `undefined` in their type optional, but\n * not `undefined` itself.\n *\n * @deprecated Use `ObjectType` and/or `ExactOptionalize` from `@metamask/superstruct@>=3.2.0` instead.\n * @example\n * ```ts\n * type Foo = ObjectOptional<{ foo: string | undefined }>;\n * // Foo is equivalent to { foo?: string }\n * ```\n */\nexport type ObjectOptional<Schema extends Record<string, unknown>> = {\n [Key in keyof Schema as Schema[Key] extends ExactOptionalGuard\n ? Key\n : never]?: Schema[Key] extends ExactOptionalGuard & (infer Original)\n ? Original\n : never;\n} & {\n [Key in keyof Schema as Schema[Key] extends ExactOptionalGuard\n ? never\n : Key]: Schema[Key];\n};\n\n/**\n * An object type with support for exact optionals. This is used by the `object`\n * struct. This uses the {@link ObjectOptional} helper to make properties with\n * `undefined` in their type optional, but not `undefined` itself.\n *\n * @deprecated Use `ObjectType` from `@metamask/superstruct@>=3.2.0` instead.\n */\nexport type ObjectType<Schema extends ObjectSchema> = Simplify<\n ObjectOptional<\n Optionalize<{\n [Key in keyof Schema]: Infer<Schema[Key]>;\n }>\n >\n>;\n\n/**\n * A struct to check if the given value is a valid object, with support for\n * {@link exactOptional} types.\n *\n * @deprecated Use `exactOptional` and `object` from `@metamask/superstruct@>=3.2.0` instead.\n * @param schema - The schema of the object.\n * @returns A struct to check if the given value is an object.\n */\nexport const object = <Schema extends ObjectSchema>(\n schema: Schema,\n): Struct<ObjectType<Schema>> =>\n // The type is slightly different from a regular object struct, because we\n // want to make properties with `undefined` in their type optional, but not\n // `undefined` itself. This means that we need a type cast.\n superstructObject(schema) as unknown as Struct<ObjectType<Schema>>;\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars -- Branding symbol for the opaque guard type; used only via `typeof`.\ndeclare const exactOptionalSymbol: unique symbol;\ntype ExactOptionalGuard = {\n _exactOptionalGuard?: typeof exactOptionalSymbol;\n};\n\n/**\n * Check the last field of a path is present.\n *\n * @param context - The context to check.\n * @param context.path - The path to check.\n * @param context.branch - The branch to check.\n * @returns Whether the last field of a path is present.\n */\nfunction hasOptional({ path, branch }: Context): boolean {\n const field = path[path.length - 1];\n return hasProperty(branch[branch.length - 2], field);\n}\n\n/**\n * A struct which allows the property of an object to be absent, or to be present\n * as long as it's valid and not set to `undefined`.\n *\n * This struct should be used in conjunction with the {@link object} from this\n * library, to get proper type inference.\n *\n * @deprecated Use `exactOptional` and `object` from `@metamask/superstruct@>=3.2.0` instead.\n * @param struct - The struct to check the value against, if present.\n * @returns A struct to check if the given value is valid, or not present.\n * @example\n * ```ts\n * const struct = object({\n * foo: exactOptional(string()),\n * bar: exactOptional(number()),\n * baz: optional(boolean()),\n * qux: unknown(),\n * });\n *\n * type Type = Infer<typeof struct>;\n * // Type is equivalent to:\n * // {\n * // foo?: string;\n * // bar?: number;\n * // baz?: boolean | undefined;\n * // qux: unknown;\n * // }\n * ```\n */\nexport function exactOptional<Type, Schema>(\n struct: Struct<Type, Schema>,\n): Struct<Type & ExactOptionalGuard, Schema> {\n return new Struct<Type & ExactOptionalGuard, Schema>({\n ...struct,\n\n type: `optional ${struct.type}`,\n validator: (value, context) =>\n !hasOptional(context) || struct.validator(value, context),\n\n refiner: (value, context) =>\n !hasOptional(context) || struct.refiner(value, context),\n });\n}\n\n/**\n * Validate an unknown input to be valid JSON.\n *\n * Useful for constructing JSON structs.\n *\n * @param json - An unknown value.\n * @returns True if the value is valid JSON, otherwise false.\n */\nfunction validateJson(json: unknown): boolean {\n if (json === null || typeof json === 'boolean' || typeof json === 'string') {\n return true;\n }\n\n if (typeof json === 'number' && Number.isFinite(json)) {\n return true;\n }\n\n if (typeof json === 'object') {\n let every = true;\n if (Array.isArray(json)) {\n // Ignoring linting error since for-of is significantly slower than a normal for-loop\n // and performance is important in this specific function.\n // eslint-disable-next-line @typescript-eslint/prefer-for-of\n for (let i = 0; i < json.length; i++) {\n if (!validateJson(json[i])) {\n every = false;\n break;\n }\n }\n return every;\n }\n\n const entries = Object.entries(json);\n // Ignoring linting errors since for-of is significantly slower than a normal for-loop\n // and performance is important in this specific function.\n // eslint-disable-next-line @typescript-eslint/prefer-for-of\n for (let i = 0; i < entries.length; i++) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n if (typeof entries[i]![0] !== 'string' || !validateJson(entries[i]![1])) {\n every = false;\n break;\n }\n }\n return every;\n }\n\n return false;\n}\n\n/**\n * A struct to check if the given value is a valid JSON-serializable value.\n *\n * Note that this struct is unsafe. For safe validation, use {@link JsonStruct}.\n */\nexport const UnsafeJsonStruct: Struct<Json> = define('JSON', (json) =>\n validateJson(json),\n);\n\n/**\n * A struct to check if the given value is a valid JSON-serializable value.\n *\n * This struct sanitizes the value before validating it, so that it is safe to\n * use with untrusted input.\n */\nexport const JsonStruct = coerce(\n UnsafeJsonStruct,\n refine(any(), 'JSON', (value) => is(value, UnsafeJsonStruct)),\n (value) =>\n JSON.parse(\n JSON.stringify(value, (propKey, propValue) => {\n // Strip __proto__ and constructor properties to prevent prototype pollution.\n if (propKey === '__proto__' || propKey === 'constructor') {\n return undefined;\n }\n return propValue;\n }),\n ),\n);\n\n/**\n * Check if the given value is a valid {@link Json} value, i.e., a value that is\n * serializable to JSON.\n *\n * @param value - The value to check.\n * @returns Whether the value is a valid {@link Json} value.\n */\nexport function isValidJson(value: unknown): value is Json {\n try {\n getSafeJson(value);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Validate and return sanitized JSON.\n *\n * Note:\n * This function uses sanitized JsonStruct for validation\n * that applies stringify and then parse of a value provided\n * to ensure that there are no getters which can have side effects\n * that can cause security issues.\n *\n * @param value - JSON structure to be processed.\n * @returns Sanitized JSON structure.\n */\nexport function getSafeJson<Type extends Json = Json>(value: unknown): Type {\n return create(value, JsonStruct) as Type;\n}\n\n/**\n * Get the size of a JSON value in bytes. This also validates the value.\n *\n * @param value - The JSON value to get the size of.\n * @returns The size of the JSON value in bytes.\n */\nexport function getJsonSize(value: unknown): number {\n assertStruct(value, JsonStruct, 'Invalid JSON value');\n\n const json = JSON.stringify(value);\n return new TextEncoder().encode(json).byteLength;\n}\n\n/**\n * The string '2.0'.\n */\nexport const jsonrpc2 = '2.0' as const;\nexport const JsonRpcVersionStruct = literal(jsonrpc2);\n\n/**\n * A String specifying the version of the JSON-RPC protocol.\n * MUST be exactly \"2.0\".\n */\nexport type JsonRpcVersion2 = typeof jsonrpc2;\n\nexport const JsonRpcIdStruct = nullable(union([number(), string()]));\n\n/**\n * An identifier established by the Client that MUST contain a String, Number,\n * or NULL value if included. If it is not included it is assumed to be a\n * notification. The value SHOULD normally not be Null and Numbers SHOULD\n * NOT contain fractional parts.\n */\nexport type JsonRpcId = Infer<typeof JsonRpcIdStruct>;\n\nexport const JsonRpcErrorStruct = object({\n code: integer(),\n message: string(),\n data: exactOptional(JsonStruct),\n stack: exactOptional(string()),\n});\n\n/**\n * Mark a certain key of a type as optional.\n */\nexport type OptionalField<\n Type extends Record<string, unknown>,\n Key extends keyof Type,\n> = Omit<Type, Key> & Partial<Pick<Type, Key>>;\n\n/**\n * A JSON-RPC error object.\n *\n * Note that TypeScript infers `unknown | undefined` as `unknown`, meaning that\n * the `data` field is not optional. To make it optional, we use the\n * `OptionalField` helper, to explicitly make it optional.\n */\nexport type JsonRpcError = OptionalField<\n Infer<typeof JsonRpcErrorStruct>,\n 'data'\n>;\n\nexport const JsonRpcParamsStruct: Struct<Json[] | Record<string, Json>, null> =\n union([record(string(), JsonStruct), array(JsonStruct)]);\n\nexport type JsonRpcParams = Json[] | Record<string, Json>;\n\nexport const JsonRpcRequestStruct = object({\n id: JsonRpcIdStruct,\n jsonrpc: JsonRpcVersionStruct,\n method: string(),\n params: exactOptional(JsonRpcParamsStruct),\n});\n\nexport type InferWithParams<\n Type extends Struct<any>,\n Params extends JsonRpcParams,\n> = Infer<Type> & {\n params?: Params;\n};\n\n/**\n * A JSON-RPC request object.\n */\nexport type JsonRpcRequest<Params extends JsonRpcParams = JsonRpcParams> =\n InferWithParams<typeof JsonRpcRequestStruct, Params>;\n\nexport const JsonRpcNotificationStruct = object({\n jsonrpc: JsonRpcVersionStruct,\n method: string(),\n params: exactOptional(JsonRpcParamsStruct),\n});\n\n/**\n * A JSON-RPC notification object.\n */\nexport type JsonRpcNotification<Params extends JsonRpcParams = JsonRpcParams> =\n InferWithParams<typeof JsonRpcNotificationStruct, Params>;\n\n/**\n * Check if the given value is a valid {@link JsonRpcNotification} object.\n *\n * @param value - The value to check.\n * @returns Whether the given value is a valid {@link JsonRpcNotification}\n * object.\n */\nexport function isJsonRpcNotification(\n value: unknown,\n): value is JsonRpcNotification {\n return is(value, JsonRpcNotificationStruct);\n}\n\n/**\n * Assert that the given value is a valid {@link JsonRpcNotification} object.\n *\n * @param value - The value to check.\n * @param ErrorWrapper - The error class to throw if the assertion fails.\n * Defaults to {@link AssertionError}.\n * @throws If the given value is not a valid {@link JsonRpcNotification} object.\n */\nexport function assertIsJsonRpcNotification(\n value: unknown,\n ErrorWrapper?: AssertionErrorConstructor,\n): asserts value is JsonRpcNotification {\n assertStruct(\n value,\n JsonRpcNotificationStruct,\n 'Invalid JSON-RPC notification',\n ErrorWrapper,\n );\n}\n\n/**\n * Check if the given value is a valid {@link JsonRpcRequest} object.\n *\n * @param value - The value to check.\n * @returns Whether the given value is a valid {@link JsonRpcRequest} object.\n */\nexport function isJsonRpcRequest(value: unknown): value is JsonRpcRequest {\n return is(value, JsonRpcRequestStruct);\n}\n\n/**\n * Assert that the given value is a valid {@link JsonRpcRequest} object.\n *\n * @param value - The JSON-RPC request or notification to check.\n * @param ErrorWrapper - The error class to throw if the assertion fails.\n * Defaults to {@link AssertionError}.\n * @throws If the given value is not a valid {@link JsonRpcRequest} object.\n */\nexport function assertIsJsonRpcRequest(\n value: unknown,\n ErrorWrapper?: AssertionErrorConstructor,\n): asserts value is JsonRpcRequest {\n assertStruct(\n value,\n JsonRpcRequestStruct,\n 'Invalid JSON-RPC request',\n ErrorWrapper,\n );\n}\n\nexport const PendingJsonRpcResponseStruct = superstructObject({\n id: JsonRpcIdStruct,\n jsonrpc: JsonRpcVersionStruct,\n result: optional(unknown()),\n error: optional(JsonRpcErrorStruct),\n});\n\n/**\n * A JSON-RPC response object that has not yet been resolved.\n */\nexport type PendingJsonRpcResponse<Result extends Json = Json> = Omit<\n Infer<typeof PendingJsonRpcResponseStruct>,\n 'result'\n> & {\n result?: Result;\n};\n\nexport const JsonRpcSuccessStruct = object({\n id: JsonRpcIdStruct,\n jsonrpc: JsonRpcVersionStruct,\n result: JsonStruct,\n});\n\n/**\n * A successful JSON-RPC response object.\n */\nexport type JsonRpcSuccess<Result extends Json = Json> = Omit<\n Infer<typeof JsonRpcSuccessStruct>,\n 'result'\n> & {\n result: Result;\n};\n\nexport const JsonRpcFailureStruct = object({\n id: JsonRpcIdStruct,\n jsonrpc: JsonRpcVersionStruct,\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion -- The assertion does not change assignability, but it does pin the emitted declaration to the named `JsonRpcError`. Without it TypeScript inlines the structure and leaks the unexported `ExactOptionalGuard` into the published types.\n error: JsonRpcErrorStruct as Struct<JsonRpcError>,\n});\n\n/**\n * A failed JSON-RPC response object.\n */\nexport type JsonRpcFailure = Infer<typeof JsonRpcFailureStruct>;\n\nexport const JsonRpcResponseStruct = union([\n JsonRpcSuccessStruct,\n JsonRpcFailureStruct,\n]);\n\n/**\n * A JSON-RPC response object. Must be checked to determine whether it's a\n * success or failure.\n *\n * @template Result - The type of the result.\n */\nexport type JsonRpcResponse<Result extends Json = Json> =\n | JsonRpcSuccess<Result>\n | JsonRpcFailure;\n\n/**\n * Type guard to check whether specified JSON-RPC response is a\n * {@link PendingJsonRpcResponse}.\n *\n * @param response - The JSON-RPC response to check.\n * @returns Whether the specified JSON-RPC response is pending.\n */\nexport function isPendingJsonRpcResponse(\n response: unknown,\n): response is PendingJsonRpcResponse {\n return is(response, PendingJsonRpcResponseStruct);\n}\n\n/**\n * Assert that the given value is a valid {@link PendingJsonRpcResponse} object.\n *\n * @param response - The JSON-RPC response to check.\n * @param ErrorWrapper - The error class to throw if the assertion fails.\n * Defaults to {@link AssertionError}.\n * @throws If the given value is not a valid {@link PendingJsonRpcResponse}\n * object.\n */\nexport function assertIsPendingJsonRpcResponse(\n response: unknown,\n ErrorWrapper?: AssertionErrorConstructor,\n): asserts response is PendingJsonRpcResponse {\n assertStruct(\n response,\n PendingJsonRpcResponseStruct,\n 'Invalid pending JSON-RPC response',\n ErrorWrapper,\n );\n}\n\n/**\n * Type guard to check if a value is a {@link JsonRpcResponse}.\n *\n * @param response - The object to check.\n * @returns Whether the object is a JsonRpcResponse.\n */\nexport function isJsonRpcResponse(\n response: unknown,\n): response is JsonRpcResponse {\n return is(response, JsonRpcResponseStruct);\n}\n\n/**\n * Assert that the given value is a valid {@link JsonRpcResponse} object.\n *\n * @param value - The value to check.\n * @param ErrorWrapper - The error class to throw if the assertion fails.\n * Defaults to {@link AssertionError}.\n * @throws If the given value is not a valid {@link JsonRpcResponse} object.\n */\nexport function assertIsJsonRpcResponse(\n value: unknown,\n ErrorWrapper?: AssertionErrorConstructor,\n): asserts value is JsonRpcResponse {\n assertStruct(\n value,\n JsonRpcResponseStruct,\n 'Invalid JSON-RPC response',\n ErrorWrapper,\n );\n}\n\n/**\n * Check if the given value is a valid {@link JsonRpcSuccess} object.\n *\n * @param value - The value to check.\n * @returns Whether the given value is a valid {@link JsonRpcSuccess} object.\n */\nexport function isJsonRpcSuccess(value: unknown): value is JsonRpcSuccess {\n return is(value, JsonRpcSuccessStruct);\n}\n\n/**\n * Assert that the given value is a valid {@link JsonRpcSuccess} object.\n *\n * @param value - The value to check.\n * @param ErrorWrapper - The error class to throw if the assertion fails.\n * Defaults to {@link AssertionError}.\n * @throws If the given value is not a valid {@link JsonRpcSuccess} object.\n */\nexport function assertIsJsonRpcSuccess(\n value: unknown,\n ErrorWrapper?: AssertionErrorConstructor,\n): asserts value is JsonRpcSuccess {\n assertStruct(\n value,\n JsonRpcSuccessStruct,\n 'Invalid JSON-RPC success response',\n ErrorWrapper,\n );\n}\n\n/**\n * Check if the given value is a valid {@link JsonRpcFailure} object.\n *\n * @param value - The value to check.\n * @returns Whether the given value is a valid {@link JsonRpcFailure} object.\n */\nexport function isJsonRpcFailure(value: unknown): value is JsonRpcFailure {\n return is(value, JsonRpcFailureStruct);\n}\n\n/**\n * Assert that the given value is a valid {@link JsonRpcFailure} object.\n *\n * @param value - The value to check.\n * @param ErrorWrapper - The error class to throw if the assertion fails.\n * Defaults to {@link AssertionError}.\n * @throws If the given value is not a valid {@link JsonRpcFailure} object.\n */\nexport function assertIsJsonRpcFailure(\n value: unknown,\n ErrorWrapper?: AssertionErrorConstructor,\n): asserts value is JsonRpcFailure {\n assertStruct(\n value,\n JsonRpcFailureStruct,\n 'Invalid JSON-RPC failure response',\n ErrorWrapper,\n );\n}\n\n/**\n * Check if the given value is a valid {@link JsonRpcError} object.\n *\n * @param value - The value to check.\n * @returns Whether the given value is a valid {@link JsonRpcError} object.\n */\nexport function isJsonRpcError(value: unknown): value is JsonRpcError {\n return is(value, JsonRpcErrorStruct);\n}\n\n/**\n * Assert that the given value is a valid {@link JsonRpcError} object.\n *\n * @param value - The value to check.\n * @param ErrorWrapper - The error class to throw if the assertion fails.\n * Defaults to {@link AssertionError}.\n * @throws If the given value is not a valid {@link JsonRpcError} object.\n */\nexport function assertIsJsonRpcError(\n value: unknown,\n ErrorWrapper?: AssertionErrorConstructor,\n): asserts value is JsonRpcError {\n assertStruct(\n value,\n JsonRpcErrorStruct,\n 'Invalid JSON-RPC error',\n ErrorWrapper,\n );\n}\n\ntype JsonRpcValidatorOptions = {\n permitEmptyString?: boolean;\n permitFractions?: boolean;\n permitNull?: boolean;\n};\n\n/**\n * Gets a function for validating JSON-RPC request / response `id` values.\n *\n * By manipulating the options of this factory, you can control the behavior\n * of the resulting validator for some edge cases. This is useful because e.g.\n * `null` should sometimes but not always be permitted.\n *\n * Note that the empty string (`''`) is always permitted by the JSON-RPC\n * specification, but that kind of sucks and you may want to forbid it in some\n * instances anyway.\n *\n * For more details, see the\n * [JSON-RPC Specification](https://www.jsonrpc.org/specification).\n *\n * @param options - An options object.\n * @param options.permitEmptyString - Whether the empty string (i.e. `''`)\n * should be treated as a valid ID. Default: `true`\n * @param options.permitFractions - Whether fractional numbers (e.g. `1.2`)\n * should be treated as valid IDs. Default: `false`\n * @param options.permitNull - Whether `null` should be treated as a valid ID.\n * Default: `true`\n * @returns The JSON-RPC ID validator function.\n */\nexport function getJsonRpcIdValidator(options?: JsonRpcValidatorOptions) {\n const { permitEmptyString, permitFractions, permitNull } = {\n permitEmptyString: true,\n permitFractions: false,\n permitNull: true,\n ...options,\n };\n\n /**\n * Type guard for {@link JsonRpcId}.\n *\n * @param id - The JSON-RPC ID value to check.\n * @returns Whether the given ID is valid per the options given to the\n * factory.\n */\n const isValidJsonRpcId = (id: unknown): id is JsonRpcId => {\n return Boolean(\n (typeof id === 'number' && (permitFractions || Number.isInteger(id))) ||\n (typeof id === 'string' && (permitEmptyString || id.length > 0)) ||\n (permitNull && id === null),\n );\n };\n\n return isValidJsonRpcId;\n}\n"]}
@@ -1,7 +1,7 @@
1
- import type { TypedTransaction, LegacyTxData } from "@ethereumjs/tx";
2
- import type { Eip1024EncryptedData } from "./encryption-types.mjs";
3
- import type { Hex } from "./hex.mjs";
4
- import type { Json } from "./json.mjs";
1
+ import type { TypedTransaction, LegacyTxData } from '@ethereumjs/tx';
2
+ import type { Eip1024EncryptedData } from './encryption-types.js';
3
+ import type { Hex } from './hex.js';
4
+ import type { Json } from './json.js';
5
5
  /**
6
6
  * A Keyring class.
7
7
  *
@@ -240,4 +240,4 @@ export type Keyring<State extends Json> = {
240
240
  */
241
241
  destroy?(): Promise<void>;
242
242
  };
243
- //# sourceMappingURL=keyring.d.mts.map
243
+ //# sourceMappingURL=keyring.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyring.d.ts","sourceRoot":"","sources":["../src/keyring.ts"],"names":[],"mappings":"AA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