@feelyourprotocol/util 8141.0.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 (223) hide show
  1. package/LICENSE +373 -0
  2. package/README.md +297 -0
  3. package/dist/cjs/account.d.ts +165 -0
  4. package/dist/cjs/account.d.ts.map +1 -0
  5. package/dist/cjs/account.js +530 -0
  6. package/dist/cjs/account.js.map +1 -0
  7. package/dist/cjs/address.d.ts +67 -0
  8. package/dist/cjs/address.d.ts.map +1 -0
  9. package/dist/cjs/address.js +136 -0
  10. package/dist/cjs/address.js.map +1 -0
  11. package/dist/cjs/authorization.d.ts +41 -0
  12. package/dist/cjs/authorization.d.ts.map +1 -0
  13. package/dist/cjs/authorization.js +135 -0
  14. package/dist/cjs/authorization.js.map +1 -0
  15. package/dist/cjs/bal.d.ts +129 -0
  16. package/dist/cjs/bal.d.ts.map +1 -0
  17. package/dist/cjs/bal.js +529 -0
  18. package/dist/cjs/bal.js.map +1 -0
  19. package/dist/cjs/binaryTree.d.ts +148 -0
  20. package/dist/cjs/binaryTree.d.ts.map +1 -0
  21. package/dist/cjs/binaryTree.js +240 -0
  22. package/dist/cjs/binaryTree.js.map +1 -0
  23. package/dist/cjs/blobs.d.ts +76 -0
  24. package/dist/cjs/blobs.d.ts.map +1 -0
  25. package/dist/cjs/blobs.js +175 -0
  26. package/dist/cjs/blobs.js.map +1 -0
  27. package/dist/cjs/bytes.d.ts +291 -0
  28. package/dist/cjs/bytes.d.ts.map +1 -0
  29. package/dist/cjs/bytes.js +606 -0
  30. package/dist/cjs/bytes.js.map +1 -0
  31. package/dist/cjs/constants.d.ts +91 -0
  32. package/dist/cjs/constants.d.ts.map +1 -0
  33. package/dist/cjs/constants.js +97 -0
  34. package/dist/cjs/constants.js.map +1 -0
  35. package/dist/cjs/db.d.ts +65 -0
  36. package/dist/cjs/db.d.ts.map +1 -0
  37. package/dist/cjs/db.js +14 -0
  38. package/dist/cjs/db.js.map +1 -0
  39. package/dist/cjs/env.d.ts +9 -0
  40. package/dist/cjs/env.d.ts.map +1 -0
  41. package/dist/cjs/env.js +13 -0
  42. package/dist/cjs/env.js.map +1 -0
  43. package/dist/cjs/errors.d.ts +3 -0
  44. package/dist/cjs/errors.d.ts.map +1 -0
  45. package/dist/cjs/errors.js +19 -0
  46. package/dist/cjs/errors.js.map +1 -0
  47. package/dist/cjs/helpers.d.ts +21 -0
  48. package/dist/cjs/helpers.d.ts.map +1 -0
  49. package/dist/cjs/helpers.js +50 -0
  50. package/dist/cjs/helpers.js.map +1 -0
  51. package/dist/cjs/index.d.ts +67 -0
  52. package/dist/cjs/index.d.ts.map +1 -0
  53. package/dist/cjs/index.js +93 -0
  54. package/dist/cjs/index.js.map +1 -0
  55. package/dist/cjs/internal.d.ts +72 -0
  56. package/dist/cjs/internal.d.ts.map +1 -0
  57. package/dist/cjs/internal.js +182 -0
  58. package/dist/cjs/internal.js.map +1 -0
  59. package/dist/cjs/kzg.d.ts +14 -0
  60. package/dist/cjs/kzg.d.ts.map +1 -0
  61. package/dist/cjs/kzg.js +3 -0
  62. package/dist/cjs/kzg.js.map +1 -0
  63. package/dist/cjs/lock.d.ts +15 -0
  64. package/dist/cjs/lock.d.ts.map +1 -0
  65. package/dist/cjs/lock.js +45 -0
  66. package/dist/cjs/lock.js.map +1 -0
  67. package/dist/cjs/mapDB.d.ts +17 -0
  68. package/dist/cjs/mapDB.d.ts.map +1 -0
  69. package/dist/cjs/mapDB.js +46 -0
  70. package/dist/cjs/mapDB.js.map +1 -0
  71. package/dist/cjs/package.json +3 -0
  72. package/dist/cjs/provider.d.ts +46 -0
  73. package/dist/cjs/provider.d.ts.map +1 -0
  74. package/dist/cjs/provider.js +84 -0
  75. package/dist/cjs/provider.js.map +1 -0
  76. package/dist/cjs/request.d.ts +20 -0
  77. package/dist/cjs/request.d.ts.map +1 -0
  78. package/dist/cjs/request.js +35 -0
  79. package/dist/cjs/request.js.map +1 -0
  80. package/dist/cjs/signature.d.ts +47 -0
  81. package/dist/cjs/signature.d.ts.map +1 -0
  82. package/dist/cjs/signature.js +147 -0
  83. package/dist/cjs/signature.js.map +1 -0
  84. package/dist/cjs/tasks.d.ts +32 -0
  85. package/dist/cjs/tasks.d.ts.map +1 -0
  86. package/dist/cjs/tasks.js +51 -0
  87. package/dist/cjs/tasks.js.map +1 -0
  88. package/dist/cjs/types.d.ts +64 -0
  89. package/dist/cjs/types.d.ts.map +1 -0
  90. package/dist/cjs/types.js +78 -0
  91. package/dist/cjs/types.js.map +1 -0
  92. package/dist/cjs/units.d.ts +22 -0
  93. package/dist/cjs/units.d.ts.map +1 -0
  94. package/dist/cjs/units.js +51 -0
  95. package/dist/cjs/units.js.map +1 -0
  96. package/dist/cjs/withdrawal.d.ts +72 -0
  97. package/dist/cjs/withdrawal.d.ts.map +1 -0
  98. package/dist/cjs/withdrawal.js +93 -0
  99. package/dist/cjs/withdrawal.js.map +1 -0
  100. package/dist/esm/account.d.ts +165 -0
  101. package/dist/esm/account.d.ts.map +1 -0
  102. package/dist/esm/account.js +505 -0
  103. package/dist/esm/account.js.map +1 -0
  104. package/dist/esm/address.d.ts +67 -0
  105. package/dist/esm/address.d.ts.map +1 -0
  106. package/dist/esm/address.js +125 -0
  107. package/dist/esm/address.js.map +1 -0
  108. package/dist/esm/authorization.d.ts +41 -0
  109. package/dist/esm/authorization.d.ts.map +1 -0
  110. package/dist/esm/authorization.js +126 -0
  111. package/dist/esm/authorization.js.map +1 -0
  112. package/dist/esm/bal.d.ts +129 -0
  113. package/dist/esm/bal.d.ts.map +1 -0
  114. package/dist/esm/bal.js +522 -0
  115. package/dist/esm/bal.js.map +1 -0
  116. package/dist/esm/binaryTree.d.ts +148 -0
  117. package/dist/esm/binaryTree.d.ts.map +1 -0
  118. package/dist/esm/binaryTree.js +226 -0
  119. package/dist/esm/binaryTree.js.map +1 -0
  120. package/dist/esm/blobs.d.ts +76 -0
  121. package/dist/esm/blobs.d.ts.map +1 -0
  122. package/dist/esm/blobs.js +163 -0
  123. package/dist/esm/blobs.js.map +1 -0
  124. package/dist/esm/bytes.d.ts +291 -0
  125. package/dist/esm/bytes.d.ts.map +1 -0
  126. package/dist/esm/bytes.js +562 -0
  127. package/dist/esm/bytes.js.map +1 -0
  128. package/dist/esm/constants.d.ts +91 -0
  129. package/dist/esm/constants.d.ts.map +1 -0
  130. package/dist/esm/constants.js +94 -0
  131. package/dist/esm/constants.js.map +1 -0
  132. package/dist/esm/db.d.ts +65 -0
  133. package/dist/esm/db.d.ts.map +1 -0
  134. package/dist/esm/db.js +11 -0
  135. package/dist/esm/db.js.map +1 -0
  136. package/dist/esm/env.d.ts +9 -0
  137. package/dist/esm/env.d.ts.map +1 -0
  138. package/dist/esm/env.js +9 -0
  139. package/dist/esm/env.js.map +1 -0
  140. package/dist/esm/errors.d.ts +3 -0
  141. package/dist/esm/errors.d.ts.map +1 -0
  142. package/dist/esm/errors.js +14 -0
  143. package/dist/esm/errors.js.map +1 -0
  144. package/dist/esm/helpers.d.ts +21 -0
  145. package/dist/esm/helpers.d.ts.map +1 -0
  146. package/dist/esm/helpers.js +43 -0
  147. package/dist/esm/helpers.js.map +1 -0
  148. package/dist/esm/index.d.ts +67 -0
  149. package/dist/esm/index.d.ts.map +1 -0
  150. package/dist/esm/index.js +67 -0
  151. package/dist/esm/index.js.map +1 -0
  152. package/dist/esm/internal.d.ts +72 -0
  153. package/dist/esm/internal.d.ts.map +1 -0
  154. package/dist/esm/internal.js +170 -0
  155. package/dist/esm/internal.js.map +1 -0
  156. package/dist/esm/kzg.d.ts +14 -0
  157. package/dist/esm/kzg.d.ts.map +1 -0
  158. package/dist/esm/kzg.js +2 -0
  159. package/dist/esm/kzg.js.map +1 -0
  160. package/dist/esm/lock.d.ts +15 -0
  161. package/dist/esm/lock.d.ts.map +1 -0
  162. package/dist/esm/lock.js +41 -0
  163. package/dist/esm/lock.js.map +1 -0
  164. package/dist/esm/mapDB.d.ts +17 -0
  165. package/dist/esm/mapDB.d.ts.map +1 -0
  166. package/dist/esm/mapDB.js +42 -0
  167. package/dist/esm/mapDB.js.map +1 -0
  168. package/dist/esm/package.json +3 -0
  169. package/dist/esm/provider.d.ts +46 -0
  170. package/dist/esm/provider.d.ts.map +1 -0
  171. package/dist/esm/provider.js +79 -0
  172. package/dist/esm/provider.js.map +1 -0
  173. package/dist/esm/request.d.ts +20 -0
  174. package/dist/esm/request.d.ts.map +1 -0
  175. package/dist/esm/request.js +30 -0
  176. package/dist/esm/request.js.map +1 -0
  177. package/dist/esm/signature.d.ts +47 -0
  178. package/dist/esm/signature.d.ts.map +1 -0
  179. package/dist/esm/signature.js +137 -0
  180. package/dist/esm/signature.js.map +1 -0
  181. package/dist/esm/tasks.d.ts +32 -0
  182. package/dist/esm/tasks.d.ts.map +1 -0
  183. package/dist/esm/tasks.js +47 -0
  184. package/dist/esm/tasks.js.map +1 -0
  185. package/dist/esm/types.d.ts +64 -0
  186. package/dist/esm/types.d.ts.map +1 -0
  187. package/dist/esm/types.js +71 -0
  188. package/dist/esm/types.js.map +1 -0
  189. package/dist/esm/units.d.ts +22 -0
  190. package/dist/esm/units.d.ts.map +1 -0
  191. package/dist/esm/units.js +46 -0
  192. package/dist/esm/units.js.map +1 -0
  193. package/dist/esm/withdrawal.d.ts +72 -0
  194. package/dist/esm/withdrawal.d.ts.map +1 -0
  195. package/dist/esm/withdrawal.js +86 -0
  196. package/dist/esm/withdrawal.js.map +1 -0
  197. package/dist/tsconfig.prod.cjs.tsbuildinfo +1 -0
  198. package/dist/tsconfig.prod.esm.tsbuildinfo +1 -0
  199. package/package.json +116 -0
  200. package/src/account.ts +630 -0
  201. package/src/address.ts +158 -0
  202. package/src/authorization.ts +180 -0
  203. package/src/bal.ts +761 -0
  204. package/src/binaryTree.ts +353 -0
  205. package/src/blobs.ts +209 -0
  206. package/src/bytes.ts +659 -0
  207. package/src/constants.ts +125 -0
  208. package/src/db.ts +86 -0
  209. package/src/env.ts +9 -0
  210. package/src/errors.ts +28 -0
  211. package/src/helpers.ts +46 -0
  212. package/src/index.ts +88 -0
  213. package/src/internal.ts +212 -0
  214. package/src/kzg.ts +24 -0
  215. package/src/lock.ts +42 -0
  216. package/src/mapDB.ts +57 -0
  217. package/src/provider.ts +109 -0
  218. package/src/request.ts +48 -0
  219. package/src/signature.ts +202 -0
  220. package/src/tasks.ts +59 -0
  221. package/src/types.ts +177 -0
  222. package/src/units.ts +56 -0
  223. package/src/withdrawal.ts +133 -0
