@mentaproject/client 0.1.35 → 0.1.36

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.
@@ -0,0 +1,4335 @@
1
+ import {
2
+ Hash,
3
+ abytes,
4
+ aexists,
5
+ anumber,
6
+ aoutput,
7
+ clean,
8
+ createHasher,
9
+ rotlBH,
10
+ rotlBL,
11
+ rotlSH,
12
+ rotlSL,
13
+ split,
14
+ swap32IfBE,
15
+ toBytes,
16
+ u32
17
+ } from "./chunk-NV2TBI2O.js";
18
+
19
+ // node_modules/viem/node_modules/abitype/dist/esm/version.js
20
+ var version = "1.1.0";
21
+
22
+ // node_modules/viem/node_modules/abitype/dist/esm/errors.js
23
+ var BaseError = class _BaseError extends Error {
24
+ constructor(shortMessage, args = {}) {
25
+ const details = args.cause instanceof _BaseError ? args.cause.details : args.cause?.message ? args.cause.message : args.details;
26
+ const docsPath6 = args.cause instanceof _BaseError ? args.cause.docsPath || args.docsPath : args.docsPath;
27
+ const message = [
28
+ shortMessage || "An error occurred.",
29
+ "",
30
+ ...args.metaMessages ? [...args.metaMessages, ""] : [],
31
+ ...docsPath6 ? [`Docs: https://abitype.dev${docsPath6}`] : [],
32
+ ...details ? [`Details: ${details}`] : [],
33
+ `Version: abitype@${version}`
34
+ ].join("\n");
35
+ super(message);
36
+ Object.defineProperty(this, "details", {
37
+ enumerable: true,
38
+ configurable: true,
39
+ writable: true,
40
+ value: void 0
41
+ });
42
+ Object.defineProperty(this, "docsPath", {
43
+ enumerable: true,
44
+ configurable: true,
45
+ writable: true,
46
+ value: void 0
47
+ });
48
+ Object.defineProperty(this, "metaMessages", {
49
+ enumerable: true,
50
+ configurable: true,
51
+ writable: true,
52
+ value: void 0
53
+ });
54
+ Object.defineProperty(this, "shortMessage", {
55
+ enumerable: true,
56
+ configurable: true,
57
+ writable: true,
58
+ value: void 0
59
+ });
60
+ Object.defineProperty(this, "name", {
61
+ enumerable: true,
62
+ configurable: true,
63
+ writable: true,
64
+ value: "AbiTypeError"
65
+ });
66
+ if (args.cause)
67
+ this.cause = args.cause;
68
+ this.details = details;
69
+ this.docsPath = docsPath6;
70
+ this.metaMessages = args.metaMessages;
71
+ this.shortMessage = shortMessage;
72
+ }
73
+ };
74
+
75
+ // node_modules/viem/node_modules/abitype/dist/esm/regex.js
76
+ function execTyped(regex, string) {
77
+ const match = regex.exec(string);
78
+ return match?.groups;
79
+ }
80
+ var bytesRegex = /^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/;
81
+ var integerRegex = /^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;
82
+ var isTupleRegex = /^\(.+?\).*?$/;
83
+
84
+ // node_modules/viem/node_modules/abitype/dist/esm/human-readable/formatAbiParameter.js
85
+ var tupleRegex = /^tuple(?<array>(\[(\d*)\])*)$/;
86
+ function formatAbiParameter(abiParameter) {
87
+ let type = abiParameter.type;
88
+ if (tupleRegex.test(abiParameter.type) && "components" in abiParameter) {
89
+ type = "(";
90
+ const length = abiParameter.components.length;
91
+ for (let i = 0; i < length; i++) {
92
+ const component = abiParameter.components[i];
93
+ type += formatAbiParameter(component);
94
+ if (i < length - 1)
95
+ type += ", ";
96
+ }
97
+ const result = execTyped(tupleRegex, abiParameter.type);
98
+ type += `)${result?.array ?? ""}`;
99
+ return formatAbiParameter({
100
+ ...abiParameter,
101
+ type
102
+ });
103
+ }
104
+ if ("indexed" in abiParameter && abiParameter.indexed)
105
+ type = `${type} indexed`;
106
+ if (abiParameter.name)
107
+ return `${type} ${abiParameter.name}`;
108
+ return type;
109
+ }
110
+
111
+ // node_modules/viem/node_modules/abitype/dist/esm/human-readable/formatAbiParameters.js
112
+ function formatAbiParameters(abiParameters) {
113
+ let params = "";
114
+ const length = abiParameters.length;
115
+ for (let i = 0; i < length; i++) {
116
+ const abiParameter = abiParameters[i];
117
+ params += formatAbiParameter(abiParameter);
118
+ if (i !== length - 1)
119
+ params += ", ";
120
+ }
121
+ return params;
122
+ }
123
+
124
+ // node_modules/viem/node_modules/abitype/dist/esm/human-readable/formatAbiItem.js
125
+ function formatAbiItem(abiItem) {
126
+ if (abiItem.type === "function")
127
+ return `function ${abiItem.name}(${formatAbiParameters(abiItem.inputs)})${abiItem.stateMutability && abiItem.stateMutability !== "nonpayable" ? ` ${abiItem.stateMutability}` : ""}${abiItem.outputs?.length ? ` returns (${formatAbiParameters(abiItem.outputs)})` : ""}`;
128
+ if (abiItem.type === "event")
129
+ return `event ${abiItem.name}(${formatAbiParameters(abiItem.inputs)})`;
130
+ if (abiItem.type === "error")
131
+ return `error ${abiItem.name}(${formatAbiParameters(abiItem.inputs)})`;
132
+ if (abiItem.type === "constructor")
133
+ return `constructor(${formatAbiParameters(abiItem.inputs)})${abiItem.stateMutability === "payable" ? " payable" : ""}`;
134
+ if (abiItem.type === "fallback")
135
+ return `fallback() external${abiItem.stateMutability === "payable" ? " payable" : ""}`;
136
+ return "receive() external payable";
137
+ }
138
+
139
+ // node_modules/viem/node_modules/abitype/dist/esm/human-readable/runtime/signatures.js
140
+ var errorSignatureRegex = /^error (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;
141
+ function isErrorSignature(signature) {
142
+ return errorSignatureRegex.test(signature);
143
+ }
144
+ function execErrorSignature(signature) {
145
+ return execTyped(errorSignatureRegex, signature);
146
+ }
147
+ var eventSignatureRegex = /^event (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;
148
+ function isEventSignature(signature) {
149
+ return eventSignatureRegex.test(signature);
150
+ }
151
+ function execEventSignature(signature) {
152
+ return execTyped(eventSignatureRegex, signature);
153
+ }
154
+ var functionSignatureRegex = /^function (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)(?: (?<scope>external|public{1}))?(?: (?<stateMutability>pure|view|nonpayable|payable{1}))?(?: returns\s?\((?<returns>.*?)\))?$/;
155
+ function isFunctionSignature(signature) {
156
+ return functionSignatureRegex.test(signature);
157
+ }
158
+ function execFunctionSignature(signature) {
159
+ return execTyped(functionSignatureRegex, signature);
160
+ }
161
+ var structSignatureRegex = /^struct (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*) \{(?<properties>.*?)\}$/;
162
+ function isStructSignature(signature) {
163
+ return structSignatureRegex.test(signature);
164
+ }
165
+ function execStructSignature(signature) {
166
+ return execTyped(structSignatureRegex, signature);
167
+ }
168
+ var constructorSignatureRegex = /^constructor\((?<parameters>.*?)\)(?:\s(?<stateMutability>payable{1}))?$/;
169
+ function isConstructorSignature(signature) {
170
+ return constructorSignatureRegex.test(signature);
171
+ }
172
+ function execConstructorSignature(signature) {
173
+ return execTyped(constructorSignatureRegex, signature);
174
+ }
175
+ var fallbackSignatureRegex = /^fallback\(\) external(?:\s(?<stateMutability>payable{1}))?$/;
176
+ function isFallbackSignature(signature) {
177
+ return fallbackSignatureRegex.test(signature);
178
+ }
179
+ function execFallbackSignature(signature) {
180
+ return execTyped(fallbackSignatureRegex, signature);
181
+ }
182
+ var receiveSignatureRegex = /^receive\(\) external payable$/;
183
+ function isReceiveSignature(signature) {
184
+ return receiveSignatureRegex.test(signature);
185
+ }
186
+ var eventModifiers = /* @__PURE__ */ new Set(["indexed"]);
187
+ var functionModifiers = /* @__PURE__ */ new Set([
188
+ "calldata",
189
+ "memory",
190
+ "storage"
191
+ ]);
192
+
193
+ // node_modules/viem/node_modules/abitype/dist/esm/human-readable/errors/abiItem.js
194
+ var UnknownTypeError = class extends BaseError {
195
+ constructor({ type }) {
196
+ super("Unknown type.", {
197
+ metaMessages: [
198
+ `Type "${type}" is not a valid ABI type. Perhaps you forgot to include a struct signature?`
199
+ ]
200
+ });
201
+ Object.defineProperty(this, "name", {
202
+ enumerable: true,
203
+ configurable: true,
204
+ writable: true,
205
+ value: "UnknownTypeError"
206
+ });
207
+ }
208
+ };
209
+ var UnknownSolidityTypeError = class extends BaseError {
210
+ constructor({ type }) {
211
+ super("Unknown type.", {
212
+ metaMessages: [`Type "${type}" is not a valid ABI type.`]
213
+ });
214
+ Object.defineProperty(this, "name", {
215
+ enumerable: true,
216
+ configurable: true,
217
+ writable: true,
218
+ value: "UnknownSolidityTypeError"
219
+ });
220
+ }
221
+ };
222
+
223
+ // node_modules/viem/node_modules/abitype/dist/esm/human-readable/errors/abiParameter.js
224
+ var InvalidParameterError = class extends BaseError {
225
+ constructor({ param }) {
226
+ super("Invalid ABI parameter.", {
227
+ details: param
228
+ });
229
+ Object.defineProperty(this, "name", {
230
+ enumerable: true,
231
+ configurable: true,
232
+ writable: true,
233
+ value: "InvalidParameterError"
234
+ });
235
+ }
236
+ };
237
+ var SolidityProtectedKeywordError = class extends BaseError {
238
+ constructor({ param, name }) {
239
+ super("Invalid ABI parameter.", {
240
+ details: param,
241
+ metaMessages: [
242
+ `"${name}" is a protected Solidity keyword. More info: https://docs.soliditylang.org/en/latest/cheatsheet.html`
243
+ ]
244
+ });
245
+ Object.defineProperty(this, "name", {
246
+ enumerable: true,
247
+ configurable: true,
248
+ writable: true,
249
+ value: "SolidityProtectedKeywordError"
250
+ });
251
+ }
252
+ };
253
+ var InvalidModifierError = class extends BaseError {
254
+ constructor({ param, type, modifier }) {
255
+ super("Invalid ABI parameter.", {
256
+ details: param,
257
+ metaMessages: [
258
+ `Modifier "${modifier}" not allowed${type ? ` in "${type}" type` : ""}.`
259
+ ]
260
+ });
261
+ Object.defineProperty(this, "name", {
262
+ enumerable: true,
263
+ configurable: true,
264
+ writable: true,
265
+ value: "InvalidModifierError"
266
+ });
267
+ }
268
+ };
269
+ var InvalidFunctionModifierError = class extends BaseError {
270
+ constructor({ param, type, modifier }) {
271
+ super("Invalid ABI parameter.", {
272
+ details: param,
273
+ metaMessages: [
274
+ `Modifier "${modifier}" not allowed${type ? ` in "${type}" type` : ""}.`,
275
+ `Data location can only be specified for array, struct, or mapping types, but "${modifier}" was given.`
276
+ ]
277
+ });
278
+ Object.defineProperty(this, "name", {
279
+ enumerable: true,
280
+ configurable: true,
281
+ writable: true,
282
+ value: "InvalidFunctionModifierError"
283
+ });
284
+ }
285
+ };
286
+ var InvalidAbiTypeParameterError = class extends BaseError {
287
+ constructor({ abiParameter }) {
288
+ super("Invalid ABI parameter.", {
289
+ details: JSON.stringify(abiParameter, null, 2),
290
+ metaMessages: ["ABI parameter type is invalid."]
291
+ });
292
+ Object.defineProperty(this, "name", {
293
+ enumerable: true,
294
+ configurable: true,
295
+ writable: true,
296
+ value: "InvalidAbiTypeParameterError"
297
+ });
298
+ }
299
+ };
300
+
301
+ // node_modules/viem/node_modules/abitype/dist/esm/human-readable/errors/signature.js
302
+ var InvalidSignatureError = class extends BaseError {
303
+ constructor({ signature, type }) {
304
+ super(`Invalid ${type} signature.`, {
305
+ details: signature
306
+ });
307
+ Object.defineProperty(this, "name", {
308
+ enumerable: true,
309
+ configurable: true,
310
+ writable: true,
311
+ value: "InvalidSignatureError"
312
+ });
313
+ }
314
+ };
315
+ var UnknownSignatureError = class extends BaseError {
316
+ constructor({ signature }) {
317
+ super("Unknown signature.", {
318
+ details: signature
319
+ });
320
+ Object.defineProperty(this, "name", {
321
+ enumerable: true,
322
+ configurable: true,
323
+ writable: true,
324
+ value: "UnknownSignatureError"
325
+ });
326
+ }
327
+ };
328
+ var InvalidStructSignatureError = class extends BaseError {
329
+ constructor({ signature }) {
330
+ super("Invalid struct signature.", {
331
+ details: signature,
332
+ metaMessages: ["No properties exist."]
333
+ });
334
+ Object.defineProperty(this, "name", {
335
+ enumerable: true,
336
+ configurable: true,
337
+ writable: true,
338
+ value: "InvalidStructSignatureError"
339
+ });
340
+ }
341
+ };
342
+
343
+ // node_modules/viem/node_modules/abitype/dist/esm/human-readable/errors/struct.js
344
+ var CircularReferenceError = class extends BaseError {
345
+ constructor({ type }) {
346
+ super("Circular reference detected.", {
347
+ metaMessages: [`Struct "${type}" is a circular reference.`]
348
+ });
349
+ Object.defineProperty(this, "name", {
350
+ enumerable: true,
351
+ configurable: true,
352
+ writable: true,
353
+ value: "CircularReferenceError"
354
+ });
355
+ }
356
+ };
357
+
358
+ // node_modules/viem/node_modules/abitype/dist/esm/human-readable/errors/splitParameters.js
359
+ var InvalidParenthesisError = class extends BaseError {
360
+ constructor({ current, depth }) {
361
+ super("Unbalanced parentheses.", {
362
+ metaMessages: [
363
+ `"${current.trim()}" has too many ${depth > 0 ? "opening" : "closing"} parentheses.`
364
+ ],
365
+ details: `Depth "${depth}"`
366
+ });
367
+ Object.defineProperty(this, "name", {
368
+ enumerable: true,
369
+ configurable: true,
370
+ writable: true,
371
+ value: "InvalidParenthesisError"
372
+ });
373
+ }
374
+ };
375
+
376
+ // node_modules/viem/node_modules/abitype/dist/esm/human-readable/runtime/cache.js
377
+ function getParameterCacheKey(param, type, structs) {
378
+ let structKey = "";
379
+ if (structs)
380
+ for (const struct of Object.entries(structs)) {
381
+ if (!struct)
382
+ continue;
383
+ let propertyKey = "";
384
+ for (const property of struct[1]) {
385
+ propertyKey += `[${property.type}${property.name ? `:${property.name}` : ""}]`;
386
+ }
387
+ structKey += `(${struct[0]}{${propertyKey}})`;
388
+ }
389
+ if (type)
390
+ return `${type}:${param}${structKey}`;
391
+ return param;
392
+ }
393
+ var parameterCache = /* @__PURE__ */ new Map([
394
+ // Unnamed
395
+ ["address", { type: "address" }],
396
+ ["bool", { type: "bool" }],
397
+ ["bytes", { type: "bytes" }],
398
+ ["bytes32", { type: "bytes32" }],
399
+ ["int", { type: "int256" }],
400
+ ["int256", { type: "int256" }],
401
+ ["string", { type: "string" }],
402
+ ["uint", { type: "uint256" }],
403
+ ["uint8", { type: "uint8" }],
404
+ ["uint16", { type: "uint16" }],
405
+ ["uint24", { type: "uint24" }],
406
+ ["uint32", { type: "uint32" }],
407
+ ["uint64", { type: "uint64" }],
408
+ ["uint96", { type: "uint96" }],
409
+ ["uint112", { type: "uint112" }],
410
+ ["uint160", { type: "uint160" }],
411
+ ["uint192", { type: "uint192" }],
412
+ ["uint256", { type: "uint256" }],
413
+ // Named
414
+ ["address owner", { type: "address", name: "owner" }],
415
+ ["address to", { type: "address", name: "to" }],
416
+ ["bool approved", { type: "bool", name: "approved" }],
417
+ ["bytes _data", { type: "bytes", name: "_data" }],
418
+ ["bytes data", { type: "bytes", name: "data" }],
419
+ ["bytes signature", { type: "bytes", name: "signature" }],
420
+ ["bytes32 hash", { type: "bytes32", name: "hash" }],
421
+ ["bytes32 r", { type: "bytes32", name: "r" }],
422
+ ["bytes32 root", { type: "bytes32", name: "root" }],
423
+ ["bytes32 s", { type: "bytes32", name: "s" }],
424
+ ["string name", { type: "string", name: "name" }],
425
+ ["string symbol", { type: "string", name: "symbol" }],
426
+ ["string tokenURI", { type: "string", name: "tokenURI" }],
427
+ ["uint tokenId", { type: "uint256", name: "tokenId" }],
428
+ ["uint8 v", { type: "uint8", name: "v" }],
429
+ ["uint256 balance", { type: "uint256", name: "balance" }],
430
+ ["uint256 tokenId", { type: "uint256", name: "tokenId" }],
431
+ ["uint256 value", { type: "uint256", name: "value" }],
432
+ // Indexed
433
+ [
434
+ "event:address indexed from",
435
+ { type: "address", name: "from", indexed: true }
436
+ ],
437
+ ["event:address indexed to", { type: "address", name: "to", indexed: true }],
438
+ [
439
+ "event:uint indexed tokenId",
440
+ { type: "uint256", name: "tokenId", indexed: true }
441
+ ],
442
+ [
443
+ "event:uint256 indexed tokenId",
444
+ { type: "uint256", name: "tokenId", indexed: true }
445
+ ]
446
+ ]);
447
+
448
+ // node_modules/viem/node_modules/abitype/dist/esm/human-readable/runtime/utils.js
449
+ function parseSignature(signature, structs = {}) {
450
+ if (isFunctionSignature(signature))
451
+ return parseFunctionSignature(signature, structs);
452
+ if (isEventSignature(signature))
453
+ return parseEventSignature(signature, structs);
454
+ if (isErrorSignature(signature))
455
+ return parseErrorSignature(signature, structs);
456
+ if (isConstructorSignature(signature))
457
+ return parseConstructorSignature(signature, structs);
458
+ if (isFallbackSignature(signature))
459
+ return parseFallbackSignature(signature);
460
+ if (isReceiveSignature(signature))
461
+ return {
462
+ type: "receive",
463
+ stateMutability: "payable"
464
+ };
465
+ throw new UnknownSignatureError({ signature });
466
+ }
467
+ function parseFunctionSignature(signature, structs = {}) {
468
+ const match = execFunctionSignature(signature);
469
+ if (!match)
470
+ throw new InvalidSignatureError({ signature, type: "function" });
471
+ const inputParams = splitParameters(match.parameters);
472
+ const inputs = [];
473
+ const inputLength = inputParams.length;
474
+ for (let i = 0; i < inputLength; i++) {
475
+ inputs.push(parseAbiParameter(inputParams[i], {
476
+ modifiers: functionModifiers,
477
+ structs,
478
+ type: "function"
479
+ }));
480
+ }
481
+ const outputs = [];
482
+ if (match.returns) {
483
+ const outputParams = splitParameters(match.returns);
484
+ const outputLength = outputParams.length;
485
+ for (let i = 0; i < outputLength; i++) {
486
+ outputs.push(parseAbiParameter(outputParams[i], {
487
+ modifiers: functionModifiers,
488
+ structs,
489
+ type: "function"
490
+ }));
491
+ }
492
+ }
493
+ return {
494
+ name: match.name,
495
+ type: "function",
496
+ stateMutability: match.stateMutability ?? "nonpayable",
497
+ inputs,
498
+ outputs
499
+ };
500
+ }
501
+ function parseEventSignature(signature, structs = {}) {
502
+ const match = execEventSignature(signature);
503
+ if (!match)
504
+ throw new InvalidSignatureError({ signature, type: "event" });
505
+ const params = splitParameters(match.parameters);
506
+ const abiParameters = [];
507
+ const length = params.length;
508
+ for (let i = 0; i < length; i++)
509
+ abiParameters.push(parseAbiParameter(params[i], {
510
+ modifiers: eventModifiers,
511
+ structs,
512
+ type: "event"
513
+ }));
514
+ return { name: match.name, type: "event", inputs: abiParameters };
515
+ }
516
+ function parseErrorSignature(signature, structs = {}) {
517
+ const match = execErrorSignature(signature);
518
+ if (!match)
519
+ throw new InvalidSignatureError({ signature, type: "error" });
520
+ const params = splitParameters(match.parameters);
521
+ const abiParameters = [];
522
+ const length = params.length;
523
+ for (let i = 0; i < length; i++)
524
+ abiParameters.push(parseAbiParameter(params[i], { structs, type: "error" }));
525
+ return { name: match.name, type: "error", inputs: abiParameters };
526
+ }
527
+ function parseConstructorSignature(signature, structs = {}) {
528
+ const match = execConstructorSignature(signature);
529
+ if (!match)
530
+ throw new InvalidSignatureError({ signature, type: "constructor" });
531
+ const params = splitParameters(match.parameters);
532
+ const abiParameters = [];
533
+ const length = params.length;
534
+ for (let i = 0; i < length; i++)
535
+ abiParameters.push(parseAbiParameter(params[i], { structs, type: "constructor" }));
536
+ return {
537
+ type: "constructor",
538
+ stateMutability: match.stateMutability ?? "nonpayable",
539
+ inputs: abiParameters
540
+ };
541
+ }
542
+ function parseFallbackSignature(signature) {
543
+ const match = execFallbackSignature(signature);
544
+ if (!match)
545
+ throw new InvalidSignatureError({ signature, type: "fallback" });
546
+ return {
547
+ type: "fallback",
548
+ stateMutability: match.stateMutability ?? "nonpayable"
549
+ };
550
+ }
551
+ var abiParameterWithoutTupleRegex = /^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*(?:\spayable)?)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/;
552
+ var abiParameterWithTupleRegex = /^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/;
553
+ var dynamicIntegerRegex = /^u?int$/;
554
+ function parseAbiParameter(param, options) {
555
+ const parameterCacheKey = getParameterCacheKey(param, options?.type, options?.structs);
556
+ if (parameterCache.has(parameterCacheKey))
557
+ return parameterCache.get(parameterCacheKey);
558
+ const isTuple = isTupleRegex.test(param);
559
+ const match = execTyped(isTuple ? abiParameterWithTupleRegex : abiParameterWithoutTupleRegex, param);
560
+ if (!match)
561
+ throw new InvalidParameterError({ param });
562
+ if (match.name && isSolidityKeyword(match.name))
563
+ throw new SolidityProtectedKeywordError({ param, name: match.name });
564
+ const name = match.name ? { name: match.name } : {};
565
+ const indexed = match.modifier === "indexed" ? { indexed: true } : {};
566
+ const structs = options?.structs ?? {};
567
+ let type;
568
+ let components = {};
569
+ if (isTuple) {
570
+ type = "tuple";
571
+ const params = splitParameters(match.type);
572
+ const components_ = [];
573
+ const length = params.length;
574
+ for (let i = 0; i < length; i++) {
575
+ components_.push(parseAbiParameter(params[i], { structs }));
576
+ }
577
+ components = { components: components_ };
578
+ } else if (match.type in structs) {
579
+ type = "tuple";
580
+ components = { components: structs[match.type] };
581
+ } else if (dynamicIntegerRegex.test(match.type)) {
582
+ type = `${match.type}256`;
583
+ } else if (match.type === "address payable") {
584
+ type = "address";
585
+ } else {
586
+ type = match.type;
587
+ if (!(options?.type === "struct") && !isSolidityType(type))
588
+ throw new UnknownSolidityTypeError({ type });
589
+ }
590
+ if (match.modifier) {
591
+ if (!options?.modifiers?.has?.(match.modifier))
592
+ throw new InvalidModifierError({
593
+ param,
594
+ type: options?.type,
595
+ modifier: match.modifier
596
+ });
597
+ if (functionModifiers.has(match.modifier) && !isValidDataLocation(type, !!match.array))
598
+ throw new InvalidFunctionModifierError({
599
+ param,
600
+ type: options?.type,
601
+ modifier: match.modifier
602
+ });
603
+ }
604
+ const abiParameter = {
605
+ type: `${type}${match.array ?? ""}`,
606
+ ...name,
607
+ ...indexed,
608
+ ...components
609
+ };
610
+ parameterCache.set(parameterCacheKey, abiParameter);
611
+ return abiParameter;
612
+ }
613
+ function splitParameters(params, result = [], current = "", depth = 0) {
614
+ const length = params.trim().length;
615
+ for (let i = 0; i < length; i++) {
616
+ const char = params[i];
617
+ const tail = params.slice(i + 1);
618
+ switch (char) {
619
+ case ",":
620
+ return depth === 0 ? splitParameters(tail, [...result, current.trim()]) : splitParameters(tail, result, `${current}${char}`, depth);
621
+ case "(":
622
+ return splitParameters(tail, result, `${current}${char}`, depth + 1);
623
+ case ")":
624
+ return splitParameters(tail, result, `${current}${char}`, depth - 1);
625
+ default:
626
+ return splitParameters(tail, result, `${current}${char}`, depth);
627
+ }
628
+ }
629
+ if (current === "")
630
+ return result;
631
+ if (depth !== 0)
632
+ throw new InvalidParenthesisError({ current, depth });
633
+ result.push(current.trim());
634
+ return result;
635
+ }
636
+ function isSolidityType(type) {
637
+ return type === "address" || type === "bool" || type === "function" || type === "string" || bytesRegex.test(type) || integerRegex.test(type);
638
+ }
639
+ var protectedKeywordsRegex = /^(?:after|alias|anonymous|apply|auto|byte|calldata|case|catch|constant|copyof|default|defined|error|event|external|false|final|function|immutable|implements|in|indexed|inline|internal|let|mapping|match|memory|mutable|null|of|override|partial|private|promise|public|pure|reference|relocatable|return|returns|sizeof|static|storage|struct|super|supports|switch|this|true|try|typedef|typeof|var|view|virtual)$/;
640
+ function isSolidityKeyword(name) {
641
+ return name === "address" || name === "bool" || name === "function" || name === "string" || name === "tuple" || bytesRegex.test(name) || integerRegex.test(name) || protectedKeywordsRegex.test(name);
642
+ }
643
+ function isValidDataLocation(type, isArray) {
644
+ return isArray || type === "bytes" || type === "string" || type === "tuple";
645
+ }
646
+
647
+ // node_modules/viem/node_modules/abitype/dist/esm/human-readable/runtime/structs.js
648
+ function parseStructs(signatures) {
649
+ const shallowStructs = {};
650
+ const signaturesLength = signatures.length;
651
+ for (let i = 0; i < signaturesLength; i++) {
652
+ const signature = signatures[i];
653
+ if (!isStructSignature(signature))
654
+ continue;
655
+ const match = execStructSignature(signature);
656
+ if (!match)
657
+ throw new InvalidSignatureError({ signature, type: "struct" });
658
+ const properties = match.properties.split(";");
659
+ const components = [];
660
+ const propertiesLength = properties.length;
661
+ for (let k = 0; k < propertiesLength; k++) {
662
+ const property = properties[k];
663
+ const trimmed = property.trim();
664
+ if (!trimmed)
665
+ continue;
666
+ const abiParameter = parseAbiParameter(trimmed, {
667
+ type: "struct"
668
+ });
669
+ components.push(abiParameter);
670
+ }
671
+ if (!components.length)
672
+ throw new InvalidStructSignatureError({ signature });
673
+ shallowStructs[match.name] = components;
674
+ }
675
+ const resolvedStructs = {};
676
+ const entries = Object.entries(shallowStructs);
677
+ const entriesLength = entries.length;
678
+ for (let i = 0; i < entriesLength; i++) {
679
+ const [name, parameters] = entries[i];
680
+ resolvedStructs[name] = resolveStructs(parameters, shallowStructs);
681
+ }
682
+ return resolvedStructs;
683
+ }
684
+ var typeWithoutTupleRegex = /^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?$/;
685
+ function resolveStructs(abiParameters, structs, ancestors = /* @__PURE__ */ new Set()) {
686
+ const components = [];
687
+ const length = abiParameters.length;
688
+ for (let i = 0; i < length; i++) {
689
+ const abiParameter = abiParameters[i];
690
+ const isTuple = isTupleRegex.test(abiParameter.type);
691
+ if (isTuple)
692
+ components.push(abiParameter);
693
+ else {
694
+ const match = execTyped(typeWithoutTupleRegex, abiParameter.type);
695
+ if (!match?.type)
696
+ throw new InvalidAbiTypeParameterError({ abiParameter });
697
+ const { array, type } = match;
698
+ if (type in structs) {
699
+ if (ancestors.has(type))
700
+ throw new CircularReferenceError({ type });
701
+ components.push({
702
+ ...abiParameter,
703
+ type: `tuple${array ?? ""}`,
704
+ components: resolveStructs(structs[type] ?? [], structs, /* @__PURE__ */ new Set([...ancestors, type]))
705
+ });
706
+ } else {
707
+ if (isSolidityType(type))
708
+ components.push(abiParameter);
709
+ else
710
+ throw new UnknownTypeError({ type });
711
+ }
712
+ }
713
+ }
714
+ return components;
715
+ }
716
+
717
+ // node_modules/viem/node_modules/abitype/dist/esm/human-readable/parseAbi.js
718
+ function parseAbi(signatures) {
719
+ const structs = parseStructs(signatures);
720
+ const abi = [];
721
+ const length = signatures.length;
722
+ for (let i = 0; i < length; i++) {
723
+ const signature = signatures[i];
724
+ if (isStructSignature(signature))
725
+ continue;
726
+ abi.push(parseSignature(signature, structs));
727
+ }
728
+ return abi;
729
+ }
730
+
731
+ // node_modules/viem/node_modules/ox/_esm/core/version.js
732
+ var version2 = "0.1.1";
733
+
734
+ // node_modules/viem/node_modules/ox/_esm/core/internal/errors.js
735
+ function getVersion() {
736
+ return version2;
737
+ }
738
+
739
+ // node_modules/viem/node_modules/ox/_esm/core/Errors.js
740
+ var BaseError2 = class _BaseError extends Error {
741
+ constructor(shortMessage, options = {}) {
742
+ const details = (() => {
743
+ if (options.cause instanceof _BaseError) {
744
+ if (options.cause.details)
745
+ return options.cause.details;
746
+ if (options.cause.shortMessage)
747
+ return options.cause.shortMessage;
748
+ }
749
+ if (options.cause && "details" in options.cause && typeof options.cause.details === "string")
750
+ return options.cause.details;
751
+ if (options.cause?.message)
752
+ return options.cause.message;
753
+ return options.details;
754
+ })();
755
+ const docsPath6 = (() => {
756
+ if (options.cause instanceof _BaseError)
757
+ return options.cause.docsPath || options.docsPath;
758
+ return options.docsPath;
759
+ })();
760
+ const docsBaseUrl = "https://oxlib.sh";
761
+ const docs = `${docsBaseUrl}${docsPath6 ?? ""}`;
762
+ const message = [
763
+ shortMessage || "An error occurred.",
764
+ ...options.metaMessages ? ["", ...options.metaMessages] : [],
765
+ ...details || docsPath6 ? [
766
+ "",
767
+ details ? `Details: ${details}` : void 0,
768
+ docsPath6 ? `See: ${docs}` : void 0
769
+ ] : []
770
+ ].filter((x) => typeof x === "string").join("\n");
771
+ super(message, options.cause ? { cause: options.cause } : void 0);
772
+ Object.defineProperty(this, "details", {
773
+ enumerable: true,
774
+ configurable: true,
775
+ writable: true,
776
+ value: void 0
777
+ });
778
+ Object.defineProperty(this, "docs", {
779
+ enumerable: true,
780
+ configurable: true,
781
+ writable: true,
782
+ value: void 0
783
+ });
784
+ Object.defineProperty(this, "docsPath", {
785
+ enumerable: true,
786
+ configurable: true,
787
+ writable: true,
788
+ value: void 0
789
+ });
790
+ Object.defineProperty(this, "shortMessage", {
791
+ enumerable: true,
792
+ configurable: true,
793
+ writable: true,
794
+ value: void 0
795
+ });
796
+ Object.defineProperty(this, "cause", {
797
+ enumerable: true,
798
+ configurable: true,
799
+ writable: true,
800
+ value: void 0
801
+ });
802
+ Object.defineProperty(this, "name", {
803
+ enumerable: true,
804
+ configurable: true,
805
+ writable: true,
806
+ value: "BaseError"
807
+ });
808
+ Object.defineProperty(this, "version", {
809
+ enumerable: true,
810
+ configurable: true,
811
+ writable: true,
812
+ value: `ox@${getVersion()}`
813
+ });
814
+ this.cause = options.cause;
815
+ this.details = details;
816
+ this.docs = docs;
817
+ this.docsPath = docsPath6;
818
+ this.shortMessage = shortMessage;
819
+ }
820
+ walk(fn) {
821
+ return walk(this, fn);
822
+ }
823
+ };
824
+ function walk(err, fn) {
825
+ if (fn?.(err))
826
+ return err;
827
+ if (err && typeof err === "object" && "cause" in err && err.cause)
828
+ return walk(err.cause, fn);
829
+ return fn ? null : err;
830
+ }
831
+
832
+ // node_modules/viem/node_modules/ox/_esm/core/internal/hex.js
833
+ function pad(hex_, options = {}) {
834
+ const { dir, size: size3 = 32 } = options;
835
+ if (size3 === 0)
836
+ return hex_;
837
+ const hex = hex_.replace("0x", "");
838
+ if (hex.length > size3 * 2)
839
+ throw new SizeExceedsPaddingSizeError({
840
+ size: Math.ceil(hex.length / 2),
841
+ targetSize: size3,
842
+ type: "Hex"
843
+ });
844
+ return `0x${hex[dir === "right" ? "padEnd" : "padStart"](size3 * 2, "0")}`;
845
+ }
846
+
847
+ // node_modules/viem/node_modules/ox/_esm/core/Hex.js
848
+ function fromNumber(value, options = {}) {
849
+ const { signed, size: size3 } = options;
850
+ const value_ = BigInt(value);
851
+ let maxValue;
852
+ if (size3) {
853
+ if (signed)
854
+ maxValue = (1n << BigInt(size3) * 8n - 1n) - 1n;
855
+ else
856
+ maxValue = 2n ** (BigInt(size3) * 8n) - 1n;
857
+ } else if (typeof value === "number") {
858
+ maxValue = BigInt(Number.MAX_SAFE_INTEGER);
859
+ }
860
+ const minValue = typeof maxValue === "bigint" && signed ? -maxValue - 1n : 0;
861
+ if (maxValue && value_ > maxValue || value_ < minValue) {
862
+ const suffix = typeof value === "bigint" ? "n" : "";
863
+ throw new IntegerOutOfRangeError({
864
+ max: maxValue ? `${maxValue}${suffix}` : void 0,
865
+ min: `${minValue}${suffix}`,
866
+ signed,
867
+ size: size3,
868
+ value: `${value}${suffix}`
869
+ });
870
+ }
871
+ const stringValue = (signed && value_ < 0 ? (1n << BigInt(size3 * 8)) + BigInt(value_) : value_).toString(16);
872
+ const hex = `0x${stringValue}`;
873
+ if (size3)
874
+ return padLeft(hex, size3);
875
+ return hex;
876
+ }
877
+ function padLeft(value, size3) {
878
+ return pad(value, { dir: "left", size: size3 });
879
+ }
880
+ var IntegerOutOfRangeError = class extends BaseError2 {
881
+ constructor({ max, min, signed, size: size3, value }) {
882
+ super(`Number \`${value}\` is not in safe${size3 ? ` ${size3 * 8}-bit` : ""}${signed ? " signed" : " unsigned"} integer range ${max ? `(\`${min}\` to \`${max}\`)` : `(above \`${min}\`)`}`);
883
+ Object.defineProperty(this, "name", {
884
+ enumerable: true,
885
+ configurable: true,
886
+ writable: true,
887
+ value: "Hex.IntegerOutOfRangeError"
888
+ });
889
+ }
890
+ };
891
+ var SizeExceedsPaddingSizeError = class extends BaseError2 {
892
+ constructor({ size: size3, targetSize, type }) {
893
+ super(`${type.charAt(0).toUpperCase()}${type.slice(1).toLowerCase()} size (\`${size3}\`) exceeds padding size (\`${targetSize}\`).`);
894
+ Object.defineProperty(this, "name", {
895
+ enumerable: true,
896
+ configurable: true,
897
+ writable: true,
898
+ value: "Hex.SizeExceedsPaddingSizeError"
899
+ });
900
+ }
901
+ };
902
+
903
+ // node_modules/viem/node_modules/ox/_esm/core/Withdrawal.js
904
+ function toRpc(withdrawal) {
905
+ return {
906
+ address: withdrawal.address,
907
+ amount: fromNumber(withdrawal.amount),
908
+ index: fromNumber(withdrawal.index),
909
+ validatorIndex: fromNumber(withdrawal.validatorIndex)
910
+ };
911
+ }
912
+
913
+ // node_modules/viem/node_modules/ox/_esm/core/BlockOverrides.js
914
+ function toRpc2(blockOverrides) {
915
+ return {
916
+ ...typeof blockOverrides.baseFeePerGas === "bigint" && {
917
+ baseFeePerGas: fromNumber(blockOverrides.baseFeePerGas)
918
+ },
919
+ ...typeof blockOverrides.blobBaseFee === "bigint" && {
920
+ blobBaseFee: fromNumber(blockOverrides.blobBaseFee)
921
+ },
922
+ ...typeof blockOverrides.feeRecipient === "string" && {
923
+ feeRecipient: blockOverrides.feeRecipient
924
+ },
925
+ ...typeof blockOverrides.gasLimit === "bigint" && {
926
+ gasLimit: fromNumber(blockOverrides.gasLimit)
927
+ },
928
+ ...typeof blockOverrides.number === "bigint" && {
929
+ number: fromNumber(blockOverrides.number)
930
+ },
931
+ ...typeof blockOverrides.prevRandao === "bigint" && {
932
+ prevRandao: fromNumber(blockOverrides.prevRandao)
933
+ },
934
+ ...typeof blockOverrides.time === "bigint" && {
935
+ time: fromNumber(blockOverrides.time)
936
+ },
937
+ ...blockOverrides.withdrawals && {
938
+ withdrawals: blockOverrides.withdrawals.map(toRpc)
939
+ }
940
+ };
941
+ }
942
+
943
+ // node_modules/viem/_esm/accounts/utils/parseAccount.js
944
+ function parseAccount(account) {
945
+ if (typeof account === "string")
946
+ return { address: account, type: "json-rpc" };
947
+ return account;
948
+ }
949
+
950
+ // node_modules/viem/_esm/constants/abis.js
951
+ var multicall3Abi = [
952
+ {
953
+ inputs: [
954
+ {
955
+ components: [
956
+ {
957
+ name: "target",
958
+ type: "address"
959
+ },
960
+ {
961
+ name: "allowFailure",
962
+ type: "bool"
963
+ },
964
+ {
965
+ name: "callData",
966
+ type: "bytes"
967
+ }
968
+ ],
969
+ name: "calls",
970
+ type: "tuple[]"
971
+ }
972
+ ],
973
+ name: "aggregate3",
974
+ outputs: [
975
+ {
976
+ components: [
977
+ {
978
+ name: "success",
979
+ type: "bool"
980
+ },
981
+ {
982
+ name: "returnData",
983
+ type: "bytes"
984
+ }
985
+ ],
986
+ name: "returnData",
987
+ type: "tuple[]"
988
+ }
989
+ ],
990
+ stateMutability: "view",
991
+ type: "function"
992
+ },
993
+ {
994
+ inputs: [],
995
+ name: "getCurrentBlockTimestamp",
996
+ outputs: [
997
+ {
998
+ internalType: "uint256",
999
+ name: "timestamp",
1000
+ type: "uint256"
1001
+ }
1002
+ ],
1003
+ stateMutability: "view",
1004
+ type: "function"
1005
+ }
1006
+ ];
1007
+ var batchGatewayAbi = [
1008
+ {
1009
+ name: "query",
1010
+ type: "function",
1011
+ stateMutability: "view",
1012
+ inputs: [
1013
+ {
1014
+ type: "tuple[]",
1015
+ name: "queries",
1016
+ components: [
1017
+ {
1018
+ type: "address",
1019
+ name: "sender"
1020
+ },
1021
+ {
1022
+ type: "string[]",
1023
+ name: "urls"
1024
+ },
1025
+ {
1026
+ type: "bytes",
1027
+ name: "data"
1028
+ }
1029
+ ]
1030
+ }
1031
+ ],
1032
+ outputs: [
1033
+ {
1034
+ type: "bool[]",
1035
+ name: "failures"
1036
+ },
1037
+ {
1038
+ type: "bytes[]",
1039
+ name: "responses"
1040
+ }
1041
+ ]
1042
+ },
1043
+ {
1044
+ name: "HttpError",
1045
+ type: "error",
1046
+ inputs: [
1047
+ {
1048
+ type: "uint16",
1049
+ name: "status"
1050
+ },
1051
+ {
1052
+ type: "string",
1053
+ name: "message"
1054
+ }
1055
+ ]
1056
+ }
1057
+ ];
1058
+ var universalResolverErrors = [
1059
+ {
1060
+ inputs: [
1061
+ {
1062
+ name: "dns",
1063
+ type: "bytes"
1064
+ }
1065
+ ],
1066
+ name: "DNSDecodingFailed",
1067
+ type: "error"
1068
+ },
1069
+ {
1070
+ inputs: [
1071
+ {
1072
+ name: "ens",
1073
+ type: "string"
1074
+ }
1075
+ ],
1076
+ name: "DNSEncodingFailed",
1077
+ type: "error"
1078
+ },
1079
+ {
1080
+ inputs: [],
1081
+ name: "EmptyAddress",
1082
+ type: "error"
1083
+ },
1084
+ {
1085
+ inputs: [
1086
+ {
1087
+ name: "status",
1088
+ type: "uint16"
1089
+ },
1090
+ {
1091
+ name: "message",
1092
+ type: "string"
1093
+ }
1094
+ ],
1095
+ name: "HttpError",
1096
+ type: "error"
1097
+ },
1098
+ {
1099
+ inputs: [],
1100
+ name: "InvalidBatchGatewayResponse",
1101
+ type: "error"
1102
+ },
1103
+ {
1104
+ inputs: [
1105
+ {
1106
+ name: "errorData",
1107
+ type: "bytes"
1108
+ }
1109
+ ],
1110
+ name: "ResolverError",
1111
+ type: "error"
1112
+ },
1113
+ {
1114
+ inputs: [
1115
+ {
1116
+ name: "name",
1117
+ type: "bytes"
1118
+ },
1119
+ {
1120
+ name: "resolver",
1121
+ type: "address"
1122
+ }
1123
+ ],
1124
+ name: "ResolverNotContract",
1125
+ type: "error"
1126
+ },
1127
+ {
1128
+ inputs: [
1129
+ {
1130
+ name: "name",
1131
+ type: "bytes"
1132
+ }
1133
+ ],
1134
+ name: "ResolverNotFound",
1135
+ type: "error"
1136
+ },
1137
+ {
1138
+ inputs: [
1139
+ {
1140
+ name: "primary",
1141
+ type: "string"
1142
+ },
1143
+ {
1144
+ name: "primaryAddress",
1145
+ type: "bytes"
1146
+ }
1147
+ ],
1148
+ name: "ReverseAddressMismatch",
1149
+ type: "error"
1150
+ },
1151
+ {
1152
+ inputs: [
1153
+ {
1154
+ internalType: "bytes4",
1155
+ name: "selector",
1156
+ type: "bytes4"
1157
+ }
1158
+ ],
1159
+ name: "UnsupportedResolverProfile",
1160
+ type: "error"
1161
+ }
1162
+ ];
1163
+ var universalResolverResolveAbi = [
1164
+ ...universalResolverErrors,
1165
+ {
1166
+ name: "resolveWithGateways",
1167
+ type: "function",
1168
+ stateMutability: "view",
1169
+ inputs: [
1170
+ { name: "name", type: "bytes" },
1171
+ { name: "data", type: "bytes" },
1172
+ { name: "gateways", type: "string[]" }
1173
+ ],
1174
+ outputs: [
1175
+ { name: "", type: "bytes" },
1176
+ { name: "address", type: "address" }
1177
+ ]
1178
+ }
1179
+ ];
1180
+ var universalResolverReverseAbi = [
1181
+ ...universalResolverErrors,
1182
+ {
1183
+ name: "reverseWithGateways",
1184
+ type: "function",
1185
+ stateMutability: "view",
1186
+ inputs: [
1187
+ { type: "bytes", name: "reverseName" },
1188
+ { type: "uint256", name: "coinType" },
1189
+ { type: "string[]", name: "gateways" }
1190
+ ],
1191
+ outputs: [
1192
+ { type: "string", name: "resolvedName" },
1193
+ { type: "address", name: "resolver" },
1194
+ { type: "address", name: "reverseResolver" }
1195
+ ]
1196
+ }
1197
+ ];
1198
+
1199
+ // node_modules/viem/_esm/constants/contract.js
1200
+ var aggregate3Signature = "0x82ad56cb";
1201
+
1202
+ // node_modules/viem/_esm/constants/contracts.js
1203
+ var deploylessCallViaBytecodeBytecode = "0x608060405234801561001057600080fd5b5060405161018e38038061018e83398101604081905261002f91610124565b6000808351602085016000f59050803b61004857600080fd5b6000808351602085016000855af16040513d6000823e81610067573d81fd5b3d81f35b634e487b7160e01b600052604160045260246000fd5b600082601f83011261009257600080fd5b81516001600160401b038111156100ab576100ab61006b565b604051601f8201601f19908116603f011681016001600160401b03811182821017156100d9576100d961006b565b6040528181528382016020018510156100f157600080fd5b60005b82811015610110576020818601810151838301820152016100f4565b506000918101602001919091529392505050565b6000806040838503121561013757600080fd5b82516001600160401b0381111561014d57600080fd5b61015985828601610081565b602085015190935090506001600160401b0381111561017757600080fd5b61018385828601610081565b915050925092905056fe";
1204
+ var deploylessCallViaFactoryBytecode = "0x608060405234801561001057600080fd5b506040516102c03803806102c083398101604081905261002f916101e6565b836001600160a01b03163b6000036100e457600080836001600160a01b03168360405161005c9190610270565b6000604051808303816000865af19150503d8060008114610099576040519150601f19603f3d011682016040523d82523d6000602084013e61009e565b606091505b50915091508115806100b857506001600160a01b0386163b155b156100e1578060405163101bb98d60e01b81526004016100d8919061028c565b60405180910390fd5b50505b6000808451602086016000885af16040513d6000823e81610103573d81fd5b3d81f35b80516001600160a01b038116811461011e57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561015457818101518382015260200161013c565b50506000910152565b600082601f83011261016e57600080fd5b81516001600160401b0381111561018757610187610123565b604051601f8201601f19908116603f011681016001600160401b03811182821017156101b5576101b5610123565b6040528181528382016020018510156101cd57600080fd5b6101de826020830160208701610139565b949350505050565b600080600080608085870312156101fc57600080fd5b61020585610107565b60208601519094506001600160401b0381111561022157600080fd5b61022d8782880161015d565b93505061023c60408601610107565b60608601519092506001600160401b0381111561025857600080fd5b6102648782880161015d565b91505092959194509250565b60008251610282818460208701610139565b9190910192915050565b60208152600082518060208401526102ab816040850160208701610139565b601f01601f1916919091016040019291505056fe";
1205
+ var multicall3Bytecode = "0x608060405234801561001057600080fd5b506115b9806100206000396000f3fe6080604052600436106100f35760003560e01c80634d2301cc1161008a578063a8b0574e11610059578063a8b0574e14610325578063bce38bd714610350578063c3077fa914610380578063ee82ac5e146103b2576100f3565b80634d2301cc1461026257806372425d9d1461029f57806382ad56cb146102ca57806386d516e8146102fa576100f3565b80633408e470116100c65780633408e470146101af578063399542e9146101da5780633e64a6961461020c57806342cbb15c14610237576100f3565b80630f28c97d146100f8578063174dea7114610123578063252dba421461015357806327e86d6e14610184575b600080fd5b34801561010457600080fd5b5061010d6103ef565b60405161011a9190610c0a565b60405180910390f35b61013d60048036038101906101389190610c94565b6103f7565b60405161014a9190610e94565b60405180910390f35b61016d60048036038101906101689190610f0c565b610615565b60405161017b92919061101b565b60405180910390f35b34801561019057600080fd5b506101996107ab565b6040516101a69190611064565b60405180910390f35b3480156101bb57600080fd5b506101c46107b7565b6040516101d19190610c0a565b60405180910390f35b6101f460048036038101906101ef91906110ab565b6107bf565b6040516102039392919061110b565b60405180910390f35b34801561021857600080fd5b506102216107e1565b60405161022e9190610c0a565b60405180910390f35b34801561024357600080fd5b5061024c6107e9565b6040516102599190610c0a565b60405180910390f35b34801561026e57600080fd5b50610289600480360381019061028491906111a7565b6107f1565b6040516102969190610c0a565b60405180910390f35b3480156102ab57600080fd5b506102b4610812565b6040516102c19190610c0a565b60405180910390f35b6102e460048036038101906102df919061122a565b61081a565b6040516102f19190610e94565b60405180910390f35b34801561030657600080fd5b5061030f6109e4565b60405161031c9190610c0a565b60405180910390f35b34801561033157600080fd5b5061033a6109ec565b6040516103479190611286565b60405180910390f35b61036a600480360381019061036591906110ab565b6109f4565b6040516103779190610e94565b60405180910390f35b61039a60048036038101906103959190610f0c565b610ba6565b6040516103a99392919061110b565b60405180910390f35b3480156103be57600080fd5b506103d960048036038101906103d491906112cd565b610bca565b6040516103e69190611064565b60405180910390f35b600042905090565b60606000808484905090508067ffffffffffffffff81111561041c5761041b6112fa565b5b60405190808252806020026020018201604052801561045557816020015b610442610bd5565b81526020019060019003908161043a5790505b5092503660005b828110156105c957600085828151811061047957610478611329565b5b6020026020010151905087878381811061049657610495611329565b5b90506020028101906104a89190611367565b925060008360400135905080860195508360000160208101906104cb91906111a7565b73ffffffffffffffffffffffffffffffffffffffff16818580606001906104f2919061138f565b604051610500929190611431565b60006040518083038185875af1925050503d806000811461053d576040519150601f19603f3d011682016040523d82523d6000602084013e610542565b606091505b5083600001846020018290528215151515815250505081516020850135176105bc577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260846000fd5b826001019250505061045c565b5082341461060c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610603906114a7565b60405180910390fd5b50505092915050565b6000606043915060008484905090508067ffffffffffffffff81111561063e5761063d6112fa565b5b60405190808252806020026020018201604052801561067157816020015b606081526020019060019003908161065c5790505b5091503660005b828110156107a157600087878381811061069557610694611329565b5b90506020028101906106a791906114c7565b92508260000160208101906106bc91906111a7565b73ffffffffffffffffffffffffffffffffffffffff168380602001906106e2919061138f565b6040516106f0929190611431565b6000604051808303816000865af19150503d806000811461072d576040519150601f19603f3d011682016040523d82523d6000602084013e610732565b606091505b5086848151811061074657610745611329565b5b60200260200101819052819250505080610795576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161078c9061153b565b60405180910390fd5b81600101915050610678565b5050509250929050565b60006001430340905090565b600046905090565b6000806060439250434091506107d68686866109f4565b905093509350939050565b600048905090565b600043905090565b60008173ffffffffffffffffffffffffffffffffffffffff16319050919050565b600044905090565b606060008383905090508067ffffffffffffffff81111561083e5761083d6112fa565b5b60405190808252806020026020018201604052801561087757816020015b610864610bd5565b81526020019060019003908161085c5790505b5091503660005b828110156109db57600084828151811061089b5761089a611329565b5b602002602001015190508686838181106108b8576108b7611329565b5b90506020028101906108ca919061155b565b92508260000160208101906108df91906111a7565b73ffffffffffffffffffffffffffffffffffffffff16838060400190610905919061138f565b604051610913929190611431565b6000604051808303816000865af19150503d8060008114610950576040519150601f19603f3d011682016040523d82523d6000602084013e610955565b606091505b5082600001836020018290528215151515815250505080516020840135176109cf577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260646000fd5b8160010191505061087e565b50505092915050565b600045905090565b600041905090565b606060008383905090508067ffffffffffffffff811115610a1857610a176112fa565b5b604051908082528060200260200182016040528015610a5157816020015b610a3e610bd5565b815260200190600190039081610a365790505b5091503660005b82811015610b9c576000848281518110610a7557610a74611329565b5b60200260200101519050868683818110610a9257610a91611329565b5b9050602002810190610aa491906114c7565b9250826000016020810190610ab991906111a7565b73ffffffffffffffffffffffffffffffffffffffff16838060200190610adf919061138f565b604051610aed929190611431565b6000604051808303816000865af19150503d8060008114610b2a576040519150601f19603f3d011682016040523d82523d6000602084013e610b2f565b606091505b508260000183602001829052821515151581525050508715610b90578060000151610b8f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b869061153b565b60405180910390fd5b5b81600101915050610a58565b5050509392505050565b6000806060610bb7600186866107bf565b8093508194508295505050509250925092565b600081409050919050565b6040518060400160405280600015158152602001606081525090565b6000819050919050565b610c0481610bf1565b82525050565b6000602082019050610c1f6000830184610bfb565b92915050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f840112610c5457610c53610c2f565b5b8235905067ffffffffffffffff811115610c7157610c70610c34565b5b602083019150836020820283011115610c8d57610c8c610c39565b5b9250929050565b60008060208385031215610cab57610caa610c25565b5b600083013567ffffffffffffffff811115610cc957610cc8610c2a565b5b610cd585828601610c3e565b92509250509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b60008115159050919050565b610d2281610d0d565b82525050565b600081519050919050565b600082825260208201905092915050565b60005b83811015610d62578082015181840152602081019050610d47565b83811115610d71576000848401525b50505050565b6000601f19601f8301169050919050565b6000610d9382610d28565b610d9d8185610d33565b9350610dad818560208601610d44565b610db681610d77565b840191505092915050565b6000604083016000830151610dd96000860182610d19565b5060208301518482036020860152610df18282610d88565b9150508091505092915050565b6000610e0a8383610dc1565b905092915050565b6000602082019050919050565b6000610e2a82610ce1565b610e348185610cec565b935083602082028501610e4685610cfd565b8060005b85811015610e825784840389528151610e638582610dfe565b9450610e6e83610e12565b925060208a01995050600181019050610e4a565b50829750879550505050505092915050565b60006020820190508181036000830152610eae8184610e1f565b905092915050565b60008083601f840112610ecc57610ecb610c2f565b5b8235905067ffffffffffffffff811115610ee957610ee8610c34565b5b602083019150836020820283011115610f0557610f04610c39565b5b9250929050565b60008060208385031215610f2357610f22610c25565b5b600083013567ffffffffffffffff811115610f4157610f40610c2a565b5b610f4d85828601610eb6565b92509250509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6000610f918383610d88565b905092915050565b6000602082019050919050565b6000610fb182610f59565b610fbb8185610f64565b935083602082028501610fcd85610f75565b8060005b858110156110095784840389528151610fea8582610f85565b9450610ff583610f99565b925060208a01995050600181019050610fd1565b50829750879550505050505092915050565b60006040820190506110306000830185610bfb565b81810360208301526110428184610fa6565b90509392505050565b6000819050919050565b61105e8161104b565b82525050565b60006020820190506110796000830184611055565b92915050565b61108881610d0d565b811461109357600080fd5b50565b6000813590506110a58161107f565b92915050565b6000806000604084860312156110c4576110c3610c25565b5b60006110d286828701611096565b935050602084013567ffffffffffffffff8111156110f3576110f2610c2a565b5b6110ff86828701610eb6565b92509250509250925092565b60006060820190506111206000830186610bfb565b61112d6020830185611055565b818103604083015261113f8184610e1f565b9050949350505050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061117482611149565b9050919050565b61118481611169565b811461118f57600080fd5b50565b6000813590506111a18161117b565b92915050565b6000602082840312156111bd576111bc610c25565b5b60006111cb84828501611192565b91505092915050565b60008083601f8401126111ea576111e9610c2f565b5b8235905067ffffffffffffffff81111561120757611206610c34565b5b60208301915083602082028301111561122357611222610c39565b5b9250929050565b6000806020838503121561124157611240610c25565b5b600083013567ffffffffffffffff81111561125f5761125e610c2a565b5b61126b858286016111d4565b92509250509250929050565b61128081611169565b82525050565b600060208201905061129b6000830184611277565b92915050565b6112aa81610bf1565b81146112b557600080fd5b50565b6000813590506112c7816112a1565b92915050565b6000602082840312156112e3576112e2610c25565b5b60006112f1848285016112b8565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600080fd5b600080fd5b600080fd5b60008235600160800383360303811261138357611382611358565b5b80830191505092915050565b600080833560016020038436030381126113ac576113ab611358565b5b80840192508235915067ffffffffffffffff8211156113ce576113cd61135d565b5b6020830192506001820236038313156113ea576113e9611362565b5b509250929050565b600081905092915050565b82818337600083830152505050565b600061141883856113f2565b93506114258385846113fd565b82840190509392505050565b600061143e82848661140c565b91508190509392505050565b600082825260208201905092915050565b7f4d756c746963616c6c333a2076616c7565206d69736d61746368000000000000600082015250565b6000611491601a8361144a565b915061149c8261145b565b602082019050919050565b600060208201905081810360008301526114c081611484565b9050919050565b6000823560016040038336030381126114e3576114e2611358565b5b80830191505092915050565b7f4d756c746963616c6c333a2063616c6c206661696c6564000000000000000000600082015250565b600061152560178361144a565b9150611530826114ef565b602082019050919050565b6000602082019050818103600083015261155481611518565b9050919050565b60008235600160600383360303811261157757611576611358565b5b8083019150509291505056fea264697066735822122020c1bc9aacf8e4a6507193432a895a8e77094f45a1395583f07b24e860ef06cd64736f6c634300080c0033";
1206
+
1207
+ // node_modules/viem/_esm/errors/version.js
1208
+ var version3 = "2.42.1";
1209
+
1210
+ // node_modules/viem/_esm/errors/base.js
1211
+ var errorConfig = {
1212
+ getDocsUrl: ({ docsBaseUrl, docsPath: docsPath6 = "", docsSlug }) => docsPath6 ? `${docsBaseUrl ?? "https://viem.sh"}${docsPath6}${docsSlug ? `#${docsSlug}` : ""}` : void 0,
1213
+ version: `viem@${version3}`
1214
+ };
1215
+ var BaseError3 = class _BaseError extends Error {
1216
+ constructor(shortMessage, args = {}) {
1217
+ const details = (() => {
1218
+ if (args.cause instanceof _BaseError)
1219
+ return args.cause.details;
1220
+ if (args.cause?.message)
1221
+ return args.cause.message;
1222
+ return args.details;
1223
+ })();
1224
+ const docsPath6 = (() => {
1225
+ if (args.cause instanceof _BaseError)
1226
+ return args.cause.docsPath || args.docsPath;
1227
+ return args.docsPath;
1228
+ })();
1229
+ const docsUrl = errorConfig.getDocsUrl?.({ ...args, docsPath: docsPath6 });
1230
+ const message = [
1231
+ shortMessage || "An error occurred.",
1232
+ "",
1233
+ ...args.metaMessages ? [...args.metaMessages, ""] : [],
1234
+ ...docsUrl ? [`Docs: ${docsUrl}`] : [],
1235
+ ...details ? [`Details: ${details}`] : [],
1236
+ ...errorConfig.version ? [`Version: ${errorConfig.version}`] : []
1237
+ ].join("\n");
1238
+ super(message, args.cause ? { cause: args.cause } : void 0);
1239
+ Object.defineProperty(this, "details", {
1240
+ enumerable: true,
1241
+ configurable: true,
1242
+ writable: true,
1243
+ value: void 0
1244
+ });
1245
+ Object.defineProperty(this, "docsPath", {
1246
+ enumerable: true,
1247
+ configurable: true,
1248
+ writable: true,
1249
+ value: void 0
1250
+ });
1251
+ Object.defineProperty(this, "metaMessages", {
1252
+ enumerable: true,
1253
+ configurable: true,
1254
+ writable: true,
1255
+ value: void 0
1256
+ });
1257
+ Object.defineProperty(this, "shortMessage", {
1258
+ enumerable: true,
1259
+ configurable: true,
1260
+ writable: true,
1261
+ value: void 0
1262
+ });
1263
+ Object.defineProperty(this, "version", {
1264
+ enumerable: true,
1265
+ configurable: true,
1266
+ writable: true,
1267
+ value: void 0
1268
+ });
1269
+ Object.defineProperty(this, "name", {
1270
+ enumerable: true,
1271
+ configurable: true,
1272
+ writable: true,
1273
+ value: "BaseError"
1274
+ });
1275
+ this.details = details;
1276
+ this.docsPath = docsPath6;
1277
+ this.metaMessages = args.metaMessages;
1278
+ this.name = args.name ?? this.name;
1279
+ this.shortMessage = shortMessage;
1280
+ this.version = version3;
1281
+ }
1282
+ walk(fn) {
1283
+ return walk2(this, fn);
1284
+ }
1285
+ };
1286
+ function walk2(err, fn) {
1287
+ if (fn?.(err))
1288
+ return err;
1289
+ if (err && typeof err === "object" && "cause" in err && err.cause !== void 0)
1290
+ return walk2(err.cause, fn);
1291
+ return fn ? null : err;
1292
+ }
1293
+
1294
+ // node_modules/viem/_esm/errors/chain.js
1295
+ var ChainDoesNotSupportContract = class extends BaseError3 {
1296
+ constructor({ blockNumber, chain, contract }) {
1297
+ super(`Chain "${chain.name}" does not support contract "${contract.name}".`, {
1298
+ metaMessages: [
1299
+ "This could be due to any of the following:",
1300
+ ...blockNumber && contract.blockCreated && contract.blockCreated > blockNumber ? [
1301
+ `- The contract "${contract.name}" was not deployed until block ${contract.blockCreated} (current block ${blockNumber}).`
1302
+ ] : [
1303
+ `- The chain does not have the contract "${contract.name}" configured.`
1304
+ ]
1305
+ ],
1306
+ name: "ChainDoesNotSupportContract"
1307
+ });
1308
+ }
1309
+ };
1310
+ var ClientChainNotConfiguredError = class extends BaseError3 {
1311
+ constructor() {
1312
+ super("No chain was provided to the Client.", {
1313
+ name: "ClientChainNotConfiguredError"
1314
+ });
1315
+ }
1316
+ };
1317
+
1318
+ // node_modules/viem/_esm/constants/solidity.js
1319
+ var solidityError = {
1320
+ inputs: [
1321
+ {
1322
+ name: "message",
1323
+ type: "string"
1324
+ }
1325
+ ],
1326
+ name: "Error",
1327
+ type: "error"
1328
+ };
1329
+ var solidityPanic = {
1330
+ inputs: [
1331
+ {
1332
+ name: "reason",
1333
+ type: "uint256"
1334
+ }
1335
+ ],
1336
+ name: "Panic",
1337
+ type: "error"
1338
+ };
1339
+
1340
+ // node_modules/viem/_esm/utils/abi/formatAbiItem.js
1341
+ function formatAbiItem2(abiItem, { includeName = false } = {}) {
1342
+ if (abiItem.type !== "function" && abiItem.type !== "event" && abiItem.type !== "error")
1343
+ throw new InvalidDefinitionTypeError(abiItem.type);
1344
+ return `${abiItem.name}(${formatAbiParams(abiItem.inputs, { includeName })})`;
1345
+ }
1346
+ function formatAbiParams(params, { includeName = false } = {}) {
1347
+ if (!params)
1348
+ return "";
1349
+ return params.map((param) => formatAbiParam(param, { includeName })).join(includeName ? ", " : ",");
1350
+ }
1351
+ function formatAbiParam(param, { includeName }) {
1352
+ if (param.type.startsWith("tuple")) {
1353
+ return `(${formatAbiParams(param.components, { includeName })})${param.type.slice("tuple".length)}`;
1354
+ }
1355
+ return param.type + (includeName && param.name ? ` ${param.name}` : "");
1356
+ }
1357
+
1358
+ // node_modules/viem/_esm/utils/data/isHex.js
1359
+ function isHex(value, { strict = true } = {}) {
1360
+ if (!value)
1361
+ return false;
1362
+ if (typeof value !== "string")
1363
+ return false;
1364
+ return strict ? /^0x[0-9a-fA-F]*$/.test(value) : value.startsWith("0x");
1365
+ }
1366
+
1367
+ // node_modules/viem/_esm/utils/data/size.js
1368
+ function size2(value) {
1369
+ if (isHex(value, { strict: false }))
1370
+ return Math.ceil((value.length - 2) / 2);
1371
+ return value.length;
1372
+ }
1373
+
1374
+ // node_modules/viem/_esm/errors/abi.js
1375
+ var AbiConstructorNotFoundError = class extends BaseError3 {
1376
+ constructor({ docsPath: docsPath6 }) {
1377
+ super([
1378
+ "A constructor was not found on the ABI.",
1379
+ "Make sure you are using the correct ABI and that the constructor exists on it."
1380
+ ].join("\n"), {
1381
+ docsPath: docsPath6,
1382
+ name: "AbiConstructorNotFoundError"
1383
+ });
1384
+ }
1385
+ };
1386
+ var AbiConstructorParamsNotFoundError = class extends BaseError3 {
1387
+ constructor({ docsPath: docsPath6 }) {
1388
+ super([
1389
+ "Constructor arguments were provided (`args`), but a constructor parameters (`inputs`) were not found on the ABI.",
1390
+ "Make sure you are using the correct ABI, and that the `inputs` attribute on the constructor exists."
1391
+ ].join("\n"), {
1392
+ docsPath: docsPath6,
1393
+ name: "AbiConstructorParamsNotFoundError"
1394
+ });
1395
+ }
1396
+ };
1397
+ var AbiDecodingDataSizeTooSmallError = class extends BaseError3 {
1398
+ constructor({ data, params, size: size3 }) {
1399
+ super([`Data size of ${size3} bytes is too small for given parameters.`].join("\n"), {
1400
+ metaMessages: [
1401
+ `Params: (${formatAbiParams(params, { includeName: true })})`,
1402
+ `Data: ${data} (${size3} bytes)`
1403
+ ],
1404
+ name: "AbiDecodingDataSizeTooSmallError"
1405
+ });
1406
+ Object.defineProperty(this, "data", {
1407
+ enumerable: true,
1408
+ configurable: true,
1409
+ writable: true,
1410
+ value: void 0
1411
+ });
1412
+ Object.defineProperty(this, "params", {
1413
+ enumerable: true,
1414
+ configurable: true,
1415
+ writable: true,
1416
+ value: void 0
1417
+ });
1418
+ Object.defineProperty(this, "size", {
1419
+ enumerable: true,
1420
+ configurable: true,
1421
+ writable: true,
1422
+ value: void 0
1423
+ });
1424
+ this.data = data;
1425
+ this.params = params;
1426
+ this.size = size3;
1427
+ }
1428
+ };
1429
+ var AbiDecodingZeroDataError = class extends BaseError3 {
1430
+ constructor() {
1431
+ super('Cannot decode zero data ("0x") with ABI parameters.', {
1432
+ name: "AbiDecodingZeroDataError"
1433
+ });
1434
+ }
1435
+ };
1436
+ var AbiEncodingArrayLengthMismatchError = class extends BaseError3 {
1437
+ constructor({ expectedLength, givenLength, type }) {
1438
+ super([
1439
+ `ABI encoding array length mismatch for type ${type}.`,
1440
+ `Expected length: ${expectedLength}`,
1441
+ `Given length: ${givenLength}`
1442
+ ].join("\n"), { name: "AbiEncodingArrayLengthMismatchError" });
1443
+ }
1444
+ };
1445
+ var AbiEncodingBytesSizeMismatchError = class extends BaseError3 {
1446
+ constructor({ expectedSize, value }) {
1447
+ super(`Size of bytes "${value}" (bytes${size2(value)}) does not match expected size (bytes${expectedSize}).`, { name: "AbiEncodingBytesSizeMismatchError" });
1448
+ }
1449
+ };
1450
+ var AbiEncodingLengthMismatchError = class extends BaseError3 {
1451
+ constructor({ expectedLength, givenLength }) {
1452
+ super([
1453
+ "ABI encoding params/values length mismatch.",
1454
+ `Expected length (params): ${expectedLength}`,
1455
+ `Given length (values): ${givenLength}`
1456
+ ].join("\n"), { name: "AbiEncodingLengthMismatchError" });
1457
+ }
1458
+ };
1459
+ var AbiErrorInputsNotFoundError = class extends BaseError3 {
1460
+ constructor(errorName, { docsPath: docsPath6 }) {
1461
+ super([
1462
+ `Arguments (\`args\`) were provided to "${errorName}", but "${errorName}" on the ABI does not contain any parameters (\`inputs\`).`,
1463
+ "Cannot encode error result without knowing what the parameter types are.",
1464
+ "Make sure you are using the correct ABI and that the inputs exist on it."
1465
+ ].join("\n"), {
1466
+ docsPath: docsPath6,
1467
+ name: "AbiErrorInputsNotFoundError"
1468
+ });
1469
+ }
1470
+ };
1471
+ var AbiErrorNotFoundError = class extends BaseError3 {
1472
+ constructor(errorName, { docsPath: docsPath6 } = {}) {
1473
+ super([
1474
+ `Error ${errorName ? `"${errorName}" ` : ""}not found on ABI.`,
1475
+ "Make sure you are using the correct ABI and that the error exists on it."
1476
+ ].join("\n"), {
1477
+ docsPath: docsPath6,
1478
+ name: "AbiErrorNotFoundError"
1479
+ });
1480
+ }
1481
+ };
1482
+ var AbiErrorSignatureNotFoundError = class extends BaseError3 {
1483
+ constructor(signature, { docsPath: docsPath6 }) {
1484
+ super([
1485
+ `Encoded error signature "${signature}" not found on ABI.`,
1486
+ "Make sure you are using the correct ABI and that the error exists on it.",
1487
+ `You can look up the decoded signature here: https://openchain.xyz/signatures?query=${signature}.`
1488
+ ].join("\n"), {
1489
+ docsPath: docsPath6,
1490
+ name: "AbiErrorSignatureNotFoundError"
1491
+ });
1492
+ Object.defineProperty(this, "signature", {
1493
+ enumerable: true,
1494
+ configurable: true,
1495
+ writable: true,
1496
+ value: void 0
1497
+ });
1498
+ this.signature = signature;
1499
+ }
1500
+ };
1501
+ var AbiFunctionNotFoundError = class extends BaseError3 {
1502
+ constructor(functionName, { docsPath: docsPath6 } = {}) {
1503
+ super([
1504
+ `Function ${functionName ? `"${functionName}" ` : ""}not found on ABI.`,
1505
+ "Make sure you are using the correct ABI and that the function exists on it."
1506
+ ].join("\n"), {
1507
+ docsPath: docsPath6,
1508
+ name: "AbiFunctionNotFoundError"
1509
+ });
1510
+ }
1511
+ };
1512
+ var AbiFunctionOutputsNotFoundError = class extends BaseError3 {
1513
+ constructor(functionName, { docsPath: docsPath6 }) {
1514
+ super([
1515
+ `Function "${functionName}" does not contain any \`outputs\` on ABI.`,
1516
+ "Cannot decode function result without knowing what the parameter types are.",
1517
+ "Make sure you are using the correct ABI and that the function exists on it."
1518
+ ].join("\n"), {
1519
+ docsPath: docsPath6,
1520
+ name: "AbiFunctionOutputsNotFoundError"
1521
+ });
1522
+ }
1523
+ };
1524
+ var AbiFunctionSignatureNotFoundError = class extends BaseError3 {
1525
+ constructor(signature, { docsPath: docsPath6 }) {
1526
+ super([
1527
+ `Encoded function signature "${signature}" not found on ABI.`,
1528
+ "Make sure you are using the correct ABI and that the function exists on it.",
1529
+ `You can look up the signature here: https://openchain.xyz/signatures?query=${signature}.`
1530
+ ].join("\n"), {
1531
+ docsPath: docsPath6,
1532
+ name: "AbiFunctionSignatureNotFoundError"
1533
+ });
1534
+ }
1535
+ };
1536
+ var AbiItemAmbiguityError = class extends BaseError3 {
1537
+ constructor(x, y) {
1538
+ super("Found ambiguous types in overloaded ABI items.", {
1539
+ metaMessages: [
1540
+ `\`${x.type}\` in \`${formatAbiItem2(x.abiItem)}\`, and`,
1541
+ `\`${y.type}\` in \`${formatAbiItem2(y.abiItem)}\``,
1542
+ "",
1543
+ "These types encode differently and cannot be distinguished at runtime.",
1544
+ "Remove one of the ambiguous items in the ABI."
1545
+ ],
1546
+ name: "AbiItemAmbiguityError"
1547
+ });
1548
+ }
1549
+ };
1550
+ var InvalidAbiEncodingTypeError = class extends BaseError3 {
1551
+ constructor(type, { docsPath: docsPath6 }) {
1552
+ super([
1553
+ `Type "${type}" is not a valid encoding type.`,
1554
+ "Please provide a valid ABI type."
1555
+ ].join("\n"), { docsPath: docsPath6, name: "InvalidAbiEncodingType" });
1556
+ }
1557
+ };
1558
+ var InvalidAbiDecodingTypeError = class extends BaseError3 {
1559
+ constructor(type, { docsPath: docsPath6 }) {
1560
+ super([
1561
+ `Type "${type}" is not a valid decoding type.`,
1562
+ "Please provide a valid ABI type."
1563
+ ].join("\n"), { docsPath: docsPath6, name: "InvalidAbiDecodingType" });
1564
+ }
1565
+ };
1566
+ var InvalidArrayError = class extends BaseError3 {
1567
+ constructor(value) {
1568
+ super([`Value "${value}" is not a valid array.`].join("\n"), {
1569
+ name: "InvalidArrayError"
1570
+ });
1571
+ }
1572
+ };
1573
+ var InvalidDefinitionTypeError = class extends BaseError3 {
1574
+ constructor(type) {
1575
+ super([
1576
+ `"${type}" is not a valid definition type.`,
1577
+ 'Valid types: "function", "event", "error"'
1578
+ ].join("\n"), { name: "InvalidDefinitionTypeError" });
1579
+ }
1580
+ };
1581
+
1582
+ // node_modules/viem/_esm/errors/data.js
1583
+ var SliceOffsetOutOfBoundsError2 = class extends BaseError3 {
1584
+ constructor({ offset, position, size: size3 }) {
1585
+ super(`Slice ${position === "start" ? "starting" : "ending"} at offset "${offset}" is out-of-bounds (size: ${size3}).`, { name: "SliceOffsetOutOfBoundsError" });
1586
+ }
1587
+ };
1588
+ var SizeExceedsPaddingSizeError2 = class extends BaseError3 {
1589
+ constructor({ size: size3, targetSize, type }) {
1590
+ super(`${type.charAt(0).toUpperCase()}${type.slice(1).toLowerCase()} size (${size3}) exceeds padding size (${targetSize}).`, { name: "SizeExceedsPaddingSizeError" });
1591
+ }
1592
+ };
1593
+ var InvalidBytesLengthError = class extends BaseError3 {
1594
+ constructor({ size: size3, targetSize, type }) {
1595
+ super(`${type.charAt(0).toUpperCase()}${type.slice(1).toLowerCase()} is expected to be ${targetSize} ${type} long, but is ${size3} ${type} long.`, { name: "InvalidBytesLengthError" });
1596
+ }
1597
+ };
1598
+
1599
+ // node_modules/viem/_esm/utils/data/slice.js
1600
+ function slice(value, start, end, { strict } = {}) {
1601
+ if (isHex(value, { strict: false }))
1602
+ return sliceHex(value, start, end, {
1603
+ strict
1604
+ });
1605
+ return sliceBytes(value, start, end, {
1606
+ strict
1607
+ });
1608
+ }
1609
+ function assertStartOffset2(value, start) {
1610
+ if (typeof start === "number" && start > 0 && start > size2(value) - 1)
1611
+ throw new SliceOffsetOutOfBoundsError2({
1612
+ offset: start,
1613
+ position: "start",
1614
+ size: size2(value)
1615
+ });
1616
+ }
1617
+ function assertEndOffset2(value, start, end) {
1618
+ if (typeof start === "number" && typeof end === "number" && size2(value) !== end - start) {
1619
+ throw new SliceOffsetOutOfBoundsError2({
1620
+ offset: end,
1621
+ position: "end",
1622
+ size: size2(value)
1623
+ });
1624
+ }
1625
+ }
1626
+ function sliceBytes(value_, start, end, { strict } = {}) {
1627
+ assertStartOffset2(value_, start);
1628
+ const value = value_.slice(start, end);
1629
+ if (strict)
1630
+ assertEndOffset2(value, start, end);
1631
+ return value;
1632
+ }
1633
+ function sliceHex(value_, start, end, { strict } = {}) {
1634
+ assertStartOffset2(value_, start);
1635
+ const value = `0x${value_.replace("0x", "").slice((start ?? 0) * 2, (end ?? value_.length) * 2)}`;
1636
+ if (strict)
1637
+ assertEndOffset2(value, start, end);
1638
+ return value;
1639
+ }
1640
+
1641
+ // node_modules/viem/_esm/utils/data/pad.js
1642
+ function pad2(hexOrBytes, { dir, size: size3 = 32 } = {}) {
1643
+ if (typeof hexOrBytes === "string")
1644
+ return padHex(hexOrBytes, { dir, size: size3 });
1645
+ return padBytes(hexOrBytes, { dir, size: size3 });
1646
+ }
1647
+ function padHex(hex_, { dir, size: size3 = 32 } = {}) {
1648
+ if (size3 === null)
1649
+ return hex_;
1650
+ const hex = hex_.replace("0x", "");
1651
+ if (hex.length > size3 * 2)
1652
+ throw new SizeExceedsPaddingSizeError2({
1653
+ size: Math.ceil(hex.length / 2),
1654
+ targetSize: size3,
1655
+ type: "hex"
1656
+ });
1657
+ return `0x${hex[dir === "right" ? "padEnd" : "padStart"](size3 * 2, "0")}`;
1658
+ }
1659
+ function padBytes(bytes, { dir, size: size3 = 32 } = {}) {
1660
+ if (size3 === null)
1661
+ return bytes;
1662
+ if (bytes.length > size3)
1663
+ throw new SizeExceedsPaddingSizeError2({
1664
+ size: bytes.length,
1665
+ targetSize: size3,
1666
+ type: "bytes"
1667
+ });
1668
+ const paddedBytes = new Uint8Array(size3);
1669
+ for (let i = 0; i < size3; i++) {
1670
+ const padEnd = dir === "right";
1671
+ paddedBytes[padEnd ? i : size3 - i - 1] = bytes[padEnd ? i : bytes.length - i - 1];
1672
+ }
1673
+ return paddedBytes;
1674
+ }
1675
+
1676
+ // node_modules/viem/_esm/errors/encoding.js
1677
+ var IntegerOutOfRangeError2 = class extends BaseError3 {
1678
+ constructor({ max, min, signed, size: size3, value }) {
1679
+ super(`Number "${value}" is not in safe ${size3 ? `${size3 * 8}-bit ${signed ? "signed" : "unsigned"} ` : ""}integer range ${max ? `(${min} to ${max})` : `(above ${min})`}`, { name: "IntegerOutOfRangeError" });
1680
+ }
1681
+ };
1682
+ var InvalidBytesBooleanError = class extends BaseError3 {
1683
+ constructor(bytes) {
1684
+ super(`Bytes value "${bytes}" is not a valid boolean. The bytes array must contain a single byte of either a 0 or 1 value.`, {
1685
+ name: "InvalidBytesBooleanError"
1686
+ });
1687
+ }
1688
+ };
1689
+ var SizeOverflowError2 = class extends BaseError3 {
1690
+ constructor({ givenSize, maxSize }) {
1691
+ super(`Size cannot exceed ${maxSize} bytes. Given size: ${givenSize} bytes.`, { name: "SizeOverflowError" });
1692
+ }
1693
+ };
1694
+
1695
+ // node_modules/viem/_esm/utils/data/trim.js
1696
+ function trim2(hexOrBytes, { dir = "left" } = {}) {
1697
+ let data = typeof hexOrBytes === "string" ? hexOrBytes.replace("0x", "") : hexOrBytes;
1698
+ let sliceLength = 0;
1699
+ for (let i = 0; i < data.length - 1; i++) {
1700
+ if (data[dir === "left" ? i : data.length - i - 1].toString() === "0")
1701
+ sliceLength++;
1702
+ else
1703
+ break;
1704
+ }
1705
+ data = dir === "left" ? data.slice(sliceLength) : data.slice(0, data.length - sliceLength);
1706
+ if (typeof hexOrBytes === "string") {
1707
+ if (data.length === 1 && dir === "right")
1708
+ data = `${data}0`;
1709
+ return `0x${data.length % 2 === 1 ? `0${data}` : data}`;
1710
+ }
1711
+ return data;
1712
+ }
1713
+
1714
+ // node_modules/viem/_esm/utils/encoding/fromHex.js
1715
+ function assertSize2(hexOrBytes, { size: size3 }) {
1716
+ if (size2(hexOrBytes) > size3)
1717
+ throw new SizeOverflowError2({
1718
+ givenSize: size2(hexOrBytes),
1719
+ maxSize: size3
1720
+ });
1721
+ }
1722
+ function hexToBigInt(hex, opts = {}) {
1723
+ const { signed } = opts;
1724
+ if (opts.size)
1725
+ assertSize2(hex, { size: opts.size });
1726
+ const value = BigInt(hex);
1727
+ if (!signed)
1728
+ return value;
1729
+ const size3 = (hex.length - 2) / 2;
1730
+ const max = (1n << BigInt(size3) * 8n - 1n) - 1n;
1731
+ if (value <= max)
1732
+ return value;
1733
+ return value - BigInt(`0x${"f".padStart(size3 * 2, "f")}`) - 1n;
1734
+ }
1735
+ function hexToNumber(hex, opts = {}) {
1736
+ return Number(hexToBigInt(hex, opts));
1737
+ }
1738
+
1739
+ // node_modules/viem/_esm/utils/encoding/toHex.js
1740
+ var hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_v, i) => i.toString(16).padStart(2, "0"));
1741
+ function toHex(value, opts = {}) {
1742
+ if (typeof value === "number" || typeof value === "bigint")
1743
+ return numberToHex(value, opts);
1744
+ if (typeof value === "string") {
1745
+ return stringToHex(value, opts);
1746
+ }
1747
+ if (typeof value === "boolean")
1748
+ return boolToHex(value, opts);
1749
+ return bytesToHex(value, opts);
1750
+ }
1751
+ function boolToHex(value, opts = {}) {
1752
+ const hex = `0x${Number(value)}`;
1753
+ if (typeof opts.size === "number") {
1754
+ assertSize2(hex, { size: opts.size });
1755
+ return pad2(hex, { size: opts.size });
1756
+ }
1757
+ return hex;
1758
+ }
1759
+ function bytesToHex(value, opts = {}) {
1760
+ let string = "";
1761
+ for (let i = 0; i < value.length; i++) {
1762
+ string += hexes[value[i]];
1763
+ }
1764
+ const hex = `0x${string}`;
1765
+ if (typeof opts.size === "number") {
1766
+ assertSize2(hex, { size: opts.size });
1767
+ return pad2(hex, { dir: "right", size: opts.size });
1768
+ }
1769
+ return hex;
1770
+ }
1771
+ function numberToHex(value_, opts = {}) {
1772
+ const { signed, size: size3 } = opts;
1773
+ const value = BigInt(value_);
1774
+ let maxValue;
1775
+ if (size3) {
1776
+ if (signed)
1777
+ maxValue = (1n << BigInt(size3) * 8n - 1n) - 1n;
1778
+ else
1779
+ maxValue = 2n ** (BigInt(size3) * 8n) - 1n;
1780
+ } else if (typeof value_ === "number") {
1781
+ maxValue = BigInt(Number.MAX_SAFE_INTEGER);
1782
+ }
1783
+ const minValue = typeof maxValue === "bigint" && signed ? -maxValue - 1n : 0;
1784
+ if (maxValue && value > maxValue || value < minValue) {
1785
+ const suffix = typeof value_ === "bigint" ? "n" : "";
1786
+ throw new IntegerOutOfRangeError2({
1787
+ max: maxValue ? `${maxValue}${suffix}` : void 0,
1788
+ min: `${minValue}${suffix}`,
1789
+ signed,
1790
+ size: size3,
1791
+ value: `${value_}${suffix}`
1792
+ });
1793
+ }
1794
+ const hex = `0x${(signed && value < 0 ? (1n << BigInt(size3 * 8)) + BigInt(value) : value).toString(16)}`;
1795
+ if (size3)
1796
+ return pad2(hex, { size: size3 });
1797
+ return hex;
1798
+ }
1799
+ var encoder = /* @__PURE__ */ new TextEncoder();
1800
+ function stringToHex(value_, opts = {}) {
1801
+ const value = encoder.encode(value_);
1802
+ return bytesToHex(value, opts);
1803
+ }
1804
+
1805
+ // node_modules/viem/_esm/utils/encoding/toBytes.js
1806
+ var encoder2 = /* @__PURE__ */ new TextEncoder();
1807
+ function toBytes2(value, opts = {}) {
1808
+ if (typeof value === "number" || typeof value === "bigint")
1809
+ return numberToBytes(value, opts);
1810
+ if (typeof value === "boolean")
1811
+ return boolToBytes(value, opts);
1812
+ if (isHex(value))
1813
+ return hexToBytes(value, opts);
1814
+ return stringToBytes(value, opts);
1815
+ }
1816
+ function boolToBytes(value, opts = {}) {
1817
+ const bytes = new Uint8Array(1);
1818
+ bytes[0] = Number(value);
1819
+ if (typeof opts.size === "number") {
1820
+ assertSize2(bytes, { size: opts.size });
1821
+ return pad2(bytes, { size: opts.size });
1822
+ }
1823
+ return bytes;
1824
+ }
1825
+ var charCodeMap = {
1826
+ zero: 48,
1827
+ nine: 57,
1828
+ A: 65,
1829
+ F: 70,
1830
+ a: 97,
1831
+ f: 102
1832
+ };
1833
+ function charCodeToBase16(char) {
1834
+ if (char >= charCodeMap.zero && char <= charCodeMap.nine)
1835
+ return char - charCodeMap.zero;
1836
+ if (char >= charCodeMap.A && char <= charCodeMap.F)
1837
+ return char - (charCodeMap.A - 10);
1838
+ if (char >= charCodeMap.a && char <= charCodeMap.f)
1839
+ return char - (charCodeMap.a - 10);
1840
+ return void 0;
1841
+ }
1842
+ function hexToBytes(hex_, opts = {}) {
1843
+ let hex = hex_;
1844
+ if (opts.size) {
1845
+ assertSize2(hex, { size: opts.size });
1846
+ hex = pad2(hex, { dir: "right", size: opts.size });
1847
+ }
1848
+ let hexString = hex.slice(2);
1849
+ if (hexString.length % 2)
1850
+ hexString = `0${hexString}`;
1851
+ const length = hexString.length / 2;
1852
+ const bytes = new Uint8Array(length);
1853
+ for (let index = 0, j = 0; index < length; index++) {
1854
+ const nibbleLeft = charCodeToBase16(hexString.charCodeAt(j++));
1855
+ const nibbleRight = charCodeToBase16(hexString.charCodeAt(j++));
1856
+ if (nibbleLeft === void 0 || nibbleRight === void 0) {
1857
+ throw new BaseError3(`Invalid byte sequence ("${hexString[j - 2]}${hexString[j - 1]}" in "${hexString}").`);
1858
+ }
1859
+ bytes[index] = nibbleLeft * 16 + nibbleRight;
1860
+ }
1861
+ return bytes;
1862
+ }
1863
+ function numberToBytes(value, opts) {
1864
+ const hex = numberToHex(value, opts);
1865
+ return hexToBytes(hex);
1866
+ }
1867
+ function stringToBytes(value, opts = {}) {
1868
+ const bytes = encoder2.encode(value);
1869
+ if (typeof opts.size === "number") {
1870
+ assertSize2(bytes, { size: opts.size });
1871
+ return pad2(bytes, { dir: "right", size: opts.size });
1872
+ }
1873
+ return bytes;
1874
+ }
1875
+
1876
+ // node_modules/@noble/hashes/esm/sha3.js
1877
+ var _0n = BigInt(0);
1878
+ var _1n = BigInt(1);
1879
+ var _2n = BigInt(2);
1880
+ var _7n = BigInt(7);
1881
+ var _256n = BigInt(256);
1882
+ var _0x71n = BigInt(113);
1883
+ var SHA3_PI = [];
1884
+ var SHA3_ROTL = [];
1885
+ var _SHA3_IOTA = [];
1886
+ for (let round = 0, R = _1n, x = 1, y = 0; round < 24; round++) {
1887
+ [x, y] = [y, (2 * x + 3 * y) % 5];
1888
+ SHA3_PI.push(2 * (5 * y + x));
1889
+ SHA3_ROTL.push((round + 1) * (round + 2) / 2 % 64);
1890
+ let t = _0n;
1891
+ for (let j = 0; j < 7; j++) {
1892
+ R = (R << _1n ^ (R >> _7n) * _0x71n) % _256n;
1893
+ if (R & _2n)
1894
+ t ^= _1n << (_1n << /* @__PURE__ */ BigInt(j)) - _1n;
1895
+ }
1896
+ _SHA3_IOTA.push(t);
1897
+ }
1898
+ var IOTAS = split(_SHA3_IOTA, true);
1899
+ var SHA3_IOTA_H = IOTAS[0];
1900
+ var SHA3_IOTA_L = IOTAS[1];
1901
+ var rotlH = (h, l, s) => s > 32 ? rotlBH(h, l, s) : rotlSH(h, l, s);
1902
+ var rotlL = (h, l, s) => s > 32 ? rotlBL(h, l, s) : rotlSL(h, l, s);
1903
+ function keccakP(s, rounds = 24) {
1904
+ const B = new Uint32Array(5 * 2);
1905
+ for (let round = 24 - rounds; round < 24; round++) {
1906
+ for (let x = 0; x < 10; x++)
1907
+ B[x] = s[x] ^ s[x + 10] ^ s[x + 20] ^ s[x + 30] ^ s[x + 40];
1908
+ for (let x = 0; x < 10; x += 2) {
1909
+ const idx1 = (x + 8) % 10;
1910
+ const idx0 = (x + 2) % 10;
1911
+ const B0 = B[idx0];
1912
+ const B1 = B[idx0 + 1];
1913
+ const Th = rotlH(B0, B1, 1) ^ B[idx1];
1914
+ const Tl = rotlL(B0, B1, 1) ^ B[idx1 + 1];
1915
+ for (let y = 0; y < 50; y += 10) {
1916
+ s[x + y] ^= Th;
1917
+ s[x + y + 1] ^= Tl;
1918
+ }
1919
+ }
1920
+ let curH = s[2];
1921
+ let curL = s[3];
1922
+ for (let t = 0; t < 24; t++) {
1923
+ const shift = SHA3_ROTL[t];
1924
+ const Th = rotlH(curH, curL, shift);
1925
+ const Tl = rotlL(curH, curL, shift);
1926
+ const PI = SHA3_PI[t];
1927
+ curH = s[PI];
1928
+ curL = s[PI + 1];
1929
+ s[PI] = Th;
1930
+ s[PI + 1] = Tl;
1931
+ }
1932
+ for (let y = 0; y < 50; y += 10) {
1933
+ for (let x = 0; x < 10; x++)
1934
+ B[x] = s[y + x];
1935
+ for (let x = 0; x < 10; x++)
1936
+ s[y + x] ^= ~B[(x + 2) % 10] & B[(x + 4) % 10];
1937
+ }
1938
+ s[0] ^= SHA3_IOTA_H[round];
1939
+ s[1] ^= SHA3_IOTA_L[round];
1940
+ }
1941
+ clean(B);
1942
+ }
1943
+ var Keccak = class _Keccak extends Hash {
1944
+ // NOTE: we accept arguments in bytes instead of bits here.
1945
+ constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) {
1946
+ super();
1947
+ this.pos = 0;
1948
+ this.posOut = 0;
1949
+ this.finished = false;
1950
+ this.destroyed = false;
1951
+ this.enableXOF = false;
1952
+ this.blockLen = blockLen;
1953
+ this.suffix = suffix;
1954
+ this.outputLen = outputLen;
1955
+ this.enableXOF = enableXOF;
1956
+ this.rounds = rounds;
1957
+ anumber(outputLen);
1958
+ if (!(0 < blockLen && blockLen < 200))
1959
+ throw new Error("only keccak-f1600 function is supported");
1960
+ this.state = new Uint8Array(200);
1961
+ this.state32 = u32(this.state);
1962
+ }
1963
+ clone() {
1964
+ return this._cloneInto();
1965
+ }
1966
+ keccak() {
1967
+ swap32IfBE(this.state32);
1968
+ keccakP(this.state32, this.rounds);
1969
+ swap32IfBE(this.state32);
1970
+ this.posOut = 0;
1971
+ this.pos = 0;
1972
+ }
1973
+ update(data) {
1974
+ aexists(this);
1975
+ data = toBytes(data);
1976
+ abytes(data);
1977
+ const { blockLen, state } = this;
1978
+ const len = data.length;
1979
+ for (let pos = 0; pos < len; ) {
1980
+ const take = Math.min(blockLen - this.pos, len - pos);
1981
+ for (let i = 0; i < take; i++)
1982
+ state[this.pos++] ^= data[pos++];
1983
+ if (this.pos === blockLen)
1984
+ this.keccak();
1985
+ }
1986
+ return this;
1987
+ }
1988
+ finish() {
1989
+ if (this.finished)
1990
+ return;
1991
+ this.finished = true;
1992
+ const { state, suffix, pos, blockLen } = this;
1993
+ state[pos] ^= suffix;
1994
+ if ((suffix & 128) !== 0 && pos === blockLen - 1)
1995
+ this.keccak();
1996
+ state[blockLen - 1] ^= 128;
1997
+ this.keccak();
1998
+ }
1999
+ writeInto(out) {
2000
+ aexists(this, false);
2001
+ abytes(out);
2002
+ this.finish();
2003
+ const bufferOut = this.state;
2004
+ const { blockLen } = this;
2005
+ for (let pos = 0, len = out.length; pos < len; ) {
2006
+ if (this.posOut >= blockLen)
2007
+ this.keccak();
2008
+ const take = Math.min(blockLen - this.posOut, len - pos);
2009
+ out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos);
2010
+ this.posOut += take;
2011
+ pos += take;
2012
+ }
2013
+ return out;
2014
+ }
2015
+ xofInto(out) {
2016
+ if (!this.enableXOF)
2017
+ throw new Error("XOF is not possible for this instance");
2018
+ return this.writeInto(out);
2019
+ }
2020
+ xof(bytes) {
2021
+ anumber(bytes);
2022
+ return this.xofInto(new Uint8Array(bytes));
2023
+ }
2024
+ digestInto(out) {
2025
+ aoutput(out, this);
2026
+ if (this.finished)
2027
+ throw new Error("digest() was already called");
2028
+ this.writeInto(out);
2029
+ this.destroy();
2030
+ return out;
2031
+ }
2032
+ digest() {
2033
+ return this.digestInto(new Uint8Array(this.outputLen));
2034
+ }
2035
+ destroy() {
2036
+ this.destroyed = true;
2037
+ clean(this.state);
2038
+ }
2039
+ _cloneInto(to) {
2040
+ const { blockLen, suffix, outputLen, rounds, enableXOF } = this;
2041
+ to || (to = new _Keccak(blockLen, suffix, outputLen, enableXOF, rounds));
2042
+ to.state32.set(this.state32);
2043
+ to.pos = this.pos;
2044
+ to.posOut = this.posOut;
2045
+ to.finished = this.finished;
2046
+ to.rounds = rounds;
2047
+ to.suffix = suffix;
2048
+ to.outputLen = outputLen;
2049
+ to.enableXOF = enableXOF;
2050
+ to.destroyed = this.destroyed;
2051
+ return to;
2052
+ }
2053
+ };
2054
+ var gen = (suffix, blockLen, outputLen) => createHasher(() => new Keccak(blockLen, suffix, outputLen));
2055
+ var keccak_256 = /* @__PURE__ */ (() => gen(1, 136, 256 / 8))();
2056
+
2057
+ // node_modules/viem/_esm/utils/hash/keccak256.js
2058
+ function keccak256(value, to_) {
2059
+ const to = to_ || "hex";
2060
+ const bytes = keccak_256(isHex(value, { strict: false }) ? toBytes2(value) : value);
2061
+ if (to === "bytes")
2062
+ return bytes;
2063
+ return toHex(bytes);
2064
+ }
2065
+
2066
+ // node_modules/viem/_esm/utils/hash/hashSignature.js
2067
+ var hash = (value) => keccak256(toBytes2(value));
2068
+ function hashSignature(sig) {
2069
+ return hash(sig);
2070
+ }
2071
+
2072
+ // node_modules/viem/_esm/utils/hash/normalizeSignature.js
2073
+ function normalizeSignature(signature) {
2074
+ let active = true;
2075
+ let current = "";
2076
+ let level = 0;
2077
+ let result = "";
2078
+ let valid = false;
2079
+ for (let i = 0; i < signature.length; i++) {
2080
+ const char = signature[i];
2081
+ if (["(", ")", ","].includes(char))
2082
+ active = true;
2083
+ if (char === "(")
2084
+ level++;
2085
+ if (char === ")")
2086
+ level--;
2087
+ if (!active)
2088
+ continue;
2089
+ if (level === 0) {
2090
+ if (char === " " && ["event", "function", ""].includes(result))
2091
+ result = "";
2092
+ else {
2093
+ result += char;
2094
+ if (char === ")") {
2095
+ valid = true;
2096
+ break;
2097
+ }
2098
+ }
2099
+ continue;
2100
+ }
2101
+ if (char === " ") {
2102
+ if (signature[i - 1] !== "," && current !== "," && current !== ",(") {
2103
+ current = "";
2104
+ active = false;
2105
+ }
2106
+ continue;
2107
+ }
2108
+ result += char;
2109
+ current += char;
2110
+ }
2111
+ if (!valid)
2112
+ throw new BaseError3("Unable to normalize signature.");
2113
+ return result;
2114
+ }
2115
+
2116
+ // node_modules/viem/_esm/utils/hash/toSignature.js
2117
+ var toSignature = (def) => {
2118
+ const def_ = (() => {
2119
+ if (typeof def === "string")
2120
+ return def;
2121
+ return formatAbiItem(def);
2122
+ })();
2123
+ return normalizeSignature(def_);
2124
+ };
2125
+
2126
+ // node_modules/viem/_esm/utils/hash/toSignatureHash.js
2127
+ function toSignatureHash(fn) {
2128
+ return hashSignature(toSignature(fn));
2129
+ }
2130
+
2131
+ // node_modules/viem/_esm/utils/hash/toFunctionSelector.js
2132
+ var toFunctionSelector = (fn) => slice(toSignatureHash(fn), 0, 4);
2133
+
2134
+ // node_modules/viem/_esm/errors/address.js
2135
+ var InvalidAddressError = class extends BaseError3 {
2136
+ constructor({ address }) {
2137
+ super(`Address "${address}" is invalid.`, {
2138
+ metaMessages: [
2139
+ "- Address must be a hex value of 20 bytes (40 hex characters).",
2140
+ "- Address must match its checksum counterpart."
2141
+ ],
2142
+ name: "InvalidAddressError"
2143
+ });
2144
+ }
2145
+ };
2146
+
2147
+ // node_modules/viem/_esm/utils/lru.js
2148
+ var LruMap = class extends Map {
2149
+ constructor(size3) {
2150
+ super();
2151
+ Object.defineProperty(this, "maxSize", {
2152
+ enumerable: true,
2153
+ configurable: true,
2154
+ writable: true,
2155
+ value: void 0
2156
+ });
2157
+ this.maxSize = size3;
2158
+ }
2159
+ get(key) {
2160
+ const value = super.get(key);
2161
+ if (super.has(key) && value !== void 0) {
2162
+ this.delete(key);
2163
+ super.set(key, value);
2164
+ }
2165
+ return value;
2166
+ }
2167
+ set(key, value) {
2168
+ super.set(key, value);
2169
+ if (this.maxSize && this.size > this.maxSize) {
2170
+ const firstKey = this.keys().next().value;
2171
+ if (firstKey)
2172
+ this.delete(firstKey);
2173
+ }
2174
+ return this;
2175
+ }
2176
+ };
2177
+
2178
+ // node_modules/viem/_esm/utils/address/isAddress.js
2179
+ var addressRegex = /^0x[a-fA-F0-9]{40}$/;
2180
+ var isAddressCache = /* @__PURE__ */ new LruMap(8192);
2181
+ function isAddress(address, options) {
2182
+ const { strict = true } = options ?? {};
2183
+ const cacheKey = `${address}.${strict}`;
2184
+ if (isAddressCache.has(cacheKey))
2185
+ return isAddressCache.get(cacheKey);
2186
+ const result = (() => {
2187
+ if (!addressRegex.test(address))
2188
+ return false;
2189
+ if (address.toLowerCase() === address)
2190
+ return true;
2191
+ if (strict)
2192
+ return checksumAddress(address) === address;
2193
+ return true;
2194
+ })();
2195
+ isAddressCache.set(cacheKey, result);
2196
+ return result;
2197
+ }
2198
+
2199
+ // node_modules/viem/_esm/utils/address/getAddress.js
2200
+ var checksumAddressCache = /* @__PURE__ */ new LruMap(8192);
2201
+ function checksumAddress(address_, chainId) {
2202
+ if (checksumAddressCache.has(`${address_}.${chainId}`))
2203
+ return checksumAddressCache.get(`${address_}.${chainId}`);
2204
+ const hexAddress = chainId ? `${chainId}${address_.toLowerCase()}` : address_.substring(2).toLowerCase();
2205
+ const hash2 = keccak256(stringToBytes(hexAddress), "bytes");
2206
+ const address = (chainId ? hexAddress.substring(`${chainId}0x`.length) : hexAddress).split("");
2207
+ for (let i = 0; i < 40; i += 2) {
2208
+ if (hash2[i >> 1] >> 4 >= 8 && address[i]) {
2209
+ address[i] = address[i].toUpperCase();
2210
+ }
2211
+ if ((hash2[i >> 1] & 15) >= 8 && address[i + 1]) {
2212
+ address[i + 1] = address[i + 1].toUpperCase();
2213
+ }
2214
+ }
2215
+ const result = `0x${address.join("")}`;
2216
+ checksumAddressCache.set(`${address_}.${chainId}`, result);
2217
+ return result;
2218
+ }
2219
+
2220
+ // node_modules/viem/_esm/errors/cursor.js
2221
+ var NegativeOffsetError = class extends BaseError3 {
2222
+ constructor({ offset }) {
2223
+ super(`Offset \`${offset}\` cannot be negative.`, {
2224
+ name: "NegativeOffsetError"
2225
+ });
2226
+ }
2227
+ };
2228
+ var PositionOutOfBoundsError = class extends BaseError3 {
2229
+ constructor({ length, position }) {
2230
+ super(`Position \`${position}\` is out of bounds (\`0 < position < ${length}\`).`, { name: "PositionOutOfBoundsError" });
2231
+ }
2232
+ };
2233
+ var RecursiveReadLimitExceededError = class extends BaseError3 {
2234
+ constructor({ count, limit }) {
2235
+ super(`Recursive read limit of \`${limit}\` exceeded (recursive read count: \`${count}\`).`, { name: "RecursiveReadLimitExceededError" });
2236
+ }
2237
+ };
2238
+
2239
+ // node_modules/viem/_esm/utils/cursor.js
2240
+ var staticCursor = {
2241
+ bytes: new Uint8Array(),
2242
+ dataView: new DataView(new ArrayBuffer(0)),
2243
+ position: 0,
2244
+ positionReadCount: /* @__PURE__ */ new Map(),
2245
+ recursiveReadCount: 0,
2246
+ recursiveReadLimit: Number.POSITIVE_INFINITY,
2247
+ assertReadLimit() {
2248
+ if (this.recursiveReadCount >= this.recursiveReadLimit)
2249
+ throw new RecursiveReadLimitExceededError({
2250
+ count: this.recursiveReadCount + 1,
2251
+ limit: this.recursiveReadLimit
2252
+ });
2253
+ },
2254
+ assertPosition(position) {
2255
+ if (position < 0 || position > this.bytes.length - 1)
2256
+ throw new PositionOutOfBoundsError({
2257
+ length: this.bytes.length,
2258
+ position
2259
+ });
2260
+ },
2261
+ decrementPosition(offset) {
2262
+ if (offset < 0)
2263
+ throw new NegativeOffsetError({ offset });
2264
+ const position = this.position - offset;
2265
+ this.assertPosition(position);
2266
+ this.position = position;
2267
+ },
2268
+ getReadCount(position) {
2269
+ return this.positionReadCount.get(position || this.position) || 0;
2270
+ },
2271
+ incrementPosition(offset) {
2272
+ if (offset < 0)
2273
+ throw new NegativeOffsetError({ offset });
2274
+ const position = this.position + offset;
2275
+ this.assertPosition(position);
2276
+ this.position = position;
2277
+ },
2278
+ inspectByte(position_) {
2279
+ const position = position_ ?? this.position;
2280
+ this.assertPosition(position);
2281
+ return this.bytes[position];
2282
+ },
2283
+ inspectBytes(length, position_) {
2284
+ const position = position_ ?? this.position;
2285
+ this.assertPosition(position + length - 1);
2286
+ return this.bytes.subarray(position, position + length);
2287
+ },
2288
+ inspectUint8(position_) {
2289
+ const position = position_ ?? this.position;
2290
+ this.assertPosition(position);
2291
+ return this.bytes[position];
2292
+ },
2293
+ inspectUint16(position_) {
2294
+ const position = position_ ?? this.position;
2295
+ this.assertPosition(position + 1);
2296
+ return this.dataView.getUint16(position);
2297
+ },
2298
+ inspectUint24(position_) {
2299
+ const position = position_ ?? this.position;
2300
+ this.assertPosition(position + 2);
2301
+ return (this.dataView.getUint16(position) << 8) + this.dataView.getUint8(position + 2);
2302
+ },
2303
+ inspectUint32(position_) {
2304
+ const position = position_ ?? this.position;
2305
+ this.assertPosition(position + 3);
2306
+ return this.dataView.getUint32(position);
2307
+ },
2308
+ pushByte(byte) {
2309
+ this.assertPosition(this.position);
2310
+ this.bytes[this.position] = byte;
2311
+ this.position++;
2312
+ },
2313
+ pushBytes(bytes) {
2314
+ this.assertPosition(this.position + bytes.length - 1);
2315
+ this.bytes.set(bytes, this.position);
2316
+ this.position += bytes.length;
2317
+ },
2318
+ pushUint8(value) {
2319
+ this.assertPosition(this.position);
2320
+ this.bytes[this.position] = value;
2321
+ this.position++;
2322
+ },
2323
+ pushUint16(value) {
2324
+ this.assertPosition(this.position + 1);
2325
+ this.dataView.setUint16(this.position, value);
2326
+ this.position += 2;
2327
+ },
2328
+ pushUint24(value) {
2329
+ this.assertPosition(this.position + 2);
2330
+ this.dataView.setUint16(this.position, value >> 8);
2331
+ this.dataView.setUint8(this.position + 2, value & ~4294967040);
2332
+ this.position += 3;
2333
+ },
2334
+ pushUint32(value) {
2335
+ this.assertPosition(this.position + 3);
2336
+ this.dataView.setUint32(this.position, value);
2337
+ this.position += 4;
2338
+ },
2339
+ readByte() {
2340
+ this.assertReadLimit();
2341
+ this._touch();
2342
+ const value = this.inspectByte();
2343
+ this.position++;
2344
+ return value;
2345
+ },
2346
+ readBytes(length, size3) {
2347
+ this.assertReadLimit();
2348
+ this._touch();
2349
+ const value = this.inspectBytes(length);
2350
+ this.position += size3 ?? length;
2351
+ return value;
2352
+ },
2353
+ readUint8() {
2354
+ this.assertReadLimit();
2355
+ this._touch();
2356
+ const value = this.inspectUint8();
2357
+ this.position += 1;
2358
+ return value;
2359
+ },
2360
+ readUint16() {
2361
+ this.assertReadLimit();
2362
+ this._touch();
2363
+ const value = this.inspectUint16();
2364
+ this.position += 2;
2365
+ return value;
2366
+ },
2367
+ readUint24() {
2368
+ this.assertReadLimit();
2369
+ this._touch();
2370
+ const value = this.inspectUint24();
2371
+ this.position += 3;
2372
+ return value;
2373
+ },
2374
+ readUint32() {
2375
+ this.assertReadLimit();
2376
+ this._touch();
2377
+ const value = this.inspectUint32();
2378
+ this.position += 4;
2379
+ return value;
2380
+ },
2381
+ get remaining() {
2382
+ return this.bytes.length - this.position;
2383
+ },
2384
+ setPosition(position) {
2385
+ const oldPosition = this.position;
2386
+ this.assertPosition(position);
2387
+ this.position = position;
2388
+ return () => this.position = oldPosition;
2389
+ },
2390
+ _touch() {
2391
+ if (this.recursiveReadLimit === Number.POSITIVE_INFINITY)
2392
+ return;
2393
+ const count = this.getReadCount();
2394
+ this.positionReadCount.set(this.position, count + 1);
2395
+ if (count > 0)
2396
+ this.recursiveReadCount++;
2397
+ }
2398
+ };
2399
+ function createCursor(bytes, { recursiveReadLimit = 8192 } = {}) {
2400
+ const cursor = Object.create(staticCursor);
2401
+ cursor.bytes = bytes;
2402
+ cursor.dataView = new DataView(bytes.buffer ?? bytes, bytes.byteOffset, bytes.byteLength);
2403
+ cursor.positionReadCount = /* @__PURE__ */ new Map();
2404
+ cursor.recursiveReadLimit = recursiveReadLimit;
2405
+ return cursor;
2406
+ }
2407
+
2408
+ // node_modules/viem/_esm/utils/encoding/fromBytes.js
2409
+ function bytesToBigInt(bytes, opts = {}) {
2410
+ if (typeof opts.size !== "undefined")
2411
+ assertSize2(bytes, { size: opts.size });
2412
+ const hex = bytesToHex(bytes, opts);
2413
+ return hexToBigInt(hex, opts);
2414
+ }
2415
+ function bytesToBool(bytes_, opts = {}) {
2416
+ let bytes = bytes_;
2417
+ if (typeof opts.size !== "undefined") {
2418
+ assertSize2(bytes, { size: opts.size });
2419
+ bytes = trim2(bytes);
2420
+ }
2421
+ if (bytes.length > 1 || bytes[0] > 1)
2422
+ throw new InvalidBytesBooleanError(bytes);
2423
+ return Boolean(bytes[0]);
2424
+ }
2425
+ function bytesToNumber(bytes, opts = {}) {
2426
+ if (typeof opts.size !== "undefined")
2427
+ assertSize2(bytes, { size: opts.size });
2428
+ const hex = bytesToHex(bytes, opts);
2429
+ return hexToNumber(hex, opts);
2430
+ }
2431
+ function bytesToString(bytes_, opts = {}) {
2432
+ let bytes = bytes_;
2433
+ if (typeof opts.size !== "undefined") {
2434
+ assertSize2(bytes, { size: opts.size });
2435
+ bytes = trim2(bytes, { dir: "right" });
2436
+ }
2437
+ return new TextDecoder().decode(bytes);
2438
+ }
2439
+
2440
+ // node_modules/viem/_esm/utils/data/concat.js
2441
+ function concat(values) {
2442
+ if (typeof values[0] === "string")
2443
+ return concatHex(values);
2444
+ return concatBytes(values);
2445
+ }
2446
+ function concatBytes(values) {
2447
+ let length = 0;
2448
+ for (const arr of values) {
2449
+ length += arr.length;
2450
+ }
2451
+ const result = new Uint8Array(length);
2452
+ let offset = 0;
2453
+ for (const arr of values) {
2454
+ result.set(arr, offset);
2455
+ offset += arr.length;
2456
+ }
2457
+ return result;
2458
+ }
2459
+ function concatHex(values) {
2460
+ return `0x${values.reduce((acc, x) => acc + x.replace("0x", ""), "")}`;
2461
+ }
2462
+
2463
+ // node_modules/viem/_esm/utils/regex.js
2464
+ var integerRegex2 = /^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;
2465
+
2466
+ // node_modules/viem/_esm/utils/abi/encodeAbiParameters.js
2467
+ function encodeAbiParameters(params, values) {
2468
+ if (params.length !== values.length)
2469
+ throw new AbiEncodingLengthMismatchError({
2470
+ expectedLength: params.length,
2471
+ givenLength: values.length
2472
+ });
2473
+ const preparedParams = prepareParams({
2474
+ params,
2475
+ values
2476
+ });
2477
+ const data = encodeParams(preparedParams);
2478
+ if (data.length === 0)
2479
+ return "0x";
2480
+ return data;
2481
+ }
2482
+ function prepareParams({ params, values }) {
2483
+ const preparedParams = [];
2484
+ for (let i = 0; i < params.length; i++) {
2485
+ preparedParams.push(prepareParam({ param: params[i], value: values[i] }));
2486
+ }
2487
+ return preparedParams;
2488
+ }
2489
+ function prepareParam({ param, value }) {
2490
+ const arrayComponents = getArrayComponents(param.type);
2491
+ if (arrayComponents) {
2492
+ const [length, type] = arrayComponents;
2493
+ return encodeArray(value, { length, param: { ...param, type } });
2494
+ }
2495
+ if (param.type === "tuple") {
2496
+ return encodeTuple(value, {
2497
+ param
2498
+ });
2499
+ }
2500
+ if (param.type === "address") {
2501
+ return encodeAddress(value);
2502
+ }
2503
+ if (param.type === "bool") {
2504
+ return encodeBool(value);
2505
+ }
2506
+ if (param.type.startsWith("uint") || param.type.startsWith("int")) {
2507
+ const signed = param.type.startsWith("int");
2508
+ const [, , size3 = "256"] = integerRegex2.exec(param.type) ?? [];
2509
+ return encodeNumber(value, {
2510
+ signed,
2511
+ size: Number(size3)
2512
+ });
2513
+ }
2514
+ if (param.type.startsWith("bytes")) {
2515
+ return encodeBytes(value, { param });
2516
+ }
2517
+ if (param.type === "string") {
2518
+ return encodeString(value);
2519
+ }
2520
+ throw new InvalidAbiEncodingTypeError(param.type, {
2521
+ docsPath: "/docs/contract/encodeAbiParameters"
2522
+ });
2523
+ }
2524
+ function encodeParams(preparedParams) {
2525
+ let staticSize = 0;
2526
+ for (let i = 0; i < preparedParams.length; i++) {
2527
+ const { dynamic, encoded } = preparedParams[i];
2528
+ if (dynamic)
2529
+ staticSize += 32;
2530
+ else
2531
+ staticSize += size2(encoded);
2532
+ }
2533
+ const staticParams = [];
2534
+ const dynamicParams = [];
2535
+ let dynamicSize = 0;
2536
+ for (let i = 0; i < preparedParams.length; i++) {
2537
+ const { dynamic, encoded } = preparedParams[i];
2538
+ if (dynamic) {
2539
+ staticParams.push(numberToHex(staticSize + dynamicSize, { size: 32 }));
2540
+ dynamicParams.push(encoded);
2541
+ dynamicSize += size2(encoded);
2542
+ } else {
2543
+ staticParams.push(encoded);
2544
+ }
2545
+ }
2546
+ return concat([...staticParams, ...dynamicParams]);
2547
+ }
2548
+ function encodeAddress(value) {
2549
+ if (!isAddress(value))
2550
+ throw new InvalidAddressError({ address: value });
2551
+ return { dynamic: false, encoded: padHex(value.toLowerCase()) };
2552
+ }
2553
+ function encodeArray(value, { length, param }) {
2554
+ const dynamic = length === null;
2555
+ if (!Array.isArray(value))
2556
+ throw new InvalidArrayError(value);
2557
+ if (!dynamic && value.length !== length)
2558
+ throw new AbiEncodingArrayLengthMismatchError({
2559
+ expectedLength: length,
2560
+ givenLength: value.length,
2561
+ type: `${param.type}[${length}]`
2562
+ });
2563
+ let dynamicChild = false;
2564
+ const preparedParams = [];
2565
+ for (let i = 0; i < value.length; i++) {
2566
+ const preparedParam = prepareParam({ param, value: value[i] });
2567
+ if (preparedParam.dynamic)
2568
+ dynamicChild = true;
2569
+ preparedParams.push(preparedParam);
2570
+ }
2571
+ if (dynamic || dynamicChild) {
2572
+ const data = encodeParams(preparedParams);
2573
+ if (dynamic) {
2574
+ const length2 = numberToHex(preparedParams.length, { size: 32 });
2575
+ return {
2576
+ dynamic: true,
2577
+ encoded: preparedParams.length > 0 ? concat([length2, data]) : length2
2578
+ };
2579
+ }
2580
+ if (dynamicChild)
2581
+ return { dynamic: true, encoded: data };
2582
+ }
2583
+ return {
2584
+ dynamic: false,
2585
+ encoded: concat(preparedParams.map(({ encoded }) => encoded))
2586
+ };
2587
+ }
2588
+ function encodeBytes(value, { param }) {
2589
+ const [, paramSize] = param.type.split("bytes");
2590
+ const bytesSize = size2(value);
2591
+ if (!paramSize) {
2592
+ let value_ = value;
2593
+ if (bytesSize % 32 !== 0)
2594
+ value_ = padHex(value_, {
2595
+ dir: "right",
2596
+ size: Math.ceil((value.length - 2) / 2 / 32) * 32
2597
+ });
2598
+ return {
2599
+ dynamic: true,
2600
+ encoded: concat([padHex(numberToHex(bytesSize, { size: 32 })), value_])
2601
+ };
2602
+ }
2603
+ if (bytesSize !== Number.parseInt(paramSize, 10))
2604
+ throw new AbiEncodingBytesSizeMismatchError({
2605
+ expectedSize: Number.parseInt(paramSize, 10),
2606
+ value
2607
+ });
2608
+ return { dynamic: false, encoded: padHex(value, { dir: "right" }) };
2609
+ }
2610
+ function encodeBool(value) {
2611
+ if (typeof value !== "boolean")
2612
+ throw new BaseError3(`Invalid boolean value: "${value}" (type: ${typeof value}). Expected: \`true\` or \`false\`.`);
2613
+ return { dynamic: false, encoded: padHex(boolToHex(value)) };
2614
+ }
2615
+ function encodeNumber(value, { signed, size: size3 = 256 }) {
2616
+ if (typeof size3 === "number") {
2617
+ const max = 2n ** (BigInt(size3) - (signed ? 1n : 0n)) - 1n;
2618
+ const min = signed ? -max - 1n : 0n;
2619
+ if (value > max || value < min)
2620
+ throw new IntegerOutOfRangeError2({
2621
+ max: max.toString(),
2622
+ min: min.toString(),
2623
+ signed,
2624
+ size: size3 / 8,
2625
+ value: value.toString()
2626
+ });
2627
+ }
2628
+ return {
2629
+ dynamic: false,
2630
+ encoded: numberToHex(value, {
2631
+ size: 32,
2632
+ signed
2633
+ })
2634
+ };
2635
+ }
2636
+ function encodeString(value) {
2637
+ const hexValue = stringToHex(value);
2638
+ const partsLength = Math.ceil(size2(hexValue) / 32);
2639
+ const parts = [];
2640
+ for (let i = 0; i < partsLength; i++) {
2641
+ parts.push(padHex(slice(hexValue, i * 32, (i + 1) * 32), {
2642
+ dir: "right"
2643
+ }));
2644
+ }
2645
+ return {
2646
+ dynamic: true,
2647
+ encoded: concat([
2648
+ padHex(numberToHex(size2(hexValue), { size: 32 })),
2649
+ ...parts
2650
+ ])
2651
+ };
2652
+ }
2653
+ function encodeTuple(value, { param }) {
2654
+ let dynamic = false;
2655
+ const preparedParams = [];
2656
+ for (let i = 0; i < param.components.length; i++) {
2657
+ const param_ = param.components[i];
2658
+ const index = Array.isArray(value) ? i : param_.name;
2659
+ const preparedParam = prepareParam({
2660
+ param: param_,
2661
+ value: value[index]
2662
+ });
2663
+ preparedParams.push(preparedParam);
2664
+ if (preparedParam.dynamic)
2665
+ dynamic = true;
2666
+ }
2667
+ return {
2668
+ dynamic,
2669
+ encoded: dynamic ? encodeParams(preparedParams) : concat(preparedParams.map(({ encoded }) => encoded))
2670
+ };
2671
+ }
2672
+ function getArrayComponents(type) {
2673
+ const matches = type.match(/^(.*)\[(\d+)?\]$/);
2674
+ return matches ? (
2675
+ // Return `null` if the array is dynamic.
2676
+ [matches[2] ? Number(matches[2]) : null, matches[1]]
2677
+ ) : void 0;
2678
+ }
2679
+
2680
+ // node_modules/viem/_esm/utils/abi/decodeAbiParameters.js
2681
+ function decodeAbiParameters(params, data) {
2682
+ const bytes = typeof data === "string" ? hexToBytes(data) : data;
2683
+ const cursor = createCursor(bytes);
2684
+ if (size2(bytes) === 0 && params.length > 0)
2685
+ throw new AbiDecodingZeroDataError();
2686
+ if (size2(data) && size2(data) < 32)
2687
+ throw new AbiDecodingDataSizeTooSmallError({
2688
+ data: typeof data === "string" ? data : bytesToHex(data),
2689
+ params,
2690
+ size: size2(data)
2691
+ });
2692
+ let consumed = 0;
2693
+ const values = [];
2694
+ for (let i = 0; i < params.length; ++i) {
2695
+ const param = params[i];
2696
+ cursor.setPosition(consumed);
2697
+ const [data2, consumed_] = decodeParameter(cursor, param, {
2698
+ staticPosition: 0
2699
+ });
2700
+ consumed += consumed_;
2701
+ values.push(data2);
2702
+ }
2703
+ return values;
2704
+ }
2705
+ function decodeParameter(cursor, param, { staticPosition }) {
2706
+ const arrayComponents = getArrayComponents(param.type);
2707
+ if (arrayComponents) {
2708
+ const [length, type] = arrayComponents;
2709
+ return decodeArray(cursor, { ...param, type }, { length, staticPosition });
2710
+ }
2711
+ if (param.type === "tuple")
2712
+ return decodeTuple(cursor, param, { staticPosition });
2713
+ if (param.type === "address")
2714
+ return decodeAddress(cursor);
2715
+ if (param.type === "bool")
2716
+ return decodeBool(cursor);
2717
+ if (param.type.startsWith("bytes"))
2718
+ return decodeBytes(cursor, param, { staticPosition });
2719
+ if (param.type.startsWith("uint") || param.type.startsWith("int"))
2720
+ return decodeNumber(cursor, param);
2721
+ if (param.type === "string")
2722
+ return decodeString(cursor, { staticPosition });
2723
+ throw new InvalidAbiDecodingTypeError(param.type, {
2724
+ docsPath: "/docs/contract/decodeAbiParameters"
2725
+ });
2726
+ }
2727
+ var sizeOfLength = 32;
2728
+ var sizeOfOffset = 32;
2729
+ function decodeAddress(cursor) {
2730
+ const value = cursor.readBytes(32);
2731
+ return [checksumAddress(bytesToHex(sliceBytes(value, -20))), 32];
2732
+ }
2733
+ function decodeArray(cursor, param, { length, staticPosition }) {
2734
+ if (!length) {
2735
+ const offset = bytesToNumber(cursor.readBytes(sizeOfOffset));
2736
+ const start = staticPosition + offset;
2737
+ const startOfData = start + sizeOfLength;
2738
+ cursor.setPosition(start);
2739
+ const length2 = bytesToNumber(cursor.readBytes(sizeOfLength));
2740
+ const dynamicChild = hasDynamicChild(param);
2741
+ let consumed2 = 0;
2742
+ const value2 = [];
2743
+ for (let i = 0; i < length2; ++i) {
2744
+ cursor.setPosition(startOfData + (dynamicChild ? i * 32 : consumed2));
2745
+ const [data, consumed_] = decodeParameter(cursor, param, {
2746
+ staticPosition: startOfData
2747
+ });
2748
+ consumed2 += consumed_;
2749
+ value2.push(data);
2750
+ }
2751
+ cursor.setPosition(staticPosition + 32);
2752
+ return [value2, 32];
2753
+ }
2754
+ if (hasDynamicChild(param)) {
2755
+ const offset = bytesToNumber(cursor.readBytes(sizeOfOffset));
2756
+ const start = staticPosition + offset;
2757
+ const value2 = [];
2758
+ for (let i = 0; i < length; ++i) {
2759
+ cursor.setPosition(start + i * 32);
2760
+ const [data] = decodeParameter(cursor, param, {
2761
+ staticPosition: start
2762
+ });
2763
+ value2.push(data);
2764
+ }
2765
+ cursor.setPosition(staticPosition + 32);
2766
+ return [value2, 32];
2767
+ }
2768
+ let consumed = 0;
2769
+ const value = [];
2770
+ for (let i = 0; i < length; ++i) {
2771
+ const [data, consumed_] = decodeParameter(cursor, param, {
2772
+ staticPosition: staticPosition + consumed
2773
+ });
2774
+ consumed += consumed_;
2775
+ value.push(data);
2776
+ }
2777
+ return [value, consumed];
2778
+ }
2779
+ function decodeBool(cursor) {
2780
+ return [bytesToBool(cursor.readBytes(32), { size: 32 }), 32];
2781
+ }
2782
+ function decodeBytes(cursor, param, { staticPosition }) {
2783
+ const [_, size3] = param.type.split("bytes");
2784
+ if (!size3) {
2785
+ const offset = bytesToNumber(cursor.readBytes(32));
2786
+ cursor.setPosition(staticPosition + offset);
2787
+ const length = bytesToNumber(cursor.readBytes(32));
2788
+ if (length === 0) {
2789
+ cursor.setPosition(staticPosition + 32);
2790
+ return ["0x", 32];
2791
+ }
2792
+ const data = cursor.readBytes(length);
2793
+ cursor.setPosition(staticPosition + 32);
2794
+ return [bytesToHex(data), 32];
2795
+ }
2796
+ const value = bytesToHex(cursor.readBytes(Number.parseInt(size3, 10), 32));
2797
+ return [value, 32];
2798
+ }
2799
+ function decodeNumber(cursor, param) {
2800
+ const signed = param.type.startsWith("int");
2801
+ const size3 = Number.parseInt(param.type.split("int")[1] || "256", 10);
2802
+ const value = cursor.readBytes(32);
2803
+ return [
2804
+ size3 > 48 ? bytesToBigInt(value, { signed }) : bytesToNumber(value, { signed }),
2805
+ 32
2806
+ ];
2807
+ }
2808
+ function decodeTuple(cursor, param, { staticPosition }) {
2809
+ const hasUnnamedChild = param.components.length === 0 || param.components.some(({ name }) => !name);
2810
+ const value = hasUnnamedChild ? [] : {};
2811
+ let consumed = 0;
2812
+ if (hasDynamicChild(param)) {
2813
+ const offset = bytesToNumber(cursor.readBytes(sizeOfOffset));
2814
+ const start = staticPosition + offset;
2815
+ for (let i = 0; i < param.components.length; ++i) {
2816
+ const component = param.components[i];
2817
+ cursor.setPosition(start + consumed);
2818
+ const [data, consumed_] = decodeParameter(cursor, component, {
2819
+ staticPosition: start
2820
+ });
2821
+ consumed += consumed_;
2822
+ value[hasUnnamedChild ? i : component?.name] = data;
2823
+ }
2824
+ cursor.setPosition(staticPosition + 32);
2825
+ return [value, 32];
2826
+ }
2827
+ for (let i = 0; i < param.components.length; ++i) {
2828
+ const component = param.components[i];
2829
+ const [data, consumed_] = decodeParameter(cursor, component, {
2830
+ staticPosition
2831
+ });
2832
+ value[hasUnnamedChild ? i : component?.name] = data;
2833
+ consumed += consumed_;
2834
+ }
2835
+ return [value, consumed];
2836
+ }
2837
+ function decodeString(cursor, { staticPosition }) {
2838
+ const offset = bytesToNumber(cursor.readBytes(32));
2839
+ const start = staticPosition + offset;
2840
+ cursor.setPosition(start);
2841
+ const length = bytesToNumber(cursor.readBytes(32));
2842
+ if (length === 0) {
2843
+ cursor.setPosition(staticPosition + 32);
2844
+ return ["", 32];
2845
+ }
2846
+ const data = cursor.readBytes(length, 32);
2847
+ const value = bytesToString(trim2(data));
2848
+ cursor.setPosition(staticPosition + 32);
2849
+ return [value, 32];
2850
+ }
2851
+ function hasDynamicChild(param) {
2852
+ const { type } = param;
2853
+ if (type === "string")
2854
+ return true;
2855
+ if (type === "bytes")
2856
+ return true;
2857
+ if (type.endsWith("[]"))
2858
+ return true;
2859
+ if (type === "tuple")
2860
+ return param.components?.some(hasDynamicChild);
2861
+ const arrayComponents = getArrayComponents(param.type);
2862
+ if (arrayComponents && hasDynamicChild({ ...param, type: arrayComponents[1] }))
2863
+ return true;
2864
+ return false;
2865
+ }
2866
+
2867
+ // node_modules/viem/_esm/utils/abi/decodeErrorResult.js
2868
+ function decodeErrorResult(parameters) {
2869
+ const { abi, data } = parameters;
2870
+ const signature = slice(data, 0, 4);
2871
+ if (signature === "0x")
2872
+ throw new AbiDecodingZeroDataError();
2873
+ const abi_ = [...abi || [], solidityError, solidityPanic];
2874
+ const abiItem = abi_.find((x) => x.type === "error" && signature === toFunctionSelector(formatAbiItem2(x)));
2875
+ if (!abiItem)
2876
+ throw new AbiErrorSignatureNotFoundError(signature, {
2877
+ docsPath: "/docs/contract/decodeErrorResult"
2878
+ });
2879
+ return {
2880
+ abiItem,
2881
+ args: "inputs" in abiItem && abiItem.inputs && abiItem.inputs.length > 0 ? decodeAbiParameters(abiItem.inputs, slice(data, 4)) : void 0,
2882
+ errorName: abiItem.name
2883
+ };
2884
+ }
2885
+
2886
+ // node_modules/viem/_esm/utils/stringify.js
2887
+ var stringify = (value, replacer, space) => JSON.stringify(value, (key, value_) => {
2888
+ const value2 = typeof value_ === "bigint" ? value_.toString() : value_;
2889
+ return typeof replacer === "function" ? replacer(key, value2) : value2;
2890
+ }, space);
2891
+
2892
+ // node_modules/viem/_esm/utils/hash/toEventSelector.js
2893
+ var toEventSelector = toSignatureHash;
2894
+
2895
+ // node_modules/viem/_esm/utils/abi/getAbiItem.js
2896
+ function getAbiItem(parameters) {
2897
+ const { abi, args = [], name } = parameters;
2898
+ const isSelector = isHex(name, { strict: false });
2899
+ const abiItems = abi.filter((abiItem) => {
2900
+ if (isSelector) {
2901
+ if (abiItem.type === "function")
2902
+ return toFunctionSelector(abiItem) === name;
2903
+ if (abiItem.type === "event")
2904
+ return toEventSelector(abiItem) === name;
2905
+ return false;
2906
+ }
2907
+ return "name" in abiItem && abiItem.name === name;
2908
+ });
2909
+ if (abiItems.length === 0)
2910
+ return void 0;
2911
+ if (abiItems.length === 1)
2912
+ return abiItems[0];
2913
+ let matchedAbiItem;
2914
+ for (const abiItem of abiItems) {
2915
+ if (!("inputs" in abiItem))
2916
+ continue;
2917
+ if (!args || args.length === 0) {
2918
+ if (!abiItem.inputs || abiItem.inputs.length === 0)
2919
+ return abiItem;
2920
+ continue;
2921
+ }
2922
+ if (!abiItem.inputs)
2923
+ continue;
2924
+ if (abiItem.inputs.length === 0)
2925
+ continue;
2926
+ if (abiItem.inputs.length !== args.length)
2927
+ continue;
2928
+ const matched = args.every((arg, index) => {
2929
+ const abiParameter = "inputs" in abiItem && abiItem.inputs[index];
2930
+ if (!abiParameter)
2931
+ return false;
2932
+ return isArgOfType(arg, abiParameter);
2933
+ });
2934
+ if (matched) {
2935
+ if (matchedAbiItem && "inputs" in matchedAbiItem && matchedAbiItem.inputs) {
2936
+ const ambiguousTypes = getAmbiguousTypes(abiItem.inputs, matchedAbiItem.inputs, args);
2937
+ if (ambiguousTypes)
2938
+ throw new AbiItemAmbiguityError({
2939
+ abiItem,
2940
+ type: ambiguousTypes[0]
2941
+ }, {
2942
+ abiItem: matchedAbiItem,
2943
+ type: ambiguousTypes[1]
2944
+ });
2945
+ }
2946
+ matchedAbiItem = abiItem;
2947
+ }
2948
+ }
2949
+ if (matchedAbiItem)
2950
+ return matchedAbiItem;
2951
+ return abiItems[0];
2952
+ }
2953
+ function isArgOfType(arg, abiParameter) {
2954
+ const argType = typeof arg;
2955
+ const abiParameterType = abiParameter.type;
2956
+ switch (abiParameterType) {
2957
+ case "address":
2958
+ return isAddress(arg, { strict: false });
2959
+ case "bool":
2960
+ return argType === "boolean";
2961
+ case "function":
2962
+ return argType === "string";
2963
+ case "string":
2964
+ return argType === "string";
2965
+ default: {
2966
+ if (abiParameterType === "tuple" && "components" in abiParameter)
2967
+ return Object.values(abiParameter.components).every((component, index) => {
2968
+ return isArgOfType(Object.values(arg)[index], component);
2969
+ });
2970
+ if (/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/.test(abiParameterType))
2971
+ return argType === "number" || argType === "bigint";
2972
+ if (/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(abiParameterType))
2973
+ return argType === "string" || arg instanceof Uint8Array;
2974
+ if (/[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(abiParameterType)) {
2975
+ return Array.isArray(arg) && arg.every((x) => isArgOfType(x, {
2976
+ ...abiParameter,
2977
+ // Pop off `[]` or `[M]` from end of type
2978
+ type: abiParameterType.replace(/(\[[0-9]{0,}\])$/, "")
2979
+ }));
2980
+ }
2981
+ return false;
2982
+ }
2983
+ }
2984
+ }
2985
+ function getAmbiguousTypes(sourceParameters, targetParameters, args) {
2986
+ for (const parameterIndex in sourceParameters) {
2987
+ const sourceParameter = sourceParameters[parameterIndex];
2988
+ const targetParameter = targetParameters[parameterIndex];
2989
+ if (sourceParameter.type === "tuple" && targetParameter.type === "tuple" && "components" in sourceParameter && "components" in targetParameter)
2990
+ return getAmbiguousTypes(sourceParameter.components, targetParameter.components, args[parameterIndex]);
2991
+ const types = [sourceParameter.type, targetParameter.type];
2992
+ const ambiguous = (() => {
2993
+ if (types.includes("address") && types.includes("bytes20"))
2994
+ return true;
2995
+ if (types.includes("address") && types.includes("string"))
2996
+ return isAddress(args[parameterIndex], { strict: false });
2997
+ if (types.includes("address") && types.includes("bytes"))
2998
+ return isAddress(args[parameterIndex], { strict: false });
2999
+ return false;
3000
+ })();
3001
+ if (ambiguous)
3002
+ return types;
3003
+ }
3004
+ return;
3005
+ }
3006
+
3007
+ // node_modules/viem/_esm/constants/unit.js
3008
+ var etherUnits = {
3009
+ gwei: 9,
3010
+ wei: 18
3011
+ };
3012
+ var gweiUnits = {
3013
+ ether: -9,
3014
+ wei: 9
3015
+ };
3016
+
3017
+ // node_modules/viem/_esm/utils/unit/formatUnits.js
3018
+ function formatUnits(value, decimals) {
3019
+ let display = value.toString();
3020
+ const negative = display.startsWith("-");
3021
+ if (negative)
3022
+ display = display.slice(1);
3023
+ display = display.padStart(decimals, "0");
3024
+ let [integer, fraction] = [
3025
+ display.slice(0, display.length - decimals),
3026
+ display.slice(display.length - decimals)
3027
+ ];
3028
+ fraction = fraction.replace(/(0+)$/, "");
3029
+ return `${negative ? "-" : ""}${integer || "0"}${fraction ? `.${fraction}` : ""}`;
3030
+ }
3031
+
3032
+ // node_modules/viem/_esm/utils/unit/formatEther.js
3033
+ function formatEther(wei, unit = "wei") {
3034
+ return formatUnits(wei, etherUnits[unit]);
3035
+ }
3036
+
3037
+ // node_modules/viem/_esm/utils/unit/formatGwei.js
3038
+ function formatGwei(wei, unit = "wei") {
3039
+ return formatUnits(wei, gweiUnits[unit]);
3040
+ }
3041
+
3042
+ // node_modules/viem/_esm/errors/stateOverride.js
3043
+ var AccountStateConflictError = class extends BaseError3 {
3044
+ constructor({ address }) {
3045
+ super(`State for account "${address}" is set multiple times.`, {
3046
+ name: "AccountStateConflictError"
3047
+ });
3048
+ }
3049
+ };
3050
+ var StateAssignmentConflictError = class extends BaseError3 {
3051
+ constructor() {
3052
+ super("state and stateDiff are set on the same account.", {
3053
+ name: "StateAssignmentConflictError"
3054
+ });
3055
+ }
3056
+ };
3057
+ function prettyStateMapping(stateMapping) {
3058
+ return stateMapping.reduce((pretty, { slot, value }) => {
3059
+ return `${pretty} ${slot}: ${value}
3060
+ `;
3061
+ }, "");
3062
+ }
3063
+ function prettyStateOverride(stateOverride) {
3064
+ return stateOverride.reduce((pretty, { address, ...state }) => {
3065
+ let val = `${pretty} ${address}:
3066
+ `;
3067
+ if (state.nonce)
3068
+ val += ` nonce: ${state.nonce}
3069
+ `;
3070
+ if (state.balance)
3071
+ val += ` balance: ${state.balance}
3072
+ `;
3073
+ if (state.code)
3074
+ val += ` code: ${state.code}
3075
+ `;
3076
+ if (state.state) {
3077
+ val += " state:\n";
3078
+ val += prettyStateMapping(state.state);
3079
+ }
3080
+ if (state.stateDiff) {
3081
+ val += " stateDiff:\n";
3082
+ val += prettyStateMapping(state.stateDiff);
3083
+ }
3084
+ return val;
3085
+ }, " State Override:\n").slice(0, -1);
3086
+ }
3087
+
3088
+ // node_modules/viem/_esm/errors/transaction.js
3089
+ function prettyPrint(args) {
3090
+ const entries = Object.entries(args).map(([key, value]) => {
3091
+ if (value === void 0 || value === false)
3092
+ return null;
3093
+ return [key, value];
3094
+ }).filter(Boolean);
3095
+ const maxLength = entries.reduce((acc, [key]) => Math.max(acc, key.length), 0);
3096
+ return entries.map(([key, value]) => ` ${`${key}:`.padEnd(maxLength + 1)} ${value}`).join("\n");
3097
+ }
3098
+ var TransactionReceiptNotFoundError = class extends BaseError3 {
3099
+ constructor({ hash: hash2 }) {
3100
+ super(`Transaction receipt with hash "${hash2}" could not be found. The Transaction may not be processed on a block yet.`, {
3101
+ name: "TransactionReceiptNotFoundError"
3102
+ });
3103
+ }
3104
+ };
3105
+
3106
+ // node_modules/viem/_esm/errors/utils.js
3107
+ var getUrl = (url) => url;
3108
+
3109
+ // node_modules/viem/_esm/errors/contract.js
3110
+ var CallExecutionError = class extends BaseError3 {
3111
+ constructor(cause, { account: account_, docsPath: docsPath6, chain, data, gas, gasPrice, maxFeePerGas, maxPriorityFeePerGas, nonce, to, value, stateOverride }) {
3112
+ const account = account_ ? parseAccount(account_) : void 0;
3113
+ let prettyArgs = prettyPrint({
3114
+ from: account?.address,
3115
+ to,
3116
+ value: typeof value !== "undefined" && `${formatEther(value)} ${chain?.nativeCurrency?.symbol || "ETH"}`,
3117
+ data,
3118
+ gas,
3119
+ gasPrice: typeof gasPrice !== "undefined" && `${formatGwei(gasPrice)} gwei`,
3120
+ maxFeePerGas: typeof maxFeePerGas !== "undefined" && `${formatGwei(maxFeePerGas)} gwei`,
3121
+ maxPriorityFeePerGas: typeof maxPriorityFeePerGas !== "undefined" && `${formatGwei(maxPriorityFeePerGas)} gwei`,
3122
+ nonce
3123
+ });
3124
+ if (stateOverride) {
3125
+ prettyArgs += `
3126
+ ${prettyStateOverride(stateOverride)}`;
3127
+ }
3128
+ super(cause.shortMessage, {
3129
+ cause,
3130
+ docsPath: docsPath6,
3131
+ metaMessages: [
3132
+ ...cause.metaMessages ? [...cause.metaMessages, " "] : [],
3133
+ "Raw Call Arguments:",
3134
+ prettyArgs
3135
+ ].filter(Boolean),
3136
+ name: "CallExecutionError"
3137
+ });
3138
+ Object.defineProperty(this, "cause", {
3139
+ enumerable: true,
3140
+ configurable: true,
3141
+ writable: true,
3142
+ value: void 0
3143
+ });
3144
+ this.cause = cause;
3145
+ }
3146
+ };
3147
+ var CounterfactualDeploymentFailedError = class extends BaseError3 {
3148
+ constructor({ factory }) {
3149
+ super(`Deployment for counterfactual contract call failed${factory ? ` for factory "${factory}".` : ""}`, {
3150
+ metaMessages: [
3151
+ "Please ensure:",
3152
+ "- The `factory` is a valid contract deployment factory (ie. Create2 Factory, ERC-4337 Factory, etc).",
3153
+ "- The `factoryData` is a valid encoded function call for contract deployment function on the factory."
3154
+ ],
3155
+ name: "CounterfactualDeploymentFailedError"
3156
+ });
3157
+ }
3158
+ };
3159
+ var RawContractError = class extends BaseError3 {
3160
+ constructor({ data, message }) {
3161
+ super(message || "", { name: "RawContractError" });
3162
+ Object.defineProperty(this, "code", {
3163
+ enumerable: true,
3164
+ configurable: true,
3165
+ writable: true,
3166
+ value: 3
3167
+ });
3168
+ Object.defineProperty(this, "data", {
3169
+ enumerable: true,
3170
+ configurable: true,
3171
+ writable: true,
3172
+ value: void 0
3173
+ });
3174
+ this.data = data;
3175
+ }
3176
+ };
3177
+
3178
+ // node_modules/viem/_esm/utils/abi/decodeFunctionResult.js
3179
+ var docsPath = "/docs/contract/decodeFunctionResult";
3180
+ function decodeFunctionResult(parameters) {
3181
+ const { abi, args, functionName, data } = parameters;
3182
+ let abiItem = abi[0];
3183
+ if (functionName) {
3184
+ const item = getAbiItem({ abi, args, name: functionName });
3185
+ if (!item)
3186
+ throw new AbiFunctionNotFoundError(functionName, { docsPath });
3187
+ abiItem = item;
3188
+ }
3189
+ if (abiItem.type !== "function")
3190
+ throw new AbiFunctionNotFoundError(void 0, { docsPath });
3191
+ if (!abiItem.outputs)
3192
+ throw new AbiFunctionOutputsNotFoundError(abiItem.name, { docsPath });
3193
+ const values = decodeAbiParameters(abiItem.outputs, data);
3194
+ if (values && values.length > 1)
3195
+ return values;
3196
+ if (values && values.length === 1)
3197
+ return values[0];
3198
+ return void 0;
3199
+ }
3200
+
3201
+ // node_modules/viem/_esm/utils/abi/encodeDeployData.js
3202
+ var docsPath2 = "/docs/contract/encodeDeployData";
3203
+ function encodeDeployData(parameters) {
3204
+ const { abi, args, bytecode } = parameters;
3205
+ if (!args || args.length === 0)
3206
+ return bytecode;
3207
+ const description = abi.find((x) => "type" in x && x.type === "constructor");
3208
+ if (!description)
3209
+ throw new AbiConstructorNotFoundError({ docsPath: docsPath2 });
3210
+ if (!("inputs" in description))
3211
+ throw new AbiConstructorParamsNotFoundError({ docsPath: docsPath2 });
3212
+ if (!description.inputs || description.inputs.length === 0)
3213
+ throw new AbiConstructorParamsNotFoundError({ docsPath: docsPath2 });
3214
+ const data = encodeAbiParameters(description.inputs, args);
3215
+ return concatHex([bytecode, data]);
3216
+ }
3217
+
3218
+ // node_modules/viem/_esm/utils/abi/prepareEncodeFunctionData.js
3219
+ var docsPath3 = "/docs/contract/encodeFunctionData";
3220
+ function prepareEncodeFunctionData(parameters) {
3221
+ const { abi, args, functionName } = parameters;
3222
+ let abiItem = abi[0];
3223
+ if (functionName) {
3224
+ const item = getAbiItem({
3225
+ abi,
3226
+ args,
3227
+ name: functionName
3228
+ });
3229
+ if (!item)
3230
+ throw new AbiFunctionNotFoundError(functionName, { docsPath: docsPath3 });
3231
+ abiItem = item;
3232
+ }
3233
+ if (abiItem.type !== "function")
3234
+ throw new AbiFunctionNotFoundError(void 0, { docsPath: docsPath3 });
3235
+ return {
3236
+ abi: [abiItem],
3237
+ functionName: toFunctionSelector(formatAbiItem2(abiItem))
3238
+ };
3239
+ }
3240
+
3241
+ // node_modules/viem/_esm/utils/abi/encodeFunctionData.js
3242
+ function encodeFunctionData(parameters) {
3243
+ const { args } = parameters;
3244
+ const { abi, functionName } = (() => {
3245
+ if (parameters.abi.length === 1 && parameters.functionName?.startsWith("0x"))
3246
+ return parameters;
3247
+ return prepareEncodeFunctionData(parameters);
3248
+ })();
3249
+ const abiItem = abi[0];
3250
+ const signature = functionName;
3251
+ const data = "inputs" in abiItem && abiItem.inputs ? encodeAbiParameters(abiItem.inputs, args ?? []) : void 0;
3252
+ return concatHex([signature, data ?? "0x"]);
3253
+ }
3254
+
3255
+ // node_modules/viem/_esm/utils/chain/getChainContractAddress.js
3256
+ function getChainContractAddress({ blockNumber, chain, contract: name }) {
3257
+ const contract = chain?.contracts?.[name];
3258
+ if (!contract)
3259
+ throw new ChainDoesNotSupportContract({
3260
+ chain,
3261
+ contract: { name }
3262
+ });
3263
+ if (blockNumber && contract.blockCreated && contract.blockCreated > blockNumber)
3264
+ throw new ChainDoesNotSupportContract({
3265
+ blockNumber,
3266
+ chain,
3267
+ contract: {
3268
+ name,
3269
+ blockCreated: contract.blockCreated
3270
+ }
3271
+ });
3272
+ return contract.address;
3273
+ }
3274
+
3275
+ // node_modules/viem/_esm/errors/node.js
3276
+ var ExecutionRevertedError = class extends BaseError3 {
3277
+ constructor({ cause, message } = {}) {
3278
+ const reason = message?.replace("execution reverted: ", "")?.replace("execution reverted", "");
3279
+ super(`Execution reverted ${reason ? `with reason: ${reason}` : "for an unknown reason"}.`, {
3280
+ cause,
3281
+ name: "ExecutionRevertedError"
3282
+ });
3283
+ }
3284
+ };
3285
+ Object.defineProperty(ExecutionRevertedError, "code", {
3286
+ enumerable: true,
3287
+ configurable: true,
3288
+ writable: true,
3289
+ value: 3
3290
+ });
3291
+ Object.defineProperty(ExecutionRevertedError, "nodeMessage", {
3292
+ enumerable: true,
3293
+ configurable: true,
3294
+ writable: true,
3295
+ value: /execution reverted/
3296
+ });
3297
+ var FeeCapTooHighError = class extends BaseError3 {
3298
+ constructor({ cause, maxFeePerGas } = {}) {
3299
+ super(`The fee cap (\`maxFeePerGas\`${maxFeePerGas ? ` = ${formatGwei(maxFeePerGas)} gwei` : ""}) cannot be higher than the maximum allowed value (2^256-1).`, {
3300
+ cause,
3301
+ name: "FeeCapTooHighError"
3302
+ });
3303
+ }
3304
+ };
3305
+ Object.defineProperty(FeeCapTooHighError, "nodeMessage", {
3306
+ enumerable: true,
3307
+ configurable: true,
3308
+ writable: true,
3309
+ value: /max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/
3310
+ });
3311
+ var FeeCapTooLowError = class extends BaseError3 {
3312
+ constructor({ cause, maxFeePerGas } = {}) {
3313
+ super(`The fee cap (\`maxFeePerGas\`${maxFeePerGas ? ` = ${formatGwei(maxFeePerGas)}` : ""} gwei) cannot be lower than the block base fee.`, {
3314
+ cause,
3315
+ name: "FeeCapTooLowError"
3316
+ });
3317
+ }
3318
+ };
3319
+ Object.defineProperty(FeeCapTooLowError, "nodeMessage", {
3320
+ enumerable: true,
3321
+ configurable: true,
3322
+ writable: true,
3323
+ value: /max fee per gas less than block base fee|fee cap less than block base fee|transaction is outdated/
3324
+ });
3325
+ var NonceTooHighError = class extends BaseError3 {
3326
+ constructor({ cause, nonce } = {}) {
3327
+ super(`Nonce provided for the transaction ${nonce ? `(${nonce}) ` : ""}is higher than the next one expected.`, { cause, name: "NonceTooHighError" });
3328
+ }
3329
+ };
3330
+ Object.defineProperty(NonceTooHighError, "nodeMessage", {
3331
+ enumerable: true,
3332
+ configurable: true,
3333
+ writable: true,
3334
+ value: /nonce too high/
3335
+ });
3336
+ var NonceTooLowError = class extends BaseError3 {
3337
+ constructor({ cause, nonce } = {}) {
3338
+ super([
3339
+ `Nonce provided for the transaction ${nonce ? `(${nonce}) ` : ""}is lower than the current nonce of the account.`,
3340
+ "Try increasing the nonce or find the latest nonce with `getTransactionCount`."
3341
+ ].join("\n"), { cause, name: "NonceTooLowError" });
3342
+ }
3343
+ };
3344
+ Object.defineProperty(NonceTooLowError, "nodeMessage", {
3345
+ enumerable: true,
3346
+ configurable: true,
3347
+ writable: true,
3348
+ value: /nonce too low|transaction already imported|already known/
3349
+ });
3350
+ var NonceMaxValueError = class extends BaseError3 {
3351
+ constructor({ cause, nonce } = {}) {
3352
+ super(`Nonce provided for the transaction ${nonce ? `(${nonce}) ` : ""}exceeds the maximum allowed nonce.`, { cause, name: "NonceMaxValueError" });
3353
+ }
3354
+ };
3355
+ Object.defineProperty(NonceMaxValueError, "nodeMessage", {
3356
+ enumerable: true,
3357
+ configurable: true,
3358
+ writable: true,
3359
+ value: /nonce has max value/
3360
+ });
3361
+ var InsufficientFundsError = class extends BaseError3 {
3362
+ constructor({ cause } = {}) {
3363
+ super([
3364
+ "The total cost (gas * gas fee + value) of executing this transaction exceeds the balance of the account."
3365
+ ].join("\n"), {
3366
+ cause,
3367
+ metaMessages: [
3368
+ "This error could arise when the account does not have enough funds to:",
3369
+ " - pay for the total gas fee,",
3370
+ " - pay for the value to send.",
3371
+ " ",
3372
+ "The cost of the transaction is calculated as `gas * gas fee + value`, where:",
3373
+ " - `gas` is the amount of gas needed for transaction to execute,",
3374
+ " - `gas fee` is the gas fee,",
3375
+ " - `value` is the amount of ether to send to the recipient."
3376
+ ],
3377
+ name: "InsufficientFundsError"
3378
+ });
3379
+ }
3380
+ };
3381
+ Object.defineProperty(InsufficientFundsError, "nodeMessage", {
3382
+ enumerable: true,
3383
+ configurable: true,
3384
+ writable: true,
3385
+ value: /insufficient funds|exceeds transaction sender account balance/
3386
+ });
3387
+ var IntrinsicGasTooHighError = class extends BaseError3 {
3388
+ constructor({ cause, gas } = {}) {
3389
+ super(`The amount of gas ${gas ? `(${gas}) ` : ""}provided for the transaction exceeds the limit allowed for the block.`, {
3390
+ cause,
3391
+ name: "IntrinsicGasTooHighError"
3392
+ });
3393
+ }
3394
+ };
3395
+ Object.defineProperty(IntrinsicGasTooHighError, "nodeMessage", {
3396
+ enumerable: true,
3397
+ configurable: true,
3398
+ writable: true,
3399
+ value: /intrinsic gas too high|gas limit reached/
3400
+ });
3401
+ var IntrinsicGasTooLowError = class extends BaseError3 {
3402
+ constructor({ cause, gas } = {}) {
3403
+ super(`The amount of gas ${gas ? `(${gas}) ` : ""}provided for the transaction is too low.`, {
3404
+ cause,
3405
+ name: "IntrinsicGasTooLowError"
3406
+ });
3407
+ }
3408
+ };
3409
+ Object.defineProperty(IntrinsicGasTooLowError, "nodeMessage", {
3410
+ enumerable: true,
3411
+ configurable: true,
3412
+ writable: true,
3413
+ value: /intrinsic gas too low/
3414
+ });
3415
+ var TransactionTypeNotSupportedError = class extends BaseError3 {
3416
+ constructor({ cause }) {
3417
+ super("The transaction type is not supported for this chain.", {
3418
+ cause,
3419
+ name: "TransactionTypeNotSupportedError"
3420
+ });
3421
+ }
3422
+ };
3423
+ Object.defineProperty(TransactionTypeNotSupportedError, "nodeMessage", {
3424
+ enumerable: true,
3425
+ configurable: true,
3426
+ writable: true,
3427
+ value: /transaction type not valid/
3428
+ });
3429
+ var TipAboveFeeCapError = class extends BaseError3 {
3430
+ constructor({ cause, maxPriorityFeePerGas, maxFeePerGas } = {}) {
3431
+ super([
3432
+ `The provided tip (\`maxPriorityFeePerGas\`${maxPriorityFeePerGas ? ` = ${formatGwei(maxPriorityFeePerGas)} gwei` : ""}) cannot be higher than the fee cap (\`maxFeePerGas\`${maxFeePerGas ? ` = ${formatGwei(maxFeePerGas)} gwei` : ""}).`
3433
+ ].join("\n"), {
3434
+ cause,
3435
+ name: "TipAboveFeeCapError"
3436
+ });
3437
+ }
3438
+ };
3439
+ Object.defineProperty(TipAboveFeeCapError, "nodeMessage", {
3440
+ enumerable: true,
3441
+ configurable: true,
3442
+ writable: true,
3443
+ value: /max priority fee per gas higher than max fee per gas|tip higher than fee cap/
3444
+ });
3445
+ var UnknownNodeError = class extends BaseError3 {
3446
+ constructor({ cause }) {
3447
+ super(`An error occurred while executing: ${cause?.shortMessage}`, {
3448
+ cause,
3449
+ name: "UnknownNodeError"
3450
+ });
3451
+ }
3452
+ };
3453
+
3454
+ // node_modules/viem/_esm/errors/request.js
3455
+ var HttpRequestError = class extends BaseError3 {
3456
+ constructor({ body, cause, details, headers, status, url }) {
3457
+ super("HTTP request failed.", {
3458
+ cause,
3459
+ details,
3460
+ metaMessages: [
3461
+ status && `Status: ${status}`,
3462
+ `URL: ${getUrl(url)}`,
3463
+ body && `Request body: ${stringify(body)}`
3464
+ ].filter(Boolean),
3465
+ name: "HttpRequestError"
3466
+ });
3467
+ Object.defineProperty(this, "body", {
3468
+ enumerable: true,
3469
+ configurable: true,
3470
+ writable: true,
3471
+ value: void 0
3472
+ });
3473
+ Object.defineProperty(this, "headers", {
3474
+ enumerable: true,
3475
+ configurable: true,
3476
+ writable: true,
3477
+ value: void 0
3478
+ });
3479
+ Object.defineProperty(this, "status", {
3480
+ enumerable: true,
3481
+ configurable: true,
3482
+ writable: true,
3483
+ value: void 0
3484
+ });
3485
+ Object.defineProperty(this, "url", {
3486
+ enumerable: true,
3487
+ configurable: true,
3488
+ writable: true,
3489
+ value: void 0
3490
+ });
3491
+ this.body = body;
3492
+ this.headers = headers;
3493
+ this.status = status;
3494
+ this.url = url;
3495
+ }
3496
+ };
3497
+
3498
+ // node_modules/viem/_esm/utils/errors/getNodeError.js
3499
+ function getNodeError(err, args) {
3500
+ const message = (err.details || "").toLowerCase();
3501
+ const executionRevertedError = err instanceof BaseError3 ? err.walk((e) => e?.code === ExecutionRevertedError.code) : err;
3502
+ if (executionRevertedError instanceof BaseError3)
3503
+ return new ExecutionRevertedError({
3504
+ cause: err,
3505
+ message: executionRevertedError.details
3506
+ });
3507
+ if (ExecutionRevertedError.nodeMessage.test(message))
3508
+ return new ExecutionRevertedError({
3509
+ cause: err,
3510
+ message: err.details
3511
+ });
3512
+ if (FeeCapTooHighError.nodeMessage.test(message))
3513
+ return new FeeCapTooHighError({
3514
+ cause: err,
3515
+ maxFeePerGas: args?.maxFeePerGas
3516
+ });
3517
+ if (FeeCapTooLowError.nodeMessage.test(message))
3518
+ return new FeeCapTooLowError({
3519
+ cause: err,
3520
+ maxFeePerGas: args?.maxFeePerGas
3521
+ });
3522
+ if (NonceTooHighError.nodeMessage.test(message))
3523
+ return new NonceTooHighError({ cause: err, nonce: args?.nonce });
3524
+ if (NonceTooLowError.nodeMessage.test(message))
3525
+ return new NonceTooLowError({ cause: err, nonce: args?.nonce });
3526
+ if (NonceMaxValueError.nodeMessage.test(message))
3527
+ return new NonceMaxValueError({ cause: err, nonce: args?.nonce });
3528
+ if (InsufficientFundsError.nodeMessage.test(message))
3529
+ return new InsufficientFundsError({ cause: err });
3530
+ if (IntrinsicGasTooHighError.nodeMessage.test(message))
3531
+ return new IntrinsicGasTooHighError({ cause: err, gas: args?.gas });
3532
+ if (IntrinsicGasTooLowError.nodeMessage.test(message))
3533
+ return new IntrinsicGasTooLowError({ cause: err, gas: args?.gas });
3534
+ if (TransactionTypeNotSupportedError.nodeMessage.test(message))
3535
+ return new TransactionTypeNotSupportedError({ cause: err });
3536
+ if (TipAboveFeeCapError.nodeMessage.test(message))
3537
+ return new TipAboveFeeCapError({
3538
+ cause: err,
3539
+ maxFeePerGas: args?.maxFeePerGas,
3540
+ maxPriorityFeePerGas: args?.maxPriorityFeePerGas
3541
+ });
3542
+ return new UnknownNodeError({
3543
+ cause: err
3544
+ });
3545
+ }
3546
+
3547
+ // node_modules/viem/_esm/utils/errors/getCallError.js
3548
+ function getCallError(err, { docsPath: docsPath6, ...args }) {
3549
+ const cause = (() => {
3550
+ const cause2 = getNodeError(err, args);
3551
+ if (cause2 instanceof UnknownNodeError)
3552
+ return err;
3553
+ return cause2;
3554
+ })();
3555
+ return new CallExecutionError(cause, {
3556
+ docsPath: docsPath6,
3557
+ ...args
3558
+ });
3559
+ }
3560
+
3561
+ // node_modules/viem/_esm/utils/formatters/extract.js
3562
+ function extract(value_, { format }) {
3563
+ if (!format)
3564
+ return {};
3565
+ const value = {};
3566
+ function extract_(formatted2) {
3567
+ const keys = Object.keys(formatted2);
3568
+ for (const key of keys) {
3569
+ if (key in value_)
3570
+ value[key] = value_[key];
3571
+ if (formatted2[key] && typeof formatted2[key] === "object" && !Array.isArray(formatted2[key]))
3572
+ extract_(formatted2[key]);
3573
+ }
3574
+ }
3575
+ const formatted = format(value_ || {});
3576
+ extract_(formatted);
3577
+ return value;
3578
+ }
3579
+
3580
+ // node_modules/viem/_esm/utils/formatters/transactionRequest.js
3581
+ var rpcTransactionType = {
3582
+ legacy: "0x0",
3583
+ eip2930: "0x1",
3584
+ eip1559: "0x2",
3585
+ eip4844: "0x3",
3586
+ eip7702: "0x4"
3587
+ };
3588
+ function formatTransactionRequest(request, _) {
3589
+ const rpcRequest = {};
3590
+ if (typeof request.authorizationList !== "undefined")
3591
+ rpcRequest.authorizationList = formatAuthorizationList(request.authorizationList);
3592
+ if (typeof request.accessList !== "undefined")
3593
+ rpcRequest.accessList = request.accessList;
3594
+ if (typeof request.blobVersionedHashes !== "undefined")
3595
+ rpcRequest.blobVersionedHashes = request.blobVersionedHashes;
3596
+ if (typeof request.blobs !== "undefined") {
3597
+ if (typeof request.blobs[0] !== "string")
3598
+ rpcRequest.blobs = request.blobs.map((x) => bytesToHex(x));
3599
+ else
3600
+ rpcRequest.blobs = request.blobs;
3601
+ }
3602
+ if (typeof request.data !== "undefined")
3603
+ rpcRequest.data = request.data;
3604
+ if (request.account)
3605
+ rpcRequest.from = request.account.address;
3606
+ if (typeof request.from !== "undefined")
3607
+ rpcRequest.from = request.from;
3608
+ if (typeof request.gas !== "undefined")
3609
+ rpcRequest.gas = numberToHex(request.gas);
3610
+ if (typeof request.gasPrice !== "undefined")
3611
+ rpcRequest.gasPrice = numberToHex(request.gasPrice);
3612
+ if (typeof request.maxFeePerBlobGas !== "undefined")
3613
+ rpcRequest.maxFeePerBlobGas = numberToHex(request.maxFeePerBlobGas);
3614
+ if (typeof request.maxFeePerGas !== "undefined")
3615
+ rpcRequest.maxFeePerGas = numberToHex(request.maxFeePerGas);
3616
+ if (typeof request.maxPriorityFeePerGas !== "undefined")
3617
+ rpcRequest.maxPriorityFeePerGas = numberToHex(request.maxPriorityFeePerGas);
3618
+ if (typeof request.nonce !== "undefined")
3619
+ rpcRequest.nonce = numberToHex(request.nonce);
3620
+ if (typeof request.to !== "undefined")
3621
+ rpcRequest.to = request.to;
3622
+ if (typeof request.type !== "undefined")
3623
+ rpcRequest.type = rpcTransactionType[request.type];
3624
+ if (typeof request.value !== "undefined")
3625
+ rpcRequest.value = numberToHex(request.value);
3626
+ return rpcRequest;
3627
+ }
3628
+ function formatAuthorizationList(authorizationList) {
3629
+ return authorizationList.map((authorization) => ({
3630
+ address: authorization.address,
3631
+ r: authorization.r ? numberToHex(BigInt(authorization.r)) : authorization.r,
3632
+ s: authorization.s ? numberToHex(BigInt(authorization.s)) : authorization.s,
3633
+ chainId: numberToHex(authorization.chainId),
3634
+ nonce: numberToHex(authorization.nonce),
3635
+ ...typeof authorization.yParity !== "undefined" ? { yParity: numberToHex(authorization.yParity) } : {},
3636
+ ...typeof authorization.v !== "undefined" && typeof authorization.yParity === "undefined" ? { v: numberToHex(authorization.v) } : {}
3637
+ }));
3638
+ }
3639
+
3640
+ // node_modules/viem/_esm/utils/promise/withResolvers.js
3641
+ function withResolvers() {
3642
+ let resolve = () => void 0;
3643
+ let reject = () => void 0;
3644
+ const promise = new Promise((resolve_, reject_) => {
3645
+ resolve = resolve_;
3646
+ reject = reject_;
3647
+ });
3648
+ return { promise, resolve, reject };
3649
+ }
3650
+
3651
+ // node_modules/viem/_esm/utils/promise/createBatchScheduler.js
3652
+ var schedulerCache = /* @__PURE__ */ new Map();
3653
+ function createBatchScheduler({ fn, id, shouldSplitBatch, wait = 0, sort }) {
3654
+ const exec = async () => {
3655
+ const scheduler = getScheduler();
3656
+ flush();
3657
+ const args = scheduler.map(({ args: args2 }) => args2);
3658
+ if (args.length === 0)
3659
+ return;
3660
+ fn(args).then((data) => {
3661
+ if (sort && Array.isArray(data))
3662
+ data.sort(sort);
3663
+ for (let i = 0; i < scheduler.length; i++) {
3664
+ const { resolve } = scheduler[i];
3665
+ resolve?.([data[i], data]);
3666
+ }
3667
+ }).catch((err) => {
3668
+ for (let i = 0; i < scheduler.length; i++) {
3669
+ const { reject } = scheduler[i];
3670
+ reject?.(err);
3671
+ }
3672
+ });
3673
+ };
3674
+ const flush = () => schedulerCache.delete(id);
3675
+ const getBatchedArgs = () => getScheduler().map(({ args }) => args);
3676
+ const getScheduler = () => schedulerCache.get(id) || [];
3677
+ const setScheduler = (item) => schedulerCache.set(id, [...getScheduler(), item]);
3678
+ return {
3679
+ flush,
3680
+ async schedule(args) {
3681
+ const { promise, resolve, reject } = withResolvers();
3682
+ const split2 = shouldSplitBatch?.([...getBatchedArgs(), args]);
3683
+ if (split2)
3684
+ exec();
3685
+ const hasActiveScheduler = getScheduler().length > 0;
3686
+ if (hasActiveScheduler) {
3687
+ setScheduler({ args, resolve, reject });
3688
+ return promise;
3689
+ }
3690
+ setScheduler({ args, resolve, reject });
3691
+ setTimeout(exec, wait);
3692
+ return promise;
3693
+ }
3694
+ };
3695
+ }
3696
+
3697
+ // node_modules/viem/_esm/utils/stateOverride.js
3698
+ function serializeStateMapping(stateMapping) {
3699
+ if (!stateMapping || stateMapping.length === 0)
3700
+ return void 0;
3701
+ return stateMapping.reduce((acc, { slot, value }) => {
3702
+ if (slot.length !== 66)
3703
+ throw new InvalidBytesLengthError({
3704
+ size: slot.length,
3705
+ targetSize: 66,
3706
+ type: "hex"
3707
+ });
3708
+ if (value.length !== 66)
3709
+ throw new InvalidBytesLengthError({
3710
+ size: value.length,
3711
+ targetSize: 66,
3712
+ type: "hex"
3713
+ });
3714
+ acc[slot] = value;
3715
+ return acc;
3716
+ }, {});
3717
+ }
3718
+ function serializeAccountStateOverride(parameters) {
3719
+ const { balance, nonce, state, stateDiff, code } = parameters;
3720
+ const rpcAccountStateOverride = {};
3721
+ if (code !== void 0)
3722
+ rpcAccountStateOverride.code = code;
3723
+ if (balance !== void 0)
3724
+ rpcAccountStateOverride.balance = numberToHex(balance);
3725
+ if (nonce !== void 0)
3726
+ rpcAccountStateOverride.nonce = numberToHex(nonce);
3727
+ if (state !== void 0)
3728
+ rpcAccountStateOverride.state = serializeStateMapping(state);
3729
+ if (stateDiff !== void 0) {
3730
+ if (rpcAccountStateOverride.state)
3731
+ throw new StateAssignmentConflictError();
3732
+ rpcAccountStateOverride.stateDiff = serializeStateMapping(stateDiff);
3733
+ }
3734
+ return rpcAccountStateOverride;
3735
+ }
3736
+ function serializeStateOverride(parameters) {
3737
+ if (!parameters)
3738
+ return void 0;
3739
+ const rpcStateOverride = {};
3740
+ for (const { address, ...accountState } of parameters) {
3741
+ if (!isAddress(address, { strict: false }))
3742
+ throw new InvalidAddressError({ address });
3743
+ if (rpcStateOverride[address])
3744
+ throw new AccountStateConflictError({ address });
3745
+ rpcStateOverride[address] = serializeAccountStateOverride(accountState);
3746
+ }
3747
+ return rpcStateOverride;
3748
+ }
3749
+
3750
+ // node_modules/viem/_esm/constants/number.js
3751
+ var maxInt8 = 2n ** (8n - 1n) - 1n;
3752
+ var maxInt16 = 2n ** (16n - 1n) - 1n;
3753
+ var maxInt24 = 2n ** (24n - 1n) - 1n;
3754
+ var maxInt32 = 2n ** (32n - 1n) - 1n;
3755
+ var maxInt40 = 2n ** (40n - 1n) - 1n;
3756
+ var maxInt48 = 2n ** (48n - 1n) - 1n;
3757
+ var maxInt56 = 2n ** (56n - 1n) - 1n;
3758
+ var maxInt64 = 2n ** (64n - 1n) - 1n;
3759
+ var maxInt72 = 2n ** (72n - 1n) - 1n;
3760
+ var maxInt80 = 2n ** (80n - 1n) - 1n;
3761
+ var maxInt88 = 2n ** (88n - 1n) - 1n;
3762
+ var maxInt96 = 2n ** (96n - 1n) - 1n;
3763
+ var maxInt104 = 2n ** (104n - 1n) - 1n;
3764
+ var maxInt112 = 2n ** (112n - 1n) - 1n;
3765
+ var maxInt120 = 2n ** (120n - 1n) - 1n;
3766
+ var maxInt128 = 2n ** (128n - 1n) - 1n;
3767
+ var maxInt136 = 2n ** (136n - 1n) - 1n;
3768
+ var maxInt144 = 2n ** (144n - 1n) - 1n;
3769
+ var maxInt152 = 2n ** (152n - 1n) - 1n;
3770
+ var maxInt160 = 2n ** (160n - 1n) - 1n;
3771
+ var maxInt168 = 2n ** (168n - 1n) - 1n;
3772
+ var maxInt176 = 2n ** (176n - 1n) - 1n;
3773
+ var maxInt184 = 2n ** (184n - 1n) - 1n;
3774
+ var maxInt192 = 2n ** (192n - 1n) - 1n;
3775
+ var maxInt200 = 2n ** (200n - 1n) - 1n;
3776
+ var maxInt208 = 2n ** (208n - 1n) - 1n;
3777
+ var maxInt216 = 2n ** (216n - 1n) - 1n;
3778
+ var maxInt224 = 2n ** (224n - 1n) - 1n;
3779
+ var maxInt232 = 2n ** (232n - 1n) - 1n;
3780
+ var maxInt240 = 2n ** (240n - 1n) - 1n;
3781
+ var maxInt248 = 2n ** (248n - 1n) - 1n;
3782
+ var maxInt256 = 2n ** (256n - 1n) - 1n;
3783
+ var minInt8 = -(2n ** (8n - 1n));
3784
+ var minInt16 = -(2n ** (16n - 1n));
3785
+ var minInt24 = -(2n ** (24n - 1n));
3786
+ var minInt32 = -(2n ** (32n - 1n));
3787
+ var minInt40 = -(2n ** (40n - 1n));
3788
+ var minInt48 = -(2n ** (48n - 1n));
3789
+ var minInt56 = -(2n ** (56n - 1n));
3790
+ var minInt64 = -(2n ** (64n - 1n));
3791
+ var minInt72 = -(2n ** (72n - 1n));
3792
+ var minInt80 = -(2n ** (80n - 1n));
3793
+ var minInt88 = -(2n ** (88n - 1n));
3794
+ var minInt96 = -(2n ** (96n - 1n));
3795
+ var minInt104 = -(2n ** (104n - 1n));
3796
+ var minInt112 = -(2n ** (112n - 1n));
3797
+ var minInt120 = -(2n ** (120n - 1n));
3798
+ var minInt128 = -(2n ** (128n - 1n));
3799
+ var minInt136 = -(2n ** (136n - 1n));
3800
+ var minInt144 = -(2n ** (144n - 1n));
3801
+ var minInt152 = -(2n ** (152n - 1n));
3802
+ var minInt160 = -(2n ** (160n - 1n));
3803
+ var minInt168 = -(2n ** (168n - 1n));
3804
+ var minInt176 = -(2n ** (176n - 1n));
3805
+ var minInt184 = -(2n ** (184n - 1n));
3806
+ var minInt192 = -(2n ** (192n - 1n));
3807
+ var minInt200 = -(2n ** (200n - 1n));
3808
+ var minInt208 = -(2n ** (208n - 1n));
3809
+ var minInt216 = -(2n ** (216n - 1n));
3810
+ var minInt224 = -(2n ** (224n - 1n));
3811
+ var minInt232 = -(2n ** (232n - 1n));
3812
+ var minInt240 = -(2n ** (240n - 1n));
3813
+ var minInt248 = -(2n ** (248n - 1n));
3814
+ var minInt256 = -(2n ** (256n - 1n));
3815
+ var maxUint8 = 2n ** 8n - 1n;
3816
+ var maxUint16 = 2n ** 16n - 1n;
3817
+ var maxUint24 = 2n ** 24n - 1n;
3818
+ var maxUint32 = 2n ** 32n - 1n;
3819
+ var maxUint40 = 2n ** 40n - 1n;
3820
+ var maxUint48 = 2n ** 48n - 1n;
3821
+ var maxUint56 = 2n ** 56n - 1n;
3822
+ var maxUint64 = 2n ** 64n - 1n;
3823
+ var maxUint72 = 2n ** 72n - 1n;
3824
+ var maxUint80 = 2n ** 80n - 1n;
3825
+ var maxUint88 = 2n ** 88n - 1n;
3826
+ var maxUint96 = 2n ** 96n - 1n;
3827
+ var maxUint104 = 2n ** 104n - 1n;
3828
+ var maxUint112 = 2n ** 112n - 1n;
3829
+ var maxUint120 = 2n ** 120n - 1n;
3830
+ var maxUint128 = 2n ** 128n - 1n;
3831
+ var maxUint136 = 2n ** 136n - 1n;
3832
+ var maxUint144 = 2n ** 144n - 1n;
3833
+ var maxUint152 = 2n ** 152n - 1n;
3834
+ var maxUint160 = 2n ** 160n - 1n;
3835
+ var maxUint168 = 2n ** 168n - 1n;
3836
+ var maxUint176 = 2n ** 176n - 1n;
3837
+ var maxUint184 = 2n ** 184n - 1n;
3838
+ var maxUint192 = 2n ** 192n - 1n;
3839
+ var maxUint200 = 2n ** 200n - 1n;
3840
+ var maxUint208 = 2n ** 208n - 1n;
3841
+ var maxUint216 = 2n ** 216n - 1n;
3842
+ var maxUint224 = 2n ** 224n - 1n;
3843
+ var maxUint232 = 2n ** 232n - 1n;
3844
+ var maxUint240 = 2n ** 240n - 1n;
3845
+ var maxUint248 = 2n ** 248n - 1n;
3846
+ var maxUint256 = 2n ** 256n - 1n;
3847
+
3848
+ // node_modules/viem/_esm/utils/transaction/assertRequest.js
3849
+ function assertRequest(args) {
3850
+ const { account: account_, maxFeePerGas, maxPriorityFeePerGas, to } = args;
3851
+ const account = account_ ? parseAccount(account_) : void 0;
3852
+ if (account && !isAddress(account.address))
3853
+ throw new InvalidAddressError({ address: account.address });
3854
+ if (to && !isAddress(to))
3855
+ throw new InvalidAddressError({ address: to });
3856
+ if (maxFeePerGas && maxFeePerGas > maxUint256)
3857
+ throw new FeeCapTooHighError({ maxFeePerGas });
3858
+ if (maxPriorityFeePerGas && maxFeePerGas && maxPriorityFeePerGas > maxFeePerGas)
3859
+ throw new TipAboveFeeCapError({ maxFeePerGas, maxPriorityFeePerGas });
3860
+ }
3861
+
3862
+ // node_modules/viem/_esm/actions/public/call.js
3863
+ async function call(client, args) {
3864
+ const { account: account_ = client.account, authorizationList, batch = Boolean(client.batch?.multicall), blockNumber, blockTag = client.experimental_blockTag ?? "latest", accessList, blobs, blockOverrides, code, data: data_, factory, factoryData, gas, gasPrice, maxFeePerBlobGas, maxFeePerGas, maxPriorityFeePerGas, nonce, to, value, stateOverride, ...rest } = args;
3865
+ const account = account_ ? parseAccount(account_) : void 0;
3866
+ if (code && (factory || factoryData))
3867
+ throw new BaseError3("Cannot provide both `code` & `factory`/`factoryData` as parameters.");
3868
+ if (code && to)
3869
+ throw new BaseError3("Cannot provide both `code` & `to` as parameters.");
3870
+ const deploylessCallViaBytecode = code && data_;
3871
+ const deploylessCallViaFactory = factory && factoryData && to && data_;
3872
+ const deploylessCall = deploylessCallViaBytecode || deploylessCallViaFactory;
3873
+ const data = (() => {
3874
+ if (deploylessCallViaBytecode)
3875
+ return toDeploylessCallViaBytecodeData({
3876
+ code,
3877
+ data: data_
3878
+ });
3879
+ if (deploylessCallViaFactory)
3880
+ return toDeploylessCallViaFactoryData({
3881
+ data: data_,
3882
+ factory,
3883
+ factoryData,
3884
+ to
3885
+ });
3886
+ return data_;
3887
+ })();
3888
+ try {
3889
+ assertRequest(args);
3890
+ const blockNumberHex = typeof blockNumber === "bigint" ? numberToHex(blockNumber) : void 0;
3891
+ const block = blockNumberHex || blockTag;
3892
+ const rpcBlockOverrides = blockOverrides ? toRpc2(blockOverrides) : void 0;
3893
+ const rpcStateOverride = serializeStateOverride(stateOverride);
3894
+ const chainFormat = client.chain?.formatters?.transactionRequest?.format;
3895
+ const format = chainFormat || formatTransactionRequest;
3896
+ const request = format({
3897
+ // Pick out extra data that might exist on the chain's transaction request type.
3898
+ ...extract(rest, { format: chainFormat }),
3899
+ accessList,
3900
+ account,
3901
+ authorizationList,
3902
+ blobs,
3903
+ data,
3904
+ gas,
3905
+ gasPrice,
3906
+ maxFeePerBlobGas,
3907
+ maxFeePerGas,
3908
+ maxPriorityFeePerGas,
3909
+ nonce,
3910
+ to: deploylessCall ? void 0 : to,
3911
+ value
3912
+ }, "call");
3913
+ if (batch && shouldPerformMulticall({ request }) && !rpcStateOverride && !rpcBlockOverrides) {
3914
+ try {
3915
+ return await scheduleMulticall(client, {
3916
+ ...request,
3917
+ blockNumber,
3918
+ blockTag
3919
+ });
3920
+ } catch (err) {
3921
+ if (!(err instanceof ClientChainNotConfiguredError) && !(err instanceof ChainDoesNotSupportContract))
3922
+ throw err;
3923
+ }
3924
+ }
3925
+ const params = (() => {
3926
+ const base = [
3927
+ request,
3928
+ block
3929
+ ];
3930
+ if (rpcStateOverride && rpcBlockOverrides)
3931
+ return [...base, rpcStateOverride, rpcBlockOverrides];
3932
+ if (rpcStateOverride)
3933
+ return [...base, rpcStateOverride];
3934
+ if (rpcBlockOverrides)
3935
+ return [...base, {}, rpcBlockOverrides];
3936
+ return base;
3937
+ })();
3938
+ const response = await client.request({
3939
+ method: "eth_call",
3940
+ params
3941
+ });
3942
+ if (response === "0x")
3943
+ return { data: void 0 };
3944
+ return { data: response };
3945
+ } catch (err) {
3946
+ const data2 = getRevertErrorData(err);
3947
+ const { offchainLookup: offchainLookup2, offchainLookupSignature: offchainLookupSignature2 } = await import("./ccip-VFWQBRRA.js");
3948
+ if (client.ccipRead !== false && data2?.slice(0, 10) === offchainLookupSignature2 && to)
3949
+ return { data: await offchainLookup2(client, { data: data2, to }) };
3950
+ if (deploylessCall && data2?.slice(0, 10) === "0x101bb98d")
3951
+ throw new CounterfactualDeploymentFailedError({ factory });
3952
+ throw getCallError(err, {
3953
+ ...args,
3954
+ account,
3955
+ chain: client.chain
3956
+ });
3957
+ }
3958
+ }
3959
+ function shouldPerformMulticall({ request }) {
3960
+ const { data, to, ...request_ } = request;
3961
+ if (!data)
3962
+ return false;
3963
+ if (data.startsWith(aggregate3Signature))
3964
+ return false;
3965
+ if (!to)
3966
+ return false;
3967
+ if (Object.values(request_).filter((x) => typeof x !== "undefined").length > 0)
3968
+ return false;
3969
+ return true;
3970
+ }
3971
+ async function scheduleMulticall(client, args) {
3972
+ const { batchSize = 1024, deployless = false, wait = 0 } = typeof client.batch?.multicall === "object" ? client.batch.multicall : {};
3973
+ const { blockNumber, blockTag = client.experimental_blockTag ?? "latest", data, to } = args;
3974
+ const multicallAddress = (() => {
3975
+ if (deployless)
3976
+ return null;
3977
+ if (args.multicallAddress)
3978
+ return args.multicallAddress;
3979
+ if (client.chain) {
3980
+ return getChainContractAddress({
3981
+ blockNumber,
3982
+ chain: client.chain,
3983
+ contract: "multicall3"
3984
+ });
3985
+ }
3986
+ throw new ClientChainNotConfiguredError();
3987
+ })();
3988
+ const blockNumberHex = typeof blockNumber === "bigint" ? numberToHex(blockNumber) : void 0;
3989
+ const block = blockNumberHex || blockTag;
3990
+ const { schedule } = createBatchScheduler({
3991
+ id: `${client.uid}.${block}`,
3992
+ wait,
3993
+ shouldSplitBatch(args2) {
3994
+ const size3 = args2.reduce((size4, { data: data2 }) => size4 + (data2.length - 2), 0);
3995
+ return size3 > batchSize * 2;
3996
+ },
3997
+ fn: async (requests) => {
3998
+ const calls = requests.map((request) => ({
3999
+ allowFailure: true,
4000
+ callData: request.data,
4001
+ target: request.to
4002
+ }));
4003
+ const calldata = encodeFunctionData({
4004
+ abi: multicall3Abi,
4005
+ args: [calls],
4006
+ functionName: "aggregate3"
4007
+ });
4008
+ const data2 = await client.request({
4009
+ method: "eth_call",
4010
+ params: [
4011
+ {
4012
+ ...multicallAddress === null ? {
4013
+ data: toDeploylessCallViaBytecodeData({
4014
+ code: multicall3Bytecode,
4015
+ data: calldata
4016
+ })
4017
+ } : { to: multicallAddress, data: calldata }
4018
+ },
4019
+ block
4020
+ ]
4021
+ });
4022
+ return decodeFunctionResult({
4023
+ abi: multicall3Abi,
4024
+ args: [calls],
4025
+ functionName: "aggregate3",
4026
+ data: data2 || "0x"
4027
+ });
4028
+ }
4029
+ });
4030
+ const [{ returnData, success }] = await schedule({ data, to });
4031
+ if (!success)
4032
+ throw new RawContractError({ data: returnData });
4033
+ if (returnData === "0x")
4034
+ return { data: void 0 };
4035
+ return { data: returnData };
4036
+ }
4037
+ function toDeploylessCallViaBytecodeData(parameters) {
4038
+ const { code, data } = parameters;
4039
+ return encodeDeployData({
4040
+ abi: parseAbi(["constructor(bytes, bytes)"]),
4041
+ bytecode: deploylessCallViaBytecodeBytecode,
4042
+ args: [code, data]
4043
+ });
4044
+ }
4045
+ function toDeploylessCallViaFactoryData(parameters) {
4046
+ const { data, factory, factoryData, to } = parameters;
4047
+ return encodeDeployData({
4048
+ abi: parseAbi(["constructor(address, bytes, address, bytes)"]),
4049
+ bytecode: deploylessCallViaFactoryBytecode,
4050
+ args: [to, data, factory, factoryData]
4051
+ });
4052
+ }
4053
+ function getRevertErrorData(err) {
4054
+ if (!(err instanceof BaseError3))
4055
+ return void 0;
4056
+ const error = err.walk();
4057
+ return typeof error?.data === "object" ? error.data?.data : error.data;
4058
+ }
4059
+
4060
+ // node_modules/viem/_esm/errors/ccip.js
4061
+ var OffchainLookupError = class extends BaseError3 {
4062
+ constructor({ callbackSelector, cause, data, extraData, sender, urls }) {
4063
+ super(cause.shortMessage || "An error occurred while fetching for an offchain result.", {
4064
+ cause,
4065
+ metaMessages: [
4066
+ ...cause.metaMessages || [],
4067
+ cause.metaMessages?.length ? "" : [],
4068
+ "Offchain Gateway Call:",
4069
+ urls && [
4070
+ " Gateway URL(s):",
4071
+ ...urls.map((url) => ` ${getUrl(url)}`)
4072
+ ],
4073
+ ` Sender: ${sender}`,
4074
+ ` Data: ${data}`,
4075
+ ` Callback selector: ${callbackSelector}`,
4076
+ ` Extra data: ${extraData}`
4077
+ ].flat(),
4078
+ name: "OffchainLookupError"
4079
+ });
4080
+ }
4081
+ };
4082
+ var OffchainLookupResponseMalformedError = class extends BaseError3 {
4083
+ constructor({ result, url }) {
4084
+ super("Offchain gateway response is malformed. Response data must be a hex value.", {
4085
+ metaMessages: [
4086
+ `Gateway URL: ${getUrl(url)}`,
4087
+ `Response: ${stringify(result)}`
4088
+ ],
4089
+ name: "OffchainLookupResponseMalformedError"
4090
+ });
4091
+ }
4092
+ };
4093
+ var OffchainLookupSenderMismatchError = class extends BaseError3 {
4094
+ constructor({ sender, to }) {
4095
+ super("Reverted sender address does not match target contract address (`to`).", {
4096
+ metaMessages: [
4097
+ `Contract address: ${to}`,
4098
+ `OffchainLookup sender address: ${sender}`
4099
+ ],
4100
+ name: "OffchainLookupSenderMismatchError"
4101
+ });
4102
+ }
4103
+ };
4104
+
4105
+ // node_modules/viem/_esm/utils/address/isAddressEqual.js
4106
+ function isAddressEqual(a, b) {
4107
+ if (!isAddress(a, { strict: false }))
4108
+ throw new InvalidAddressError({ address: a });
4109
+ if (!isAddress(b, { strict: false }))
4110
+ throw new InvalidAddressError({ address: b });
4111
+ return a.toLowerCase() === b.toLowerCase();
4112
+ }
4113
+
4114
+ // node_modules/viem/_esm/utils/abi/decodeFunctionData.js
4115
+ function decodeFunctionData(parameters) {
4116
+ const { abi, data } = parameters;
4117
+ const signature = slice(data, 0, 4);
4118
+ const description = abi.find((x) => x.type === "function" && signature === toFunctionSelector(formatAbiItem2(x)));
4119
+ if (!description)
4120
+ throw new AbiFunctionSignatureNotFoundError(signature, {
4121
+ docsPath: "/docs/contract/decodeFunctionData"
4122
+ });
4123
+ return {
4124
+ functionName: description.name,
4125
+ args: "inputs" in description && description.inputs && description.inputs.length > 0 ? decodeAbiParameters(description.inputs, slice(data, 4)) : void 0
4126
+ };
4127
+ }
4128
+
4129
+ // node_modules/viem/_esm/utils/abi/encodeErrorResult.js
4130
+ var docsPath4 = "/docs/contract/encodeErrorResult";
4131
+ function encodeErrorResult(parameters) {
4132
+ const { abi, errorName, args } = parameters;
4133
+ let abiItem = abi[0];
4134
+ if (errorName) {
4135
+ const item = getAbiItem({ abi, args, name: errorName });
4136
+ if (!item)
4137
+ throw new AbiErrorNotFoundError(errorName, { docsPath: docsPath4 });
4138
+ abiItem = item;
4139
+ }
4140
+ if (abiItem.type !== "error")
4141
+ throw new AbiErrorNotFoundError(void 0, { docsPath: docsPath4 });
4142
+ const definition = formatAbiItem2(abiItem);
4143
+ const signature = toFunctionSelector(definition);
4144
+ let data = "0x";
4145
+ if (args && args.length > 0) {
4146
+ if (!abiItem.inputs)
4147
+ throw new AbiErrorInputsNotFoundError(abiItem.name, { docsPath: docsPath4 });
4148
+ data = encodeAbiParameters(abiItem.inputs, args);
4149
+ }
4150
+ return concatHex([signature, data]);
4151
+ }
4152
+
4153
+ // node_modules/viem/_esm/utils/abi/encodeFunctionResult.js
4154
+ var docsPath5 = "/docs/contract/encodeFunctionResult";
4155
+ function encodeFunctionResult(parameters) {
4156
+ const { abi, functionName, result } = parameters;
4157
+ let abiItem = abi[0];
4158
+ if (functionName) {
4159
+ const item = getAbiItem({ abi, name: functionName });
4160
+ if (!item)
4161
+ throw new AbiFunctionNotFoundError(functionName, { docsPath: docsPath5 });
4162
+ abiItem = item;
4163
+ }
4164
+ if (abiItem.type !== "function")
4165
+ throw new AbiFunctionNotFoundError(void 0, { docsPath: docsPath5 });
4166
+ if (!abiItem.outputs)
4167
+ throw new AbiFunctionOutputsNotFoundError(abiItem.name, { docsPath: docsPath5 });
4168
+ const values = (() => {
4169
+ if (abiItem.outputs.length === 0)
4170
+ return [];
4171
+ if (abiItem.outputs.length === 1)
4172
+ return [result];
4173
+ if (Array.isArray(result))
4174
+ return result;
4175
+ throw new InvalidArrayError(result);
4176
+ })();
4177
+ return encodeAbiParameters(abiItem.outputs, values);
4178
+ }
4179
+
4180
+ // node_modules/viem/_esm/utils/ens/localBatchGatewayRequest.js
4181
+ var localBatchGatewayUrl = "x-batch-gateway:true";
4182
+ async function localBatchGatewayRequest(parameters) {
4183
+ const { data, ccipRequest: ccipRequest2 } = parameters;
4184
+ const { args: [queries] } = decodeFunctionData({ abi: batchGatewayAbi, data });
4185
+ const failures = [];
4186
+ const responses = [];
4187
+ await Promise.all(queries.map(async (query, i) => {
4188
+ try {
4189
+ responses[i] = query.urls.includes(localBatchGatewayUrl) ? await localBatchGatewayRequest({ data: query.data, ccipRequest: ccipRequest2 }) : await ccipRequest2(query);
4190
+ failures[i] = false;
4191
+ } catch (err) {
4192
+ failures[i] = true;
4193
+ responses[i] = encodeError(err);
4194
+ }
4195
+ }));
4196
+ return encodeFunctionResult({
4197
+ abi: batchGatewayAbi,
4198
+ functionName: "query",
4199
+ result: [failures, responses]
4200
+ });
4201
+ }
4202
+ function encodeError(error) {
4203
+ if (error.name === "HttpRequestError" && error.status)
4204
+ return encodeErrorResult({
4205
+ abi: batchGatewayAbi,
4206
+ errorName: "HttpError",
4207
+ args: [error.status, error.shortMessage]
4208
+ });
4209
+ return encodeErrorResult({
4210
+ abi: [solidityError],
4211
+ errorName: "Error",
4212
+ args: ["shortMessage" in error ? error.shortMessage : error.message]
4213
+ });
4214
+ }
4215
+
4216
+ // node_modules/viem/_esm/utils/ccip.js
4217
+ var offchainLookupSignature = "0x556f1830";
4218
+ var offchainLookupAbiItem = {
4219
+ name: "OffchainLookup",
4220
+ type: "error",
4221
+ inputs: [
4222
+ {
4223
+ name: "sender",
4224
+ type: "address"
4225
+ },
4226
+ {
4227
+ name: "urls",
4228
+ type: "string[]"
4229
+ },
4230
+ {
4231
+ name: "callData",
4232
+ type: "bytes"
4233
+ },
4234
+ {
4235
+ name: "callbackFunction",
4236
+ type: "bytes4"
4237
+ },
4238
+ {
4239
+ name: "extraData",
4240
+ type: "bytes"
4241
+ }
4242
+ ]
4243
+ };
4244
+ async function offchainLookup(client, { blockNumber, blockTag, data, to }) {
4245
+ const { args } = decodeErrorResult({
4246
+ data,
4247
+ abi: [offchainLookupAbiItem]
4248
+ });
4249
+ const [sender, urls, callData, callbackSelector, extraData] = args;
4250
+ const { ccipRead } = client;
4251
+ const ccipRequest_ = ccipRead && typeof ccipRead?.request === "function" ? ccipRead.request : ccipRequest;
4252
+ try {
4253
+ if (!isAddressEqual(to, sender))
4254
+ throw new OffchainLookupSenderMismatchError({ sender, to });
4255
+ const result = urls.includes(localBatchGatewayUrl) ? await localBatchGatewayRequest({
4256
+ data: callData,
4257
+ ccipRequest: ccipRequest_
4258
+ }) : await ccipRequest_({ data: callData, sender, urls });
4259
+ const { data: data_ } = await call(client, {
4260
+ blockNumber,
4261
+ blockTag,
4262
+ data: concat([
4263
+ callbackSelector,
4264
+ encodeAbiParameters([{ type: "bytes" }, { type: "bytes" }], [result, extraData])
4265
+ ]),
4266
+ to
4267
+ });
4268
+ return data_;
4269
+ } catch (err) {
4270
+ throw new OffchainLookupError({
4271
+ callbackSelector,
4272
+ cause: err,
4273
+ data,
4274
+ extraData,
4275
+ sender,
4276
+ urls
4277
+ });
4278
+ }
4279
+ }
4280
+ async function ccipRequest({ data, sender, urls }) {
4281
+ let error = new Error("An unknown error occurred.");
4282
+ for (let i = 0; i < urls.length; i++) {
4283
+ const url = urls[i];
4284
+ const method = url.includes("{data}") ? "GET" : "POST";
4285
+ const body = method === "POST" ? { data, sender } : void 0;
4286
+ const headers = method === "POST" ? { "Content-Type": "application/json" } : {};
4287
+ try {
4288
+ const response = await fetch(url.replace("{sender}", sender.toLowerCase()).replace("{data}", data), {
4289
+ body: JSON.stringify(body),
4290
+ headers,
4291
+ method
4292
+ });
4293
+ let result;
4294
+ if (response.headers.get("Content-Type")?.startsWith("application/json")) {
4295
+ result = (await response.json()).data;
4296
+ } else {
4297
+ result = await response.text();
4298
+ }
4299
+ if (!response.ok) {
4300
+ error = new HttpRequestError({
4301
+ body,
4302
+ details: result?.error ? stringify(result.error) : response.statusText,
4303
+ headers: response.headers,
4304
+ status: response.status,
4305
+ url
4306
+ });
4307
+ continue;
4308
+ }
4309
+ if (!isHex(result)) {
4310
+ error = new OffchainLookupResponseMalformedError({
4311
+ result,
4312
+ url
4313
+ });
4314
+ continue;
4315
+ }
4316
+ return result;
4317
+ } catch (err) {
4318
+ error = new HttpRequestError({
4319
+ body,
4320
+ details: err.message,
4321
+ url
4322
+ });
4323
+ }
4324
+ }
4325
+ throw error;
4326
+ }
4327
+
4328
+ export {
4329
+ TransactionReceiptNotFoundError,
4330
+ offchainLookupSignature,
4331
+ offchainLookupAbiItem,
4332
+ offchainLookup,
4333
+ ccipRequest
4334
+ };
4335
+ //# sourceMappingURL=chunk-ZEQAXTUF.js.map