@arp-protocol/cli 0.0.0-stage → 0.0.1
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.
- package/README.md +68 -2
- package/dist/chunks/backfill-j4hxt1w1.js +262 -0
- package/dist/chunks/ccip-qmytgn8e.js +198 -0
- package/dist/chunks/cli-0hqxver6.js +2042 -0
- package/dist/chunks/cli-0z6f3603.js +7527 -0
- package/dist/chunks/cli-3kbbwfbp.js +359 -0
- package/dist/chunks/cli-74hv4etk.js +14371 -0
- package/dist/chunks/cli-c8568g4c.js +4043 -0
- package/dist/chunks/cli-d3dy7cxe.js +2110 -0
- package/dist/chunks/cli-g5zvr10v.js +19 -0
- package/dist/chunks/cli-tyey74p3.js +303 -0
- package/dist/chunks/cli-v446mw5v.js +1033 -0
- package/dist/chunks/cli-zpft011j.js +43 -0
- package/dist/chunks/commands-dnk10vze.js +805 -0
- package/dist/chunks/env-s4585w6j.js +56 -0
- package/dist/chunks/index-3a3ssef1.js +53 -0
- package/dist/chunks/line-zy1tc2np.js +45 -0
- package/dist/chunks/node-0ydee9hy.js +593 -0
- package/dist/chunks/node-init-4v2m2vj0.js +255 -0
- package/dist/chunks/secp256k1-j2w0pmjr.js +17 -0
- package/dist/chunks/server-jmyjttvv.js +3170 -0
- package/dist/chunks/share-g8v5qe6r.js +101 -0
- package/dist/cli.js +229 -0
- package/dist/hook.js +1027 -0
- package/package.json +47 -4
|
@@ -0,0 +1,2042 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
Hash,
|
|
4
|
+
abytes,
|
|
5
|
+
aexists,
|
|
6
|
+
anumber,
|
|
7
|
+
aoutput,
|
|
8
|
+
clean,
|
|
9
|
+
createHasher,
|
|
10
|
+
rotlBH,
|
|
11
|
+
rotlBL,
|
|
12
|
+
rotlSH,
|
|
13
|
+
rotlSL,
|
|
14
|
+
split,
|
|
15
|
+
swap32IfBE,
|
|
16
|
+
toBytes,
|
|
17
|
+
u32
|
|
18
|
+
} from "./cli-3kbbwfbp.js";
|
|
19
|
+
|
|
20
|
+
// ../../node_modules/.bun/viem@2.52.0+1cd18485b0404aca/node_modules/viem/_esm/utils/data/isHex.js
|
|
21
|
+
function isHex(value, { strict = true } = {}) {
|
|
22
|
+
if (!value)
|
|
23
|
+
return false;
|
|
24
|
+
if (typeof value !== "string")
|
|
25
|
+
return false;
|
|
26
|
+
return strict ? /^0x[0-9a-fA-F]*$/.test(value) : value.startsWith("0x");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// ../../node_modules/.bun/viem@2.52.0+1cd18485b0404aca/node_modules/viem/_esm/utils/data/concat.js
|
|
30
|
+
function concat(values) {
|
|
31
|
+
if (typeof values[0] === "string")
|
|
32
|
+
return concatHex(values);
|
|
33
|
+
return concatBytes(values);
|
|
34
|
+
}
|
|
35
|
+
function concatBytes(values) {
|
|
36
|
+
let length = 0;
|
|
37
|
+
for (const arr of values) {
|
|
38
|
+
length += arr.length;
|
|
39
|
+
}
|
|
40
|
+
const result = new Uint8Array(length);
|
|
41
|
+
let offset = 0;
|
|
42
|
+
for (const arr of values) {
|
|
43
|
+
result.set(arr, offset);
|
|
44
|
+
offset += arr.length;
|
|
45
|
+
}
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
function concatHex(values) {
|
|
49
|
+
return `0x${values.reduce((acc, x) => acc + x.replace("0x", ""), "")}`;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// ../../node_modules/.bun/viem@2.52.0+1cd18485b0404aca/node_modules/viem/_esm/constants/unit.js
|
|
53
|
+
var etherUnits = {
|
|
54
|
+
gwei: 9,
|
|
55
|
+
wei: 18
|
|
56
|
+
};
|
|
57
|
+
var gweiUnits = {
|
|
58
|
+
ether: -9,
|
|
59
|
+
wei: 9
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
// ../../node_modules/.bun/viem@2.52.0+1cd18485b0404aca/node_modules/viem/_esm/utils/unit/formatUnits.js
|
|
63
|
+
function formatUnits(value, decimals) {
|
|
64
|
+
let display = value.toString();
|
|
65
|
+
const negative = display.startsWith("-");
|
|
66
|
+
if (negative)
|
|
67
|
+
display = display.slice(1);
|
|
68
|
+
display = display.padStart(decimals, "0");
|
|
69
|
+
let [integer, fraction] = [
|
|
70
|
+
display.slice(0, display.length - decimals),
|
|
71
|
+
display.slice(display.length - decimals)
|
|
72
|
+
];
|
|
73
|
+
fraction = fraction.replace(/(0+)$/, "");
|
|
74
|
+
return `${negative ? "-" : ""}${integer || "0"}${fraction ? `.${fraction}` : ""}`;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// ../../node_modules/.bun/viem@2.52.0+1cd18485b0404aca/node_modules/viem/_esm/utils/unit/formatEther.js
|
|
78
|
+
function formatEther(wei, unit = "wei") {
|
|
79
|
+
return formatUnits(wei, etherUnits[unit]);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// ../../node_modules/.bun/viem@2.52.0+1cd18485b0404aca/node_modules/viem/_esm/utils/abi/formatAbiItem.js
|
|
83
|
+
function formatAbiItem(abiItem, { includeName = false } = {}) {
|
|
84
|
+
if (abiItem.type !== "function" && abiItem.type !== "event" && abiItem.type !== "error")
|
|
85
|
+
throw new InvalidDefinitionTypeError(abiItem.type);
|
|
86
|
+
return `${abiItem.name}(${formatAbiParams(abiItem.inputs, { includeName })})`;
|
|
87
|
+
}
|
|
88
|
+
function formatAbiParams(params, { includeName = false } = {}) {
|
|
89
|
+
if (!params)
|
|
90
|
+
return "";
|
|
91
|
+
return params.map((param) => formatAbiParam(param, { includeName })).join(includeName ? ", " : ",");
|
|
92
|
+
}
|
|
93
|
+
function formatAbiParam(param, { includeName }) {
|
|
94
|
+
if (param.type.startsWith("tuple")) {
|
|
95
|
+
return `(${formatAbiParams(param.components, { includeName })})${param.type.slice("tuple".length)}`;
|
|
96
|
+
}
|
|
97
|
+
return param.type + (includeName && param.name ? ` ${param.name}` : "");
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// ../../node_modules/.bun/viem@2.52.0+1cd18485b0404aca/node_modules/viem/_esm/utils/data/size.js
|
|
101
|
+
function size(value) {
|
|
102
|
+
if (isHex(value, { strict: false }))
|
|
103
|
+
return Math.ceil((value.length - 2) / 2);
|
|
104
|
+
return value.length;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// ../../node_modules/.bun/viem@2.52.0+1cd18485b0404aca/node_modules/viem/_esm/errors/version.js
|
|
108
|
+
var version = "2.52.0";
|
|
109
|
+
|
|
110
|
+
// ../../node_modules/.bun/viem@2.52.0+1cd18485b0404aca/node_modules/viem/_esm/errors/base.js
|
|
111
|
+
var errorConfig = {
|
|
112
|
+
getDocsUrl: ({ docsBaseUrl, docsPath = "", docsSlug }) => docsPath ? `${docsBaseUrl ?? "https://viem.sh"}${docsPath}${docsSlug ? `#${docsSlug}` : ""}` : undefined,
|
|
113
|
+
version: `viem@${version}`
|
|
114
|
+
};
|
|
115
|
+
class BaseError extends Error {
|
|
116
|
+
constructor(shortMessage, args = {}) {
|
|
117
|
+
const details = (() => {
|
|
118
|
+
if (args.cause instanceof BaseError)
|
|
119
|
+
return args.cause.details;
|
|
120
|
+
if (args.cause?.message)
|
|
121
|
+
return args.cause.message;
|
|
122
|
+
return args.details;
|
|
123
|
+
})();
|
|
124
|
+
const docsPath = (() => {
|
|
125
|
+
if (args.cause instanceof BaseError)
|
|
126
|
+
return args.cause.docsPath || args.docsPath;
|
|
127
|
+
return args.docsPath;
|
|
128
|
+
})();
|
|
129
|
+
const docsUrl = errorConfig.getDocsUrl?.({ ...args, docsPath });
|
|
130
|
+
const message = [
|
|
131
|
+
shortMessage || "An error occurred.",
|
|
132
|
+
"",
|
|
133
|
+
...args.metaMessages ? [...args.metaMessages, ""] : [],
|
|
134
|
+
...docsUrl ? [`Docs: ${docsUrl}`] : [],
|
|
135
|
+
...details ? [`Details: ${details}`] : [],
|
|
136
|
+
...errorConfig.version ? [`Version: ${errorConfig.version}`] : []
|
|
137
|
+
].join(`
|
|
138
|
+
`);
|
|
139
|
+
super(message, args.cause ? { cause: args.cause } : undefined);
|
|
140
|
+
Object.defineProperty(this, "details", {
|
|
141
|
+
enumerable: true,
|
|
142
|
+
configurable: true,
|
|
143
|
+
writable: true,
|
|
144
|
+
value: undefined
|
|
145
|
+
});
|
|
146
|
+
Object.defineProperty(this, "docsPath", {
|
|
147
|
+
enumerable: true,
|
|
148
|
+
configurable: true,
|
|
149
|
+
writable: true,
|
|
150
|
+
value: undefined
|
|
151
|
+
});
|
|
152
|
+
Object.defineProperty(this, "metaMessages", {
|
|
153
|
+
enumerable: true,
|
|
154
|
+
configurable: true,
|
|
155
|
+
writable: true,
|
|
156
|
+
value: undefined
|
|
157
|
+
});
|
|
158
|
+
Object.defineProperty(this, "shortMessage", {
|
|
159
|
+
enumerable: true,
|
|
160
|
+
configurable: true,
|
|
161
|
+
writable: true,
|
|
162
|
+
value: undefined
|
|
163
|
+
});
|
|
164
|
+
Object.defineProperty(this, "version", {
|
|
165
|
+
enumerable: true,
|
|
166
|
+
configurable: true,
|
|
167
|
+
writable: true,
|
|
168
|
+
value: undefined
|
|
169
|
+
});
|
|
170
|
+
Object.defineProperty(this, "name", {
|
|
171
|
+
enumerable: true,
|
|
172
|
+
configurable: true,
|
|
173
|
+
writable: true,
|
|
174
|
+
value: "BaseError"
|
|
175
|
+
});
|
|
176
|
+
this.details = details;
|
|
177
|
+
this.docsPath = docsPath;
|
|
178
|
+
this.metaMessages = args.metaMessages;
|
|
179
|
+
this.name = args.name ?? this.name;
|
|
180
|
+
this.shortMessage = shortMessage;
|
|
181
|
+
this.version = version;
|
|
182
|
+
}
|
|
183
|
+
walk(fn) {
|
|
184
|
+
return walk(this, fn);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
function walk(err, fn) {
|
|
188
|
+
if (fn?.(err))
|
|
189
|
+
return err;
|
|
190
|
+
if (err && typeof err === "object" && "cause" in err && err.cause !== undefined)
|
|
191
|
+
return walk(err.cause, fn);
|
|
192
|
+
return fn ? null : err;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// ../../node_modules/.bun/viem@2.52.0+1cd18485b0404aca/node_modules/viem/_esm/errors/abi.js
|
|
196
|
+
class AbiConstructorNotFoundError extends BaseError {
|
|
197
|
+
constructor({ docsPath }) {
|
|
198
|
+
super([
|
|
199
|
+
"A constructor was not found on the ABI.",
|
|
200
|
+
"Make sure you are using the correct ABI and that the constructor exists on it."
|
|
201
|
+
].join(`
|
|
202
|
+
`), {
|
|
203
|
+
docsPath,
|
|
204
|
+
name: "AbiConstructorNotFoundError"
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
class AbiConstructorParamsNotFoundError extends BaseError {
|
|
210
|
+
constructor({ docsPath }) {
|
|
211
|
+
super([
|
|
212
|
+
"Constructor arguments were provided (`args`), but a constructor parameters (`inputs`) were not found on the ABI.",
|
|
213
|
+
"Make sure you are using the correct ABI, and that the `inputs` attribute on the constructor exists."
|
|
214
|
+
].join(`
|
|
215
|
+
`), {
|
|
216
|
+
docsPath,
|
|
217
|
+
name: "AbiConstructorParamsNotFoundError"
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
class AbiDecodingDataSizeTooSmallError extends BaseError {
|
|
222
|
+
constructor({ data, params, size: size2 }) {
|
|
223
|
+
super([`Data size of ${size2} bytes is too small for given parameters.`].join(`
|
|
224
|
+
`), {
|
|
225
|
+
metaMessages: [
|
|
226
|
+
`Params: (${formatAbiParams(params, { includeName: true })})`,
|
|
227
|
+
`Data: ${data} (${size2} bytes)`
|
|
228
|
+
],
|
|
229
|
+
name: "AbiDecodingDataSizeTooSmallError"
|
|
230
|
+
});
|
|
231
|
+
Object.defineProperty(this, "data", {
|
|
232
|
+
enumerable: true,
|
|
233
|
+
configurable: true,
|
|
234
|
+
writable: true,
|
|
235
|
+
value: undefined
|
|
236
|
+
});
|
|
237
|
+
Object.defineProperty(this, "params", {
|
|
238
|
+
enumerable: true,
|
|
239
|
+
configurable: true,
|
|
240
|
+
writable: true,
|
|
241
|
+
value: undefined
|
|
242
|
+
});
|
|
243
|
+
Object.defineProperty(this, "size", {
|
|
244
|
+
enumerable: true,
|
|
245
|
+
configurable: true,
|
|
246
|
+
writable: true,
|
|
247
|
+
value: undefined
|
|
248
|
+
});
|
|
249
|
+
this.data = data;
|
|
250
|
+
this.params = params;
|
|
251
|
+
this.size = size2;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
class AbiDecodingZeroDataError extends BaseError {
|
|
256
|
+
constructor({ cause } = {}) {
|
|
257
|
+
super('Cannot decode zero data ("0x") with ABI parameters.', {
|
|
258
|
+
name: "AbiDecodingZeroDataError",
|
|
259
|
+
cause
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
class AbiEncodingArrayLengthMismatchError extends BaseError {
|
|
265
|
+
constructor({ expectedLength, givenLength, type }) {
|
|
266
|
+
super([
|
|
267
|
+
`ABI encoding array length mismatch for type ${type}.`,
|
|
268
|
+
`Expected length: ${expectedLength}`,
|
|
269
|
+
`Given length: ${givenLength}`
|
|
270
|
+
].join(`
|
|
271
|
+
`), { name: "AbiEncodingArrayLengthMismatchError" });
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
class AbiEncodingBytesSizeMismatchError extends BaseError {
|
|
276
|
+
constructor({ expectedSize, value }) {
|
|
277
|
+
super(`Size of bytes "${value}" (bytes${size(value)}) does not match expected size (bytes${expectedSize}).`, { name: "AbiEncodingBytesSizeMismatchError" });
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
class AbiEncodingLengthMismatchError extends BaseError {
|
|
282
|
+
constructor({ expectedLength, givenLength }) {
|
|
283
|
+
super([
|
|
284
|
+
"ABI encoding params/values length mismatch.",
|
|
285
|
+
`Expected length (params): ${expectedLength}`,
|
|
286
|
+
`Given length (values): ${givenLength}`
|
|
287
|
+
].join(`
|
|
288
|
+
`), { name: "AbiEncodingLengthMismatchError" });
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
class AbiErrorInputsNotFoundError extends BaseError {
|
|
293
|
+
constructor(errorName, { docsPath }) {
|
|
294
|
+
super([
|
|
295
|
+
`Arguments (\`args\`) were provided to "${errorName}", but "${errorName}" on the ABI does not contain any parameters (\`inputs\`).`,
|
|
296
|
+
"Cannot encode error result without knowing what the parameter types are.",
|
|
297
|
+
"Make sure you are using the correct ABI and that the inputs exist on it."
|
|
298
|
+
].join(`
|
|
299
|
+
`), {
|
|
300
|
+
docsPath,
|
|
301
|
+
name: "AbiErrorInputsNotFoundError"
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
class AbiErrorNotFoundError extends BaseError {
|
|
307
|
+
constructor(errorName, { docsPath } = {}) {
|
|
308
|
+
super([
|
|
309
|
+
`Error ${errorName ? `"${errorName}" ` : ""}not found on ABI.`,
|
|
310
|
+
"Make sure you are using the correct ABI and that the error exists on it."
|
|
311
|
+
].join(`
|
|
312
|
+
`), {
|
|
313
|
+
docsPath,
|
|
314
|
+
name: "AbiErrorNotFoundError"
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
class AbiErrorSignatureNotFoundError extends BaseError {
|
|
320
|
+
constructor(signature, { docsPath, cause }) {
|
|
321
|
+
super([
|
|
322
|
+
`Encoded error signature "${signature}" not found on ABI.`,
|
|
323
|
+
"Make sure you are using the correct ABI and that the error exists on it.",
|
|
324
|
+
`You can look up the decoded signature here: https://4byte.sourcify.dev/?q=${signature}.`
|
|
325
|
+
].join(`
|
|
326
|
+
`), {
|
|
327
|
+
docsPath,
|
|
328
|
+
name: "AbiErrorSignatureNotFoundError",
|
|
329
|
+
cause
|
|
330
|
+
});
|
|
331
|
+
Object.defineProperty(this, "signature", {
|
|
332
|
+
enumerable: true,
|
|
333
|
+
configurable: true,
|
|
334
|
+
writable: true,
|
|
335
|
+
value: undefined
|
|
336
|
+
});
|
|
337
|
+
this.signature = signature;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
class AbiEventSignatureEmptyTopicsError extends BaseError {
|
|
342
|
+
constructor({ docsPath }) {
|
|
343
|
+
super("Cannot extract event signature from empty topics.", {
|
|
344
|
+
docsPath,
|
|
345
|
+
name: "AbiEventSignatureEmptyTopicsError"
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
class AbiEventSignatureNotFoundError extends BaseError {
|
|
351
|
+
constructor(signature, { docsPath }) {
|
|
352
|
+
super([
|
|
353
|
+
`Encoded event signature "${signature}" not found on ABI.`,
|
|
354
|
+
"Make sure you are using the correct ABI and that the event exists on it.",
|
|
355
|
+
`You can look up the signature here: https://4byte.sourcify.dev/?q=${signature}.`
|
|
356
|
+
].join(`
|
|
357
|
+
`), {
|
|
358
|
+
docsPath,
|
|
359
|
+
name: "AbiEventSignatureNotFoundError"
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
class AbiEventNotFoundError extends BaseError {
|
|
365
|
+
constructor(eventName, { docsPath } = {}) {
|
|
366
|
+
super([
|
|
367
|
+
`Event ${eventName ? `"${eventName}" ` : ""}not found on ABI.`,
|
|
368
|
+
"Make sure you are using the correct ABI and that the event exists on it."
|
|
369
|
+
].join(`
|
|
370
|
+
`), {
|
|
371
|
+
docsPath,
|
|
372
|
+
name: "AbiEventNotFoundError"
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
class AbiFunctionNotFoundError extends BaseError {
|
|
378
|
+
constructor(functionName, { docsPath } = {}) {
|
|
379
|
+
super([
|
|
380
|
+
`Function ${functionName ? `"${functionName}" ` : ""}not found on ABI.`,
|
|
381
|
+
"Make sure you are using the correct ABI and that the function exists on it."
|
|
382
|
+
].join(`
|
|
383
|
+
`), {
|
|
384
|
+
docsPath,
|
|
385
|
+
name: "AbiFunctionNotFoundError"
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
class AbiFunctionOutputsNotFoundError extends BaseError {
|
|
391
|
+
constructor(functionName, { docsPath }) {
|
|
392
|
+
super([
|
|
393
|
+
`Function "${functionName}" does not contain any \`outputs\` on ABI.`,
|
|
394
|
+
"Cannot decode function result without knowing what the parameter types are.",
|
|
395
|
+
"Make sure you are using the correct ABI and that the function exists on it."
|
|
396
|
+
].join(`
|
|
397
|
+
`), {
|
|
398
|
+
docsPath,
|
|
399
|
+
name: "AbiFunctionOutputsNotFoundError"
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
class AbiFunctionSignatureNotFoundError extends BaseError {
|
|
405
|
+
constructor(signature, { docsPath }) {
|
|
406
|
+
super([
|
|
407
|
+
`Encoded function signature "${signature}" not found on ABI.`,
|
|
408
|
+
"Make sure you are using the correct ABI and that the function exists on it.",
|
|
409
|
+
`You can look up the signature here: https://4byte.sourcify.dev/?q=${signature}.`
|
|
410
|
+
].join(`
|
|
411
|
+
`), {
|
|
412
|
+
docsPath,
|
|
413
|
+
name: "AbiFunctionSignatureNotFoundError"
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
class AbiItemAmbiguityError extends BaseError {
|
|
419
|
+
constructor(x, y) {
|
|
420
|
+
super("Found ambiguous types in overloaded ABI items.", {
|
|
421
|
+
metaMessages: [
|
|
422
|
+
`\`${x.type}\` in \`${formatAbiItem(x.abiItem)}\`, and`,
|
|
423
|
+
`\`${y.type}\` in \`${formatAbiItem(y.abiItem)}\``,
|
|
424
|
+
"",
|
|
425
|
+
"These types encode differently and cannot be distinguished at runtime.",
|
|
426
|
+
"Remove one of the ambiguous items in the ABI."
|
|
427
|
+
],
|
|
428
|
+
name: "AbiItemAmbiguityError"
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
class BytesSizeMismatchError extends BaseError {
|
|
434
|
+
constructor({ expectedSize, givenSize }) {
|
|
435
|
+
super(`Expected bytes${expectedSize}, got bytes${givenSize}.`, {
|
|
436
|
+
name: "BytesSizeMismatchError"
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
class DecodeLogDataMismatch extends BaseError {
|
|
442
|
+
constructor({ abiItem, data, params, size: size2 }) {
|
|
443
|
+
super([
|
|
444
|
+
`Data size of ${size2} bytes is too small for non-indexed event parameters.`
|
|
445
|
+
].join(`
|
|
446
|
+
`), {
|
|
447
|
+
metaMessages: [
|
|
448
|
+
`Params: (${formatAbiParams(params, { includeName: true })})`,
|
|
449
|
+
`Data: ${data} (${size2} bytes)`
|
|
450
|
+
],
|
|
451
|
+
name: "DecodeLogDataMismatch"
|
|
452
|
+
});
|
|
453
|
+
Object.defineProperty(this, "abiItem", {
|
|
454
|
+
enumerable: true,
|
|
455
|
+
configurable: true,
|
|
456
|
+
writable: true,
|
|
457
|
+
value: undefined
|
|
458
|
+
});
|
|
459
|
+
Object.defineProperty(this, "data", {
|
|
460
|
+
enumerable: true,
|
|
461
|
+
configurable: true,
|
|
462
|
+
writable: true,
|
|
463
|
+
value: undefined
|
|
464
|
+
});
|
|
465
|
+
Object.defineProperty(this, "params", {
|
|
466
|
+
enumerable: true,
|
|
467
|
+
configurable: true,
|
|
468
|
+
writable: true,
|
|
469
|
+
value: undefined
|
|
470
|
+
});
|
|
471
|
+
Object.defineProperty(this, "size", {
|
|
472
|
+
enumerable: true,
|
|
473
|
+
configurable: true,
|
|
474
|
+
writable: true,
|
|
475
|
+
value: undefined
|
|
476
|
+
});
|
|
477
|
+
this.abiItem = abiItem;
|
|
478
|
+
this.data = data;
|
|
479
|
+
this.params = params;
|
|
480
|
+
this.size = size2;
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
class DecodeLogTopicsMismatch extends BaseError {
|
|
485
|
+
constructor({ abiItem, param }) {
|
|
486
|
+
super([
|
|
487
|
+
`Expected a topic for indexed event parameter${param.name ? ` "${param.name}"` : ""} on event "${formatAbiItem(abiItem, { includeName: true })}".`
|
|
488
|
+
].join(`
|
|
489
|
+
`), { name: "DecodeLogTopicsMismatch" });
|
|
490
|
+
Object.defineProperty(this, "abiItem", {
|
|
491
|
+
enumerable: true,
|
|
492
|
+
configurable: true,
|
|
493
|
+
writable: true,
|
|
494
|
+
value: undefined
|
|
495
|
+
});
|
|
496
|
+
this.abiItem = abiItem;
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
class InvalidAbiEncodingTypeError extends BaseError {
|
|
501
|
+
constructor(type, { docsPath }) {
|
|
502
|
+
super([
|
|
503
|
+
`Type "${type}" is not a valid encoding type.`,
|
|
504
|
+
"Please provide a valid ABI type."
|
|
505
|
+
].join(`
|
|
506
|
+
`), { docsPath, name: "InvalidAbiEncodingType" });
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
class InvalidAbiDecodingTypeError extends BaseError {
|
|
511
|
+
constructor(type, { docsPath }) {
|
|
512
|
+
super([
|
|
513
|
+
`Type "${type}" is not a valid decoding type.`,
|
|
514
|
+
"Please provide a valid ABI type."
|
|
515
|
+
].join(`
|
|
516
|
+
`), { docsPath, name: "InvalidAbiDecodingType" });
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
class InvalidArrayError extends BaseError {
|
|
521
|
+
constructor(value) {
|
|
522
|
+
super([`Value "${value}" is not a valid array.`].join(`
|
|
523
|
+
`), {
|
|
524
|
+
name: "InvalidArrayError"
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
class InvalidDefinitionTypeError extends BaseError {
|
|
530
|
+
constructor(type) {
|
|
531
|
+
super([
|
|
532
|
+
`"${type}" is not a valid definition type.`,
|
|
533
|
+
'Valid types: "function", "event", "error"'
|
|
534
|
+
].join(`
|
|
535
|
+
`), { name: "InvalidDefinitionTypeError" });
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
// ../../node_modules/.bun/viem@2.52.0+1cd18485b0404aca/node_modules/viem/_esm/errors/address.js
|
|
540
|
+
class InvalidAddressError extends BaseError {
|
|
541
|
+
constructor({ address }) {
|
|
542
|
+
super(`Address "${address}" is invalid.`, {
|
|
543
|
+
metaMessages: [
|
|
544
|
+
"- Address must be a hex value of 20 bytes (40 hex characters).",
|
|
545
|
+
"- Address must match its checksum counterpart."
|
|
546
|
+
],
|
|
547
|
+
name: "InvalidAddressError"
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
// ../../node_modules/.bun/viem@2.52.0+1cd18485b0404aca/node_modules/viem/_esm/errors/encoding.js
|
|
553
|
+
class IntegerOutOfRangeError extends BaseError {
|
|
554
|
+
constructor({ max, min, signed, size: size2, value }) {
|
|
555
|
+
super(`Number "${value}" is not in safe ${size2 ? `${size2 * 8}-bit ${signed ? "signed" : "unsigned"} ` : ""}integer range ${max ? `(${min} to ${max})` : `(above ${min})`}`, { name: "IntegerOutOfRangeError" });
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
class InvalidBytesBooleanError extends BaseError {
|
|
560
|
+
constructor(bytes) {
|
|
561
|
+
super(`Bytes value "${bytes}" is not a valid boolean. The bytes array must contain a single byte of either a 0 or 1 value.`, {
|
|
562
|
+
name: "InvalidBytesBooleanError"
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
class InvalidHexBooleanError extends BaseError {
|
|
568
|
+
constructor(hex) {
|
|
569
|
+
super(`Hex value "${hex}" is not a valid boolean. The hex value must be "0x0" (false) or "0x1" (true).`, { name: "InvalidHexBooleanError" });
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
class SizeOverflowError extends BaseError {
|
|
573
|
+
constructor({ givenSize, maxSize }) {
|
|
574
|
+
super(`Size cannot exceed ${maxSize} bytes. Given size: ${givenSize} bytes.`, { name: "SizeOverflowError" });
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
// ../../node_modules/.bun/viem@2.52.0+1cd18485b0404aca/node_modules/viem/_esm/utils/lru.js
|
|
579
|
+
class LruMap extends Map {
|
|
580
|
+
constructor(size2) {
|
|
581
|
+
super();
|
|
582
|
+
Object.defineProperty(this, "maxSize", {
|
|
583
|
+
enumerable: true,
|
|
584
|
+
configurable: true,
|
|
585
|
+
writable: true,
|
|
586
|
+
value: undefined
|
|
587
|
+
});
|
|
588
|
+
this.maxSize = size2;
|
|
589
|
+
}
|
|
590
|
+
get(key) {
|
|
591
|
+
const value = super.get(key);
|
|
592
|
+
if (super.has(key)) {
|
|
593
|
+
super.delete(key);
|
|
594
|
+
super.set(key, value);
|
|
595
|
+
}
|
|
596
|
+
return value;
|
|
597
|
+
}
|
|
598
|
+
set(key, value) {
|
|
599
|
+
if (super.has(key))
|
|
600
|
+
super.delete(key);
|
|
601
|
+
super.set(key, value);
|
|
602
|
+
if (this.maxSize && this.size > this.maxSize) {
|
|
603
|
+
const firstKey = super.keys().next().value;
|
|
604
|
+
if (firstKey !== undefined)
|
|
605
|
+
super.delete(firstKey);
|
|
606
|
+
}
|
|
607
|
+
return this;
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
// ../../node_modules/.bun/viem@2.52.0+1cd18485b0404aca/node_modules/viem/_esm/errors/data.js
|
|
612
|
+
class SliceOffsetOutOfBoundsError extends BaseError {
|
|
613
|
+
constructor({ offset, position, size: size2 }) {
|
|
614
|
+
super(`Slice ${position === "start" ? "starting" : "ending"} at offset "${offset}" is out-of-bounds (size: ${size2}).`, { name: "SliceOffsetOutOfBoundsError" });
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
class SizeExceedsPaddingSizeError extends BaseError {
|
|
619
|
+
constructor({ size: size2, targetSize, type }) {
|
|
620
|
+
super(`${type.charAt(0).toUpperCase()}${type.slice(1).toLowerCase()} size (${size2}) exceeds padding size (${targetSize}).`, { name: "SizeExceedsPaddingSizeError" });
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
class InvalidBytesLengthError extends BaseError {
|
|
625
|
+
constructor({ size: size2, targetSize, type }) {
|
|
626
|
+
super(`${type.charAt(0).toUpperCase()}${type.slice(1).toLowerCase()} is expected to be ${targetSize} ${type} long, but is ${size2} ${type} long.`, { name: "InvalidBytesLengthError" });
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
// ../../node_modules/.bun/viem@2.52.0+1cd18485b0404aca/node_modules/viem/_esm/utils/data/pad.js
|
|
631
|
+
function pad(hexOrBytes, { dir, size: size2 = 32 } = {}) {
|
|
632
|
+
if (typeof hexOrBytes === "string")
|
|
633
|
+
return padHex(hexOrBytes, { dir, size: size2 });
|
|
634
|
+
return padBytes(hexOrBytes, { dir, size: size2 });
|
|
635
|
+
}
|
|
636
|
+
function padHex(hex_, { dir, size: size2 = 32 } = {}) {
|
|
637
|
+
if (size2 === null)
|
|
638
|
+
return hex_;
|
|
639
|
+
const hex = hex_.replace("0x", "");
|
|
640
|
+
if (hex.length > size2 * 2)
|
|
641
|
+
throw new SizeExceedsPaddingSizeError({
|
|
642
|
+
size: Math.ceil(hex.length / 2),
|
|
643
|
+
targetSize: size2,
|
|
644
|
+
type: "hex"
|
|
645
|
+
});
|
|
646
|
+
return `0x${hex[dir === "right" ? "padEnd" : "padStart"](size2 * 2, "0")}`;
|
|
647
|
+
}
|
|
648
|
+
function padBytes(bytes, { dir, size: size2 = 32 } = {}) {
|
|
649
|
+
if (size2 === null)
|
|
650
|
+
return bytes;
|
|
651
|
+
if (bytes.length > size2)
|
|
652
|
+
throw new SizeExceedsPaddingSizeError({
|
|
653
|
+
size: bytes.length,
|
|
654
|
+
targetSize: size2,
|
|
655
|
+
type: "bytes"
|
|
656
|
+
});
|
|
657
|
+
const paddedBytes = new Uint8Array(size2);
|
|
658
|
+
for (let i = 0;i < size2; i++) {
|
|
659
|
+
const padEnd = dir === "right";
|
|
660
|
+
paddedBytes[padEnd ? i : size2 - i - 1] = bytes[padEnd ? i : bytes.length - i - 1];
|
|
661
|
+
}
|
|
662
|
+
return paddedBytes;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
// ../../node_modules/.bun/viem@2.52.0+1cd18485b0404aca/node_modules/viem/_esm/utils/data/trim.js
|
|
666
|
+
function trim(hexOrBytes, { dir = "left" } = {}) {
|
|
667
|
+
let data = typeof hexOrBytes === "string" ? hexOrBytes.replace("0x", "") : hexOrBytes;
|
|
668
|
+
let sliceLength = 0;
|
|
669
|
+
for (let i = 0;i < data.length - 1; i++) {
|
|
670
|
+
if (data[dir === "left" ? i : data.length - i - 1].toString() === "0")
|
|
671
|
+
sliceLength++;
|
|
672
|
+
else
|
|
673
|
+
break;
|
|
674
|
+
}
|
|
675
|
+
data = dir === "left" ? data.slice(sliceLength) : data.slice(0, data.length - sliceLength);
|
|
676
|
+
if (typeof hexOrBytes === "string") {
|
|
677
|
+
if (data.length === 1 && dir === "right")
|
|
678
|
+
data = `${data}0`;
|
|
679
|
+
return `0x${data.length % 2 === 1 ? `0${data}` : data}`;
|
|
680
|
+
}
|
|
681
|
+
return data;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
// ../../node_modules/.bun/viem@2.52.0+1cd18485b0404aca/node_modules/viem/_esm/utils/encoding/fromHex.js
|
|
685
|
+
function assertSize(hexOrBytes, { size: size2 }) {
|
|
686
|
+
if (size(hexOrBytes) > size2)
|
|
687
|
+
throw new SizeOverflowError({
|
|
688
|
+
givenSize: size(hexOrBytes),
|
|
689
|
+
maxSize: size2
|
|
690
|
+
});
|
|
691
|
+
}
|
|
692
|
+
function hexToBigInt(hex, opts = {}) {
|
|
693
|
+
const { signed } = opts;
|
|
694
|
+
if (opts.size)
|
|
695
|
+
assertSize(hex, { size: opts.size });
|
|
696
|
+
const value = BigInt(hex);
|
|
697
|
+
if (!signed)
|
|
698
|
+
return value;
|
|
699
|
+
const size2 = (hex.length - 2) / 2;
|
|
700
|
+
const max = (1n << BigInt(size2) * 8n - 1n) - 1n;
|
|
701
|
+
if (value <= max)
|
|
702
|
+
return value;
|
|
703
|
+
return value - BigInt(`0x${"f".padStart(size2 * 2, "f")}`) - 1n;
|
|
704
|
+
}
|
|
705
|
+
function hexToBool(hex_, opts = {}) {
|
|
706
|
+
let hex = hex_;
|
|
707
|
+
if (opts.size) {
|
|
708
|
+
assertSize(hex, { size: opts.size });
|
|
709
|
+
hex = trim(hex);
|
|
710
|
+
}
|
|
711
|
+
if (trim(hex) === "0x00")
|
|
712
|
+
return false;
|
|
713
|
+
if (trim(hex) === "0x01")
|
|
714
|
+
return true;
|
|
715
|
+
throw new InvalidHexBooleanError(hex);
|
|
716
|
+
}
|
|
717
|
+
function hexToNumber(hex, opts = {}) {
|
|
718
|
+
const value = hexToBigInt(hex, opts);
|
|
719
|
+
const number = Number(value);
|
|
720
|
+
if (!Number.isSafeInteger(number))
|
|
721
|
+
throw new IntegerOutOfRangeError({
|
|
722
|
+
max: `${Number.MAX_SAFE_INTEGER}`,
|
|
723
|
+
min: `${Number.MIN_SAFE_INTEGER}`,
|
|
724
|
+
signed: opts.signed,
|
|
725
|
+
size: opts.size,
|
|
726
|
+
value: `${value}n`
|
|
727
|
+
});
|
|
728
|
+
return number;
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
// ../../node_modules/.bun/viem@2.52.0+1cd18485b0404aca/node_modules/viem/_esm/utils/encoding/toHex.js
|
|
732
|
+
var hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_v, i) => i.toString(16).padStart(2, "0"));
|
|
733
|
+
function toHex(value, opts = {}) {
|
|
734
|
+
if (typeof value === "number" || typeof value === "bigint")
|
|
735
|
+
return numberToHex(value, opts);
|
|
736
|
+
if (typeof value === "string") {
|
|
737
|
+
return stringToHex(value, opts);
|
|
738
|
+
}
|
|
739
|
+
if (typeof value === "boolean")
|
|
740
|
+
return boolToHex(value, opts);
|
|
741
|
+
return bytesToHex(value, opts);
|
|
742
|
+
}
|
|
743
|
+
function boolToHex(value, opts = {}) {
|
|
744
|
+
const hex = `0x${Number(value)}`;
|
|
745
|
+
if (typeof opts.size === "number") {
|
|
746
|
+
assertSize(hex, { size: opts.size });
|
|
747
|
+
return pad(hex, { size: opts.size });
|
|
748
|
+
}
|
|
749
|
+
return hex;
|
|
750
|
+
}
|
|
751
|
+
function bytesToHex(value, opts = {}) {
|
|
752
|
+
let string = "";
|
|
753
|
+
for (let i = 0;i < value.length; i++) {
|
|
754
|
+
string += hexes[value[i]];
|
|
755
|
+
}
|
|
756
|
+
const hex = `0x${string}`;
|
|
757
|
+
if (typeof opts.size === "number") {
|
|
758
|
+
assertSize(hex, { size: opts.size });
|
|
759
|
+
return pad(hex, { dir: "right", size: opts.size });
|
|
760
|
+
}
|
|
761
|
+
return hex;
|
|
762
|
+
}
|
|
763
|
+
function numberToHex(value_, opts = {}) {
|
|
764
|
+
const { signed, size: size2 } = opts;
|
|
765
|
+
const value = BigInt(value_);
|
|
766
|
+
let maxValue;
|
|
767
|
+
if (size2) {
|
|
768
|
+
if (signed)
|
|
769
|
+
maxValue = (1n << BigInt(size2) * 8n - 1n) - 1n;
|
|
770
|
+
else
|
|
771
|
+
maxValue = 2n ** (BigInt(size2) * 8n) - 1n;
|
|
772
|
+
} else if (typeof value_ === "number") {
|
|
773
|
+
maxValue = BigInt(Number.MAX_SAFE_INTEGER);
|
|
774
|
+
}
|
|
775
|
+
const minValue = typeof maxValue === "bigint" && signed ? -maxValue - 1n : 0;
|
|
776
|
+
if (maxValue && value > maxValue || value < minValue) {
|
|
777
|
+
const suffix = typeof value_ === "bigint" ? "n" : "";
|
|
778
|
+
throw new IntegerOutOfRangeError({
|
|
779
|
+
max: maxValue ? `${maxValue}${suffix}` : undefined,
|
|
780
|
+
min: `${minValue}${suffix}`,
|
|
781
|
+
signed,
|
|
782
|
+
size: size2,
|
|
783
|
+
value: `${value_}${suffix}`
|
|
784
|
+
});
|
|
785
|
+
}
|
|
786
|
+
const hex = `0x${(signed && value < 0 ? (1n << BigInt(size2 * 8)) + BigInt(value) : value).toString(16)}`;
|
|
787
|
+
if (size2)
|
|
788
|
+
return pad(hex, { size: size2 });
|
|
789
|
+
return hex;
|
|
790
|
+
}
|
|
791
|
+
var encoder = /* @__PURE__ */ new TextEncoder;
|
|
792
|
+
function stringToHex(value_, opts = {}) {
|
|
793
|
+
const value = encoder.encode(value_);
|
|
794
|
+
return bytesToHex(value, opts);
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
// ../../node_modules/.bun/viem@2.52.0+1cd18485b0404aca/node_modules/viem/_esm/utils/encoding/toBytes.js
|
|
798
|
+
var encoder2 = /* @__PURE__ */ new TextEncoder;
|
|
799
|
+
function toBytes2(value, opts = {}) {
|
|
800
|
+
if (typeof value === "number" || typeof value === "bigint")
|
|
801
|
+
return numberToBytes(value, opts);
|
|
802
|
+
if (typeof value === "boolean")
|
|
803
|
+
return boolToBytes(value, opts);
|
|
804
|
+
if (isHex(value))
|
|
805
|
+
return hexToBytes(value, opts);
|
|
806
|
+
return stringToBytes(value, opts);
|
|
807
|
+
}
|
|
808
|
+
function boolToBytes(value, opts = {}) {
|
|
809
|
+
const bytes = new Uint8Array(1);
|
|
810
|
+
bytes[0] = Number(value);
|
|
811
|
+
if (typeof opts.size === "number") {
|
|
812
|
+
assertSize(bytes, { size: opts.size });
|
|
813
|
+
return pad(bytes, { size: opts.size });
|
|
814
|
+
}
|
|
815
|
+
return bytes;
|
|
816
|
+
}
|
|
817
|
+
var charCodeMap = {
|
|
818
|
+
zero: 48,
|
|
819
|
+
nine: 57,
|
|
820
|
+
A: 65,
|
|
821
|
+
F: 70,
|
|
822
|
+
a: 97,
|
|
823
|
+
f: 102
|
|
824
|
+
};
|
|
825
|
+
function charCodeToBase16(char) {
|
|
826
|
+
if (char >= charCodeMap.zero && char <= charCodeMap.nine)
|
|
827
|
+
return char - charCodeMap.zero;
|
|
828
|
+
if (char >= charCodeMap.A && char <= charCodeMap.F)
|
|
829
|
+
return char - (charCodeMap.A - 10);
|
|
830
|
+
if (char >= charCodeMap.a && char <= charCodeMap.f)
|
|
831
|
+
return char - (charCodeMap.a - 10);
|
|
832
|
+
return;
|
|
833
|
+
}
|
|
834
|
+
function hexToBytes(hex_, opts = {}) {
|
|
835
|
+
let hex = hex_;
|
|
836
|
+
if (opts.size) {
|
|
837
|
+
assertSize(hex, { size: opts.size });
|
|
838
|
+
hex = pad(hex, { dir: "right", size: opts.size });
|
|
839
|
+
}
|
|
840
|
+
let hexString = hex.slice(2);
|
|
841
|
+
if (hexString.length % 2)
|
|
842
|
+
hexString = `0${hexString}`;
|
|
843
|
+
const length = hexString.length / 2;
|
|
844
|
+
const bytes = new Uint8Array(length);
|
|
845
|
+
for (let index = 0, j = 0;index < length; index++) {
|
|
846
|
+
const nibbleLeft = charCodeToBase16(hexString.charCodeAt(j++));
|
|
847
|
+
const nibbleRight = charCodeToBase16(hexString.charCodeAt(j++));
|
|
848
|
+
if (nibbleLeft === undefined || nibbleRight === undefined) {
|
|
849
|
+
throw new BaseError(`Invalid byte sequence ("${hexString[j - 2]}${hexString[j - 1]}" in "${hexString}").`);
|
|
850
|
+
}
|
|
851
|
+
bytes[index] = nibbleLeft * 16 + nibbleRight;
|
|
852
|
+
}
|
|
853
|
+
return bytes;
|
|
854
|
+
}
|
|
855
|
+
function numberToBytes(value, opts) {
|
|
856
|
+
const hex = numberToHex(value, opts);
|
|
857
|
+
return hexToBytes(hex);
|
|
858
|
+
}
|
|
859
|
+
function stringToBytes(value, opts = {}) {
|
|
860
|
+
const bytes = encoder2.encode(value);
|
|
861
|
+
if (typeof opts.size === "number") {
|
|
862
|
+
assertSize(bytes, { size: opts.size });
|
|
863
|
+
return pad(bytes, { dir: "right", size: opts.size });
|
|
864
|
+
}
|
|
865
|
+
return bytes;
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
// ../../node_modules/.bun/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/sha3.js
|
|
869
|
+
var _0n = BigInt(0);
|
|
870
|
+
var _1n = BigInt(1);
|
|
871
|
+
var _2n = BigInt(2);
|
|
872
|
+
var _7n = BigInt(7);
|
|
873
|
+
var _256n = BigInt(256);
|
|
874
|
+
var _0x71n = BigInt(113);
|
|
875
|
+
var SHA3_PI = [];
|
|
876
|
+
var SHA3_ROTL = [];
|
|
877
|
+
var _SHA3_IOTA = [];
|
|
878
|
+
for (let round = 0, R = _1n, x = 1, y = 0;round < 24; round++) {
|
|
879
|
+
[x, y] = [y, (2 * x + 3 * y) % 5];
|
|
880
|
+
SHA3_PI.push(2 * (5 * y + x));
|
|
881
|
+
SHA3_ROTL.push((round + 1) * (round + 2) / 2 % 64);
|
|
882
|
+
let t = _0n;
|
|
883
|
+
for (let j = 0;j < 7; j++) {
|
|
884
|
+
R = (R << _1n ^ (R >> _7n) * _0x71n) % _256n;
|
|
885
|
+
if (R & _2n)
|
|
886
|
+
t ^= _1n << (_1n << /* @__PURE__ */ BigInt(j)) - _1n;
|
|
887
|
+
}
|
|
888
|
+
_SHA3_IOTA.push(t);
|
|
889
|
+
}
|
|
890
|
+
var IOTAS = split(_SHA3_IOTA, true);
|
|
891
|
+
var SHA3_IOTA_H = IOTAS[0];
|
|
892
|
+
var SHA3_IOTA_L = IOTAS[1];
|
|
893
|
+
var rotlH = (h, l, s) => s > 32 ? rotlBH(h, l, s) : rotlSH(h, l, s);
|
|
894
|
+
var rotlL = (h, l, s) => s > 32 ? rotlBL(h, l, s) : rotlSL(h, l, s);
|
|
895
|
+
function keccakP(s, rounds = 24) {
|
|
896
|
+
const B = new Uint32Array(5 * 2);
|
|
897
|
+
for (let round = 24 - rounds;round < 24; round++) {
|
|
898
|
+
for (let x = 0;x < 10; x++)
|
|
899
|
+
B[x] = s[x] ^ s[x + 10] ^ s[x + 20] ^ s[x + 30] ^ s[x + 40];
|
|
900
|
+
for (let x = 0;x < 10; x += 2) {
|
|
901
|
+
const idx1 = (x + 8) % 10;
|
|
902
|
+
const idx0 = (x + 2) % 10;
|
|
903
|
+
const B0 = B[idx0];
|
|
904
|
+
const B1 = B[idx0 + 1];
|
|
905
|
+
const Th = rotlH(B0, B1, 1) ^ B[idx1];
|
|
906
|
+
const Tl = rotlL(B0, B1, 1) ^ B[idx1 + 1];
|
|
907
|
+
for (let y = 0;y < 50; y += 10) {
|
|
908
|
+
s[x + y] ^= Th;
|
|
909
|
+
s[x + y + 1] ^= Tl;
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
let curH = s[2];
|
|
913
|
+
let curL = s[3];
|
|
914
|
+
for (let t = 0;t < 24; t++) {
|
|
915
|
+
const shift = SHA3_ROTL[t];
|
|
916
|
+
const Th = rotlH(curH, curL, shift);
|
|
917
|
+
const Tl = rotlL(curH, curL, shift);
|
|
918
|
+
const PI = SHA3_PI[t];
|
|
919
|
+
curH = s[PI];
|
|
920
|
+
curL = s[PI + 1];
|
|
921
|
+
s[PI] = Th;
|
|
922
|
+
s[PI + 1] = Tl;
|
|
923
|
+
}
|
|
924
|
+
for (let y = 0;y < 50; y += 10) {
|
|
925
|
+
for (let x = 0;x < 10; x++)
|
|
926
|
+
B[x] = s[y + x];
|
|
927
|
+
for (let x = 0;x < 10; x++)
|
|
928
|
+
s[y + x] ^= ~B[(x + 2) % 10] & B[(x + 4) % 10];
|
|
929
|
+
}
|
|
930
|
+
s[0] ^= SHA3_IOTA_H[round];
|
|
931
|
+
s[1] ^= SHA3_IOTA_L[round];
|
|
932
|
+
}
|
|
933
|
+
clean(B);
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
class Keccak extends Hash {
|
|
937
|
+
constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) {
|
|
938
|
+
super();
|
|
939
|
+
this.pos = 0;
|
|
940
|
+
this.posOut = 0;
|
|
941
|
+
this.finished = false;
|
|
942
|
+
this.destroyed = false;
|
|
943
|
+
this.enableXOF = false;
|
|
944
|
+
this.blockLen = blockLen;
|
|
945
|
+
this.suffix = suffix;
|
|
946
|
+
this.outputLen = outputLen;
|
|
947
|
+
this.enableXOF = enableXOF;
|
|
948
|
+
this.rounds = rounds;
|
|
949
|
+
anumber(outputLen);
|
|
950
|
+
if (!(0 < blockLen && blockLen < 200))
|
|
951
|
+
throw new Error("only keccak-f1600 function is supported");
|
|
952
|
+
this.state = new Uint8Array(200);
|
|
953
|
+
this.state32 = u32(this.state);
|
|
954
|
+
}
|
|
955
|
+
clone() {
|
|
956
|
+
return this._cloneInto();
|
|
957
|
+
}
|
|
958
|
+
keccak() {
|
|
959
|
+
swap32IfBE(this.state32);
|
|
960
|
+
keccakP(this.state32, this.rounds);
|
|
961
|
+
swap32IfBE(this.state32);
|
|
962
|
+
this.posOut = 0;
|
|
963
|
+
this.pos = 0;
|
|
964
|
+
}
|
|
965
|
+
update(data) {
|
|
966
|
+
aexists(this);
|
|
967
|
+
data = toBytes(data);
|
|
968
|
+
abytes(data);
|
|
969
|
+
const { blockLen, state } = this;
|
|
970
|
+
const len = data.length;
|
|
971
|
+
for (let pos = 0;pos < len; ) {
|
|
972
|
+
const take = Math.min(blockLen - this.pos, len - pos);
|
|
973
|
+
for (let i = 0;i < take; i++)
|
|
974
|
+
state[this.pos++] ^= data[pos++];
|
|
975
|
+
if (this.pos === blockLen)
|
|
976
|
+
this.keccak();
|
|
977
|
+
}
|
|
978
|
+
return this;
|
|
979
|
+
}
|
|
980
|
+
finish() {
|
|
981
|
+
if (this.finished)
|
|
982
|
+
return;
|
|
983
|
+
this.finished = true;
|
|
984
|
+
const { state, suffix, pos, blockLen } = this;
|
|
985
|
+
state[pos] ^= suffix;
|
|
986
|
+
if ((suffix & 128) !== 0 && pos === blockLen - 1)
|
|
987
|
+
this.keccak();
|
|
988
|
+
state[blockLen - 1] ^= 128;
|
|
989
|
+
this.keccak();
|
|
990
|
+
}
|
|
991
|
+
writeInto(out) {
|
|
992
|
+
aexists(this, false);
|
|
993
|
+
abytes(out);
|
|
994
|
+
this.finish();
|
|
995
|
+
const bufferOut = this.state;
|
|
996
|
+
const { blockLen } = this;
|
|
997
|
+
for (let pos = 0, len = out.length;pos < len; ) {
|
|
998
|
+
if (this.posOut >= blockLen)
|
|
999
|
+
this.keccak();
|
|
1000
|
+
const take = Math.min(blockLen - this.posOut, len - pos);
|
|
1001
|
+
out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos);
|
|
1002
|
+
this.posOut += take;
|
|
1003
|
+
pos += take;
|
|
1004
|
+
}
|
|
1005
|
+
return out;
|
|
1006
|
+
}
|
|
1007
|
+
xofInto(out) {
|
|
1008
|
+
if (!this.enableXOF)
|
|
1009
|
+
throw new Error("XOF is not possible for this instance");
|
|
1010
|
+
return this.writeInto(out);
|
|
1011
|
+
}
|
|
1012
|
+
xof(bytes) {
|
|
1013
|
+
anumber(bytes);
|
|
1014
|
+
return this.xofInto(new Uint8Array(bytes));
|
|
1015
|
+
}
|
|
1016
|
+
digestInto(out) {
|
|
1017
|
+
aoutput(out, this);
|
|
1018
|
+
if (this.finished)
|
|
1019
|
+
throw new Error("digest() was already called");
|
|
1020
|
+
this.writeInto(out);
|
|
1021
|
+
this.destroy();
|
|
1022
|
+
return out;
|
|
1023
|
+
}
|
|
1024
|
+
digest() {
|
|
1025
|
+
return this.digestInto(new Uint8Array(this.outputLen));
|
|
1026
|
+
}
|
|
1027
|
+
destroy() {
|
|
1028
|
+
this.destroyed = true;
|
|
1029
|
+
clean(this.state);
|
|
1030
|
+
}
|
|
1031
|
+
_cloneInto(to) {
|
|
1032
|
+
const { blockLen, suffix, outputLen, rounds, enableXOF } = this;
|
|
1033
|
+
to || (to = new Keccak(blockLen, suffix, outputLen, enableXOF, rounds));
|
|
1034
|
+
to.state32.set(this.state32);
|
|
1035
|
+
to.pos = this.pos;
|
|
1036
|
+
to.posOut = this.posOut;
|
|
1037
|
+
to.finished = this.finished;
|
|
1038
|
+
to.rounds = rounds;
|
|
1039
|
+
to.suffix = suffix;
|
|
1040
|
+
to.outputLen = outputLen;
|
|
1041
|
+
to.enableXOF = enableXOF;
|
|
1042
|
+
to.destroyed = this.destroyed;
|
|
1043
|
+
return to;
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
var gen = (suffix, blockLen, outputLen) => createHasher(() => new Keccak(blockLen, suffix, outputLen));
|
|
1047
|
+
var keccak_256 = /* @__PURE__ */ (() => gen(1, 136, 256 / 8))();
|
|
1048
|
+
|
|
1049
|
+
// ../../node_modules/.bun/viem@2.52.0+1cd18485b0404aca/node_modules/viem/_esm/utils/hash/keccak256.js
|
|
1050
|
+
function keccak256(value, to_) {
|
|
1051
|
+
const to = to_ || "hex";
|
|
1052
|
+
const bytes = keccak_256(isHex(value, { strict: false }) ? toBytes2(value) : value);
|
|
1053
|
+
if (to === "bytes")
|
|
1054
|
+
return bytes;
|
|
1055
|
+
return toHex(bytes);
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
// ../../node_modules/.bun/viem@2.52.0+1cd18485b0404aca/node_modules/viem/_esm/utils/address/getAddress.js
|
|
1059
|
+
var checksumAddressCache = /* @__PURE__ */ new LruMap(8192);
|
|
1060
|
+
function checksumAddress(address_, chainId) {
|
|
1061
|
+
if (checksumAddressCache.has(`${address_}.${chainId}`))
|
|
1062
|
+
return checksumAddressCache.get(`${address_}.${chainId}`);
|
|
1063
|
+
const hexAddress = chainId ? `${chainId}${address_.toLowerCase()}` : address_.substring(2).toLowerCase();
|
|
1064
|
+
const hash = keccak256(stringToBytes(hexAddress), "bytes");
|
|
1065
|
+
const address = (chainId ? hexAddress.substring(`${chainId}0x`.length) : hexAddress).split("");
|
|
1066
|
+
for (let i = 0;i < 40; i += 2) {
|
|
1067
|
+
if (hash[i >> 1] >> 4 >= 8 && address[i]) {
|
|
1068
|
+
address[i] = address[i].toUpperCase();
|
|
1069
|
+
}
|
|
1070
|
+
if ((hash[i >> 1] & 15) >= 8 && address[i + 1]) {
|
|
1071
|
+
address[i + 1] = address[i + 1].toUpperCase();
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
const result = `0x${address.join("")}`;
|
|
1075
|
+
checksumAddressCache.set(`${address_}.${chainId}`, result);
|
|
1076
|
+
return result;
|
|
1077
|
+
}
|
|
1078
|
+
function getAddress(address, chainId) {
|
|
1079
|
+
if (!isAddress(address, { strict: false }))
|
|
1080
|
+
throw new InvalidAddressError({ address });
|
|
1081
|
+
return checksumAddress(address, chainId);
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
// ../../node_modules/.bun/viem@2.52.0+1cd18485b0404aca/node_modules/viem/_esm/utils/address/isAddress.js
|
|
1085
|
+
var addressRegex = /^0x[a-fA-F0-9]{40}$/;
|
|
1086
|
+
var isAddressCache = /* @__PURE__ */ new LruMap(8192);
|
|
1087
|
+
function isAddress(address, options) {
|
|
1088
|
+
const { strict = true } = options ?? {};
|
|
1089
|
+
const cacheKey = `${address}.${strict}`;
|
|
1090
|
+
if (isAddressCache.has(cacheKey))
|
|
1091
|
+
return isAddressCache.get(cacheKey);
|
|
1092
|
+
const result = (() => {
|
|
1093
|
+
if (!addressRegex.test(address))
|
|
1094
|
+
return false;
|
|
1095
|
+
if (address.toLowerCase() === address)
|
|
1096
|
+
return true;
|
|
1097
|
+
if (strict)
|
|
1098
|
+
return checksumAddress(address) === address;
|
|
1099
|
+
return true;
|
|
1100
|
+
})();
|
|
1101
|
+
isAddressCache.set(cacheKey, result);
|
|
1102
|
+
return result;
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
// ../../node_modules/.bun/viem@2.52.0+1cd18485b0404aca/node_modules/viem/_esm/utils/data/slice.js
|
|
1106
|
+
function slice(value, start, end, { strict } = {}) {
|
|
1107
|
+
if (isHex(value, { strict: false }))
|
|
1108
|
+
return sliceHex(value, start, end, {
|
|
1109
|
+
strict
|
|
1110
|
+
});
|
|
1111
|
+
return sliceBytes(value, start, end, {
|
|
1112
|
+
strict
|
|
1113
|
+
});
|
|
1114
|
+
}
|
|
1115
|
+
function assertStartOffset(value, start) {
|
|
1116
|
+
if (typeof start === "number" && start > 0 && start > size(value) - 1)
|
|
1117
|
+
throw new SliceOffsetOutOfBoundsError({
|
|
1118
|
+
offset: start,
|
|
1119
|
+
position: "start",
|
|
1120
|
+
size: size(value)
|
|
1121
|
+
});
|
|
1122
|
+
}
|
|
1123
|
+
function assertEndOffset(value, start, end) {
|
|
1124
|
+
if (typeof start === "number" && typeof end === "number" && size(value) !== end - start) {
|
|
1125
|
+
throw new SliceOffsetOutOfBoundsError({
|
|
1126
|
+
offset: end,
|
|
1127
|
+
position: "end",
|
|
1128
|
+
size: size(value)
|
|
1129
|
+
});
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
function sliceBytes(value_, start, end, { strict } = {}) {
|
|
1133
|
+
assertStartOffset(value_, start);
|
|
1134
|
+
const value = value_.slice(start, end);
|
|
1135
|
+
if (strict)
|
|
1136
|
+
assertEndOffset(value, start, end);
|
|
1137
|
+
return value;
|
|
1138
|
+
}
|
|
1139
|
+
function sliceHex(value_, start, end, { strict } = {}) {
|
|
1140
|
+
assertStartOffset(value_, start);
|
|
1141
|
+
const value = `0x${value_.replace("0x", "").slice((start ?? 0) * 2, (end ?? value_.length) * 2)}`;
|
|
1142
|
+
if (strict)
|
|
1143
|
+
assertEndOffset(value, start, end);
|
|
1144
|
+
return value;
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
// ../../node_modules/.bun/viem@2.52.0+1cd18485b0404aca/node_modules/viem/_esm/utils/regex.js
|
|
1148
|
+
var bytesRegex = /^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/;
|
|
1149
|
+
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)?$/;
|
|
1150
|
+
|
|
1151
|
+
// ../../node_modules/.bun/viem@2.52.0+1cd18485b0404aca/node_modules/viem/_esm/utils/abi/encodeAbiParameters.js
|
|
1152
|
+
function encodeAbiParameters(params, values) {
|
|
1153
|
+
if (params.length !== values.length)
|
|
1154
|
+
throw new AbiEncodingLengthMismatchError({
|
|
1155
|
+
expectedLength: params.length,
|
|
1156
|
+
givenLength: values.length
|
|
1157
|
+
});
|
|
1158
|
+
const preparedParams = prepareParams({
|
|
1159
|
+
params,
|
|
1160
|
+
values
|
|
1161
|
+
});
|
|
1162
|
+
const data = encodeParams(preparedParams);
|
|
1163
|
+
if (data.length === 0)
|
|
1164
|
+
return "0x";
|
|
1165
|
+
return data;
|
|
1166
|
+
}
|
|
1167
|
+
function prepareParams({ params, values }) {
|
|
1168
|
+
const preparedParams = [];
|
|
1169
|
+
for (let i = 0;i < params.length; i++) {
|
|
1170
|
+
preparedParams.push(prepareParam({ param: params[i], value: values[i] }));
|
|
1171
|
+
}
|
|
1172
|
+
return preparedParams;
|
|
1173
|
+
}
|
|
1174
|
+
function prepareParam({ param, value }) {
|
|
1175
|
+
const arrayComponents = getArrayComponents(param.type);
|
|
1176
|
+
if (arrayComponents) {
|
|
1177
|
+
const [length, type] = arrayComponents;
|
|
1178
|
+
return encodeArray(value, { length, param: { ...param, type } });
|
|
1179
|
+
}
|
|
1180
|
+
if (param.type === "tuple") {
|
|
1181
|
+
return encodeTuple(value, {
|
|
1182
|
+
param
|
|
1183
|
+
});
|
|
1184
|
+
}
|
|
1185
|
+
if (param.type === "address") {
|
|
1186
|
+
return encodeAddress(value);
|
|
1187
|
+
}
|
|
1188
|
+
if (param.type === "bool") {
|
|
1189
|
+
return encodeBool(value);
|
|
1190
|
+
}
|
|
1191
|
+
if (param.type.startsWith("uint") || param.type.startsWith("int")) {
|
|
1192
|
+
const signed = param.type.startsWith("int");
|
|
1193
|
+
const [, , size2 = "256"] = integerRegex.exec(param.type) ?? [];
|
|
1194
|
+
return encodeNumber(value, {
|
|
1195
|
+
signed,
|
|
1196
|
+
size: Number(size2)
|
|
1197
|
+
});
|
|
1198
|
+
}
|
|
1199
|
+
if (param.type.startsWith("bytes")) {
|
|
1200
|
+
return encodeBytes(value, { param });
|
|
1201
|
+
}
|
|
1202
|
+
if (param.type === "string") {
|
|
1203
|
+
return encodeString(value);
|
|
1204
|
+
}
|
|
1205
|
+
throw new InvalidAbiEncodingTypeError(param.type, {
|
|
1206
|
+
docsPath: "/docs/contract/encodeAbiParameters"
|
|
1207
|
+
});
|
|
1208
|
+
}
|
|
1209
|
+
function encodeParams(preparedParams) {
|
|
1210
|
+
let staticSize = 0;
|
|
1211
|
+
for (let i = 0;i < preparedParams.length; i++) {
|
|
1212
|
+
const { dynamic, encoded } = preparedParams[i];
|
|
1213
|
+
if (dynamic)
|
|
1214
|
+
staticSize += 32;
|
|
1215
|
+
else
|
|
1216
|
+
staticSize += size(encoded);
|
|
1217
|
+
}
|
|
1218
|
+
const staticParams = [];
|
|
1219
|
+
const dynamicParams = [];
|
|
1220
|
+
let dynamicSize = 0;
|
|
1221
|
+
for (let i = 0;i < preparedParams.length; i++) {
|
|
1222
|
+
const { dynamic, encoded } = preparedParams[i];
|
|
1223
|
+
if (dynamic) {
|
|
1224
|
+
staticParams.push(numberToHex(staticSize + dynamicSize, { size: 32 }));
|
|
1225
|
+
dynamicParams.push(encoded);
|
|
1226
|
+
dynamicSize += size(encoded);
|
|
1227
|
+
} else {
|
|
1228
|
+
staticParams.push(encoded);
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
return concat([...staticParams, ...dynamicParams]);
|
|
1232
|
+
}
|
|
1233
|
+
function encodeAddress(value) {
|
|
1234
|
+
if (!isAddress(value))
|
|
1235
|
+
throw new InvalidAddressError({ address: value });
|
|
1236
|
+
return { dynamic: false, encoded: padHex(value.toLowerCase()) };
|
|
1237
|
+
}
|
|
1238
|
+
function encodeArray(value, { length, param }) {
|
|
1239
|
+
const dynamic = length === null;
|
|
1240
|
+
if (!Array.isArray(value))
|
|
1241
|
+
throw new InvalidArrayError(value);
|
|
1242
|
+
if (!dynamic && value.length !== length)
|
|
1243
|
+
throw new AbiEncodingArrayLengthMismatchError({
|
|
1244
|
+
expectedLength: length,
|
|
1245
|
+
givenLength: value.length,
|
|
1246
|
+
type: `${param.type}[${length}]`
|
|
1247
|
+
});
|
|
1248
|
+
let dynamicChild = false;
|
|
1249
|
+
const preparedParams = [];
|
|
1250
|
+
for (let i = 0;i < value.length; i++) {
|
|
1251
|
+
const preparedParam = prepareParam({ param, value: value[i] });
|
|
1252
|
+
if (preparedParam.dynamic)
|
|
1253
|
+
dynamicChild = true;
|
|
1254
|
+
preparedParams.push(preparedParam);
|
|
1255
|
+
}
|
|
1256
|
+
if (dynamic || dynamicChild) {
|
|
1257
|
+
const data = encodeParams(preparedParams);
|
|
1258
|
+
if (dynamic) {
|
|
1259
|
+
const length2 = numberToHex(preparedParams.length, { size: 32 });
|
|
1260
|
+
return {
|
|
1261
|
+
dynamic: true,
|
|
1262
|
+
encoded: preparedParams.length > 0 ? concat([length2, data]) : length2
|
|
1263
|
+
};
|
|
1264
|
+
}
|
|
1265
|
+
if (dynamicChild)
|
|
1266
|
+
return { dynamic: true, encoded: data };
|
|
1267
|
+
}
|
|
1268
|
+
return {
|
|
1269
|
+
dynamic: false,
|
|
1270
|
+
encoded: concat(preparedParams.map(({ encoded }) => encoded))
|
|
1271
|
+
};
|
|
1272
|
+
}
|
|
1273
|
+
function encodeBytes(value, { param }) {
|
|
1274
|
+
const [, paramSize] = param.type.split("bytes");
|
|
1275
|
+
const bytesSize = size(value);
|
|
1276
|
+
if (!paramSize) {
|
|
1277
|
+
let value_ = value;
|
|
1278
|
+
if (bytesSize % 32 !== 0)
|
|
1279
|
+
value_ = padHex(value_, {
|
|
1280
|
+
dir: "right",
|
|
1281
|
+
size: Math.ceil((value.length - 2) / 2 / 32) * 32
|
|
1282
|
+
});
|
|
1283
|
+
return {
|
|
1284
|
+
dynamic: true,
|
|
1285
|
+
encoded: concat([padHex(numberToHex(bytesSize, { size: 32 })), value_])
|
|
1286
|
+
};
|
|
1287
|
+
}
|
|
1288
|
+
if (bytesSize !== Number.parseInt(paramSize, 10))
|
|
1289
|
+
throw new AbiEncodingBytesSizeMismatchError({
|
|
1290
|
+
expectedSize: Number.parseInt(paramSize, 10),
|
|
1291
|
+
value
|
|
1292
|
+
});
|
|
1293
|
+
return { dynamic: false, encoded: padHex(value, { dir: "right" }) };
|
|
1294
|
+
}
|
|
1295
|
+
function encodeBool(value) {
|
|
1296
|
+
if (typeof value !== "boolean")
|
|
1297
|
+
throw new BaseError(`Invalid boolean value: "${value}" (type: ${typeof value}). Expected: \`true\` or \`false\`.`);
|
|
1298
|
+
return { dynamic: false, encoded: padHex(boolToHex(value)) };
|
|
1299
|
+
}
|
|
1300
|
+
function encodeNumber(value, { signed, size: size2 = 256 }) {
|
|
1301
|
+
if (typeof size2 === "number") {
|
|
1302
|
+
const max = 2n ** (BigInt(size2) - (signed ? 1n : 0n)) - 1n;
|
|
1303
|
+
const min = signed ? -max - 1n : 0n;
|
|
1304
|
+
if (value > max || value < min)
|
|
1305
|
+
throw new IntegerOutOfRangeError({
|
|
1306
|
+
max: max.toString(),
|
|
1307
|
+
min: min.toString(),
|
|
1308
|
+
signed,
|
|
1309
|
+
size: size2 / 8,
|
|
1310
|
+
value: value.toString()
|
|
1311
|
+
});
|
|
1312
|
+
}
|
|
1313
|
+
return {
|
|
1314
|
+
dynamic: false,
|
|
1315
|
+
encoded: numberToHex(value, {
|
|
1316
|
+
size: 32,
|
|
1317
|
+
signed
|
|
1318
|
+
})
|
|
1319
|
+
};
|
|
1320
|
+
}
|
|
1321
|
+
function encodeString(value) {
|
|
1322
|
+
const hexValue = stringToHex(value);
|
|
1323
|
+
const partsLength = Math.ceil(size(hexValue) / 32);
|
|
1324
|
+
const parts = [];
|
|
1325
|
+
for (let i = 0;i < partsLength; i++) {
|
|
1326
|
+
parts.push(padHex(slice(hexValue, i * 32, (i + 1) * 32), {
|
|
1327
|
+
dir: "right"
|
|
1328
|
+
}));
|
|
1329
|
+
}
|
|
1330
|
+
return {
|
|
1331
|
+
dynamic: true,
|
|
1332
|
+
encoded: concat([
|
|
1333
|
+
padHex(numberToHex(size(hexValue), { size: 32 })),
|
|
1334
|
+
...parts
|
|
1335
|
+
])
|
|
1336
|
+
};
|
|
1337
|
+
}
|
|
1338
|
+
function encodeTuple(value, { param }) {
|
|
1339
|
+
let dynamic = false;
|
|
1340
|
+
const preparedParams = [];
|
|
1341
|
+
for (let i = 0;i < param.components.length; i++) {
|
|
1342
|
+
const param_ = param.components[i];
|
|
1343
|
+
const index = Array.isArray(value) ? i : param_.name;
|
|
1344
|
+
const preparedParam = prepareParam({
|
|
1345
|
+
param: param_,
|
|
1346
|
+
value: value[index]
|
|
1347
|
+
});
|
|
1348
|
+
preparedParams.push(preparedParam);
|
|
1349
|
+
if (preparedParam.dynamic)
|
|
1350
|
+
dynamic = true;
|
|
1351
|
+
}
|
|
1352
|
+
return {
|
|
1353
|
+
dynamic,
|
|
1354
|
+
encoded: dynamic ? encodeParams(preparedParams) : concat(preparedParams.map(({ encoded }) => encoded))
|
|
1355
|
+
};
|
|
1356
|
+
}
|
|
1357
|
+
function getArrayComponents(type) {
|
|
1358
|
+
const matches = type.match(/^(.*)\[(\d+)?\]$/);
|
|
1359
|
+
return matches ? [matches[2] ? Number(matches[2]) : null, matches[1]] : undefined;
|
|
1360
|
+
}
|
|
1361
|
+
|
|
1362
|
+
// ../../node_modules/.bun/viem@2.52.0+1cd18485b0404aca/node_modules/viem/_esm/utils/stringify.js
|
|
1363
|
+
var stringify = (value, replacer, space) => JSON.stringify(value, (key, value_) => {
|
|
1364
|
+
const value2 = typeof value_ === "bigint" ? value_.toString() : value_;
|
|
1365
|
+
return typeof replacer === "function" ? replacer(key, value2) : value2;
|
|
1366
|
+
}, space);
|
|
1367
|
+
|
|
1368
|
+
// ../../node_modules/.bun/viem@2.52.0+1cd18485b0404aca/node_modules/viem/_esm/utils/unit/formatGwei.js
|
|
1369
|
+
function formatGwei(wei, unit = "wei") {
|
|
1370
|
+
return formatUnits(wei, gweiUnits[unit]);
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1373
|
+
// ../../node_modules/.bun/viem@2.52.0+1cd18485b0404aca/node_modules/viem/_esm/errors/transaction.js
|
|
1374
|
+
function prettyPrint(args) {
|
|
1375
|
+
const entries = Object.entries(args).map(([key, value]) => {
|
|
1376
|
+
if (value === undefined || value === false)
|
|
1377
|
+
return null;
|
|
1378
|
+
return [key, value];
|
|
1379
|
+
}).filter(Boolean);
|
|
1380
|
+
const maxLength = entries.reduce((acc, [key]) => Math.max(acc, key.length), 0);
|
|
1381
|
+
return entries.map(([key, value]) => ` ${`${key}:`.padEnd(maxLength + 1)} ${value}`).join(`
|
|
1382
|
+
`);
|
|
1383
|
+
}
|
|
1384
|
+
class InvalidLegacyVError extends BaseError {
|
|
1385
|
+
constructor({ v }) {
|
|
1386
|
+
super(`Invalid \`v\` value "${v}". Expected 27 or 28.`, {
|
|
1387
|
+
name: "InvalidLegacyVError"
|
|
1388
|
+
});
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
class InvalidSerializableTransactionError extends BaseError {
|
|
1393
|
+
constructor({ transaction }) {
|
|
1394
|
+
super("Cannot infer a transaction type from provided transaction.", {
|
|
1395
|
+
metaMessages: [
|
|
1396
|
+
"Provided Transaction:",
|
|
1397
|
+
"{",
|
|
1398
|
+
prettyPrint(transaction),
|
|
1399
|
+
"}",
|
|
1400
|
+
"",
|
|
1401
|
+
"To infer the type, either provide:",
|
|
1402
|
+
"- a `type` to the Transaction, or",
|
|
1403
|
+
"- an EIP-1559 Transaction with `maxFeePerGas`, or",
|
|
1404
|
+
"- an EIP-2930 Transaction with `gasPrice` & `accessList`, or",
|
|
1405
|
+
"- an EIP-4844 Transaction with `blobs`, `blobVersionedHashes`, `sidecars`, or",
|
|
1406
|
+
"- an EIP-7702 Transaction with `authorizationList`, or",
|
|
1407
|
+
"- a Legacy Transaction with `gasPrice`"
|
|
1408
|
+
],
|
|
1409
|
+
name: "InvalidSerializableTransactionError"
|
|
1410
|
+
});
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
class InvalidStorageKeySizeError extends BaseError {
|
|
1414
|
+
constructor({ storageKey }) {
|
|
1415
|
+
super(`Size for storage key "${storageKey}" is invalid. Expected 32 bytes. Got ${Math.floor((storageKey.length - 2) / 2)} bytes.`, { name: "InvalidStorageKeySizeError" });
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
|
|
1419
|
+
class TransactionExecutionError extends BaseError {
|
|
1420
|
+
constructor(cause, { account, docsPath, chain, data, gas, gasPrice, maxFeePerGas, maxPriorityFeePerGas, nonce, to, value }) {
|
|
1421
|
+
const prettyArgs = prettyPrint({
|
|
1422
|
+
chain: chain && `${chain?.name} (id: ${chain?.id})`,
|
|
1423
|
+
from: account?.address,
|
|
1424
|
+
to,
|
|
1425
|
+
value: typeof value !== "undefined" && `${formatEther(value)} ${chain?.nativeCurrency?.symbol || "ETH"}`,
|
|
1426
|
+
data,
|
|
1427
|
+
gas,
|
|
1428
|
+
gasPrice: typeof gasPrice !== "undefined" && `${formatGwei(gasPrice)} gwei`,
|
|
1429
|
+
maxFeePerGas: typeof maxFeePerGas !== "undefined" && `${formatGwei(maxFeePerGas)} gwei`,
|
|
1430
|
+
maxPriorityFeePerGas: typeof maxPriorityFeePerGas !== "undefined" && `${formatGwei(maxPriorityFeePerGas)} gwei`,
|
|
1431
|
+
nonce
|
|
1432
|
+
});
|
|
1433
|
+
super(cause.shortMessage, {
|
|
1434
|
+
cause,
|
|
1435
|
+
docsPath,
|
|
1436
|
+
metaMessages: [
|
|
1437
|
+
...cause.metaMessages ? [...cause.metaMessages, " "] : [],
|
|
1438
|
+
"Request Arguments:",
|
|
1439
|
+
prettyArgs
|
|
1440
|
+
].filter(Boolean),
|
|
1441
|
+
name: "TransactionExecutionError"
|
|
1442
|
+
});
|
|
1443
|
+
Object.defineProperty(this, "cause", {
|
|
1444
|
+
enumerable: true,
|
|
1445
|
+
configurable: true,
|
|
1446
|
+
writable: true,
|
|
1447
|
+
value: undefined
|
|
1448
|
+
});
|
|
1449
|
+
this.cause = cause;
|
|
1450
|
+
}
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1453
|
+
class TransactionNotFoundError extends BaseError {
|
|
1454
|
+
constructor({ blockHash, blockNumber, blockTag, hash, index }) {
|
|
1455
|
+
let identifier = "Transaction";
|
|
1456
|
+
if (blockTag && index !== undefined)
|
|
1457
|
+
identifier = `Transaction at block time "${blockTag}" at index "${index}"`;
|
|
1458
|
+
if (blockHash && index !== undefined)
|
|
1459
|
+
identifier = `Transaction at block hash "${blockHash}" at index "${index}"`;
|
|
1460
|
+
if (blockNumber && index !== undefined)
|
|
1461
|
+
identifier = `Transaction at block number "${blockNumber}" at index "${index}"`;
|
|
1462
|
+
if (hash)
|
|
1463
|
+
identifier = `Transaction with hash "${hash}"`;
|
|
1464
|
+
super(`${identifier} could not be found.`, {
|
|
1465
|
+
name: "TransactionNotFoundError"
|
|
1466
|
+
});
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
|
|
1470
|
+
class TransactionReceiptNotFoundError extends BaseError {
|
|
1471
|
+
constructor({ hash }) {
|
|
1472
|
+
super(`Transaction receipt with hash "${hash}" could not be found. The Transaction may not be processed on a block yet.`, {
|
|
1473
|
+
name: "TransactionReceiptNotFoundError"
|
|
1474
|
+
});
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
|
|
1478
|
+
class TransactionReceiptRevertedError extends BaseError {
|
|
1479
|
+
constructor({ receipt }) {
|
|
1480
|
+
super(`Transaction with hash "${receipt.transactionHash}" reverted.`, {
|
|
1481
|
+
metaMessages: [
|
|
1482
|
+
'The receipt marked the transaction as "reverted". This could mean that the function on the contract you are trying to call threw an error.',
|
|
1483
|
+
" ",
|
|
1484
|
+
"You can attempt to extract the revert reason by:",
|
|
1485
|
+
"- calling the `simulateContract` or `simulateCalls` Action with the `abi` and `functionName` of the contract",
|
|
1486
|
+
"- using the `call` Action with raw `data`"
|
|
1487
|
+
],
|
|
1488
|
+
name: "TransactionReceiptRevertedError"
|
|
1489
|
+
});
|
|
1490
|
+
Object.defineProperty(this, "receipt", {
|
|
1491
|
+
enumerable: true,
|
|
1492
|
+
configurable: true,
|
|
1493
|
+
writable: true,
|
|
1494
|
+
value: undefined
|
|
1495
|
+
});
|
|
1496
|
+
this.receipt = receipt;
|
|
1497
|
+
}
|
|
1498
|
+
}
|
|
1499
|
+
|
|
1500
|
+
class WaitForTransactionReceiptTimeoutError extends BaseError {
|
|
1501
|
+
constructor({ hash }) {
|
|
1502
|
+
super(`Timed out while waiting for transaction with hash "${hash}" to be confirmed.`, { name: "WaitForTransactionReceiptTimeoutError" });
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1506
|
+
// ../../node_modules/.bun/viem@2.52.0+1cd18485b0404aca/node_modules/viem/_esm/errors/chain.js
|
|
1507
|
+
class ChainDoesNotSupportContract extends BaseError {
|
|
1508
|
+
constructor({ blockNumber, chain, contract }) {
|
|
1509
|
+
super(`Chain "${chain.name}" does not support contract "${contract.name}".`, {
|
|
1510
|
+
metaMessages: [
|
|
1511
|
+
"This could be due to any of the following:",
|
|
1512
|
+
...blockNumber && contract.blockCreated && contract.blockCreated > blockNumber ? [
|
|
1513
|
+
`- The contract "${contract.name}" was not deployed until block ${contract.blockCreated} (current block ${blockNumber}).`
|
|
1514
|
+
] : [
|
|
1515
|
+
`- The chain does not have the contract "${contract.name}" configured.`
|
|
1516
|
+
]
|
|
1517
|
+
],
|
|
1518
|
+
name: "ChainDoesNotSupportContract"
|
|
1519
|
+
});
|
|
1520
|
+
}
|
|
1521
|
+
}
|
|
1522
|
+
|
|
1523
|
+
class ChainMismatchError extends BaseError {
|
|
1524
|
+
constructor({ chain, currentChainId }) {
|
|
1525
|
+
super(`The current chain of the wallet (id: ${currentChainId}) does not match the target chain for the transaction (id: ${chain.id} – ${chain.name}).`, {
|
|
1526
|
+
metaMessages: [
|
|
1527
|
+
`Current Chain ID: ${currentChainId}`,
|
|
1528
|
+
`Expected Chain ID: ${chain.id} – ${chain.name}`
|
|
1529
|
+
],
|
|
1530
|
+
name: "ChainMismatchError"
|
|
1531
|
+
});
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1535
|
+
class ChainNotFoundError extends BaseError {
|
|
1536
|
+
constructor() {
|
|
1537
|
+
super([
|
|
1538
|
+
"No chain was provided to the request.",
|
|
1539
|
+
"Please provide a chain with the `chain` argument on the Action, or by supplying a `chain` to WalletClient."
|
|
1540
|
+
].join(`
|
|
1541
|
+
`), {
|
|
1542
|
+
name: "ChainNotFoundError"
|
|
1543
|
+
});
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1547
|
+
class ClientChainNotConfiguredError extends BaseError {
|
|
1548
|
+
constructor() {
|
|
1549
|
+
super("No chain was provided to the Client.", {
|
|
1550
|
+
name: "ClientChainNotConfiguredError"
|
|
1551
|
+
});
|
|
1552
|
+
}
|
|
1553
|
+
}
|
|
1554
|
+
|
|
1555
|
+
class InvalidChainIdError extends BaseError {
|
|
1556
|
+
constructor({ chainId }) {
|
|
1557
|
+
super(typeof chainId === "number" ? `Chain ID "${chainId}" is invalid.` : "Chain ID is invalid.", { name: "InvalidChainIdError" });
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
1560
|
+
|
|
1561
|
+
// ../../node_modules/.bun/viem@2.52.0+1cd18485b0404aca/node_modules/viem/_esm/errors/cursor.js
|
|
1562
|
+
class NegativeOffsetError extends BaseError {
|
|
1563
|
+
constructor({ offset }) {
|
|
1564
|
+
super(`Offset \`${offset}\` cannot be negative.`, {
|
|
1565
|
+
name: "NegativeOffsetError"
|
|
1566
|
+
});
|
|
1567
|
+
}
|
|
1568
|
+
}
|
|
1569
|
+
|
|
1570
|
+
class PositionOutOfBoundsError extends BaseError {
|
|
1571
|
+
constructor({ length, position }) {
|
|
1572
|
+
super(`Position \`${position}\` is out of bounds (\`0 < position < ${length}\`).`, { name: "PositionOutOfBoundsError" });
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
|
|
1576
|
+
class RecursiveReadLimitExceededError extends BaseError {
|
|
1577
|
+
constructor({ count, limit }) {
|
|
1578
|
+
super(`Recursive read limit of \`${limit}\` exceeded (recursive read count: \`${count}\`).`, { name: "RecursiveReadLimitExceededError" });
|
|
1579
|
+
}
|
|
1580
|
+
}
|
|
1581
|
+
|
|
1582
|
+
// ../../node_modules/.bun/viem@2.52.0+1cd18485b0404aca/node_modules/viem/_esm/utils/cursor.js
|
|
1583
|
+
var staticCursor = {
|
|
1584
|
+
bytes: new Uint8Array,
|
|
1585
|
+
dataView: new DataView(new ArrayBuffer(0)),
|
|
1586
|
+
position: 0,
|
|
1587
|
+
positionReadCount: new Map,
|
|
1588
|
+
recursiveReadCount: 0,
|
|
1589
|
+
recursiveReadLimit: Number.POSITIVE_INFINITY,
|
|
1590
|
+
assertReadLimit() {
|
|
1591
|
+
if (this.recursiveReadCount >= this.recursiveReadLimit)
|
|
1592
|
+
throw new RecursiveReadLimitExceededError({
|
|
1593
|
+
count: this.recursiveReadCount + 1,
|
|
1594
|
+
limit: this.recursiveReadLimit
|
|
1595
|
+
});
|
|
1596
|
+
},
|
|
1597
|
+
assertPosition(position) {
|
|
1598
|
+
if (position < 0 || position > this.bytes.length - 1)
|
|
1599
|
+
throw new PositionOutOfBoundsError({
|
|
1600
|
+
length: this.bytes.length,
|
|
1601
|
+
position
|
|
1602
|
+
});
|
|
1603
|
+
},
|
|
1604
|
+
decrementPosition(offset) {
|
|
1605
|
+
if (offset < 0)
|
|
1606
|
+
throw new NegativeOffsetError({ offset });
|
|
1607
|
+
const position = this.position - offset;
|
|
1608
|
+
this.assertPosition(position);
|
|
1609
|
+
this.position = position;
|
|
1610
|
+
},
|
|
1611
|
+
getReadCount(position) {
|
|
1612
|
+
return this.positionReadCount.get(position || this.position) || 0;
|
|
1613
|
+
},
|
|
1614
|
+
incrementPosition(offset) {
|
|
1615
|
+
if (offset < 0)
|
|
1616
|
+
throw new NegativeOffsetError({ offset });
|
|
1617
|
+
const position = this.position + offset;
|
|
1618
|
+
this.assertPosition(position);
|
|
1619
|
+
this.position = position;
|
|
1620
|
+
},
|
|
1621
|
+
inspectByte(position_) {
|
|
1622
|
+
const position = position_ ?? this.position;
|
|
1623
|
+
this.assertPosition(position);
|
|
1624
|
+
return this.bytes[position];
|
|
1625
|
+
},
|
|
1626
|
+
inspectBytes(length, position_) {
|
|
1627
|
+
const position = position_ ?? this.position;
|
|
1628
|
+
this.assertPosition(position + length - 1);
|
|
1629
|
+
return this.bytes.subarray(position, position + length);
|
|
1630
|
+
},
|
|
1631
|
+
inspectUint8(position_) {
|
|
1632
|
+
const position = position_ ?? this.position;
|
|
1633
|
+
this.assertPosition(position);
|
|
1634
|
+
return this.bytes[position];
|
|
1635
|
+
},
|
|
1636
|
+
inspectUint16(position_) {
|
|
1637
|
+
const position = position_ ?? this.position;
|
|
1638
|
+
this.assertPosition(position + 1);
|
|
1639
|
+
return this.dataView.getUint16(position);
|
|
1640
|
+
},
|
|
1641
|
+
inspectUint24(position_) {
|
|
1642
|
+
const position = position_ ?? this.position;
|
|
1643
|
+
this.assertPosition(position + 2);
|
|
1644
|
+
return (this.dataView.getUint16(position) << 8) + this.dataView.getUint8(position + 2);
|
|
1645
|
+
},
|
|
1646
|
+
inspectUint32(position_) {
|
|
1647
|
+
const position = position_ ?? this.position;
|
|
1648
|
+
this.assertPosition(position + 3);
|
|
1649
|
+
return this.dataView.getUint32(position);
|
|
1650
|
+
},
|
|
1651
|
+
pushByte(byte) {
|
|
1652
|
+
this.assertPosition(this.position);
|
|
1653
|
+
this.bytes[this.position] = byte;
|
|
1654
|
+
this.position++;
|
|
1655
|
+
},
|
|
1656
|
+
pushBytes(bytes) {
|
|
1657
|
+
this.assertPosition(this.position + bytes.length - 1);
|
|
1658
|
+
this.bytes.set(bytes, this.position);
|
|
1659
|
+
this.position += bytes.length;
|
|
1660
|
+
},
|
|
1661
|
+
pushUint8(value) {
|
|
1662
|
+
this.assertPosition(this.position);
|
|
1663
|
+
this.bytes[this.position] = value;
|
|
1664
|
+
this.position++;
|
|
1665
|
+
},
|
|
1666
|
+
pushUint16(value) {
|
|
1667
|
+
this.assertPosition(this.position + 1);
|
|
1668
|
+
this.dataView.setUint16(this.position, value);
|
|
1669
|
+
this.position += 2;
|
|
1670
|
+
},
|
|
1671
|
+
pushUint24(value) {
|
|
1672
|
+
this.assertPosition(this.position + 2);
|
|
1673
|
+
this.dataView.setUint16(this.position, value >> 8);
|
|
1674
|
+
this.dataView.setUint8(this.position + 2, value & ~4294967040);
|
|
1675
|
+
this.position += 3;
|
|
1676
|
+
},
|
|
1677
|
+
pushUint32(value) {
|
|
1678
|
+
this.assertPosition(this.position + 3);
|
|
1679
|
+
this.dataView.setUint32(this.position, value);
|
|
1680
|
+
this.position += 4;
|
|
1681
|
+
},
|
|
1682
|
+
readByte() {
|
|
1683
|
+
this.assertReadLimit();
|
|
1684
|
+
this._touch();
|
|
1685
|
+
const value = this.inspectByte();
|
|
1686
|
+
this.position++;
|
|
1687
|
+
return value;
|
|
1688
|
+
},
|
|
1689
|
+
readBytes(length, size2) {
|
|
1690
|
+
this.assertReadLimit();
|
|
1691
|
+
this._touch();
|
|
1692
|
+
const value = this.inspectBytes(length);
|
|
1693
|
+
this.position += size2 ?? length;
|
|
1694
|
+
return value;
|
|
1695
|
+
},
|
|
1696
|
+
readUint8() {
|
|
1697
|
+
this.assertReadLimit();
|
|
1698
|
+
this._touch();
|
|
1699
|
+
const value = this.inspectUint8();
|
|
1700
|
+
this.position += 1;
|
|
1701
|
+
return value;
|
|
1702
|
+
},
|
|
1703
|
+
readUint16() {
|
|
1704
|
+
this.assertReadLimit();
|
|
1705
|
+
this._touch();
|
|
1706
|
+
const value = this.inspectUint16();
|
|
1707
|
+
this.position += 2;
|
|
1708
|
+
return value;
|
|
1709
|
+
},
|
|
1710
|
+
readUint24() {
|
|
1711
|
+
this.assertReadLimit();
|
|
1712
|
+
this._touch();
|
|
1713
|
+
const value = this.inspectUint24();
|
|
1714
|
+
this.position += 3;
|
|
1715
|
+
return value;
|
|
1716
|
+
},
|
|
1717
|
+
readUint32() {
|
|
1718
|
+
this.assertReadLimit();
|
|
1719
|
+
this._touch();
|
|
1720
|
+
const value = this.inspectUint32();
|
|
1721
|
+
this.position += 4;
|
|
1722
|
+
return value;
|
|
1723
|
+
},
|
|
1724
|
+
get remaining() {
|
|
1725
|
+
return this.bytes.length - this.position;
|
|
1726
|
+
},
|
|
1727
|
+
setPosition(position) {
|
|
1728
|
+
const oldPosition = this.position;
|
|
1729
|
+
this.assertPosition(position);
|
|
1730
|
+
this.position = position;
|
|
1731
|
+
return () => this.position = oldPosition;
|
|
1732
|
+
},
|
|
1733
|
+
_touch() {
|
|
1734
|
+
if (this.recursiveReadLimit === Number.POSITIVE_INFINITY)
|
|
1735
|
+
return;
|
|
1736
|
+
const count = this.getReadCount();
|
|
1737
|
+
this.positionReadCount.set(this.position, count + 1);
|
|
1738
|
+
if (count > 0)
|
|
1739
|
+
this.recursiveReadCount++;
|
|
1740
|
+
}
|
|
1741
|
+
};
|
|
1742
|
+
function createCursor(bytes, { recursiveReadLimit = 8192 } = {}) {
|
|
1743
|
+
const cursor = Object.create(staticCursor);
|
|
1744
|
+
cursor.bytes = bytes;
|
|
1745
|
+
cursor.dataView = new DataView(bytes.buffer ?? bytes, bytes.byteOffset, bytes.byteLength);
|
|
1746
|
+
cursor.positionReadCount = new Map;
|
|
1747
|
+
cursor.recursiveReadLimit = recursiveReadLimit;
|
|
1748
|
+
return cursor;
|
|
1749
|
+
}
|
|
1750
|
+
|
|
1751
|
+
// ../../node_modules/.bun/viem@2.52.0+1cd18485b0404aca/node_modules/viem/_esm/constants/number.js
|
|
1752
|
+
var maxInt8 = 2n ** (8n - 1n) - 1n;
|
|
1753
|
+
var maxInt16 = 2n ** (16n - 1n) - 1n;
|
|
1754
|
+
var maxInt24 = 2n ** (24n - 1n) - 1n;
|
|
1755
|
+
var maxInt32 = 2n ** (32n - 1n) - 1n;
|
|
1756
|
+
var maxInt40 = 2n ** (40n - 1n) - 1n;
|
|
1757
|
+
var maxInt48 = 2n ** (48n - 1n) - 1n;
|
|
1758
|
+
var maxInt56 = 2n ** (56n - 1n) - 1n;
|
|
1759
|
+
var maxInt64 = 2n ** (64n - 1n) - 1n;
|
|
1760
|
+
var maxInt72 = 2n ** (72n - 1n) - 1n;
|
|
1761
|
+
var maxInt80 = 2n ** (80n - 1n) - 1n;
|
|
1762
|
+
var maxInt88 = 2n ** (88n - 1n) - 1n;
|
|
1763
|
+
var maxInt96 = 2n ** (96n - 1n) - 1n;
|
|
1764
|
+
var maxInt104 = 2n ** (104n - 1n) - 1n;
|
|
1765
|
+
var maxInt112 = 2n ** (112n - 1n) - 1n;
|
|
1766
|
+
var maxInt120 = 2n ** (120n - 1n) - 1n;
|
|
1767
|
+
var maxInt128 = 2n ** (128n - 1n) - 1n;
|
|
1768
|
+
var maxInt136 = 2n ** (136n - 1n) - 1n;
|
|
1769
|
+
var maxInt144 = 2n ** (144n - 1n) - 1n;
|
|
1770
|
+
var maxInt152 = 2n ** (152n - 1n) - 1n;
|
|
1771
|
+
var maxInt160 = 2n ** (160n - 1n) - 1n;
|
|
1772
|
+
var maxInt168 = 2n ** (168n - 1n) - 1n;
|
|
1773
|
+
var maxInt176 = 2n ** (176n - 1n) - 1n;
|
|
1774
|
+
var maxInt184 = 2n ** (184n - 1n) - 1n;
|
|
1775
|
+
var maxInt192 = 2n ** (192n - 1n) - 1n;
|
|
1776
|
+
var maxInt200 = 2n ** (200n - 1n) - 1n;
|
|
1777
|
+
var maxInt208 = 2n ** (208n - 1n) - 1n;
|
|
1778
|
+
var maxInt216 = 2n ** (216n - 1n) - 1n;
|
|
1779
|
+
var maxInt224 = 2n ** (224n - 1n) - 1n;
|
|
1780
|
+
var maxInt232 = 2n ** (232n - 1n) - 1n;
|
|
1781
|
+
var maxInt240 = 2n ** (240n - 1n) - 1n;
|
|
1782
|
+
var maxInt248 = 2n ** (248n - 1n) - 1n;
|
|
1783
|
+
var maxInt256 = 2n ** (256n - 1n) - 1n;
|
|
1784
|
+
var minInt8 = -(2n ** (8n - 1n));
|
|
1785
|
+
var minInt16 = -(2n ** (16n - 1n));
|
|
1786
|
+
var minInt24 = -(2n ** (24n - 1n));
|
|
1787
|
+
var minInt32 = -(2n ** (32n - 1n));
|
|
1788
|
+
var minInt40 = -(2n ** (40n - 1n));
|
|
1789
|
+
var minInt48 = -(2n ** (48n - 1n));
|
|
1790
|
+
var minInt56 = -(2n ** (56n - 1n));
|
|
1791
|
+
var minInt64 = -(2n ** (64n - 1n));
|
|
1792
|
+
var minInt72 = -(2n ** (72n - 1n));
|
|
1793
|
+
var minInt80 = -(2n ** (80n - 1n));
|
|
1794
|
+
var minInt88 = -(2n ** (88n - 1n));
|
|
1795
|
+
var minInt96 = -(2n ** (96n - 1n));
|
|
1796
|
+
var minInt104 = -(2n ** (104n - 1n));
|
|
1797
|
+
var minInt112 = -(2n ** (112n - 1n));
|
|
1798
|
+
var minInt120 = -(2n ** (120n - 1n));
|
|
1799
|
+
var minInt128 = -(2n ** (128n - 1n));
|
|
1800
|
+
var minInt136 = -(2n ** (136n - 1n));
|
|
1801
|
+
var minInt144 = -(2n ** (144n - 1n));
|
|
1802
|
+
var minInt152 = -(2n ** (152n - 1n));
|
|
1803
|
+
var minInt160 = -(2n ** (160n - 1n));
|
|
1804
|
+
var minInt168 = -(2n ** (168n - 1n));
|
|
1805
|
+
var minInt176 = -(2n ** (176n - 1n));
|
|
1806
|
+
var minInt184 = -(2n ** (184n - 1n));
|
|
1807
|
+
var minInt192 = -(2n ** (192n - 1n));
|
|
1808
|
+
var minInt200 = -(2n ** (200n - 1n));
|
|
1809
|
+
var minInt208 = -(2n ** (208n - 1n));
|
|
1810
|
+
var minInt216 = -(2n ** (216n - 1n));
|
|
1811
|
+
var minInt224 = -(2n ** (224n - 1n));
|
|
1812
|
+
var minInt232 = -(2n ** (232n - 1n));
|
|
1813
|
+
var minInt240 = -(2n ** (240n - 1n));
|
|
1814
|
+
var minInt248 = -(2n ** (248n - 1n));
|
|
1815
|
+
var minInt256 = -(2n ** (256n - 1n));
|
|
1816
|
+
var maxUint8 = 2n ** 8n - 1n;
|
|
1817
|
+
var maxUint16 = 2n ** 16n - 1n;
|
|
1818
|
+
var maxUint24 = 2n ** 24n - 1n;
|
|
1819
|
+
var maxUint32 = 2n ** 32n - 1n;
|
|
1820
|
+
var maxUint40 = 2n ** 40n - 1n;
|
|
1821
|
+
var maxUint48 = 2n ** 48n - 1n;
|
|
1822
|
+
var maxUint56 = 2n ** 56n - 1n;
|
|
1823
|
+
var maxUint64 = 2n ** 64n - 1n;
|
|
1824
|
+
var maxUint72 = 2n ** 72n - 1n;
|
|
1825
|
+
var maxUint80 = 2n ** 80n - 1n;
|
|
1826
|
+
var maxUint88 = 2n ** 88n - 1n;
|
|
1827
|
+
var maxUint96 = 2n ** 96n - 1n;
|
|
1828
|
+
var maxUint104 = 2n ** 104n - 1n;
|
|
1829
|
+
var maxUint112 = 2n ** 112n - 1n;
|
|
1830
|
+
var maxUint120 = 2n ** 120n - 1n;
|
|
1831
|
+
var maxUint128 = 2n ** 128n - 1n;
|
|
1832
|
+
var maxUint136 = 2n ** 136n - 1n;
|
|
1833
|
+
var maxUint144 = 2n ** 144n - 1n;
|
|
1834
|
+
var maxUint152 = 2n ** 152n - 1n;
|
|
1835
|
+
var maxUint160 = 2n ** 160n - 1n;
|
|
1836
|
+
var maxUint168 = 2n ** 168n - 1n;
|
|
1837
|
+
var maxUint176 = 2n ** 176n - 1n;
|
|
1838
|
+
var maxUint184 = 2n ** 184n - 1n;
|
|
1839
|
+
var maxUint192 = 2n ** 192n - 1n;
|
|
1840
|
+
var maxUint200 = 2n ** 200n - 1n;
|
|
1841
|
+
var maxUint208 = 2n ** 208n - 1n;
|
|
1842
|
+
var maxUint216 = 2n ** 216n - 1n;
|
|
1843
|
+
var maxUint224 = 2n ** 224n - 1n;
|
|
1844
|
+
var maxUint232 = 2n ** 232n - 1n;
|
|
1845
|
+
var maxUint240 = 2n ** 240n - 1n;
|
|
1846
|
+
var maxUint248 = 2n ** 248n - 1n;
|
|
1847
|
+
var maxUint256 = 2n ** 256n - 1n;
|
|
1848
|
+
|
|
1849
|
+
// ../../node_modules/.bun/viem@2.52.0+1cd18485b0404aca/node_modules/viem/_esm/errors/node.js
|
|
1850
|
+
class ExecutionRevertedError extends BaseError {
|
|
1851
|
+
constructor({ cause, message } = {}) {
|
|
1852
|
+
const reason = message?.replace("execution reverted: ", "")?.replace("execution reverted", "");
|
|
1853
|
+
super(`Execution reverted ${reason ? `with reason: ${reason}` : "for an unknown reason"}.`, {
|
|
1854
|
+
cause,
|
|
1855
|
+
name: "ExecutionRevertedError"
|
|
1856
|
+
});
|
|
1857
|
+
}
|
|
1858
|
+
}
|
|
1859
|
+
Object.defineProperty(ExecutionRevertedError, "code", {
|
|
1860
|
+
enumerable: true,
|
|
1861
|
+
configurable: true,
|
|
1862
|
+
writable: true,
|
|
1863
|
+
value: 3
|
|
1864
|
+
});
|
|
1865
|
+
Object.defineProperty(ExecutionRevertedError, "nodeMessage", {
|
|
1866
|
+
enumerable: true,
|
|
1867
|
+
configurable: true,
|
|
1868
|
+
writable: true,
|
|
1869
|
+
value: /execution reverted|gas required exceeds allowance/
|
|
1870
|
+
});
|
|
1871
|
+
|
|
1872
|
+
class FeeCapTooHighError extends BaseError {
|
|
1873
|
+
constructor({ cause, maxFeePerGas } = {}) {
|
|
1874
|
+
super(`The fee cap (\`maxFeePerGas\`${maxFeePerGas ? ` = ${formatGwei(maxFeePerGas)} gwei` : ""}) cannot be higher than the maximum allowed value (2^256-1).`, {
|
|
1875
|
+
cause,
|
|
1876
|
+
name: "FeeCapTooHighError"
|
|
1877
|
+
});
|
|
1878
|
+
}
|
|
1879
|
+
}
|
|
1880
|
+
Object.defineProperty(FeeCapTooHighError, "nodeMessage", {
|
|
1881
|
+
enumerable: true,
|
|
1882
|
+
configurable: true,
|
|
1883
|
+
writable: true,
|
|
1884
|
+
value: /max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/
|
|
1885
|
+
});
|
|
1886
|
+
|
|
1887
|
+
class FeeCapTooLowError extends BaseError {
|
|
1888
|
+
constructor({ cause, maxFeePerGas } = {}) {
|
|
1889
|
+
super(`The fee cap (\`maxFeePerGas\`${maxFeePerGas ? ` = ${formatGwei(maxFeePerGas)}` : ""} gwei) cannot be lower than the block base fee.`, {
|
|
1890
|
+
cause,
|
|
1891
|
+
name: "FeeCapTooLowError"
|
|
1892
|
+
});
|
|
1893
|
+
}
|
|
1894
|
+
}
|
|
1895
|
+
Object.defineProperty(FeeCapTooLowError, "nodeMessage", {
|
|
1896
|
+
enumerable: true,
|
|
1897
|
+
configurable: true,
|
|
1898
|
+
writable: true,
|
|
1899
|
+
value: /max fee per gas less than block base fee|fee cap less than block base fee|transaction is outdated/
|
|
1900
|
+
});
|
|
1901
|
+
|
|
1902
|
+
class NonceTooHighError extends BaseError {
|
|
1903
|
+
constructor({ cause, nonce } = {}) {
|
|
1904
|
+
super(`Nonce provided for the transaction ${nonce ? `(${nonce}) ` : ""}is higher than the next one expected.`, { cause, name: "NonceTooHighError" });
|
|
1905
|
+
}
|
|
1906
|
+
}
|
|
1907
|
+
Object.defineProperty(NonceTooHighError, "nodeMessage", {
|
|
1908
|
+
enumerable: true,
|
|
1909
|
+
configurable: true,
|
|
1910
|
+
writable: true,
|
|
1911
|
+
value: /nonce too high/
|
|
1912
|
+
});
|
|
1913
|
+
|
|
1914
|
+
class NonceTooLowError extends BaseError {
|
|
1915
|
+
constructor({ cause, nonce } = {}) {
|
|
1916
|
+
super([
|
|
1917
|
+
`Nonce provided for the transaction ${nonce ? `(${nonce}) ` : ""}is lower than the current nonce of the account.`,
|
|
1918
|
+
"Try increasing the nonce or find the latest nonce with `getTransactionCount`."
|
|
1919
|
+
].join(`
|
|
1920
|
+
`), { cause, name: "NonceTooLowError" });
|
|
1921
|
+
}
|
|
1922
|
+
}
|
|
1923
|
+
Object.defineProperty(NonceTooLowError, "nodeMessage", {
|
|
1924
|
+
enumerable: true,
|
|
1925
|
+
configurable: true,
|
|
1926
|
+
writable: true,
|
|
1927
|
+
value: /nonce too low|transaction already imported|already known/
|
|
1928
|
+
});
|
|
1929
|
+
|
|
1930
|
+
class NonceMaxValueError extends BaseError {
|
|
1931
|
+
constructor({ cause, nonce } = {}) {
|
|
1932
|
+
super(`Nonce provided for the transaction ${nonce ? `(${nonce}) ` : ""}exceeds the maximum allowed nonce.`, { cause, name: "NonceMaxValueError" });
|
|
1933
|
+
}
|
|
1934
|
+
}
|
|
1935
|
+
Object.defineProperty(NonceMaxValueError, "nodeMessage", {
|
|
1936
|
+
enumerable: true,
|
|
1937
|
+
configurable: true,
|
|
1938
|
+
writable: true,
|
|
1939
|
+
value: /nonce has max value/
|
|
1940
|
+
});
|
|
1941
|
+
|
|
1942
|
+
class InsufficientFundsError extends BaseError {
|
|
1943
|
+
constructor({ cause } = {}) {
|
|
1944
|
+
super([
|
|
1945
|
+
"The total cost (gas * gas fee + value) of executing this transaction exceeds the balance of the account."
|
|
1946
|
+
].join(`
|
|
1947
|
+
`), {
|
|
1948
|
+
cause,
|
|
1949
|
+
metaMessages: [
|
|
1950
|
+
"This error could arise when the account does not have enough funds to:",
|
|
1951
|
+
" - pay for the total gas fee,",
|
|
1952
|
+
" - pay for the value to send.",
|
|
1953
|
+
" ",
|
|
1954
|
+
"The cost of the transaction is calculated as `gas * gas fee + value`, where:",
|
|
1955
|
+
" - `gas` is the amount of gas needed for transaction to execute,",
|
|
1956
|
+
" - `gas fee` is the gas fee,",
|
|
1957
|
+
" - `value` is the amount of ether to send to the recipient."
|
|
1958
|
+
],
|
|
1959
|
+
name: "InsufficientFundsError"
|
|
1960
|
+
});
|
|
1961
|
+
}
|
|
1962
|
+
}
|
|
1963
|
+
Object.defineProperty(InsufficientFundsError, "nodeMessage", {
|
|
1964
|
+
enumerable: true,
|
|
1965
|
+
configurable: true,
|
|
1966
|
+
writable: true,
|
|
1967
|
+
value: /insufficient funds|exceeds transaction sender account balance/
|
|
1968
|
+
});
|
|
1969
|
+
|
|
1970
|
+
class IntrinsicGasTooHighError extends BaseError {
|
|
1971
|
+
constructor({ cause, gas } = {}) {
|
|
1972
|
+
super(`The amount of gas ${gas ? `(${gas}) ` : ""}provided for the transaction exceeds the limit allowed for the block.`, {
|
|
1973
|
+
cause,
|
|
1974
|
+
name: "IntrinsicGasTooHighError"
|
|
1975
|
+
});
|
|
1976
|
+
}
|
|
1977
|
+
}
|
|
1978
|
+
Object.defineProperty(IntrinsicGasTooHighError, "nodeMessage", {
|
|
1979
|
+
enumerable: true,
|
|
1980
|
+
configurable: true,
|
|
1981
|
+
writable: true,
|
|
1982
|
+
value: /intrinsic gas too high|gas limit reached/
|
|
1983
|
+
});
|
|
1984
|
+
|
|
1985
|
+
class IntrinsicGasTooLowError extends BaseError {
|
|
1986
|
+
constructor({ cause, gas } = {}) {
|
|
1987
|
+
super(`The amount of gas ${gas ? `(${gas}) ` : ""}provided for the transaction is too low.`, {
|
|
1988
|
+
cause,
|
|
1989
|
+
name: "IntrinsicGasTooLowError"
|
|
1990
|
+
});
|
|
1991
|
+
}
|
|
1992
|
+
}
|
|
1993
|
+
Object.defineProperty(IntrinsicGasTooLowError, "nodeMessage", {
|
|
1994
|
+
enumerable: true,
|
|
1995
|
+
configurable: true,
|
|
1996
|
+
writable: true,
|
|
1997
|
+
value: /intrinsic gas too low/
|
|
1998
|
+
});
|
|
1999
|
+
|
|
2000
|
+
class TransactionTypeNotSupportedError extends BaseError {
|
|
2001
|
+
constructor({ cause }) {
|
|
2002
|
+
super("The transaction type is not supported for this chain.", {
|
|
2003
|
+
cause,
|
|
2004
|
+
name: "TransactionTypeNotSupportedError"
|
|
2005
|
+
});
|
|
2006
|
+
}
|
|
2007
|
+
}
|
|
2008
|
+
Object.defineProperty(TransactionTypeNotSupportedError, "nodeMessage", {
|
|
2009
|
+
enumerable: true,
|
|
2010
|
+
configurable: true,
|
|
2011
|
+
writable: true,
|
|
2012
|
+
value: /transaction type not valid/
|
|
2013
|
+
});
|
|
2014
|
+
|
|
2015
|
+
class TipAboveFeeCapError extends BaseError {
|
|
2016
|
+
constructor({ cause, maxPriorityFeePerGas, maxFeePerGas } = {}) {
|
|
2017
|
+
super([
|
|
2018
|
+
`The provided tip (\`maxPriorityFeePerGas\`${maxPriorityFeePerGas ? ` = ${formatGwei(maxPriorityFeePerGas)} gwei` : ""}) cannot be higher than the fee cap (\`maxFeePerGas\`${maxFeePerGas ? ` = ${formatGwei(maxFeePerGas)} gwei` : ""}).`
|
|
2019
|
+
].join(`
|
|
2020
|
+
`), {
|
|
2021
|
+
cause,
|
|
2022
|
+
name: "TipAboveFeeCapError"
|
|
2023
|
+
});
|
|
2024
|
+
}
|
|
2025
|
+
}
|
|
2026
|
+
Object.defineProperty(TipAboveFeeCapError, "nodeMessage", {
|
|
2027
|
+
enumerable: true,
|
|
2028
|
+
configurable: true,
|
|
2029
|
+
writable: true,
|
|
2030
|
+
value: /max priority fee per gas higher than max fee per gas|tip higher than fee cap/
|
|
2031
|
+
});
|
|
2032
|
+
|
|
2033
|
+
class UnknownNodeError extends BaseError {
|
|
2034
|
+
constructor({ cause }) {
|
|
2035
|
+
super(`An error occurred while executing: ${cause?.shortMessage}`, {
|
|
2036
|
+
cause,
|
|
2037
|
+
name: "UnknownNodeError"
|
|
2038
|
+
});
|
|
2039
|
+
}
|
|
2040
|
+
}
|
|
2041
|
+
|
|
2042
|
+
export { BaseError, InvalidBytesBooleanError, InvalidBytesLengthError, isHex, size, trim, toBytes2 as toBytes, hexToBytes, stringToBytes, assertSize, hexToBigInt, hexToBool, hexToNumber, toHex, bytesToHex, numberToHex, stringToHex, InvalidAddressError, LruMap, keccak_256, keccak256, checksumAddress, getAddress, isAddress, concat, concatHex, PositionOutOfBoundsError, createCursor, etherUnits, formatEther, formatGwei, prettyPrint, InvalidLegacyVError, InvalidSerializableTransactionError, InvalidStorageKeySizeError, TransactionExecutionError, TransactionNotFoundError, TransactionReceiptNotFoundError, TransactionReceiptRevertedError, WaitForTransactionReceiptTimeoutError, maxUint256, ChainDoesNotSupportContract, ChainMismatchError, ChainNotFoundError, ClientChainNotConfiguredError, InvalidChainIdError, ExecutionRevertedError, FeeCapTooHighError, FeeCapTooLowError, NonceTooHighError, NonceTooLowError, NonceMaxValueError, InsufficientFundsError, IntrinsicGasTooHighError, IntrinsicGasTooLowError, TransactionTypeNotSupportedError, TipAboveFeeCapError, UnknownNodeError, slice, sliceBytes, sliceHex, formatAbiItem, AbiConstructorNotFoundError, AbiConstructorParamsNotFoundError, AbiDecodingDataSizeTooSmallError, AbiDecodingZeroDataError, AbiErrorInputsNotFoundError, AbiErrorNotFoundError, AbiErrorSignatureNotFoundError, AbiEventSignatureEmptyTopicsError, AbiEventSignatureNotFoundError, AbiEventNotFoundError, AbiFunctionNotFoundError, AbiFunctionOutputsNotFoundError, AbiFunctionSignatureNotFoundError, AbiItemAmbiguityError, BytesSizeMismatchError, DecodeLogDataMismatch, DecodeLogTopicsMismatch, InvalidAbiDecodingTypeError, InvalidArrayError, bytesRegex, integerRegex, encodeAbiParameters, getArrayComponents, stringify };
|