@@ -0,0 +1,562 @@
1
+ import { bytesToHex as bytesToUnprefixedHexNoble, hexToBytes as hexToBytesNoble, randomBytes as randomBytesNoble, } from '@noble/hashes/utils.js';
2
+ import { EthereumJSErrorWithoutCode } from "./errors.js";
3
+ import { assertIsArray, assertIsBytes, assertIsHexString } from "./helpers.js";
4
+ import { isHexString, padToEven, stripHexPrefix } from "./internal.js";
5
+ const BIGINT_0 = BigInt(0);
6
+ /**
7
+ * @deprecated
8
+ */
9
+ export const bytesToUnprefixedHex = bytesToUnprefixedHexNoble;
10
+ /**
11
+ * Converts a {@link PrefixedHexString} to a {@link Uint8Array}
12
+ * @param {PrefixedHexString} hex The 0x-prefixed hex string to convert
13
+ * @returns {Uint8Array} The converted bytes
14
+ * @throws If the input is not a valid 0x-prefixed hex string
15
+ */
16
+ export const hexToBytes = (hex) => {
17
+ if (!hex.startsWith('0x'))
18
+ throw EthereumJSErrorWithoutCode('input string must be 0x prefixed');
19
+ return hexToBytesNoble(padToEven(stripHexPrefix(hex)));
20
+ };
21
+ export const unprefixedHexToBytes = (hex) => {
22
+ if (hex.startsWith('0x'))
23
+ throw EthereumJSErrorWithoutCode('input string cannot be 0x prefixed');
24
+ return hexToBytesNoble(padToEven(hex));
25
+ };
26
+ /**
27
+ * Converts a {@link Uint8Array} to a {@link PrefixedHexString}
28
+ * @param {Uint8Array} bytes the bytes to convert
29
+ * @returns {PrefixedHexString} the hex string
30
+ * @dev Returns `0x` if provided an empty Uint8Array
31
+ */
32
+ export const bytesToHex = (bytes) => {
33
+ // Using deprecated bytesToUnprefixedHex for performance: bytesToHex is a wrapper that adds the 0x prefix.
34
+ // Using bytesToUnprefixedHex directly avoids creating an intermediate prefixed string and then stripping it.
35
+ const unprefixedHex = bytesToUnprefixedHex(bytes);
36
+ return `0x${unprefixedHex}`;
37
+ };
38
+ // BigInt cache for the numbers 0 - 256*256-1 (two-byte bytes)
39
+ const BIGINT_CACHE = [];
40
+ for (let i = 0; i <= 256 * 256 - 1; i++) {
41
+ BIGINT_CACHE[i] = BigInt(i);
42
+ }
43
+ /**
44
+ * Converts a {@link Uint8Array} to a {@link bigint}
45
+ * @param {Uint8Array} bytes the bytes to convert
46
+ * @returns {bigint}
47
+ */
48
+ export const bytesToBigInt = (bytes, littleEndian = false) => {
49
+ assertIsBytes(bytes);
50
+ if (littleEndian) {
51
+ bytes = bytes.slice().reverse();
52
+ }
53
+ const hex = bytesToHex(bytes);
54
+ if (hex === '0x') {
55
+ return BIGINT_0;
56
+ }
57
+ if (hex.length === 4) {
58
+ // If the byte length is 1 (this is faster than checking `bytes.length === 1`)
59
+ return BIGINT_CACHE[bytes[0]];
60
+ }
61
+ if (hex.length === 6) {
62
+ return BIGINT_CACHE[bytes[0] * 256 + bytes[1]];
63
+ }
64
+ return BigInt(hex);
65
+ };
66
+ /**
67
+ * Converts a {@link Uint8Array} to a {@link number}.
68
+ * @param {Uint8Array} bytes the bytes to convert
69
+ * @return {number}
70
+ * @throws If the input number exceeds 53 bits.
71
+ */
72
+ export const bytesToInt = (bytes) => {
73
+ const res = Number(bytesToBigInt(bytes));
74
+ if (!Number.isSafeInteger(res))
75
+ throw EthereumJSErrorWithoutCode('Number exceeds 53 bits');
76
+ return res;
77
+ };
78
+ /******************************************/
79
+ /**
80
+ * Converts a {@link number} into a {@link PrefixedHexString}
81
+ * @param {number} i
82
+ * @return {PrefixedHexString}
83
+ */
84
+ export const intToHex = (i) => {
85
+ if (!Number.isSafeInteger(i) || i < 0) {
86
+ throw EthereumJSErrorWithoutCode(`Received an invalid integer type: ${i}`);
87
+ }
88
+ return `0x${i.toString(16)}`;
89
+ };
90
+ /**
91
+ * Converts an {@link number} to a {@link Uint8Array}
92
+ * @param {Number} i
93
+ * @return {Uint8Array}
94
+ */
95
+ export const intToBytes = (i) => {
96
+ const hex = intToHex(i);
97
+ return hexToBytes(hex);
98
+ };
99
+ /**
100
+ * Converts a {@link bigint} to a {@link Uint8Array}
101
+ * * @param {bigint} num the bigint to convert
102
+ * @returns {Uint8Array}
103
+ */
104
+ export const bigIntToBytes = (num, littleEndian = false) => {
105
+ const bytes = hexToBytes(`0x${padToEven(num.toString(16))}`);
106
+ return littleEndian ? bytes.reverse() : bytes;
107
+ };
108
+ /**
109
+ * Pads a `Uint8Array` with zeros till it has `length` bytes.
110
+ * Throws if input length exceeds target length, unless allowTruncate is true.
111
+ * @param {Uint8Array} msg the value to pad
112
+ * @param {number} length the number of bytes the output should be
113
+ * @param {boolean} right whether to start padding from the left or right
114
+ * @param {boolean} allowTruncate whether to allow truncation if msg exceeds length
115
+ * @return {Uint8Array}
116
+ */
117
+ const setLength = (msg, length, right, allowTruncate) => {
118
+ if (msg.length > length) {
119
+ if (!allowTruncate) {
120
+ throw EthereumJSErrorWithoutCode(`Input length ${msg.length} exceeds target length ${length}. Use allowTruncate option to truncate.`);
121
+ }
122
+ return right ? msg.subarray(0, length) : msg.subarray(-length);
123
+ }
124
+ if (msg.length < length) {
125
+ return right
126
+ ? new Uint8Array([...msg, ...new Uint8Array(length - msg.length)])
127
+ : new Uint8Array([...new Uint8Array(length - msg.length), ...msg]);
128
+ }
129
+ return msg;
130
+ };
131
+ /**
132
+ * Left Pads a `Uint8Array` with leading zeros till it has `length` bytes.
133
+ * Throws if input length exceeds target length, unless allowTruncate option is true.
134
+ * @param {Uint8Array} msg the value to pad
135
+ * @param {number} length the number of bytes the output should be
136
+ * @param {SetLengthOpts} opts options object with allowTruncate flag
137
+ * @return {Uint8Array}
138
+ */
139
+ export const setLengthLeft = (msg, length, opts = {}) => {
140
+ assertIsBytes(msg);
141
+ return setLength(msg, length, false, opts.allowTruncate ?? false);
142
+ };
143
+ /**
144
+ * Right Pads a `Uint8Array` with trailing zeros till it has `length` bytes.
145
+ * Throws if input length exceeds target length, unless allowTruncate option is true.
146
+ * @param {Uint8Array} msg the value to pad
147
+ * @param {number} length the number of bytes the output should be
148
+ * @param {SetLengthOpts} opts options object with allowTruncate flag
149
+ * @return {Uint8Array}
150
+ */
151
+ export const setLengthRight = (msg, length, opts = {}) => {
152
+ assertIsBytes(msg);
153
+ return setLength(msg, length, true, opts.allowTruncate ?? false);
154
+ };
155
+ /**
156
+ * Trims leading zeros from a `Uint8Array`, `number[]` or `string`.
157
+ * @param {Uint8Array|number[]|string} a
158
+ * @return {Uint8Array|number[]|string}
159
+ */
160
+ const stripZeros = (a) => {
161
+ let first = a[0];
162
+ while (a.length > 0 && first.toString() === '0') {
163
+ a = a.slice(1);
164
+ first = a[0];
165
+ }
166
+ return a;
167
+ };
168
+ /**
169
+ * Trims leading zeros from a `Uint8Array`.
170
+ * @param {Uint8Array} a
171
+ * @return {Uint8Array}
172
+ */
173
+ export const unpadBytes = (a) => {
174
+ assertIsBytes(a);
175
+ return stripZeros(a);
176
+ };
177
+ /**
178
+ * Trims leading zeros from an `Array` (of numbers).
179
+ * @param {number[]} a
180
+ * @return {number[]}
181
+ */
182
+ export const unpadArray = (a) => {
183
+ assertIsArray(a);
184
+ return stripZeros(a);
185
+ };
186
+ /**
187
+ * Trims leading zeros from a `PrefixedHexString`.
188
+ * @param {PrefixedHexString} a
189
+ * @return {PrefixedHexString}
190
+ */
191
+ export const unpadHex = (a) => {
192
+ assertIsHexString(a);
193
+ return `0x${stripZeros(stripHexPrefix(a))}`;
194
+ };
195
+ /**
196
+ * Attempts to turn a value into a `Uint8Array`.
197
+ * Inputs supported: `Buffer`, `Uint8Array`, `String` (hex-prefixed), `Number`, null/undefined, `BigInt` and other objects
198
+ * with a `toArray()` or `toBytes()` method.
199
+ * @param {ToBytesInputTypes} v the value
200
+ * @return {Uint8Array}
201
+ */
202
+ export const toBytes = (v) => {
203
+ if (v === null || v === undefined) {
204
+ return new Uint8Array();
205
+ }
206
+ if (Array.isArray(v) || v instanceof Uint8Array) {
207
+ return Uint8Array.from(v);
208
+ }
209
+ if (typeof v === 'string') {
210
+ if (!isHexString(v)) {
211
+ throw EthereumJSErrorWithoutCode(`Cannot convert string to Uint8Array. toBytes only supports 0x-prefixed hex strings and this string was given: ${v}`);
212
+ }
213
+ return hexToBytes(v);
214
+ }
215
+ if (typeof v === 'number') {
216
+ return intToBytes(v);
217
+ }
218
+ if (typeof v === 'bigint') {
219
+ if (v < BIGINT_0) {
220
+ throw EthereumJSErrorWithoutCode(`Cannot convert negative bigint to Uint8Array. Given: ${v}`);
221
+ }
222
+ let n = v.toString(16);
223
+ if (n.length % 2)
224
+ n = '0' + n;
225
+ return unprefixedHexToBytes(n);
226
+ }
227
+ if (v.toBytes !== undefined) {
228
+ // converts a `TransformableToBytes` object to a Uint8Array
229
+ return v.toBytes();
230
+ }
231
+ throw EthereumJSErrorWithoutCode('invalid type');
232
+ };
233
+ /**
234
+ * Interprets a `Uint8Array` as a signed integer and returns a `BigInt`. Assumes 256-bit numbers.
235
+ * @param {Uint8Array} num Signed integer value
236
+ * @returns {bigint}
237
+ */
238
+ export const fromSigned = (num) => {
239
+ return BigInt.asIntN(256, bytesToBigInt(num));
240
+ };
241
+ /**
242
+ * Converts a `BigInt` to an unsigned integer and returns it as a `Uint8Array`. Assumes 256-bit numbers.
243
+ * @param {bigint} num
244
+ * @returns {Uint8Array}
245
+ */
246
+ export const toUnsigned = (num) => {
247
+ return bigIntToBytes(BigInt.asUintN(256, num));
248
+ };
249
+ /**
250
+ * Adds "0x" to a given `string` if it does not already start with "0x".
251
+ * @param {string} str
252
+ * @return {PrefixedHexString}
253
+ */
254
+ export const addHexPrefix = (str) => {
255
+ if (typeof str !== 'string') {
256
+ return str;
257
+ }
258
+ return isHexString(str) ? str : `0x${str}`;
259
+ };
260
+ /**
261
+ * Shortens a string or Uint8Array's hex string representation to maxLength (default 50).
262
+ *
263
+ * Examples:
264
+ *
265
+ * Input: '657468657265756d000000000000000000000000000000000000000000000000'
266
+ * Output: '657468657265756d0000000000000000000000000000000000…'
267
+ * @param {Uint8Array | string} bytes
268
+ * @param {number} maxLength
269
+ * @return {string}
270
+ */
271
+ export const short = (bytes, maxLength = 50) => {
272
+ const byteStr = bytes instanceof Uint8Array ? bytesToHex(bytes) : bytes;
273
+ const len = byteStr.slice(0, 2) === '0x' ? maxLength + 2 : maxLength;
274
+ if (byteStr.length <= len) {
275
+ return byteStr;
276
+ }
277
+ return byteStr.slice(0, len) + '…';
278
+ };
279
+ /**
280
+ * Checks provided Uint8Array for leading zeroes and throws if found.
281
+ *
282
+ * Examples:
283
+ *
284
+ * Valid values: 0x1, 0x, 0x01, 0x1234
285
+ * Invalid values: 0x0, 0x00, 0x001, 0x0001
286
+ *
287
+ * Note: This method is useful for validating that RLP encoded integers comply with the rule that all
288
+ * integer values encoded to RLP must be in the most compact form and contain no leading zero bytes
289
+ * @param values An object containing string keys and Uint8Array values
290
+ * @throws if any provided value is found to have leading zero bytes
291
+ */
292
+ export const validateNoLeadingZeroes = (values) => {
293
+ for (const [k, v] of Object.entries(values)) {
294
+ if (v !== undefined && v.length > 0 && v[0] === 0) {
295
+ throw EthereumJSErrorWithoutCode(`${k} cannot have leading zeroes, received: ${bytesToHex(v)}`);
296
+ }
297
+ }
298
+ };
299
+ /**
300
+ * Converts a {@link bigint} to a `0x` prefixed hex string
301
+ * @param {bigint} num the bigint to convert
302
+ * @returns {PrefixedHexString}
303
+ */
304
+ export const bigIntToHex = (num) => {
305
+ return `0x${num.toString(16)}`;
306
+ };
307
+ /**
308
+ * Calculates max bigint from an array of bigints
309
+ * @param args array of bigints
310
+ */
311
+ export const bigIntMax = (...args) => args.reduce((m, e) => (e > m ? e : m));
312
+ /**
313
+ * Calculates min BigInt from an array of BigInts
314
+ * @param args array of bigints
315
+ */
316
+ export const bigIntMin = (...args) => args.reduce((m, e) => (e < m ? e : m));
317
+ /**
318
+ * Convert value from bigint to an unpadded Uint8Array
319
+ * (useful for RLP transport)
320
+ * @param {bigint} value the bigint to convert
321
+ * @returns {Uint8Array}
322
+ */
323
+ export const bigIntToUnpaddedBytes = (value) => {
324
+ return unpadBytes(bigIntToBytes(value));
325
+ };
326
+ export const bigIntToAddressBytes = (value, strict = true) => {
327
+ const addressBytes = bigIntToBytes(value);
328
+ if (strict && addressBytes.length > 20) {
329
+ throw Error(`Invalid address bytes length=${addressBytes.length} strict=${strict}`);
330
+ }
331
+ // When not strict, allow truncation of values larger than 20 bytes
332
+ return setLengthLeft(addressBytes, 20, { allowTruncate: !strict });
333
+ };
334
+ /**
335
+ * Convert value from number to an unpadded Uint8Array
336
+ * (useful for RLP transport)
337
+ * @param {number} value the bigint to convert
338
+ * @returns {Uint8Array}
339
+ */
340
+ export const intToUnpaddedBytes = (value) => {
341
+ return unpadBytes(intToBytes(value));
342
+ };
343
+ /**
344
+ * Compares two Uint8Arrays and returns a number indicating their order in a sorted array.
345
+ *
346
+ * @param {Uint8Array} value1 - The first Uint8Array to compare.
347
+ * @param {Uint8Array} value2 - The second Uint8Array to compare.
348
+ * @returns {number} A positive number if value1 is larger than value2,
349
+ * A negative number if value1 is smaller than value2,
350
+ * or 0 if value1 and value2 are equal.
351
+ */
352
+ export const compareBytes = (value1, value2) => {
353
+ const bigIntValue1 = bytesToBigInt(value1);
354
+ const bigIntValue2 = bytesToBigInt(value2);
355
+ return bigIntValue1 > bigIntValue2 ? 1 : bigIntValue1 < bigIntValue2 ? -1 : 0;
356
+ };
357
+ /**
358
+ * Generates a Uint8Array of random bytes of specified length.
359
+ *
360
+ * @param {number} length - The length of the Uint8Array.
361
+ * @returns {Uint8Array} A Uint8Array of random bytes of specified length.
362
+ */
363
+ export const randomBytes = (length) => {
364
+ return randomBytesNoble(length);
365
+ };
366
+ /**
367
+ * This mirrors the functionality of the `ethereum-cryptography` export except
368
+ * it skips the check to validate that every element of `arrays` is indeed a `uint8Array`
369
+ * Can give small performance gains on large arrays
370
+ * @param {Uint8Array[]} arrays an array of Uint8Arrays
371
+ * @returns {Uint8Array} one Uint8Array with all the elements of the original set
372
+ * works like `Buffer.concat`
373
+ */
374
+ export const concatBytes = (...arrays) => {
375
+ if (arrays.length === 1)
376
+ return arrays[0];
377
+ const length = arrays.reduce((a, arr) => a + arr.length, 0);
378
+ const result = new Uint8Array(length);
379
+ for (let i = 0, pad = 0; i < arrays.length; i++) {
380
+ const arr = arrays[i];
381
+ result.set(arr, pad);
382
+ pad += arr.length;
383
+ }
384
+ return result;
385
+ };
386
+ /**
387
+ * @notice Convert a Uint8Array to a 32-bit integer
388
+ * @param {Uint8Array} bytes The input Uint8Array from which to read the 32-bit integer.
389
+ * @param {boolean} littleEndian True for little-endian, undefined or false for big-endian.
390
+ * @return {number} The 32-bit integer read from the input Uint8Array.
391
+ */
392
+ export function bytesToInt32(bytes, littleEndian = false) {
393
+ if (bytes.length < 4) {
394
+ bytes = setLength(bytes, 4, littleEndian, false);
395
+ }
396
+ const dataView = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
397
+ return dataView.getUint32(0, littleEndian);
398
+ }
399
+ /**
400
+ * @notice Convert a Uint8Array to a 64-bit bigint
401
+ * @param {Uint8Array} bytes The input Uint8Array from which to read the 64-bit bigint.
402
+ * @param {boolean} littleEndian True for little-endian, undefined or false for big-endian.
403
+ * @return {bigint} The 64-bit bigint read from the input Uint8Array.
404
+ */
405
+ export function bytesToBigInt64(bytes, littleEndian = false) {
406
+ if (bytes.length < 8) {
407
+ bytes = setLength(bytes, 8, littleEndian, false);
408
+ }
409
+ const dataView = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
410
+ return dataView.getBigUint64(0, littleEndian);
411
+ }
412
+ /**
413
+ * @notice Convert a 32-bit integer to a Uint8Array.
414
+ * @param {number} value The 32-bit integer to convert.
415
+ * @param {boolean} littleEndian True for little-endian, undefined or false for big-endian.
416
+ * @return {Uint8Array} A Uint8Array of length 4 containing the integer.
417
+ */
418
+ export function int32ToBytes(value, littleEndian = false) {
419
+ const buffer = new ArrayBuffer(4);
420
+ const dataView = new DataView(buffer);
421
+ dataView.setUint32(0, value, littleEndian);
422
+ return new Uint8Array(buffer);
423
+ }
424
+ /**
425
+ * @notice Convert a 64-bit bigint to a Uint8Array.
426
+ * @param {bigint} value The 64-bit bigint to convert.
427
+ * @param {boolean} littleEndian True for little-endian, undefined or false for big-endian.
428
+ * @return {Uint8Array} A Uint8Array of length 8 containing the bigint.
429
+ */
430
+ export function bigInt64ToBytes(value, littleEndian = false) {
431
+ const buffer = new ArrayBuffer(8);
432
+ const dataView = new DataView(buffer);
433
+ dataView.setBigUint64(0, value, littleEndian);
434
+ return new Uint8Array(buffer);
435
+ }
436
+ export { utf8ToBytes } from '@noble/hashes/utils.js';
437
+ /**
438
+ * @notice Converts a Uint8Array to a UTF-8 string.
439
+ * Implementation copied from ethereum-cryptography https://github.com/ethereum/js-ethereum-cryptography/blob/31f980b2847545d33268f2510ba38a3836202a44/src/utils.ts#L22-L27
440
+ * @param {Uint8Array} bytes - The input Uint8Array to convert.
441
+ * @returns {string} The UTF-8 string.
442
+ * @throws {TypeError} If the input is not a Uint8Array.
443
+ *
444
+ */
445
+ export function bytesToUtf8(bytes) {
446
+ if (!(bytes instanceof Uint8Array)) {
447
+ throw new TypeError(`bytesToUtf8 expected Uint8Array, got ${typeof bytes}`);
448
+ }
449
+ return new TextDecoder().decode(bytes);
450
+ }
451
+ /**
452
+ * @notice Compares two Uint8Arrays and returns true if they are equal.
453
+ * Implementation copied from ethereum-cryptography https://github.com/ethereum/js-ethereum-cryptography/blob/main/src/utils.ts#L35-L45
454
+ * @param {Uint8Array} a - The first Uint8Array to compare.
455
+ * @param {Uint8Array} b - The second Uint8Array to compare.
456
+ * @returns {boolean} True if the Uint8Arrays are equal, false otherwise.
457
+ */
458
+ export function equalsBytes(a, b) {
459
+ if (a.length !== b.length) {
460
+ return false;
461
+ }
462
+ for (let i = 0; i < a.length; i++) {
463
+ if (a[i] !== b[i]) {
464
+ return false;
465
+ }
466
+ }
467
+ return true;
468
+ }
469
+ export function hexToBigInt(input) {
470
+ return bytesToBigInt(hexToBytes(isHexString(input) ? input : `0x${input}`));
471
+ }
472
+ /**
473
+ * Converts a Uint8Array of bytes into an array of bits.
474
+ * @param {Uint8Array} bytes - The input byte array.
475
+ * @param {number} bitLength - The number of bits to extract from the input bytes.
476
+ * @returns {number[]} An array of bits (each 0 or 1) corresponding to the input bytes.
477
+ */
478
+ export function bytesToBits(bytes, bitLength) {
479
+ const bits = [];
480
+ for (let i = 0; i < (bitLength ?? bytes.length * 8); i++) {
481
+ const byteIndex = Math.floor(i / 8);
482
+ const bitIndex = 7 - (i % 8);
483
+ bits.push((bytes[byteIndex] >> bitIndex) & 1);
484
+ }
485
+ return bits;
486
+ }
487
+ /**
488
+ * Converts an array of bits into a Uint8Array.
489
+ * The input bits are grouped into sets of 8, with the first bit in each group being the most significant.
490
+ * @param {number[]} bits - The input array of bits (each should be 0 or 1). Its length should be a multiple of 8.
491
+ * @returns {Uint8Array} A Uint8Array constructed from the input bits.
492
+ */
493
+ export function bitsToBytes(bits) {
494
+ const numBytes = Math.ceil(bits.length / 8); // Ensure partial byte storage
495
+ const byteData = new Uint8Array(numBytes);
496
+ for (let i = 0; i < bits.length; i++) {
497
+ const byteIndex = Math.floor(i / 8);
498
+ const bitIndex = 7 - (i % 8);
499
+ byteData[byteIndex] |= bits[i] << bitIndex;
500
+ }
501
+ return byteData;
502
+ }
503
+ /**
504
+ * Compares two byte arrays and returns the count of consecutively matching items from the start.
505
+ * @param {Uint8Array} bytes1 - The first Uint8Array to compare.
506
+ * @param {Uint8Array} bytes2 - The second Uint8Array to compare.
507
+ * @returns {number} The count of consecutively matching items from the start.
508
+ */
509
+ export function matchingBytesLength(bytes1, bytes2) {
510
+ let count = 0;
511
+ const minLength = Math.min(bytes1.length, bytes2.length);
512
+ for (let i = 0; i < minLength; i++) {
513
+ if (bytes1[i] === bytes2[i]) {
514
+ count++;
515
+ }
516
+ else {
517
+ // Break early if a mismatch is found
518
+ break;
519
+ }
520
+ }
521
+ return count;
522
+ }
523
+ /**
524
+ * Compares two arrays of bits (0 or 1) and returns the count of consecutively matching bits from the start.
525
+ * @param {number[]} bits1 - The first array of bits, in bytes or bits.
526
+ * @param {number[]} bits2 - The second array of bits, in bytes or bits.
527
+ * @returns {number} The count of consecutively matching bits from the start.
528
+ */
529
+ export function matchingBitsLength(bits1, bits2) {
530
+ let count = 0;
531
+ const minLength = Math.min(bits1.length, bits2.length);
532
+ for (let i = 0; i < minLength; i++) {
533
+ if (bits1[i] === bits2[i]) {
534
+ count++;
535
+ }
536
+ else {
537
+ return count;
538
+ }
539
+ }
540
+ return count;
541
+ }
542
+ /**
543
+ * Checks whether two arrays of bits are equal.
544
+ *
545
+ * Two arrays are considered equal if they have the same length and each corresponding element is identical.
546
+ *
547
+ * @param {number[]} bits1 - The first bits array.
548
+ * @param {number[]} bits2 - The second bits array.
549
+ * @returns {boolean} True if the arrays are equal; otherwise, false.
550
+ */
551
+ export function equalsBits(bits1, bits2) {
552
+ if (bits1.length !== bits2.length) {
553
+ return false;
554
+ }
555
+ for (let i = 0; i < bits1.length; i++) {
556
+ if (bits1[i] !== bits2[i]) {
557
+ return false;
558
+ }
559
+ }
560
+ return true;
561
+ }
562
+ //# sourceMappingURL=bytes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bytes.js","sourceRoot":"","sources":["../../src/bytes.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,IAAI,yBAAyB,EACvC,UAAU,IAAI,eAAe,EAC7B,WAAW,IAAI,gBAAgB,GAChC,MAAM,wBAAwB,CAAA;AAE/B,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAA;AACxD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAC9E,OAAO,EAAE,WAAW,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,CAAA;QACT,CAAC;aAAM,CAAC;YACN,qCAAqC;YACrC,MAAK;QACP,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAe,EAAE,KAAe;IACjE,IAAI,KAAK,GAAG,CAAC,CAAA;IACb,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IACtD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,EAAE,CAAC,EAAE,EAAE,CAAC;QACnC,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;YAC1B,KAAK,EAAE,CAAA;QACT,CAAC;aAAM,CAAC;YACN,OAAO,KAAK,CAAA;QACd,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,UAAU,CAAC,KAAe,EAAE,KAAe;IACzD,IAAI,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,EAAE,CAAC;QAClC,OAAO,KAAK,CAAA;IACd,CAAC;IACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;YAC1B,OAAO,KAAK,CAAA;QACd,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC"}
@@ -0,0 +1,91 @@
1
+ /**
2
+ * 2^64-1
3
+ */
4
+ export declare const MAX_UINT64: bigint;
5
+ /**
6
+ * The max integer that the evm can handle (2^256-1)
7
+ */
8
+ export declare const MAX_INTEGER: bigint;
9
+ /**
10
+ * The max integer that the evm can handle (2^256-1) as a bigint
11
+ * 2^256-1 equals to 340282366920938463463374607431768211455
12
+ * We use literal value instead of calculated value for compatibility issue.
13
+ */
14
+ export declare const MAX_INTEGER_BIGINT: bigint;
15
+ export declare const SECP256K1_ORDER: bigint;
16
+ export declare const SECP256K1_ORDER_DIV_2: bigint;
17
+ /**
18
+ * 2^256
19
+ */
20
+ export declare const TWO_POW256: bigint;
21
+ /**
22
+ * Keccak-256 hash of null
23
+ */
24
+ export declare const KECCAK256_NULL_S = "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470";
25
+ /**
26
+ * Keccak-256 hash of null
27
+ */
28
+ export declare const KECCAK256_NULL: Uint8Array<ArrayBufferLike>;
29
+ /**
30
+ * Keccak-256 of an RLP of an empty array
31
+ */
32
+ export declare const KECCAK256_RLP_ARRAY_S = "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347";
33
+ /**
34
+ * Keccak-256 of an RLP of an empty array
35
+ */
36
+ export declare const KECCAK256_RLP_ARRAY: Uint8Array<ArrayBufferLike>;
37
+ /**
38
+ * Keccak-256 hash of the RLP of null
39
+ */
40
+ export declare const KECCAK256_RLP_S = "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421";
41
+ /**
42
+ * Keccak-256 hash of the RLP of null
43
+ */
44
+ export declare const KECCAK256_RLP: Uint8Array<ArrayBufferLike>;
45
+ export declare const SHA256_NULL: Uint8Array<ArrayBufferLike>;
46
+ /**
47
+ * RLP encoded empty string
48
+ */
49
+ export declare const RLP_EMPTY_STRING: Uint8Array<ArrayBuffer>;
50
+ export declare const MAX_WITHDRAWALS_PER_PAYLOAD = 16;
51
+ export declare const RIPEMD160_ADDRESS_STRING = "0000000000000000000000000000000000000003";
52
+ /**
53
+ * System address used by various EIPs (EIP-2935, EIP-7002, EIP-7251, EIP-7708, BAL).
54
+ * Single canonical definition to avoid duplication across packages.
55
+ */
56
+ export declare const SYSTEM_ADDRESS = "0xfffffffffffffffffffffffffffffffffffffffe";
57
+ export declare const SYSTEM_ADDRESS_BYTES: Uint8Array<ArrayBufferLike>;
58
+ /**
59
+ * EIP-7934: RLP Execution Block Size Limit constants
60
+ * Maximum RLP-encoded block size to 10 MiB, with a 2 MiB margin for beacon block sizes
61
+ */
62
+ export declare const MAX_BLOCK_SIZE = 10485760;
63
+ export declare const SAFETY_MARGIN = 2097152;
64
+ export declare const MAX_RLP_BLOCK_SIZE: number;
65
+ /**
66
+ * BigInt constants
67
+ */
68
+ export declare const BIGINT_NEG1: bigint;
69
+ export declare const BIGINT_0: bigint;
70
+ export declare const BIGINT_1: bigint;
71
+ export declare const BIGINT_2: bigint;
72
+ export declare const BIGINT_3: bigint;
73
+ export declare const BIGINT_7: bigint;
74
+ export declare const BIGINT_8: bigint;
75
+ export declare const BIGINT_27: bigint;
76
+ export declare const BIGINT_28: bigint;
77
+ export declare const BIGINT_31: bigint;
78
+ export declare const BIGINT_32: bigint;
79
+ export declare const BIGINT_64: bigint;
80
+ export declare const BIGINT_128: bigint;
81
+ export declare const BIGINT_255: bigint;
82
+ export declare const BIGINT_256: bigint;
83
+ export declare const BIGINT_96: bigint;
84
+ export declare const BIGINT_100: bigint;
85
+ export declare const BIGINT_160: bigint;
86
+ export declare const BIGINT_224: bigint;
87
+ export declare const BIGINT_2EXP96: bigint;
88
+ export declare const BIGINT_2EXP160: bigint;
89
+ export declare const BIGINT_2EXP224: bigint;
90
+ export declare const BIGINT_2EXP256: bigint;
91
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,eAAO,MAAM,UAAU,QAA+B,CAAA;AAEtD;;GAEG;AACH,eAAO,MAAM,WAAW,QAEvB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,QAE9B,CAAA;AAED,eAAO,MAAM,eAAe,QAA4B,CAAA;AACxD,eAAO,MAAM,q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