@dvmkit/dvm-cli 0.1.4 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/README.md +14 -0
  2. package/dist/{_esm-M2HUAA3B.js → _esm-MN4BUYV6.js} +56 -54
  3. package/dist/{accounts-S747UW3A.js → accounts-2WZE4N5F.js} +5 -5
  4. package/dist/actions-LR65XILR.js +244 -0
  5. package/dist/{ccip-XZ5F5J6R.js → ccip-JXYJSXTW.js} +3 -3
  6. package/dist/{chains-PINFXYUE.js → chains-LJ7XK6H3.js} +8 -8
  7. package/dist/{chunk-YZUBKHHA.js → chunk-2VVVWBQA.js} +471 -471
  8. package/dist/chunk-3SWX5BQP.js +66 -0
  9. package/dist/chunk-4JXFXP4Y.js +757 -0
  10. package/dist/{chunk-GIDSTROG.js → chunk-4NWEJTAW.js} +160 -158
  11. package/dist/{chunk-UXQCP26E.js → chunk-65EY7CT4.js} +2 -2
  12. package/dist/{chunk-6UGZAFIR.js → chunk-6CC6JGEU.js} +348 -18
  13. package/dist/{chunk-PHZHPRQE.js → chunk-6O27TEXD.js} +173 -173
  14. package/dist/{chunk-HPRIQEJS.js → chunk-7OK7MBT6.js} +19 -19
  15. package/dist/{chunk-7UPZZGC5.js → chunk-BECPI5H5.js} +193 -193
  16. package/dist/chunk-CJTE5TS3.js +1298 -0
  17. package/dist/{chunk-RWBYCM47.js → chunk-ECEM3ZAS.js} +10 -10
  18. package/dist/{chunk-ACNNU5RY.js → chunk-ECK465AY.js} +694 -565
  19. package/dist/{chunk-XGABM4H5.js → chunk-EGY4KDBW.js} +3822 -2012
  20. package/dist/{chunk-SLDVIXCS.js → chunk-EVQERRCP.js} +12 -12
  21. package/dist/{chunk-4AQ4G7L5.js → chunk-EZHT2RLJ.js} +383 -383
  22. package/dist/{chunk-IC6OXFYW.js → chunk-F55NNH2F.js} +63 -63
  23. package/dist/chunk-G5C6E6PJ.js +9063 -0
  24. package/dist/{chunk-6AJ7H2VX.js → chunk-GZWKCIYN.js} +213 -1281
  25. package/dist/{chunk-ZGXCK43G.js → chunk-LH3QPVN6.js} +8499 -8498
  26. package/dist/{chunk-MMJR6N3J.js → chunk-MLDUKBU3.js} +1368 -1368
  27. package/dist/chunk-N3UJT2NJ.js +3 -0
  28. package/dist/chunk-N7MGIK2U.js +61408 -0
  29. package/dist/{chunk-BZNZWRBB.js → chunk-OWJZYYMG.js} +11 -15
  30. package/dist/chunk-ZJYO7OLO.js +514 -0
  31. package/dist/{client-D3XFLWOK.js → client-OWIOFBKS.js} +18 -16
  32. package/dist/{dist-7MMV3EZA.js → dist-2G3QBGID.js} +11 -10
  33. package/dist/dvm.js +27046 -4414
  34. package/dist/esm-RQLHAH2K.js +5183 -0
  35. package/dist/internal-JDG52DJH.js +1230 -0
  36. package/dist/payout-reporter-3UB5WRCV-XTVZFIAO.js +17 -0
  37. package/dist/{pocket-refill-GDYSTECR.js → pocket-refill-QJMMD6QN.js} +29 -30
  38. package/dist/revenue-reporter-JIKUPXOK-TYUBTF4P.js +11 -0
  39. package/dist/{secp256k1-4YWQEMGF.js → secp256k1-JLZEQ2H7.js} +2 -2
  40. package/dist/tempo-lifecycle-SQL3KLEZ-AATA2SKI.js +28 -0
  41. package/dist/{tempo-wallet-5FEOI4CF.js → tempo-wallet-QOLEIPCV-SWCXRBDS.js} +2 -4
  42. package/dist/{x402-VNFA3DBY.js → x402-FTG2GRAQ-UGAUMUL6.js} +13 -24
  43. package/package.json +2 -10
  44. package/skills/dvm/SKILL.md +2 -1
  45. package/dist/channel-store-GOV7TEDN.js +0 -62
  46. package/dist/chunk-3PPOU55E.js +0 -312
  47. package/dist/chunk-3TBULV3F.js +0 -551
  48. package/dist/chunk-5BUV73FO.js +0 -2351
  49. package/dist/chunk-EY5K4BM3.js +0 -1780
  50. package/dist/chunk-G3RLVJF5.js +0 -19
  51. package/dist/chunk-KC4UPK44.js +0 -113
  52. package/dist/chunk-MTBCEXJ6.js +0 -4602
  53. package/dist/chunk-ONQMRWY3.js +0 -83
  54. package/dist/chunk-TO47XRK7.js +0 -24890
  55. package/dist/chunk-U5TNSUYW.js +0 -1757
  56. package/dist/chunk-UU6QMSTQ.js +0 -171
  57. package/dist/chunk-ZELLQI7F.js +0 -248
  58. package/dist/lifecycle-5RLM5JMN.js +0 -29
  59. package/dist/tempo-lifecycle-DHZPQTSB.js +0 -31
  60. package/dist/wallet-G3VOUCL4.js +0 -30
@@ -17,23 +17,7 @@ import {
17
17
  swap32IfBE,
18
18
  toBytes,
19
19
  u32
20
- } from "./chunk-HPRIQEJS.js";
21
-
22
- // node_modules/viem/_esm/utils/data/isHex.js
23
- function isHex(value, { strict = true } = {}) {
24
- if (!value)
25
- return false;
26
- if (typeof value !== "string")
27
- return false;
28
- return strict ? /^0x[0-9a-fA-F]*$/.test(value) : value.startsWith("0x");
29
- }
30
-
31
- // node_modules/viem/_esm/utils/data/size.js
32
- function size(value) {
33
- if (isHex(value, { strict: false }))
34
- return Math.ceil((value.length - 2) / 2);
35
- return value.length;
36
- }
20
+ } from "./chunk-7OK7MBT6.js";
37
21
 
38
22
  // node_modules/viem/_esm/errors/version.js
39
23
  var version = "2.55.11";
@@ -125,442 +109,119 @@ function walk(err, fn) {
125
109
  return fn ? null : err;
126
110
  }
127
111
 
