@tinycloud/cli 0.7.7-beta.6 → 0.7.7-beta.8

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