@inco/js 0.1.11 → 0.1.12

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.
@@ -41,1703 +41,6 @@ var __export = (target, all) => {
41
41
  };
42
42
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
43
43
 
44
- // node_modules/viem/_esm/errors/version.js
45
- var version = "2.22.23";
46
-
47
- // node_modules/viem/_esm/errors/base.js
48
- function walk(err, fn) {
49
- if (fn?.(err))
50
- return err;
51
- if (err && typeof err === "object" && "cause" in err && err.cause !== undefined)
52
- return walk(err.cause, fn);
53
- return fn ? null : err;
54
- }
55
- var errorConfig, BaseError;
56
- var init_base = __esm(() => {
57
- errorConfig = {
58
- getDocsUrl: ({ docsBaseUrl, docsPath = "", docsSlug }) => docsPath ? `${docsBaseUrl ?? "https://viem.sh"}${docsPath}${docsSlug ? `#${docsSlug}` : ""}` : undefined,
59
- version: `viem@${version}`
60
- };
61
- BaseError = class BaseError extends Error {
62
- constructor(shortMessage, args = {}) {
63
- const details = (() => {
64
- if (args.cause instanceof BaseError)
65
- return args.cause.details;
66
- if (args.cause?.message)
67
- return args.cause.message;
68
- return args.details;
69
- })();
70
- const docsPath = (() => {
71
- if (args.cause instanceof BaseError)
72
- return args.cause.docsPath || args.docsPath;
73
- return args.docsPath;
74
- })();
75
- const docsUrl = errorConfig.getDocsUrl?.({ ...args, docsPath });
76
- const message = [
77
- shortMessage || "An error occurred.",
78
- "",
79
- ...args.metaMessages ? [...args.metaMessages, ""] : [],
80
- ...docsUrl ? [`Docs: ${docsUrl}`] : [],
81
- ...details ? [`Details: ${details}`] : [],
82
- ...errorConfig.version ? [`Version: ${errorConfig.version}`] : []
83
- ].join(`
84
- `);
85
- super(message, args.cause ? { cause: args.cause } : undefined);
86
- Object.defineProperty(this, "details", {
87
- enumerable: true,
88
- configurable: true,
89
- writable: true,
90
- value: undefined
91
- });
92
- Object.defineProperty(this, "docsPath", {
93
- enumerable: true,
94
- configurable: true,
95
- writable: true,
96
- value: undefined
97
- });
98
- Object.defineProperty(this, "metaMessages", {
99
- enumerable: true,
100
- configurable: true,
101
- writable: true,
102
- value: undefined
103
- });
104
- Object.defineProperty(this, "shortMessage", {
105
- enumerable: true,
106
- configurable: true,
107
- writable: true,
108
- value: undefined
109
- });
110
- Object.defineProperty(this, "version", {
111
- enumerable: true,
112
- configurable: true,
113
- writable: true,
114
- value: undefined
115
- });
116
- Object.defineProperty(this, "name", {
117
- enumerable: true,
118
- configurable: true,
119
- writable: true,
120
- value: "BaseError"
121
- });
122
- this.details = details;
123
- this.docsPath = docsPath;
124
- this.metaMessages = args.metaMessages;
125
- this.name = args.name ?? this.name;
126
- this.shortMessage = shortMessage;
127
- this.version = version;
128
- }
129
- walk(fn) {
130
- return walk(this, fn);
131
- }
132
- };
133
- });
134
-
135
- // node_modules/viem/_esm/errors/encoding.js
136
- var IntegerOutOfRangeError, SizeOverflowError;
137
- var init_encoding = __esm(() => {
138
- init_base();
139
- IntegerOutOfRangeError = class IntegerOutOfRangeError extends BaseError {
140
- constructor({ max, min, signed, size, value }) {
141
- super(`Number "${value}" is not in safe ${size ? `${size * 8}-bit ${signed ? "signed" : "unsigned"} ` : ""}integer range ${max ? `(${min} to ${max})` : `(above ${min})`}`, { name: "IntegerOutOfRangeError" });
142
- }
143
- };
144
- SizeOverflowError = class SizeOverflowError extends BaseError {
145
- constructor({ givenSize, maxSize }) {
146
- super(`Size cannot exceed ${maxSize} bytes. Given size: ${givenSize} bytes.`, { name: "SizeOverflowError" });
147
- }
148
- };
149
- });
150
-
151
- // node_modules/viem/_esm/utils/data/isHex.js
152
- function isHex(value, { strict = true } = {}) {
153
- if (!value)
154
- return false;
155
- if (typeof value !== "string")
156
- return false;
157
- return strict ? /^0x[0-9a-fA-F]*$/.test(value) : value.startsWith("0x");
158
- }
159
-
160
- // node_modules/viem/_esm/utils/data/size.js
161
- function size(value) {
162
- if (isHex(value, { strict: false }))
163
- return Math.ceil((value.length - 2) / 2);
164
- return value.length;
165
- }
166
- var init_size = () => {
167
- };
168
-
169
- // node_modules/viem/_esm/utils/data/trim.js
170
- function trim(hexOrBytes, { dir = "left" } = {}) {
171
- let data = typeof hexOrBytes === "string" ? hexOrBytes.replace("0x", "") : hexOrBytes;
172
- let sliceLength = 0;
173
- for (let i = 0;i < data.length - 1; i++) {
174
- if (data[dir === "left" ? i : data.length - i - 1].toString() === "0")
175
- sliceLength++;
176
- else
177
- break;
178
- }
179
- data = dir === "left" ? data.slice(sliceLength) : data.slice(0, data.length - sliceLength);
180
- if (typeof hexOrBytes === "string") {
181
- if (data.length === 1 && dir === "right")
182
- data = `${data}0`;
183
- return `0x${data.length % 2 === 1 ? `0${data}` : data}`;
184
- }
185
- return data;
186
- }
187
-
188
- // node_modules/viem/_esm/errors/data.js
189
- var SliceOffsetOutOfBoundsError, SizeExceedsPaddingSizeError;
190
- var init_data = __esm(() => {
191
- init_base();
192
- SliceOffsetOutOfBoundsError = class SliceOffsetOutOfBoundsError extends BaseError {
193
- constructor({ offset, position, size: size2 }) {
194
- super(`Slice ${position === "start" ? "starting" : "ending"} at offset "${offset}" is out-of-bounds (size: ${size2}).`, { name: "SliceOffsetOutOfBoundsError" });
195
- }
196
- };
197
- SizeExceedsPaddingSizeError = class SizeExceedsPaddingSizeError extends BaseError {
198
- constructor({ size: size2, targetSize, type }) {
199
- super(`${type.charAt(0).toUpperCase()}${type.slice(1).toLowerCase()} size (${size2}) exceeds padding size (${targetSize}).`, { name: "SizeExceedsPaddingSizeError" });
200
- }
201
- };
202
- });
203
-
204
- // node_modules/viem/_esm/utils/data/pad.js
205
- function pad(hexOrBytes, { dir, size: size2 = 32 } = {}) {
206
- if (typeof hexOrBytes === "string")
207
- return padHex(hexOrBytes, { dir, size: size2 });
208
- return padBytes(hexOrBytes, { dir, size: size2 });
209
- }
210
- function padHex(hex_, { dir, size: size2 = 32 } = {}) {
211
- if (size2 === null)
212
- return hex_;
213
- const hex = hex_.replace("0x", "");
214
- if (hex.length > size2 * 2)
215
- throw new SizeExceedsPaddingSizeError({
216
- size: Math.ceil(hex.length / 2),
217
- targetSize: size2,
218
- type: "hex"
219
- });
220
- return `0x${hex[dir === "right" ? "padEnd" : "padStart"](size2 * 2, "0")}`;
221
- }
222
- function padBytes(bytes, { dir, size: size2 = 32 } = {}) {
223
- if (size2 === null)
224
- return bytes;
225
- if (bytes.length > size2)
226
- throw new SizeExceedsPaddingSizeError({
227
- size: bytes.length,
228
- targetSize: size2,
229
- type: "bytes"
230
- });
231
- const paddedBytes = new Uint8Array(size2);
232
- for (let i = 0;i < size2; i++) {
233
- const padEnd = dir === "right";
234
- paddedBytes[padEnd ? i : size2 - i - 1] = bytes[padEnd ? i : bytes.length - i - 1];
235
- }
236
- return paddedBytes;
237
- }
238
- var init_pad = __esm(() => {
239
- init_data();
240
- });
241
-
242
- // node_modules/viem/_esm/utils/encoding/toHex.js
243
- function toHex(value, opts = {}) {
244
- if (typeof value === "number" || typeof value === "bigint")
245
- return numberToHex(value, opts);
246
- if (typeof value === "string") {
247
- return stringToHex(value, opts);
248
- }
249
- if (typeof value === "boolean")
250
- return boolToHex(value, opts);
251
- return bytesToHex(value, opts);
252
- }
253
- function boolToHex(value, opts = {}) {
254
- const hex = `0x${Number(value)}`;
255
- if (typeof opts.size === "number") {
256
- assertSize(hex, { size: opts.size });
257
- return pad(hex, { size: opts.size });
258
- }
259
- return hex;
260
- }
261
- function bytesToHex(value, opts = {}) {
262
- let string = "";
263
- for (let i = 0;i < value.length; i++) {
264
- string += hexes[value[i]];
265
- }
266
- const hex = `0x${string}`;
267
- if (typeof opts.size === "number") {
268
- assertSize(hex, { size: opts.size });
269
- return pad(hex, { dir: "right", size: opts.size });
270
- }
271
- return hex;
272
- }
273
- function numberToHex(value_, opts = {}) {
274
- const { signed, size: size2 } = opts;
275
- const value = BigInt(value_);
276
- let maxValue;
277
- if (size2) {
278
- if (signed)
279
- maxValue = (1n << BigInt(size2) * 8n - 1n) - 1n;
280
- else
281
- maxValue = 2n ** (BigInt(size2) * 8n) - 1n;
282
- } else if (typeof value_ === "number") {
283
- maxValue = BigInt(Number.MAX_SAFE_INTEGER);
284
- }
285
- const minValue = typeof maxValue === "bigint" && signed ? -maxValue - 1n : 0;
286
- if (maxValue && value > maxValue || value < minValue) {
287
- const suffix = typeof value_ === "bigint" ? "n" : "";
288
- throw new IntegerOutOfRangeError({
289
- max: maxValue ? `${maxValue}${suffix}` : undefined,
290
- min: `${minValue}${suffix}`,
291
- signed,
292
- size: size2,
293
- value: `${value_}${suffix}`
294
- });
295
- }
296
- const hex = `0x${(signed && value < 0 ? (1n << BigInt(size2 * 8)) + BigInt(value) : value).toString(16)}`;
297
- if (size2)
298
- return pad(hex, { size: size2 });
299
- return hex;
300
- }
301
- function stringToHex(value_, opts = {}) {
302
- const value = encoder.encode(value_);
303
- return bytesToHex(value, opts);
304
- }
305
- var hexes, encoder;
306
- var init_toHex = __esm(() => {
307
- init_encoding();
308
- init_pad();
309
- init_fromHex();
310
- hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_v, i) => i.toString(16).padStart(2, "0"));
311
- encoder = /* @__PURE__ */ new TextEncoder;
312
- });
313
-
314
- // node_modules/viem/_esm/utils/encoding/toBytes.js
315
- function toBytes(value, opts = {}) {
316
- if (typeof value === "number" || typeof value === "bigint")
317
- return numberToBytes(value, opts);
318
- if (typeof value === "boolean")
319
- return boolToBytes(value, opts);
320
- if (isHex(value))
321
- return hexToBytes(value, opts);
322
- return stringToBytes(value, opts);
323
- }
324
- function boolToBytes(value, opts = {}) {
325
- const bytes = new Uint8Array(1);
326
- bytes[0] = Number(value);
327
- if (typeof opts.size === "number") {
328
- assertSize(bytes, { size: opts.size });
329
- return pad(bytes, { size: opts.size });
330
- }
331
- return bytes;
332
- }
333
- function charCodeToBase16(char) {
334
- if (char >= charCodeMap.zero && char <= charCodeMap.nine)
335
- return char - charCodeMap.zero;
336
- if (char >= charCodeMap.A && char <= charCodeMap.F)
337
- return char - (charCodeMap.A - 10);
338
- if (char >= charCodeMap.a && char <= charCodeMap.f)
339
- return char - (charCodeMap.a - 10);
340
- return;
341
- }
342
- function hexToBytes(hex_, opts = {}) {
343
- let hex = hex_;
344
- if (opts.size) {
345
- assertSize(hex, { size: opts.size });
346
- hex = pad(hex, { dir: "right", size: opts.size });
347
- }
348
- let hexString = hex.slice(2);
349
- if (hexString.length % 2)
350
- hexString = `0${hexString}`;
351
- const length = hexString.length / 2;
352
- const bytes = new Uint8Array(length);
353
- for (let index = 0, j = 0;index < length; index++) {
354
- const nibbleLeft = charCodeToBase16(hexString.charCodeAt(j++));
355
- const nibbleRight = charCodeToBase16(hexString.charCodeAt(j++));
356
- if (nibbleLeft === undefined || nibbleRight === undefined) {
357
- throw new BaseError(`Invalid byte sequence ("${hexString[j - 2]}${hexString[j - 1]}" in "${hexString}").`);
358
- }
359
- bytes[index] = nibbleLeft * 16 + nibbleRight;
360
- }
361
- return bytes;
362
- }
363
- function numberToBytes(value, opts) {
364
- const hex = numberToHex(value, opts);
365
- return hexToBytes(hex);
366
- }
367
- function stringToBytes(value, opts = {}) {
368
- const bytes = encoder2.encode(value);
369
- if (typeof opts.size === "number") {
370
- assertSize(bytes, { size: opts.size });
371
- return pad(bytes, { dir: "right", size: opts.size });
372
- }
373
- return bytes;
374
- }
375
- var encoder2, charCodeMap;
376
- var init_toBytes = __esm(() => {
377
- init_base();
378
- init_pad();
379
- init_fromHex();
380
- init_toHex();
381
- encoder2 = /* @__PURE__ */ new TextEncoder;
382
- charCodeMap = {
383
- zero: 48,
384
- nine: 57,
385
- A: 65,
386
- F: 70,
387
- a: 97,
388
- f: 102
389
- };
390
- });
391
-
392
- // node_modules/viem/_esm/utils/encoding/fromHex.js
393
- function assertSize(hexOrBytes, { size: size2 }) {
394
- if (size(hexOrBytes) > size2)
395
- throw new SizeOverflowError({
396
- givenSize: size(hexOrBytes),
397
- maxSize: size2
398
- });
399
- }
400
- function hexToBigInt(hex, opts = {}) {
401
- const { signed } = opts;
402
- if (opts.size)
403
- assertSize(hex, { size: opts.size });
404
- const value = BigInt(hex);
405
- if (!signed)
406
- return value;
407
- const size2 = (hex.length - 2) / 2;
408
- const max = (1n << BigInt(size2) * 8n - 1n) - 1n;
409
- if (value <= max)
410
- return value;
411
- return value - BigInt(`0x${"f".padStart(size2 * 2, "f")}`) - 1n;
412
- }
413
- function hexToNumber(hex, opts = {}) {
414
- return Number(hexToBigInt(hex, opts));
415
- }
416
- var init_fromHex = __esm(() => {
417
- init_encoding();
418
- init_size();
419
- });
420
-
421
- // node_modules/viem/_esm/utils/formatters/formatter.js
422
- function defineFormatter(type, format) {
423
- return ({ exclude, format: overrides }) => {
424
- return {
425
- exclude,
426
- format: (args) => {
427
- const formatted = format(args);
428
- if (exclude) {
429
- for (const key of exclude) {
430
- delete formatted[key];
431
- }
432
- }
433
- return {
434
- ...formatted,
435
- ...overrides(args)
436
- };
437
- },
438
- type
439
- };
440
- };
441
- }
442
-
443
- // node_modules/viem/_esm/constants/number.js
444
- var maxInt8, maxInt16, maxInt24, maxInt32, maxInt40, maxInt48, maxInt56, maxInt64, maxInt72, maxInt80, maxInt88, maxInt96, maxInt104, maxInt112, maxInt120, maxInt128, maxInt136, maxInt144, maxInt152, maxInt160, maxInt168, maxInt176, maxInt184, maxInt192, maxInt200, maxInt208, maxInt216, maxInt224, maxInt232, maxInt240, maxInt248, maxInt256, minInt8, minInt16, minInt24, minInt32, minInt40, minInt48, minInt56, minInt64, minInt72, minInt80, minInt88, minInt96, minInt104, minInt112, minInt120, minInt128, minInt136, minInt144, minInt152, minInt160, minInt168, minInt176, minInt184, minInt192, minInt200, minInt208, minInt216, minInt224, minInt232, minInt240, minInt248, minInt256, maxUint8, maxUint16, maxUint24, maxUint32, maxUint40, maxUint48, maxUint56, maxUint64, maxUint72, maxUint80, maxUint88, maxUint96, maxUint104, maxUint112, maxUint120, maxUint128, maxUint136, maxUint144, maxUint152, maxUint160, maxUint168, maxUint176, maxUint184, maxUint192, maxUint200, maxUint208, maxUint216, maxUint224, maxUint232, maxUint240, maxUint248, maxUint256;
445
- var init_number = __esm(() => {
446
- maxInt8 = 2n ** (8n - 1n) - 1n;
447
- maxInt16 = 2n ** (16n - 1n) - 1n;
448
- maxInt24 = 2n ** (24n - 1n) - 1n;
449
- maxInt32 = 2n ** (32n - 1n) - 1n;
450
- maxInt40 = 2n ** (40n - 1n) - 1n;
451
- maxInt48 = 2n ** (48n - 1n) - 1n;
452
- maxInt56 = 2n ** (56n - 1n) - 1n;
453
- maxInt64 = 2n ** (64n - 1n) - 1n;
454
- maxInt72 = 2n ** (72n - 1n) - 1n;
455
- maxInt80 = 2n ** (80n - 1n) - 1n;
456
- maxInt88 = 2n ** (88n - 1n) - 1n;
457
- maxInt96 = 2n ** (96n - 1n) - 1n;
458
- maxInt104 = 2n ** (104n - 1n) - 1n;
459
- maxInt112 = 2n ** (112n - 1n) - 1n;
460
- maxInt120 = 2n ** (120n - 1n) - 1n;
461
- maxInt128 = 2n ** (128n - 1n) - 1n;
462
- maxInt136 = 2n ** (136n - 1n) - 1n;
463
- maxInt144 = 2n ** (144n - 1n) - 1n;
464
- maxInt152 = 2n ** (152n - 1n) - 1n;
465
- maxInt160 = 2n ** (160n - 1n) - 1n;
466
- maxInt168 = 2n ** (168n - 1n) - 1n;
467
- maxInt176 = 2n ** (176n - 1n) - 1n;
468
- maxInt184 = 2n ** (184n - 1n) - 1n;
469
- maxInt192 = 2n ** (192n - 1n) - 1n;
470
- maxInt200 = 2n ** (200n - 1n) - 1n;
471
- maxInt208 = 2n ** (208n - 1n) - 1n;
472
- maxInt216 = 2n ** (216n - 1n) - 1n;
473
- maxInt224 = 2n ** (224n - 1n) - 1n;
474
- maxInt232 = 2n ** (232n - 1n) - 1n;
475
- maxInt240 = 2n ** (240n - 1n) - 1n;
476
- maxInt248 = 2n ** (248n - 1n) - 1n;
477
- maxInt256 = 2n ** (256n - 1n) - 1n;
478
- minInt8 = -(2n ** (8n - 1n));
479
- minInt16 = -(2n ** (16n - 1n));
480
- minInt24 = -(2n ** (24n - 1n));
481
- minInt32 = -(2n ** (32n - 1n));
482
- minInt40 = -(2n ** (40n - 1n));
483
- minInt48 = -(2n ** (48n - 1n));
484
- minInt56 = -(2n ** (56n - 1n));
485
- minInt64 = -(2n ** (64n - 1n));
486
- minInt72 = -(2n ** (72n - 1n));
487
- minInt80 = -(2n ** (80n - 1n));
488
- minInt88 = -(2n ** (88n - 1n));
489
- minInt96 = -(2n ** (96n - 1n));
490
- minInt104 = -(2n ** (104n - 1n));
491
- minInt112 = -(2n ** (112n - 1n));
492
- minInt120 = -(2n ** (120n - 1n));
493
- minInt128 = -(2n ** (128n - 1n));
494
- minInt136 = -(2n ** (136n - 1n));
495
- minInt144 = -(2n ** (144n - 1n));
496
- minInt152 = -(2n ** (152n - 1n));
497
- minInt160 = -(2n ** (160n - 1n));
498
- minInt168 = -(2n ** (168n - 1n));
499
- minInt176 = -(2n ** (176n - 1n));
500
- minInt184 = -(2n ** (184n - 1n));
501
- minInt192 = -(2n ** (192n - 1n));
502
- minInt200 = -(2n ** (200n - 1n));
503
- minInt208 = -(2n ** (208n - 1n));
504
- minInt216 = -(2n ** (216n - 1n));
505
- minInt224 = -(2n ** (224n - 1n));
506
- minInt232 = -(2n ** (232n - 1n));
507
- minInt240 = -(2n ** (240n - 1n));
508
- minInt248 = -(2n ** (248n - 1n));
509
- minInt256 = -(2n ** (256n - 1n));
510
- maxUint8 = 2n ** 8n - 1n;
511
- maxUint16 = 2n ** 16n - 1n;
512
- maxUint24 = 2n ** 24n - 1n;
513
- maxUint32 = 2n ** 32n - 1n;
514
- maxUint40 = 2n ** 40n - 1n;
515
- maxUint48 = 2n ** 48n - 1n;
516
- maxUint56 = 2n ** 56n - 1n;
517
- maxUint64 = 2n ** 64n - 1n;
518
- maxUint72 = 2n ** 72n - 1n;
519
- maxUint80 = 2n ** 80n - 1n;
520
- maxUint88 = 2n ** 88n - 1n;
521
- maxUint96 = 2n ** 96n - 1n;
522
- maxUint104 = 2n ** 104n - 1n;
523
- maxUint112 = 2n ** 112n - 1n;
524
- maxUint120 = 2n ** 120n - 1n;
525
- maxUint128 = 2n ** 128n - 1n;
526
- maxUint136 = 2n ** 136n - 1n;
527
- maxUint144 = 2n ** 144n - 1n;
528
- maxUint152 = 2n ** 152n - 1n;
529
- maxUint160 = 2n ** 160n - 1n;
530
- maxUint168 = 2n ** 168n - 1n;
531
- maxUint176 = 2n ** 176n - 1n;
532
- maxUint184 = 2n ** 184n - 1n;
533
- maxUint192 = 2n ** 192n - 1n;
534
- maxUint200 = 2n ** 200n - 1n;
535
- maxUint208 = 2n ** 208n - 1n;
536
- maxUint216 = 2n ** 216n - 1n;
537
- maxUint224 = 2n ** 224n - 1n;
538
- maxUint232 = 2n ** 232n - 1n;
539
- maxUint240 = 2n ** 240n - 1n;
540
- maxUint248 = 2n ** 248n - 1n;
541
- maxUint256 = 2n ** 256n - 1n;
542
- });
543
-
544
- // node_modules/viem/_esm/utils/data/concat.js
545
- function concatHex(values) {
546
- return `0x${values.reduce((acc, x) => acc + x.replace("0x", ""), "")}`;
547
- }
548
-
549
- // node_modules/viem/_esm/errors/cursor.js
550
- var NegativeOffsetError, PositionOutOfBoundsError, RecursiveReadLimitExceededError;
551
- var init_cursor = __esm(() => {
552
- init_base();
553
- NegativeOffsetError = class NegativeOffsetError extends BaseError {
554
- constructor({ offset }) {
555
- super(`Offset \`${offset}\` cannot be negative.`, {
556
- name: "NegativeOffsetError"
557
- });
558
- }
559
- };
560
- PositionOutOfBoundsError = class PositionOutOfBoundsError extends BaseError {
561
- constructor({ length, position }) {
562
- super(`Position \`${position}\` is out of bounds (\`0 < position < ${length}\`).`, { name: "PositionOutOfBoundsError" });
563
- }
564
- };
565
- RecursiveReadLimitExceededError = class RecursiveReadLimitExceededError extends BaseError {
566
- constructor({ count, limit }) {
567
- super(`Recursive read limit of \`${limit}\` exceeded (recursive read count: \`${count}\`).`, { name: "RecursiveReadLimitExceededError" });
568
- }
569
- };
570
- });
571
-
572
- // node_modules/viem/_esm/utils/cursor.js
573
- function createCursor(bytes, { recursiveReadLimit = 8192 } = {}) {
574
- const cursor = Object.create(staticCursor);
575
- cursor.bytes = bytes;
576
- cursor.dataView = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
577
- cursor.positionReadCount = new Map;
578
- cursor.recursiveReadLimit = recursiveReadLimit;
579
- return cursor;
580
- }
581
- var staticCursor;
582
- var init_cursor2 = __esm(() => {
583
- init_cursor();
584
- staticCursor = {
585
- bytes: new Uint8Array,
586
- dataView: new DataView(new ArrayBuffer(0)),
587
- position: 0,
588
- positionReadCount: new Map,
589
- recursiveReadCount: 0,
590
- recursiveReadLimit: Number.POSITIVE_INFINITY,
591
- assertReadLimit() {
592
- if (this.recursiveReadCount >= this.recursiveReadLimit)
593
- throw new RecursiveReadLimitExceededError({
594
- count: this.recursiveReadCount + 1,
595
- limit: this.recursiveReadLimit
596
- });
597
- },
598
- assertPosition(position) {
599
- if (position < 0 || position > this.bytes.length - 1)
600
- throw new PositionOutOfBoundsError({
601
- length: this.bytes.length,
602
- position
603
- });
604
- },
605
- decrementPosition(offset) {
606
- if (offset < 0)
607
- throw new NegativeOffsetError({ offset });
608
- const position = this.position - offset;
609
- this.assertPosition(position);
610
- this.position = position;
611
- },
612
- getReadCount(position) {
613
- return this.positionReadCount.get(position || this.position) || 0;
614
- },
615
- incrementPosition(offset) {
616
- if (offset < 0)
617
- throw new NegativeOffsetError({ offset });
618
- const position = this.position + offset;
619
- this.assertPosition(position);
620
- this.position = position;
621
- },
622
- inspectByte(position_) {
623
- const position = position_ ?? this.position;
624
- this.assertPosition(position);
625
- return this.bytes[position];
626
- },
627
- inspectBytes(length, position_) {
628
- const position = position_ ?? this.position;
629
- this.assertPosition(position + length - 1);
630
- return this.bytes.subarray(position, position + length);
631
- },
632
- inspectUint8(position_) {
633
- const position = position_ ?? this.position;
634
- this.assertPosition(position);
635
- return this.bytes[position];
636
- },
637
- inspectUint16(position_) {
638
- const position = position_ ?? this.position;
639
- this.assertPosition(position + 1);
640
- return this.dataView.getUint16(position);
641
- },
642
- inspectUint24(position_) {
643
- const position = position_ ?? this.position;
644
- this.assertPosition(position + 2);
645
- return (this.dataView.getUint16(position) << 8) + this.dataView.getUint8(position + 2);
646
- },
647
- inspectUint32(position_) {
648
- const position = position_ ?? this.position;
649
- this.assertPosition(position + 3);
650
- return this.dataView.getUint32(position);
651
- },
652
- pushByte(byte) {
653
- this.assertPosition(this.position);
654
- this.bytes[this.position] = byte;
655
- this.position++;
656
- },
657
- pushBytes(bytes) {
658
- this.assertPosition(this.position + bytes.length - 1);
659
- this.bytes.set(bytes, this.position);
660
- this.position += bytes.length;
661
- },
662
- pushUint8(value) {
663
- this.assertPosition(this.position);
664
- this.bytes[this.position] = value;
665
- this.position++;
666
- },
667
- pushUint16(value) {
668
- this.assertPosition(this.position + 1);
669
- this.dataView.setUint16(this.position, value);
670
- this.position += 2;
671
- },
672
- pushUint24(value) {
673
- this.assertPosition(this.position + 2);
674
- this.dataView.setUint16(this.position, value >> 8);
675
- this.dataView.setUint8(this.position + 2, value & ~4294967040);
676
- this.position += 3;
677
- },
678
- pushUint32(value) {
679
- this.assertPosition(this.position + 3);
680
- this.dataView.setUint32(this.position, value);
681
- this.position += 4;
682
- },
683
- readByte() {
684
- this.assertReadLimit();
685
- this._touch();
686
- const value = this.inspectByte();
687
- this.position++;
688
- return value;
689
- },
690
- readBytes(length, size2) {
691
- this.assertReadLimit();
692
- this._touch();
693
- const value = this.inspectBytes(length);
694
- this.position += size2 ?? length;
695
- return value;
696
- },
697
- readUint8() {
698
- this.assertReadLimit();
699
- this._touch();
700
- const value = this.inspectUint8();
701
- this.position += 1;
702
- return value;
703
- },
704
- readUint16() {
705
- this.assertReadLimit();
706
- this._touch();
707
- const value = this.inspectUint16();
708
- this.position += 2;
709
- return value;
710
- },
711
- readUint24() {
712
- this.assertReadLimit();
713
- this._touch();
714
- const value = this.inspectUint24();
715
- this.position += 3;
716
- return value;
717
- },
718
- readUint32() {
719
- this.assertReadLimit();
720
- this._touch();
721
- const value = this.inspectUint32();
722
- this.position += 4;
723
- return value;
724
- },
725
- get remaining() {
726
- return this.bytes.length - this.position;
727
- },
728
- setPosition(position) {
729
- const oldPosition = this.position;
730
- this.assertPosition(position);
731
- this.position = position;
732
- return () => this.position = oldPosition;
733
- },
734
- _touch() {
735
- if (this.recursiveReadLimit === Number.POSITIVE_INFINITY)
736
- return;
737
- const count = this.getReadCount();
738
- this.positionReadCount.set(this.position, count + 1);
739
- if (count > 0)
740
- this.recursiveReadCount++;
741
- }
742
- };
743
- });
744
-
745
- // node_modules/viem/_esm/constants/unit.js
746
- var gweiUnits;
747
- var init_unit = __esm(() => {
748
- gweiUnits = {
749
- ether: -9,
750
- wei: 9
751
- };
752
- });
753
-
754
- // node_modules/viem/_esm/utils/unit/formatUnits.js
755
- function formatUnits(value, decimals) {
756
- let display = value.toString();
757
- const negative = display.startsWith("-");
758
- if (negative)
759
- display = display.slice(1);
760
- display = display.padStart(decimals, "0");
761
- let [integer, fraction] = [
762
- display.slice(0, display.length - decimals),
763
- display.slice(display.length - decimals)
764
- ];
765
- fraction = fraction.replace(/(0+)$/, "");
766
- return `${negative ? "-" : ""}${integer || "0"}${fraction ? `.${fraction}` : ""}`;
767
- }
768
-
769
- // node_modules/viem/_esm/utils/unit/formatGwei.js
770
- function formatGwei(wei, unit = "wei") {
771
- return formatUnits(wei, gweiUnits[unit]);
772
- }
773
- var init_formatGwei = __esm(() => {
774
- init_unit();
775
- });
776
-
777
- // node_modules/viem/_esm/errors/transaction.js
778
- function prettyPrint(args) {
779
- const entries = Object.entries(args).map(([key, value]) => {
780
- if (value === undefined || value === false)
781
- return null;
782
- return [key, value];
783
- }).filter(Boolean);
784
- const maxLength = entries.reduce((acc, [key]) => Math.max(acc, key.length), 0);
785
- return entries.map(([key, value]) => ` ${`${key}:`.padEnd(maxLength + 1)} ${value}`).join(`
786
- `);
787
- }
788
- var InvalidLegacyVError, InvalidSerializableTransactionError, InvalidStorageKeySizeError;
789
- var init_transaction = __esm(() => {
790
- init_base();
791
- InvalidLegacyVError = class InvalidLegacyVError extends BaseError {
792
- constructor({ v }) {
793
- super(`Invalid \`v\` value "${v}". Expected 27 or 28.`, {
794
- name: "InvalidLegacyVError"
795
- });
796
- }
797
- };
798
- InvalidSerializableTransactionError = class InvalidSerializableTransactionError extends BaseError {
799
- constructor({ transaction }) {
800
- super("Cannot infer a transaction type from provided transaction.", {
801
- metaMessages: [
802
- "Provided Transaction:",
803
- "{",
804
- prettyPrint(transaction),
805
- "}",
806
- "",
807
- "To infer the type, either provide:",
808
- "- a `type` to the Transaction, or",
809
- "- an EIP-1559 Transaction with `maxFeePerGas`, or",
810
- "- an EIP-2930 Transaction with `gasPrice` & `accessList`, or",
811
- "- an EIP-4844 Transaction with `blobs`, `blobVersionedHashes`, `sidecars`, or",
812
- "- an EIP-7702 Transaction with `authorizationList`, or",
813
- "- a Legacy Transaction with `gasPrice`"
814
- ],
815
- name: "InvalidSerializableTransactionError"
816
- });
817
- }
818
- };
819
- InvalidStorageKeySizeError = class InvalidStorageKeySizeError extends BaseError {
820
- constructor({ storageKey }) {
821
- super(`Size for storage key "${storageKey}" is invalid. Expected 32 bytes. Got ${Math.floor((storageKey.length - 2) / 2)} bytes.`, { name: "InvalidStorageKeySizeError" });
822
- }
823
- };
824
- });
825
-
826
- // ../node_modules/@noble/hashes/esm/_assert.js
827
- function anumber(n) {
828
- if (!Number.isSafeInteger(n) || n < 0)
829
- throw new Error("positive integer expected, got " + n);
830
- }
831
- function isBytes(a) {
832
- return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
833
- }
834
- function abytes(b, ...lengths) {
835
- if (!isBytes(b))
836
- throw new Error("Uint8Array expected");
837
- if (lengths.length > 0 && !lengths.includes(b.length))
838
- throw new Error("Uint8Array expected of length " + lengths + ", got length=" + b.length);
839
- }
840
- function aexists(instance, checkFinished = true) {
841
- if (instance.destroyed)
842
- throw new Error("Hash instance has been destroyed");
843
- if (checkFinished && instance.finished)
844
- throw new Error("Hash#digest() has already been called");
845
- }
846
- function aoutput(out, instance) {
847
- abytes(out);
848
- const min = instance.outputLen;
849
- if (out.length < min) {
850
- throw new Error("digestInto() expects output buffer of length at least " + min);
851
- }
852
- }
853
- var init__assert = () => {
854
- };
855
-
856
- // ../node_modules/@noble/hashes/esm/utils.js
857
- function u32(arr) {
858
- return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
859
- }
860
- function createView(arr) {
861
- return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
862
- }
863
- function rotr(word, shift) {
864
- return word << 32 - shift | word >>> shift;
865
- }
866
- function byteSwap(word) {
867
- return word << 24 & 4278190080 | word << 8 & 16711680 | word >>> 8 & 65280 | word >>> 24 & 255;
868
- }
869
- function byteSwap32(arr) {
870
- for (let i = 0;i < arr.length; i++) {
871
- arr[i] = byteSwap(arr[i]);
872
- }
873
- }
874
- function utf8ToBytes(str) {
875
- if (typeof str !== "string")
876
- throw new Error("utf8ToBytes expected string, got " + typeof str);
877
- return new Uint8Array(new TextEncoder().encode(str));
878
- }
879
- function toBytes2(data) {
880
- if (typeof data === "string")
881
- data = utf8ToBytes(data);
882
- abytes(data);
883
- return data;
884
- }
885
-
886
- class Hash {
887
- clone() {
888
- return this._cloneInto();
889
- }
890
- }
891
- function wrapConstructor(hashCons) {
892
- const hashC = (msg) => hashCons().update(toBytes2(msg)).digest();
893
- const tmp = hashCons();
894
- hashC.outputLen = tmp.outputLen;
895
- hashC.blockLen = tmp.blockLen;
896
- hashC.create = () => hashCons();
897
- return hashC;
898
- }
899
- function wrapXOFConstructorWithOpts(hashCons) {
900
- const hashC = (msg, opts) => hashCons(opts).update(toBytes2(msg)).digest();
901
- const tmp = hashCons({});
902
- hashC.outputLen = tmp.outputLen;
903
- hashC.blockLen = tmp.blockLen;
904
- hashC.create = (opts) => hashCons(opts);
905
- return hashC;
906
- }
907
- var isLE;
908
- var init_utils = __esm(() => {
909
- init__assert();
910
- /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
911
- isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68)();
912
- });
913
-
914
- // ../node_modules/@noble/hashes/esm/_md.js
915
- function setBigUint64(view, byteOffset, value, isLE2) {
916
- if (typeof view.setBigUint64 === "function")
917
- return view.setBigUint64(byteOffset, value, isLE2);
918
- const _32n = BigInt(32);
919
- const _u32_max = BigInt(4294967295);
920
- const wh = Number(value >> _32n & _u32_max);
921
- const wl = Number(value & _u32_max);
922
- const h = isLE2 ? 4 : 0;
923
- const l = isLE2 ? 0 : 4;
924
- view.setUint32(byteOffset + h, wh, isLE2);
925
- view.setUint32(byteOffset + l, wl, isLE2);
926
- }
927
- function Chi(a, b, c) {
928
- return a & b ^ ~a & c;
929
- }
930
- function Maj(a, b, c) {
931
- return a & b ^ a & c ^ b & c;
932
- }
933
- var HashMD;
934
- var init__md = __esm(() => {
935
- init__assert();
936
- init_utils();
937
- HashMD = class HashMD extends Hash {
938
- constructor(blockLen, outputLen, padOffset, isLE2) {
939
- super();
940
- this.blockLen = blockLen;
941
- this.outputLen = outputLen;
942
- this.padOffset = padOffset;
943
- this.isLE = isLE2;
944
- this.finished = false;
945
- this.length = 0;
946
- this.pos = 0;
947
- this.destroyed = false;
948
- this.buffer = new Uint8Array(blockLen);
949
- this.view = createView(this.buffer);
950
- }
951
- update(data) {
952
- aexists(this);
953
- const { view, buffer, blockLen } = this;
954
- data = toBytes2(data);
955
- const len = data.length;
956
- for (let pos = 0;pos < len; ) {
957
- const take = Math.min(blockLen - this.pos, len - pos);
958
- if (take === blockLen) {
959
- const dataView = createView(data);
960
- for (;blockLen <= len - pos; pos += blockLen)
961
- this.process(dataView, pos);
962
- continue;
963
- }
964
- buffer.set(data.subarray(pos, pos + take), this.pos);
965
- this.pos += take;
966
- pos += take;
967
- if (this.pos === blockLen) {
968
- this.process(view, 0);
969
- this.pos = 0;
970
- }
971
- }
972
- this.length += data.length;
973
- this.roundClean();
974
- return this;
975
- }
976
- digestInto(out) {
977
- aexists(this);
978
- aoutput(out, this);
979
- this.finished = true;
980
- const { buffer, view, blockLen, isLE: isLE2 } = this;
981
- let { pos } = this;
982
- buffer[pos++] = 128;
983
- this.buffer.subarray(pos).fill(0);
984
- if (this.padOffset > blockLen - pos) {
985
- this.process(view, 0);
986
- pos = 0;
987
- }
988
- for (let i = pos;i < blockLen; i++)
989
- buffer[i] = 0;
990
- setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE2);
991
- this.process(view, 0);
992
- const oview = createView(out);
993
- const len = this.outputLen;
994
- if (len % 4)
995
- throw new Error("_sha2: outputLen should be aligned to 32bit");
996
- const outLen = len / 4;
997
- const state = this.get();
998
- if (outLen > state.length)
999
- throw new Error("_sha2: outputLen bigger than state");
1000
- for (let i = 0;i < outLen; i++)
1001
- oview.setUint32(4 * i, state[i], isLE2);
1002
- }
1003
- digest() {
1004
- const { buffer, outputLen } = this;
1005
- this.digestInto(buffer);
1006
- const res = buffer.slice(0, outputLen);
1007
- this.destroy();
1008
- return res;
1009
- }
1010
- _cloneInto(to) {
1011
- to || (to = new this.constructor);
1012
- to.set(...this.get());
1013
- const { blockLen, buffer, length, finished, destroyed, pos } = this;
1014
- to.length = length;
1015
- to.pos = pos;
1016
- to.finished = finished;
1017
- to.destroyed = destroyed;
1018
- if (length % blockLen)
1019
- to.buffer.set(buffer);
1020
- return to;
1021
- }
1022
- };
1023
- });
1024
-
1025
- // ../node_modules/@noble/hashes/esm/sha256.js
1026
- var SHA256_K, SHA256_IV, SHA256_W, SHA256, sha256;
1027
- var init_sha256 = __esm(() => {
1028
- init__md();
1029
- init_utils();
1030
- SHA256_K = /* @__PURE__ */ new Uint32Array([
1031
- 1116352408,
1032
- 1899447441,
1033
- 3049323471,
1034
- 3921009573,
1035
- 961987163,
1036
- 1508970993,
1037
- 2453635748,
1038
- 2870763221,
1039
- 3624381080,
1040
- 310598401,
1041
- 607225278,
1042
- 1426881987,
1043
- 1925078388,
1044
- 2162078206,
1045
- 2614888103,
1046
- 3248222580,
1047
- 3835390401,
1048
- 4022224774,
1049
- 264347078,
1050
- 604807628,
1051
- 770255983,
1052
- 1249150122,
1053
- 1555081692,
1054
- 1996064986,
1055
- 2554220882,
1056
- 2821834349,
1057
- 2952996808,
1058
- 3210313671,
1059
- 3336571891,
1060
- 3584528711,
1061
- 113926993,
1062
- 338241895,
1063
- 666307205,
1064
- 773529912,
1065
- 1294757372,
1066
- 1396182291,
1067
- 1695183700,
1068
- 1986661051,
1069
- 2177026350,
1070
- 2456956037,
1071
- 2730485921,
1072
- 2820302411,
1073
- 3259730800,
1074
- 3345764771,
1075
- 3516065817,
1076
- 3600352804,
1077
- 4094571909,
1078
- 275423344,
1079
- 430227734,
1080
- 506948616,
1081
- 659060556,
1082
- 883997877,
1083
- 958139571,
1084
- 1322822218,
1085
- 1537002063,
1086
- 1747873779,
1087
- 1955562222,
1088
- 2024104815,
1089
- 2227730452,
1090
- 2361852424,
1091
- 2428436474,
1092
- 2756734187,
1093
- 3204031479,
1094
- 3329325298
1095
- ]);
1096
- SHA256_IV = /* @__PURE__ */ new Uint32Array([
1097
- 1779033703,
1098
- 3144134277,
1099
- 1013904242,
1100
- 2773480762,
1101
- 1359893119,
1102
- 2600822924,
1103
- 528734635,
1104
- 1541459225
1105
- ]);
1106
- SHA256_W = /* @__PURE__ */ new Uint32Array(64);
1107
- SHA256 = class SHA256 extends HashMD {
1108
- constructor() {
1109
- super(64, 32, 8, false);
1110
- this.A = SHA256_IV[0] | 0;
1111
- this.B = SHA256_IV[1] | 0;
1112
- this.C = SHA256_IV[2] | 0;
1113
- this.D = SHA256_IV[3] | 0;
1114
- this.E = SHA256_IV[4] | 0;
1115
- this.F = SHA256_IV[5] | 0;
1116
- this.G = SHA256_IV[6] | 0;
1117
- this.H = SHA256_IV[7] | 0;
1118
- }
1119
- get() {
1120
- const { A, B, C, D, E, F, G, H } = this;
1121
- return [A, B, C, D, E, F, G, H];
1122
- }
1123
- set(A, B, C, D, E, F, G, H) {
1124
- this.A = A | 0;
1125
- this.B = B | 0;
1126
- this.C = C | 0;
1127
- this.D = D | 0;
1128
- this.E = E | 0;
1129
- this.F = F | 0;
1130
- this.G = G | 0;
1131
- this.H = H | 0;
1132
- }
1133
- process(view, offset) {
1134
- for (let i = 0;i < 16; i++, offset += 4)
1135
- SHA256_W[i] = view.getUint32(offset, false);
1136
- for (let i = 16;i < 64; i++) {
1137
- const W15 = SHA256_W[i - 15];
1138
- const W2 = SHA256_W[i - 2];
1139
- const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ W15 >>> 3;
1140
- const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ W2 >>> 10;
1141
- SHA256_W[i] = s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16] | 0;
1142
- }
1143
- let { A, B, C, D, E, F, G, H } = this;
1144
- for (let i = 0;i < 64; i++) {
1145
- const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);
1146
- const T1 = H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i] | 0;
1147
- const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);
1148
- const T2 = sigma0 + Maj(A, B, C) | 0;
1149
- H = G;
1150
- G = F;
1151
- F = E;
1152
- E = D + T1 | 0;
1153
- D = C;
1154
- C = B;
1155
- B = A;
1156
- A = T1 + T2 | 0;
1157
- }
1158
- A = A + this.A | 0;
1159
- B = B + this.B | 0;
1160
- C = C + this.C | 0;
1161
- D = D + this.D | 0;
1162
- E = E + this.E | 0;
1163
- F = F + this.F | 0;
1164
- G = G + this.G | 0;
1165
- H = H + this.H | 0;
1166
- this.set(A, B, C, D, E, F, G, H);
1167
- }
1168
- roundClean() {
1169
- SHA256_W.fill(0);
1170
- }
1171
- destroy() {
1172
- this.set(0, 0, 0, 0, 0, 0, 0, 0);
1173
- this.buffer.fill(0);
1174
- }
1175
- };
1176
- sha256 = /* @__PURE__ */ wrapConstructor(() => new SHA256);
1177
- });
1178
-
1179
- // node_modules/viem/_esm/errors/address.js
1180
- var InvalidAddressError;
1181
- var init_address = __esm(() => {
1182
- init_base();
1183
- InvalidAddressError = class InvalidAddressError extends BaseError {
1184
- constructor({ address }) {
1185
- super(`Address "${address}" is invalid.`, {
1186
- metaMessages: [
1187
- "- Address must be a hex value of 20 bytes (40 hex characters).",
1188
- "- Address must match its checksum counterpart."
1189
- ],
1190
- name: "InvalidAddressError"
1191
- });
1192
- }
1193
- };
1194
- });
1195
-
1196
- // node_modules/viem/_esm/errors/chain.js
1197
- var InvalidChainIdError;
1198
- var init_chain = __esm(() => {
1199
- init_base();
1200
- InvalidChainIdError = class InvalidChainIdError extends BaseError {
1201
- constructor({ chainId }) {
1202
- super(typeof chainId === "number" ? `Chain ID "${chainId}" is invalid.` : "Chain ID is invalid.", { name: "InvalidChainIdError" });
1203
- }
1204
- };
1205
- });
1206
-
1207
- // node_modules/viem/_esm/errors/node.js
1208
- var ExecutionRevertedError, FeeCapTooHighError, FeeCapTooLowError, NonceTooHighError, NonceTooLowError, NonceMaxValueError, InsufficientFundsError, IntrinsicGasTooHighError, IntrinsicGasTooLowError, TransactionTypeNotSupportedError, TipAboveFeeCapError;
1209
- var init_node = __esm(() => {
1210
- init_formatGwei();
1211
- init_base();
1212
- ExecutionRevertedError = class ExecutionRevertedError extends BaseError {
1213
- constructor({ cause, message } = {}) {
1214
- const reason = message?.replace("execution reverted: ", "")?.replace("execution reverted", "");
1215
- super(`Execution reverted ${reason ? `with reason: ${reason}` : "for an unknown reason"}.`, {
1216
- cause,
1217
- name: "ExecutionRevertedError"
1218
- });
1219
- }
1220
- };
1221
- Object.defineProperty(ExecutionRevertedError, "code", {
1222
- enumerable: true,
1223
- configurable: true,
1224
- writable: true,
1225
- value: 3
1226
- });
1227
- Object.defineProperty(ExecutionRevertedError, "nodeMessage", {
1228
- enumerable: true,
1229
- configurable: true,
1230
- writable: true,
1231
- value: /execution reverted/
1232
- });
1233
- FeeCapTooHighError = class FeeCapTooHighError extends BaseError {
1234
- constructor({ cause, maxFeePerGas } = {}) {
1235
- super(`The fee cap (\`maxFeePerGas\`${maxFeePerGas ? ` = ${formatGwei(maxFeePerGas)} gwei` : ""}) cannot be higher than the maximum allowed value (2^256-1).`, {
1236
- cause,
1237
- name: "FeeCapTooHighError"
1238
- });
1239
- }
1240
- };
1241
- Object.defineProperty(FeeCapTooHighError, "nodeMessage", {
1242
- enumerable: true,
1243
- configurable: true,
1244
- writable: true,
1245
- value: /max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/
1246
- });
1247
- FeeCapTooLowError = class FeeCapTooLowError extends BaseError {
1248
- constructor({ cause, maxFeePerGas } = {}) {
1249
- super(`The fee cap (\`maxFeePerGas\`${maxFeePerGas ? ` = ${formatGwei(maxFeePerGas)}` : ""} gwei) cannot be lower than the block base fee.`, {
1250
- cause,
1251
- name: "FeeCapTooLowError"
1252
- });
1253
- }
1254
- };
1255
- Object.defineProperty(FeeCapTooLowError, "nodeMessage", {
1256
- enumerable: true,
1257
- configurable: true,
1258
- writable: true,
1259
- value: /max fee per gas less than block base fee|fee cap less than block base fee|transaction is outdated/
1260
- });
1261
- NonceTooHighError = class NonceTooHighError extends BaseError {
1262
- constructor({ cause, nonce } = {}) {
1263
- super(`Nonce provided for the transaction ${nonce ? `(${nonce}) ` : ""}is higher than the next one expected.`, { cause, name: "NonceTooHighError" });
1264
- }
1265
- };
1266
- Object.defineProperty(NonceTooHighError, "nodeMessage", {
1267
- enumerable: true,
1268
- configurable: true,
1269
- writable: true,
1270
- value: /nonce too high/
1271
- });
1272
- NonceTooLowError = class NonceTooLowError extends BaseError {
1273
- constructor({ cause, nonce } = {}) {
1274
- super([
1275
- `Nonce provided for the transaction ${nonce ? `(${nonce}) ` : ""}is lower than the current nonce of the account.`,
1276
- "Try increasing the nonce or find the latest nonce with `getTransactionCount`."
1277
- ].join(`
1278
- `), { cause, name: "NonceTooLowError" });
1279
- }
1280
- };
1281
- Object.defineProperty(NonceTooLowError, "nodeMessage", {
1282
- enumerable: true,
1283
- configurable: true,
1284
- writable: true,
1285
- value: /nonce too low|transaction already imported|already known/
1286
- });
1287
- NonceMaxValueError = class NonceMaxValueError extends BaseError {
1288
- constructor({ cause, nonce } = {}) {
1289
- super(`Nonce provided for the transaction ${nonce ? `(${nonce}) ` : ""}exceeds the maximum allowed nonce.`, { cause, name: "NonceMaxValueError" });
1290
- }
1291
- };
1292
- Object.defineProperty(NonceMaxValueError, "nodeMessage", {
1293
- enumerable: true,
1294
- configurable: true,
1295
- writable: true,
1296
- value: /nonce has max value/
1297
- });
1298
- InsufficientFundsError = class InsufficientFundsError extends BaseError {
1299
- constructor({ cause } = {}) {
1300
- super([
1301
- "The total cost (gas * gas fee + value) of executing this transaction exceeds the balance of the account."
1302
- ].join(`
1303
- `), {
1304
- cause,
1305
- metaMessages: [
1306
- "This error could arise when the account does not have enough funds to:",
1307
- " - pay for the total gas fee,",
1308
- " - pay for the value to send.",
1309
- " ",
1310
- "The cost of the transaction is calculated as `gas * gas fee + value`, where:",
1311
- " - `gas` is the amount of gas needed for transaction to execute,",
1312
- " - `gas fee` is the gas fee,",
1313
- " - `value` is the amount of ether to send to the recipient."
1314
- ],
1315
- name: "InsufficientFundsError"
1316
- });
1317
- }
1318
- };
1319
- Object.defineProperty(InsufficientFundsError, "nodeMessage", {
1320
- enumerable: true,
1321
- configurable: true,
1322
- writable: true,
1323
- value: /insufficient funds|exceeds transaction sender account balance/
1324
- });
1325
- IntrinsicGasTooHighError = class IntrinsicGasTooHighError extends BaseError {
1326
- constructor({ cause, gas } = {}) {
1327
- super(`The amount of gas ${gas ? `(${gas}) ` : ""}provided for the transaction exceeds the limit allowed for the block.`, {
1328
- cause,
1329
- name: "IntrinsicGasTooHighError"
1330
- });
1331
- }
1332
- };
1333
- Object.defineProperty(IntrinsicGasTooHighError, "nodeMessage", {
1334
- enumerable: true,
1335
- configurable: true,
1336
- writable: true,
1337
- value: /intrinsic gas too high|gas limit reached/
1338
- });
1339
- IntrinsicGasTooLowError = class IntrinsicGasTooLowError extends BaseError {
1340
- constructor({ cause, gas } = {}) {
1341
- super(`The amount of gas ${gas ? `(${gas}) ` : ""}provided for the transaction is too low.`, {
1342
- cause,
1343
- name: "IntrinsicGasTooLowError"
1344
- });
1345
- }
1346
- };
1347
- Object.defineProperty(IntrinsicGasTooLowError, "nodeMessage", {
1348
- enumerable: true,
1349
- configurable: true,
1350
- writable: true,
1351
- value: /intrinsic gas too low/
1352
- });
1353
- TransactionTypeNotSupportedError = class TransactionTypeNotSupportedError extends BaseError {
1354
- constructor({ cause }) {
1355
- super("The transaction type is not supported for this chain.", {
1356
- cause,
1357
- name: "TransactionTypeNotSupportedError"
1358
- });
1359
- }
1360
- };
1361
- Object.defineProperty(TransactionTypeNotSupportedError, "nodeMessage", {
1362
- enumerable: true,
1363
- configurable: true,
1364
- writable: true,
1365
- value: /transaction type not valid/
1366
- });
1367
- TipAboveFeeCapError = class TipAboveFeeCapError extends BaseError {
1368
- constructor({ cause, maxPriorityFeePerGas, maxFeePerGas } = {}) {
1369
- super([
1370
- `The provided tip (\`maxPriorityFeePerGas\`${maxPriorityFeePerGas ? ` = ${formatGwei(maxPriorityFeePerGas)} gwei` : ""}) cannot be higher than the fee cap (\`maxFeePerGas\`${maxFeePerGas ? ` = ${formatGwei(maxFeePerGas)} gwei` : ""}).`
1371
- ].join(`
1372
- `), {
1373
- cause,
1374
- name: "TipAboveFeeCapError"
1375
- });
1376
- }
1377
- };
1378
- Object.defineProperty(TipAboveFeeCapError, "nodeMessage", {
1379
- enumerable: true,
1380
- configurable: true,
1381
- writable: true,
1382
- value: /max priority fee per gas higher than max fee per gas|tip higher than fee cap/
1383
- });
1384
- });
1385
-
1386
- // node_modules/viem/_esm/utils/lru.js
1387
- var LruMap;
1388
- var init_lru = __esm(() => {
1389
- LruMap = class LruMap extends Map {
1390
- constructor(size2) {
1391
- super();
1392
- Object.defineProperty(this, "maxSize", {
1393
- enumerable: true,
1394
- configurable: true,
1395
- writable: true,
1396
- value: undefined
1397
- });
1398
- this.maxSize = size2;
1399
- }
1400
- get(key) {
1401
- const value = super.get(key);
1402
- if (super.has(key) && value !== undefined) {
1403
- this.delete(key);
1404
- super.set(key, value);
1405
- }
1406
- return value;
1407
- }
1408
- set(key, value) {
1409
- super.set(key, value);
1410
- if (this.maxSize && this.size > this.maxSize) {
1411
- const firstKey = this.keys().next().value;
1412
- if (firstKey)
1413
- this.delete(firstKey);
1414
- }
1415
- return this;
1416
- }
1417
- };
1418
- });
1419
-
1420
- // ../node_modules/@noble/hashes/esm/_u64.js
1421
- function fromBig(n, le = false) {
1422
- if (le)
1423
- return { h: Number(n & U32_MASK64), l: Number(n >> _32n & U32_MASK64) };
1424
- return { h: Number(n >> _32n & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };
1425
- }
1426
- function split(lst, le = false) {
1427
- let Ah = new Uint32Array(lst.length);
1428
- let Al = new Uint32Array(lst.length);
1429
- for (let i = 0;i < lst.length; i++) {
1430
- const { h, l } = fromBig(lst[i], le);
1431
- [Ah[i], Al[i]] = [h, l];
1432
- }
1433
- return [Ah, Al];
1434
- }
1435
- var U32_MASK64, _32n, rotlSH = (h, l, s) => h << s | l >>> 32 - s, rotlSL = (h, l, s) => l << s | h >>> 32 - s, rotlBH = (h, l, s) => l << s - 32 | h >>> 64 - s, rotlBL = (h, l, s) => h << s - 32 | l >>> 64 - s;
1436
- var init__u64 = __esm(() => {
1437
- U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
1438
- _32n = /* @__PURE__ */ BigInt(32);
1439
- });
1440
-
1441
- // ../node_modules/@noble/hashes/esm/sha3.js
1442
- function keccakP(s, rounds = 24) {
1443
- const B = new Uint32Array(5 * 2);
1444
- for (let round = 24 - rounds;round < 24; round++) {
1445
- for (let x = 0;x < 10; x++)
1446
- B[x] = s[x] ^ s[x + 10] ^ s[x + 20] ^ s[x + 30] ^ s[x + 40];
1447
- for (let x = 0;x < 10; x += 2) {
1448
- const idx1 = (x + 8) % 10;
1449
- const idx0 = (x + 2) % 10;
1450
- const B0 = B[idx0];
1451
- const B1 = B[idx0 + 1];
1452
- const Th = rotlH(B0, B1, 1) ^ B[idx1];
1453
- const Tl = rotlL(B0, B1, 1) ^ B[idx1 + 1];
1454
- for (let y = 0;y < 50; y += 10) {
1455
- s[x + y] ^= Th;
1456
- s[x + y + 1] ^= Tl;
1457
- }
1458
- }
1459
- let curH = s[2];
1460
- let curL = s[3];
1461
- for (let t = 0;t < 24; t++) {
1462
- const shift = SHA3_ROTL[t];
1463
- const Th = rotlH(curH, curL, shift);
1464
- const Tl = rotlL(curH, curL, shift);
1465
- const PI = SHA3_PI[t];
1466
- curH = s[PI];
1467
- curL = s[PI + 1];
1468
- s[PI] = Th;
1469
- s[PI + 1] = Tl;
1470
- }
1471
- for (let y = 0;y < 50; y += 10) {
1472
- for (let x = 0;x < 10; x++)
1473
- B[x] = s[y + x];
1474
- for (let x = 0;x < 10; x++)
1475
- s[y + x] ^= ~B[(x + 2) % 10] & B[(x + 4) % 10];
1476
- }
1477
- s[0] ^= SHA3_IOTA_H[round];
1478
- s[1] ^= SHA3_IOTA_L[round];
1479
- }
1480
- B.fill(0);
1481
- }
1482
- var SHA3_PI, SHA3_ROTL, _SHA3_IOTA, _0n, _1n, _2n, _7n, _256n, _0x71n, SHA3_IOTA_H, SHA3_IOTA_L, rotlH = (h, l, s) => s > 32 ? rotlBH(h, l, s) : rotlSH(h, l, s), rotlL = (h, l, s) => s > 32 ? rotlBL(h, l, s) : rotlSL(h, l, s), Keccak, gen = (suffix, blockLen, outputLen) => wrapConstructor(() => new Keccak(blockLen, suffix, outputLen)), sha3_224, sha3_256, sha3_384, sha3_512, keccak_224, keccak_256, keccak_384, keccak_512, genShake = (suffix, blockLen, outputLen) => wrapXOFConstructorWithOpts((opts = {}) => new Keccak(blockLen, suffix, opts.dkLen === undefined ? outputLen : opts.dkLen, true)), shake128, shake256;
1483
- var init_sha3 = __esm(() => {
1484
- init__assert();
1485
- init__u64();
1486
- init_utils();
1487
- SHA3_PI = [];
1488
- SHA3_ROTL = [];
1489
- _SHA3_IOTA = [];
1490
- _0n = /* @__PURE__ */ BigInt(0);
1491
- _1n = /* @__PURE__ */ BigInt(1);
1492
- _2n = /* @__PURE__ */ BigInt(2);
1493
- _7n = /* @__PURE__ */ BigInt(7);
1494
- _256n = /* @__PURE__ */ BigInt(256);
1495
- _0x71n = /* @__PURE__ */ BigInt(113);
1496
- for (let round = 0, R = _1n, x = 1, y = 0;round < 24; round++) {
1497
- [x, y] = [y, (2 * x + 3 * y) % 5];
1498
- SHA3_PI.push(2 * (5 * y + x));
1499
- SHA3_ROTL.push((round + 1) * (round + 2) / 2 % 64);
1500
- let t = _0n;
1501
- for (let j = 0;j < 7; j++) {
1502
- R = (R << _1n ^ (R >> _7n) * _0x71n) % _256n;
1503
- if (R & _2n)
1504
- t ^= _1n << (_1n << /* @__PURE__ */ BigInt(j)) - _1n;
1505
- }
1506
- _SHA3_IOTA.push(t);
1507
- }
1508
- [SHA3_IOTA_H, SHA3_IOTA_L] = /* @__PURE__ */ split(_SHA3_IOTA, true);
1509
- Keccak = class Keccak extends Hash {
1510
- constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) {
1511
- super();
1512
- this.blockLen = blockLen;
1513
- this.suffix = suffix;
1514
- this.outputLen = outputLen;
1515
- this.enableXOF = enableXOF;
1516
- this.rounds = rounds;
1517
- this.pos = 0;
1518
- this.posOut = 0;
1519
- this.finished = false;
1520
- this.destroyed = false;
1521
- anumber(outputLen);
1522
- if (0 >= this.blockLen || this.blockLen >= 200)
1523
- throw new Error("Sha3 supports only keccak-f1600 function");
1524
- this.state = new Uint8Array(200);
1525
- this.state32 = u32(this.state);
1526
- }
1527
- keccak() {
1528
- if (!isLE)
1529
- byteSwap32(this.state32);
1530
- keccakP(this.state32, this.rounds);
1531
- if (!isLE)
1532
- byteSwap32(this.state32);
1533
- this.posOut = 0;
1534
- this.pos = 0;
1535
- }
1536
- update(data) {
1537
- aexists(this);
1538
- const { blockLen, state } = this;
1539
- data = toBytes2(data);
1540
- const len = data.length;
1541
- for (let pos = 0;pos < len; ) {
1542
- const take = Math.min(blockLen - this.pos, len - pos);
1543
- for (let i = 0;i < take; i++)
1544
- state[this.pos++] ^= data[pos++];
1545
- if (this.pos === blockLen)
1546
- this.keccak();
1547
- }
1548
- return this;
1549
- }
1550
- finish() {
1551
- if (this.finished)
1552
- return;
1553
- this.finished = true;
1554
- const { state, suffix, pos, blockLen } = this;
1555
- state[pos] ^= suffix;
1556
- if ((suffix & 128) !== 0 && pos === blockLen - 1)
1557
- this.keccak();
1558
- state[blockLen - 1] ^= 128;
1559
- this.keccak();
1560
- }
1561
- writeInto(out) {
1562
- aexists(this, false);
1563
- abytes(out);
1564
- this.finish();
1565
- const bufferOut = this.state;
1566
- const { blockLen } = this;
1567
- for (let pos = 0, len = out.length;pos < len; ) {
1568
- if (this.posOut >= blockLen)
1569
- this.keccak();
1570
- const take = Math.min(blockLen - this.posOut, len - pos);
1571
- out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos);
1572
- this.posOut += take;
1573
- pos += take;
1574
- }
1575
- return out;
1576
- }
1577
- xofInto(out) {
1578
- if (!this.enableXOF)
1579
- throw new Error("XOF is not possible for this instance");
1580
- return this.writeInto(out);
1581
- }
1582
- xof(bytes) {
1583
- anumber(bytes);
1584
- return this.xofInto(new Uint8Array(bytes));
1585
- }
1586
- digestInto(out) {
1587
- aoutput(out, this);
1588
- if (this.finished)
1589
- throw new Error("digest() was already called");
1590
- this.writeInto(out);
1591
- this.destroy();
1592
- return out;
1593
- }
1594
- digest() {
1595
- return this.digestInto(new Uint8Array(this.outputLen));
1596
- }
1597
- destroy() {
1598
- this.destroyed = true;
1599
- this.state.fill(0);
1600
- }
1601
- _cloneInto(to) {
1602
- const { blockLen, suffix, outputLen, rounds, enableXOF } = this;
1603
- to || (to = new Keccak(blockLen, suffix, outputLen, enableXOF, rounds));
1604
- to.state32.set(this.state32);
1605
- to.pos = this.pos;
1606
- to.posOut = this.posOut;
1607
- to.finished = this.finished;
1608
- to.rounds = rounds;
1609
- to.suffix = suffix;
1610
- to.outputLen = outputLen;
1611
- to.enableXOF = enableXOF;
1612
- to.destroyed = this.destroyed;
1613
- return to;
1614
- }
1615
- };
1616
- sha3_224 = /* @__PURE__ */ gen(6, 144, 224 / 8);
1617
- sha3_256 = /* @__PURE__ */ gen(6, 136, 256 / 8);
1618
- sha3_384 = /* @__PURE__ */ gen(6, 104, 384 / 8);
1619
- sha3_512 = /* @__PURE__ */ gen(6, 72, 512 / 8);
1620
- keccak_224 = /* @__PURE__ */ gen(1, 144, 224 / 8);
1621
- keccak_256 = /* @__PURE__ */ gen(1, 136, 256 / 8);
1622
- keccak_384 = /* @__PURE__ */ gen(1, 104, 384 / 8);
1623
- keccak_512 = /* @__PURE__ */ gen(1, 72, 512 / 8);
1624
- shake128 = /* @__PURE__ */ genShake(31, 168, 128 / 8);
1625
- shake256 = /* @__PURE__ */ genShake(31, 136, 256 / 8);
1626
- });
1627
-
1628
- // node_modules/viem/_esm/utils/hash/keccak256.js
1629
- function keccak256(value, to_) {
1630
- const to = to_ || "hex";
1631
- const bytes = keccak_256(isHex(value, { strict: false }) ? toBytes(value) : value);
1632
- if (to === "bytes")
1633
- return bytes;
1634
- return toHex(bytes);
1635
- }
1636
- var init_keccak256 = __esm(() => {
1637
- init_sha3();
1638
- init_toBytes();
1639
- init_toHex();
1640
- });
1641
-
1642
- // node_modules/viem/_esm/utils/address/getAddress.js
1643
- function checksumAddress(address_, chainId) {
1644
- if (checksumAddressCache.has(`${address_}.${chainId}`))
1645
- return checksumAddressCache.get(`${address_}.${chainId}`);
1646
- const hexAddress = chainId ? `${chainId}${address_.toLowerCase()}` : address_.substring(2).toLowerCase();
1647
- const hash = keccak256(stringToBytes(hexAddress), "bytes");
1648
- const address = (chainId ? hexAddress.substring(`${chainId}0x`.length) : hexAddress).split("");
1649
- for (let i = 0;i < 40; i += 2) {
1650
- if (hash[i >> 1] >> 4 >= 8 && address[i]) {
1651
- address[i] = address[i].toUpperCase();
1652
- }
1653
- if ((hash[i >> 1] & 15) >= 8 && address[i + 1]) {
1654
- address[i + 1] = address[i + 1].toUpperCase();
1655
- }
1656
- }
1657
- const result = `0x${address.join("")}`;
1658
- checksumAddressCache.set(`${address_}.${chainId}`, result);
1659
- return result;
1660
- }
1661
- var checksumAddressCache;
1662
- var init_getAddress = __esm(() => {
1663
- init_toBytes();
1664
- init_keccak256();
1665
- init_lru();
1666
- checksumAddressCache = /* @__PURE__ */ new LruMap(8192);
1667
- });
1668
-
1669
- // node_modules/viem/_esm/utils/address/isAddress.js
1670
- function isAddress(address, options) {
1671
- const { strict = true } = options ?? {};
1672
- const cacheKey = `${address}.${strict}`;
1673
- if (isAddressCache.has(cacheKey))
1674
- return isAddressCache.get(cacheKey);
1675
- const result = (() => {
1676
- if (!addressRegex.test(address))
1677
- return false;
1678
- if (address.toLowerCase() === address)
1679
- return true;
1680
- if (strict)
1681
- return checksumAddress(address) === address;
1682
- return true;
1683
- })();
1684
- isAddressCache.set(cacheKey, result);
1685
- return result;
1686
- }
1687
- var addressRegex, isAddressCache;
1688
- var init_isAddress = __esm(() => {
1689
- init_lru();
1690
- init_getAddress();
1691
- addressRegex = /^0x[a-fA-F0-9]{40}$/;
1692
- isAddressCache = /* @__PURE__ */ new LruMap(8192);
1693
- });
1694
-
1695
- // node_modules/viem/_esm/utils/data/slice.js
1696
- function slice(value, start, end, { strict } = {}) {
1697
- if (isHex(value, { strict: false }))
1698
- return sliceHex(value, start, end, {
1699
- strict
1700
- });
1701
- return sliceBytes(value, start, end, {
1702
- strict
1703
- });
1704
- }
1705
- function assertStartOffset(value, start) {
1706
- if (typeof start === "number" && start > 0 && start > size(value) - 1)
1707
- throw new SliceOffsetOutOfBoundsError({
1708
- offset: start,
1709
- position: "start",
1710
- size: size(value)
1711
- });
1712
- }
1713
- function assertEndOffset(value, start, end) {
1714
- if (typeof start === "number" && typeof end === "number" && size(value) !== end - start) {
1715
- throw new SliceOffsetOutOfBoundsError({
1716
- offset: end,
1717
- position: "end",
1718
- size: size(value)
1719
- });
1720
- }
1721
- }
1722
- function sliceBytes(value_, start, end, { strict } = {}) {
1723
- assertStartOffset(value_, start);
1724
- const value = value_.slice(start, end);
1725
- if (strict)
1726
- assertEndOffset(value, start, end);
1727
- return value;
1728
- }
1729
- function sliceHex(value_, start, end, { strict } = {}) {
1730
- assertStartOffset(value_, start);
1731
- const value = `0x${value_.replace("0x", "").slice((start ?? 0) * 2, (end ?? value_.length) * 2)}`;
1732
- if (strict)
1733
- assertEndOffset(value, start, end);
1734
- return value;
1735
- }
1736
- var init_slice = __esm(() => {
1737
- init_data();
1738
- init_size();
1739
- });
1740
-
1741
44
  // src/fhevm/index.ts