128
- // node_modules/viem/_esm/utils/abi/formatAbiItem.js
129
- function formatAbiItem(abiItem, { includeName = false } = {}) {
130
- if (abiItem.type !== "function" && abiItem.type !== "event" && abiItem.type !== "error")
131
- throw new InvalidDefinitionTypeError(abiItem.type);
132
- return `${abiItem.name}(${formatAbiParams(abiItem.inputs, { includeName })})`;
133
- }
134
- function formatAbiParams(params, { includeName = false } = {}) {
135
- if (!params)
136
- return "";
137
- return params.map((param) => formatAbiParam(param, { includeName })).join(includeName ? ", " : ",");
138
- }
139
- function formatAbiParam(param, { includeName }) {
140
- if (param.type.startsWith("tuple")) {
141
- return `(${formatAbiParams(param.components, { includeName })})${param.type.slice("tuple".length)}`;
142
- }
143
- return param.type + (includeName && param.name ? ` ${param.name}` : "");
144
- }
145
-
146
- // node_modules/viem/_esm/errors/abi.js
147
- var AbiConstructorNotFoundError = class extends BaseError {
148
- constructor({ docsPath }) {
149
- super([
150
- "A constructor was not found on the ABI.",
151
- "Make sure you are using the correct ABI and that the constructor exists on it."
152
- ].join("\n"), {
153
- docsPath,
154
- name: "AbiConstructorNotFoundError"
155
- });
112
+ // node_modules/viem/_esm/errors/encoding.js
113
+ var IntegerOutOfRangeError = class extends BaseError {
114
+ constructor({ max, min, signed, size: size2, value }) {
115
+ super(`Number "${value}" is not in safe ${size2 ? `${size2 * 8}-bit ${signed ? "signed" : "unsigned"} ` : ""}integer range ${max ? `(${min} to ${max})` : `(above ${min})`}`, { name: "IntegerOutOfRangeError" });
156
116
  }
157
117
  };
158
- var AbiConstructorParamsNotFoundError = class extends BaseError {
159
- constructor({ docsPath }) {
160
- super([
161
- "Constructor arguments were provided (`args`), but a constructor parameters (`inputs`) were not found on the ABI.",
162
- "Make sure you are using the correct ABI, and that the `inputs` attribute on the constructor exists."
163
- ].join("\n"), {
164
- docsPath,
165
- name: "AbiConstructorParamsNotFoundError"
118
+ var InvalidBytesBooleanError = class extends BaseError {
119
+ constructor(bytes) {
120
+ super(`Bytes value "${bytes}" is not a valid boolean. The bytes array must contain a single byte of either a 0 or 1 value.`, {
121
+ name: "InvalidBytesBooleanError"
166
122
  });
167
123
  }
168
124
  };
169
- var AbiDecodingDataSizeInvalidError = class extends BaseError {
170
- constructor({ data, size: size2 }) {
171
- super([
172
- `Data size of ${size2} bytes is invalid.`,
173
- "Size must be in increments of 32 bytes (size % 32 === 0)."
174
- ].join("\n"), {
175
- metaMessages: [`Data: ${data} (${size2} bytes)`],
176
- name: "AbiDecodingDataSizeInvalidError"
177
- });
125
+ var InvalidHexBooleanError = class extends BaseError {
126
+ constructor(hex) {
127
+ super(`Hex value "${hex}" is not a valid boolean. The hex value must be "0x0" (false) or "0x1" (true).`, { name: "InvalidHexBooleanError" });
178
128
  }
179
129
  };
180
- var AbiDecodingDataSizeTooSmallError = class extends BaseError {
181
- constructor({ data, params, size: size2 }) {
182
- super([`Data size of ${size2} bytes is too small for given parameters.`].join("\n"), {
183
- metaMessages: [
184
- `Params: (${formatAbiParams(params, { includeName: true })})`,
185
- `Data: ${data} (${size2} bytes)`
186
- ],
187
- name: "AbiDecodingDataSizeTooSmallError"
188
- });
189
- Object.defineProperty(this, "data", {
190
- enumerable: true,
191
- configurable: true,
192
- writable: true,
193
- value: void 0
194
- });
195
- Object.defineProperty(this, "params", {
196
- enumerable: true,
197
- configurable: true,
198
- writable: true,
199
- value: void 0
200
- });
201
- Object.defineProperty(this, "size", {
202
- enumerable: true,
203
- configurable: true,
204
- writable: true,
205
- value: void 0
206
- });
207
- this.data = data;
208
- this.params = params;
209
- this.size = size2;
130
+ var InvalidHexValueError = class extends BaseError {
131
+ constructor(value) {
132
+ super(`Hex value "${value}" is an odd length (${value.length}). It must be an even length.`, { name: "InvalidHexValueError" });
210
133
  }
211
134
  };
212
- var AbiDecodingZeroDataError = class extends BaseError {
213
- constructor({ cause } = {}) {
214
- super('Cannot decode zero data ("0x") with ABI parameters.', {
215
- name: "AbiDecodingZeroDataError",
216
- cause
135
+ var RlpDepthLimitExceededError = class extends BaseError {
136
+ constructor({ limit }) {
137
+ super(`RLP depth limit of \`${limit}\` exceeded.`, {
138
+ name: "RlpDepthLimitExceededError"
217
139
  });
218
140
  }
219
141
  };
220
- var AbiEncodingArrayLengthMismatchError = class extends BaseError {
221
- constructor({ expectedLength, givenLength, type }) {
222
- super([
223
- `ABI encoding array length mismatch for type ${type}.`,
224
- `Expected length: ${expectedLength}`,
225
- `Given length: ${givenLength}`
226
- ].join("\n"), { name: "AbiEncodingArrayLengthMismatchError" });
227
- }
228
- };
229
- var AbiEncodingBytesSizeMismatchError = class extends BaseError {
230
- constructor({ expectedSize, value }) {
231
- super(`Size of bytes "${value}" (bytes${size(value)}) does not match expected size (bytes${expectedSize}).`, { name: "AbiEncodingBytesSizeMismatchError" });
232
- }
233
- };
234
- var AbiEncodingLengthMismatchError = class extends BaseError {
235
- constructor({ expectedLength, givenLength }) {
236
- super([
237
- "ABI encoding params/values length mismatch.",
238
- `Expected length (params): ${expectedLength}`,
239
- `Given length (values): ${givenLength}`
240
- ].join("\n"), { name: "AbiEncodingLengthMismatchError" });
142
+ var RlpListBoundaryExceededError = class extends BaseError {
143
+ constructor({ consumed, declared }) {
144
+ super(`RLP list items consumed \`${consumed}\` bytes but the list declared a length of \`${declared}\`.`, { name: "RlpListBoundaryExceededError" });
241
145
  }
242
146
  };
243
- var AbiErrorInputsNotFoundError = class extends BaseError {
244
- constructor(errorName, { docsPath }) {
245
- super([
246
- `Arguments (\`args\`) were provided to "${errorName}", but "${errorName}" on the ABI does not contain any parameters (\`inputs\`).`,
247
- "Cannot encode error result without knowing what the parameter types are.",
248
- "Make sure you are using the correct ABI and that the inputs exist on it."
249
- ].join("\n"), {
250
- docsPath,
251
- name: "AbiErrorInputsNotFoundError"
252
- });
147
+ var RlpTrailingBytesError = class extends BaseError {
148
+ constructor({ count }) {
149
+ super(`RLP payload encodes a single item, but \`${count}\` trailing ${count === 1 ? "byte remains" : "bytes remain"}.`, { name: "RlpTrailingBytesError" });
253
150
  }
254
151
  };
255
- var AbiErrorNotFoundError = class extends BaseError {
256
- constructor(errorName, { docsPath } = {}) {
257
- super([
258
- `Error ${errorName ? `"${errorName}" ` : ""}not found on ABI.`,
259
- "Make sure you are using the correct ABI and that the error exists on it."
260
- ].join("\n"), {
261
- docsPath,
262
- name: "AbiErrorNotFoundError"
263
- });
152
+ var SizeOverflowError = class extends BaseError {
153
+ constructor({ givenSize, maxSize }) {
154
+ super(`Size cannot exceed ${maxSize} bytes. Given size: ${givenSize} bytes.`, { name: "SizeOverflowError" });
264
155
  }
265
156
  };
266
- var AbiErrorSignatureNotFoundError = class extends BaseError {
267
- constructor(signature, { docsPath, cause }) {
268
- super([
269
- `Encoded error signature "${signature}" not found on ABI.`,
270
- "Make sure you are using the correct ABI and that the error exists on it.",
271
- `You can look up the decoded signature here: https://4byte.sourcify.dev/?q=${signature}.`
272
- ].join("\n"), {
273
- docsPath,
274
- name: "AbiErrorSignatureNotFoundError",
275
- cause
276
- });
277
- Object.defineProperty(this, "signature", {
278
- enumerable: true,
279
- configurable: true,
280
- writable: true,
281
- value: void 0
282
- });
283
- this.signature = signature;
157
+
158
+ // node_modules/viem/_esm/errors/data.js
159
+ var SliceOffsetOutOfBoundsError = class extends BaseError {
160
+ constructor({ offset, position, size: size2 }) {
161
+ super(`Slice ${position === "start" ? "starting" : "ending"} at offset "${offset}" is out-of-bounds (size: ${size2}).`, { name: "SliceOffsetOutOfBoundsError" });
284
162
  }
285
163
  };
286
- var AbiEventSignatureEmptyTopicsError = class extends BaseError {
287
- constructor({ docsPath }) {
288
- super("Cannot extract event signature from empty topics.", {
289
- docsPath,
290
- name: "AbiEventSignatureEmptyTopicsError"
291
- });
164
+ var SizeExceedsPaddingSizeError = class extends BaseError {
165
+ constructor({ size: size2, targetSize, type }) {
166
+ super(`${type.charAt(0).toUpperCase()}${type.slice(1).toLowerCase()} size (${size2}) exceeds padding size (${targetSize}).`, { name: "SizeExceedsPaddingSizeError" });
292
167
  }
293
168
  };
294
- var AbiEventSignatureNotFoundError = class extends BaseError {
295
- constructor(signature, { docsPath }) {
296
- super([
297
- `Encoded event signature "${signature}" not found on ABI.`,
298
- "Make sure you are using the correct ABI and that the event exists on it.",
299
- `You can look up the signature here: https://4byte.sourcify.dev/?q=${signature}.`
300
- ].join("\n"), {
301
- docsPath,
302
- name: "AbiEventSignatureNotFoundError"
303
- });
169
+ var InvalidBytesLengthError = class extends BaseError {
170
+ constructor({ size: size2, targetSize, type }) {
171
+ super(`${type.charAt(0).toUpperCase()}${type.slice(1).toLowerCase()} is expected to be ${targetSize} ${type} long, but is ${size2} ${type} long.`, { name: "InvalidBytesLengthError" });
304
172
  }
305
173
  };
306
- var AbiEventNotFoundError = class extends BaseError {
307
- constructor(eventName, { docsPath } = {}) {
308
- super([
309
- `Event ${eventName ? `"${eventName}" ` : ""}not found on ABI.`,
310
- "Make sure you are using the correct ABI and that the event exists on it."
311
- ].join("\n"), {
312
- docsPath,
313
- name: "AbiEventNotFoundError"
174
+
175
+ // node_modules/viem/_esm/utils/data/pad.js
176
+ function pad(hexOrBytes, { dir, size: size2 = 32 } = {}) {
177
+ if (typeof hexOrBytes === "string")
178
+ return padHex(hexOrBytes, { dir, size: size2 });
179
+ return padBytes(hexOrBytes, { dir, size: size2 });
180
+ }
181
+ function padHex(hex_, { dir, size: size2 = 32 } = {}) {
182
+ if (size2 === null)
183
+ return hex_;
184
+ const hex = hex_.replace("0x", "");
185
+ if (hex.length > size2 * 2)
186
+ throw new SizeExceedsPaddingSizeError({
187
+ size: Math.ceil(hex.length / 2),
188
+ targetSize: size2,
189
+ type: "hex"
314
190
  });
315
- }
316
- };
317
- var AbiFunctionNotFoundError = class extends BaseError {
318
- constructor(functionName, { docsPath } = {}) {
319
- super([
320
- `Function ${functionName ? `"${functionName}" ` : ""}not found on ABI.`,
321
- "Make sure you are using the correct ABI and that the function exists on it."
322
- ].join("\n"), {
323
- docsPath,
324
- name: "AbiFunctionNotFoundError"
191
+ return `0x${hex[dir === "right" ? "padEnd" : "padStart"](size2 * 2, "0")}`;
192
+ }
193
+ function padBytes(bytes, { dir, size: size2 = 32 } = {}) {
194
+ if (size2 === null)
195
+ return bytes;
196
+ if (bytes.length > size2)
197
+ throw new SizeExceedsPaddingSizeError({
198
+ size: bytes.length,
199
+ targetSize: size2,
200
+ type: "bytes"
325
201
  });
326
- }
327
- };
328
- var AbiFunctionOutputsNotFoundError = class extends BaseError {
329
- constructor(functionName, { docsPath }) {
330
- super([
331
- `Function "${functionName}" does not contain any \`outputs\` on ABI.`,
332
- "Cannot decode function result without knowing what the parameter types are.",
333
- "Make sure you are using the correct ABI and that the function exists on it."
334
- ].join("\n"), {
335
- docsPath,
336
- name: "AbiFunctionOutputsNotFoundError"
337
- });
338
- }
339
- };
340
- var AbiFunctionSignatureNotFoundError = class extends BaseError {
341
- constructor(signature, { docsPath }) {
342
- super([
343
- `Encoded function signature "${signature}" not found on ABI.`,
344
- "Make sure you are using the correct ABI and that the function exists on it.",
345
- `You can look up the signature here: https://4byte.sourcify.dev/?q=${signature}.`
346
- ].join("\n"), {
347
- docsPath,
348
- name: "AbiFunctionSignatureNotFoundError"
349
- });
350
- }
351
- };
352
- var AbiItemAmbiguityError = class extends BaseError {
353
- constructor(x, y) {
354
- super("Found ambiguous types in overloaded ABI items.", {
355
- metaMessages: [
356
- `\`${x.type}\` in \`${formatAbiItem(x.abiItem)}\`, and`,
357
- `\`${y.type}\` in \`${formatAbiItem(y.abiItem)}\``,
358
- "",
359
- "These types encode differently and cannot be distinguished at runtime.",
360
- "Remove one of the ambiguous items in the ABI."
361
- ],
362
- name: "AbiItemAmbiguityError"
363
- });
364
- }
365
- };
366
- var BytesSizeMismatchError = class extends BaseError {
367
- constructor({ expectedSize, givenSize }) {
368
- super(`Expected bytes${expectedSize}, got bytes${givenSize}.`, {
369
- name: "BytesSizeMismatchError"
370
- });
371
- }
372
- };
373
- var DecodeLogDataMismatch = class extends BaseError {
374
- constructor({ abiItem, data, params, size: size2 }) {
375
- super([
376
- `Data size of ${size2} bytes is too small for non-indexed event parameters.`
377
- ].join("\n"), {
378
- metaMessages: [
379
- `Params: (${formatAbiParams(params, { includeName: true })})`,
380
- `Data: ${data} (${size2} bytes)`
381
- ],
382
- name: "DecodeLogDataMismatch"
383
- });
384
- Object.defineProperty(this, "abiItem", {
385
- enumerable: true,
386
- configurable: true,
387
- writable: true,
388
- value: void 0
389
- });
390
- Object.defineProperty(this, "data", {
391
- enumerable: true,
392
- configurable: true,
393
- writable: true,
394
- value: void 0
395
- });
396
- Object.defineProperty(this, "params", {
397
- enumerable: true,
398
- configurable: true,
399
- writable: true,
400
- value: void 0
401
- });
402
- Object.defineProperty(this, "size", {
403
- enumerable: true,
404
- configurable: true,
405
- writable: true,
406
- value: void 0
407
- });
408
- this.abiItem = abiItem;
409
- this.data = data;
410
- this.params = params;
411
- this.size = size2;
412
- }
413
- };
414
- var DecodeLogTopicsMismatch = class extends BaseError {
415
- constructor({ abiItem, param }) {
416
- super([
417
- `Expected a topic for indexed event parameter${param.name ? ` "${param.name}"` : ""} on event "${formatAbiItem(abiItem, { includeName: true })}".`
418
- ].join("\n"), { name: "DecodeLogTopicsMismatch" });
419
- Object.defineProperty(this, "abiItem", {
420
- enumerable: true,
421
- configurable: true,
422
- writable: true,
423
- value: void 0
424
- });
425
- this.abiItem = abiItem;
426
- }
427
- };
428
- var InvalidAbiEncodingTypeError = class extends BaseError {
429
- constructor(type, { docsPath }) {
430
- super([
431
- `Type "${type}" is not a valid encoding type.`,
432
- "Please provide a valid ABI type."
433
- ].join("\n"), { docsPath, name: "InvalidAbiEncodingType" });
434
- }
435
- };
436
- var InvalidAbiDecodingTypeError = class extends BaseError {
437
- constructor(type, { docsPath }) {
438
- super([
439
- `Type "${type}" is not a valid decoding type.`,
440
- "Please provide a valid ABI type."
441
- ].join("\n"), { docsPath, name: "InvalidAbiDecodingType" });
442
- }
443
- };
444
- var InvalidArrayError = class extends BaseError {
445
- constructor(value) {
446
- super([`Value "${value}" is not a valid array.`].join("\n"), {
447
- name: "InvalidArrayError"
448
- });
449
- }
450
- };
451
- var InvalidDefinitionTypeError = class extends BaseError {
452
- constructor(type) {
453
- super([
454
- `"${type}" is not a valid definition type.`,
455
- 'Valid types: "function", "event", "error"'
456
- ].join("\n"), { name: "InvalidDefinitionTypeError" });
457
- }
458
- };
459
- var UnsupportedPackedAbiType = class extends BaseError {
460
- constructor(type) {
461
- super(`Type "${type}" is not supported for packed encoding.`, {
462
- name: "UnsupportedPackedAbiType"
463
- });
464
- }
465
- };
466
-
467
- // node_modules/viem/_esm/errors/data.js
468
- var SliceOffsetOutOfBoundsError = class extends BaseError {
469
- constructor({ offset, position, size: size2 }) {
470
- super(`Slice ${position === "start" ? "starting" : "ending"} at offset "${offset}" is out-of-bounds (size: ${size2}).`, { name: "SliceOffsetOutOfBoundsError" });
471
- }
472
- };
473
- var SizeExceedsPaddingSizeError = class extends BaseError {
474
- constructor({ size: size2, targetSize, type }) {
475
- super(`${type.charAt(0).toUpperCase()}${type.slice(1).toLowerCase()} size (${size2}) exceeds padding size (${targetSize}).`, { name: "SizeExceedsPaddingSizeError" });
476
- }
477
- };
478
- var InvalidBytesLengthError = class extends BaseError {
479
- constructor({ size: size2, targetSize, type }) {
480
- super(`${type.charAt(0).toUpperCase()}${type.slice(1).toLowerCase()} is expected to be ${targetSize} ${type} long, but is ${size2} ${type} long.`, { name: "InvalidBytesLengthError" });
481
- }
482
- };
483
-
484
- // node_modules/viem/_esm/utils/data/pad.js
485
- function pad(hexOrBytes, { dir, size: size2 = 32 } = {}) {
486
- if (typeof hexOrBytes === "string")
487
- return padHex(hexOrBytes, { dir, size: size2 });
488
- return padBytes(hexOrBytes, { dir, size: size2 });
489
- }
490
- function padHex(hex_, { dir, size: size2 = 32 } = {}) {
491
- if (size2 === null)
492
- return hex_;
493
- const hex = hex_.replace("0x", "");
494
- if (hex.length > size2 * 2)
495
- throw new SizeExceedsPaddingSizeError({
496
- size: Math.ceil(hex.length / 2),
497
- targetSize: size2,
498
- type: "hex"
499
- });
500
- return `0x${hex[dir === "right" ? "padEnd" : "padStart"](size2 * 2, "0")}`;
501
- }
502
- function padBytes(bytes, { dir, size: size2 = 32 } = {}) {
503
- if (size2 === null)
504
- return bytes;
505
- if (bytes.length > size2)
506
- throw new SizeExceedsPaddingSizeError({
507
- size: bytes.length,
508
- targetSize: size2,
509
- type: "bytes"
510
- });
511
- const paddedBytes = new Uint8Array(size2);
512
- for (let i = 0; i < size2; i++) {
513
- const padEnd = dir === "right";
514
- paddedBytes[padEnd ? i : size2 - i - 1] = bytes[padEnd ? i : bytes.length - i - 1];
202
+ const paddedBytes = new Uint8Array(size2);
203
+ for (let i = 0; i < size2; i++) {
204
+ const padEnd = dir === "right";
205
+ paddedBytes[padEnd ? i : size2 - i - 1] = bytes[padEnd ? i : bytes.length - i - 1];
515
206
  }
516
207
  return paddedBytes;
517
208
  }
518
209
 
519
- // node_modules/viem/_esm/errors/encoding.js
520
- var IntegerOutOfRangeError = class extends BaseError {
521
- constructor({ max, min, signed, size: size2, value }) {
522
- super(`Number "${value}" is not in safe ${size2 ? `${size2 * 8}-bit ${signed ? "signed" : "unsigned"} ` : ""}integer range ${max ? `(${min} to ${max})` : `(above ${min})`}`, { name: "IntegerOutOfRangeError" });
523
- }
524
- };
525
- var InvalidBytesBooleanError = class extends BaseError {
526
- constructor(bytes) {
527
- super(`Bytes value "${bytes}" is not a valid boolean. The bytes array must contain a single byte of either a 0 or 1 value.`, {
528
- name: "InvalidBytesBooleanError"
529
- });
530
- }
531
- };
532
- var InvalidHexBooleanError = class extends BaseError {
533
- constructor(hex) {
534
- super(`Hex value "${hex}" is not a valid boolean. The hex value must be "0x0" (false) or "0x1" (true).`, { name: "InvalidHexBooleanError" });
535
- }
536
- };
537
- var InvalidHexValueError = class extends BaseError {
538
- constructor(value) {
539
- super(`Hex value "${value}" is an odd length (${value.length}). It must be an even length.`, { name: "InvalidHexValueError" });
540
- }
541
- };
542
- var RlpDepthLimitExceededError = class extends BaseError {
543
- constructor({ limit }) {
544
- super(`RLP depth limit of \`${limit}\` exceeded.`, {
545
- name: "RlpDepthLimitExceededError"
546
- });
547
- }
548
- };
549
- var RlpListBoundaryExceededError = class extends BaseError {
550
- constructor({ consumed, declared }) {
551
- super(`RLP list items consumed \`${consumed}\` bytes but the list declared a length of \`${declared}\`.`, { name: "RlpListBoundaryExceededError" });
552
- }
553
- };
554
- var RlpTrailingBytesError = class extends BaseError {
555
- constructor({ count }) {
556
- super(`RLP payload encodes a single item, but \`${count}\` trailing ${count === 1 ? "byte remains" : "bytes remain"}.`, { name: "RlpTrailingBytesError" });
557
- }
558
- };
559
- var SizeOverflowError = class extends BaseError {
560
- constructor({ givenSize, maxSize }) {
561
- super(`Size cannot exceed ${maxSize} bytes. Given size: ${givenSize} bytes.`, { name: "SizeOverflowError" });
562
- }
563
- };
210
+ // node_modules/viem/_esm/utils/data/isHex.js
211
+ function isHex(value, { strict = true } = {}) {
212
+ if (!value)
213
+ return false;
214
+ if (typeof value !== "string")
215
+ return false;
216
+ return strict ? /^0x[0-9a-fA-F]*$/.test(value) : value.startsWith("0x");
217
+ }
218
+
219
+ // node_modules/viem/_esm/utils/data/size.js
220
+ function size(value) {
221
+ if (isHex(value, { strict: false }))
222
+ return Math.ceil((value.length - 2) / 2);
223
+ return value.length;
224
+ }
564
225
 
565
226
  // node_modules/viem/_esm/utils/data/trim.js
566
227
  function trim(hexOrBytes, { dir = "left" } = {}) {
@@ -581,13 +242,81 @@ function trim(hexOrBytes, { dir = "left" } = {}) {
581
242
  return data;
582
243
  }
583
244
 
584
- // node_modules/viem/_esm/utils/encoding/toHex.js
585
- var hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_v, i) => i.toString(16).padStart(2, "0"));
586
- function toHex(value, opts = {}) {
587
- if (typeof value === "number" || typeof value === "bigint")
588
- return numberToHex(value, opts);
589
- if (typeof value === "string") {
590
- return stringToHex(value, opts);
245
+ // node_modules/viem/_esm/utils/encoding/fromHex.js
246
+ function assertSize(hexOrBytes, { size: size2 }) {
247
+ if (size(hexOrBytes) > size2)
248
+ throw new SizeOverflowError({
249
+ givenSize: size(hexOrBytes),
250
+ maxSize: size2
251
+ });
252
+ }
253
+ function fromHex(hex, toOrOpts) {
254
+ const opts = typeof toOrOpts === "string" ? { to: toOrOpts } : toOrOpts;
255
+ const to = opts.to;
256
+ if (to === "number")
257
+ return hexToNumber(hex, opts);
258
+ if (to === "bigint")
259
+ return hexToBigInt(hex, opts);
260
+ if (to === "string")
261
+ return hexToString(hex, opts);
262
+ if (to === "boolean")
263
+ return hexToBool(hex, opts);
264
+ return hexToBytes(hex, opts);
265
+ }
266
+ function hexToBigInt(hex, opts = {}) {
267
+ const { signed } = opts;
268
+ if (opts.size)
269
+ assertSize(hex, { size: opts.size });
270
+ const value = BigInt(hex);
271
+ if (!signed)
272
+ return value;
273
+ const size2 = (hex.length - 2) / 2;
274
+ const max = (1n << BigInt(size2) * 8n - 1n) - 1n;
275
+ if (value <= max)
276
+ return value;
277
+ return value - BigInt(`0x${"f".padStart(size2 * 2, "f")}`) - 1n;
278
+ }
279
+ function hexToBool(hex_, opts = {}) {
280
+ let hex = hex_;
281
+ if (opts.size) {
282
+ assertSize(hex, { size: opts.size });
283
+ hex = trim(hex);
284
+ }
285
+ if (trim(hex) === "0x00")
286
+ return false;
287
+ if (trim(hex) === "0x01")
288
+ return true;
289
+ throw new InvalidHexBooleanError(hex);
290
+ }
291
+ function hexToNumber(hex, opts = {}) {
292
+ const value = hexToBigInt(hex, opts);
293
+ const number = Number(value);
294
+ if (!Number.isSafeInteger(number))
295
+ throw new IntegerOutOfRangeError({
296
+ max: `${Number.MAX_SAFE_INTEGER}`,
297
+ min: `${Number.MIN_SAFE_INTEGER}`,
298
+ signed: opts.signed,
299
+ size: opts.size,
300
+ value: `${value}n`
301
+ });
302
+ return number;
303
+ }
304
+ function hexToString(hex, opts = {}) {
305
+ let bytes = hexToBytes(hex);
306
+ if (opts.size) {
307
+ assertSize(bytes, { size: opts.size });
308
+ bytes = trim(bytes, { dir: "right" });
309
+ }
310
+ return new TextDecoder().decode(bytes);
311
+ }
312
+
313
+ // node_modules/viem/_esm/utils/encoding/toHex.js
314
+ var hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_v, i) => i.toString(16).padStart(2, "0"));
315
+ function toHex(value, opts = {}) {
316
+ if (typeof value === "number" || typeof value === "bigint")
317
+ return numberToHex(value, opts);
318
+ if (typeof value === "string") {
319
+ return stringToHex(value, opts);
591
320
  }
592
321
  if (typeof value === "boolean")
593
322
  return boolToHex(value, opts);
@@ -718,73 +447,18 @@ function stringToBytes(value, opts = {}) {
718
447
  return bytes;
719
448
  }
720
449
 
721
- // node_modules/viem/_esm/utils/encoding/fromHex.js
722
- function assertSize(hexOrBytes, { size: size2 }) {
723
- if (size(hexOrBytes) > size2)
724
- throw new SizeOverflowError({
725
- givenSize: size(hexOrBytes),
726
- maxSize: size2
727
- });
728
- }
729
- function fromHex(hex, toOrOpts) {
730
- const opts = typeof toOrOpts === "string" ? { to: toOrOpts } : toOrOpts;
731
- const to = opts.to;
732
- if (to === "number")
733
- return hexToNumber(hex, opts);
734
- if (to === "bigint")
735
- return hexToBigInt(hex, opts);
736
- if (to === "string")
737
- return hexToString(hex, opts);
738
- if (to === "boolean")
739
- return hexToBool(hex, opts);
740
- return hexToBytes(hex, opts);
741
- }
742
- function hexToBigInt(hex, opts = {}) {
743
- const { signed } = opts;
744
- if (opts.size)
745
- assertSize(hex, { size: opts.size });
746
- const value = BigInt(hex);
747
- if (!signed)
748
- return value;
749
- const size2 = (hex.length - 2) / 2;
750
- const max = (1n << BigInt(size2) * 8n - 1n) - 1n;
751
- if (value <= max)
752
- return value;
753
- return value - BigInt(`0x${"f".padStart(size2 * 2, "f")}`) - 1n;
754
- }
755
- function hexToBool(hex_, opts = {}) {
756
- let hex = hex_;
757
- if (opts.size) {
758
- assertSize(hex, { size: opts.size });
759
- hex = trim(hex);
760
- }
761
- if (trim(hex) === "0x00")
762
- return false;
763
- if (trim(hex) === "0x01")
764
- return true;
765
- throw new InvalidHexBooleanError(hex);
766
- }
767
- function hexToNumber(hex, opts = {}) {
768
- const value = hexToBigInt(hex, opts);
769
- const number = Number(value);
770
- if (!Number.isSafeInteger(number))
771
- throw new IntegerOutOfRangeError({
772
- max: `${Number.MAX_SAFE_INTEGER}`,
773
- min: `${Number.MIN_SAFE_INTEGER}`,
774
- signed: opts.signed,
775
- size: opts.size,
776
- value: `${value}n`
450
+ // node_modules/viem/_esm/errors/address.js
451
+ var InvalidAddressError = class extends BaseError {
452
+ constructor({ address }) {
453
+ super(`Address "${address}" is invalid.`, {
454
+ metaMessages: [
455
+ "- Address must be a hex value of 20 bytes (40 hex characters).",
456
+ "- Address must match its checksum counterpart."
457
+ ],
458
+ name: "InvalidAddressError"
777
459
  });
778
- return number;
779
- }
780
- function hexToString(hex, opts = {}) {
781
- let bytes = hexToBytes(hex);
782
- if (opts.size) {
783
- assertSize(bytes, { size: opts.size });
784
- bytes = trim(bytes, { dir: "right" });
785
460
  }
786
- return new TextDecoder().decode(bytes);
787
- }
461
+ };
788
462
 
789
463
  // node_modules/viem/node_modules/@noble/hashes/esm/sha3.js
790
464
  var _0n = BigInt(0);
@@ -976,19 +650,6 @@ function keccak256(value, to_) {
976
650
  return toHex(bytes);
977
651
  }
978
652
 
979
- // node_modules/viem/_esm/errors/address.js
980
- var InvalidAddressError = class extends BaseError {
981
- constructor({ address }) {
982
- super(`Address "${address}" is invalid.`, {
983
- metaMessages: [
984
- "- Address must be a hex value of 20 bytes (40 hex characters).",
985
- "- Address must match its checksum counterpart."
986
- ],
987
- name: "InvalidAddressError"
988
- });
989
- }
990
- };
991
-
992
653
  // node_modules/viem/_esm/utils/lru.js
993
654
  var LruMap = class extends Map {
994
655
  constructor(size2) {
@@ -1092,919 +753,1270 @@ function concatHex(values) {
1092
753
  return `0x${values.reduce((acc, x) => acc + x.replace("0x", ""), "")}`;
1093
754
  }
1094
755
 
1095
- // node_modules/viem/_esm/utils/data/slice.js
1096
- function slice(value, start, end, { strict } = {}) {
1097
- if (isHex(value, { strict: false }))
1098
- return sliceHex(value, start, end, {
1099
- strict
1100
- });
1101
- return sliceBytes(value, start, end, {
1102
- strict
1103
- });
756
+ // node_modules/viem/_esm/utils/unit/Value.js
757
+ var exponents = {
758
+ wei: 0,
759
+ gwei: 9,
760
+ szabo: 12,
761
+ finney: 15,
762
+ ether: 18
763
+ };
764
+ function format(value, decimals = 0) {
765
+ if (!Number.isInteger(decimals) || decimals < 0)
766
+ throw new InvalidDecimalsError({ decimals });
767
+ let display = value.toString();
768
+ const negative = display.startsWith("-");
769
+ if (negative)
770
+ display = display.slice(1);
771
+ display = display.padStart(decimals, "0");
772
+ let [integer, fraction] = [
773
+ display.slice(0, display.length - decimals),
774
+ display.slice(display.length - decimals)
775
+ ];
776
+ fraction = fraction.replace(/(0+)$/, "");
777
+ return `${negative ? "-" : ""}${integer || "0"}${fraction ? `.${fraction}` : ""}`;
1104
778
  }
1105
- function assertStartOffset(value, start) {
1106
- if (typeof start === "number" && start > 0 && start > size(value) - 1)
1107
- throw new SliceOffsetOutOfBoundsError({
1108
- offset: start,
1109
- position: "start",
1110
- size: size(value)
1111
- });
779
+ function formatEther(wei, unit = "wei") {
780
+ return format(wei, exponents.ether - exponents[unit]);
1112
781
  }
1113
- function assertEndOffset(value, start, end) {
1114
- if (typeof start === "number" && typeof end === "number" && size(value) !== end - start) {
1115
- throw new SliceOffsetOutOfBoundsError({
1116
- offset: end,
1117
- position: "end",
1118
- size: size(value)
1119
- });
1120
- }
782
+ function formatGwei(wei, unit = "wei") {
783
+ return format(wei, exponents.gwei - exponents[unit]);
1121
784
  }
1122
- function sliceBytes(value_, start, end, { strict } = {}) {
1123
- assertStartOffset(value_, start);
1124
- const value = value_.slice(start, end);
1125
- if (strict)
1126
- assertEndOffset(value, start, end);
1127
- return value;
785
+ function from(value, decimals = 0) {
786
+ if (!Number.isInteger(decimals) || decimals < 0)
787
+ throw new InvalidDecimalsError({ decimals });
788
+ if (!/^-?(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)$/.test(value))
789
+ throw new InvalidDecimalNumberError({ value });
790
+ let [integer = "", fraction = "0"] = value.split(".");
791
+ const negative = integer.startsWith("-");
792
+ if (negative)
793
+ integer = integer.slice(1);
794
+ if (integer === "")
795
+ integer = "0";
796
+ fraction = fraction.replace(/(0+)$/, "");
797
+ if (decimals === 0) {
798
+ if (fraction.length > 0 && Number.parseInt(fraction[0], 10) >= 5)
799
+ integer = `${BigInt(integer) + 1n}`;
800
+ fraction = "";
801
+ } else if (fraction.length > decimals) {
802
+ const left = fraction.slice(0, decimals);
803
+ const roundDigit = Number.parseInt(fraction.slice(decimals, decimals + 1), 10);
804
+ if (roundDigit >= 5) {
805
+ const carried = carry(left);
806
+ if (carried.length > decimals) {
807
+ fraction = carried.slice(1);
808
+ integer = `${BigInt(integer) + 1n}`;
809
+ } else {
810
+ fraction = carried;
811
+ }
812
+ } else {
813
+ fraction = left;
814
+ }
815
+ } else {
816
+ fraction = fraction.padEnd(decimals, "0");
817
+ }
818
+ return BigInt(`${negative ? "-" : ""}${integer}${fraction}`);
1128
819
  }
1129
- function sliceHex(value_, start, end, { strict } = {}) {
1130
- assertStartOffset(value_, start);
1131
- const value = `0x${value_.replace("0x", "").slice((start ?? 0) * 2, (end ?? value_.length) * 2)}`;
1132
- if (strict)
1133
- assertEndOffset(value, start, end);
1134
- return value;
820
+ function carry(digits) {
821
+ const out = digits.split("");
822
+ let i = out.length - 1;
823
+ while (i >= 0) {
824
+ const d = Number.parseInt(out[i], 10) + 1;
825
+ if (d < 10) {
826
+ out[i] = String(d);
827
+ return out.join("");
828
+ }
829
+ out[i] = "0";
830
+ i--;
831
+ }
832
+ return `1${out.join("")}`;
1135
833
  }
834
+ function fromEther(ether, unit = "wei") {
835
+ return from(ether, exponents.ether - exponents[unit]);
836
+ }
837
+ function fromGwei(gwei, unit = "wei") {
838
+ return from(gwei, exponents.gwei - exponents[unit]);
839
+ }
840
+ var InvalidDecimalNumberError = class extends Error {
841
+ constructor({ value }) {
842
+ super(`Value \`${value}\` is not a valid decimal number.`);
843
+ Object.defineProperty(this, "name", {
844
+ enumerable: true,
845
+ configurable: true,
846
+ writable: true,
847
+ value: "Value.InvalidDecimalNumberError"
848
+ });
849
+ }
850
+ };
851
+ var InvalidDecimalsError = class extends Error {
852
+ constructor({ decimals }) {
853
+ super(`\`decimals\` must be a non-negative integer. Got \`${decimals}\`.`);
854
+ Object.defineProperty(this, "name", {
855
+ enumerable: true,
856
+ configurable: true,
857
+ writable: true,
858
+ value: "Value.InvalidDecimalsError"
859
+ });
860
+ }
861
+ };
1136
862
 
1137
- // node_modules/viem/_esm/utils/regex.js
1138
- var arrayRegex = /^(.*)\[([0-9]*)\]$/;
1139
- var bytesRegex = /^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/;
1140
- 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)?$/;
863
+ // node_modules/viem/_esm/utils/unit/formatEther.js
864
+ function formatEther2(wei, unit = "wei") {
865
+ return formatEther(wei, unit);
866
+ }
1141
867
 
1142
- // node_modules/viem/_esm/utils/abi/encodeAbiParameters.js
1143
- function encodeAbiParameters(params, values) {
1144
- if (params.length !== values.length)
1145
- throw new AbiEncodingLengthMismatchError({
1146
- expectedLength: params.length,
1147
- givenLength: values.length
1148
- });
1149
- const preparedParams = prepareParams({
1150
- params,
1151
- values
1152
- });
1153
- return encodeParams(preparedParams);
868
+ // node_modules/viem/_esm/utils/unit/formatGwei.js
869
+ function formatGwei2(wei, unit = "wei") {
870
+ return formatGwei(wei, unit);
1154
871
  }
1155
- function prepareParams({ params, values }) {
1156
- const preparedParams = [];
1157
- for (let i = 0; i < params.length; i++) {
1158
- preparedParams.push(prepareParam({ param: params[i], value: values[i] }));
1159
- }
1160
- return preparedParams;
872
+
873
+ // node_modules/viem/_esm/errors/transaction.js
874
+ function prettyPrint(args) {
875
+ const entries = Object.entries(args).map(([key, value]) => {
876
+ if (value === void 0 || value === false)
877
+ return null;
878
+ return [key, value];
879
+ }).filter(Boolean);
880
+ const maxLength = entries.reduce((acc, [key]) => Math.max(acc, key.length), 0);
881
+ return entries.map(([key, value]) => ` ${`${key}:`.padEnd(maxLength + 1)} ${value}`).join("\n");
1161
882
  }
1162
- function prepareParam({ param, value }) {
1163
- const arrayComponents = getArrayComponents(param.type);
1164
- if (arrayComponents) {
1165
- const [length, type] = arrayComponents;
1166
- return encodeArray(value, { length, param: { ...param, type } });
883
+ var FeeConflictError = class extends BaseError {
884
+ constructor() {
885
+ super([
886
+ "Cannot specify both a `gasPrice` and a `maxFeePerGas`/`maxPriorityFeePerGas`.",
887
+ "Use `maxFeePerGas`/`maxPriorityFeePerGas` for EIP-1559 compatible networks, and `gasPrice` for others."
888
+ ].join("\n"), { name: "FeeConflictError" });
1167
889
  }
1168
- if (param.type === "tuple") {
1169
- return encodeTuple(value, {
1170
- param
890
+ };
891
+ var InvalidLegacyVError = class extends BaseError {
892
+ constructor({ v }) {
893
+ super(`Invalid \`v\` value "${v}". Expected 27 or 28.`, {
894
+ name: "InvalidLegacyVError"
1171
895
  });
1172
896
  }
1173
- if (param.type === "address") {
1174
- return encodeAddress(value);
897
+ };
898
+ var InvalidYParityError = class extends BaseError {
899
+ constructor({ yParity }) {
900
+ super(`Invalid \`yParity\` value "${yParity}". Expected 0 or 1.`, {
901
+ name: "InvalidYParityError"
902
+ });
1175
903
  }
1176
- if (param.type === "bool") {
1177
- return encodeBool(value);
904
+ };
905
+ var InvalidSerializableTransactionError = class extends BaseError {
906
+ constructor({ transaction }) {
907
+ super("Cannot infer a transaction type from provided transaction.", {
908
+ metaMessages: [
909
+ "Provided Transaction:",
910
+ "{",
911
+ prettyPrint(transaction),
912
+ "}",
913
+ "",
914
+ "To infer the type, either provide:",
915
+ "- a `type` to the Transaction, or",
916
+ "- an EIP-1559 Transaction with `maxFeePerGas`, or",
917
+ "- an EIP-2930 Transaction with `gasPrice` & `accessList`, or",
918
+ "- an EIP-4844 Transaction with `blobs`, `blobVersionedHashes`, `sidecars`, or",
919
+ "- an EIP-7702 Transaction with `authorizationList`, or",
920
+ "- a Legacy Transaction with `gasPrice`"
921
+ ],
922
+ name: "InvalidSerializableTransactionError"
923
+ });
1178
924
  }
1179
- if (param.type.startsWith("uint") || param.type.startsWith("int")) {
1180
- const signed = param.type.startsWith("int");
1181
- const [, , size2 = "256"] = integerRegex.exec(param.type) ?? [];
1182
- return encodeNumber(value, {
1183
- signed,
1184
- size: Number(size2)
925
+ };
926
+ var InvalidSerializedTransactionTypeError = class extends BaseError {
927
+ constructor({ serializedType }) {
928
+ super(`Serialized transaction type "${serializedType}" is invalid.`, {
929
+ name: "InvalidSerializedTransactionType"
930
+ });
931
+ Object.defineProperty(this, "serializedType", {
932
+ enumerable: true,
933
+ configurable: true,
934
+ writable: true,
935
+ value: void 0
1185
936
  });
937
+ this.serializedType = serializedType;
1186
938
  }
1187
- if (param.type.startsWith("bytes")) {
1188
- return encodeBytes(value, { param });
939
+ };
940
+ var InvalidSerializedTransactionError = class extends BaseError {
941
+ constructor({ attributes, serializedTransaction, type }) {
942
+ const missing = Object.entries(attributes).map(([key, value]) => typeof value === "undefined" ? key : void 0).filter(Boolean);
943
+ super(`Invalid serialized transaction of type "${type}" was provided.`, {
944
+ metaMessages: [
945
+ `Serialized Transaction: "${serializedTransaction}"`,
946
+ missing.length > 0 ? `Missing Attributes: ${missing.join(", ")}` : ""
947
+ ].filter(Boolean),
948
+ name: "InvalidSerializedTransactionError"
949
+ });
950
+ Object.defineProperty(this, "serializedTransaction", {
951
+ enumerable: true,
952
+ configurable: true,
953
+ writable: true,
954
+ value: void 0
955
+ });
956
+ Object.defineProperty(this, "type", {
957
+ enumerable: true,
958
+ configurable: true,
959
+ writable: true,
960
+ value: void 0
961
+ });
962
+ this.serializedTransaction = serializedTransaction;
963
+ this.type = type;
1189
964
  }
1190
- if (param.type === "string") {
1191
- return encodeString(value);
965
+ };
966
+ var InvalidStorageKeySizeError = class extends BaseError {
967
+ constructor({ storageKey }) {
968
+ super(`Size for storage key "${storageKey}" is invalid. Expected 32 bytes. Got ${Math.floor((storageKey.length - 2) / 2)} bytes.`, { name: "InvalidStorageKeySizeError" });
1192
969
  }
1193
- throw new InvalidAbiEncodingTypeError(param.type, {
1194
- docsPath: "/docs/contract/encodeAbiParameters"
1195
- });
1196
- }
1197
- function encodeParams(preparedParams) {
1198
- let staticSize = 0;
1199
- for (let i = 0; i < preparedParams.length; i++) {
1200
- const { dynamic, encoded } = preparedParams[i];
1201
- if (dynamic)
1202
- staticSize += 32;
1203
- else
1204
- staticSize += size(encoded);
970
+ };
971
+ var TransactionExecutionError = class extends BaseError {
972
+ constructor(cause, { account, docsPath, chain, data, gas, gasPrice, maxFeePerGas, maxPriorityFeePerGas, nonce, to, value }) {
973
+ const prettyArgs = prettyPrint({
974
+ chain: chain && `${chain?.name} (id: ${chain?.id})`,
975
+ from: account?.address,
976
+ to,
977
+ value: typeof value !== "undefined" && `${formatEther2(value)} ${chain?.nativeCurrency?.symbol || "ETH"}`,
978
+ data,
979
+ gas,
980
+ gasPrice: typeof gasPrice !== "undefined" && `${formatGwei2(gasPrice)} gwei`,
981
+ maxFeePerGas: typeof maxFeePerGas !== "undefined" && `${formatGwei2(maxFeePerGas)} gwei`,
982
+ maxPriorityFeePerGas: typeof maxPriorityFeePerGas !== "undefined" && `${formatGwei2(maxPriorityFeePerGas)} gwei`,
983
+ nonce
984
+ });
985
+ super(cause.shortMessage, {
986
+ cause,
987
+ docsPath,
988
+ metaMessages: [
989
+ ...cause.metaMessages ? [...cause.metaMessages, " "] : [],
990
+ "Request Arguments:",
991
+ prettyArgs
992
+ ].filter(Boolean),
993
+ name: "TransactionExecutionError"
994
+ });
995
+ Object.defineProperty(this, "cause", {
996
+ enumerable: true,
997
+ configurable: true,
998
+ writable: true,
999
+ value: void 0
1000
+ });
1001
+ this.cause = cause;
1205
1002
  }
1206
- const staticParams = [];
1207
- const dynamicParams = [];
1208
- let dynamicSize = 0;
1209
- for (let i = 0; i < preparedParams.length; i++) {
1210
- const { dynamic, encoded } = preparedParams[i];
1211
- if (dynamic) {
1212
- staticParams.push(numberToHex(staticSize + dynamicSize, { size: 32 }));
1213
- dynamicParams.push(encoded);
1214
- dynamicSize += size(encoded);
1215
- } else {
1216
- staticParams.push(encoded);
1217
- }
1003
+ };
1004
+ var TransactionNotFoundError = class extends BaseError {
1005
+ constructor({ blockHash, blockNumber, blockTag, hash, index }) {
1006
+ let identifier = "Transaction";
1007
+ if (blockTag && index !== void 0)
1008
+ identifier = `Transaction at block time "${blockTag}" at index "${index}"`;
1009
+ if (blockHash && index !== void 0)
1010
+ identifier = `Transaction at block hash "${blockHash}" at index "${index}"`;
1011
+ if (blockNumber && index !== void 0)
1012
+ identifier = `Transaction at block number "${blockNumber}" at index "${index}"`;
1013
+ if (hash)
1014
+ identifier = `Transaction with hash "${hash}"`;
1015
+ super(`${identifier} could not be found.`, {
1016
+ name: "TransactionNotFoundError"
1017
+ });
1218
1018
  }
1219
- return concatHex([...staticParams, ...dynamicParams]);
1220
- }
1221
- function encodeAddress(value) {
1222
- if (!isAddress(value))
1223
- throw new InvalidAddressError({ address: value });
1224
- return { dynamic: false, encoded: padHex(value.toLowerCase()) };
1225
- }
1226
- function encodeArray(value, { length, param }) {
1227
- const dynamic = length === null;
1228
- if (!Array.isArray(value))
1229
- throw new InvalidArrayError(value);
1230
- if (!dynamic && value.length !== length)
1231
- throw new AbiEncodingArrayLengthMismatchError({
1232
- expectedLength: length,
1233
- givenLength: value.length,
1234
- type: `${param.type}[${length}]`
1019
+ };
1020
+ var TransactionReceiptNotFoundError = class extends BaseError {
1021
+ constructor({ hash }) {
1022
+ super(`Transaction receipt with hash "${hash}" could not be found. The Transaction may not be processed on a block yet.`, {
1023
+ name: "TransactionReceiptNotFoundError"
1235
1024
  });
1236
- let dynamicChild = value.length === 0 && isDynamicType(param);
1237
- const preparedParams = [];
1238
- for (let i = 0; i < value.length; i++) {
1239
- const preparedParam = prepareParam({ param, value: value[i] });
1240
- if (preparedParam.dynamic)
1241
- dynamicChild = true;
1242
- preparedParams.push(preparedParam);
1243
1025
  }
1244
- if (dynamic || dynamicChild) {
1245
- const data = encodeParams(preparedParams);
1246
- if (dynamic) {
1247
- const length2 = numberToHex(preparedParams.length, { size: 32 });
1248
- return {
1249
- dynamic: true,
1250
- encoded: concatHex([length2, data])
1251
- };
1252
- }
1253
- if (dynamicChild)
1254
- return { dynamic: true, encoded: data };
1026
+ };
1027
+ var TransactionReceiptRevertedError = class extends BaseError {
1028
+ constructor({ receipt }) {
1029
+ super(`Transaction with hash "${receipt.transactionHash}" reverted.`, {
1030
+ metaMessages: [
1031
+ 'The receipt marked the transaction as "reverted". This could mean that the function on the contract you are trying to call threw an error.',
1032
+ " ",
1033
+ "You can attempt to extract the revert reason by:",
1034
+ "- calling the `simulateContract` or `simulateCalls` Action with the `abi` and `functionName` of the contract",
1035
+ "- using the `call` Action with raw `data`"
1036
+ ],
1037
+ name: "TransactionReceiptRevertedError"
1038
+ });
1039
+ Object.defineProperty(this, "receipt", {
1040
+ enumerable: true,
1041
+ configurable: true,
1042
+ writable: true,
1043
+ value: void 0
1044
+ });
1045
+ this.receipt = receipt;
1255
1046
  }
1256
- return {
1257
- dynamic: false,
1258
- encoded: concatHex(preparedParams.map(({ encoded }) => encoded))
1259
- };
1260
- }
1261
- function encodeBytes(value, { param }) {
1262
- const [, paramSize] = param.type.split("bytes");
1263
- const bytesSize = size(value);
1264
- if (!paramSize) {
1265
- let value_ = value;
1266
- if (bytesSize % 32 !== 0)
1267
- value_ = padHex(value_, {
1268
- dir: "right",
1269
- size: Math.ceil((value.length - 2) / 2 / 32) * 32
1270
- });
1271
- return {
1272
- dynamic: true,
1273
- encoded: concatHex([
1274
- padHex(numberToHex(bytesSize, { size: 32 })),
1275
- value_
1276
- ])
1277
- };
1047
+ };
1048
+ var WaitForTransactionReceiptTimeoutError = class extends BaseError {
1049
+ constructor({ hash }) {
1050
+ super(`Timed out while waiting for transaction with hash "${hash}" to be confirmed.`, { name: "WaitForTransactionReceiptTimeoutError" });
1278
1051
  }
1279
- if (bytesSize !== Number.parseInt(paramSize, 10))
1280
- throw new AbiEncodingBytesSizeMismatchError({
1281
- expectedSize: Number.parseInt(paramSize, 10),
1282
- value
1052
+ };
1053
+
1054
+ // node_modules/viem/_esm/constants/number.js
1055
+ var maxInt8 = 2n ** (8n - 1n) - 1n;
1056
+ var maxInt16 = 2n ** (16n - 1n) - 1n;
1057
+ var maxInt24 = 2n ** (24n - 1n) - 1n;
1058
+ var maxInt32 = 2n ** (32n - 1n) - 1n;
1059
+ var maxInt40 = 2n ** (40n - 1n) - 1n;
1060
+ var maxInt48 = 2n ** (48n - 1n) - 1n;
1061
+ var maxInt56 = 2n ** (56n - 1n) - 1n;
1062
+ var maxInt64 = 2n ** (64n - 1n) - 1n;
1063
+ var maxInt72 = 2n ** (72n - 1n) - 1n;
1064
+ var maxInt80 = 2n ** (80n - 1n) - 1n;
1065
+ var maxInt88 = 2n ** (88n - 1n) - 1n;
1066
+ var maxInt96 = 2n ** (96n - 1n) - 1n;
1067
+ var maxInt104 = 2n ** (104n - 1n) - 1n;
1068
+ var maxInt112 = 2n ** (112n - 1n) - 1n;
1069
+ var maxInt120 = 2n ** (120n - 1n) - 1n;
1070
+ var maxInt128 = 2n ** (128n - 1n) - 1n;
1071
+ var maxInt136 = 2n ** (136n - 1n) - 1n;
1072
+ var maxInt144 = 2n ** (144n - 1n) - 1n;
1073
+ var maxInt152 = 2n ** (152n - 1n) - 1n;
1074
+ var maxInt160 = 2n ** (160n - 1n) - 1n;
1075
+ var maxInt168 = 2n ** (168n - 1n) - 1n;
1076
+ var maxInt176 = 2n ** (176n - 1n) - 1n;
1077
+ var maxInt184 = 2n ** (184n - 1n) - 1n;
1078
+ var maxInt192 = 2n ** (192n - 1n) - 1n;
1079
+ var maxInt200 = 2n ** (200n - 1n) - 1n;
1080
+ var maxInt208 = 2n ** (208n - 1n) - 1n;
1081
+ var maxInt216 = 2n ** (216n - 1n) - 1n;
1082
+ var maxInt224 = 2n ** (224n - 1n) - 1n;
1083
+ var maxInt232 = 2n ** (232n - 1n) - 1n;
1084
+ var maxInt240 = 2n ** (240n - 1n) - 1n;
1085
+ var maxInt248 = 2n ** (248n - 1n) - 1n;
1086
+ var maxInt256 = 2n ** (256n - 1n) - 1n;
1087
+ var minInt8 = -(2n ** (8n - 1n));
1088
+ var minInt16 = -(2n ** (16n - 1n));
1089
+ var minInt24 = -(2n ** (24n - 1n));
1090
+ var minInt32 = -(2n ** (32n - 1n));
1091
+ var minInt40 = -(2n ** (40n - 1n));
1092
+ var minInt48 = -(2n ** (48n - 1n));
1093
+ var minInt56 = -(2n ** (56n - 1n));
1094
+ var minInt64 = -(2n ** (64n - 1n));
1095
+ var minInt72 = -(2n ** (72n - 1n));
1096
+ var minInt80 = -(2n ** (80n - 1n));
1097
+ var minInt88 = -(2n ** (88n - 1n));
1098
+ var minInt96 = -(2n ** (96n - 1n));
1099
+ var minInt104 = -(2n ** (104n - 1n));
1100
+ var minInt112 = -(2n ** (112n - 1n));
1101
+ var minInt120 = -(2n ** (120n - 1n));
1102
+ var minInt128 = -(2n ** (128n - 1n));
1103
+ var minInt136 = -(2n ** (136n - 1n));
1104
+ var minInt144 = -(2n ** (144n - 1n));
1105
+ var minInt152 = -(2n ** (152n - 1n));
1106
+ var minInt160 = -(2n ** (160n - 1n));
1107
+ var minInt168 = -(2n ** (168n - 1n));
1108
+ var minInt176 = -(2n ** (176n - 1n));
1109
+ var minInt184 = -(2n ** (184n - 1n));
1110
+ var minInt192 = -(2n ** (192n - 1n));
1111
+ var minInt200 = -(2n ** (200n - 1n));
1112
+ var minInt208 = -(2n ** (208n - 1n));
1113
+ var minInt216 = -(2n ** (216n - 1n));
1114
+ var minInt224 = -(2n ** (224n - 1n));
1115
+ var minInt232 = -(2n ** (232n - 1n));
1116
+ var minInt240 = -(2n ** (240n - 1n));
1117
+ var minInt248 = -(2n ** (248n - 1n));
1118
+ var minInt256 = -(2n ** (256n - 1n));
1119
+ var maxUint8 = 2n ** 8n - 1n;
1120
+ var maxUint16 = 2n ** 16n - 1n;
1121
+ var maxUint24 = 2n ** 24n - 1n;
1122
+ var maxUint32 = 2n ** 32n - 1n;
1123
+ var maxUint40 = 2n ** 40n - 1n;
1124
+ var maxUint48 = 2n ** 48n - 1n;
1125
+ var maxUint56 = 2n ** 56n - 1n;
1126
+ var maxUint64 = 2n ** 64n - 1n;
1127
+ var maxUint72 = 2n ** 72n - 1n;
1128
+ var maxUint80 = 2n ** 80n - 1n;
1129
+ var maxUint88 = 2n ** 88n - 1n;
1130
+ var maxUint96 = 2n ** 96n - 1n;
1131
+ var maxUint104 = 2n ** 104n - 1n;
1132
+ var maxUint112 = 2n ** 112n - 1n;
1133
+ var maxUint120 = 2n ** 120n - 1n;
1134
+ var maxUint128 = 2n ** 128n - 1n;
1135
+ var maxUint136 = 2n ** 136n - 1n;
1136
+ var maxUint144 = 2n ** 144n - 1n;
1137
+ var maxUint152 = 2n ** 152n - 1n;
1138
+ var maxUint160 = 2n ** 160n - 1n;
1139
+ var maxUint168 = 2n ** 168n - 1n;
1140
+ var maxUint176 = 2n ** 176n - 1n;
1141
+ var maxUint184 = 2n ** 184n - 1n;
1142
+ var maxUint192 = 2n ** 192n - 1n;
1143
+ var maxUint200 = 2n ** 200n - 1n;
1144
+ var maxUint208 = 2n ** 208n - 1n;
1145
+ var maxUint216 = 2n ** 216n - 1n;
1146
+ var maxUint224 = 2n ** 224n - 1n;
1147
+ var maxUint232 = 2n ** 232n - 1n;
1148
+ var maxUint240 = 2n ** 240n - 1n;
1149
+ var maxUint248 = 2n ** 248n - 1n;
1150
+ var maxUint256 = 2n ** 256n - 1n;
1151
+
1152
+ // node_modules/viem/_esm/errors/chain.js
1153
+ var ChainDoesNotSupportContract = class extends BaseError {
1154
+ constructor({ blockNumber, chain, contract }) {
1155
+ super(`Chain "${chain.name}" does not support contract "${contract.name}".`, {
1156
+ metaMessages: [
1157
+ "This could be due to any of the following:",
1158
+ ...blockNumber && contract.blockCreated && contract.blockCreated > blockNumber ? [
1159
+ `- The contract "${contract.name}" was not deployed until block ${contract.blockCreated} (current block ${blockNumber}).`
1160
+ ] : [
1161
+ `- The chain does not have the contract "${contract.name}" configured.`
1162
+ ]
1163
+ ],
1164
+ name: "ChainDoesNotSupportContract"
1283
1165
  });
1284
- return { dynamic: false, encoded: padHex(value, { dir: "right" }) };
1285
- }
1286
- function encodeBool(value) {
1287
- if (typeof value !== "boolean")
1288
- throw new BaseError(`Invalid boolean value: "${value}" (type: ${typeof value}). Expected: \`true\` or \`false\`.`);
1289
- return { dynamic: false, encoded: padHex(boolToHex(value)) };
1290
- }
1291
- function encodeNumber(value, { signed, size: size2 = 256 }) {
1292
- if (typeof size2 === "number") {
1293
- const max = 2n ** (BigInt(size2) - (signed ? 1n : 0n)) - 1n;
1294
- const min = signed ? -max - 1n : 0n;
1295
- if (value > max || value < min)
1296
- throw new IntegerOutOfRangeError({
1297
- max: max.toString(),
1298
- min: min.toString(),
1299
- signed,
1300
- size: size2 / 8,
1301
- value: value.toString()
1302
- });
1303
1166
  }
1304
- return {
1305
- dynamic: false,
1306
- encoded: numberToHex(value, {
1307
- size: 32,
1308
- signed
1309
- })
1310
- };
1311
- }
1312
- function encodeString(value) {
1313
- const hexValue = stringToHex(value);
1314
- const partsLength = Math.ceil(size(hexValue) / 32);
1315
- const parts = [];
1316
- for (let i = 0; i < partsLength; i++) {
1317
- parts.push(padHex(slice(hexValue, i * 32, (i + 1) * 32), {
1318
- dir: "right"
1319
- }));
1167
+ };
1168
+ var ChainMismatchError = class extends BaseError {
1169
+ constructor({ chain, currentChainId }) {
1170
+ super(`The current chain of the wallet (id: ${currentChainId}) does not match the target chain for the transaction (id: ${chain.id} \u2013 ${chain.name}).`, {
1171
+ metaMessages: [
1172
+ `Current Chain ID: ${currentChainId}`,
1173
+ `Expected Chain ID: ${chain.id} \u2013 ${chain.name}`
1174
+ ],
1175
+ name: "ChainMismatchError"
1176
+ });
1320
1177
  }
1321
- return {
1322
- dynamic: true,
1323
- encoded: concatHex([
1324
- padHex(numberToHex(size(hexValue), { size: 32 })),
1325
- ...parts
1326
- ])
1327
- };
1328
- }
1329
- function encodeTuple(value, { param }) {
1330
- let dynamic = false;
1331
- const preparedParams = [];
1332
- for (let i = 0; i < param.components.length; i++) {
1333
- const param_ = param.components[i];
1334
- const index = Array.isArray(value) ? i : param_.name;
1335
- const preparedParam = prepareParam({
1336
- param: param_,
1337
- value: value[index]
1178
+ };
1179
+ var ChainNotFoundError = class extends BaseError {
1180
+ constructor() {
1181
+ super([
1182
+ "No chain was provided to the request.",
1183
+ "Please provide a chain with the `chain` argument on the Action, or by supplying a `chain` to WalletClient."
1184
+ ].join("\n"), {
1185
+ name: "ChainNotFoundError"
1338
1186
  });
1339
- preparedParams.push(preparedParam);
1340
- if (preparedParam.dynamic)
1341
- dynamic = true;
1342
1187
  }
1343
- return {
1344
- dynamic,
1345
- encoded: dynamic ? encodeParams(preparedParams) : concatHex(preparedParams.map(({ encoded }) => encoded))
1346
- };
1347
- }
1348
- function getArrayComponents(type) {
1349
- const matches = type.match(/^(.*)\[(\d+)?\]$/);
1350
- return matches ? (
1351
- // Return `null` if the array is dynamic.
1352
- [matches[2] ? Number(matches[2]) : null, matches[1]]
1353
- ) : void 0;
1354
- }
1355
- function isDynamicType(param) {
1356
- const { type } = param;
1357
- if (type === "string")
1358
- return true;
1359
- if (type === "bytes")
1360
- return true;
1361
- if (type.endsWith("[]"))
1362
- return true;
1363
- if (type === "tuple")
1364
- return param.components.some(isDynamicType);
1365
- const arrayComponents = getArrayComponents(type);
1366
- if (arrayComponents)
1367
- return isDynamicType({ ...param, type: arrayComponents[1] });
1368
- return false;
1369
- }
1370
-
1371
- // node_modules/viem/_esm/accounts/utils/parseAccount.js
1372
- function parseAccount(account) {
1373
- if (typeof account === "string")
1374
- return { address: account, type: "json-rpc" };
1375
- return account;
1376
- }
1377
-
1378
- // node_modules/viem/_esm/utils/stringify.js
1379
- var stringify = (value, replacer, space) => JSON.stringify(value, (key, value_) => {
1380
- const value2 = typeof value_ === "bigint" ? value_.toString() : value_;
1381
- return typeof replacer === "function" ? replacer(key, value2) : value2;
1382
- }, space);
1188
+ };
1189
+ var ClientChainNotConfiguredError = class extends BaseError {
1190
+ constructor() {
1191
+ super("No chain was provided to the Client.", {
1192
+ name: "ClientChainNotConfiguredError"
1193
+ });
1194
+ }
1195
+ };
1196
+ var InvalidChainIdError = class extends BaseError {
1197
+ constructor({ chainId }) {
1198
+ super(typeof chainId === "number" ? `Chain ID "${chainId}" is invalid.` : "Chain ID is invalid.", { name: "InvalidChainIdError" });
1199
+ }
1200
+ };
1383
1201
 
1384
- // node_modules/viem/_esm/utils/unit/Value.js
1385
- var exponents = {
1386
- wei: 0,
1387
- gwei: 9,
1388
- szabo: 12,
1389
- finney: 15,
1390
- ether: 18
1202
+ // node_modules/viem/_esm/errors/node.js
1203
+ var ExecutionRevertedError = class extends BaseError {
1204
+ constructor({ cause, message } = {}) {
1205
+ const reason = message?.replace("execution reverted: ", "")?.replace("execution reverted", "");
1206
+ super(`Execution reverted ${reason ? `with reason: ${reason}` : "for an unknown reason"}.`, {
1207
+ cause,
1208
+ name: "ExecutionRevertedError"
1209
+ });
1210
+ }
1211
+ };
1212
+ Object.defineProperty(ExecutionRevertedError, "code", {
1213
+ enumerable: true,
1214
+ configurable: true,
1215
+ writable: true,
1216
+ value: 3
1217
+ });
1218
+ Object.defineProperty(ExecutionRevertedError, "nodeMessage", {
1219
+ enumerable: true,
1220
+ configurable: true,
1221
+ writable: true,
1222
+ value: /execution reverted|gas required exceeds allowance/
1223
+ });
1224
+ var FeeCapTooHighError = class extends BaseError {
1225
+ constructor({ cause, maxFeePerGas } = {}) {
1226
+ super(`The fee cap (\`maxFeePerGas\`${maxFeePerGas ? ` = ${formatGwei2(maxFeePerGas)} gwei` : ""}) cannot be higher than the maximum allowed value (2^256-1).`, {
1227
+ cause,
1228
+ name: "FeeCapTooHighError"
1229
+ });
1230
+ }
1231
+ };
1232
+ Object.defineProperty(FeeCapTooHighError, "nodeMessage", {
1233
+ enumerable: true,
1234
+ configurable: true,
1235
+ writable: true,
1236
+ value: /max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/
1237
+ });
1238
+ var FeeCapTooLowError = class extends BaseError {
1239
+ constructor({ cause, maxFeePerGas } = {}) {
1240
+ super(`The fee cap (\`maxFeePerGas\`${maxFeePerGas ? ` = ${formatGwei2(maxFeePerGas)}` : ""} gwei) cannot be lower than the block base fee.`, {
1241
+ cause,
1242
+ name: "FeeCapTooLowError"
1243
+ });
1244
+ }
1245
+ };
1246
+ Object.defineProperty(FeeCapTooLowError, "nodeMessage", {
1247
+ enumerable: true,
1248
+ configurable: true,
1249
+ writable: true,
1250
+ value: /max fee per gas less than block base fee|fee cap less than block base fee|transaction is outdated/
1251
+ });
1252
+ var NonceTooHighError = class extends BaseError {
1253
+ constructor({ cause, nonce } = {}) {
1254
+ super(`Nonce provided for the transaction ${nonce ? `(${nonce}) ` : ""}is higher than the next one expected.`, { cause, name: "NonceTooHighError" });
1255
+ }
1256
+ };
1257
+ Object.defineProperty(NonceTooHighError, "nodeMessage", {
1258
+ enumerable: true,
1259
+ configurable: true,
1260
+ writable: true,
1261
+ value: /nonce too high/
1262
+ });
1263
+ var NonceTooLowError = class extends BaseError {
1264
+ constructor({ cause, nonce } = {}) {
1265
+ super([
1266
+ `Nonce provided for the transaction ${nonce ? `(${nonce}) ` : ""}is lower than the current nonce of the account.`,
1267
+ "Try increasing the nonce or find the latest nonce with `getTransactionCount`."
1268
+ ].join("\n"), { cause, name: "NonceTooLowError" });
1269
+ }
1270
+ };
1271
+ Object.defineProperty(NonceTooLowError, "nodeMessage", {
1272
+ enumerable: true,
1273
+ configurable: true,
1274
+ writable: true,
1275
+ value: /nonce too low|transaction already imported|already known/
1276
+ });
1277
+ var NonceMaxValueError = class extends BaseError {
1278
+ constructor({ cause, nonce } = {}) {
1279
+ super(`Nonce provided for the transaction ${nonce ? `(${nonce}) ` : ""}exceeds the maximum allowed nonce.`, { cause, name: "NonceMaxValueError" });
1280
+ }
1281
+ };
1282
+ Object.defineProperty(NonceMaxValueError, "nodeMessage", {
1283
+ enumerable: true,
1284
+ configurable: true,
1285
+ writable: true,
1286
+ value: /nonce has max value/
1287
+ });
1288
+ var InsufficientFundsError = class extends BaseError {
1289
+ constructor({ cause } = {}) {
1290
+ super([
1291
+ "The total cost (gas * gas fee + value) of executing this transaction exceeds the balance of the account."
1292
+ ].join("\n"), {
1293
+ cause,
1294
+ metaMessages: [
1295
+ "This error could arise when the account does not have enough funds to:",
1296
+ " - pay for the total gas fee,",
1297
+ " - pay for the value to send.",
1298
+ " ",
1299
+ "The cost of the transaction is calculated as `gas * gas fee + value`, where:",
1300
+ " - `gas` is the amount of gas needed for transaction to execute,",
1301
+ " - `gas fee` is the gas fee,",
1302
+ " - `value` is the amount of ether to send to the recipient."
1303
+ ],
1304
+ name: "InsufficientFundsError"
1305
+ });
1306
+ }
1391
1307
  };
1392
- function format(value, decimals = 0) {
1393
- if (!Number.isInteger(decimals) || decimals < 0)
1394
- throw new InvalidDecimalsError({ decimals });
1395
- let display = value.toString();
1396
- const negative = display.startsWith("-");
1397
- if (negative)
1398
- display = display.slice(1);
1399
- display = display.padStart(decimals, "0");
1400
- let [integer, fraction] = [
1401
- display.slice(0, display.length - decimals),
1402
- display.slice(display.length - decimals)
1403
- ];
1404
- fraction = fraction.replace(/(0+)$/, "");
1405
- return `${negative ? "-" : ""}${integer || "0"}${fraction ? `.${fraction}` : ""}`;
1406
- }
1407
- function formatEther(wei, unit = "wei") {
1408
- return format(wei, exponents.ether - exponents[unit]);
1409
- }
1410
- function formatGwei(wei, unit = "wei") {
1411
- return format(wei, exponents.gwei - exponents[unit]);
1412
- }
1413
- function from(value, decimals = 0) {
1414
- if (!Number.isInteger(decimals) || decimals < 0)
1415
- throw new InvalidDecimalsError({ decimals });
1416
- if (!/^-?(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)$/.test(value))
1417
- throw new InvalidDecimalNumberError({ value });
1418
- let [integer = "", fraction = "0"] = value.split(".");
1419
- const negative = integer.startsWith("-");
1420
- if (negative)
1421
- integer = integer.slice(1);
1422
- if (integer === "")
1423
- integer = "0";
1424
- fraction = fraction.replace(/(0+)$/, "");
1425
- if (decimals === 0) {
1426
- if (fraction.length > 0 && Number.parseInt(fraction[0], 10) >= 5)
1427
- integer = `${BigInt(integer) + 1n}`;
1428
- fraction = "";
1429
- } else if (fraction.length > decimals) {
1430
- const left = fraction.slice(0, decimals);
1431
- const roundDigit = Number.parseInt(fraction.slice(decimals, decimals + 1), 10);
1432
- if (roundDigit >= 5) {
1433
- const carried = carry(left);
1434
- if (carried.length > decimals) {
1435
- fraction = carried.slice(1);
1436
- integer = `${BigInt(integer) + 1n}`;
1437
- } else {
1438
- fraction = carried;
1439
- }
1440
- } else {
1441
- fraction = left;
1442
- }
1443
- } else {
1444
- fraction = fraction.padEnd(decimals, "0");
1308
+ Object.defineProperty(InsufficientFundsError, "nodeMessage", {
1309
+ enumerable: true,
1310
+ configurable: true,
1311
+ writable: true,
1312
+ value: /insufficient funds|exceeds transaction sender account balance/
1313
+ });
1314
+ var IntrinsicGasTooHighError = class extends BaseError {
1315
+ constructor({ cause, gas } = {}) {
1316
+ super(`The amount of gas ${gas ? `(${gas}) ` : ""}provided for the transaction exceeds the limit allowed for the block.`, {
1317
+ cause,
1318
+ name: "IntrinsicGasTooHighError"
1319
+ });
1445
1320
  }
1446
- return BigInt(`${negative ? "-" : ""}${integer}${fraction}`);
1447
- }
1448
- function carry(digits) {
1449
- const out = digits.split("");
1450
- let i = out.length - 1;
1451
- while (i >= 0) {
1452
- const d = Number.parseInt(out[i], 10) + 1;
1453
- if (d < 10) {
1454
- out[i] = String(d);
1455
- return out.join("");
1456
- }
1457
- out[i] = "0";
1458
- i--;
1321
+ };
1322
+ Object.defineProperty(IntrinsicGasTooHighError, "nodeMessage", {
1323
+ enumerable: true,
1324
+ configurable: true,
1325
+ writable: true,
1326
+ value: /intrinsic gas too high|gas limit reached/
1327
+ });
1328
+ var IntrinsicGasTooLowError = class extends BaseError {
1329
+ constructor({ cause, gas } = {}) {
1330
+ super(`The amount of gas ${gas ? `(${gas}) ` : ""}provided for the transaction is too low.`, {
1331
+ cause,
1332
+ name: "IntrinsicGasTooLowError"
1333
+ });
1459
1334
  }
1460
- return `1${out.join("")}`;
1461
- }
1462
- function fromEther(ether, unit = "wei") {
1463
- return from(ether, exponents.ether - exponents[unit]);
1464
- }
1465
- function fromGwei(gwei, unit = "wei") {
1466
- return from(gwei, exponents.gwei - exponents[unit]);
1467
- }
1468
- var InvalidDecimalNumberError = class extends Error {
1469
- constructor({ value }) {
1470
- super(`Value \`${value}\` is not a valid decimal number.`);
1471
- Object.defineProperty(this, "name", {
1472
- enumerable: true,
1473
- configurable: true,
1474
- writable: true,
1475
- value: "Value.InvalidDecimalNumberError"
1335
+ };
1336
+ Object.defineProperty(IntrinsicGasTooLowError, "nodeMessage", {
1337
+ enumerable: true,
1338
+ configurable: true,
1339
+ writable: true,
1340
+ value: /intrinsic gas too low/
1341
+ });
1342
+ var TransactionTypeNotSupportedError = class extends BaseError {
1343
+ constructor({ cause }) {
1344
+ super("The transaction type is not supported for this chain.", {
1345
+ cause,
1346
+ name: "TransactionTypeNotSupportedError"
1476
1347
  });
1477
1348
  }
1478
1349
  };
1479
- var InvalidDecimalsError = class extends Error {
1480
- constructor({ decimals }) {
1481
- super(`\`decimals\` must be a non-negative integer. Got \`${decimals}\`.`);
1482
- Object.defineProperty(this, "name", {
1483
- enumerable: true,
1484
- configurable: true,
1485
- writable: true,
1486
- value: "Value.InvalidDecimalsError"
1350
+ Object.defineProperty(TransactionTypeNotSupportedError, "nodeMessage", {
1351
+ enumerable: true,
1352
+ configurable: true,
1353
+ writable: true,
1354
+ value: /transaction type not valid/
1355
+ });
1356
+ var TipAboveFeeCapError = class extends BaseError {
1357
+ constructor({ cause, maxPriorityFeePerGas, maxFeePerGas } = {}) {
1358
+ super([
1359
+ `The provided tip (\`maxPriorityFeePerGas\`${maxPriorityFeePerGas ? ` = ${formatGwei2(maxPriorityFeePerGas)} gwei` : ""}) cannot be higher than the fee cap (\`maxFeePerGas\`${maxFeePerGas ? ` = ${formatGwei2(maxFeePerGas)} gwei` : ""}).`
1360
+ ].join("\n"), {
1361
+ cause,
1362
+ name: "TipAboveFeeCapError"
1363
+ });
1364
+ }
1365
+ };
1366
+ Object.defineProperty(TipAboveFeeCapError, "nodeMessage", {
1367
+ enumerable: true,
1368
+ configurable: true,
1369
+ writable: true,
1370
+ value: /max priority fee per gas higher than max fee per gas|tip higher than fee cap/
1371
+ });
1372
+ var UnknownNodeError = class extends BaseError {
1373
+ constructor({ cause }) {
1374
+ super(`An error occurred while executing: ${cause?.shortMessage}`, {
1375
+ cause,
1376
+ name: "UnknownNodeError"
1487
1377
  });
1488
1378
  }
1489
1379
  };
1490
1380
 
1491
- // node_modules/viem/_esm/utils/unit/formatEther.js
1492
- function formatEther2(wei, unit = "wei") {
1493
- return formatEther(wei, unit);
1381
+ // node_modules/viem/_esm/utils/data/slice.js
1382
+ function slice(value, start, end, { strict } = {}) {
1383
+ if (isHex(value, { strict: false }))
1384
+ return sliceHex(value, start, end, {
1385
+ strict
1386
+ });
1387
+ return sliceBytes(value, start, end, {
1388
+ strict
1389
+ });
1494
1390
  }
1495
-
1496
- // node_modules/viem/_esm/utils/unit/formatGwei.js
1497
- function formatGwei2(wei, unit = "wei") {
1498
- return formatGwei(wei, unit);
1391
+ function assertStartOffset(value, start) {
1392
+ if (typeof start === "number" && start > 0 && start > size(value) - 1)
1393
+ throw new SliceOffsetOutOfBoundsError({
1394
+ offset: start,
1395
+ position: "start",
1396
+ size: size(value)
1397
+ });
1398
+ }
1399
+ function assertEndOffset(value, start, end) {
1400
+ if (typeof start === "number" && typeof end === "number" && size(value) !== end - start) {
1401
+ throw new SliceOffsetOutOfBoundsError({
1402
+ offset: end,
1403
+ position: "end",
1404
+ size: size(value)
1405
+ });
1406
+ }
1407
+ }
1408
+ function sliceBytes(value_, start, end, { strict } = {}) {
1409
+ assertStartOffset(value_, start);
1410
+ const value = value_.slice(start, end);
1411
+ if (strict)
1412
+ assertEndOffset(value, start, end);
1413
+ return value;
1414
+ }
1415
+ function sliceHex(value_, start, end, { strict } = {}) {
1416
+ assertStartOffset(value_, start);
1417
+ const value = `0x${value_.replace("0x", "").slice((start ?? 0) * 2, (end ?? value_.length) * 2)}`;
1418
+ if (strict)
1419
+ assertEndOffset(value, start, end);
1420
+ return value;
1499
1421
  }
1500
1422
 
1501
- // node_modules/viem/_esm/errors/transaction.js
1502
- function prettyPrint(args) {
1503
- const entries = Object.entries(args).map(([key, value]) => {
1504
- if (value === void 0 || value === false)
1505
- return null;
1506
- return [key, value];
1507
- }).filter(Boolean);
1508
- const maxLength = entries.reduce((acc, [key]) => Math.max(acc, key.length), 0);
1509
- return entries.map(([key, value]) => ` ${`${key}:`.padEnd(maxLength + 1)} ${value}`).join("\n");
1423
+ // node_modules/viem/_esm/utils/abi/formatAbiItem.js
1424
+ function formatAbiItem(abiItem, { includeName = false } = {}) {
1425
+ if (abiItem.type !== "function" && abiItem.type !== "event" && abiItem.type !== "error")
1426
+ throw new InvalidDefinitionTypeError(abiItem.type);
1427
+ return `${abiItem.name}(${formatAbiParams(abiItem.inputs, { includeName })})`;
1510
1428
  }
1511
- var FeeConflictError = class extends BaseError {
1512
- constructor() {
1513
- super([
1514
- "Cannot specify both a `gasPrice` and a `maxFeePerGas`/`maxPriorityFeePerGas`.",
1515
- "Use `maxFeePerGas`/`maxPriorityFeePerGas` for EIP-1559 compatible networks, and `gasPrice` for others."
1516
- ].join("\n"), { name: "FeeConflictError" });
1429
+ function formatAbiParams(params, { includeName = false } = {}) {
1430
+ if (!params)
1431
+ return "";
1432
+ return params.map((param) => formatAbiParam(param, { includeName })).join(includeName ? ", " : ",");
1433
+ }
1434
+ function formatAbiParam(param, { includeName }) {
1435
+ if (param.type.startsWith("tuple")) {
1436
+ return `(${formatAbiParams(param.components, { includeName })})${param.type.slice("tuple".length)}`;
1517
1437
  }
1518
- };
1519
- var InvalidLegacyVError = class extends BaseError {
1520
- constructor({ v }) {
1521
- super(`Invalid \`v\` value "${v}". Expected 27 or 28.`, {
1522
- name: "InvalidLegacyVError"
1438
+ return param.type + (includeName && param.name ? ` ${param.name}` : "");
1439
+ }
1440
+
1441
+ // node_modules/viem/_esm/errors/abi.js
1442
+ var AbiConstructorNotFoundError = class extends BaseError {
1443
+ constructor({ docsPath }) {
1444
+ super([
1445
+ "A constructor was not found on the ABI.",
1446
+ "Make sure you are using the correct ABI and that the constructor exists on it."
1447
+ ].join("\n"), {
1448
+ docsPath,
1449
+ name: "AbiConstructorNotFoundError"
1523
1450
  });
1524
1451
  }
1525
1452
  };
1526
- var InvalidYParityError = class extends BaseError {
1527
- constructor({ yParity }) {
1528
- super(`Invalid \`yParity\` value "${yParity}". Expected 0 or 1.`, {
1529
- name: "InvalidYParityError"
1453
+ var AbiConstructorParamsNotFoundError = class extends BaseError {
1454
+ constructor({ docsPath }) {
1455
+ super([
1456
+ "Constructor arguments were provided (`args`), but a constructor parameters (`inputs`) were not found on the ABI.",
1457
+ "Make sure you are using the correct ABI, and that the `inputs` attribute on the constructor exists."
1458
+ ].join("\n"), {
1459
+ docsPath,
1460
+ name: "AbiConstructorParamsNotFoundError"
1530
1461
  });
1531
1462
  }
1532
1463
  };
1533
- var InvalidSerializableTransactionError = class extends BaseError {
1534
- constructor({ transaction }) {
1535
- super("Cannot infer a transaction type from provided transaction.", {
1536
- metaMessages: [
1537
- "Provided Transaction:",
1538
- "{",
1539
- prettyPrint(transaction),
1540
- "}",
1541
- "",
1542
- "To infer the type, either provide:",
1543
- "- a `type` to the Transaction, or",
1544
- "- an EIP-1559 Transaction with `maxFeePerGas`, or",
1545
- "- an EIP-2930 Transaction with `gasPrice` & `accessList`, or",
1546
- "- an EIP-4844 Transaction with `blobs`, `blobVersionedHashes`, `sidecars`, or",
1547
- "- an EIP-7702 Transaction with `authorizationList`, or",
1548
- "- a Legacy Transaction with `gasPrice`"
1549
- ],
1550
- name: "InvalidSerializableTransactionError"
1464
+ var AbiDecodingDataSizeInvalidError = class extends BaseError {
1465
+ constructor({ data, size: size2 }) {
1466
+ super([
1467
+ `Data size of ${size2} bytes is invalid.`,
1468
+ "Size must be in increments of 32 bytes (size % 32 === 0)."
1469
+ ].join("\n"), {
1470
+ metaMessages: [`Data: ${data} (${size2} bytes)`],
1471
+ name: "AbiDecodingDataSizeInvalidError"
1551
1472
  });
1552
1473
  }
1553
1474
  };
1554
- var InvalidSerializedTransactionTypeError = class extends BaseError {
1555
- constructor({ serializedType }) {
1556
- super(`Serialized transaction type "${serializedType}" is invalid.`, {
1557
- name: "InvalidSerializedTransactionType"
1475
+ var AbiDecodingDataSizeTooSmallError = class extends BaseError {
1476
+ constructor({ data, params, size: size2 }) {
1477
+ super([`Data size of ${size2} bytes is too small for given parameters.`].join("\n"), {
1478
+ metaMessages: [
1479
+ `Params: (${formatAbiParams(params, { includeName: true })})`,
1480
+ `Data: ${data} (${size2} bytes)`
1481
+ ],
1482
+ name: "AbiDecodingDataSizeTooSmallError"
1558
1483
  });
1559
- Object.defineProperty(this, "serializedType", {
1484
+ Object.defineProperty(this, "data", {
1560
1485
  enumerable: true,
1561
1486
  configurable: true,
1562
1487
  writable: true,
1563
1488
  value: void 0
1564
1489
  });
1565
- this.serializedType = serializedType;
1566
- }
1567
- };
1568
- var InvalidSerializedTransactionError = class extends BaseError {
1569
- constructor({ attributes, serializedTransaction, type }) {
1570
- const missing = Object.entries(attributes).map(([key, value]) => typeof value === "undefined" ? key : void 0).filter(Boolean);
1571
- super(`Invalid serialized transaction of type "${type}" was provided.`, {
1572
- metaMessages: [
1573
- `Serialized Transaction: "${serializedTransaction}"`,
1574
- missing.length > 0 ? `Missing Attributes: ${missing.join(", ")}` : ""
1575
- ].filter(Boolean),
1576
- name: "InvalidSerializedTransactionError"
1577
- });
1578
- Object.defineProperty(this, "serializedTransaction", {
1490
+ Object.defineProperty(this, "params", {
1579
1491
  enumerable: true,
1580
1492
  configurable: true,
1581
1493
  writable: true,
1582
1494
  value: void 0
1583
1495
  });
1584
- Object.defineProperty(this, "type", {
1496
+ Object.defineProperty(this, "size", {
1585
1497
  enumerable: true,
1586
1498
  configurable: true,
1587
1499
  writable: true,
1588
1500
  value: void 0
1589
1501
  });
1590
- this.serializedTransaction = serializedTransaction;
1591
- this.type = type;
1502
+ this.data = data;
1503
+ this.params = params;
1504
+ this.size = size2;
1592
1505
  }
1593
1506
  };
1594
- var InvalidStorageKeySizeError = class extends BaseError {
1595
- constructor({ storageKey }) {
1596
- super(`Size for storage key "${storageKey}" is invalid. Expected 32 bytes. Got ${Math.floor((storageKey.length - 2) / 2)} bytes.`, { name: "InvalidStorageKeySizeError" });
1507
+ var AbiDecodingZeroDataError = class extends BaseError {
1508
+ constructor({ cause } = {}) {
1509
+ super('Cannot decode zero data ("0x") with ABI parameters.', {
1510
+ name: "AbiDecodingZeroDataError",
1511
+ cause
1512
+ });
1597
1513
  }
1598
1514
  };
1599
- var TransactionExecutionError = class extends BaseError {
1600
- constructor(cause, { account, docsPath, chain, data, gas, gasPrice, maxFeePerGas, maxPriorityFeePerGas, nonce, to, value }) {
1601
- const prettyArgs = prettyPrint({
1602
- chain: chain && `${chain?.name} (id: ${chain?.id})`,
1603
- from: account?.address,
1604
- to,
1605
- value: typeof value !== "undefined" && `${formatEther2(value)} ${chain?.nativeCurrency?.symbol || "ETH"}`,
1606
- data,
1607
- gas,
1608
- gasPrice: typeof gasPrice !== "undefined" && `${formatGwei2(gasPrice)} gwei`,
1609
- maxFeePerGas: typeof maxFeePerGas !== "undefined" && `${formatGwei2(maxFeePerGas)} gwei`,
1610
- maxPriorityFeePerGas: typeof maxPriorityFeePerGas !== "undefined" && `${formatGwei2(maxPriorityFeePerGas)} gwei`,
1611
- nonce
1515
+ var AbiEncodingArrayLengthMismatchError = class extends BaseError {
1516
+ constructor({ expectedLength, givenLength, type }) {
1517
+ super([
1518
+ `ABI encoding array length mismatch for type ${type}.`,
1519
+ `Expected length: ${expectedLength}`,
1520
+ `Given length: ${givenLength}`
1521
+ ].join("\n"), { name: "AbiEncodingArrayLengthMismatchError" });
1522
+ }
1523
+ };
1524
+ var AbiEncodingBytesSizeMismatchError = class extends BaseError {
1525
+ constructor({ expectedSize, value }) {
1526
+ super(`Size of bytes "${value}" (bytes${size(value)}) does not match expected size (bytes${expectedSize}).`, { name: "AbiEncodingBytesSizeMismatchError" });
1527
+ }
1528
+ };
1529
+ var AbiEncodingLengthMismatchError = class extends BaseError {
1530
+ constructor({ expectedLength, givenLength }) {
1531
+ super([
1532
+ "ABI encoding params/values length mismatch.",
1533
+ `Expected length (params): ${expectedLength}`,
1534
+ `Given length (values): ${givenLength}`
1535
+ ].join("\n"), { name: "AbiEncodingLengthMismatchError" });
1536
+ }
1537
+ };
1538
+ var AbiErrorInputsNotFoundError = class extends BaseError {
1539
+ constructor(errorName, { docsPath }) {
1540
+ super([
1541
+ `Arguments (\`args\`) were provided to "${errorName}", but "${errorName}" on the ABI does not contain any parameters (\`inputs\`).`,
1542
+ "Cannot encode error result without knowing what the parameter types are.",
1543
+ "Make sure you are using the correct ABI and that the inputs exist on it."
1544
+ ].join("\n"), {
1545
+ docsPath,
1546
+ name: "AbiErrorInputsNotFoundError"
1612
1547
  });
1613
- super(cause.shortMessage, {
1614
- cause,
1548
+ }
1549
+ };
1550
+ var AbiErrorNotFoundError = class extends BaseError {
1551
+ constructor(errorName, { docsPath } = {}) {
1552
+ super([
1553
+ `Error ${errorName ? `"${errorName}" ` : ""}not found on ABI.`,
1554
+ "Make sure you are using the correct ABI and that the error exists on it."
1555
+ ].join("\n"), {
1615
1556
  docsPath,
1616
- metaMessages: [
1617
- ...cause.metaMessages ? [...cause.metaMessages, " "] : [],
1618
- "Request Arguments:",
1619
- prettyArgs
1620
- ].filter(Boolean),
1621
- name: "TransactionExecutionError"
1557
+ name: "AbiErrorNotFoundError"
1622
1558
  });
1623
- Object.defineProperty(this, "cause", {
1559
+ }
1560
+ };
1561
+ var AbiErrorSignatureNotFoundError = class extends BaseError {
1562
+ constructor(signature, { docsPath, cause }) {
1563
+ super([
1564
+ `Encoded error signature "${signature}" not found on ABI.`,
1565
+ "Make sure you are using the correct ABI and that the error exists on it.",
1566
+ `You can look up the decoded signature here: https://4byte.sourcify.dev/?q=${signature}.`
1567
+ ].join("\n"), {
1568
+ docsPath,
1569
+ name: "AbiErrorSignatureNotFoundError",
1570
+ cause
1571
+ });
1572
+ Object.defineProperty(this, "signature", {
1624
1573
  enumerable: true,
1625
1574
  configurable: true,
1626
1575
  writable: true,
1627
1576
  value: void 0
1628
1577
  });
1629
- this.cause = cause;
1578
+ this.signature = signature;
1630
1579
  }
1631
1580
  };
1632
- var TransactionNotFoundError = class extends BaseError {
1633
- constructor({ blockHash, blockNumber, blockTag, hash, index }) {
1634
- let identifier = "Transaction";
1635
- if (blockTag && index !== void 0)
1636
- identifier = `Transaction at block time "${blockTag}" at index "${index}"`;
1637
- if (blockHash && index !== void 0)
1638
- identifier = `Transaction at block hash "${blockHash}" at index "${index}"`;
1639
- if (blockNumber && index !== void 0)
1640
- identifier = `Transaction at block number "${blockNumber}" at index "${index}"`;
1641
- if (hash)
1642
- identifier = `Transaction with hash "${hash}"`;
1643
- super(`${identifier} could not be found.`, {
1644
- name: "TransactionNotFoundError"
1581
+ var AbiEventSignatureEmptyTopicsError = class extends BaseError {
1582
+ constructor({ docsPath }) {
1583
+ super("Cannot extract event signature from empty topics.", {
1584
+ docsPath,
1585
+ name: "AbiEventSignatureEmptyTopicsError"
1645
1586
  });
1646
1587
  }
1647
1588
  };
1648
- var TransactionReceiptNotFoundError = class extends BaseError {
1649
- constructor({ hash }) {
1650
- super(`Transaction receipt with hash "${hash}" could not be found. The Transaction may not be processed on a block yet.`, {
1651
- name: "TransactionReceiptNotFoundError"
1589
+ var AbiEventSignatureNotFoundError = class extends BaseError {
1590
+ constructor(signature, { docsPath }) {
1591
+ super([
1592
+ `Encoded event signature "${signature}" not found on ABI.`,
1593
+ "Make sure you are using the correct ABI and that the event exists on it.",
1594
+ `You can look up the signature here: https://4byte.sourcify.dev/?q=${signature}.`
1595
+ ].join("\n"), {
1596
+ docsPath,
1597
+ name: "AbiEventSignatureNotFoundError"
1598
+ });
1599
+ }
1600
+ };
1601
+ var AbiEventNotFoundError = class extends BaseError {
1602
+ constructor(eventName, { docsPath } = {}) {
1603
+ super([
1604
+ `Event ${eventName ? `"${eventName}" ` : ""}not found on ABI.`,
1605
+ "Make sure you are using the correct ABI and that the event exists on it."
1606
+ ].join("\n"), {
1607
+ docsPath,
1608
+ name: "AbiEventNotFoundError"
1609
+ });
1610
+ }
1611
+ };
1612
+ var AbiFunctionNotFoundError = class extends BaseError {
1613
+ constructor(functionName, { docsPath } = {}) {
1614
+ super([
1615
+ `Function ${functionName ? `"${functionName}" ` : ""}not found on ABI.`,
1616
+ "Make sure you are using the correct ABI and that the function exists on it."
1617
+ ].join("\n"), {
1618
+ docsPath,
1619
+ name: "AbiFunctionNotFoundError"
1620
+ });
1621
+ }
1622
+ };
1623
+ var AbiFunctionOutputsNotFoundError = class extends BaseError {
1624
+ constructor(functionName, { docsPath }) {
1625
+ super([
1626
+ `Function "${functionName}" does not contain any \`outputs\` on ABI.`,
1627
+ "Cannot decode function result without knowing what the parameter types are.",
1628
+ "Make sure you are using the correct ABI and that the function exists on it."
1629
+ ].join("\n"), {
1630
+ docsPath,
1631
+ name: "AbiFunctionOutputsNotFoundError"
1632
+ });
1633
+ }
1634
+ };
1635
+ var AbiFunctionSignatureNotFoundError = class extends BaseError {
1636
+ constructor(signature, { docsPath }) {
1637
+ super([
1638
+ `Encoded function signature "${signature}" not found on ABI.`,
1639
+ "Make sure you are using the correct ABI and that the function exists on it.",
1640
+ `You can look up the signature here: https://4byte.sourcify.dev/?q=${signature}.`
1641
+ ].join("\n"), {
1642
+ docsPath,
1643
+ name: "AbiFunctionSignatureNotFoundError"
1644
+ });
1645
+ }
1646
+ };
1647
+ var AbiItemAmbiguityError = class extends BaseError {
1648
+ constructor(x, y) {
1649
+ super("Found ambiguous types in overloaded ABI items.", {
1650
+ metaMessages: [
1651
+ `\`${x.type}\` in \`${formatAbiItem(x.abiItem)}\`, and`,
1652
+ `\`${y.type}\` in \`${formatAbiItem(y.abiItem)}\``,
1653
+ "",
1654
+ "These types encode differently and cannot be distinguished at runtime.",
1655
+ "Remove one of the ambiguous items in the ABI."
1656
+ ],
1657
+ name: "AbiItemAmbiguityError"
1658
+ });
1659
+ }
1660
+ };
1661
+ var BytesSizeMismatchError = class extends BaseError {
1662
+ constructor({ expectedSize, givenSize }) {
1663
+ super(`Expected bytes${expectedSize}, got bytes${givenSize}.`, {
1664
+ name: "BytesSizeMismatchError"
1652
1665
  });
1653
1666
  }
1654
1667
  };
1655
- var TransactionReceiptRevertedError = class extends BaseError {
1656
- constructor({ receipt }) {
1657
- super(`Transaction with hash "${receipt.transactionHash}" reverted.`, {
1668
+ var DecodeLogDataMismatch = class extends BaseError {
1669
+ constructor({ abiItem, data, params, size: size2 }) {
1670
+ super([
1671
+ `Data size of ${size2} bytes is too small for non-indexed event parameters.`
1672
+ ].join("\n"), {
1658
1673
  metaMessages: [
1659
- 'The receipt marked the transaction as "reverted". This could mean that the function on the contract you are trying to call threw an error.',
1660
- " ",
1661
- "You can attempt to extract the revert reason by:",
1662
- "- calling the `simulateContract` or `simulateCalls` Action with the `abi` and `functionName` of the contract",
1663
- "- using the `call` Action with raw `data`"
1674
+ `Params: (${formatAbiParams(params, { includeName: true })})`,
1675
+ `Data: ${data} (${size2} bytes)`
1664
1676
  ],
1665
- name: "TransactionReceiptRevertedError"
1677
+ name: "DecodeLogDataMismatch"
1666
1678
  });
1667
- Object.defineProperty(this, "receipt", {
1679
+ Object.defineProperty(this, "abiItem", {
1668
1680
  enumerable: true,
1669
1681
  configurable: true,
1670
1682
  writable: true,
1671
1683
  value: void 0
1672
1684
  });
1673
- this.receipt = receipt;
1674
- }
1675
- };
1676
- var WaitForTransactionReceiptTimeoutError = class extends BaseError {
1677
- constructor({ hash }) {
1678
- super(`Timed out while waiting for transaction with hash "${hash}" to be confirmed.`, { name: "WaitForTransactionReceiptTimeoutError" });
1679
- }
1680
- };
1681
-
1682
- // node_modules/viem/_esm/errors/node.js
1683
- var ExecutionRevertedError = class extends BaseError {
1684
- constructor({ cause, message } = {}) {
1685
- const reason = message?.replace("execution reverted: ", "")?.replace("execution reverted", "");
1686
- super(`Execution reverted ${reason ? `with reason: ${reason}` : "for an unknown reason"}.`, {
1687
- cause,
1688
- name: "ExecutionRevertedError"
1685
+ Object.defineProperty(this, "data", {
1686
+ enumerable: true,
1687
+ configurable: true,
1688
+ writable: true,
1689
+ value: void 0
1689
1690
  });
1690
- }
1691
- };
1692
- Object.defineProperty(ExecutionRevertedError, "code", {
1693
- enumerable: true,
1694
- configurable: true,
1695
- writable: true,
1696
- value: 3
1697
- });
1698
- Object.defineProperty(ExecutionRevertedError, "nodeMessage", {
1699
- enumerable: true,
1700
- configurable: true,
1701
- writable: true,
1702
- value: /execution reverted|gas required exceeds allowance/
1703
- });
1704
- var FeeCapTooHighError = class extends BaseError {
1705
- constructor({ cause, maxFeePerGas } = {}) {
1706
- super(`The fee cap (\`maxFeePerGas\`${maxFeePerGas ? ` = ${formatGwei2(maxFeePerGas)} gwei` : ""}) cannot be higher than the maximum allowed value (2^256-1).`, {
1707
- cause,
1708
- name: "FeeCapTooHighError"
1691
+ Object.defineProperty(this, "params", {
1692
+ enumerable: true,
1693
+ configurable: true,
1694
+ writable: true,
1695
+ value: void 0
1709
1696
  });
1710
- }
1711
- };
1712
- Object.defineProperty(FeeCapTooHighError, "nodeMessage", {
1713
- enumerable: true,
1714
- configurable: true,
1715
- writable: true,
1716
- value: /max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/
1717
- });
1718
- var FeeCapTooLowError = class extends BaseError {
1719
- constructor({ cause, maxFeePerGas } = {}) {
1720
- super(`The fee cap (\`maxFeePerGas\`${maxFeePerGas ? ` = ${formatGwei2(maxFeePerGas)}` : ""} gwei) cannot be lower than the block base fee.`, {
1721
- cause,
1722
- name: "FeeCapTooLowError"
1697
+ Object.defineProperty(this, "size", {
1698
+ enumerable: true,
1699
+ configurable: true,
1700
+ writable: true,
1701
+ value: void 0
1723
1702
  });
1703
+ this.abiItem = abiItem;
1704
+ this.data = data;
1705
+ this.params = params;
1706
+ this.size = size2;
1724
1707
  }
1725
1708
  };
1726
- Object.defineProperty(FeeCapTooLowError, "nodeMessage", {
1727
- enumerable: true,
1728
- configurable: true,
1729
- writable: true,
1730
- value: /max fee per gas less than block base fee|fee cap less than block base fee|transaction is outdated/
1731
- });
1732
- var NonceTooHighError = class extends BaseError {
1733
- constructor({ cause, nonce } = {}) {
1734
- super(`Nonce provided for the transaction ${nonce ? `(${nonce}) ` : ""}is higher than the next one expected.`, { cause, name: "NonceTooHighError" });
1709
+ var DecodeLogTopicsMismatch = class extends BaseError {
1710
+ constructor({ abiItem, param }) {
1711
+ super([
1712
+ `Expected a topic for indexed event parameter${param.name ? ` "${param.name}"` : ""} on event "${formatAbiItem(abiItem, { includeName: true })}".`
1713
+ ].join("\n"), { name: "DecodeLogTopicsMismatch" });
1714
+ Object.defineProperty(this, "abiItem", {
1715
+ enumerable: true,
1716
+ configurable: true,
1717
+ writable: true,
1718
+ value: void 0
1719
+ });
1720
+ this.abiItem = abiItem;
1735
1721
  }
1736
1722
  };
1737
- Object.defineProperty(NonceTooHighError, "nodeMessage", {
1738
- enumerable: true,
1739
- configurable: true,
1740
- writable: true,
1741
- value: /nonce too high/
1742
- });
1743
- var NonceTooLowError = class extends BaseError {
1744
- constructor({ cause, nonce } = {}) {
1723
+ var InvalidAbiEncodingTypeError = class extends BaseError {
1724
+ constructor(type, { docsPath }) {
1745
1725
  super([
1746
- `Nonce provided for the transaction ${nonce ? `(${nonce}) ` : ""}is lower than the current nonce of the account.`,
1747
- "Try increasing the nonce or find the latest nonce with `getTransactionCount`."
1748
- ].join("\n"), { cause, name: "NonceTooLowError" });
1726
+ `Type "${type}" is not a valid encoding type.`,
1727
+ "Please provide a valid ABI type."
1728
+ ].join("\n"), { docsPath, name: "InvalidAbiEncodingType" });
1749
1729
  }
1750
1730
  };
1751
- Object.defineProperty(NonceTooLowError, "nodeMessage", {
1752
- enumerable: true,
1753
- configurable: true,
1754
- writable: true,
1755
- value: /nonce too low|transaction already imported|already known/
1756
- });
1757
- var NonceMaxValueError = class extends BaseError {
1758
- constructor({ cause, nonce } = {}) {
1759
- super(`Nonce provided for the transaction ${nonce ? `(${nonce}) ` : ""}exceeds the maximum allowed nonce.`, { cause, name: "NonceMaxValueError" });
1731
+ var InvalidAbiDecodingTypeError = class extends BaseError {
1732
+ constructor(type, { docsPath }) {
1733
+ super([
1734
+ `Type "${type}" is not a valid decoding type.`,
1735
+ "Please provide a valid ABI type."
1736
+ ].join("\n"), { docsPath, name: "InvalidAbiDecodingType" });
1760
1737
  }
1761
1738
  };
1762
- Object.defineProperty(NonceMaxValueError, "nodeMessage", {
1763
- enumerable: true,
1764
- configurable: true,
1765
- writable: true,
1766
- value: /nonce has max value/
1767
- });
1768
- var InsufficientFundsError = class extends BaseError {
1769
- constructor({ cause } = {}) {
1770
- super([
1771
- "The total cost (gas * gas fee + value) of executing this transaction exceeds the balance of the account."
1772
- ].join("\n"), {
1773
- cause,
1774
- metaMessages: [
1775
- "This error could arise when the account does not have enough funds to:",
1776
- " - pay for the total gas fee,",
1777
- " - pay for the value to send.",
1778
- " ",
1779
- "The cost of the transaction is calculated as `gas * gas fee + value`, where:",
1780
- " - `gas` is the amount of gas needed for transaction to execute,",
1781
- " - `gas fee` is the gas fee,",
1782
- " - `value` is the amount of ether to send to the recipient."
1783
- ],
1784
- name: "InsufficientFundsError"
1739
+ var InvalidArrayError = class extends BaseError {
1740
+ constructor(value) {
1741
+ super([`Value "${value}" is not a valid array.`].join("\n"), {
1742
+ name: "InvalidArrayError"
1785
1743
  });
1786
1744
  }
1787
1745
  };
1788
- Object.defineProperty(InsufficientFundsError, "nodeMessage", {
1789
- enumerable: true,
1790
- configurable: true,
1791
- writable: true,
1792
- value: /insufficient funds|exceeds transaction sender account balance/
1793
- });
1794
- var IntrinsicGasTooHighError = class extends BaseError {
1795
- constructor({ cause, gas } = {}) {
1796
- super(`The amount of gas ${gas ? `(${gas}) ` : ""}provided for the transaction exceeds the limit allowed for the block.`, {
1797
- cause,
1798
- name: "IntrinsicGasTooHighError"
1799
- });
1746
+ var InvalidDefinitionTypeError = class extends BaseError {
1747
+ constructor(type) {
1748
+ super([
1749
+ `"${type}" is not a valid definition type.`,
1750
+ 'Valid types: "function", "event", "error"'
1751
+ ].join("\n"), { name: "InvalidDefinitionTypeError" });
1800
1752
  }
1801
1753
  };
1802
- Object.defineProperty(IntrinsicGasTooHighError, "nodeMessage", {
1803
- enumerable: true,
1804
- configurable: true,
1805
- writable: true,
1806
- value: /intrinsic gas too high|gas limit reached/
1807
- });
1808
- var IntrinsicGasTooLowError = class extends BaseError {
1809
- constructor({ cause, gas } = {}) {
1810
- super(`The amount of gas ${gas ? `(${gas}) ` : ""}provided for the transaction is too low.`, {
1811
- cause,
1812
- name: "IntrinsicGasTooLowError"
1754
+ var UnsupportedPackedAbiType = class extends BaseError {
1755
+ constructor(type) {
1756
+ super(`Type "${type}" is not supported for packed encoding.`, {
1757
+ name: "UnsupportedPackedAbiType"
1813
1758
  });
1814
1759
  }
1815
1760
  };
1816
- Object.defineProperty(IntrinsicGasTooLowError, "nodeMessage", {
1817
- enumerable: true,
1818
- configurable: true,
1819
- writable: true,
1820
- value: /intrinsic gas too low/
1821
- });
1822
- var TransactionTypeNotSupportedError = class extends BaseError {
1823
- constructor({ cause }) {
1824
- super("The transaction type is not supported for this chain.", {
1825
- cause,
1826
- name: "TransactionTypeNotSupportedError"
1761
+
1762
+ // node_modules/viem/_esm/utils/regex.js
1763
+ var arrayRegex = /^(.*)\[([0-9]*)\]$/;
1764
+ var bytesRegex = /^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/;
1765
+ 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)?$/;
1766
+
1767
+ // node_modules/viem/_esm/utils/abi/encodeAbiParameters.js
1768
+ function encodeAbiParameters(params, values) {
1769
+ if (params.length !== values.length)
1770
+ throw new AbiEncodingLengthMismatchError({
1771
+ expectedLength: params.length,
1772
+ givenLength: values.length
1827
1773
  });
1774
+ const preparedParams = prepareParams({
1775
+ params,
1776
+ values
1777
+ });
1778
+ return encodeParams(preparedParams);
1779
+ }
1780
+ function prepareParams({ params, values }) {
1781
+ const preparedParams = [];
1782
+ for (let i = 0; i < params.length; i++) {
1783
+ preparedParams.push(prepareParam({ param: params[i], value: values[i] }));
1828
1784
  }
1829
- };
1830
- Object.defineProperty(TransactionTypeNotSupportedError, "nodeMessage", {
1831
- enumerable: true,
1832
- configurable: true,
1833
- writable: true,
1834
- value: /transaction type not valid/
1835
- });
1836
- var TipAboveFeeCapError = class extends BaseError {
1837
- constructor({ cause, maxPriorityFeePerGas, maxFeePerGas } = {}) {
1838
- super([
1839
- `The provided tip (\`maxPriorityFeePerGas\`${maxPriorityFeePerGas ? ` = ${formatGwei2(maxPriorityFeePerGas)} gwei` : ""}) cannot be higher than the fee cap (\`maxFeePerGas\`${maxFeePerGas ? ` = ${formatGwei2(maxFeePerGas)} gwei` : ""}).`
1840
- ].join("\n"), {
1841
- cause,
1842
- name: "TipAboveFeeCapError"
1785
+ return preparedParams;
1786
+ }
1787
+ function prepareParam({ param, value }) {
1788
+ const arrayComponents = getArrayComponents(param.type);
1789
+ if (arrayComponents) {
1790
+ const [length, type] = arrayComponents;
1791
+ return encodeArray(value, { length, param: { ...param, type } });
1792
+ }
1793
+ if (param.type === "tuple") {
1794
+ return encodeTuple(value, {
1795
+ param
1843
1796
  });
1844
1797
  }
1845
- };
1846
- Object.defineProperty(TipAboveFeeCapError, "nodeMessage", {
1847
- enumerable: true,
1848
- configurable: true,
1849
- writable: true,
1850
- value: /max priority fee per gas higher than max fee per gas|tip higher than fee cap/
1851
- });
1852
- var UnknownNodeError = class extends BaseError {
1853
- constructor({ cause }) {
1854
- super(`An error occurred while executing: ${cause?.shortMessage}`, {
1855
- cause,
1856
- name: "UnknownNodeError"
1798
+ if (param.type === "address") {
1799
+ return encodeAddress(value);
1800
+ }
1801
+ if (param.type === "bool") {
1802
+ return encodeBool(value);
1803
+ }
1804
+ if (param.type.startsWith("uint") || param.type.startsWith("int")) {
1805
+ const signed = param.type.startsWith("int");
1806
+ const [, , size2 = "256"] = integerRegex.exec(param.type) ?? [];
1807
+ return encodeNumber(value, {
1808
+ signed,
1809
+ size: Number(size2)
1857
1810
  });
1858
1811
  }
1859
- };
1860
-
1861
- // node_modules/viem/_esm/constants/number.js
1862
- var maxInt8 = 2n ** (8n - 1n) - 1n;
1863
- var maxInt16 = 2n ** (16n - 1n) - 1n;
1864
- var maxInt24 = 2n ** (24n - 1n) - 1n;
1865
- var maxInt32 = 2n ** (32n - 1n) - 1n;
1866
- var maxInt40 = 2n ** (40n - 1n) - 1n;
1867
- var maxInt48 = 2n ** (48n - 1n) - 1n;
1868
- var maxInt56 = 2n ** (56n - 1n) - 1n;
1869
- var maxInt64 = 2n ** (64n - 1n) - 1n;
1870
- var maxInt72 = 2n ** (72n - 1n) - 1n;
1871
- var maxInt80 = 2n ** (80n - 1n) - 1n;
1872
- var maxInt88 = 2n ** (88n - 1n) - 1n;
1873
- var maxInt96 = 2n ** (96n - 1n) - 1n;
1874
- var maxInt104 = 2n ** (104n - 1n) - 1n;
1875
- var maxInt112 = 2n ** (112n - 1n) - 1n;
1876
- var maxInt120 = 2n ** (120n - 1n) - 1n;
1877
- var maxInt128 = 2n ** (128n - 1n) - 1n;
1878
- var maxInt136 = 2n ** (136n - 1n) - 1n;
1879
- var maxInt144 = 2n ** (144n - 1n) - 1n;
1880
- var maxInt152 = 2n ** (152n - 1n) - 1n;
1881
- var maxInt160 = 2n ** (160n - 1n) - 1n;
1882
- var maxInt168 = 2n ** (168n - 1n) - 1n;
1883
- var maxInt176 = 2n ** (176n - 1n) - 1n;
1884
- var maxInt184 = 2n ** (184n - 1n) - 1n;
1885
- var maxInt192 = 2n ** (192n - 1n) - 1n;
1886
- var maxInt200 = 2n ** (200n - 1n) - 1n;
1887
- var maxInt208 = 2n ** (208n - 1n) - 1n;
1888
- var maxInt216 = 2n ** (216n - 1n) - 1n;
1889
- var maxInt224 = 2n ** (224n - 1n) - 1n;
1890
- var maxInt232 = 2n ** (232n - 1n) - 1n;
1891
- var maxInt240 = 2n ** (240n - 1n) - 1n;
1892
- var maxInt248 = 2n ** (248n - 1n) - 1n;
1893
- var maxInt256 = 2n ** (256n - 1n) - 1n;
1894
- var minInt8 = -(2n ** (8n - 1n));
1895
- var minInt16 = -(2n ** (16n - 1n));
1896
- var minInt24 = -(2n ** (24n - 1n));
1897
- var minInt32 = -(2n ** (32n - 1n));
1898
- var minInt40 = -(2n ** (40n - 1n));
1899
- var minInt48 = -(2n ** (48n - 1n));
1900
- var minInt56 = -(2n ** (56n - 1n));
1901
- var minInt64 = -(2n ** (64n - 1n));
1902
- var minInt72 = -(2n ** (72n - 1n));
1903
- var minInt80 = -(2n ** (80n - 1n));
1904
- var minInt88 = -(2n ** (88n - 1n));
1905
- var minInt96 = -(2n ** (96n - 1n));
1906
- var minInt104 = -(2n ** (104n - 1n));
1907
- var minInt112 = -(2n ** (112n - 1n));
1908
- var minInt120 = -(2n ** (120n - 1n));
1909
- var minInt128 = -(2n ** (128n - 1n));
1910
- var minInt136 = -(2n ** (136n - 1n));
1911
- var minInt144 = -(2n ** (144n - 1n));
1912
- var minInt152 = -(2n ** (152n - 1n));
1913
- var minInt160 = -(2n ** (160n - 1n));
1914
- var minInt168 = -(2n ** (168n - 1n));
1915
- var minInt176 = -(2n ** (176n - 1n));
1916
- var minInt184 = -(2n ** (184n - 1n));
1917
- var minInt192 = -(2n ** (192n - 1n));
1918
- var minInt200 = -(2n ** (200n - 1n));
1919
- var minInt208 = -(2n ** (208n - 1n));
1920
- var minInt216 = -(2n ** (216n - 1n));
1921
- var minInt224 = -(2n ** (224n - 1n));
1922
- var minInt232 = -(2n ** (232n - 1n));
1923
- var minInt240 = -(2n ** (240n - 1n));
1924
- var minInt248 = -(2n ** (248n - 1n));
1925
- var minInt256 = -(2n ** (256n - 1n));
1926
- var maxUint8 = 2n ** 8n - 1n;
1927
- var maxUint16 = 2n ** 16n - 1n;
1928
- var maxUint24 = 2n ** 24n - 1n;
1929
- var maxUint32 = 2n ** 32n - 1n;
1930
- var maxUint40 = 2n ** 40n - 1n;
1931
- var maxUint48 = 2n ** 48n - 1n;
1932
- var maxUint56 = 2n ** 56n - 1n;
1933
- var maxUint64 = 2n ** 64n - 1n;
1934
- var maxUint72 = 2n ** 72n - 1n;
1935
- var maxUint80 = 2n ** 80n - 1n;
1936
- var maxUint88 = 2n ** 88n - 1n;
1937
- var maxUint96 = 2n ** 96n - 1n;
1938
- var maxUint104 = 2n ** 104n - 1n;
1939
- var maxUint112 = 2n ** 112n - 1n;
1940
- var maxUint120 = 2n ** 120n - 1n;
1941
- var maxUint128 = 2n ** 128n - 1n;
1942
- var maxUint136 = 2n ** 136n - 1n;
1943
- var maxUint144 = 2n ** 144n - 1n;
1944
- var maxUint152 = 2n ** 152n - 1n;
1945
- var maxUint160 = 2n ** 160n - 1n;
1946
- var maxUint168 = 2n ** 168n - 1n;
1947
- var maxUint176 = 2n ** 176n - 1n;
1948
- var maxUint184 = 2n ** 184n - 1n;
1949
- var maxUint192 = 2n ** 192n - 1n;
1950
- var maxUint200 = 2n ** 200n - 1n;
1951
- var maxUint208 = 2n ** 208n - 1n;
1952
- var maxUint216 = 2n ** 216n - 1n;
1953
- var maxUint224 = 2n ** 224n - 1n;
1954
- var maxUint232 = 2n ** 232n - 1n;
1955
- var maxUint240 = 2n ** 240n - 1n;
1956
- var maxUint248 = 2n ** 248n - 1n;
1957
- var maxUint256 = 2n ** 256n - 1n;
1958
-
1959
- // node_modules/viem/_esm/errors/chain.js
1960
- var ChainDoesNotSupportContract = class extends BaseError {
1961
- constructor({ blockNumber, chain, contract }) {
1962
- super(`Chain "${chain.name}" does not support contract "${contract.name}".`, {
1963
- metaMessages: [
1964
- "This could be due to any of the following:",
1965
- ...blockNumber && contract.blockCreated && contract.blockCreated > blockNumber ? [
1966
- `- The contract "${contract.name}" was not deployed until block ${contract.blockCreated} (current block ${blockNumber}).`
1967
- ] : [
1968
- `- The chain does not have the contract "${contract.name}" configured.`
1969
- ]
1970
- ],
1971
- name: "ChainDoesNotSupportContract"
1812
+ if (param.type.startsWith("bytes")) {
1813
+ return encodeBytes(value, { param });
1814
+ }
1815
+ if (param.type === "string") {
1816
+ return encodeString(value);
1817
+ }
1818
+ throw new InvalidAbiEncodingTypeError(param.type, {
1819
+ docsPath: "/docs/contract/encodeAbiParameters"
1820
+ });
1821
+ }
1822
+ function encodeParams(preparedParams) {
1823
+ let staticSize = 0;
1824
+ for (let i = 0; i < preparedParams.length; i++) {
1825
+ const { dynamic, encoded } = preparedParams[i];
1826
+ if (dynamic)
1827
+ staticSize += 32;
1828
+ else
1829
+ staticSize += size(encoded);
1830
+ }
1831
+ const staticParams = [];
1832
+ const dynamicParams = [];
1833
+ let dynamicSize = 0;
1834
+ for (let i = 0; i < preparedParams.length; i++) {
1835
+ const { dynamic, encoded } = preparedParams[i];
1836
+ if (dynamic) {
1837
+ staticParams.push(numberToHex(staticSize + dynamicSize, { size: 32 }));
1838
+ dynamicParams.push(encoded);
1839
+ dynamicSize += size(encoded);
1840
+ } else {
1841
+ staticParams.push(encoded);
1842
+ }
1843
+ }
1844
+ return concatHex([...staticParams, ...dynamicParams]);
1845
+ }
1846
+ function encodeAddress(value) {
1847
+ if (!isAddress(value))
1848
+ throw new InvalidAddressError({ address: value });
1849
+ return { dynamic: false, encoded: padHex(value.toLowerCase()) };
1850
+ }
1851
+ function encodeArray(value, { length, param }) {
1852
+ const dynamic = length === null;
1853
+ if (!Array.isArray(value))
1854
+ throw new InvalidArrayError(value);
1855
+ if (!dynamic && value.length !== length)
1856
+ throw new AbiEncodingArrayLengthMismatchError({
1857
+ expectedLength: length,
1858
+ givenLength: value.length,
1859
+ type: `${param.type}[${length}]`
1972
1860
  });
1861
+ let dynamicChild = value.length === 0 && isDynamicType(param);
1862
+ const preparedParams = [];
1863
+ for (let i = 0; i < value.length; i++) {
1864
+ const preparedParam = prepareParam({ param, value: value[i] });
1865
+ if (preparedParam.dynamic)
1866
+ dynamicChild = true;
1867
+ preparedParams.push(preparedParam);
1973
1868
  }
1974
- };
1975
- var ChainMismatchError = class extends BaseError {
1976
- constructor({ chain, currentChainId }) {
1977
- super(`The current chain of the wallet (id: ${currentChainId}) does not match the target chain for the transaction (id: ${chain.id} \u2013 ${chain.name}).`, {
1978
- metaMessages: [
1979
- `Current Chain ID: ${currentChainId}`,
1980
- `Expected Chain ID: ${chain.id} \u2013 ${chain.name}`
1981
- ],
1982
- name: "ChainMismatchError"
1869
+ if (dynamic || dynamicChild) {
1870
+ const data = encodeParams(preparedParams);
1871
+ if (dynamic) {
1872
+ const length2 = numberToHex(preparedParams.length, { size: 32 });
1873
+ return {
1874
+ dynamic: true,
1875
+ encoded: concatHex([length2, data])
1876
+ };
1877
+ }
1878
+ if (dynamicChild)
1879
+ return { dynamic: true, encoded: data };
1880
+ }
1881
+ return {
1882
+ dynamic: false,
1883
+ encoded: concatHex(preparedParams.map(({ encoded }) => encoded))
1884
+ };
1885
+ }
1886
+ function encodeBytes(value, { param }) {
1887
+ const [, paramSize] = param.type.split("bytes");
1888
+ const bytesSize = size(value);
1889
+ if (!paramSize) {
1890
+ let value_ = value;
1891
+ if (bytesSize % 32 !== 0)
1892
+ value_ = padHex(value_, {
1893
+ dir: "right",
1894
+ size: Math.ceil((value.length - 2) / 2 / 32) * 32
1895
+ });
1896
+ return {
1897
+ dynamic: true,
1898
+ encoded: concatHex([
1899
+ padHex(numberToHex(bytesSize, { size: 32 })),
1900
+ value_
1901
+ ])
1902
+ };
1903
+ }
1904
+ if (bytesSize !== Number.parseInt(paramSize, 10))
1905
+ throw new AbiEncodingBytesSizeMismatchError({
1906
+ expectedSize: Number.parseInt(paramSize, 10),
1907
+ value
1983
1908
  });
1909
+ return { dynamic: false, encoded: padHex(value, { dir: "right" }) };
1910
+ }
1911
+ function encodeBool(value) {
1912
+ if (typeof value !== "boolean")
1913
+ throw new BaseError(`Invalid boolean value: "${value}" (type: ${typeof value}). Expected: \`true\` or \`false\`.`);
1914
+ return { dynamic: false, encoded: padHex(boolToHex(value)) };
1915
+ }
1916
+ function encodeNumber(value, { signed, size: size2 = 256 }) {
1917
+ if (typeof size2 === "number") {
1918
+ const max = 2n ** (BigInt(size2) - (signed ? 1n : 0n)) - 1n;
1919
+ const min = signed ? -max - 1n : 0n;
1920
+ if (value > max || value < min)
1921
+ throw new IntegerOutOfRangeError({
1922
+ max: max.toString(),
1923
+ min: min.toString(),
1924
+ signed,
1925
+ size: size2 / 8,
1926
+ value: value.toString()
1927
+ });
1984
1928
  }
1985
- };
1986
- var ChainNotFoundError = class extends BaseError {
1987
- constructor() {
1988
- super([
1989
- "No chain was provided to the request.",
1990
- "Please provide a chain with the `chain` argument on the Action, or by supplying a `chain` to WalletClient."
1991
- ].join("\n"), {
1992
- name: "ChainNotFoundError"
1993
- });
1929
+ return {
1930
+ dynamic: false,
1931
+ encoded: numberToHex(value, {
1932
+ size: 32,
1933
+ signed
1934
+ })
1935
+ };
1936
+ }
1937
+ function encodeString(value) {
1938
+ const hexValue = stringToHex(value);
1939
+ const partsLength = Math.ceil(size(hexValue) / 32);
1940
+ const parts = [];
1941
+ for (let i = 0; i < partsLength; i++) {
1942
+ parts.push(padHex(slice(hexValue, i * 32, (i + 1) * 32), {
1943
+ dir: "right"
1944
+ }));
1994
1945
  }
1995
- };
1996
- var ClientChainNotConfiguredError = class extends BaseError {
1997
- constructor() {
1998
- super("No chain was provided to the Client.", {
1999
- name: "ClientChainNotConfiguredError"
1946
+ return {
1947
+ dynamic: true,
1948
+ encoded: concatHex([
1949
+ padHex(numberToHex(size(hexValue), { size: 32 })),
1950
+ ...parts
1951
+ ])
1952
+ };
1953
+ }
1954
+ function encodeTuple(value, { param }) {
1955
+ let dynamic = false;
1956
+ const preparedParams = [];
1957
+ for (let i = 0; i < param.components.length; i++) {
1958
+ const param_ = param.components[i];
1959
+ const index = Array.isArray(value) ? i : param_.name;
1960
+ const preparedParam = prepareParam({
1961
+ param: param_,
1962
+ value: value[index]
2000
1963
  });
1964
+ preparedParams.push(preparedParam);
1965
+ if (preparedParam.dynamic)
1966
+ dynamic = true;
2001
1967
  }
2002
- };
2003
- var InvalidChainIdError = class extends BaseError {
2004
- constructor({ chainId }) {
2005
- super(typeof chainId === "number" ? `Chain ID "${chainId}" is invalid.` : "Chain ID is invalid.", { name: "InvalidChainIdError" });
2006
- }
2007
- };
1968
+ return {
1969
+ dynamic,
1970
+ encoded: dynamic ? encodeParams(preparedParams) : concatHex(preparedParams.map(({ encoded }) => encoded))
1971
+ };
1972
+ }
1973
+ function getArrayComponents(type) {
1974
+ const matches = type.match(/^(.*)\[(\d+)?\]$/);
1975
+ return matches ? (
1976
+ // Return `null` if the array is dynamic.
1977
+ [matches[2] ? Number(matches[2]) : null, matches[1]]
1978
+ ) : void 0;
1979
+ }
1980
+ function isDynamicType(param) {
1981
+ const { type } = param;
1982
+ if (type === "string")
1983
+ return true;
1984
+ if (type === "bytes")
1985
+ return true;
1986
+ if (type.endsWith("[]"))
1987
+ return true;
1988
+ if (type === "tuple")
1989
+ return param.components.some(isDynamicType);
1990
+ const arrayComponents = getArrayComponents(type);
1991
+ if (arrayComponents)
1992
+ return isDynamicType({ ...param, type: arrayComponents[1] });
1993
+ return false;
1994
+ }
1995
+
1996
+ // node_modules/viem/_esm/utils/stringify.js
1997
+ var stringify = (value, replacer, space) => JSON.stringify(value, (key, value_) => {
1998
+ const value2 = typeof value_ === "bigint" ? value_.toString() : value_;
1999
+ return typeof replacer === "function" ? replacer(key, value2) : value2;
2000
+ }, space);
2001
+
2002
+ // node_modules/viem/_esm/accounts/utils/parseAccount.js
2003
+ function parseAccount(account) {
2004
+ if (typeof account === "string")
2005
+ return { address: account, type: "json-rpc" };
2006
+ return account;
2007
+ }
2008
+
2009
+ // node_modules/viem/_esm/utils/block/formatBlockParameter.js
2010
+ function formatBlockParameter(parameters) {
2011
+ const { blockHash, blockNumber, blockTag, requireCanonical } = parameters;
2012
+ if (requireCanonical !== void 0 && !blockHash)
2013
+ throw new BaseError("`requireCanonical` can only be provided when `blockHash` is set.");
2014
+ if (blockHash)
2015
+ return requireCanonical ? { blockHash, requireCanonical } : { blockHash };
2016
+ if (typeof blockNumber === "bigint")
2017
+ return numberToHex(blockNumber);
2018
+ return blockTag ?? "latest";
2019
+ }
2008
2020
 
2009
2021
  // node_modules/viem/_esm/errors/cursor.js
2010
2022
  var NegativeOffsetError = class extends BaseError {
@@ -2194,56 +2206,9 @@ function createCursor(bytes, { recursiveReadLimit = 8192 } = {}) {
2194
2206
  return cursor;
2195
2207
  }
2196
2208
 
2197
- // node_modules/viem/_esm/utils/block/formatBlockParameter.js
2198
- function formatBlockParameter(parameters) {
2199
- const { blockHash, blockNumber, blockTag, requireCanonical } = parameters;
2200
- if (requireCanonical !== void 0 && !blockHash)
2201
- throw new BaseError("`requireCanonical` can only be provided when `blockHash` is set.");
2202
- if (blockHash)
2203
- return requireCanonical ? { blockHash, requireCanonical } : { blockHash };
2204
- if (typeof blockNumber === "bigint")
2205
- return numberToHex(blockNumber);
2206
- return blockTag ?? "latest";
2207
- }
2208
-
2209
2209
  export {
2210
- formatAbiItem,
2211
- isHex,
2212
- size,
2213
2210
  setErrorConfig,
2214
2211
  BaseError,
2215
- AbiConstructorNotFoundError,
2216
- AbiConstructorParamsNotFoundError,
2217
- AbiDecodingDataSizeInvalidError,
2218
- AbiDecodingDataSizeTooSmallError,
2219
- AbiDecodingZeroDataError,
2220
- AbiEncodingArrayLengthMismatchError,
2221
- AbiEncodingBytesSizeMismatchError,
2222
- AbiEncodingLengthMismatchError,
2223
- AbiErrorInputsNotFoundError,
2224
- AbiErrorNotFoundError,
2225
- AbiErrorSignatureNotFoundError,
2226
- AbiEventSignatureEmptyTopicsError,
2227
- AbiEventSignatureNotFoundError,
2228
- AbiEventNotFoundError,
2229
- AbiFunctionNotFoundError,
2230
- AbiFunctionOutputsNotFoundError,
2231
- AbiFunctionSignatureNotFoundError,
2232
- AbiItemAmbiguityError,
2233
- BytesSizeMismatchError,
2234
- DecodeLogDataMismatch,
2235
- DecodeLogTopicsMismatch,
2236
- InvalidAbiEncodingTypeError,
2237
- InvalidAbiDecodingTypeError,
2238
- InvalidArrayError,
2239
- InvalidDefinitionTypeError,
2240
- UnsupportedPackedAbiType,
2241
- SliceOffsetOutOfBoundsError,
2242
- SizeExceedsPaddingSizeError,
2243
- InvalidBytesLengthError,
2244
- pad,
2245
- padHex,
2246
- padBytes,
2247
2212
  IntegerOutOfRangeError,
2248
2213
  InvalidBytesBooleanError,
2249
2214
  InvalidHexBooleanError,
@@ -2252,7 +2217,20 @@ export {
2252
2217
  RlpListBoundaryExceededError,
2253
2218
  RlpTrailingBytesError,
2254
2219
  SizeOverflowError,
2220
+ SliceOffsetOutOfBoundsError,
2221
+ SizeExceedsPaddingSizeError,
2222
+ InvalidBytesLengthError,
2223
+ pad,
2224
+ padHex,
2225
+ padBytes,
2226
+ isHex,
2227
+ size,
2255
2228
  trim,
2229
+ toBytes2 as toBytes,
2230
+ boolToBytes,
2231
+ hexToBytes,
2232
+ numberToBytes,
2233
+ stringToBytes,
2256
2234
  assertSize,
2257
2235
  fromHex,
2258
2236
  hexToBigInt,
@@ -2264,32 +2242,18 @@ export {
2264
2242
  bytesToHex,
2265
2243
  numberToHex,
2266
2244
  stringToHex,
2267
- toBytes2 as toBytes,
2268
- boolToBytes,
2269
- hexToBytes,
2270
- numberToBytes,
2271
- stringToBytes,
2272
- keccak256,
2273
- InvalidAddressError,
2245
+ formatBlockParameter,
2274
2246
  LruMap,
2247
+ InvalidAddressError,
2248
+ keccak256,
2275
2249
  checksumAddress,
2276
2250
  getAddress,
2277
2251
  isAddress,
2278
2252
  concat,
2279
2253
  concatBytes,
2280
2254
  concatHex,
2281
- slice,
2282
- sliceBytes,
2283
- sliceHex,
2284
- arrayRegex,
2285
- bytesRegex,
2286
- integerRegex,
2287
- encodeAbiParameters,
2288
- getArrayComponents,
2289
- parseAccount,
2290
2255
  PositionOutOfBoundsError,
2291
2256
  createCursor,
2292
- stringify,
2293
2257
  format,
2294
2258
  from,
2295
2259
  fromEther,
@@ -2309,18 +2273,6 @@ export {
2309
2273
  TransactionReceiptNotFoundError,
2310
2274
  TransactionReceiptRevertedError,
2311
2275
  WaitForTransactionReceiptTimeoutError,
2312
- ExecutionRevertedError,
2313
- FeeCapTooHighError,
2314
- FeeCapTooLowError,
2315
- NonceTooHighError,
2316
- NonceTooLowError,
2317
- NonceMaxValueError,
2318
- InsufficientFundsError,
2319
- IntrinsicGasTooHighError,
2320
- IntrinsicGasTooLowError,
2321
- TransactionTypeNotSupportedError,
2322
- TipAboveFeeCapError,
2323
- UnknownNodeError,
2324
2276
  maxInt8,
2325
2277
  maxInt16,
2326
2278
  maxInt24,
@@ -2417,10 +2369,58 @@ export {
2417
2369
  maxUint240,
2418
2370
  maxUint248,
2419
2371
  maxUint256,
2420
- formatBlockParameter,
2421
2372
  ChainDoesNotSupportContract,
2422
2373
  ChainMismatchError,
2423
2374
  ChainNotFoundError,
2424
2375
  ClientChainNotConfiguredError,
2425
- InvalidChainIdError
2376
+ InvalidChainIdError,
2377
+ ExecutionRevertedError,
2378
+ FeeCapTooHighError,
2379
+ FeeCapTooLowError,
2380
+ NonceTooHighError,
2381
+ NonceTooLowError,
2382
+ NonceMaxValueError,
2383
+ InsufficientFundsError,
2384
+ IntrinsicGasTooHighError,
2385
+ IntrinsicGasTooLowError,
2386
+ TransactionTypeNotSupportedError,
2387
+ TipAboveFeeCapError,
2388
+ UnknownNodeError,
2389
+ slice,
2390
+ sliceBytes,
2391
+ sliceHex,
2392
+ formatAbiItem,
2393
+ AbiConstructorNotFoundError,
2394
+ AbiConstructorParamsNotFoundError,
2395
+ AbiDecodingDataSizeInvalidError,
2396
+ AbiDecodingDataSizeTooSmallError,
2397
+ AbiDecodingZeroDataError,
2398
+ AbiEncodingArrayLengthMismatchError,
2399
+ AbiEncodingBytesSizeMismatchError,
2400
+ AbiEncodingLengthMismatchError,
2401
+ AbiErrorInputsNotFoundError,
2402
+ AbiErrorNotFoundError,
2403
+ AbiErrorSignatureNotFoundError,
2404
+ AbiEventSignatureEmptyTopicsError,
2405
+ AbiEventSignatureNotFoundError,
2406
+ AbiEventNotFoundError,
2407
+ AbiFunctionNotFoundError,
2408
+ AbiFunctionOutputsNotFoundError,
2409
+ AbiFunctionSignatureNotFoundError,
2410
+ AbiItemAmbiguityError,
2411
+ BytesSizeMismatchError,
2412
+ DecodeLogDataMismatch,
2413
+ DecodeLogTopicsMismatch,
2414
+ InvalidAbiEncodingTypeError,
2415
+ InvalidAbiDecodingTypeError,
2416
+ InvalidArrayError,
2417
+ InvalidDefinitionTypeError,
2418
+ UnsupportedPackedAbiType,
2419
+ arrayRegex,
2420
+ bytesRegex,
2421
+ integerRegex,
2422
+ encodeAbiParameters,
2423
+ getArrayComponents,
2424
+ stringify,
2425
+ parseAccount
2426
2426
  };