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