@metamask/utils 8.0.0 → 8.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (272) hide show
  1. package/CHANGELOG.md +25 -1
  2. package/dist/assert.js +16 -0
  3. package/dist/assert.js.map +1 -0
  4. package/dist/assert.mjs +16 -0
  5. package/dist/assert.mjs.map +1 -0
  6. package/dist/base64.js +11 -0
  7. package/dist/base64.js.map +1 -0
  8. package/dist/base64.mjs +11 -0
  9. package/dist/base64.mjs.map +1 -0
  10. package/dist/bytes.js +43 -0
  11. package/dist/bytes.js.map +1 -0
  12. package/dist/bytes.mjs +43 -0
  13. package/dist/bytes.mjs.map +1 -0
  14. package/dist/caip-types.js +40 -0
  15. package/dist/caip-types.js.map +1 -0
  16. package/dist/caip-types.mjs +40 -0
  17. package/dist/caip-types.mjs.map +1 -0
  18. package/dist/checksum.js +12 -0
  19. package/dist/checksum.js.map +1 -0
  20. package/dist/checksum.mjs +12 -0
  21. package/dist/checksum.mjs.map +1 -0
  22. package/dist/chunk-2CY4F77D.mjs +95 -0
  23. package/dist/chunk-2CY4F77D.mjs.map +1 -0
  24. package/dist/chunk-2LBGT4GH.js +15 -0
  25. package/dist/chunk-2LBGT4GH.js.map +1 -0
  26. package/dist/chunk-2TBCL6EF.js +1 -0
  27. package/dist/chunk-2TBCL6EF.js.map +1 -0
  28. package/dist/chunk-3W5G4CYI.js +25 -0
  29. package/dist/chunk-3W5G4CYI.js.map +1 -0
  30. package/dist/chunk-4JNG5UTO.js +44 -0
  31. package/dist/chunk-4JNG5UTO.js.map +1 -0
  32. package/dist/chunk-4RMX5YWE.js +34 -0
  33. package/dist/chunk-4RMX5YWE.js.map +1 -0
  34. package/dist/chunk-5WQRFJVQ.js +257 -0
  35. package/dist/chunk-5WQRFJVQ.js.map +1 -0
  36. package/dist/chunk-65KBH4FZ.mjs +257 -0
  37. package/dist/chunk-65KBH4FZ.mjs.map +1 -0
  38. package/dist/chunk-7S5AWFX7.mjs +61 -0
  39. package/dist/chunk-7S5AWFX7.mjs.map +1 -0
  40. package/dist/chunk-AY6FDCBT.mjs +1 -0
  41. package/dist/chunk-AY6FDCBT.mjs.map +1 -0
  42. package/dist/chunk-BKR45GQY.mjs +273 -0
  43. package/dist/chunk-BKR45GQY.mjs.map +1 -0
  44. package/dist/chunk-CSDMTDND.mjs +59 -0
  45. package/dist/chunk-CSDMTDND.mjs.map +1 -0
  46. package/dist/chunk-DMPG3H3G.js +61 -0
  47. package/dist/chunk-DMPG3H3G.js.map +1 -0
  48. package/dist/chunk-DYMCEQIV.mjs +1 -0
  49. package/dist/chunk-DYMCEQIV.mjs.map +1 -0
  50. package/dist/chunk-EQMZL4XU.js +1 -0
  51. package/dist/chunk-EQMZL4XU.js.map +1 -0
  52. package/dist/chunk-G66TREC6.mjs +69 -0
  53. package/dist/chunk-G66TREC6.mjs.map +1 -0
  54. package/dist/chunk-H4YFDLB7.mjs +70 -0
  55. package/dist/chunk-H4YFDLB7.mjs.map +1 -0
  56. package/dist/chunk-HLDWS2JR.mjs +35 -0
  57. package/dist/chunk-HLDWS2JR.mjs.map +1 -0
  58. package/dist/chunk-I575FZFH.mjs +1 -0
  59. package/dist/chunk-I575FZFH.mjs.map +1 -0
  60. package/dist/chunk-JCYFTGED.js +95 -0
  61. package/dist/chunk-JCYFTGED.js.map +1 -0
  62. package/dist/chunk-JPAL7Q5S.mjs +90 -0
  63. package/dist/chunk-JPAL7Q5S.mjs.map +1 -0
  64. package/dist/chunk-LC2CRSWD.js +1 -0
  65. package/dist/chunk-LC2CRSWD.js.map +1 -0
  66. package/dist/chunk-N53OILN6.mjs +16 -0
  67. package/dist/chunk-N53OILN6.mjs.map +1 -0
  68. package/dist/chunk-QVEKZRZ2.js +70 -0
  69. package/dist/chunk-QVEKZRZ2.js.map +1 -0
  70. package/dist/chunk-RIRDOQPX.mjs +15 -0
  71. package/dist/chunk-RIRDOQPX.mjs.map +1 -0
  72. package/dist/chunk-RKRGAFXY.js +1 -0
  73. package/dist/chunk-RKRGAFXY.js.map +1 -0
  74. package/dist/chunk-RRYOWRCV.mjs +1 -0
  75. package/dist/chunk-RRYOWRCV.mjs.map +1 -0
  76. package/dist/chunk-TGOMTREC.mjs +75 -0
  77. package/dist/chunk-TGOMTREC.mjs.map +1 -0
  78. package/dist/chunk-THNLGEXV.mjs +34 -0
  79. package/dist/chunk-THNLGEXV.mjs.map +1 -0
  80. package/dist/chunk-U7ZUGCE7.js +75 -0
  81. package/dist/chunk-U7ZUGCE7.js.map +1 -0
  82. package/dist/chunk-UOTVU7OQ.js +1 -0
  83. package/dist/chunk-UOTVU7OQ.js.map +1 -0
  84. package/dist/chunk-VBYRLAP6.js +59 -0
  85. package/dist/chunk-VBYRLAP6.js.map +1 -0
  86. package/dist/chunk-VL5DYXC5.mjs +122 -0
  87. package/dist/chunk-VL5DYXC5.mjs.map +1 -0
  88. package/dist/chunk-VSEW3V2L.mjs +44 -0
  89. package/dist/chunk-VSEW3V2L.mjs.map +1 -0
  90. package/dist/chunk-WA4DHIND.mjs +1 -0
  91. package/dist/chunk-WA4DHIND.mjs.map +1 -0
  92. package/dist/chunk-WQDTPIQK.js +122 -0
  93. package/dist/chunk-WQDTPIQK.js.map +1 -0
  94. package/dist/chunk-WRBN6DWM.js +35 -0
  95. package/dist/chunk-WRBN6DWM.js.map +1 -0
  96. package/dist/chunk-X66SUIEF.mjs +25 -0
  97. package/dist/chunk-X66SUIEF.mjs.map +1 -0
  98. package/dist/chunk-XYYGZF5Y.js +16 -0
  99. package/dist/chunk-XYYGZF5Y.js.map +1 -0
  100. package/dist/chunk-YQJBIHC7.js +273 -0
  101. package/dist/chunk-YQJBIHC7.js.map +1 -0
  102. package/dist/chunk-Z2RGWDD7.js +90 -0
  103. package/dist/chunk-Z2RGWDD7.js.map +1 -0
  104. package/dist/chunk-ZRNIY7OW.js +69 -0
  105. package/dist/chunk-ZRNIY7OW.js.map +1 -0
  106. package/dist/coercers.js +18 -0
  107. package/dist/coercers.js.map +1 -0
  108. package/dist/coercers.mjs +18 -0
  109. package/dist/coercers.mjs.map +1 -0
  110. package/dist/collections.js +10 -0
  111. package/dist/collections.js.map +1 -0
  112. package/dist/collections.mjs +10 -0
  113. package/dist/collections.mjs.map +1 -0
  114. package/dist/encryption-types.js +2 -0
  115. package/dist/encryption-types.js.map +1 -0
  116. package/dist/encryption-types.mjs +2 -0
  117. package/dist/encryption-types.mjs.map +1 -0
  118. package/dist/errors.js +17 -0
  119. package/dist/errors.js.map +1 -0
  120. package/dist/errors.mjs +17 -0
  121. package/dist/errors.mjs.map +1 -0
  122. package/dist/fs.js +26 -0
  123. package/dist/fs.js.map +1 -0
  124. package/dist/fs.mjs +26 -0
  125. package/dist/fs.mjs.map +1 -0
  126. package/dist/hex.js +35 -0
  127. package/dist/hex.js.map +1 -0
  128. package/dist/hex.mjs +35 -0
  129. package/dist/hex.mjs.map +1 -0
  130. package/dist/index.js +289 -0
  131. package/dist/index.js.map +1 -0
  132. package/dist/index.mjs +289 -0
  133. package/dist/index.mjs.map +1 -0
  134. package/dist/json.js +75 -0
  135. package/dist/json.js.map +1 -0
  136. package/dist/json.mjs +75 -0
  137. package/dist/json.mjs.map +1 -0
  138. package/dist/keyring.js +2 -0
  139. package/dist/keyring.js.map +1 -0
  140. package/dist/keyring.mjs +2 -0
  141. package/dist/keyring.mjs.map +1 -0
  142. package/dist/logging.js +10 -0
  143. package/dist/logging.js.map +1 -0
  144. package/dist/logging.mjs +10 -0
  145. package/dist/logging.mjs.map +1 -0
  146. package/dist/misc.js +28 -0
  147. package/dist/misc.js.map +1 -0
  148. package/dist/misc.mjs +28 -0
  149. package/dist/misc.mjs.map +1 -0
  150. package/dist/node.js +309 -0
  151. package/dist/node.js.map +1 -0
  152. package/dist/node.mjs +309 -0
  153. package/dist/node.mjs.map +1 -0
  154. package/dist/number.js +18 -0
  155. package/dist/number.js.map +1 -0
  156. package/dist/number.mjs +18 -0
  157. package/dist/number.mjs.map +1 -0
  158. package/dist/opaque.js +2 -0
  159. package/dist/opaque.js.map +1 -0
  160. package/dist/opaque.mjs +2 -0
  161. package/dist/opaque.mjs.map +1 -0
  162. package/dist/time.js +12 -0
  163. package/dist/time.js.map +1 -0
  164. package/dist/time.mjs +12 -0
  165. package/dist/time.mjs.map +1 -0
  166. package/dist/transaction-types.js +2 -0
  167. package/dist/transaction-types.js.map +1 -0
  168. package/dist/transaction-types.mjs +2 -0
  169. package/dist/transaction-types.mjs.map +1 -0
  170. package/dist/types/assert.d.ts.map +1 -1
  171. package/dist/types/bytes.d.ts +14 -0
  172. package/dist/types/bytes.d.ts.map +1 -1
  173. package/dist/types/errors.d.ts +58 -0
  174. package/dist/types/errors.d.ts.map +1 -0
  175. package/dist/types/fs.d.ts +133 -0
  176. package/dist/types/fs.d.ts.map +1 -0
  177. package/dist/types/index.d.ts +1 -0
  178. package/dist/types/index.d.ts.map +1 -1
  179. package/dist/types/json.d.ts +83 -47
  180. package/dist/types/json.d.ts.map +1 -1
  181. package/dist/types/node.d.ts +3 -0
  182. package/dist/types/node.d.ts.map +1 -0
  183. package/dist/versions.js +27 -0
  184. package/dist/versions.js.map +1 -0
  185. package/dist/versions.mjs +27 -0
  186. package/dist/versions.mjs.map +1 -0
  187. package/package.json +21 -20
  188. package/dist/cjs/assert.js +0 -116
  189. package/dist/cjs/assert.js.map +0 -1
  190. package/dist/cjs/base64.js +0 -32
  191. package/dist/cjs/base64.js.map +0 -1
  192. package/dist/cjs/bytes.js +0 -255
  193. package/dist/cjs/bytes.js.map +0 -1
  194. package/dist/cjs/caip-types.js +0 -115
  195. package/dist/cjs/caip-types.js.map +0 -1
  196. package/dist/cjs/checksum.js +0 -17
  197. package/dist/cjs/checksum.js.map +0 -1
  198. package/dist/cjs/coercers.js +0 -96
  199. package/dist/cjs/coercers.js.map +0 -1
  200. package/dist/cjs/collections.js +0 -157
  201. package/dist/cjs/collections.js.map +0 -1
  202. package/dist/cjs/encryption-types.js +0 -6
  203. package/dist/cjs/encryption-types.js.map +0 -1
  204. package/dist/cjs/hex.js +0 -107
  205. package/dist/cjs/hex.js.map +0 -1
  206. package/dist/cjs/index.js +0 -37
  207. package/dist/cjs/index.js.map +0 -1
  208. package/dist/cjs/json.js +0 -263
  209. package/dist/cjs/json.js.map +0 -1
  210. package/dist/cjs/keyring.js +0 -6
  211. package/dist/cjs/keyring.js.map +0 -1
  212. package/dist/cjs/logging.js +0 -33
  213. package/dist/cjs/logging.js.map +0 -1
  214. package/dist/cjs/misc.js +0 -111
  215. package/dist/cjs/misc.js.map +0 -1
  216. package/dist/cjs/number.js +0 -52
  217. package/dist/cjs/number.js.map +0 -1
  218. package/dist/cjs/opaque.js +0 -8
  219. package/dist/cjs/opaque.js.map +0 -1
  220. package/dist/cjs/time.js +0 -63
  221. package/dist/cjs/time.js.map +0 -1
  222. package/dist/cjs/transaction-types.js +0 -6
  223. package/dist/cjs/transaction-types.js.map +0 -1
  224. package/dist/cjs/versions.js +0 -79
  225. package/dist/cjs/versions.js.map +0 -1
  226. package/dist/esm/assert.js +0 -133
  227. package/dist/esm/assert.js.map +0 -1
  228. package/dist/esm/base64.js +0 -28
  229. package/dist/esm/base64.js.map +0 -1
  230. package/dist/esm/bytes.js +0 -334
  231. package/dist/esm/bytes.js.map +0 -1
  232. package/dist/esm/caip-types.js +0 -99
  233. package/dist/esm/caip-types.js.map +0 -1
  234. package/dist/esm/checksum.js +0 -7
  235. package/dist/esm/checksum.js.map +0 -1
  236. package/dist/esm/coercers.js +0 -153
  237. package/dist/esm/coercers.js.map +0 -1
  238. package/dist/esm/collections.js +0 -140
  239. package/dist/esm/collections.js.map +0 -1
  240. package/dist/esm/encryption-types.js +0 -3
  241. package/dist/esm/encryption-types.js.map +0 -1
  242. package/dist/esm/hex.js +0 -108
  243. package/dist/esm/hex.js.map +0 -1
  244. package/dist/esm/index.js +0 -20
  245. package/dist/esm/index.js.map +0 -1
  246. package/dist/esm/json.js +0 -301
  247. package/dist/esm/json.js.map +0 -1
  248. package/dist/esm/keyring.js +0 -3
  249. package/dist/esm/keyring.js.map +0 -1
  250. package/dist/esm/logging.js +0 -34
  251. package/dist/esm/logging.js.map +0 -1
  252. package/dist/esm/misc.js +0 -129
  253. package/dist/esm/misc.js.map +0 -1
  254. package/dist/esm/number.js +0 -92
  255. package/dist/esm/number.js.map +0 -1
  256. package/dist/esm/opaque.js +0 -5
  257. package/dist/esm/opaque.js.map +0 -1
  258. package/dist/esm/package.json +0 -1
  259. package/dist/esm/time.js +0 -53
  260. package/dist/esm/time.js.map +0 -1
  261. package/dist/esm/transaction-types.js +0 -3
  262. package/dist/esm/transaction-types.js.map +0 -1
  263. package/dist/esm/versions.js +0 -78
  264. package/dist/esm/versions.js.map +0 -1
  265. package/dist/types/caip-types.test-d.d.ts +0 -2
  266. package/dist/types/caip-types.test-d.d.ts.map +0 -1
  267. package/dist/types/hex.test-d.d.ts +0 -2
  268. package/dist/types/hex.test-d.d.ts.map +0 -1
  269. package/dist/types/json.test-d.d.ts +0 -2
  270. package/dist/types/json.test-d.d.ts.map +0 -1
  271. package/dist/types/misc.test-d.d.ts +0 -2
  272. package/dist/types/misc.test-d.d.ts.map +0 -1
