@capxul/cli 4.20.0-beta.3 → 4.20.0-beta.30

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 (44) hide show
  1. package/README.md +1156 -21
  2. package/dist/browser/GeistVF.woff +0 -0
  3. package/dist/browser/signer.js +85954 -0
  4. package/dist/browser/signer.js.map +1 -0
  5. package/dist/entry-Cp3LiVYn.mjs +46472 -0
  6. package/dist/entry-Cp3LiVYn.mjs.map +1 -0
  7. package/dist/fast-Dvf2EM7j.mjs +57 -0
  8. package/dist/fast-Dvf2EM7j.mjs.map +1 -0
  9. package/dist/{lib-BOge5QZP.mjs → lib-5nM6ORJd.mjs} +5 -4
  10. package/dist/{lib-BOge5QZP.mjs.map → lib-5nM6ORJd.mjs.map} +1 -1
  11. package/dist/{lib-DH_xJGSE.mjs → lib-BJgR4mWJ.mjs} +6 -5
  12. package/dist/{lib-DH_xJGSE.mjs.map → lib-BJgR4mWJ.mjs.map} +1 -1
  13. package/dist/lib-BlUleR2B.mjs +3 -0
  14. package/dist/{lib-C8ENT9j6.mjs → lib-BspI667y.mjs} +7 -6
  15. package/dist/{lib-C8ENT9j6.mjs.map → lib-BspI667y.mjs.map} +1 -1
  16. package/dist/{lib-C4fpnzyy.mjs → lib-Buegx0dz.mjs} +6 -5
  17. package/dist/{lib-C4fpnzyy.mjs.map → lib-Buegx0dz.mjs.map} +1 -1
  18. package/dist/{lib-DVGoRCJN.mjs → lib-CJw8te9L.mjs} +38 -38
  19. package/dist/{lib-DVGoRCJN.mjs.map → lib-CJw8te9L.mjs.map} +1 -1
  20. package/dist/lib-C_-etuHZ.mjs +3 -0
  21. package/dist/lib-CoGPQsbr.mjs +655 -0
  22. package/dist/lib-CoGPQsbr.mjs.map +1 -0
  23. package/dist/lib-Dd_fsz7h.mjs +3 -0
  24. package/dist/lib-DnmstTkB.mjs +578 -0
  25. package/dist/lib-DnmstTkB.mjs.map +1 -0
  26. package/dist/lib-IlYdzOHo.mjs +3 -0
  27. package/dist/main.mjs +22 -51062
  28. package/dist/main.mjs.map +1 -1
  29. package/dist/organizations-Dkb73lVO.mjs +37607 -0
  30. package/dist/organizations-Dkb73lVO.mjs.map +1 -0
  31. package/dist/permission-approvals-C3cUSQeT.mjs +139 -0
  32. package/dist/permission-approvals-C3cUSQeT.mjs.map +1 -0
  33. package/dist/record-U7Yu4KQP.mjs +1295 -0
  34. package/dist/record-U7Yu4KQP.mjs.map +1 -0
  35. package/dist/{secp256k1-Cc9JhcTQ.mjs → secp256k1-D8L212-Z.mjs} +5 -298
  36. package/dist/secp256k1-D8L212-Z.mjs.map +1 -0
  37. package/dist/sha2-CR2DnMEk.mjs +298 -0
  38. package/dist/sha2-CR2DnMEk.mjs.map +1 -0
  39. package/dist/utils-DmKXBQjM.mjs +130 -0
  40. package/dist/utils-DmKXBQjM.mjs.map +1 -0
  41. package/dist/where-view-DuGbrSLp.mjs +1420 -0
  42. package/dist/where-view-DuGbrSLp.mjs.map +1 -0
  43. package/package.json +18 -10
  44. package/dist/secp256k1-Cc9JhcTQ.mjs.map +0 -1