1742
45
  var exports_fhevm = {};
1743
46
  __export(exports_fhevm, {
@@ -1745,1003 +48,11 @@ __export(exports_fhevm, {
1745
48
  });
1746
49
  module.exports = __toCommonJS(exports_fhevm);
1747
50
 
1748
- // node_modules/viem/_esm/utils/chain/defineChain.js
1749
- function defineChain(chain) {
1750
- return {
1751
- formatters: undefined,
1752
- fees: undefined,
1753
- serializers: undefined,
1754
- ...chain
1755
- };
1756
- }
1757
- // node_modules/viem/_esm/utils/formatters/transaction.js
1758
- init_fromHex();
1759
- var transactionType = {
1760
- "0x0": "legacy",
1761
- "0x1": "eip2930",
1762
- "0x2": "eip1559",
1763
- "0x3": "eip4844",
1764
- "0x4": "eip7702"
1765
- };
1766
- function formatTransaction(transaction) {
1767
- const transaction_ = {
1768
- ...transaction,
1769
- blockHash: transaction.blockHash ? transaction.blockHash : null,
1770
- blockNumber: transaction.blockNumber ? BigInt(transaction.blockNumber) : null,
1771
- chainId: transaction.chainId ? hexToNumber(transaction.chainId) : undefined,
1772
- gas: transaction.gas ? BigInt(transaction.gas) : undefined,
1773
- gasPrice: transaction.gasPrice ? BigInt(transaction.gasPrice) : undefined,
1774
- maxFeePerBlobGas: transaction.maxFeePerBlobGas ? BigInt(transaction.maxFeePerBlobGas) : undefined,
1775
- maxFeePerGas: transaction.maxFeePerGas ? BigInt(transaction.maxFeePerGas) : undefined,
1776
- maxPriorityFeePerGas: transaction.maxPriorityFeePerGas ? BigInt(transaction.maxPriorityFeePerGas) : undefined,
1777
- nonce: transaction.nonce ? hexToNumber(transaction.nonce) : undefined,
1778
- to: transaction.to ? transaction.to : null,
1779
- transactionIndex: transaction.transactionIndex ? Number(transaction.transactionIndex) : null,
1780
- type: transaction.type ? transactionType[transaction.type] : undefined,
1781
- typeHex: transaction.type ? transaction.type : undefined,
1782
- value: transaction.value ? BigInt(transaction.value) : undefined,
1783
- v: transaction.v ? BigInt(transaction.v) : undefined
1784
- };
1785
- if (transaction.authorizationList)
1786
- transaction_.authorizationList = formatAuthorizationList(transaction.authorizationList);
1787
- transaction_.yParity = (() => {
1788
- if (transaction.yParity)
1789
- return Number(transaction.yParity);
1790
- if (typeof transaction_.v === "bigint") {
1791
- if (transaction_.v === 0n || transaction_.v === 27n)
1792
- return 0;
1793
- if (transaction_.v === 1n || transaction_.v === 28n)
1794
- return 1;
1795
- if (transaction_.v >= 35n)
1796
- return transaction_.v % 2n === 0n ? 1 : 0;
1797
- }
1798
- return;
1799
- })();
1800
- if (transaction_.type === "legacy") {
1801
- delete transaction_.accessList;
1802
- delete transaction_.maxFeePerBlobGas;
1803
- delete transaction_.maxFeePerGas;
1804
- delete transaction_.maxPriorityFeePerGas;
1805
- delete transaction_.yParity;
1806
- }
1807
- if (transaction_.type === "eip2930") {
1808
- delete transaction_.maxFeePerBlobGas;
1809
- delete transaction_.maxFeePerGas;
1810
- delete transaction_.maxPriorityFeePerGas;
1811
- }
1812
- if (transaction_.type === "eip1559") {
1813
- delete transaction_.maxFeePerBlobGas;
1814
- }
1815
- return transaction_;
1816
- }
1817
- var defineTransaction = /* @__PURE__ */ defineFormatter("transaction", formatTransaction);
1818
- function formatAuthorizationList(authorizationList) {
1819
- return authorizationList.map((authorization) => ({
1820
- contractAddress: authorization.address,
1821
- chainId: Number(authorization.chainId),
1822
- nonce: Number(authorization.nonce),
1823
- r: authorization.r,
1824
- s: authorization.s,
1825
- yParity: Number(authorization.yParity)
1826
- }));
1827
- }
1828
-
1829
- // node_modules/viem/_esm/utils/formatters/block.js
1830
- function formatBlock(block) {
1831
- const transactions = (block.transactions ?? []).map((transaction) => {
1832
- if (typeof transaction === "string")
1833
- return transaction;
1834
- return formatTransaction(transaction);
1835
- });
1836
- return {
1837
- ...block,
1838
- baseFeePerGas: block.baseFeePerGas ? BigInt(block.baseFeePerGas) : null,
1839
- blobGasUsed: block.blobGasUsed ? BigInt(block.blobGasUsed) : undefined,
1840
- difficulty: block.difficulty ? BigInt(block.difficulty) : undefined,
1841
- excessBlobGas: block.excessBlobGas ? BigInt(block.excessBlobGas) : undefined,
1842
- gasLimit: block.gasLimit ? BigInt(block.gasLimit) : undefined,
1843
- gasUsed: block.gasUsed ? BigInt(block.gasUsed) : undefined,
1844
- hash: block.hash ? block.hash : null,
1845
- logsBloom: block.logsBloom ? block.logsBloom : null,
1846
- nonce: block.nonce ? block.nonce : null,
1847
- number: block.number ? BigInt(block.number) : null,
1848
- size: block.size ? BigInt(block.size) : undefined,
1849
- timestamp: block.timestamp ? BigInt(block.timestamp) : undefined,
1850
- transactions,
1851
- totalDifficulty: block.totalDifficulty ? BigInt(block.totalDifficulty) : null
1852
- };
1853
- }
1854
- var defineBlock = /* @__PURE__ */ defineFormatter("block", formatBlock);
1855
-
1856
- // node_modules/viem/_esm/utils/formatters/log.js
1857
- function formatLog(log, { args, eventName } = {}) {
1858
- return {
1859
- ...log,
1860
- blockHash: log.blockHash ? log.blockHash : null,
1861
- blockNumber: log.blockNumber ? BigInt(log.blockNumber) : null,
1862
- logIndex: log.logIndex ? Number(log.logIndex) : null,
1863
- transactionHash: log.transactionHash ? log.transactionHash : null,
1864
- transactionIndex: log.transactionIndex ? Number(log.transactionIndex) : null,
1865
- ...eventName ? { args, eventName } : {}
1866
- };
1867
- }
1868
-
1869
- // node_modules/viem/_esm/utils/formatters/transactionReceipt.js
1870
- init_fromHex();
1871
- var receiptStatuses = {
1872
- "0x0": "reverted",
1873
- "0x1": "success"
1874
- };
1875
- function formatTransactionReceipt(transactionReceipt) {
1876
- const receipt = {
1877
- ...transactionReceipt,
1878
- blockNumber: transactionReceipt.blockNumber ? BigInt(transactionReceipt.blockNumber) : null,
1879
- contractAddress: transactionReceipt.contractAddress ? transactionReceipt.contractAddress : null,
1880
- cumulativeGasUsed: transactionReceipt.cumulativeGasUsed ? BigInt(transactionReceipt.cumulativeGasUsed) : null,
1881
- effectiveGasPrice: transactionReceipt.effectiveGasPrice ? BigInt(transactionReceipt.effectiveGasPrice) : null,
1882
- gasUsed: transactionReceipt.gasUsed ? BigInt(transactionReceipt.gasUsed) : null,
1883
- logs: transactionReceipt.logs ? transactionReceipt.logs.map((log) => formatLog(log)) : null,
1884
- to: transactionReceipt.to ? transactionReceipt.to : null,
1885
- transactionIndex: transactionReceipt.transactionIndex ? hexToNumber(transactionReceipt.transactionIndex) : null,
1886
- status: transactionReceipt.status ? receiptStatuses[transactionReceipt.status] : null,
1887
- type: transactionReceipt.type ? transactionType[transactionReceipt.type] || transactionReceipt.type : null
1888
- };
1889
- if (transactionReceipt.blobGasPrice)
1890
- receipt.blobGasPrice = BigInt(transactionReceipt.blobGasPrice);
1891
- if (transactionReceipt.blobGasUsed)
1892
- receipt.blobGasUsed = BigInt(transactionReceipt.blobGasUsed);
1893
- return receipt;
1894
- }
1895
- var defineTransactionReceipt = /* @__PURE__ */ defineFormatter("transactionReceipt", formatTransactionReceipt);
1896
-
1897
- // node_modules/viem/_esm/utils/encoding/toRlp.js
1898
- init_base();
1899
- init_cursor2();
1900
- init_toBytes();
1901
- init_toHex();
1902
- function toRlp(bytes, to = "hex") {
1903
- const encodable = getEncodable(bytes);
1904
- const cursor = createCursor(new Uint8Array(encodable.length));
1905
- encodable.encode(cursor);
1906
- if (to === "hex")
1907
- return bytesToHex(cursor.bytes);
1908
- return cursor.bytes;
1909
- }
1910
- function getEncodable(bytes) {
1911
- if (Array.isArray(bytes))
1912
- return getEncodableList(bytes.map((x) => getEncodable(x)));
1913
- return getEncodableBytes(bytes);
1914
- }
1915
- function getEncodableList(list) {
1916
- const bodyLength = list.reduce((acc, x) => acc + x.length, 0);
1917
- const sizeOfBodyLength = getSizeOfLength(bodyLength);
1918
- const length = (() => {
1919
- if (bodyLength <= 55)
1920
- return 1 + bodyLength;
1921
- return 1 + sizeOfBodyLength + bodyLength;
1922
- })();
1923
- return {
1924
- length,
1925
- encode(cursor) {
1926
- if (bodyLength <= 55) {
1927
- cursor.pushByte(192 + bodyLength);
1928
- } else {
1929
- cursor.pushByte(192 + 55 + sizeOfBodyLength);
1930
- if (sizeOfBodyLength === 1)
1931
- cursor.pushUint8(bodyLength);
1932
- else if (sizeOfBodyLength === 2)
1933
- cursor.pushUint16(bodyLength);
1934
- else if (sizeOfBodyLength === 3)
1935
- cursor.pushUint24(bodyLength);
1936
- else
1937
- cursor.pushUint32(bodyLength);
1938
- }
1939
- for (const { encode } of list) {
1940
- encode(cursor);
1941
- }
1942
- }
1943
- };
1944
- }
1945
- function getEncodableBytes(bytesOrHex) {
1946
- const bytes = typeof bytesOrHex === "string" ? hexToBytes(bytesOrHex) : bytesOrHex;
1947
- const sizeOfBytesLength = getSizeOfLength(bytes.length);
1948
- const length = (() => {
1949
- if (bytes.length === 1 && bytes[0] < 128)
1950
- return 1;
1951
- if (bytes.length <= 55)
1952
- return 1 + bytes.length;
1953
- return 1 + sizeOfBytesLength + bytes.length;
1954
- })();
1955
- return {
1956
- length,
1957
- encode(cursor) {
1958
- if (bytes.length === 1 && bytes[0] < 128) {
1959
- cursor.pushBytes(bytes);
1960
- } else if (bytes.length <= 55) {
1961
- cursor.pushByte(128 + bytes.length);
1962
- cursor.pushBytes(bytes);
1963
- } else {
1964
- cursor.pushByte(128 + 55 + sizeOfBytesLength);
1965
- if (sizeOfBytesLength === 1)
1966
- cursor.pushUint8(bytes.length);
1967
- else if (sizeOfBytesLength === 2)
1968
- cursor.pushUint16(bytes.length);
1969
- else if (sizeOfBytesLength === 3)
1970
- cursor.pushUint24(bytes.length);
1971
- else
1972
- cursor.pushUint32(bytes.length);
1973
- cursor.pushBytes(bytes);
1974
- }
1975
- }
1976
- };
1977
- }
1978
- function getSizeOfLength(length) {
1979
- if (length < 2 ** 8)
1980
- return 1;
1981
- if (length < 2 ** 16)
1982
- return 2;
1983
- if (length < 2 ** 24)
1984
- return 3;
1985
- if (length < 2 ** 32)
1986
- return 4;
1987
- throw new BaseError("Length is too large.");
1988
- }
1989
-
1990
- // node_modules/viem/_esm/utils/transaction/serializeTransaction.js
1991
- init_transaction();
1992
-
1993
- // node_modules/viem/_esm/utils/blob/blobsToCommitments.js
1994
- init_toBytes();
1995
- init_toHex();
1996
- function blobsToCommitments(parameters) {
1997
- const { kzg } = parameters;
1998
- const to = parameters.to ?? (typeof parameters.blobs[0] === "string" ? "hex" : "bytes");
1999
- const blobs = typeof parameters.blobs[0] === "string" ? parameters.blobs.map((x) => hexToBytes(x)) : parameters.blobs;
2000
- const commitments = [];
2001
- for (const blob of blobs)
2002
- commitments.push(Uint8Array.from(kzg.blobToKzgCommitment(blob)));
2003
- return to === "bytes" ? commitments : commitments.map((x) => bytesToHex(x));
2004
- }
2005
-
2006
- // node_modules/viem/_esm/utils/blob/blobsToProofs.js
2007
- init_toBytes();
2008
- init_toHex();
2009
- function blobsToProofs(parameters) {
2010
- const { kzg } = parameters;
2011
- const to = parameters.to ?? (typeof parameters.blobs[0] === "string" ? "hex" : "bytes");
2012
- const blobs = typeof parameters.blobs[0] === "string" ? parameters.blobs.map((x) => hexToBytes(x)) : parameters.blobs;
2013
- const commitments = typeof parameters.commitments[0] === "string" ? parameters.commitments.map((x) => hexToBytes(x)) : parameters.commitments;
2014
- const proofs = [];
2015
- for (let i = 0;i < blobs.length; i++) {
2016
- const blob = blobs[i];
2017
- const commitment = commitments[i];
2018
- proofs.push(Uint8Array.from(kzg.computeBlobKzgProof(blob, commitment)));
2019
- }
2020
- return to === "bytes" ? proofs : proofs.map((x) => bytesToHex(x));
2021
- }
2022
-
2023
- // node_modules/viem/_esm/utils/blob/commitmentToVersionedHash.js
2024
- init_toHex();
2025
-
2026
- // node_modules/viem/_esm/utils/hash/sha256.js
2027
- init_sha256();
2028
- init_toBytes();
2029
- init_toHex();
2030
- function sha2562(value, to_) {
2031
- const to = to_ || "hex";
2032
- const bytes = sha256(isHex(value, { strict: false }) ? toBytes(value) : value);
2033
- if (to === "bytes")
2034
- return bytes;
2035
- return toHex(bytes);
2036
- }
2037
-
2038
- // node_modules/viem/_esm/utils/blob/commitmentToVersionedHash.js
2039
- function commitmentToVersionedHash(parameters) {
2040
- const { commitment, version: version2 = 1 } = parameters;
2041
- const to = parameters.to ?? (typeof commitment === "string" ? "hex" : "bytes");
2042
- const versionedHash = sha2562(commitment, "bytes");
2043
- versionedHash.set([version2], 0);
2044
- return to === "bytes" ? versionedHash : bytesToHex(versionedHash);
2045
- }
2046
-
2047
- // node_modules/viem/_esm/utils/blob/commitmentsToVersionedHashes.js
2048
- function commitmentsToVersionedHashes(parameters) {
2049
- const { commitments, version: version2 } = parameters;
2050
- const to = parameters.to ?? (typeof commitments[0] === "string" ? "hex" : "bytes");
2051
- const hashes = [];
2052
- for (const commitment of commitments) {
2053
- hashes.push(commitmentToVersionedHash({
2054
- commitment,
2055
- to,
2056
- version: version2
2057
- }));
2058
- }
2059
- return hashes;
2060
- }
2061
-
2062
- // node_modules/viem/_esm/constants/blob.js
2063
- var blobsPerTransaction = 6;
2064
- var bytesPerFieldElement = 32;
2065
- var fieldElementsPerBlob = 4096;
2066
- var bytesPerBlob = bytesPerFieldElement * fieldElementsPerBlob;
2067
- var maxBytesPerTransaction = bytesPerBlob * blobsPerTransaction - 1 - 1 * fieldElementsPerBlob * blobsPerTransaction;
2068
-
2069
- // node_modules/viem/_esm/constants/kzg.js
2070
- var versionedHashVersionKzg = 1;
2071
-
2072
- // node_modules/viem/_esm/errors/blob.js
2073
- init_base();
2074
-
2075
- class BlobSizeTooLargeError extends BaseError {
2076
- constructor({ maxSize, size: size2 }) {
2077
- super("Blob size is too large.", {
2078
- metaMessages: [`Max: ${maxSize} bytes`, `Given: ${size2} bytes`],
2079
- name: "BlobSizeTooLargeError"
2080
- });
2081
- }
2082
- }
2083
-
2084
- class EmptyBlobError extends BaseError {
2085
- constructor() {
2086
- super("Blob data must not be empty.", { name: "EmptyBlobError" });
2087
- }
2088
- }
2089
-
2090
- class InvalidVersionedHashSizeError extends BaseError {
2091
- constructor({ hash, size: size2 }) {
2092
- super(`Versioned hash "${hash}" size is invalid.`, {
2093
- metaMessages: ["Expected: 32", `Received: ${size2}`],
2094
- name: "InvalidVersionedHashSizeError"
2095
- });
2096
- }
2097
- }
2098
-
2099
- class InvalidVersionedHashVersionError extends BaseError {
2100
- constructor({ hash, version: version2 }) {
2101
- super(`Versioned hash "${hash}" version is invalid.`, {
2102
- metaMessages: [
2103
- `Expected: ${versionedHashVersionKzg}`,
2104
- `Received: ${version2}`
2105
- ],
2106
- name: "InvalidVersionedHashVersionError"
2107
- });
2108
- }
2109
- }
2110
-
2111
- // node_modules/viem/_esm/utils/blob/toBlobs.js
2112
- init_cursor2();
2113
- init_size();
2114
- init_toBytes();
2115
- init_toHex();
2116
- function toBlobs(parameters) {
2117
- const to = parameters.to ?? (typeof parameters.data === "string" ? "hex" : "bytes");
2118
- const data = typeof parameters.data === "string" ? hexToBytes(parameters.data) : parameters.data;
2119
- const size_ = size(data);
2120
- if (!size_)
2121
- throw new EmptyBlobError;
2122
- if (size_ > maxBytesPerTransaction)
2123
- throw new BlobSizeTooLargeError({
2124
- maxSize: maxBytesPerTransaction,
2125
- size: size_
2126
- });
2127
- const blobs = [];
2128
- let active = true;
2129
- let position = 0;
2130
- while (active) {
2131
- const blob = createCursor(new Uint8Array(bytesPerBlob));
2132
- let size2 = 0;
2133
- while (size2 < fieldElementsPerBlob) {
2134
- const bytes = data.slice(position, position + (bytesPerFieldElement - 1));
2135
- blob.pushByte(0);
2136
- blob.pushBytes(bytes);
2137
- if (bytes.length < 31) {
2138
- blob.pushByte(128);
2139
- active = false;
2140
- break;
2141
- }
2142
- size2++;
2143
- position += 31;
2144
- }
2145
- blobs.push(blob);
2146
- }
2147
- return to === "bytes" ? blobs.map((x) => x.bytes) : blobs.map((x) => bytesToHex(x.bytes));
2148
- }
2149
-
2150
- // node_modules/viem/_esm/utils/blob/toBlobSidecars.js
2151
- function toBlobSidecars(parameters) {
2152
- const { data, kzg, to } = parameters;
2153
- const blobs = parameters.blobs ?? toBlobs({ data, to });
2154
- const commitments = parameters.commitments ?? blobsToCommitments({ blobs, kzg, to });
2155
- const proofs = parameters.proofs ?? blobsToProofs({ blobs, commitments, kzg, to });
2156
- const sidecars = [];
2157
- for (let i = 0;i < blobs.length; i++)
2158
- sidecars.push({
2159
- blob: blobs[i],
2160
- commitment: commitments[i],
2161
- proof: proofs[i]
2162
- });
2163
- return sidecars;
2164
- }
2165
-
2166
- // node_modules/viem/_esm/utils/transaction/serializeTransaction.js
2167
- init_toHex();
2168
-
2169
- // node_modules/viem/_esm/experimental/eip7702/utils/serializeAuthorizationList.js
2170
- init_toHex();
2171
- function serializeAuthorizationList(authorizationList) {
2172
- if (!authorizationList || authorizationList.length === 0)
2173
- return [];
2174
- const serializedAuthorizationList = [];
2175
- for (const authorization of authorizationList) {
2176
- const { contractAddress, chainId, nonce, ...signature } = authorization;
2177
- serializedAuthorizationList.push([
2178
- chainId ? toHex(chainId) : "0x",
2179
- contractAddress,
2180
- nonce ? toHex(nonce) : "0x",
2181
- ...toYParitySignatureArray({}, signature)
2182
- ]);
2183
- }
2184
- return serializedAuthorizationList;
2185
- }
2186
-
2187
- // node_modules/viem/_esm/utils/transaction/assertTransaction.js
2188
- init_number();
2189
- init_address();
2190
- init_base();
2191
- init_chain();
2192
- init_node();
2193
- init_isAddress();
2194
- init_size();
2195
- init_slice();
2196
- init_fromHex();
2197
- function assertTransactionEIP7702(transaction) {
2198
- const { authorizationList } = transaction;
2199
- if (authorizationList) {
2200
- for (const authorization of authorizationList) {
2201
- const { contractAddress, chainId } = authorization;
2202
- if (!isAddress(contractAddress))
2203
- throw new InvalidAddressError({ address: contractAddress });
2204
- if (chainId < 0)
2205
- throw new InvalidChainIdError({ chainId });
2206
- }
2207
- }
2208
- assertTransactionEIP1559(transaction);
2209
- }
2210
- function assertTransactionEIP4844(transaction) {
2211
- const { blobVersionedHashes } = transaction;
2212
- if (blobVersionedHashes) {
2213
- if (blobVersionedHashes.length === 0)
2214
- throw new EmptyBlobError;
2215
- for (const hash of blobVersionedHashes) {
2216
- const size_ = size(hash);
2217
- const version2 = hexToNumber(slice(hash, 0, 1));
2218
- if (size_ !== 32)
2219
- throw new InvalidVersionedHashSizeError({ hash, size: size_ });
2220
- if (version2 !== versionedHashVersionKzg)
2221
- throw new InvalidVersionedHashVersionError({
2222
- hash,
2223
- version: version2
2224
- });
2225
- }
2226
- }
2227
- assertTransactionEIP1559(transaction);
2228
- }
2229
- function assertTransactionEIP1559(transaction) {
2230
- const { chainId, maxPriorityFeePerGas, maxFeePerGas, to } = transaction;
2231
- if (chainId <= 0)
2232
- throw new InvalidChainIdError({ chainId });
2233
- if (to && !isAddress(to))
2234
- throw new InvalidAddressError({ address: to });
2235
- if (maxFeePerGas && maxFeePerGas > maxUint256)
2236
- throw new FeeCapTooHighError({ maxFeePerGas });
2237
- if (maxPriorityFeePerGas && maxFeePerGas && maxPriorityFeePerGas > maxFeePerGas)
2238
- throw new TipAboveFeeCapError({ maxFeePerGas, maxPriorityFeePerGas });
2239
- }
2240
- function assertTransactionEIP2930(transaction) {
2241
- const { chainId, maxPriorityFeePerGas, gasPrice, maxFeePerGas, to } = transaction;
2242
- if (chainId <= 0)
2243
- throw new InvalidChainIdError({ chainId });
2244
- if (to && !isAddress(to))
2245
- throw new InvalidAddressError({ address: to });
2246
- if (maxPriorityFeePerGas || maxFeePerGas)
2247
- throw new BaseError("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");
2248
- if (gasPrice && gasPrice > maxUint256)
2249
- throw new FeeCapTooHighError({ maxFeePerGas: gasPrice });
2250
- }
2251
- function assertTransactionLegacy(transaction) {
2252
- const { chainId, maxPriorityFeePerGas, gasPrice, maxFeePerGas, to } = transaction;
2253
- if (to && !isAddress(to))
2254
- throw new InvalidAddressError({ address: to });
2255
- if (typeof chainId !== "undefined" && chainId <= 0)
2256
- throw new InvalidChainIdError({ chainId });
2257
- if (maxPriorityFeePerGas || maxFeePerGas)
2258
- throw new BaseError("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");
2259
- if (gasPrice && gasPrice > maxUint256)
2260
- throw new FeeCapTooHighError({ maxFeePerGas: gasPrice });
2261
- }
2262
-
2263
- // node_modules/viem/_esm/utils/transaction/getTransactionType.js
2264
- init_transaction();
2265
- function getTransactionType(transaction) {
2266
- if (transaction.type)
2267
- return transaction.type;
2268
- if (typeof transaction.authorizationList !== "undefined")
2269
- return "eip7702";
2270
- if (typeof transaction.blobs !== "undefined" || typeof transaction.blobVersionedHashes !== "undefined" || typeof transaction.maxFeePerBlobGas !== "undefined" || typeof transaction.sidecars !== "undefined")
2271
- return "eip4844";
2272
- if (typeof transaction.maxFeePerGas !== "undefined" || typeof transaction.maxPriorityFeePerGas !== "undefined") {
2273
- return "eip1559";
2274
- }
2275
- if (typeof transaction.gasPrice !== "undefined") {
2276
- if (typeof transaction.accessList !== "undefined")
2277
- return "eip2930";
2278
- return "legacy";
2279
- }
2280
- throw new InvalidSerializableTransactionError({ transaction });
2281
- }
2282
-
2283
- // node_modules/viem/_esm/utils/transaction/serializeAccessList.js
2284
- init_address();
2285
- init_transaction();
2286
- init_isAddress();
2287
- function serializeAccessList(accessList) {
2288
- if (!accessList || accessList.length === 0)
2289
- return [];
2290
- const serializedAccessList = [];
2291
- for (let i = 0;i < accessList.length; i++) {
2292
- const { address, storageKeys } = accessList[i];
2293
- for (let j = 0;j < storageKeys.length; j++) {
2294
- if (storageKeys[j].length - 2 !== 64) {
2295
- throw new InvalidStorageKeySizeError({ storageKey: storageKeys[j] });
2296
- }
2297
- }
2298
- if (!isAddress(address, { strict: false })) {
2299
- throw new InvalidAddressError({ address });
2300
- }
2301
- serializedAccessList.push([address, storageKeys]);
2302
- }
2303
- return serializedAccessList;
2304
- }
2305
-
2306
- // node_modules/viem/_esm/utils/transaction/serializeTransaction.js
2307
- function serializeTransaction(transaction, signature) {
2308
- const type = getTransactionType(transaction);
2309
- if (type === "eip1559")
2310
- return serializeTransactionEIP1559(transaction, signature);
2311
- if (type === "eip2930")
2312
- return serializeTransactionEIP2930(transaction, signature);
2313
- if (type === "eip4844")
2314
- return serializeTransactionEIP4844(transaction, signature);
2315
- if (type === "eip7702")
2316
- return serializeTransactionEIP7702(transaction, signature);
2317
- return serializeTransactionLegacy(transaction, signature);
2318
- }
2319
- function serializeTransactionEIP7702(transaction, signature) {
2320
- const { authorizationList, chainId, gas, nonce, to, value, maxFeePerGas, maxPriorityFeePerGas, accessList, data } = transaction;
2321
- assertTransactionEIP7702(transaction);
2322
- const serializedAccessList = serializeAccessList(accessList);
2323
- const serializedAuthorizationList = serializeAuthorizationList(authorizationList);
2324
- return concatHex([
2325
- "0x04",
2326
- toRlp([
2327
- toHex(chainId),
2328
- nonce ? toHex(nonce) : "0x",
2329
- maxPriorityFeePerGas ? toHex(maxPriorityFeePerGas) : "0x",
2330
- maxFeePerGas ? toHex(maxFeePerGas) : "0x",
2331
- gas ? toHex(gas) : "0x",
2332
- to ?? "0x",
2333
- value ? toHex(value) : "0x",
2334
- data ?? "0x",
2335
- serializedAccessList,
2336
- serializedAuthorizationList,
2337
- ...toYParitySignatureArray(transaction, signature)
2338
- ])
2339
- ]);
2340
- }
2341
- function serializeTransactionEIP4844(transaction, signature) {
2342
- const { chainId, gas, nonce, to, value, maxFeePerBlobGas, maxFeePerGas, maxPriorityFeePerGas, accessList, data } = transaction;
2343
- assertTransactionEIP4844(transaction);
2344
- let blobVersionedHashes = transaction.blobVersionedHashes;
2345
- let sidecars = transaction.sidecars;
2346
- if (transaction.blobs && (typeof blobVersionedHashes === "undefined" || typeof sidecars === "undefined")) {
2347
- const blobs2 = typeof transaction.blobs[0] === "string" ? transaction.blobs : transaction.blobs.map((x) => bytesToHex(x));
2348
- const kzg = transaction.kzg;
2349
- const commitments2 = blobsToCommitments({
2350
- blobs: blobs2,
2351
- kzg
2352
- });
2353
- if (typeof blobVersionedHashes === "undefined")
2354
- blobVersionedHashes = commitmentsToVersionedHashes({
2355
- commitments: commitments2
2356
- });
2357
- if (typeof sidecars === "undefined") {
2358
- const proofs2 = blobsToProofs({ blobs: blobs2, commitments: commitments2, kzg });
2359
- sidecars = toBlobSidecars({ blobs: blobs2, commitments: commitments2, proofs: proofs2 });
2360
- }
2361
- }
2362
- const serializedAccessList = serializeAccessList(accessList);
2363
- const serializedTransaction = [
2364
- toHex(chainId),
2365
- nonce ? toHex(nonce) : "0x",
2366
- maxPriorityFeePerGas ? toHex(maxPriorityFeePerGas) : "0x",
2367
- maxFeePerGas ? toHex(maxFeePerGas) : "0x",
2368
- gas ? toHex(gas) : "0x",
2369
- to ?? "0x",
2370
- value ? toHex(value) : "0x",
2371
- data ?? "0x",
2372
- serializedAccessList,
2373
- maxFeePerBlobGas ? toHex(maxFeePerBlobGas) : "0x",
2374
- blobVersionedHashes ?? [],
2375
- ...toYParitySignatureArray(transaction, signature)
2376
- ];
2377
- const blobs = [];
2378
- const commitments = [];
2379
- const proofs = [];
2380
- if (sidecars)
2381
- for (let i = 0;i < sidecars.length; i++) {
2382
- const { blob, commitment, proof } = sidecars[i];
2383
- blobs.push(blob);
2384
- commitments.push(commitment);
2385
- proofs.push(proof);
2386
- }
2387
- return concatHex([
2388
- "0x03",
2389
- sidecars ? toRlp([serializedTransaction, blobs, commitments, proofs]) : toRlp(serializedTransaction)
2390
- ]);
2391
- }
2392
- function serializeTransactionEIP1559(transaction, signature) {
2393
- const { chainId, gas, nonce, to, value, maxFeePerGas, maxPriorityFeePerGas, accessList, data } = transaction;
2394
- assertTransactionEIP1559(transaction);
2395
- const serializedAccessList = serializeAccessList(accessList);
2396
- const serializedTransaction = [
2397
- toHex(chainId),
2398
- nonce ? toHex(nonce) : "0x",
2399
- maxPriorityFeePerGas ? toHex(maxPriorityFeePerGas) : "0x",
2400
- maxFeePerGas ? toHex(maxFeePerGas) : "0x",
2401
- gas ? toHex(gas) : "0x",
2402
- to ?? "0x",
2403
- value ? toHex(value) : "0x",
2404
- data ?? "0x",
2405
- serializedAccessList,
2406
- ...toYParitySignatureArray(transaction, signature)
2407
- ];
2408
- return concatHex([
2409
- "0x02",
2410
- toRlp(serializedTransaction)
2411
- ]);
2412
- }
2413
- function serializeTransactionEIP2930(transaction, signature) {
2414
- const { chainId, gas, data, nonce, to, value, accessList, gasPrice } = transaction;
2415
- assertTransactionEIP2930(transaction);
2416
- const serializedAccessList = serializeAccessList(accessList);
2417
- const serializedTransaction = [
2418
- toHex(chainId),
2419
- nonce ? toHex(nonce) : "0x",
2420
- gasPrice ? toHex(gasPrice) : "0x",
2421
- gas ? toHex(gas) : "0x",
2422
- to ?? "0x",
2423
- value ? toHex(value) : "0x",
2424
- data ?? "0x",
2425
- serializedAccessList,
2426
- ...toYParitySignatureArray(transaction, signature)
2427
- ];
2428
- return concatHex([
2429
- "0x01",
2430
- toRlp(serializedTransaction)
2431
- ]);
2432
- }
2433
- function serializeTransactionLegacy(transaction, signature) {
2434
- const { chainId = 0, gas, data, nonce, to, value, gasPrice } = transaction;
2435
- assertTransactionLegacy(transaction);
2436
- let serializedTransaction = [
2437
- nonce ? toHex(nonce) : "0x",
2438
- gasPrice ? toHex(gasPrice) : "0x",
2439
- gas ? toHex(gas) : "0x",
2440
- to ?? "0x",
2441
- value ? toHex(value) : "0x",
2442
- data ?? "0x"
2443
- ];
2444
- if (signature) {
2445
- const v = (() => {
2446
- if (signature.v >= 35n) {
2447
- const inferredChainId = (signature.v - 35n) / 2n;
2448
- if (inferredChainId > 0)
2449
- return signature.v;
2450
- return 27n + (signature.v === 35n ? 0n : 1n);
2451
- }
2452
- if (chainId > 0)
2453
- return BigInt(chainId * 2) + BigInt(35n + signature.v - 27n);
2454
- const v2 = 27n + (signature.v === 27n ? 0n : 1n);
2455
- if (signature.v !== v2)
2456
- throw new InvalidLegacyVError({ v: signature.v });
2457
- return v2;
2458
- })();
2459
- const r = trim(signature.r);
2460
- const s = trim(signature.s);
2461
- serializedTransaction = [
2462
- ...serializedTransaction,
2463
- toHex(v),
2464
- r === "0x00" ? "0x" : r,
2465
- s === "0x00" ? "0x" : s
2466
- ];
2467
- } else if (chainId > 0) {
2468
- serializedTransaction = [
2469
- ...serializedTransaction,
2470
- toHex(chainId),
2471
- "0x",
2472
- "0x"
2473
- ];
2474
- }
2475
- return toRlp(serializedTransaction);
2476
- }
2477
- function toYParitySignatureArray(transaction, signature_) {
2478
- const signature = signature_ ?? transaction;
2479
- const { v, yParity } = signature;
2480
- if (typeof signature.r === "undefined")
2481
- return [];
2482
- if (typeof signature.s === "undefined")
2483
- return [];
2484
- if (typeof v === "undefined" && typeof yParity === "undefined")
2485
- return [];
2486
- const r = trim(signature.r);
2487
- const s = trim(signature.s);
2488
- const yParity_ = (() => {
2489
- if (typeof yParity === "number")
2490
- return yParity ? toHex(1) : "0x";
2491
- if (v === 0n)
2492
- return "0x";
2493
- if (v === 1n)
2494
- return toHex(1);
2495
- return v === 27n ? "0x" : toHex(1);
2496
- })();
2497
- return [yParity_, r === "0x00" ? "0x" : r, s === "0x00" ? "0x" : s];
2498
- }
2499
-
2500
- // node_modules/viem/_esm/op-stack/contracts.js
2501
- var contracts = {
2502
- gasPriceOracle: { address: "0x420000000000000000000000000000000000000F" },
2503
- l1Block: { address: "0x4200000000000000000000000000000000000015" },
2504
- l2CrossDomainMessenger: {
2505
- address: "0x4200000000000000000000000000000000000007"
2506
- },
2507
- l2Erc721Bridge: { address: "0x4200000000000000000000000000000000000014" },
2508
- l2StandardBridge: { address: "0x4200000000000000000000000000000000000010" },
2509
- l2ToL1MessagePasser: {
2510
- address: "0x4200000000000000000000000000000000000016"
2511
- }
2512
- };
2513
-
2514
- // node_modules/viem/_esm/op-stack/formatters.js
2515
- init_fromHex();
2516
- var formatters = {
2517
- block: /* @__PURE__ */ defineBlock({
2518
- format(args) {
2519
- const transactions = args.transactions?.map((transaction) => {
2520
- if (typeof transaction === "string")
2521
- return transaction;
2522
- const formatted = formatTransaction(transaction);
2523
- if (formatted.typeHex === "0x7e") {
2524
- formatted.isSystemTx = transaction.isSystemTx;
2525
- formatted.mint = transaction.mint ? hexToBigInt(transaction.mint) : undefined;
2526
- formatted.sourceHash = transaction.sourceHash;
2527
- formatted.type = "deposit";
2528
- }
2529
- return formatted;
2530
- });
2531
- return {
2532
- transactions,
2533
- stateRoot: args.stateRoot
2534
- };
2535
- }
2536
- }),
2537
- transaction: /* @__PURE__ */ defineTransaction({
2538
- format(args) {
2539
- const transaction = {};
2540
- if (args.type === "0x7e") {
2541
- transaction.isSystemTx = args.isSystemTx;
2542
- transaction.mint = args.mint ? hexToBigInt(args.mint) : undefined;
2543
- transaction.sourceHash = args.sourceHash;
2544
- transaction.type = "deposit";
2545
- }
2546
- return transaction;
2547
- }
2548
- }),
2549
- transactionReceipt: /* @__PURE__ */ defineTransactionReceipt({
2550
- format(args) {
2551
- return {
2552
- l1GasPrice: args.l1GasPrice ? hexToBigInt(args.l1GasPrice) : null,
2553
- l1GasUsed: args.l1GasUsed ? hexToBigInt(args.l1GasUsed) : null,
2554
- l1Fee: args.l1Fee ? hexToBigInt(args.l1Fee) : null,
2555
- l1FeeScalar: args.l1FeeScalar ? Number(args.l1FeeScalar) : null
2556
- };
2557
- }
2558
- })
2559
- };
2560
-
2561
- // node_modules/viem/_esm/op-stack/serializers.js
2562
- init_address();
2563
- init_isAddress();
2564
- init_toHex();
2565
- function serializeTransaction2(transaction, signature) {
2566
- if (isDeposit(transaction))
2567
- return serializeTransactionDeposit(transaction);
2568
- return serializeTransaction(transaction, signature);
2569
- }
2570
- var serializers = {
2571
- transaction: serializeTransaction2
2572
- };
2573
- function serializeTransactionDeposit(transaction) {
2574
- assertTransactionDeposit(transaction);
2575
- const { sourceHash, data, from, gas, isSystemTx, mint, to, value } = transaction;
2576
- const serializedTransaction = [
2577
- sourceHash,
2578
- from,
2579
- to ?? "0x",
2580
- mint ? toHex(mint) : "0x",
2581
- value ? toHex(value) : "0x",
2582
- gas ? toHex(gas) : "0x",
2583
- isSystemTx ? "0x1" : "0x",
2584
- data ?? "0x"
2585
- ];
2586
- return concatHex([
2587
- "0x7e",
2588
- toRlp(serializedTransaction)
2589
- ]);
2590
- }
2591
- function isDeposit(transaction) {
2592
- if (transaction.type === "deposit")
2593
- return true;
2594
- if (typeof transaction.sourceHash !== "undefined")
2595
- return true;
2596
- return false;
2597
- }
2598
- function assertTransactionDeposit(transaction) {
2599
- const { from, to } = transaction;
2600
- if (from && !isAddress(from))
2601
- throw new InvalidAddressError({ address: from });
2602
- if (to && !isAddress(to))
2603
- throw new InvalidAddressError({ address: to });
2604
- }
2605
-
2606
- // node_modules/viem/_esm/op-stack/chainConfig.js
2607
- var chainConfig = {
2608
- contracts,
2609
- formatters,
2610
- serializers
2611
- };
2612
-
2613
- // node_modules/viem/_esm/chains/definitions/anvil.js
2614
- var anvil = /* @__PURE__ */ defineChain({
2615
- id: 31337,
2616
- name: "Anvil",
2617
- nativeCurrency: {
2618
- decimals: 18,
2619
- name: "Ether",
2620
- symbol: "ETH"
2621
- },
2622
- rpcUrls: {
2623
- default: {
2624
- http: ["http://127.0.0.1:8545"],
2625
- webSocket: ["ws://127.0.0.1:8545"]
2626
- }
2627
- }
2628
- });
2629
- // node_modules/viem/_esm/chains/definitions/baseSepolia.js
2630
- var sourceId = 11155111;
2631
- var baseSepolia = /* @__PURE__ */ defineChain({
2632
- ...chainConfig,
2633
- id: 84532,
2634
- network: "base-sepolia",
2635
- name: "Base Sepolia",
2636
- nativeCurrency: { name: "Sepolia Ether", symbol: "ETH", decimals: 18 },
2637
- rpcUrls: {
2638
- default: {
2639
- http: ["https://sepolia.base.org"]
2640
- }
2641
- },
2642
- blockExplorers: {
2643
- default: {
2644
- name: "Basescan",
2645
- url: "https://sepolia.basescan.org",
2646
- apiUrl: "https://api-sepolia.basescan.org/api"
2647
- }
2648
- },
2649
- contracts: {
2650
- ...chainConfig.contracts,
2651
- disputeGameFactory: {
2652
- [sourceId]: {
2653
- address: "0xd6E6dBf4F7EA0ac412fD8b65ED297e64BB7a06E1"
2654
- }
2655
- },
2656
- l2OutputOracle: {
2657
- [sourceId]: {
2658
- address: "0x84457ca9D0163FbC4bbfe4Dfbb20ba46e48DF254"
2659
- }
2660
- },
2661
- portal: {
2662
- [sourceId]: {
2663
- address: "0x49f53e41452c74589e85ca1677426ba426459e85",
2664
- blockCreated: 4446677
2665
- }
2666
- },
2667
- l1StandardBridge: {
2668
- [sourceId]: {
2669
- address: "0xfd0Bf71F60660E2f608ed56e1659C450eB113120",
2670
- blockCreated: 4446677
2671
- }
2672
- },
2673
- multicall3: {
2674
- address: "0xca11bde05977b3631167028862be2a173976ca11",
2675
- blockCreated: 1059647
2676
- }
2677
- },
2678
- testnet: true,
2679
- sourceId
2680
- });
2681
- // node_modules/viem/_esm/chains/definitions/monadTestnet.js
2682
- var monadTestnet = /* @__PURE__ */ defineChain({
2683
- id: 10143,
2684
- name: "Monad Testnet",
2685
- nativeCurrency: {
2686
- name: "Testnet MON Token",
2687
- symbol: "MON",
2688
- decimals: 18
2689
- },
2690
- rpcUrls: {
2691
- default: {
2692
- http: ["https://testnet-rpc.monad.xyz"]
2693
- }
2694
- },
2695
- blockExplorers: {
2696
- default: {
2697
- name: "Monad Testnet explorer",
2698
- url: "https://testnet.monadexplorer.com"
2699
- }
2700
- },
2701
- contracts: {
2702
- multicall3: {
2703
- address: "0xcA11bde05977b3631167028862bE2a173976CA11",
2704
- blockCreated: 251449
2705
- }
2706
- },
2707
- testnet: true
2708
- });
2709
- // node_modules/viem/_esm/chains/definitions/sepolia.js
2710
- var sepolia = /* @__PURE__ */ defineChain({
2711
- id: 11155111,
2712
- name: "Sepolia",
2713
- nativeCurrency: { name: "Sepolia Ether", symbol: "ETH", decimals: 18 },
2714
- rpcUrls: {
2715
- default: {
2716
- http: ["https://sepolia.drpc.org"]
2717
- }
2718
- },
2719
- blockExplorers: {
2720
- default: {
2721
- name: "Etherscan",
2722
- url: "https://sepolia.etherscan.io",
2723
- apiUrl: "https://api-sepolia.etherscan.io/api"
2724
- }
2725
- },
2726
- contracts: {
2727
- multicall3: {
2728
- address: "0xca11bde05977b3631167028862be2a173976ca11",
2729
- blockCreated: 751532
2730
- },
2731
- ensRegistry: { address: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e" },
2732
- ensUniversalResolver: {
2733
- address: "0xc8Af999e38273D658BE1b921b88A9Ddf005769cC",
2734
- blockCreated: 5317080
2735
- }
2736
- },
2737
- testnet: true
2738
- });
2739
51
  // src/chain.ts
2740
52
  var supportedChains = {
2741
- baseSepolia: baseSepolia.id,
2742
- sepolia: sepolia.id,
2743
- monadTestnet: monadTestnet.id,
2744
- anvil: anvil.id
53
+ baseSepolia: 84532,
54
+ sepolia: 11155111,
55
+ monadTestnet: 10143
2745
56
  };
2746
57
  var fheSupportedChains = { baseSepolia: 84532, sepolia: 11155111 };
2747
58
  function getSupportedChain(chainish) {