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