@@ -1,92 +0,0 @@
1
- import { assert } from './assert';
2
- import { add0x, assertIsHexString } from './hex';
3
- /**
4
- * Convert a number to a hexadecimal string. This verifies that the number is a
5
- * non-negative safe integer.
6
- *
7
- * To convert a `bigint` to a hexadecimal string instead, use
8
- * {@link bigIntToHex}.
9
- *
10
- * @example
11
- * ```typescript
12
- * numberToHex(0); // '0x0'
13
- * numberToHex(1); // '0x1'
14
- * numberToHex(16); // '0x10'
15
- * ```
16
- * @param value - The number to convert to a hexadecimal string.
17
- * @returns The hexadecimal string, with the "0x"-prefix.
18
- * @throws If the number is not a non-negative safe integer.
19
- */ export const numberToHex = (value)=>{
20
- assert(typeof value === 'number', 'Value must be a number.');
21
- assert(value >= 0, 'Value must be a non-negative number.');
22
- assert(Number.isSafeInteger(value), 'Value is not a safe integer. Use `bigIntToHex` instead.');
23
- return add0x(value.toString(16));
24
- };
25
- /**
26
- * Convert a `bigint` to a hexadecimal string. This verifies that the `bigint`
27
- * is a non-negative integer.
28
- *
29
- * To convert a number to a hexadecimal string instead, use {@link numberToHex}.
30
- *
31
- * @example
32
- * ```typescript
33
- * bigIntToHex(0n); // '0x0'
34
- * bigIntToHex(1n); // '0x1'
35
- * bigIntToHex(16n); // '0x10'
36
- * ```
37
- * @param value - The `bigint` to convert to a hexadecimal string.
38
- * @returns The hexadecimal string, with the "0x"-prefix.
39
- * @throws If the `bigint` is not a non-negative integer.
40
- */ export const bigIntToHex = (value)=>{
41
- assert(typeof value === 'bigint', 'Value must be a bigint.');
42
- assert(value >= 0, 'Value must be a non-negative bigint.');
43
- return add0x(value.toString(16));
44
- };
45
- /**
46
- * Convert a hexadecimal string to a number. This verifies that the string is a
47
- * valid hex string, and that the resulting number is a safe integer. Both
48
- * "0x"-prefixed and unprefixed strings are supported.
49
- *
50
- * To convert a hexadecimal string to a `bigint` instead, use
51
- * {@link hexToBigInt}.
52
- *
53
- * @example
54
- * ```typescript
55
- * hexToNumber('0x0'); // 0
56
- * hexToNumber('0x1'); // 1
57
- * hexToNumber('0x10'); // 16
58
- * ```
59
- * @param value - The hexadecimal string to convert to a number.
60
- * @returns The number.
61
- * @throws If the value is not a valid hexadecimal string, or if the resulting
62
- * number is not a safe integer.
63
- */ export const hexToNumber = (value)=>{
64
- assertIsHexString(value);
65
- // `parseInt` accepts values without the "0x"-prefix, whereas `Number` does
66
- // not. Using this is slightly faster than `Number(add0x(value))`.
67
- const numberValue = parseInt(value, 16);
68
- assert(Number.isSafeInteger(numberValue), 'Value is not a safe integer. Use `hexToBigInt` instead.');
69
- return numberValue;
70
- };
71
- /**
72
- * Convert a hexadecimal string to a `bigint`. This verifies that the string is
73
- * a valid hex string. Both "0x"-prefixed and unprefixed strings are supported.
74
- *
75
- * To convert a hexadecimal string to a number instead, use {@link hexToNumber}.
76
- *
77
- * @example
78
- * ```typescript
79
- * hexToBigInt('0x0'); // 0n
80
- * hexToBigInt('0x1'); // 1n
81
- * hexToBigInt('0x10'); // 16n
82
- * ```
83
- * @param value - The hexadecimal string to convert to a `bigint`.
84
- * @returns The `bigint`.
85
- * @throws If the value is not a valid hexadecimal string.
86
- */ export const hexToBigInt = (value)=>{
87
- assertIsHexString(value);
88
- // The `BigInt` constructor requires the "0x"-prefix to parse a hex string.
89
- return BigInt(add0x(value));
90
- };
91
-
92
- //# sourceMappingURL=number.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/number.ts"],"sourcesContent":["import { assert } from './assert';\nimport { add0x, assertIsHexString } from './hex';\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): string => {\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): string => {\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"],"names":["assert","add0x","assertIsHexString","numberToHex","value","Number","isSafeInteger","toString","bigIntToHex","hexToNumber","numberValue","parseInt","hexToBigInt","BigInt"],"mappings":"AAAA,SAASA,MAAM,QAAQ,WAAW;AAClC,SAASC,KAAK,EAAEC,iBAAiB,QAAQ,QAAQ;AAEjD;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,MAAMC,cAAc,CAACC;IAC1BJ,OAAO,OAAOI,UAAU,UAAU;IAClCJ,OAAOI,SAAS,GAAG;IACnBJ,OACEK,OAAOC,aAAa,CAACF,QACrB;IAGF,OAAOH,MAAMG,MAAMG,QAAQ,CAAC;AAC9B,EAAE;AAEF;;;;;;;;;;;;;;;CAeC,GACD,OAAO,MAAMC,cAAc,CAACJ;IAC1BJ,OAAO,OAAOI,UAAU,UAAU;IAClCJ,OAAOI,SAAS,GAAG;IAEnB,OAAOH,MAAMG,MAAMG,QAAQ,CAAC;AAC9B,EAAE;AAEF;;;;;;;;;;;;;;;;;;CAkBC,GACD,OAAO,MAAME,cAAc,CAACL;IAC1BF,kBAAkBE;IAElB,2EAA2E;IAC3E,kEAAkE;IAClE,MAAMM,cAAcC,SAASP,OAAO;IAEpCJ,OACEK,OAAOC,aAAa,CAACI,cACrB;IAGF,OAAOA;AACT,EAAE;AAEF;;;;;;;;;;;;;;;CAeC,GACD,OAAO,MAAME,cAAc,CAACR;IAC1BF,kBAAkBE;IAElB,2EAA2E;IAC3E,OAAOS,OAAOZ,MAAMG;AACtB,EAAE"}
@@ -1,5 +0,0 @@
1
- // We use a symbol property name instead of { _type: Brand }, because that would show up in IDE suggestions,
2
- // while internal symbols do not.
3
- export { };
4
-
5
- //# sourceMappingURL=opaque.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/opaque.ts"],"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"],"names":[],"mappings":"AAAA,4GAA4G;AAC5G,iCAAiC;AACjC,WAC2E"}
@@ -1 +0,0 @@
1
- {"type":"module"}
package/dist/esm/time.js DELETED
@@ -1,53 +0,0 @@
1
- /**
2
- * Common duration constants, in milliseconds.
3
- */ export var Duration;
4
- (function(Duration) {
5
- Duration[Duration[/**
6
- * A millisecond.
7
- */ "Millisecond"] = 1] = "Millisecond";
8
- Duration[Duration[/**
9
- * A second, in milliseconds.
10
- */ "Second"] = 1000] = "Second";
11
- Duration[Duration[/**
12
- * A minute, in milliseconds.
13
- */ "Minute"] = 60000] = "Minute";
14
- Duration[Duration[/**
15
- * An hour, in milliseconds.
16
- */ "Hour"] = 3600000] = "Hour";
17
- Duration[Duration[/**
18
- * A day, in milliseconds.
19
- */ "Day"] = 86400000] = "Day";
20
- Duration[Duration[/**
21
- * A week, in milliseconds.
22
- */ "Week"] = 604800000] = "Week";
23
- Duration[Duration[/**
24
- * A year, in milliseconds.
25
- */ "Year"] = 31536000000] = "Year";
26
- })(Duration || (Duration = {}));
27
- const isNonNegativeInteger = (number)=>Number.isInteger(number) && number >= 0;
28
- const assertIsNonNegativeInteger = (number, name)=>{
29
- if (!isNonNegativeInteger(number)) {
30
- throw new Error(`"${name}" must be a non-negative integer. Received: "${number}".`);
31
- }
32
- };
33
- /**
34
- * Calculates the millisecond value of the specified number of units of time.
35
- *
36
- * @param count - The number of units of time.
37
- * @param duration - The unit of time to count.
38
- * @returns The count multiplied by the specified duration.
39
- */ export function inMilliseconds(count, duration) {
40
- assertIsNonNegativeInteger(count, 'count');
41
- return count * duration;
42
- }
43
- /**
44
- * Gets the milliseconds since a particular Unix epoch timestamp.
45
- *
46
- * @param timestamp - A Unix millisecond timestamp.
47
- * @returns The number of milliseconds elapsed since the specified timestamp.
48
- */ export function timeSince(timestamp) {
49
- assertIsNonNegativeInteger(timestamp, 'timestamp');
50
- return Date.now() - timestamp;
51
- }
52
-
53
- //# sourceMappingURL=time.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/time.ts"],"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"],"names":["Duration","Millisecond","Second","Minute","Hour","Day","Week","Year","isNonNegativeInteger","number","Number","isInteger","assertIsNonNegativeInteger","name","Error","inMilliseconds","count","duration","timeSince","timestamp","Date","now"],"mappings":"AAAA;;CAEC,cACM;UAAKA,QAAQ;IAARA,SAAAA,SACV;;GAEC,GACDC,iBAAc,KAAdA;IAJUD,SAAAA,SAMV;;GAEC,GACDE,YAAS,QAATA;IATUF,SAAAA,SAWV;;GAEC,GACDG,YAAS,SAATA;IAdUH,SAAAA,SAgBV;;GAEC,GACDI,UAAO,WAAPA;IAnBUJ,SAAAA,SAqBV;;GAEC,GACDK,SAAM,YAANA;IAxBUL,SAAAA,SA0BV;;GAEC,GACDM,UAAO,aAAPA;IA7BUN,SAAAA,SA+BV;;GAEC,GACDO,UAAO,eAAPA;GAlCUP,aAAAA;AAqCZ,MAAMQ,uBAAuB,CAACC,SAC5BC,OAAOC,SAAS,CAACF,WAAWA,UAAU;AAExC,MAAMG,6BAA6B,CAACH,QAAgBI;IAClD,IAAI,CAACL,qBAAqBC,SAAS;QACjC,MAAM,IAAIK,MACR,CAAC,CAAC,EAAED,KAAK,6CAA6C,EAAEJ,OAAO,EAAE,CAAC;IAEtE;AACF;AAEA;;;;;;CAMC,GACD,OAAO,SAASM,eAAeC,KAAa,EAAEC,QAAkB;IAC9DL,2BAA2BI,OAAO;IAClC,OAAOA,QAAQC;AACjB;AAEA;;;;;CAKC,GACD,OAAO,SAASC,UAAUC,SAAiB;IACzCP,2BAA2BO,WAAW;IACtC,OAAOC,KAAKC,GAAG,KAAKF;AACtB"}
@@ -1,3 +0,0 @@
1
- export { };
2
-
3
- //# sourceMappingURL=transaction-types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/transaction-types.ts"],"sourcesContent":["import type { Bytes } from './bytes';\nimport type { Hex } from './hex';\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"],"names":[],"mappings":"AAAA,WAqIE"}
@@ -1,78 +0,0 @@
1
- import { gt as gtSemver, gtr as gtrSemver, satisfies as satisfiesSemver, valid as validSemVerVersion, validRange as validSemVerRange } from 'semver';
2
- import { is, refine, string } from 'superstruct';
3
- import { assertStruct } from './assert';
4
- /**
5
- * A struct for validating a version string.
6
- */ export const VersionStruct = refine(string(), 'Version', (value)=>{
7
- if (validSemVerVersion(value) === null) {
8
- return `Expected SemVer version, got "${value}"`;
9
- }
10
- return true;
11
- });
12
- export const VersionRangeStruct = refine(string(), 'Version range', (value)=>{
13
- if (validSemVerRange(value) === null) {
14
- return `Expected SemVer range, got "${value}"`;
15
- }
16
- return true;
17
- });
18
- /**
19
- * Checks whether a SemVer version is valid.
20
- *
21
- * @param version - A potential version.
22
- * @returns `true` if the version is valid, and `false` otherwise.
23
- */ export function isValidSemVerVersion(version) {
24
- return is(version, VersionStruct);
25
- }
26
- /**
27
- * Checks whether a SemVer version range is valid.
28
- *
29
- * @param versionRange - A potential version range.
30
- * @returns `true` if the version range is valid, and `false` otherwise.
31
- */ export function isValidSemVerRange(versionRange) {
32
- return is(versionRange, VersionRangeStruct);
33
- }
34
- /**
35
- * Asserts that a value is a valid concrete SemVer version.
36
- *
37
- * @param version - A potential SemVer concrete version.
38
- */ export function assertIsSemVerVersion(version) {
39
- assertStruct(version, VersionStruct);
40
- }
41
- /**
42
- * Asserts that a value is a valid SemVer range.
43
- *
44
- * @param range - A potential SemVer range.
45
- */ export function assertIsSemVerRange(range) {
46
- assertStruct(range, VersionRangeStruct);
47
- }
48
- /**
49
- * Checks whether a SemVer version is greater than another.
50
- *
51
- * @param version1 - The left-hand version.
52
- * @param version2 - The right-hand version.
53
- * @returns `version1 > version2`.
54
- */ export function gtVersion(version1, version2) {
55
- return gtSemver(version1, version2);
56
- }
57
- /**
58
- * Checks whether a SemVer version is greater than all possibilities in a range.
59
- *
60
- * @param version - A SemvVer version.
61
- * @param range - The range to check against.
62
- * @returns `version > range`.
63
- */ export function gtRange(version, range) {
64
- return gtrSemver(version, range);
65
- }
66
- /**
67
- * Returns whether a SemVer version satisfies a SemVer range.
68
- *
69
- * @param version - The SemVer version to check.
70
- * @param versionRange - The SemVer version range to check against.
71
- * @returns Whether the version satisfied the version range.
72
- */ export function satisfiesVersionRange(version, versionRange) {
73
- return satisfiesSemver(version, versionRange, {
74
- includePrerelease: true
75
- });
76
- }
77
-
78
- //# sourceMappingURL=versions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/versions.ts"],"sourcesContent":["import {\n gt as gtSemver,\n gtr as gtrSemver,\n satisfies as satisfiesSemver,\n valid as validSemVerVersion,\n validRange as validSemVerRange,\n} from 'semver';\nimport type { Struct } from 'superstruct';\nimport { is, refine, string } from 'superstruct';\n\nimport { assertStruct } from './assert';\nimport type { Opaque } from './opaque';\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>;\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>;\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"],"names":["gt","gtSemver","gtr","gtrSemver","satisfies","satisfiesSemver","valid","validSemVerVersion","validRange","validSemVerRange","is","refine","string","assertStruct","VersionStruct","value","VersionRangeStruct","isValidSemVerVersion","version","isValidSemVerRange","versionRange","assertIsSemVerVersion","assertIsSemVerRange","range","gtVersion","version1","version2","gtRange","satisfiesVersionRange","includePrerelease"],"mappings":"AAAA,SACEA,MAAMC,QAAQ,EACdC,OAAOC,SAAS,EAChBC,aAAaC,eAAe,EAC5BC,SAASC,kBAAkB,EAC3BC,cAAcC,gBAAgB,QACzB,SAAS;AAEhB,SAASC,EAAE,EAAEC,MAAM,EAAEC,MAAM,QAAQ,cAAc;AAEjD,SAASC,YAAY,QAAQ,WAAW;AA+CxC;;CAEC,GACD,OAAO,MAAMC,gBAAgBH,OAC3BC,UACA,WACA,CAACG;IACC,IAAIR,mBAAmBQ,WAAW,MAAM;QACtC,OAAO,CAAC,8BAA8B,EAAEA,MAAM,CAAC,CAAC;IAClD;IACA,OAAO;AACT,GACA;AAEF,OAAO,MAAMC,qBAAqBL,OAChCC,UACA,iBACA,CAACG;IACC,IAAIN,iBAAiBM,WAAW,MAAM;QACpC,OAAO,CAAC,4BAA4B,EAAEA,MAAM,CAAC,CAAC;IAChD;IACA,OAAO;AACT,GACA;AAEF;;;;;CAKC,GACD,OAAO,SAASE,qBACdC,OAAgB;IAEhB,OAAOR,GAAGQ,SAASJ;AACrB;AAEA;;;;;CAKC,GACD,OAAO,SAASK,mBACdC,YAAqB;IAErB,OAAOV,GAAGU,cAAcJ;AAC1B;AAEA;;;;CAIC,GACD,OAAO,SAASK,sBACdH,OAAgB;IAEhBL,aAAaK,SAASJ;AACxB;AAEA;;;;CAIC,GACD,OAAO,SAASQ,oBACdC,KAAc;IAEdV,aAAaU,OAAOP;AACtB;AAEA;;;;;;CAMC,GACD,OAAO,SAASQ,UACdC,QAAuB,EACvBC,QAAuB;IAEvB,OAAOzB,SAASwB,UAAUC;AAC5B;AAEA;;;;;;CAMC,GACD,OAAO,SAASC,QAAQT,OAAsB,EAAEK,KAAkB;IAChE,OAAOpB,UAAUe,SAASK;AAC5B;AAEA;;;;;;CAMC,GACD,OAAO,SAASK,sBACdV,OAAsB,EACtBE,YAAyB;IAEzB,OAAOf,gBAAgBa,SAASE,cAAc;QAC5CS,mBAAmB;IACrB;AACF"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=caip-types.test-d.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"caip-types.test-d.d.ts","sourceRoot":"","sources":["../../src/caip-types.test-d.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=hex.test-d.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hex.test-d.d.ts","sourceRoot":"","sources":["../../src/hex.test-d.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=json.test-d.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"json.test-d.d.ts","sourceRoot":"","sources":["../../src/json.test-d.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=misc.test-d.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"misc.test-d.d.ts","sourceRoot":"","sources":["../../src/misc.test-d.ts"],"names":[],"mappings":""}