@@ -0,0 +1,1295 @@
1
+ import { a as anumber, h as u32, l as createHasher, m as toBytes$1, n as abytes, o as aoutput, p as swap32IfBE, r as aexists, s as clean, t as Hash } from "./utils-DmKXBQjM.mjs";
2
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/errors/version.js
3
+ const version = "2.55.18";
4
+ //#endregion
5
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/errors/base.js
6
+ let errorConfig = {
7
+ getDocsUrl: ({ docsBaseUrl, docsPath = "", docsSlug }) => docsPath ? `${docsBaseUrl ?? "https://viem.sh"}${docsPath}${docsSlug ? `#${docsSlug}` : ""}` : void 0,
8
+ version: `viem@${version}`
9
+ };
10
+ var BaseError = class BaseError extends Error {
11
+ constructor(shortMessage, args = {}) {
12
+ const details = (() => {
13
+ if (args.cause instanceof BaseError) return args.cause.details;
14
+ if (args.cause?.message) return args.cause.message;
15
+ return args.details;
16
+ })();
17
+ const docsPath = (() => {
18
+ if (args.cause instanceof BaseError) return args.cause.docsPath || args.docsPath;
19
+ return args.docsPath;
20
+ })();
21
+ const docsUrl = errorConfig.getDocsUrl?.({
22
+ ...args,
23
+ docsPath
24
+ });
25
+ const message = [
26
+ shortMessage || "An error occurred.",
27
+ "",
28
+ ...args.metaMessages ? [...args.metaMessages, ""] : [],
29
+ ...docsUrl ? [`Docs: ${docsUrl}`] : [],
30
+ ...details ? [`Details: ${details}`] : [],
31
+ ...errorConfig.version ? [`Version: ${errorConfig.version}`] : []
32
+ ].join("\n");
33
+ super(message, args.cause ? { cause: args.cause } : void 0);
34
+ Object.defineProperty(this, "details", {
35
+ enumerable: true,
36
+ configurable: true,
37
+ writable: true,
38
+ value: void 0
39
+ });
40
+ Object.defineProperty(this, "docsPath", {
41
+ enumerable: true,
42
+ configurable: true,
43
+ writable: true,
44
+ value: void 0
45
+ });
46
+ Object.defineProperty(this, "metaMessages", {
47
+ enumerable: true,
48
+ configurable: true,
49
+ writable: true,
50
+ value: void 0
51
+ });
52
+ Object.defineProperty(this, "shortMessage", {
53
+ enumerable: true,
54
+ configurable: true,
55
+ writable: true,
56
+ value: void 0
57
+ });
58
+ Object.defineProperty(this, "version", {
59
+ enumerable: true,
60
+ configurable: true,
61
+ writable: true,
62
+ value: void 0
63
+ });
64
+ Object.defineProperty(this, "name", {
65
+ enumerable: true,
66
+ configurable: true,
67
+ writable: true,
68
+ value: "BaseError"
69
+ });
70
+ this.details = details;
71
+ this.docsPath = docsPath;
72
+ this.metaMessages = args.metaMessages;
73
+ this.name = args.name ?? this.name;
74
+ this.shortMessage = shortMessage;
75
+ this.version = version;
76
+ }
77
+ walk(fn) {
78
+ return walk(this, fn);
79
+ }
80
+ };
81
+ function walk(err, fn) {
82
+ if (fn?.(err)) return err;
83
+ if (err && typeof err === "object" && "cause" in err && err.cause !== void 0) return walk(err.cause, fn);
84
+ return fn ? null : err;
85
+ }
86
+ //#endregion
87
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/errors/encoding.js
88
+ var IntegerOutOfRangeError = class extends BaseError {
89
+ constructor({ max, min, signed, size, value }) {
90
+ super(`Number "${value}" is not in safe ${size ? `${size * 8}-bit ${signed ? "signed" : "unsigned"} ` : ""}integer range ${max ? `(${min} to ${max})` : `(above ${min})`}`, { name: "IntegerOutOfRangeError" });
91
+ }
92
+ };
93
+ var InvalidBytesBooleanError = class extends BaseError {
94
+ constructor(bytes) {
95
+ super(`Bytes value "${bytes}" is not a valid boolean. The bytes array must contain a single byte of either a 0 or 1 value.`, { name: "InvalidBytesBooleanError" });
96
+ }
97
+ };
98
+ var SizeOverflowError = class extends BaseError {
99
+ constructor({ givenSize, maxSize }) {
100
+ super(`Size cannot exceed ${maxSize} bytes. Given size: ${givenSize} bytes.`, { name: "SizeOverflowError" });
101
+ }
102
+ };
103
+ //#endregion
104
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/utils/data/isHex.js
105
+ function isHex(value, { strict = true } = {}) {
106
+ if (!value) return false;
107
+ if (typeof value !== "string") return false;
108
+ return strict ? /^0x[0-9a-fA-F]*$/.test(value) : value.startsWith("0x");
109
+ }
110
+ //#endregion
111
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/utils/data/size.js
112
+ /**
113
+ * @description Retrieves the size of the value (in bytes).
114
+ *
115
+ * @param value The value (hex or byte array) to retrieve the size of.
116
+ * @returns The size of the value (in bytes).
117
+ */
118
+ function size(value) {
119
+ if (isHex(value, { strict: false })) return Math.ceil((value.length - 2) / 2);
120
+ return value.length;
121
+ }
122
+ //#endregion
123
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/utils/data/trim.js
124
+ function trim(hexOrBytes, { dir = "left" } = {}) {
125
+ let data = typeof hexOrBytes === "string" ? hexOrBytes.replace("0x", "") : hexOrBytes;
126
+ let sliceLength = 0;
127
+ for (let i = 0; i < data.length - 1; i++) if (data[dir === "left" ? i : data.length - i - 1].toString() === "0") sliceLength++;
128
+ else break;
129
+ data = dir === "left" ? data.slice(sliceLength) : data.slice(0, data.length - sliceLength);
130
+ if (typeof hexOrBytes === "string") {
131
+ if (data.length === 1 && dir === "right") data = `${data}0`;
132
+ return `0x${data.length % 2 === 1 ? `0${data}` : data}`;
133
+ }
134
+ return data;
135
+ }
136
+ //#endregion
137
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/errors/data.js
138
+ var SliceOffsetOutOfBoundsError = class extends BaseError {
139
+ constructor({ offset, position, size }) {
140
+ super(`Slice ${position === "start" ? "starting" : "ending"} at offset "${offset}" is out-of-bounds (size: ${size}).`, { name: "SliceOffsetOutOfBoundsError" });
141
+ }
142
+ };
143
+ var SizeExceedsPaddingSizeError = class extends BaseError {
144
+ constructor({ size, targetSize, type }) {
145
+ super(`${type.charAt(0).toUpperCase()}${type.slice(1).toLowerCase()} size (${size}) exceeds padding size (${targetSize}).`, { name: "SizeExceedsPaddingSizeError" });
146
+ }
147
+ };
148
+ //#endregion
149
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/utils/data/pad.js
150
+ function pad(hexOrBytes, { dir, size = 32 } = {}) {
151
+ if (typeof hexOrBytes === "string") return padHex(hexOrBytes, {
152
+ dir,
153
+ size
154
+ });
155
+ return padBytes(hexOrBytes, {
156
+ dir,
157
+ size
158
+ });
159
+ }
160
+ function padHex(hex_, { dir, size = 32 } = {}) {
161
+ if (size === null) return hex_;
162
+ const hex = hex_.replace("0x", "");
163
+ if (hex.length > size * 2) throw new SizeExceedsPaddingSizeError({
164
+ size: Math.ceil(hex.length / 2),
165
+ targetSize: size,
166
+ type: "hex"
167
+ });
168
+ return `0x${hex[dir === "right" ? "padEnd" : "padStart"](size * 2, "0")}`;
169
+ }
170
+ function padBytes(bytes, { dir, size = 32 } = {}) {
171
+ if (size === null) return bytes;
172
+ if (bytes.length > size) throw new SizeExceedsPaddingSizeError({
173
+ size: bytes.length,
174
+ targetSize: size,
175
+ type: "bytes"
176
+ });
177
+ const paddedBytes = new Uint8Array(size);
178
+ for (let i = 0; i < size; i++) {
179
+ const padEnd = dir === "right";
180
+ paddedBytes[padEnd ? i : size - i - 1] = bytes[padEnd ? i : bytes.length - i - 1];
181
+ }
182
+ return paddedBytes;
183
+ }
184
+ //#endregion
185
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/utils/encoding/toHex.js
186
+ const hexes = /*#__PURE__*/ Array.from({ length: 256 }, (_v, i) => i.toString(16).padStart(2, "0"));
187
+ /**
188
+ * Encodes a string, number, bigint, or ByteArray into a hex string
189
+ *
190
+ * - Docs: https://viem.sh/docs/utilities/toHex
191
+ * - Example: https://viem.sh/docs/utilities/toHex#usage
192
+ *
193
+ * @param value Value to encode.
194
+ * @param opts Options.
195
+ * @returns Hex value.
196
+ *
197
+ * @example
198
+ * import { toHex } from 'viem'
199
+ * const data = toHex('Hello world')
200
+ * // '0x48656c6c6f20776f726c6421'
201
+ *
202
+ * @example
203
+ * import { toHex } from 'viem'
204
+ * const data = toHex(420)
205
+ * // '0x1a4'
206
+ *
207
+ * @example
208
+ * import { toHex } from 'viem'
209
+ * const data = toHex('Hello world', { size: 32 })
210
+ * // '0x48656c6c6f20776f726c64210000000000000000000000000000000000000000'
211
+ */
212
+ function toHex(value, opts = {}) {
213
+ if (typeof value === "number" || typeof value === "bigint") return numberToHex(value, opts);
214
+ if (typeof value === "string") return stringToHex(value, opts);
215
+ if (typeof value === "boolean") return boolToHex(value, opts);
216
+ return bytesToHex(value, opts);
217
+ }
218
+ /**
219
+ * Encodes a boolean into a hex string
220
+ *
221
+ * - Docs: https://viem.sh/docs/utilities/toHex#booltohex
222
+ *
223
+ * @param value Value to encode.
224
+ * @param opts Options.
225
+ * @returns Hex value.
226
+ *
227
+ * @example
228
+ * import { boolToHex } from 'viem'
229
+ * const data = boolToHex(true)
230
+ * // '0x1'
231
+ *
232
+ * @example
233
+ * import { boolToHex } from 'viem'
234
+ * const data = boolToHex(false)
235
+ * // '0x0'
236
+ *
237
+ * @example
238
+ * import { boolToHex } from 'viem'
239
+ * const data = boolToHex(true, { size: 32 })
240
+ * // '0x0000000000000000000000000000000000000000000000000000000000000001'
241
+ */
242
+ function boolToHex(value, opts = {}) {
243
+ const hex = `0x${Number(value)}`;
244
+ if (typeof opts.size === "number") {
245
+ assertSize(hex, { size: opts.size });
246
+ return pad(hex, { size: opts.size });
247
+ }
248
+ return hex;
249
+ }
250
+ /**
251
+ * Encodes a bytes array into a hex string
252
+ *
253
+ * - Docs: https://viem.sh/docs/utilities/toHex#bytestohex
254
+ *
255
+ * @param value Value to encode.
256
+ * @param opts Options.
257
+ * @returns Hex value.
258
+ *
259
+ * @example
260
+ * import { bytesToHex } from 'viem'
261
+ * const data = bytesToHex(Uint8Array.from([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33])
262
+ * // '0x48656c6c6f20576f726c6421'
263
+ *
264
+ * @example
265
+ * import { bytesToHex } from 'viem'
266
+ * const data = bytesToHex(Uint8Array.from([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33]), { size: 32 })
267
+ * // '0x48656c6c6f20576f726c64210000000000000000000000000000000000000000'
268
+ */
269
+ function bytesToHex(value, opts = {}) {
270
+ let string = "";
271
+ for (let i = 0; i < value.length; i++) string += hexes[value[i]];
272
+ const hex = `0x${string}`;
273
+ if (typeof opts.size === "number") {
274
+ assertSize(hex, { size: opts.size });
275
+ return pad(hex, {
276
+ dir: "right",
277
+ size: opts.size
278
+ });
279
+ }
280
+ return hex;
281
+ }
282
+ /**
283
+ * Encodes a number or bigint into a hex string
284
+ *
285
+ * - Docs: https://viem.sh/docs/utilities/toHex#numbertohex
286
+ *
287
+ * @param value Value to encode.
288
+ * @param opts Options.
289
+ * @returns Hex value.
290
+ *
291
+ * @example
292
+ * import { numberToHex } from 'viem'
293
+ * const data = numberToHex(420)
294
+ * // '0x1a4'
295
+ *
296
+ * @example
297
+ * import { numberToHex } from 'viem'
298
+ * const data = numberToHex(420, { size: 32 })
299
+ * // '0x00000000000000000000000000000000000000000000000000000000000001a4'
300
+ */
301
+ function numberToHex(value_, opts = {}) {
302
+ const { signed, size } = opts;
303
+ const value = BigInt(value_);
304
+ let maxValue;
305
+ if (size) {
306
+ if (signed) maxValue = (1n << BigInt(size) * 8n - 1n) - 1n;
307
+ else maxValue = 2n ** (BigInt(size) * 8n) - 1n;
308
+ } else if (typeof value_ === "number") maxValue = BigInt(Number.MAX_SAFE_INTEGER);
309
+ const minValue = typeof maxValue === "bigint" && signed ? -maxValue - 1n : 0;
310
+ if (maxValue && value > maxValue || value < minValue) {
311
+ const suffix = typeof value_ === "bigint" ? "n" : "";
312
+ throw new IntegerOutOfRangeError({
313
+ max: maxValue ? `${maxValue}${suffix}` : void 0,
314
+ min: `${minValue}${suffix}`,
315
+ signed,
316
+ size,
317
+ value: `${value_}${suffix}`
318
+ });
319
+ }
320
+ const hex = `0x${(signed && value < 0 ? (1n << BigInt(size * 8)) + BigInt(value) : value).toString(16)}`;
321
+ if (size) return pad(hex, { size });
322
+ return hex;
323
+ }
324
+ const encoder$1 = /*#__PURE__*/ new TextEncoder();
325
+ /**
326
+ * Encodes a UTF-8 string into a hex string
327
+ *
328
+ * - Docs: https://viem.sh/docs/utilities/toHex#stringtohex
329
+ *
330
+ * @param value Value to encode.
331
+ * @param opts Options.
332
+ * @returns Hex value.
333
+ *
334
+ * @example
335
+ * import { stringToHex } from 'viem'
336
+ * const data = stringToHex('Hello World!')
337
+ * // '0x48656c6c6f20576f726c6421'
338
+ *
339
+ * @example
340
+ * import { stringToHex } from 'viem'
341
+ * const data = stringToHex('Hello World!', { size: 32 })
342
+ * // '0x48656c6c6f20576f726c64210000000000000000000000000000000000000000'
343
+ */
344
+ function stringToHex(value_, opts = {}) {
345
+ return bytesToHex(encoder$1.encode(value_), opts);
346
+ }
347
+ //#endregion
348
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/utils/encoding/toBytes.js
349
+ const encoder = /*#__PURE__*/ new TextEncoder();
350
+ /**
351
+ * Encodes a UTF-8 string, hex value, bigint, number or boolean to a byte array.
352
+ *
353
+ * - Docs: https://viem.sh/docs/utilities/toBytes
354
+ * - Example: https://viem.sh/docs/utilities/toBytes#usage
355
+ *
356
+ * @param value Value to encode.
357
+ * @param opts Options.
358
+ * @returns Byte array value.
359
+ *
360
+ * @example
361
+ * import { toBytes } from 'viem'
362
+ * const data = toBytes('Hello world')
363
+ * // Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33])
364
+ *
365
+ * @example
366
+ * import { toBytes } from 'viem'
367
+ * const data = toBytes(420)
368
+ * // Uint8Array([1, 164])
369
+ *
370
+ * @example
371
+ * import { toBytes } from 'viem'
372
+ * const data = toBytes(420, { size: 4 })
373
+ * // Uint8Array([0, 0, 1, 164])
374
+ */
375
+ function toBytes(value, opts = {}) {
376
+ if (typeof value === "number" || typeof value === "bigint") return numberToBytes(value, opts);
377
+ if (typeof value === "boolean") return boolToBytes(value, opts);
378
+ if (isHex(value)) return hexToBytes(value, opts);
379
+ return stringToBytes(value, opts);
380
+ }
381
+ /**
382
+ * Encodes a boolean into a byte array.
383
+ *
384
+ * - Docs: https://viem.sh/docs/utilities/toBytes#booltobytes
385
+ *
386
+ * @param value Boolean value to encode.
387
+ * @param opts Options.
388
+ * @returns Byte array value.
389
+ *
390
+ * @example
391
+ * import { boolToBytes } from 'viem'
392
+ * const data = boolToBytes(true)
393
+ * // Uint8Array([1])
394
+ *
395
+ * @example
396
+ * import { boolToBytes } from 'viem'
397
+ * const data = boolToBytes(true, { size: 32 })
398
+ * // Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1])
399
+ */
400
+ function boolToBytes(value, opts = {}) {
401
+ const bytes = /* @__PURE__ */ new Uint8Array(1);
402
+ bytes[0] = Number(value);
403
+ if (typeof opts.size === "number") {
404
+ assertSize(bytes, { size: opts.size });
405
+ return pad(bytes, { size: opts.size });
406
+ }
407
+ return bytes;
408
+ }
409
+ const charCodeMap = {
410
+ zero: 48,
411
+ nine: 57,
412
+ A: 65,
413
+ F: 70,
414
+ a: 97,
415
+ f: 102
416
+ };
417
+ function charCodeToBase16(char) {
418
+ if (char >= charCodeMap.zero && char <= charCodeMap.nine) return char - charCodeMap.zero;
419
+ if (char >= charCodeMap.A && char <= charCodeMap.F) return char - (charCodeMap.A - 10);
420
+ if (char >= charCodeMap.a && char <= charCodeMap.f) return char - (charCodeMap.a - 10);
421
+ }
422
+ /**
423
+ * Encodes a hex string into a byte array.
424
+ *
425
+ * - Docs: https://viem.sh/docs/utilities/toBytes#hextobytes
426
+ *
427
+ * @param hex Hex string to encode.
428
+ * @param opts Options.
429
+ * @returns Byte array value.
430
+ *
431
+ * @example
432
+ * import { hexToBytes } from 'viem'
433
+ * const data = hexToBytes('0x48656c6c6f20776f726c6421')
434
+ * // Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33])
435
+ *
436
+ * @example
437
+ * import { hexToBytes } from 'viem'
438
+ * const data = hexToBytes('0x48656c6c6f20776f726c6421', { size: 32 })
439
+ * // Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
440
+ */
441
+ function hexToBytes(hex_, opts = {}) {
442
+ let hex = hex_;
443
+ if (opts.size) {
444
+ assertSize(hex, { size: opts.size });
445
+ hex = pad(hex, {
446
+ dir: "right",
447
+ size: opts.size
448
+ });
449
+ }
450
+ let hexString = hex.slice(2);
451
+ if (hexString.length % 2) hexString = `0${hexString}`;
452
+ const length = hexString.length / 2;
453
+ const bytes = new Uint8Array(length);
454
+ for (let index = 0, j = 0; index < length; index++) {
455
+ const nibbleLeft = charCodeToBase16(hexString.charCodeAt(j++));
456
+ const nibbleRight = charCodeToBase16(hexString.charCodeAt(j++));
457
+ if (nibbleLeft === void 0 || nibbleRight === void 0) throw new BaseError(`Invalid byte sequence ("${hexString[j - 2]}${hexString[j - 1]}" in "${hexString}").`);
458
+ bytes[index] = nibbleLeft * 16 + nibbleRight;
459
+ }
460
+ return bytes;
461
+ }
462
+ /**
463
+ * Encodes a number into a byte array.
464
+ *
465
+ * - Docs: https://viem.sh/docs/utilities/toBytes#numbertobytes
466
+ *
467
+ * @param value Number to encode.
468
+ * @param opts Options.
469
+ * @returns Byte array value.
470
+ *
471
+ * @example
472
+ * import { numberToBytes } from 'viem'
473
+ * const data = numberToBytes(420)
474
+ * // Uint8Array([1, 164])
475
+ *
476
+ * @example
477
+ * import { numberToBytes } from 'viem'
478
+ * const data = numberToBytes(420, { size: 4 })
479
+ * // Uint8Array([0, 0, 1, 164])
480
+ */
481
+ function numberToBytes(value, opts) {
482
+ return hexToBytes(numberToHex(value, opts));
483
+ }
484
+ /**
485
+ * Encodes a UTF-8 string into a byte array.
486
+ *
487
+ * - Docs: https://viem.sh/docs/utilities/toBytes#stringtobytes
488
+ *
489
+ * @param value String to encode.
490
+ * @param opts Options.
491
+ * @returns Byte array value.
492
+ *
493
+ * @example
494
+ * import { stringToBytes } from 'viem'
495
+ * const data = stringToBytes('Hello world!')
496
+ * // Uint8Array([72, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100, 33])
497
+ *
498
+ * @example
499
+ * import { stringToBytes } from 'viem'
500
+ * const data = stringToBytes('Hello world!', { size: 32 })
501
+ * // Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
502
+ */
503
+ function stringToBytes(value, opts = {}) {
504
+ const bytes = encoder.encode(value);
505
+ if (typeof opts.size === "number") {
506
+ assertSize(bytes, { size: opts.size });
507
+ return pad(bytes, {
508
+ dir: "right",
509
+ size: opts.size
510
+ });
511
+ }
512
+ return bytes;
513
+ }
514
+ //#endregion
515
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/utils/encoding/fromHex.js
516
+ function assertSize(hexOrBytes, { size: size$1 }) {
517
+ if (size(hexOrBytes) > size$1) throw new SizeOverflowError({
518
+ givenSize: size(hexOrBytes),
519
+ maxSize: size$1
520
+ });
521
+ }
522
+ /**
523
+ * Decodes a hex value into a bigint.
524
+ *
525
+ * - Docs: https://viem.sh/docs/utilities/fromHex#hextobigint
526
+ *
527
+ * @param hex Hex value to decode.
528
+ * @param opts Options.
529
+ * @returns BigInt value.
530
+ *
531
+ * @example
532
+ * import { hexToBigInt } from 'viem'
533
+ * const data = hexToBigInt('0x1a4', { signed: true })
534
+ * // 420n
535
+ *
536
+ * @example
537
+ * import { hexToBigInt } from 'viem'
538
+ * const data = hexToBigInt('0x00000000000000000000000000000000000000000000000000000000000001a4', { size: 32 })
539
+ * // 420n
540
+ */
541
+ function hexToBigInt(hex, opts = {}) {
542
+ const { signed } = opts;
543
+ if (opts.size) assertSize(hex, { size: opts.size });
544
+ const value = BigInt(hex);
545
+ if (!signed) return value;
546
+ const size = (hex.length - 2) / 2;
547
+ if (value <= (1n << BigInt(size) * 8n - 1n) - 1n) return value;
548
+ return value - BigInt(`0x${"f".padStart(size * 2, "f")}`) - 1n;
549
+ }
550
+ /**
551
+ * Decodes a hex string into a number.
552
+ *
553
+ * - Docs: https://viem.sh/docs/utilities/fromHex#hextonumber
554
+ *
555
+ * @param hex Hex value to decode.
556
+ * @param opts Options.
557
+ * @returns Number value.
558
+ *
559
+ * @example
560
+ * import { hexToNumber } from 'viem'
561
+ * const data = hexToNumber('0x1a4')
562
+ * // 420
563
+ *
564
+ * @example
565
+ * import { hexToNumber } from 'viem'
566
+ * const data = hexToNumber('0x00000000000000000000000000000000000000000000000000000000000001a4', { size: 32 })
567
+ * // 420
568
+ */
569
+ function hexToNumber(hex, opts = {}) {
570
+ const value = hexToBigInt(hex, opts);
571
+ const number = Number(value);
572
+ if (!Number.isSafeInteger(number)) throw new IntegerOutOfRangeError({
573
+ max: `${Number.MAX_SAFE_INTEGER}`,
574
+ min: `${Number.MIN_SAFE_INTEGER}`,
575
+ signed: opts.signed,
576
+ size: opts.size,
577
+ value: `${value}n`
578
+ });
579
+ return number;
580
+ }
581
+ //#endregion
582
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/utils/data/concat.js
583
+ function concat(values) {
584
+ if (typeof values[0] === "string") return concatHex(values);
585
+ return concatBytes(values);
586
+ }
587
+ function concatBytes(values) {
588
+ let length = 0;
589
+ for (const arr of values) length += arr.length;
590
+ const result = new Uint8Array(length);
591
+ let offset = 0;
592
+ for (const arr of values) {
593
+ result.set(arr, offset);
594
+ offset += arr.length;
595
+ }
596
+ return result;
597
+ }
598
+ function concatHex(values) {
599
+ return `0x${values.reduce((acc, x) => acc + x.replace("0x", ""), "")}`;
600
+ }
601
+ //#endregion
602
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/errors/cursor.js
603
+ var NegativeOffsetError = class extends BaseError {
604
+ constructor({ offset }) {
605
+ super(`Offset \`${offset}\` cannot be negative.`, { name: "NegativeOffsetError" });
606
+ }
607
+ };
608
+ var PositionOutOfBoundsError = class extends BaseError {
609
+ constructor({ length, position }) {
610
+ super(`Position \`${position}\` is out of bounds (\`0 < position < ${length}\`).`, { name: "PositionOutOfBoundsError" });
611
+ }
612
+ };
613
+ var RecursiveReadLimitExceededError = class extends BaseError {
614
+ constructor({ count, limit }) {
615
+ super(`Recursive read limit of \`${limit}\` exceeded (recursive read count: \`${count}\`).`, { name: "RecursiveReadLimitExceededError" });
616
+ }
617
+ };
618
+ //#endregion
619
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/utils/cursor.js
620
+ const staticCursor = {
621
+ bytes: /* @__PURE__ */ new Uint8Array(),
622
+ dataView: /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(0)),
623
+ position: 0,
624
+ positionReadCount: /* @__PURE__ */ new Map(),
625
+ recursiveReadCount: 0,
626
+ recursiveReadLimit: Number.POSITIVE_INFINITY,
627
+ assertReadLimit() {
628
+ if (this.recursiveReadCount >= this.recursiveReadLimit) throw new RecursiveReadLimitExceededError({
629
+ count: this.recursiveReadCount + 1,
630
+ limit: this.recursiveReadLimit
631
+ });
632
+ },
633
+ assertPosition(position) {
634
+ if (position < 0 || position > this.bytes.length - 1) throw new PositionOutOfBoundsError({
635
+ length: this.bytes.length,
636
+ position
637
+ });
638
+ },
639
+ decrementPosition(offset) {
640
+ if (offset < 0) throw new NegativeOffsetError({ offset });
641
+ const position = this.position - offset;
642
+ this.assertPosition(position);
643
+ this.position = position;
644
+ },
645
+ getReadCount(position) {
646
+ return this.positionReadCount.get(position || this.position) || 0;
647
+ },
648
+ incrementPosition(offset) {
649
+ if (offset < 0) throw new NegativeOffsetError({ offset });
650
+ const position = this.position + offset;
651
+ this.assertPosition(position);
652
+ this.position = position;
653
+ },
654
+ inspectByte(position_) {
655
+ const position = position_ ?? this.position;
656
+ this.assertPosition(position);
657
+ return this.bytes[position];
658
+ },
659
+ inspectBytes(length, position_) {
660
+ const position = position_ ?? this.position;
661
+ this.assertPosition(position + length - 1);
662
+ return this.bytes.subarray(position, position + length);
663
+ },
664
+ inspectUint8(position_) {
665
+ const position = position_ ?? this.position;
666
+ this.assertPosition(position);
667
+ return this.bytes[position];
668
+ },
669
+ inspectUint16(position_) {
670
+ const position = position_ ?? this.position;
671
+ this.assertPosition(position + 1);
672
+ return this.dataView.getUint16(position);
673
+ },
674
+ inspectUint24(position_) {
675
+ const position = position_ ?? this.position;
676
+ this.assertPosition(position + 2);
677
+ return (this.dataView.getUint16(position) << 8) + this.dataView.getUint8(position + 2);
678
+ },
679
+ inspectUint32(position_) {
680
+ const position = position_ ?? this.position;
681
+ this.assertPosition(position + 3);
682
+ return this.dataView.getUint32(position);
683
+ },
684
+ pushByte(byte) {
685
+ this.assertPosition(this.position);
686
+ this.bytes[this.position] = byte;
687
+ this.position++;
688
+ },
689
+ pushBytes(bytes) {
690
+ this.assertPosition(this.position + bytes.length - 1);
691
+ this.bytes.set(bytes, this.position);
692
+ this.position += bytes.length;
693
+ },
694
+ pushUint8(value) {
695
+ this.assertPosition(this.position);
696
+ this.bytes[this.position] = value;
697
+ this.position++;
698
+ },
699
+ pushUint16(value) {
700
+ this.assertPosition(this.position + 1);
701
+ this.dataView.setUint16(this.position, value);
702
+ this.position += 2;
703
+ },
704
+ pushUint24(value) {
705
+ this.assertPosition(this.position + 2);
706
+ this.dataView.setUint16(this.position, value >> 8);
707
+ this.dataView.setUint8(this.position + 2, value & 255);
708
+ this.position += 3;
709
+ },
710
+ pushUint32(value) {
711
+ this.assertPosition(this.position + 3);
712
+ this.dataView.setUint32(this.position, value);
713
+ this.position += 4;
714
+ },
715
+ readByte() {
716
+ this.assertReadLimit();
717
+ this._touch();
718
+ const value = this.inspectByte();
719
+ this.position++;
720
+ return value;
721
+ },
722
+ readBytes(length, size) {
723
+ this.assertReadLimit();
724
+ this._touch();
725
+ const value = this.inspectBytes(length);
726
+ this.position += size ?? length;
727
+ return value;
728
+ },
729
+ readUint8() {
730
+ this.assertReadLimit();
731
+ this._touch();
732
+ const value = this.inspectUint8();
733
+ this.position += 1;
734
+ return value;
735
+ },
736
+ readUint16() {
737
+ this.assertReadLimit();
738
+ this._touch();
739
+ const value = this.inspectUint16();
740
+ this.position += 2;
741
+ return value;
742
+ },
743
+ readUint24() {
744
+ this.assertReadLimit();
745
+ this._touch();
746
+ const value = this.inspectUint24();
747
+ this.position += 3;
748
+ return value;
749
+ },
750
+ readUint32() {
751
+ this.assertReadLimit();
752
+ this._touch();
753
+ const value = this.inspectUint32();
754
+ this.position += 4;
755
+ return value;
756
+ },
757
+ get remaining() {
758
+ return this.bytes.length - this.position;
759
+ },
760
+ setPosition(position) {
761
+ const oldPosition = this.position;
762
+ this.assertPosition(position);
763
+ this.position = position;
764
+ return () => this.position = oldPosition;
765
+ },
766
+ _touch() {
767
+ if (this.recursiveReadLimit === Number.POSITIVE_INFINITY) return;
768
+ const count = this.getReadCount();
769
+ this.positionReadCount.set(this.position, count + 1);
770
+ if (count > 0) this.recursiveReadCount++;
771
+ }
772
+ };
773
+ function createCursor(bytes, { recursiveReadLimit = 8192 } = {}) {
774
+ const cursor = Object.create(staticCursor);
775
+ cursor.bytes = bytes;
776
+ cursor.dataView = new DataView(bytes.buffer ?? bytes, bytes.byteOffset, bytes.byteLength);
777
+ cursor.positionReadCount = /* @__PURE__ */ new Map();
778
+ cursor.recursiveReadLimit = recursiveReadLimit;
779
+ return cursor;
780
+ }
781
+ //#endregion
782
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/utils/encoding/toRlp.js
783
+ function toRlp(bytes, to = "hex") {
784
+ const encodable = getEncodable(bytes);
785
+ const cursor = createCursor(new Uint8Array(encodable.length));
786
+ encodable.encode(cursor);
787
+ if (to === "hex") return bytesToHex(cursor.bytes);
788
+ return cursor.bytes;
789
+ }
790
+ function getEncodable(bytes) {
791
+ if (Array.isArray(bytes)) return getEncodableList(bytes.map((x) => getEncodable(x)));
792
+ return getEncodableBytes(bytes);
793
+ }
794
+ function getEncodableList(list) {
795
+ const bodyLength = list.reduce((acc, x) => acc + x.length, 0);
796
+ const sizeOfBodyLength = getSizeOfLength(bodyLength);
797
+ return {
798
+ length: (() => {
799
+ if (bodyLength <= 55) return 1 + bodyLength;
800
+ return 1 + sizeOfBodyLength + bodyLength;
801
+ })(),
802
+ encode(cursor) {
803
+ if (bodyLength <= 55) cursor.pushByte(192 + bodyLength);
804
+ else {
805
+ cursor.pushByte(247 + sizeOfBodyLength);
806
+ if (sizeOfBodyLength === 1) cursor.pushUint8(bodyLength);
807
+ else if (sizeOfBodyLength === 2) cursor.pushUint16(bodyLength);
808
+ else if (sizeOfBodyLength === 3) cursor.pushUint24(bodyLength);
809
+ else cursor.pushUint32(bodyLength);
810
+ }
811
+ for (const { encode } of list) encode(cursor);
812
+ }
813
+ };
814
+ }
815
+ function getEncodableBytes(bytesOrHex) {
816
+ const bytes = typeof bytesOrHex === "string" ? hexToBytes(bytesOrHex) : bytesOrHex;
817
+ const sizeOfBytesLength = getSizeOfLength(bytes.length);
818
+ return {
819
+ length: (() => {
820
+ if (bytes.length === 1 && bytes[0] < 128) return 1;
821
+ if (bytes.length <= 55) return 1 + bytes.length;
822
+ return 1 + sizeOfBytesLength + bytes.length;
823
+ })(),
824
+ encode(cursor) {
825
+ if (bytes.length === 1 && bytes[0] < 128) cursor.pushBytes(bytes);
826
+ else if (bytes.length <= 55) {
827
+ cursor.pushByte(128 + bytes.length);
828
+ cursor.pushBytes(bytes);
829
+ } else {
830
+ cursor.pushByte(183 + sizeOfBytesLength);
831
+ if (sizeOfBytesLength === 1) cursor.pushUint8(bytes.length);
832
+ else if (sizeOfBytesLength === 2) cursor.pushUint16(bytes.length);
833
+ else if (sizeOfBytesLength === 3) cursor.pushUint24(bytes.length);
834
+ else cursor.pushUint32(bytes.length);
835
+ cursor.pushBytes(bytes);
836
+ }
837
+ }
838
+ };
839
+ }
840
+ function getSizeOfLength(length) {
841
+ if (length < 256) return 1;
842
+ if (length < 2 ** 16) return 2;
843
+ if (length < 2 ** 24) return 3;
844
+ if (length < 2 ** 32) return 4;
845
+ throw new BaseError("Length is too large.");
846
+ }
847
+ //#endregion
848
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/utils/unit/Value.js
849
+ /** @see https://ethereum.github.io/yellowpaper/paper.pdf */
850
+ const exponents = {
851
+ wei: 0,
852
+ gwei: 9,
853
+ szabo: 12,
854
+ finney: 15,
855
+ ether: 18
856
+ };
857
+ /**
858
+ * Formats a `bigint` Value to its string representation (divided by the given exponent).
859
+ *
860
+ * @example
861
+ * ```ts twoslash
862
+ * import { Value } from 'ox'
863
+ *
864
+ * Value.format(420_000_000_000n, 9)
865
+ * // @log: '420'
866
+ * ```
867
+ *
868
+ * @param value - The `bigint` Value to format.
869
+ * @param decimals - The exponent to divide the `bigint` Value by.
870
+ * @returns The string representation of the Value.
871
+ */
872
+ function format(value, decimals = 0) {
873
+ if (!Number.isInteger(decimals) || decimals < 0) throw new InvalidDecimalsError({ decimals });
874
+ let display = value.toString();
875
+ const negative = display.startsWith("-");
876
+ if (negative) display = display.slice(1);
877
+ display = display.padStart(decimals, "0");
878
+ let [integer, fraction] = [display.slice(0, display.length - decimals), display.slice(display.length - decimals)];
879
+ fraction = fraction.replace(/(0+)$/, "");
880
+ return `${negative ? "-" : ""}${integer || "0"}${fraction ? `.${fraction}` : ""}`;
881
+ }
882
+ /**
883
+ * Formats a `bigint` Value (default: wei) to a string representation of Gwei.
884
+ *
885
+ * @example
886
+ * ```ts twoslash
887
+ * import { Value } from 'ox'
888
+ *
889
+ * Value.formatGwei(1_000_000_000n)
890
+ * // @log: '1'
891
+ * ```
892
+ *
893
+ * @param wei - The Value to format.
894
+ * @param unit - The unit to format the Value in. @default 'wei'.
895
+ * @returns The Gwei string representation of the Value.
896
+ */
897
+ function formatGwei(wei, unit = "wei") {
898
+ return format(wei, exponents.gwei - exponents[unit]);
899
+ }
900
+ /**
901
+ * Thrown when the `decimals` argument is not a non-negative integer.
902
+ *
903
+ * @example
904
+ * ```ts twoslash
905
+ * import { Value } from 'ox'
906
+ *
907
+ * Value.from('1', -1)
908
+ * // @error: Value.InvalidDecimalsError: `decimals` must be a non-negative integer. Got `-1`.
909
+ * ```
910
+ */
911
+ var InvalidDecimalsError = class extends Error {
912
+ constructor({ decimals }) {
913
+ super(`\`decimals\` must be a non-negative integer. Got \`${decimals}\`.`);
914
+ Object.defineProperty(this, "name", {
915
+ enumerable: true,
916
+ configurable: true,
917
+ writable: true,
918
+ value: "Value.InvalidDecimalsError"
919
+ });
920
+ }
921
+ };
922
+ //#endregion
923
+ //#region ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/_u64.js
924
+ /**
925
+ * Internal helpers for u64. BigUint64Array is too slow as per 2025, so we implement it using Uint32Array.
926
+ * @todo re-check https://issues.chromium.org/issues/42212588
927
+ * @module
928
+ */
929
+ const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
930
+ const _32n = /* @__PURE__ */ BigInt(32);
931
+ function fromBig(n, le = false) {
932
+ if (le) return {
933
+ h: Number(n & U32_MASK64),
934
+ l: Number(n >> _32n & U32_MASK64)
935
+ };
936
+ return {
937
+ h: Number(n >> _32n & U32_MASK64) | 0,
938
+ l: Number(n & U32_MASK64) | 0
939
+ };
940
+ }
941
+ function split(lst, le = false) {
942
+ const len = lst.length;
943
+ let Ah = new Uint32Array(len);
944
+ let Al = new Uint32Array(len);
945
+ for (let i = 0; i < len; i++) {
946
+ const { h, l } = fromBig(lst[i], le);
947
+ [Ah[i], Al[i]] = [h, l];
948
+ }
949
+ return [Ah, Al];
950
+ }
951
+ const rotlSH = (h, l, s) => h << s | l >>> 32 - s;
952
+ const rotlSL = (h, l, s) => l << s | h >>> 32 - s;
953
+ const rotlBH = (h, l, s) => l << s - 32 | h >>> 64 - s;
954
+ const rotlBL = (h, l, s) => h << s - 32 | l >>> 64 - s;
955
+ //#endregion
956
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/errors/address.js
957
+ var InvalidAddressError = class extends BaseError {
958
+ constructor({ address }) {
959
+ super(`Address "${address}" is invalid.`, {
960
+ metaMessages: ["- Address must be a hex value of 20 bytes (40 hex characters).", "- Address must match its checksum counterpart."],
961
+ name: "InvalidAddressError"
962
+ });
963
+ }
964
+ };
965
+ //#endregion
966
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/utils/lru.js
967
+ /**
968
+ * Map with a LRU (Least recently used) policy.
969
+ *
970
+ * @link https://en.wikipedia.org/wiki/Cache_replacement_policies#LRU
971
+ */
972
+ var LruMap = class extends Map {
973
+ constructor(size) {
974
+ super();
975
+ Object.defineProperty(this, "maxSize", {
976
+ enumerable: true,
977
+ configurable: true,
978
+ writable: true,
979
+ value: void 0
980
+ });
981
+ this.maxSize = size;
982
+ }
983
+ get(key) {
984
+ const value = super.get(key);
985
+ if (super.has(key)) {
986
+ super.delete(key);
987
+ super.set(key, value);
988
+ }
989
+ return value;
990
+ }
991
+ set(key, value) {
992
+ if (super.has(key)) super.delete(key);
993
+ super.set(key, value);
994
+ if (this.maxSize && this.size > this.maxSize) {
995
+ const firstKey = super.keys().next().value;
996
+ if (firstKey !== void 0) super.delete(firstKey);
997
+ }
998
+ return this;
999
+ }
1000
+ };
1001
+ //#endregion
1002
+ //#region ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/sha3.js
1003
+ /**
1004
+ * SHA3 (keccak) hash function, based on a new "Sponge function" design.
1005
+ * Different from older hashes, the internal state is bigger than output size.
1006
+ *
1007
+ * Check out [FIPS-202](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf),
1008
+ * [Website](https://keccak.team/keccak.html),
1009
+ * [the differences between SHA-3 and Keccak](https://crypto.stackexchange.com/questions/15727/what-are-the-key-differences-between-the-draft-sha-3-standard-and-the-keccak-sub).
1010
+ *
1011
+ * Check out `sha3-addons` module for cSHAKE, k12, and others.
1012
+ * @module
1013
+ */
1014
+ const _0n = BigInt(0);
1015
+ const _1n = BigInt(1);
1016
+ const _2n = BigInt(2);
1017
+ const _7n = BigInt(7);
1018
+ const _256n = BigInt(256);
1019
+ const _0x71n = BigInt(113);
1020
+ const SHA3_PI = [];
1021
+ const SHA3_ROTL = [];
1022
+ const _SHA3_IOTA = [];
1023
+ for (let round = 0, R = _1n, x = 1, y = 0; round < 24; round++) {
1024
+ [x, y] = [y, (2 * x + 3 * y) % 5];
1025
+ SHA3_PI.push(2 * (5 * y + x));
1026
+ SHA3_ROTL.push((round + 1) * (round + 2) / 2 % 64);
1027
+ let t = _0n;
1028
+ for (let j = 0; j < 7; j++) {
1029
+ R = (R << _1n ^ (R >> _7n) * _0x71n) % _256n;
1030
+ if (R & _2n) t ^= _1n << (_1n << /* @__PURE__ */ BigInt(j)) - _1n;
1031
+ }
1032
+ _SHA3_IOTA.push(t);
1033
+ }
1034
+ const IOTAS = split(_SHA3_IOTA, true);
1035
+ const SHA3_IOTA_H = IOTAS[0];
1036
+ const SHA3_IOTA_L = IOTAS[1];
1037
+ const rotlH = (h, l, s) => s > 32 ? rotlBH(h, l, s) : rotlSH(h, l, s);
1038
+ const rotlL = (h, l, s) => s > 32 ? rotlBL(h, l, s) : rotlSL(h, l, s);
1039
+ /** `keccakf1600` internal function, additionally allows to adjust round count. */
1040
+ function keccakP(s, rounds = 24) {
1041
+ const B = /* @__PURE__ */ new Uint32Array(10);
1042
+ for (let round = 24 - rounds; round < 24; round++) {
1043
+ for (let x = 0; x < 10; x++) B[x] = s[x] ^ s[x + 10] ^ s[x + 20] ^ s[x + 30] ^ s[x + 40];
1044
+ for (let x = 0; x < 10; x += 2) {
1045
+ const idx1 = (x + 8) % 10;
1046
+ const idx0 = (x + 2) % 10;
1047
+ const B0 = B[idx0];
1048
+ const B1 = B[idx0 + 1];
1049
+ const Th = rotlH(B0, B1, 1) ^ B[idx1];
1050
+ const Tl = rotlL(B0, B1, 1) ^ B[idx1 + 1];
1051
+ for (let y = 0; y < 50; y += 10) {
1052
+ s[x + y] ^= Th;
1053
+ s[x + y + 1] ^= Tl;
1054
+ }
1055
+ }
1056
+ let curH = s[2];
1057
+ let curL = s[3];
1058
+ for (let t = 0; t < 24; t++) {
1059
+ const shift = SHA3_ROTL[t];
1060
+ const Th = rotlH(curH, curL, shift);
1061
+ const Tl = rotlL(curH, curL, shift);
1062
+ const PI = SHA3_PI[t];
1063
+ curH = s[PI];
1064
+ curL = s[PI + 1];
1065
+ s[PI] = Th;
1066
+ s[PI + 1] = Tl;
1067
+ }
1068
+ for (let y = 0; y < 50; y += 10) {
1069
+ for (let x = 0; x < 10; x++) B[x] = s[y + x];
1070
+ for (let x = 0; x < 10; x++) s[y + x] ^= ~B[(x + 2) % 10] & B[(x + 4) % 10];
1071
+ }
1072
+ s[0] ^= SHA3_IOTA_H[round];
1073
+ s[1] ^= SHA3_IOTA_L[round];
1074
+ }
1075
+ clean(B);
1076
+ }
1077
+ /** Keccak sponge function. */
1078
+ var Keccak = class Keccak extends Hash {
1079
+ constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) {
1080
+ super();
1081
+ this.pos = 0;
1082
+ this.posOut = 0;
1083
+ this.finished = false;
1084
+ this.destroyed = false;
1085
+ this.enableXOF = false;
1086
+ this.blockLen = blockLen;
1087
+ this.suffix = suffix;
1088
+ this.outputLen = outputLen;
1089
+ this.enableXOF = enableXOF;
1090
+ this.rounds = rounds;
1091
+ anumber(outputLen);
1092
+ if (!(0 < blockLen && blockLen < 200)) throw new Error("only keccak-f1600 function is supported");
1093
+ this.state = /* @__PURE__ */ new Uint8Array(200);
1094
+ this.state32 = u32(this.state);
1095
+ }
1096
+ clone() {
1097
+ return this._cloneInto();
1098
+ }
1099
+ keccak() {
1100
+ swap32IfBE(this.state32);
1101
+ keccakP(this.state32, this.rounds);
1102
+ swap32IfBE(this.state32);
1103
+ this.posOut = 0;
1104
+ this.pos = 0;
1105
+ }
1106
+ update(data) {
1107
+ aexists(this);
1108
+ data = toBytes$1(data);
1109
+ abytes(data);
1110
+ const { blockLen, state } = this;
1111
+ const len = data.length;
1112
+ for (let pos = 0; pos < len;) {
1113
+ const take = Math.min(blockLen - this.pos, len - pos);
1114
+ for (let i = 0; i < take; i++) state[this.pos++] ^= data[pos++];
1115
+ if (this.pos === blockLen) this.keccak();
1116
+ }
1117
+ return this;
1118
+ }
1119
+ finish() {
1120
+ if (this.finished) return;
1121
+ this.finished = true;
1122
+ const { state, suffix, pos, blockLen } = this;
1123
+ state[pos] ^= suffix;
1124
+ if ((suffix & 128) !== 0 && pos === blockLen - 1) this.keccak();
1125
+ state[blockLen - 1] ^= 128;
1126
+ this.keccak();
1127
+ }
1128
+ writeInto(out) {
1129
+ aexists(this, false);
1130
+ abytes(out);
1131
+ this.finish();
1132
+ const bufferOut = this.state;
1133
+ const { blockLen } = this;
1134
+ for (let pos = 0, len = out.length; pos < len;) {
1135
+ if (this.posOut >= blockLen) this.keccak();
1136
+ const take = Math.min(blockLen - this.posOut, len - pos);
1137
+ out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos);
1138
+ this.posOut += take;
1139
+ pos += take;
1140
+ }
1141
+ return out;
1142
+ }
1143
+ xofInto(out) {
1144
+ if (!this.enableXOF) throw new Error("XOF is not possible for this instance");
1145
+ return this.writeInto(out);
1146
+ }
1147
+ xof(bytes) {
1148
+ anumber(bytes);
1149
+ return this.xofInto(new Uint8Array(bytes));
1150
+ }
1151
+ digestInto(out) {
1152
+ aoutput(out, this);
1153
+ if (this.finished) throw new Error("digest() was already called");
1154
+ this.writeInto(out);
1155
+ this.destroy();
1156
+ return out;
1157
+ }
1158
+ digest() {
1159
+ return this.digestInto(new Uint8Array(this.outputLen));
1160
+ }
1161
+ destroy() {
1162
+ this.destroyed = true;
1163
+ clean(this.state);
1164
+ }
1165
+ _cloneInto(to) {
1166
+ const { blockLen, suffix, outputLen, rounds, enableXOF } = this;
1167
+ to || (to = new Keccak(blockLen, suffix, outputLen, enableXOF, rounds));
1168
+ to.state32.set(this.state32);
1169
+ to.pos = this.pos;
1170
+ to.posOut = this.posOut;
1171
+ to.finished = this.finished;
1172
+ to.rounds = rounds;
1173
+ to.suffix = suffix;
1174
+ to.outputLen = outputLen;
1175
+ to.enableXOF = enableXOF;
1176
+ to.destroyed = this.destroyed;
1177
+ return to;
1178
+ }
1179
+ };
1180
+ const gen = (suffix, blockLen, outputLen) => createHasher(() => new Keccak(blockLen, suffix, outputLen));
1181
+ /** keccak-256 hash function. Different from SHA3-256. */
1182
+ const keccak_256 = /* @__PURE__ */ (() => gen(1, 136, 32))();
1183
+ //#endregion
1184
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/utils/hash/keccak256.js
1185
+ function keccak256(value, to_) {
1186
+ const to = to_ || "hex";
1187
+ const bytes = keccak_256(isHex(value, { strict: false }) ? toBytes(value) : value);
1188
+ if (to === "bytes") return bytes;
1189
+ return toHex(bytes);
1190
+ }
1191
+ //#endregion
1192
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/utils/address/getAddress.js
1193
+ const checksumAddressCache = /*#__PURE__*/ new LruMap(8192);
1194
+ function checksumAddress(address_, chainId) {
1195
+ if (checksumAddressCache.has(`${address_}.${chainId}`)) return checksumAddressCache.get(`${address_}.${chainId}`);
1196
+ const hexAddress = chainId ? `${chainId}${address_.toLowerCase()}` : address_.substring(2).toLowerCase();
1197
+ const hash = keccak256(stringToBytes(hexAddress), "bytes");
1198
+ const address = (chainId ? hexAddress.substring(`${chainId}0x`.length) : hexAddress).split("");
1199
+ for (let i = 0; i < 40; i += 2) {
1200
+ if (hash[i >> 1] >> 4 >= 8 && address[i]) address[i] = address[i].toUpperCase();
1201
+ if ((hash[i >> 1] & 15) >= 8 && address[i + 1]) address[i + 1] = address[i + 1].toUpperCase();
1202
+ }
1203
+ const result = `0x${address.join("")}`;
1204
+ checksumAddressCache.set(`${address_}.${chainId}`, result);
1205
+ return result;
1206
+ }
1207
+ function getAddress(address, chainId) {
1208
+ if (!isAddress(address, { strict: false })) throw new InvalidAddressError({ address });
1209
+ return checksumAddress(address, chainId);
1210
+ }
1211
+ //#endregion
1212
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/utils/address/isAddress.js
1213
+ const addressRegex = /^0x[a-fA-F0-9]{40}$/;
1214
+ /** @internal */
1215
+ const isAddressCache = /*#__PURE__*/ new LruMap(8192);
1216
+ function isAddress(address, options) {
1217
+ const { strict = true } = options ?? {};
1218
+ const cacheKey = `${address}.${strict}`;
1219
+ if (isAddressCache.has(cacheKey)) return isAddressCache.get(cacheKey);
1220
+ const result = (() => {
1221
+ if (!addressRegex.test(address)) return false;
1222
+ if (address.toLowerCase() === address) return true;
1223
+ if (strict) return checksumAddress(address) === address;
1224
+ return true;
1225
+ })();
1226
+ isAddressCache.set(cacheKey, result);
1227
+ return result;
1228
+ }
1229
+ //#endregion
1230
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/utils/data/slice.js
1231
+ /**
1232
+ * @description Returns a section of the hex or byte array given a start/end bytes offset.
1233
+ *
1234
+ * @param value The hex or byte array to slice.
1235
+ * @param start The start offset (in bytes).
1236
+ * @param end The end offset (in bytes).
1237
+ */
1238
+ function slice(value, start, end, { strict } = {}) {
1239
+ if (isHex(value, { strict: false })) return sliceHex(value, start, end, { strict });
1240
+ return sliceBytes(value, start, end, { strict });
1241
+ }
1242
+ function assertStartOffset(value, start) {
1243
+ if (typeof start === "number" && start > 0 && start > size(value) - 1) throw new SliceOffsetOutOfBoundsError({
1244
+ offset: start,
1245
+ position: "start",
1246
+ size: size(value)
1247
+ });
1248
+ }
1249
+ function assertEndOffset(value, start, end) {
1250
+ if (typeof start === "number" && typeof end === "number" && size(value) !== end - start) throw new SliceOffsetOutOfBoundsError({
1251
+ offset: end,
1252
+ position: "end",
1253
+ size: size(value)
1254
+ });
1255
+ }
1256
+ /**
1257
+ * @description Returns a section of the byte array given a start/end bytes offset.
1258
+ *
1259
+ * @param value The byte array to slice.
1260
+ * @param start The start offset (in bytes).
1261
+ * @param end The end offset (in bytes).
1262
+ */
1263
+ function sliceBytes(value_, start, end, { strict } = {}) {
1264
+ assertStartOffset(value_, start);
1265
+ const value = value_.slice(start, end);
1266
+ if (strict) assertEndOffset(value, start, end);
1267
+ return value;
1268
+ }
1269
+ /**
1270
+ * @description Returns a section of the hex value given a start/end bytes offset.
1271
+ *
1272
+ * @param value The hex value to slice.
1273
+ * @param start The start offset (in bytes).
1274
+ * @param end The end offset (in bytes).
1275
+ */
1276
+ function sliceHex(value_, start, end, { strict } = {}) {
1277
+ assertStartOffset(value_, start);
1278
+ const value = `0x${value_.replace("0x", "").slice((start ?? 0) * 2, (end ?? value_.length) * 2)}`;
1279
+ if (strict) assertEndOffset(value, start, end);
1280
+ return value;
1281
+ }
1282
+ //#endregion
1283
+ //#region ../../packages/protocol/src/primitives/record.ts
1284
+ /** A non-null object that is not an array: a value whose fields can be read by name. */
1285
+ function isRecord(value) {
1286
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1287
+ }
1288
+ /** The field `key` of `value` when `value` is a record, else undefined. */
1289
+ function readField(value, key) {
1290
+ return isRecord(value) ? value[key] : void 0;
1291
+ }
1292
+ //#endregion
1293
+ export { isHex as A, numberToHex as C, padHex as D, pad as E, InvalidBytesBooleanError as M, BaseError as N, trim as O, bytesToHex as S, toHex as T, hexToBigInt as _, isAddress as a, toBytes as b, keccak256 as c, formatGwei as d, toRlp as f, assertSize as g, concatHex as h, sliceBytes as i, IntegerOutOfRangeError as j, size as k, InvalidAddressError as l, concat as m, readField as n, checksumAddress as o, createCursor as p, slice as r, getAddress as s, isRecord as t, format as u, hexToNumber as v, stringToHex as w, boolToHex as x, hexToBytes as y };
1294
+
1295
+ //# sourceMappingURL=record-U7Yu4KQP.mjs.map