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.
Files changed (90) hide show
  1. package/CHANGELOG.md +23 -1
  2. package/README.md +7 -1
  3. package/dist/Credential-COZQnr1-.js +2055 -0
  4. package/dist/Mcp-CrCEqLqO.js +10 -0
  5. package/dist/Sse-ChldYgU7.js +9742 -0
  6. package/dist/Sse-kCB38G56.js +16482 -0
  7. package/dist/accounts-DsuvWwph.js +232 -0
  8. package/dist/accounts-DzvAlQRn.js +5 -0
  9. package/dist/accounts-IG-Cmrwy.js +229 -0
  10. package/dist/api-CUzmQvTQ.js +2802 -0
  11. package/dist/auth-DTzQmnZ_.js +1196 -0
  12. package/dist/bin/cli.js +585 -242
  13. package/dist/ccip-Bx-zoUCJ.js +240 -0
  14. package/dist/ccip-C2k1DD1T.js +153 -0
  15. package/dist/ccip-C6CQOJYv.js +152 -0
  16. package/dist/ccip-RZzsZ5Mv.js +156 -0
  17. package/dist/chain-CafcHffR.js +1997 -0
  18. package/dist/chain-DwfP5RGZ.js +1968 -0
  19. package/dist/chunk-DBEY4PJZ.js +16 -0
  20. package/dist/chunk-DjEMn6fM.js +36 -0
  21. package/dist/client-Blw2V7LF.js +657 -0
  22. package/dist/client-C37gWJOZ.js +102 -0
  23. package/dist/client-CEc4NYAA.js +6388 -0
  24. package/dist/client-CVDTUY0l.js +5152 -0
  25. package/dist/config-BUQsit4s.js +3 -0
  26. package/dist/config-DR1Fs_wL.js +6600 -0
  27. package/dist/{config-D9wIR3xc.js → config-rvKA3SYT.js} +10 -5
  28. package/dist/decodeFunctionData-DuFcwhC_.js +4510 -0
  29. package/dist/decodeFunctionData-JPOUdvil.js +4394 -0
  30. package/dist/derive-DNUl8LU9.js +9109 -0
  31. package/dist/dist-C2YO6HSQ.js +6581 -0
  32. package/dist/dist-DM5_F3r5.js +4 -0
  33. package/dist/dist-DxJCYyL5.js +1388 -0
  34. package/dist/hashTypedData-BHmP9dBd.js +859 -0
  35. package/dist/hashTypedData-CtEdfx4y.js +846 -0
  36. package/dist/helpers-CuUSw-tH.js +7125 -0
  37. package/dist/hmac-59IlS_by.js +648 -0
  38. package/dist/http-BAtucMbS.js +2060 -0
  39. package/dist/index.d.ts +1903 -9
  40. package/dist/index.js +18006 -50
  41. package/dist/index.node-CxkL0OFh.js +3592 -0
  42. package/dist/index.node-DvmeuZBj.js +3 -0
  43. package/dist/isAddressEqual-BLrd1Hg1.js +9 -0
  44. package/dist/isAddressEqual-DsAqfQOD.js +10 -0
  45. package/dist/localBatchGatewayRequest-C-RPJyDO.js +6260 -0
  46. package/dist/localBatchGatewayRequest-DOdQ9bR7.js +93 -0
  47. package/dist/localBatchGatewayRequest-DQkbZaSy.js +6261 -0
  48. package/dist/parseUnits-CApwcKSD.js +49 -0
  49. package/dist/parseUnits-cMO2udMe.js +48 -0
  50. package/dist/schemas-BxMFYNbH.js +1270 -0
  51. package/dist/secp256k1-BZpiyffY.js +2525 -0
  52. package/dist/secp256k1-BjenrLl5.js +1877 -0
  53. package/dist/secp256k1-CLPUX17u.js +3 -0
  54. package/dist/sendRawTransactionSync-DvSkhZtW.js +3612 -0
  55. package/dist/server-CSq0IuUq.js +565 -0
  56. package/dist/setup-BY4J49Lv.js +1110 -0
  57. package/dist/setup-wMOAgrsN.js +3 -0
  58. package/dist/sha256-FAs0qeni.js +17 -0
  59. package/dist/sha3-CYkWM8Xa.js +195 -0
  60. package/dist/sha3-DbMJRJ3C.js +194 -0
  61. package/dist/sse-B4LLqBQm.js +408 -0
  62. package/dist/status-Bu23RjW6.js +3 -0
  63. package/dist/{status-DihAcUSC.js → status-X21VnGUO.js} +16 -15
  64. package/dist/stdio-BADqxZdZ.js +85 -0
  65. package/dist/streamableHttp-BHkJypcI.js +358 -0
  66. package/dist/tempo-3nttrxgQ.js +17 -0
  67. package/dist/tempo-DER0P-ul.js +18 -0
  68. package/dist/types-BEKUz-Mf.js +1240 -0
  69. package/dist/types-DatK5vR5.js +3 -0
  70. package/dist/utils-BYjkXZDF.js +444 -0
  71. package/dist/utils-SeGHMW9O.js +445 -0
  72. package/dist/wallet-DKVlrR1S.js +3 -0
  73. package/dist/wallet-DSyht15_.js +17759 -0
  74. package/package.json +18 -71
  75. package/dist/config-B_upkJeK.js +0 -66
  76. package/dist/config-Be35NM5s.js +0 -3
  77. package/dist/config-J1m-CWXT.js +0 -27
  78. package/dist/derive-CL6e8K0Z.js +0 -81
  79. package/dist/openclaw/plugin.d.ts +0 -15
  80. package/dist/openclaw/plugin.js +0 -2067
  81. package/dist/openclaw.plugin.json +0 -93
  82. package/dist/setup-CNyMLnM-.js +0 -197
  83. package/dist/setup-DTIxPe58.js +0 -3
  84. package/dist/status-DZlJ4pS7.js +0 -3
  85. package/dist/wallet-B0S-rma9.js +0 -544
  86. package/dist/wallet-DBrVZJqe.js +0 -3
  87. package/openclaw.plugin.json +0 -93
  88. package/skills/SKILL.md +0 -183
  89. package/skills/references/library.md +0 -85
  90. package/skills/references/openclaw-plugin.md +0 -145
@@ -0,0 +1,2060 @@
1
+ #!/usr/bin/env node
2
+ import { At as UnknownRpcError, Bt as ContractFunctionExecutionError, C as concat, Ct as ProviderDisconnectedError, D as fromNumber, Dt as TransactionRejectedRpcError, Et as SwitchChainError, Ft as WalletConnectSessionSettlementError, I as toNumber, It as HttpRequestError, Jt as encodeFunctionData, Kt as decodeAbiParameters, Lt as RpcRequestError, Mt as UnsupportedNonOptionalCapabilityError, N as slice, Nt as UnsupportedProviderMethodError, Ot as UnauthorizedProviderError, Pt as UserRejectedRequestError, Rt as TimeoutError, St as ParseRpcError, Tt as ResourceUnavailableRpcError, Ut as RawContractError, Yt as getAbiItem, Zt as toEventSelector, _t as InvalidRequestRpcError, bt as MethodNotFoundRpcError, dt as BundleTooLargeError, et as BaseError, ft as ChainDisconnectedError, gt as InvalidParamsRpcError, h as multicall3Abi, ht as InvalidInputRpcError, jt as UnsupportedChainIdError, kt as UnknownBundleIdError, l as erc6492SignatureValidatorByteCode, lt as AtomicReadyWalletRejectedUpgradeError, m as erc6492SignatureValidatorAbi, mt as InternalRpcError, n as call, o as getChainContractAddress, p as erc1271Abi, pt as DuplicateIdError, r as createBatchScheduler, s as encodeDeployData, tt as decodeFunctionResult, u as multicall3Bytecode, ut as AtomicityNotSupportedError, vt as JsonRpcVersionUnsupportedError, wt as ResourceNotFoundRpcError, xt as MethodNotSupportedRpcError, yt as LimitExceededRpcError, zt as CallExecutionError } from "./decodeFunctionData-DuFcwhC_.js";
3
+ import { $ as recoverAuthorizationAddress, F as readContract, I as formatLog, M as formatTransactionReceipt, _ as decode, a as assert$2, et as recoverAddress, f as toRpc$1, nt as getAction, o as extract, tt as getContractError, v as encode, y as from$1 } from "./sendRawTransactionSync-DvSkhZtW.js";
4
+ import { $ as toBytes, E as TransactionReceiptNotFoundError, F as parseAccount, Ft as formatAbiItem, I as encodeAbiParameters, J as LruMap, M as stringify, Mt as BaseError$1, Nt as size$1, Ot as DecodeLogDataMismatch, P as PositionOutOfBoundsError, Pt as isHex, St as AbiEventSignatureNotFoundError, W as concatHex, X as keccak256, bt as AbiEventNotFoundError, et as bytesToHex, gt as AbiDecodingZeroDataError, ht as AbiDecodingDataSizeTooSmallError, kt as DecodeLogTopicsMismatch, nt as stringToHex, ot as hexToBool, q as getAddress, tt as numberToHex, xt as AbiEventSignatureEmptyTopicsError } from "./chain-CafcHffR.js";
5
+ import { t as isAddressEqual } from "./isAddressEqual-DsAqfQOD.js";
6
+ import { c as serializeSignature } from "./accounts-IG-Cmrwy.js";
7
+ //#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/errors/log.js
8
+ var FilterTypeNotSupportedError = class extends BaseError$1 {
9
+ constructor(type) {
10
+ super(`Filter type "${type}" is not supported.`, { name: "FilterTypeNotSupportedError" });
11
+ }
12
+ };
13
+ //#endregion
14
+ //#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/utils/abi/encodeEventTopics.js
15
+ const docsPath$1 = "/docs/contract/encodeEventTopics";
16
+ function encodeEventTopics(parameters) {
17
+ const { abi, eventName, args } = parameters;
18
+ let abiItem = abi[0];
19
+ if (eventName) {
20
+ const item = getAbiItem({
21
+ abi,
22
+ name: eventName
23
+ });
24
+ if (!item) throw new AbiEventNotFoundError(eventName, { docsPath: docsPath$1 });
25
+ abiItem = item;
26
+ }
27
+ if (abiItem.type !== "event") throw new AbiEventNotFoundError(void 0, { docsPath: docsPath$1 });
28
+ const signature = toEventSelector(formatAbiItem(abiItem));
29
+ let topics = [];
30
+ if (args && "inputs" in abiItem) {
31
+ const indexedInputs = abiItem.inputs?.filter((param) => "indexed" in param && param.indexed);
32
+ const args_ = Array.isArray(args) ? args : Object.values(args).length > 0 ? indexedInputs?.map((x) => args[x.name]) ?? [] : [];
33
+ if (args_.length > 0) topics = indexedInputs?.map((param, i) => {
34
+ if (Array.isArray(args_[i])) return args_[i].map((_, j) => encodeArg({
35
+ param,
36
+ value: args_[i][j]
37
+ }));
38
+ return typeof args_[i] !== "undefined" && args_[i] !== null ? encodeArg({
39
+ param,
40
+ value: args_[i]
41
+ }) : null;
42
+ }) ?? [];
43
+ }
44
+ return [signature, ...topics];
45
+ }
46
+ function encodeArg({ param, value }) {
47
+ if (param.type === "string" || param.type === "bytes") return keccak256(toBytes(value));
48
+ if (param.type === "tuple" || param.type.match(/^(.*)\[(\d+)?\]$/)) throw new FilterTypeNotSupportedError(param.type);
49
+ return encodeAbiParameters([param], [value]);
50
+ }
51
+ //#endregion
52
+ //#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/utils/filters/createFilterRequestScope.js
53
+ /**
54
+ * Scopes `request` to the filter ID. If the client is a fallback, it will
55
+ * listen for responses and scope the child transport `request` function
56
+ * to the successful filter ID.
57
+ */
58
+ function createFilterRequestScope(client, { method }) {
59
+ const requestMap = {};
60
+ if (client.transport.type === "fallback") client.transport.onResponse?.(({ method: method_, response: id, status, transport }) => {
61
+ if (status === "success" && method === method_) requestMap[id] = transport.request;
62
+ });
63
+ return ((id) => requestMap[id] || client.request);
64
+ }
65
+ //#endregion
66
+ //#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/actions/public/createContractEventFilter.js
67
+ /**
68
+ * Creates a Filter to retrieve event logs that can be used with [`getFilterChanges`](https://viem.sh/docs/actions/public/getFilterChanges) or [`getFilterLogs`](https://viem.sh/docs/actions/public/getFilterLogs).
69
+ *
70
+ * - Docs: https://viem.sh/docs/contract/createContractEventFilter
71
+ *
72
+ * @param client - Client to use
73
+ * @param parameters - {@link CreateContractEventFilterParameters}
74
+ * @returns [`Filter`](https://viem.sh/docs/glossary/types#filter). {@link CreateContractEventFilterReturnType}
75
+ *
76
+ * @example
77
+ * import { createPublicClient, http, parseAbi } from 'viem'
78
+ * import { mainnet } from 'viem/chains'
79
+ * import { createContractEventFilter } from 'viem/contract'
80
+ *
81
+ * const client = createPublicClient({
82
+ * chain: mainnet,
83
+ * transport: http(),
84
+ * })
85
+ * const filter = await createContractEventFilter(client, {
86
+ * abi: parseAbi(['event Transfer(address indexed, address indexed, uint256)']),
87
+ * })
88
+ */
89
+ async function createContractEventFilter(client, parameters) {
90
+ const { address, abi, args, eventName, fromBlock, strict, toBlock } = parameters;
91
+ const getRequest = createFilterRequestScope(client, { method: "eth_newFilter" });
92
+ const topics = eventName ? encodeEventTopics({
93
+ abi,
94
+ args,
95
+ eventName
96
+ }) : void 0;
97
+ const id = await client.request({
98
+ method: "eth_newFilter",
99
+ params: [{
100
+ address,
101
+ fromBlock: typeof fromBlock === "bigint" ? numberToHex(fromBlock) : fromBlock,
102
+ toBlock: typeof toBlock === "bigint" ? numberToHex(toBlock) : toBlock,
103
+ topics
104
+ }]
105
+ });
106
+ return {
107
+ abi,
108
+ args,
109
+ eventName,
110
+ id,
111
+ request: getRequest(id),
112
+ strict: Boolean(strict),
113
+ type: "event"
114
+ };
115
+ }
116
+ //#endregion
117
+ //#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/utils/abi/decodeEventLog.js
118
+ const docsPath = "/docs/contract/decodeEventLog";
119
+ function decodeEventLog(parameters) {
120
+ const { abi, data, strict: strict_, topics } = parameters;
121
+ const strict = strict_ ?? true;
122
+ const [signature, ...argTopics] = topics;
123
+ if (!signature) throw new AbiEventSignatureEmptyTopicsError({ docsPath });
124
+ const abiItem = abi.find((x) => x.type === "event" && signature === toEventSelector(formatAbiItem(x)));
125
+ if (!(abiItem && "name" in abiItem) || abiItem.type !== "event") throw new AbiEventSignatureNotFoundError(signature, { docsPath });
126
+ const { name, inputs } = abiItem;
127
+ const isUnnamed = inputs?.some((x) => !("name" in x && x.name));
128
+ const args = isUnnamed ? [] : {};
129
+ const indexedInputs = inputs.map((x, i) => [x, i]).filter(([x]) => "indexed" in x && x.indexed);
130
+ const missingIndexedInputs = [];
131
+ for (let i = 0; i < indexedInputs.length; i++) {
132
+ const [param, argIndex] = indexedInputs[i];
133
+ const topic = argTopics[i];
134
+ if (!topic) {
135
+ if (strict) throw new DecodeLogTopicsMismatch({
136
+ abiItem,
137
+ param
138
+ });
139
+ missingIndexedInputs.push([param, argIndex]);
140
+ continue;
141
+ }
142
+ args[isUnnamed ? argIndex : param.name || argIndex] = decodeTopic({
143
+ param,
144
+ value: topic
145
+ });
146
+ }
147
+ const nonIndexedInputs = inputs.filter((x) => !("indexed" in x && x.indexed));
148
+ const inputsToDecode = strict ? nonIndexedInputs : [...missingIndexedInputs.map(([param]) => param), ...nonIndexedInputs];
149
+ if (inputsToDecode.length > 0) {
150
+ if (data && data !== "0x") try {
151
+ const decodedData = decodeAbiParameters(inputsToDecode, data);
152
+ if (decodedData) {
153
+ let dataIndex = 0;
154
+ if (!strict) for (const [param, argIndex] of missingIndexedInputs) args[isUnnamed ? argIndex : param.name || argIndex] = decodedData[dataIndex++];
155
+ if (isUnnamed) {
156
+ for (let i = 0; i < inputs.length; i++) if (args[i] === void 0 && dataIndex < decodedData.length) args[i] = decodedData[dataIndex++];
157
+ } else for (let i = 0; i < nonIndexedInputs.length; i++) args[nonIndexedInputs[i].name] = decodedData[dataIndex++];
158
+ }
159
+ } catch (err) {
160
+ if (strict) {
161
+ if (err instanceof AbiDecodingDataSizeTooSmallError || err instanceof PositionOutOfBoundsError) throw new DecodeLogDataMismatch({
162
+ abiItem,
163
+ data,
164
+ params: inputsToDecode,
165
+ size: size$1(data)
166
+ });
167
+ throw err;
168
+ }
169
+ }
170
+ else if (strict) throw new DecodeLogDataMismatch({
171
+ abiItem,
172
+ data: "0x",
173
+ params: inputsToDecode,
174
+ size: 0
175
+ });
176
+ }
177
+ return {
178
+ eventName: name,
179
+ args: Object.values(args).length > 0 ? args : void 0
180
+ };
181
+ }
182
+ function decodeTopic({ param, value }) {
183
+ if (param.type === "string" || param.type === "bytes" || param.type === "tuple" || param.type.match(/^(.*)\[(\d+)?\]$/)) return value;
184
+ return (decodeAbiParameters([param], value) || [])[0];
185
+ }
186
+ //#endregion
187
+ //#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/utils/abi/parseEventLogs.js
188
+ /**
189
+ * Extracts & decodes logs matching the provided signature(s) (`abi` + optional `eventName`)
190
+ * from a set of opaque logs.
191
+ *
192
+ * @param parameters - {@link ParseEventLogsParameters}
193
+ * @returns The logs. {@link ParseEventLogsReturnType}
194
+ *
195
+ * @example
196
+ * import { createClient, http } from 'viem'
197
+ * import { mainnet } from 'viem/chains'
198
+ * import { parseEventLogs } from 'viem/op-stack'
199
+ *
200
+ * const client = createClient({
201
+ * chain: mainnet,
202
+ * transport: http(),
203
+ * })
204
+ *
205
+ * const receipt = await getTransactionReceipt(client, {
206
+ * hash: '0xec23b2ba4bc59ba61554507c1b1bc91649e6586eb2dd00c728e8ed0db8bb37ea',
207
+ * })
208
+ *
209
+ * const logs = parseEventLogs({ logs: receipt.logs })
210
+ * // [{ args: { ... }, eventName: 'TransactionDeposited', ... }, ...]
211
+ */
212
+ function parseEventLogs(parameters) {
213
+ const { abi, args, logs, strict = true } = parameters;
214
+ const eventName = (() => {
215
+ if (!parameters.eventName) return void 0;
216
+ if (Array.isArray(parameters.eventName)) return parameters.eventName;
217
+ return [parameters.eventName];
218
+ })();
219
+ const abiTopics = abi.filter((abiItem) => abiItem.type === "event").map((abiItem) => ({
220
+ abi: abiItem,
221
+ selector: toEventSelector(abiItem)
222
+ }));
223
+ return logs.map((log) => {
224
+ const formattedLog = typeof log.blockNumber === "string" ? formatLog(log) : log;
225
+ const abiItems = abiTopics.filter((abiTopic) => formattedLog.topics[0] === abiTopic.selector);
226
+ if (abiItems.length === 0) return null;
227
+ let event;
228
+ let abiItem;
229
+ for (const item of abiItems) try {
230
+ event = decodeEventLog({
231
+ ...formattedLog,
232
+ abi: [item.abi],
233
+ strict: true
234
+ });
235
+ abiItem = item;
236
+ break;
237
+ } catch {}
238
+ if (!event && !strict) {
239
+ abiItem = abiItems[0];
240
+ try {
241
+ event = decodeEventLog({
242
+ data: formattedLog.data,
243
+ topics: formattedLog.topics,
244
+ abi: [abiItem.abi],
245
+ strict: false
246
+ });
247
+ } catch {
248
+ const isUnnamed = abiItem.abi.inputs?.some((x) => !("name" in x && x.name));
249
+ return {
250
+ ...formattedLog,
251
+ args: isUnnamed ? [] : {},
252
+ eventName: abiItem.abi.name
253
+ };
254
+ }
255
+ }
256
+ if (!event || !abiItem) return null;
257
+ if (eventName && !eventName.includes(event.eventName)) return null;
258
+ if (!includesArgs({
259
+ args: event.args,
260
+ inputs: abiItem.abi.inputs,
261
+ matchArgs: args
262
+ })) return null;
263
+ return {
264
+ ...event,
265
+ ...formattedLog
266
+ };
267
+ }).filter(Boolean);
268
+ }
269
+ function includesArgs(parameters) {
270
+ const { args, inputs, matchArgs } = parameters;
271
+ if (!matchArgs) return true;
272
+ if (!args) return false;
273
+ function isEqual(input, value, arg) {
274
+ try {
275
+ if (input.type === "address") return isAddressEqual(value, arg);
276
+ if (input.type === "string" || input.type === "bytes") return keccak256(toBytes(value)) === arg;
277
+ return value === arg;
278
+ } catch {
279
+ return false;
280
+ }
281
+ }
282
+ if (Array.isArray(args) && Array.isArray(matchArgs)) return matchArgs.every((value, index) => {
283
+ if (value === null || value === void 0) return true;
284
+ const input = inputs[index];
285
+ if (!input) return false;
286
+ return (Array.isArray(value) ? value : [value]).some((value) => isEqual(input, value, args[index]));
287
+ });
288
+ if (typeof args === "object" && !Array.isArray(args) && typeof matchArgs === "object" && !Array.isArray(matchArgs)) return Object.entries(matchArgs).every(([key, value]) => {
289
+ if (value === null || value === void 0) return true;
290
+ const input = inputs.find((input) => input.name === key);
291
+ if (!input) return false;
292
+ return (Array.isArray(value) ? value : [value]).some((value) => isEqual(input, value, args[key]));
293
+ });
294
+ return false;
295
+ }
296
+ //#endregion
297
+ //#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/actions/public/getLogs.js
298
+ /**
299
+ * Returns a list of event logs matching the provided parameters.
300
+ *
301
+ * - Docs: https://viem.sh/docs/actions/public/getLogs
302
+ * - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/logs_event-logs
303
+ * - JSON-RPC Methods: [`eth_getLogs`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getlogs)
304
+ *
305
+ * @param client - Client to use
306
+ * @param parameters - {@link GetLogsParameters}
307
+ * @returns A list of event logs. {@link GetLogsReturnType}
308
+ *
309
+ * @example
310
+ * import { createPublicClient, http, parseAbiItem } from 'viem'
311
+ * import { mainnet } from 'viem/chains'
312
+ * import { getLogs } from 'viem/public'
313
+ *
314
+ * const client = createPublicClient({
315
+ * chain: mainnet,
316
+ * transport: http(),
317
+ * })
318
+ * const logs = await getLogs(client)
319
+ */
320
+ async function getLogs(client, { address, blockHash, fromBlock, toBlock, event, events: events_, args, strict: strict_ } = {}) {
321
+ const strict = strict_ ?? false;
322
+ const events = events_ ?? (event ? [event] : void 0);
323
+ let topics = [];
324
+ if (events) {
325
+ topics = [events.flatMap((event) => encodeEventTopics({
326
+ abi: [event],
327
+ eventName: event.name,
328
+ args: events_ ? void 0 : args
329
+ }))];
330
+ if (event) topics = topics[0];
331
+ }
332
+ let logs;
333
+ if (blockHash) logs = await client.request({
334
+ method: "eth_getLogs",
335
+ params: [{
336
+ address,
337
+ topics,
338
+ blockHash
339
+ }]
340
+ });
341
+ else logs = await client.request({
342
+ method: "eth_getLogs",
343
+ params: [{
344
+ address,
345
+ topics,
346
+ fromBlock: typeof fromBlock === "bigint" ? numberToHex(fromBlock) : fromBlock,
347
+ toBlock: typeof toBlock === "bigint" ? numberToHex(toBlock) : toBlock
348
+ }]
349
+ });
350
+ const formattedLogs = logs.map((log) => formatLog(log));
351
+ if (!events) return formattedLogs;
352
+ return parseEventLogs({
353
+ abi: events,
354
+ args,
355
+ logs: formattedLogs,
356
+ strict
357
+ });
358
+ }
359
+ //#endregion
360
+ //#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/actions/public/getContractEvents.js
361
+ /**
362
+ * Returns a list of event logs emitted by a contract.
363
+ *
364
+ * - Docs: https://viem.sh/docs/contract/getContractEvents#getcontractevents
365
+ * - JSON-RPC Methods: [`eth_getLogs`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getlogs)
366
+ *
367
+ * @param client - Client to use
368
+ * @param parameters - {@link GetContractEventsParameters}
369
+ * @returns A list of event logs. {@link GetContractEventsReturnType}
370
+ *
371
+ * @example
372
+ * import { createClient, http } from 'viem'
373
+ * import { mainnet } from 'viem/chains'
374
+ * import { getContractEvents } from 'viem/public'
375
+ * import { wagmiAbi } from './abi'
376
+ *
377
+ * const client = createClient({
378
+ * chain: mainnet,
379
+ * transport: http(),
380
+ * })
381
+ * const logs = await getContractEvents(client, {
382
+ * address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
383
+ * abi: wagmiAbi,
384
+ * eventName: 'Transfer'
385
+ * })
386
+ */
387
+ async function getContractEvents(client, parameters) {
388
+ const { abi, address, args, blockHash, eventName, fromBlock, toBlock, strict } = parameters;
389
+ const event = eventName ? getAbiItem({
390
+ abi,
391
+ name: eventName
392
+ }) : void 0;
393
+ const events = !event ? abi.filter((x) => x.type === "event") : void 0;
394
+ return getAction(client, getLogs, "getLogs")({
395
+ address,
396
+ args,
397
+ blockHash,
398
+ event,
399
+ events,
400
+ fromBlock,
401
+ toBlock,
402
+ strict
403
+ });
404
+ }
405
+ //#endregion
406
+ //#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/utils/observe.js
407
+ /** @internal */
408
+ const listenersCache = /* @__PURE__ */ new Map();
409
+ /** @internal */
410
+ const cleanupCache = /* @__PURE__ */ new Map();
411
+ let callbackCount = 0;
412
+ /**
413
+ * @description Sets up an observer for a given function. If another function
414
+ * is set up under the same observer id, the function will only be called once
415
+ * for both instances of the observer.
416
+ */
417
+ function observe(observerId, callbacks, fn) {
418
+ const callbackId = ++callbackCount;
419
+ const getListeners = () => listenersCache.get(observerId) || [];
420
+ const unsubscribe = () => {
421
+ const listeners = getListeners();
422
+ listenersCache.set(observerId, listeners.filter((cb) => cb.id !== callbackId));
423
+ };
424
+ const unwatch = () => {
425
+ const listeners = getListeners();
426
+ if (!listeners.some((cb) => cb.id === callbackId)) return;
427
+ const cleanup = cleanupCache.get(observerId);
428
+ if (listeners.length === 1 && cleanup) {
429
+ const p = cleanup();
430
+ if (p instanceof Promise) p.catch(() => {});
431
+ }
432
+ unsubscribe();
433
+ };
434
+ const listeners = getListeners();
435
+ listenersCache.set(observerId, [...listeners, {
436
+ id: callbackId,
437
+ fns: callbacks
438
+ }]);
439
+ if (listeners && listeners.length > 0) return unwatch;
440
+ const emit = {};
441
+ for (const key in callbacks) emit[key] = ((...args) => {
442
+ const listeners = getListeners();
443
+ if (listeners.length === 0) return;
444
+ for (const listener of listeners) listener.fns[key]?.(...args);
445
+ });
446
+ const cleanup = fn(emit);
447
+ if (typeof cleanup === "function") cleanupCache.set(observerId, cleanup);
448
+ return unwatch;
449
+ }
450
+ //#endregion
451
+ //#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/utils/wait.js
452
+ async function wait(time) {
453
+ return new Promise((res) => setTimeout(res, time));
454
+ }
455
+ //#endregion
456
+ //#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/utils/poll.js
457
+ /**
458
+ * @description Polls a function at a specified interval.
459
+ */
460
+ function poll(fn, { emitOnBegin, initialWaitTime, interval }) {
461
+ let active = true;
462
+ const unwatch = () => active = false;
463
+ const watch = async () => {
464
+ let data;
465
+ if (emitOnBegin) data = await fn({ unpoll: unwatch });
466
+ await wait(await initialWaitTime?.(data) ?? interval);
467
+ const poll = async () => {
468
+ if (!active) return;
469
+ await fn({ unpoll: unwatch });
470
+ await wait(interval);
471
+ poll();
472
+ };
473
+ poll();
474
+ };
475
+ watch();
476
+ return unwatch;
477
+ }
478
+ //#endregion
479
+ //#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/utils/promise/withCache.js
480
+ /** @internal */
481
+ const promiseCache$1 = /* @__PURE__ */ new Map();
482
+ /** @internal */
483
+ const responseCache = /* @__PURE__ */ new Map();
484
+ function getCache(cacheKey) {
485
+ const buildCache = (cacheKey, cache) => ({
486
+ clear: () => cache.delete(cacheKey),
487
+ get: () => cache.get(cacheKey),
488
+ set: (data) => cache.set(cacheKey, data)
489
+ });
490
+ const promise = buildCache(cacheKey, promiseCache$1);
491
+ const response = buildCache(cacheKey, responseCache);
492
+ return {
493
+ clear: () => {
494
+ promise.clear();
495
+ response.clear();
496
+ },
497
+ promise,
498
+ response
499
+ };
500
+ }
501
+ /**
502
+ * @description Returns the result of a given promise, and caches the result for
503
+ * subsequent invocations against a provided cache key.
504
+ */
505
+ async function withCache(fn, { cacheKey, cacheTime = Number.POSITIVE_INFINITY }) {
506
+ const cache = getCache(cacheKey);
507
+ const response = cache.response.get();
508
+ if (response && cacheTime > 0) {
509
+ if (Date.now() - response.created.getTime() < cacheTime) return response.data;
510
+ }
511
+ let promise = cache.promise.get();
512
+ if (!promise) {
513
+ promise = fn();
514
+ cache.promise.set(promise);
515
+ }
516
+ try {
517
+ const data = await promise;
518
+ cache.response.set({
519
+ created: /* @__PURE__ */ new Date(),
520
+ data
521
+ });
522
+ return data;
523
+ } finally {
524
+ cache.promise.clear();
525
+ }
526
+ }
527
+ //#endregion
528
+ //#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/actions/public/getBlockNumber.js
529
+ const cacheKey = (id) => `blockNumber.${id}`;
530
+ /**
531
+ * Returns the number of the most recent block seen.
532
+ *
533
+ * - Docs: https://viem.sh/docs/actions/public/getBlockNumber
534
+ * - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/blocks_fetching-blocks
535
+ * - JSON-RPC Methods: [`eth_blockNumber`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_blocknumber)
536
+ *
537
+ * @param client - Client to use
538
+ * @param parameters - {@link GetBlockNumberParameters}
539
+ * @returns The number of the block. {@link GetBlockNumberReturnType}
540
+ *
541
+ * @example
542
+ * import { createPublicClient, http } from 'viem'
543
+ * import { mainnet } from 'viem/chains'
544
+ * import { getBlockNumber } from 'viem/public'
545
+ *
546
+ * const client = createPublicClient({
547
+ * chain: mainnet,
548
+ * transport: http(),
549
+ * })
550
+ * const blockNumber = await getBlockNumber(client)
551
+ * // 69420n
552
+ */
553
+ async function getBlockNumber(client, { cacheTime = client.cacheTime } = {}) {
554
+ const blockNumberHex = await withCache(() => client.request({ method: "eth_blockNumber" }), {
555
+ cacheKey: cacheKey(client.uid),
556
+ cacheTime
557
+ });
558
+ return BigInt(blockNumberHex);
559
+ }
560
+ //#endregion
561
+ //#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/actions/public/getFilterChanges.js
562
+ /**
563
+ * Returns a list of logs or hashes based on a [Filter](/docs/glossary/terms#filter) since the last time it was called.
564
+ *
565
+ * - Docs: https://viem.sh/docs/actions/public/getFilterChanges
566
+ * - JSON-RPC Methods: [`eth_getFilterChanges`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getfilterchanges)
567
+ *
568
+ * A Filter can be created from the following actions:
569
+ *
570
+ * - [`createBlockFilter`](https://viem.sh/docs/actions/public/createBlockFilter)
571
+ * - [`createContractEventFilter`](https://viem.sh/docs/contract/createContractEventFilter)
572
+ * - [`createEventFilter`](https://viem.sh/docs/actions/public/createEventFilter)
573
+ * - [`createPendingTransactionFilter`](https://viem.sh/docs/actions/public/createPendingTransactionFilter)
574
+ *
575
+ * Depending on the type of filter, the return value will be different:
576
+ *
577
+ * - If the filter was created with `createContractEventFilter` or `createEventFilter`, it returns a list of logs.
578
+ * - If the filter was created with `createPendingTransactionFilter`, it returns a list of transaction hashes.
579
+ * - If the filter was created with `createBlockFilter`, it returns a list of block hashes.
580
+ *
581
+ * @param client - Client to use
582
+ * @param parameters - {@link GetFilterChangesParameters}
583
+ * @returns Logs or hashes. {@link GetFilterChangesReturnType}
584
+ *
585
+ * @example
586
+ * // Blocks
587
+ * import { createPublicClient, http } from 'viem'
588
+ * import { mainnet } from 'viem/chains'
589
+ * import { createBlockFilter, getFilterChanges } from 'viem/public'
590
+ *
591
+ * const client = createPublicClient({
592
+ * chain: mainnet,
593
+ * transport: http(),
594
+ * })
595
+ * const filter = await createBlockFilter(client)
596
+ * const hashes = await getFilterChanges(client, { filter })
597
+ *
598
+ * @example
599
+ * // Contract Events
600
+ * import { createPublicClient, http, parseAbi } from 'viem'
601
+ * import { mainnet } from 'viem/chains'
602
+ * import { createContractEventFilter, getFilterChanges } from 'viem/public'
603
+ *
604
+ * const client = createPublicClient({
605
+ * chain: mainnet,
606
+ * transport: http(),
607
+ * })
608
+ * const filter = await createContractEventFilter(client, {
609
+ * address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
610
+ * abi: parseAbi(['event Transfer(address indexed, address indexed, uint256)']),
611
+ * eventName: 'Transfer',
612
+ * })
613
+ * const logs = await getFilterChanges(client, { filter })
614
+ *
615
+ * @example
616
+ * // Raw Events
617
+ * import { createPublicClient, http, parseAbiItem } from 'viem'
618
+ * import { mainnet } from 'viem/chains'
619
+ * import { createEventFilter, getFilterChanges } from 'viem/public'
620
+ *
621
+ * const client = createPublicClient({
622
+ * chain: mainnet,
623
+ * transport: http(),
624
+ * })
625
+ * const filter = await createEventFilter(client, {
626
+ * address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
627
+ * event: parseAbiItem('event Transfer(address indexed, address indexed, uint256)'),
628
+ * })
629
+ * const logs = await getFilterChanges(client, { filter })
630
+ *
631
+ * @example
632
+ * // Transactions
633
+ * import { createPublicClient, http } from 'viem'
634
+ * import { mainnet } from 'viem/chains'
635
+ * import { createPendingTransactionFilter, getFilterChanges } from 'viem/public'
636
+ *
637
+ * const client = createPublicClient({
638
+ * chain: mainnet,
639
+ * transport: http(),
640
+ * })
641
+ * const filter = await createPendingTransactionFilter(client)
642
+ * const hashes = await getFilterChanges(client, { filter })
643
+ */
644
+ async function getFilterChanges(_client, { filter }) {
645
+ const strict = "strict" in filter && filter.strict;
646
+ const logs = await filter.request({
647
+ method: "eth_getFilterChanges",
648
+ params: [filter.id]
649
+ });
650
+ if (typeof logs[0] === "string") return logs;
651
+ const formattedLogs = logs.map((log) => formatLog(log));
652
+ if (!("abi" in filter) || !filter.abi) return formattedLogs;
653
+ return parseEventLogs({
654
+ abi: filter.abi,
655
+ logs: formattedLogs,
656
+ strict
657
+ });
658
+ }
659
+ //#endregion
660
+ //#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/actions/public/uninstallFilter.js
661
+ /**
662
+ * Destroys a [`Filter`](https://viem.sh/docs/glossary/types#filter).
663
+ *
664
+ * - Docs: https://viem.sh/docs/actions/public/uninstallFilter
665
+ * - JSON-RPC Methods: [`eth_uninstallFilter`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_uninstallFilter)
666
+ *
667
+ * Destroys a Filter that was created from one of the following Actions:
668
+ * - [`createBlockFilter`](https://viem.sh/docs/actions/public/createBlockFilter)
669
+ * - [`createEventFilter`](https://viem.sh/docs/actions/public/createEventFilter)
670
+ * - [`createPendingTransactionFilter`](https://viem.sh/docs/actions/public/createPendingTransactionFilter)
671
+ *
672
+ * @param client - Client to use
673
+ * @param parameters - {@link UninstallFilterParameters}
674
+ * @returns A boolean indicating if the Filter was successfully uninstalled. {@link UninstallFilterReturnType}
675
+ *
676
+ * @example
677
+ * import { createPublicClient, http } from 'viem'
678
+ * import { mainnet } from 'viem/chains'
679
+ * import { createPendingTransactionFilter, uninstallFilter } from 'viem/public'
680
+ *
681
+ * const filter = await createPendingTransactionFilter(client)
682
+ * const uninstalled = await uninstallFilter(client, { filter })
683
+ * // true
684
+ */
685
+ async function uninstallFilter(_client, { filter }) {
686
+ return filter.request({
687
+ method: "eth_uninstallFilter",
688
+ params: [filter.id]
689
+ });
690
+ }
691
+ //#endregion
692
+ //#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/actions/public/watchContractEvent.js
693
+ /**
694
+ * Watches and returns emitted contract event logs.
695
+ *
696
+ * - Docs: https://viem.sh/docs/contract/watchContractEvent
697
+ *
698
+ * This Action will batch up all the event logs found within the [`pollingInterval`](https://viem.sh/docs/contract/watchContractEvent#pollinginterval-optional), and invoke them via [`onLogs`](https://viem.sh/docs/contract/watchContractEvent#onLogs).
699
+ *
700
+ * `watchContractEvent` will attempt to create an [Event Filter](https://viem.sh/docs/contract/createContractEventFilter) and listen to changes to the Filter per polling interval, however, if the RPC Provider does not support Filters (e.g. `eth_newFilter`), then `watchContractEvent` will fall back to using [`getLogs`](https://viem.sh/docs/actions/public/getLogs) instead.
701
+ *
702
+ * @param client - Client to use
703
+ * @param parameters - {@link WatchContractEventParameters}
704
+ * @returns A function that can be invoked to stop watching for new event logs. {@link WatchContractEventReturnType}
705
+ *
706
+ * @example
707
+ * import { createPublicClient, http, parseAbi } from 'viem'
708
+ * import { mainnet } from 'viem/chains'
709
+ * import { watchContractEvent } from 'viem/contract'
710
+ *
711
+ * const client = createPublicClient({
712
+ * chain: mainnet,
713
+ * transport: http(),
714
+ * })
715
+ * const unwatch = watchContractEvent(client, {
716
+ * address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
717
+ * abi: parseAbi(['event Transfer(address indexed from, address indexed to, uint256 value)']),
718
+ * eventName: 'Transfer',
719
+ * args: { from: '0xc961145a54C96E3aE9bAA048c4F4D6b04C13916b' },
720
+ * onLogs: (logs) => console.log(logs),
721
+ * })
722
+ */
723
+ function watchContractEvent(client, parameters) {
724
+ const { abi, address, args, batch = true, eventName, fromBlock, onError, onLogs, poll: poll_, pollingInterval = client.pollingInterval, strict: strict_ } = parameters;
725
+ const enablePolling = (() => {
726
+ if (typeof poll_ !== "undefined") return poll_;
727
+ if (typeof fromBlock === "bigint") return true;
728
+ if (client.transport.type === "webSocket" || client.transport.type === "ipc") return false;
729
+ if (client.transport.type === "fallback" && (client.transport.transports[0].config.type === "webSocket" || client.transport.transports[0].config.type === "ipc")) return false;
730
+ return true;
731
+ })();
732
+ const pollContractEvent = () => {
733
+ const strict = strict_ ?? false;
734
+ return observe(stringify([
735
+ "watchContractEvent",
736
+ address,
737
+ args,
738
+ batch,
739
+ client.uid,
740
+ eventName,
741
+ pollingInterval,
742
+ strict,
743
+ fromBlock
744
+ ]), {
745
+ onLogs,
746
+ onError
747
+ }, (emit) => {
748
+ let previousBlockNumber;
749
+ if (fromBlock !== void 0) previousBlockNumber = fromBlock - 1n;
750
+ let filter;
751
+ let initialized = false;
752
+ const unwatch = poll(async () => {
753
+ if (!initialized) {
754
+ try {
755
+ filter = await getAction(client, createContractEventFilter, "createContractEventFilter")({
756
+ abi,
757
+ address,
758
+ args,
759
+ eventName,
760
+ strict,
761
+ fromBlock
762
+ });
763
+ } catch {}
764
+ initialized = true;
765
+ return;
766
+ }
767
+ try {
768
+ let logs;
769
+ if (filter) logs = await getAction(client, getFilterChanges, "getFilterChanges")({ filter });
770
+ else {
771
+ const blockNumber = await getAction(client, getBlockNumber, "getBlockNumber")({});
772
+ if (previousBlockNumber && previousBlockNumber < blockNumber) logs = await getAction(client, getContractEvents, "getContractEvents")({
773
+ abi,
774
+ address,
775
+ args,
776
+ eventName,
777
+ fromBlock: previousBlockNumber + 1n,
778
+ toBlock: blockNumber,
779
+ strict
780
+ });
781
+ else logs = [];
782
+ previousBlockNumber = blockNumber;
783
+ }
784
+ if (logs.length === 0) return;
785
+ if (batch) emit.onLogs(logs);
786
+ else for (const log of logs) emit.onLogs([log]);
787
+ } catch (err) {
788
+ if (filter && err instanceof InvalidInputRpcError) initialized = false;
789
+ emit.onError?.(err);
790
+ }
791
+ }, {
792
+ emitOnBegin: true,
793
+ interval: pollingInterval
794
+ });
795
+ return async () => {
796
+ if (filter) await getAction(client, uninstallFilter, "uninstallFilter")({ filter });
797
+ unwatch();
798
+ };
799
+ });
800
+ };
801
+ const subscribeContractEvent = () => {
802
+ const strict = strict_ ?? false;
803
+ const observerId = stringify([
804
+ "watchContractEvent",
805
+ address,
806
+ args,
807
+ batch,
808
+ client.uid,
809
+ eventName,
810
+ pollingInterval,
811
+ strict
812
+ ]);
813
+ let active = true;
814
+ let unsubscribe = () => active = false;
815
+ return observe(observerId, {
816
+ onLogs,
817
+ onError
818
+ }, (emit) => {
819
+ (async () => {
820
+ try {
821
+ const transport = (() => {
822
+ if (client.transport.type === "fallback") {
823
+ const transport = client.transport.transports.find((transport) => transport.config.type === "webSocket" || transport.config.type === "ipc");
824
+ if (!transport) return client.transport;
825
+ return transport.value;
826
+ }
827
+ return client.transport;
828
+ })();
829
+ const topics = eventName ? encodeEventTopics({
830
+ abi,
831
+ eventName,
832
+ args
833
+ }) : [];
834
+ const { unsubscribe: unsubscribe_ } = await transport.subscribe({
835
+ params: ["logs", {
836
+ address,
837
+ topics
838
+ }],
839
+ onData(data) {
840
+ if (!active) return;
841
+ const log = data.result;
842
+ try {
843
+ const { eventName, args } = decodeEventLog({
844
+ abi,
845
+ data: log.data,
846
+ topics: log.topics,
847
+ strict: strict_
848
+ });
849
+ const formatted = formatLog(log, {
850
+ args,
851
+ eventName
852
+ });
853
+ emit.onLogs([formatted]);
854
+ } catch (err) {
855
+ let eventName;
856
+ let isUnnamed;
857
+ if (err instanceof DecodeLogDataMismatch || err instanceof DecodeLogTopicsMismatch) {
858
+ if (strict_) return;
859
+ eventName = err.abiItem.name;
860
+ isUnnamed = err.abiItem.inputs?.some((x) => !("name" in x && x.name));
861
+ }
862
+ const formatted = formatLog(log, {
863
+ args: isUnnamed ? [] : {},
864
+ eventName
865
+ });
866
+ emit.onLogs([formatted]);
867
+ }
868
+ },
869
+ onError(error) {
870
+ emit.onError?.(error);
871
+ }
872
+ });
873
+ unsubscribe = unsubscribe_;
874
+ if (!active) unsubscribe();
875
+ } catch (err) {
876
+ onError?.(err);
877
+ }
878
+ })();
879
+ return () => unsubscribe();
880
+ });
881
+ };
882
+ return enablePolling ? pollContractEvent() : subscribeContractEvent();
883
+ }
884
+ //#endregion
885
+ //#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/utils/promise/withRetry.js
886
+ function withRetry(fn, { delay: delay_ = 100, retryCount = 2, shouldRetry = () => true } = {}) {
887
+ return new Promise((resolve, reject) => {
888
+ const attemptRetry = async ({ count = 0 } = {}) => {
889
+ const retry = async ({ error }) => {
890
+ const delay = typeof delay_ === "function" ? delay_({
891
+ count,
892
+ error
893
+ }) : delay_;
894
+ if (delay) await wait(delay);
895
+ attemptRetry({ count: count + 1 });
896
+ };
897
+ try {
898
+ resolve(await fn());
899
+ } catch (err) {
900
+ if (count < retryCount && await shouldRetry({
901
+ count,
902
+ error: err
903
+ })) return retry({ error: err });
904
+ reject(err);
905
+ }
906
+ };
907
+ attemptRetry();
908
+ });
909
+ }
910
+ //#endregion
911
+ //#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/utils/uid.js
912
+ const size = 256;
913
+ let index = size;
914
+ let buffer;
915
+ function uid(length = 11) {
916
+ if (!buffer || index + length > size * 2) {
917
+ buffer = "";
918
+ index = 0;
919
+ for (let i = 0; i < size; i++) buffer += (256 + Math.random() * 256 | 0).toString(16).substring(1);
920
+ }
921
+ return buffer.substring(index, index++ + length);
922
+ }
923
+ //#endregion
924
+ //#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/clients/createClient.js
925
+ function createClient(parameters) {
926
+ const { batch, chain, ccipRead, dataSuffix, key = "base", name = "Base Client", type = "base" } = parameters;
927
+ const experimental_blockTag = parameters.experimental_blockTag ?? (typeof chain?.experimental_preconfirmationTime === "number" ? "pending" : void 0);
928
+ const blockTime = chain?.blockTime ?? 12e3;
929
+ const defaultPollingInterval = Math.min(Math.max(Math.floor(blockTime / 2), 500), 4e3);
930
+ const pollingInterval = parameters.pollingInterval ?? defaultPollingInterval;
931
+ const cacheTime = parameters.cacheTime ?? pollingInterval;
932
+ const account = parameters.account ? parseAccount(parameters.account) : void 0;
933
+ const { config, request, value } = parameters.transport({
934
+ account,
935
+ chain,
936
+ pollingInterval
937
+ });
938
+ const client = {
939
+ account,
940
+ batch,
941
+ cacheTime,
942
+ ccipRead,
943
+ chain,
944
+ dataSuffix,
945
+ key,
946
+ name,
947
+ pollingInterval,
948
+ request,
949
+ transport: {
950
+ ...config,
951
+ ...value
952
+ },
953
+ type,
954
+ uid: uid(),
955
+ ...experimental_blockTag ? { experimental_blockTag } : {}
956
+ };
957
+ function extend(base) {
958
+ return (extendFn) => {
959
+ const extended = extendFn(base);
960
+ for (const key in client) delete extended[key];
961
+ const combined = {
962
+ ...base,
963
+ ...extended
964
+ };
965
+ return Object.assign(combined, { extend: extend(combined) });
966
+ };
967
+ }
968
+ return Object.assign(client, { extend: extend(client) });
969
+ }
970
+ //#endregion
971
+ //#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/actions/public/getCode.js
972
+ /**
973
+ * Retrieves the bytecode at an address.
974
+ *
975
+ * - Docs: https://viem.sh/docs/contract/getCode
976
+ * - JSON-RPC Methods: [`eth_getCode`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getcode)
977
+ *
978
+ * @param client - Client to use
979
+ * @param parameters - {@link GetCodeParameters}
980
+ * @returns The contract's bytecode. {@link GetCodeReturnType}
981
+ *
982
+ * @example
983
+ * import { createPublicClient, http } from 'viem'
984
+ * import { mainnet } from 'viem/chains'
985
+ * import { getCode } from 'viem/contract'
986
+ *
987
+ * const client = createPublicClient({
988
+ * chain: mainnet,
989
+ * transport: http(),
990
+ * })
991
+ * const code = await getCode(client, {
992
+ * address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
993
+ * })
994
+ */
995
+ async function getCode(client, { address, blockNumber, blockTag = "latest" }) {
996
+ const blockNumberHex = blockNumber !== void 0 ? numberToHex(blockNumber) : void 0;
997
+ const hex = await client.request({
998
+ method: "eth_getCode",
999
+ params: [address, blockNumberHex || blockTag]
1000
+ }, { dedupe: Boolean(blockNumberHex) });
1001
+ if (hex === "0x") return void 0;
1002
+ return hex;
1003
+ }
1004
+ //#endregion
1005
+ //#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/utils/authorization/verifyAuthorization.js
1006
+ /**
1007
+ * Verify that an Authorization object was signed by the provided address.
1008
+ *
1009
+ * - Docs {@link https://viem.sh/docs/utilities/verifyAuthorization}
1010
+ *
1011
+ * @param parameters - {@link VerifyAuthorizationParameters}
1012
+ * @returns Whether or not the signature is valid. {@link VerifyAuthorizationReturnType}
1013
+ */
1014
+ async function verifyAuthorization({ address, authorization, signature }) {
1015
+ return isAddressEqual(getAddress(address), await recoverAuthorizationAddress({
1016
+ authorization,
1017
+ signature
1018
+ }));
1019
+ }
1020
+ //#endregion
1021
+ //#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/utils/promise/withDedupe.js
1022
+ /** @internal */
1023
+ const promiseCache = /* @__PURE__ */ new LruMap(8192);
1024
+ /** Deduplicates in-flight promises. */
1025
+ function withDedupe(fn, { enabled = true, id }) {
1026
+ if (!enabled || !id) return fn();
1027
+ if (promiseCache.get(id)) return promiseCache.get(id);
1028
+ const promise = fn().finally(() => promiseCache.delete(id));
1029
+ promiseCache.set(id, promise);
1030
+ return promise;
1031
+ }
1032
+ //#endregion
1033
+ //#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/utils/buildRequest.js
1034
+ function buildRequest(request, options = {}) {
1035
+ return async (args, overrideOptions = {}) => {
1036
+ const { dedupe = false, methods, retryDelay = 150, retryCount = 3, uid } = {
1037
+ ...options,
1038
+ ...overrideOptions
1039
+ };
1040
+ const { method } = args;
1041
+ if (methods?.exclude?.includes(method)) throw new MethodNotSupportedRpcError(/* @__PURE__ */ new Error("method not supported"), { method });
1042
+ if (methods?.include && !methods.include.includes(method)) throw new MethodNotSupportedRpcError(/* @__PURE__ */ new Error("method not supported"), { method });
1043
+ return withDedupe(() => withRetry(async () => {
1044
+ try {
1045
+ return await request(args);
1046
+ } catch (err_) {
1047
+ const err = err_;
1048
+ switch (err.code) {
1049
+ case ParseRpcError.code: throw new ParseRpcError(err);
1050
+ case InvalidRequestRpcError.code: throw new InvalidRequestRpcError(err);
1051
+ case MethodNotFoundRpcError.code: throw new MethodNotFoundRpcError(err, { method: args.method });
1052
+ case InvalidParamsRpcError.code: throw new InvalidParamsRpcError(err);
1053
+ case InternalRpcError.code: throw new InternalRpcError(err);
1054
+ case InvalidInputRpcError.code: throw new InvalidInputRpcError(err);
1055
+ case ResourceNotFoundRpcError.code: throw new ResourceNotFoundRpcError(err);
1056
+ case ResourceUnavailableRpcError.code: throw new ResourceUnavailableRpcError(err);
1057
+ case TransactionRejectedRpcError.code: throw new TransactionRejectedRpcError(err);
1058
+ case MethodNotSupportedRpcError.code: throw new MethodNotSupportedRpcError(err, { method: args.method });
1059
+ case LimitExceededRpcError.code: throw new LimitExceededRpcError(err);
1060
+ case JsonRpcVersionUnsupportedError.code: throw new JsonRpcVersionUnsupportedError(err);
1061
+ case UserRejectedRequestError.code: throw new UserRejectedRequestError(err);
1062
+ case UnauthorizedProviderError.code: throw new UnauthorizedProviderError(err);
1063
+ case UnsupportedProviderMethodError.code: throw new UnsupportedProviderMethodError(err);
1064
+ case ProviderDisconnectedError.code: throw new ProviderDisconnectedError(err);
1065
+ case ChainDisconnectedError.code: throw new ChainDisconnectedError(err);
1066
+ case SwitchChainError.code: throw new SwitchChainError(err);
1067
+ case UnsupportedNonOptionalCapabilityError.code: throw new UnsupportedNonOptionalCapabilityError(err);
1068
+ case UnsupportedChainIdError.code: throw new UnsupportedChainIdError(err);
1069
+ case DuplicateIdError.code: throw new DuplicateIdError(err);
1070
+ case UnknownBundleIdError.code: throw new UnknownBundleIdError(err);
1071
+ case BundleTooLargeError.code: throw new BundleTooLargeError(err);
1072
+ case AtomicReadyWalletRejectedUpgradeError.code: throw new AtomicReadyWalletRejectedUpgradeError(err);
1073
+ case AtomicityNotSupportedError.code: throw new AtomicityNotSupportedError(err);
1074
+ case 5e3: throw new UserRejectedRequestError(err);
1075
+ case WalletConnectSessionSettlementError.code: throw new WalletConnectSessionSettlementError(err);
1076
+ default:
1077
+ if (err_ instanceof BaseError$1) throw err_;
1078
+ throw new UnknownRpcError(err);
1079
+ }
1080
+ }
1081
+ }, {
1082
+ delay: ({ count, error }) => {
1083
+ if (error && error instanceof HttpRequestError) {
1084
+ const retryAfter = error?.headers?.get("Retry-After");
1085
+ if (retryAfter?.match(/\d/)) return Number.parseInt(retryAfter, 10) * 1e3;
1086
+ }
1087
+ return ~~(1 << count) * retryDelay;
1088
+ },
1089
+ retryCount,
1090
+ shouldRetry: ({ error }) => shouldRetry(error)
1091
+ }), {
1092
+ enabled: dedupe,
1093
+ id: dedupe ? stringToHex(`${uid}.${stringify(args)}`) : void 0
1094
+ });
1095
+ };
1096
+ }
1097
+ /** @internal */
1098
+ function shouldRetry(error) {
1099
+ if ("code" in error && typeof error.code === "number") {
1100
+ if (error.code === -1) return true;
1101
+ if (error.code === LimitExceededRpcError.code) return true;
1102
+ if (error.code === InternalRpcError.code) return true;
1103
+ return false;
1104
+ }
1105
+ if (error instanceof HttpRequestError && error.status) {
1106
+ if (error.status === 403) return true;
1107
+ if (error.status === 408) return true;
1108
+ if (error.status === 413) return true;
1109
+ if (error.status === 429) return true;
1110
+ if (error.status === 500) return true;
1111
+ if (error.status === 502) return true;
1112
+ if (error.status === 503) return true;
1113
+ if (error.status === 504) return true;
1114
+ return false;
1115
+ }
1116
+ return true;
1117
+ }
1118
+ //#endregion
1119
+ //#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/utils/chain/defineChain.js
1120
+ function defineChain(chain) {
1121
+ const chainInstance = {
1122
+ formatters: void 0,
1123
+ fees: void 0,
1124
+ serializers: void 0,
1125
+ ...chain
1126
+ };
1127
+ function extend(base) {
1128
+ return (fnOrExtended) => {
1129
+ const properties = typeof fnOrExtended === "function" ? fnOrExtended(base) : fnOrExtended;
1130
+ const combined = {
1131
+ ...base,
1132
+ ...properties
1133
+ };
1134
+ return Object.assign(combined, { extend: extend(combined) });
1135
+ };
1136
+ }
1137
+ return Object.assign(chainInstance, { extend: extend(chainInstance) });
1138
+ }
1139
+ function extendSchema() {
1140
+ return {};
1141
+ }
1142
+ //#endregion
1143
+ //#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/utils/promise/withTimeout.js
1144
+ function withTimeout(fn, { errorInstance = /* @__PURE__ */ new Error("timed out"), timeout, signal }) {
1145
+ return new Promise((resolve, reject) => {
1146
+ (async () => {
1147
+ let timeoutId;
1148
+ try {
1149
+ const controller = new AbortController();
1150
+ if (timeout > 0) timeoutId = setTimeout(() => {
1151
+ if (signal) controller.abort();
1152
+ else reject(errorInstance);
1153
+ }, timeout);
1154
+ resolve(await fn({ signal: controller?.signal || null }));
1155
+ } catch (err) {
1156
+ if (err?.name === "AbortError") reject(errorInstance);
1157
+ reject(err);
1158
+ } finally {
1159
+ clearTimeout(timeoutId);
1160
+ }
1161
+ })();
1162
+ });
1163
+ }
1164
+ //#endregion
1165
+ //#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/utils/rpc/id.js
1166
+ function createIdStore() {
1167
+ return {
1168
+ current: 0,
1169
+ take() {
1170
+ return this.current++;
1171
+ },
1172
+ reset() {
1173
+ this.current = 0;
1174
+ }
1175
+ };
1176
+ }
1177
+ const idCache = /* @__PURE__ */ createIdStore();
1178
+ //#endregion
1179
+ //#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/utils/rpc/http.js
1180
+ function getHttpRpcClient(url_, options = {}) {
1181
+ const { url, headers: headers_url } = parseUrl(url_);
1182
+ return { async request(params) {
1183
+ const { body, fetchFn = options.fetchFn ?? fetch, onRequest = options.onRequest, onResponse = options.onResponse, timeout = options.timeout ?? 1e4 } = params;
1184
+ const fetchOptions = {
1185
+ ...options.fetchOptions ?? {},
1186
+ ...params.fetchOptions ?? {}
1187
+ };
1188
+ const { headers, method, signal: signal_ } = fetchOptions;
1189
+ try {
1190
+ const response = await withTimeout(async ({ signal }) => {
1191
+ const init = {
1192
+ ...fetchOptions,
1193
+ body: Array.isArray(body) ? stringify(body.map((body) => ({
1194
+ jsonrpc: "2.0",
1195
+ id: body.id ?? idCache.take(),
1196
+ ...body
1197
+ }))) : stringify({
1198
+ jsonrpc: "2.0",
1199
+ id: body.id ?? idCache.take(),
1200
+ ...body
1201
+ }),
1202
+ headers: {
1203
+ ...headers_url,
1204
+ "Content-Type": "application/json",
1205
+ ...headers
1206
+ },
1207
+ method: method || "POST",
1208
+ signal: signal_ || (timeout > 0 ? signal : null)
1209
+ };
1210
+ const request = new Request(url, init);
1211
+ const args = await onRequest?.(request, init) ?? {
1212
+ ...init,
1213
+ url
1214
+ };
1215
+ return await fetchFn(args.url ?? url, args);
1216
+ }, {
1217
+ errorInstance: new TimeoutError({
1218
+ body,
1219
+ url
1220
+ }),
1221
+ timeout,
1222
+ signal: true
1223
+ });
1224
+ if (onResponse) await onResponse(response);
1225
+ let data;
1226
+ if (response.headers.get("Content-Type")?.startsWith("application/json")) data = await response.json();
1227
+ else {
1228
+ data = await response.text();
1229
+ try {
1230
+ data = JSON.parse(data || "{}");
1231
+ } catch (err) {
1232
+ if (response.ok) throw err;
1233
+ data = { error: data };
1234
+ }
1235
+ }
1236
+ if (!response.ok) {
1237
+ if (typeof data.error?.code === "number" && typeof data.error?.message === "string") return data;
1238
+ throw new HttpRequestError({
1239
+ body,
1240
+ details: stringify(data.error) || response.statusText,
1241
+ headers: response.headers,
1242
+ status: response.status,
1243
+ url
1244
+ });
1245
+ }
1246
+ return data;
1247
+ } catch (err) {
1248
+ if (err instanceof HttpRequestError) throw err;
1249
+ if (err instanceof TimeoutError) throw err;
1250
+ throw new HttpRequestError({
1251
+ body,
1252
+ cause: err,
1253
+ url
1254
+ });
1255
+ }
1256
+ } };
1257
+ }
1258
+ /** @internal */
1259
+ function parseUrl(url_) {
1260
+ try {
1261
+ const url = new URL(url_);
1262
+ const result = (() => {
1263
+ if (url.username) {
1264
+ const credentials = `${decodeURIComponent(url.username)}:${decodeURIComponent(url.password)}`;
1265
+ url.username = "";
1266
+ url.password = "";
1267
+ return {
1268
+ url: url.toString(),
1269
+ headers: { Authorization: `Basic ${btoa(credentials)}` }
1270
+ };
1271
+ }
1272
+ })();
1273
+ return {
1274
+ url: url.toString(),
1275
+ ...result
1276
+ };
1277
+ } catch {
1278
+ return { url: url_ };
1279
+ }
1280
+ }
1281
+ //#endregion
1282
+ //#region node_modules/.pnpm/ox@0.14.7_typescript@5.9.3_zod@4.3.6/node_modules/ox/_esm/core/Authorization.js
1283
+ /**
1284
+ * Converts an [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702) Authorization object into a typed {@link ox#Authorization.Authorization}.
1285
+ *
1286
+ * @example
1287
+ * An Authorization can be instantiated from an [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702) Authorization tuple in object format.
1288
+ *
1289
+ * ```ts twoslash
1290
+ * import { Authorization } from 'ox'
1291
+ *
1292
+ * const authorization = Authorization.from({
1293
+ * address: '0x1234567890abcdef1234567890abcdef12345678',
1294
+ * chainId: 1,
1295
+ * nonce: 69n,
1296
+ * })
1297
+ * ```
1298
+ *
1299
+ * @example
1300
+ * ### Attaching Signatures
1301
+ *
1302
+ * A {@link ox#Signature.Signature} can be attached with the `signature` option. The example below demonstrates signing
1303
+ * an Authorization with {@link ox#Secp256k1.(sign:function)}.
1304
+ *
1305
+ * ```ts twoslash
1306
+ * import { Authorization, Secp256k1 } from 'ox'
1307
+ *
1308
+ * const authorization = Authorization.from({
1309
+ * address: '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',
1310
+ * chainId: 1,
1311
+ * nonce: 40n,
1312
+ * })
1313
+ *
1314
+ * const signature = Secp256k1.sign({
1315
+ * payload: Authorization.getSignPayload(authorization),
1316
+ * privateKey: '0x...',
1317
+ * })
1318
+ *
1319
+ * const authorization_signed = Authorization.from(authorization, { signature }) // [!code focus]
1320
+ * ```
1321
+ *
1322
+ * @param authorization - An [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702) Authorization tuple in object format.
1323
+ * @param options - Authorization options.
1324
+ * @returns The {@link ox#Authorization.Authorization}.
1325
+ */
1326
+ function from(authorization, options = {}) {
1327
+ if (typeof authorization.chainId === "string") return fromRpc(authorization);
1328
+ return {
1329
+ ...authorization,
1330
+ ...options.signature
1331
+ };
1332
+ }
1333
+ /**
1334
+ * Converts an {@link ox#Authorization.Rpc} to an {@link ox#Authorization.Authorization}.
1335
+ *
1336
+ * @example
1337
+ * ```ts twoslash
1338
+ * import { Authorization } from 'ox'
1339
+ *
1340
+ * const authorization = Authorization.fromRpc({
1341
+ * address: '0x0000000000000000000000000000000000000000',
1342
+ * chainId: '0x1',
1343
+ * nonce: '0x1',
1344
+ * r: '0x635dc2033e60185bb36709c29c75d64ea51dfbd91c32ef4be198e4ceb169fb4d',
1345
+ * s: '0x50c2667ac4c771072746acfdcf1f1483336dcca8bd2df47cd83175dbe60f0540',
1346
+ * yParity: '0x0',
1347
+ * })
1348
+ * ```
1349
+ *
1350
+ * @param authorization - The RPC-formatted Authorization.
1351
+ * @returns A signed {@link ox#Authorization.Authorization}.
1352
+ */
1353
+ function fromRpc(authorization) {
1354
+ const { address, chainId, nonce } = authorization;
1355
+ const signature = extract(authorization);
1356
+ return {
1357
+ address,
1358
+ chainId: Number(chainId),
1359
+ nonce: BigInt(nonce),
1360
+ ...signature
1361
+ };
1362
+ }
1363
+ /**
1364
+ * Converts an {@link ox#Authorization.ListRpc} to an {@link ox#Authorization.List}.
1365
+ *
1366
+ * @example
1367
+ * ```ts twoslash
1368
+ * import { Authorization } from 'ox'
1369
+ *
1370
+ * const authorizationList = Authorization.fromRpcList([{
1371
+ * address: '0x0000000000000000000000000000000000000000',
1372
+ * chainId: '0x1',
1373
+ * nonce: '0x1',
1374
+ * r: '0x635dc2033e60185bb36709c29c75d64ea51dfbd91c32ef4be198e4ceb169fb4d',
1375
+ * s: '0x50c2667ac4c771072746acfdcf1f1483336dcca8bd2df47cd83175dbe60f0540',
1376
+ * yParity: '0x0',
1377
+ * }])
1378
+ * ```
1379
+ *
1380
+ * @param authorizationList - The RPC-formatted Authorization list.
1381
+ * @returns A signed {@link ox#Authorization.List}.
1382
+ */
1383
+ function fromRpcList(authorizationList) {
1384
+ return authorizationList.map(fromRpc);
1385
+ }
1386
+ /**
1387
+ * Converts an {@link ox#Authorization.Authorization} to an {@link ox#Authorization.Rpc}.
1388
+ *
1389
+ * @example
1390
+ * ```ts twoslash
1391
+ * import { Authorization } from 'ox'
1392
+ *
1393
+ * const authorization = Authorization.toRpc({
1394
+ * address: '0x0000000000000000000000000000000000000000',
1395
+ * chainId: 1,
1396
+ * nonce: 1n,
1397
+ * r: 44944627813007772897391531230081695102703289123332187696115181104739239197517n,
1398
+ * s: 36528503505192438307355164441104001310566505351980369085208178712678799181120n,
1399
+ * yParity: 0,
1400
+ * })
1401
+ * ```
1402
+ *
1403
+ * @param authorization - An Authorization.
1404
+ * @returns An RPC-formatted Authorization.
1405
+ */
1406
+ function toRpc(authorization) {
1407
+ const { address, chainId, nonce, ...signature } = authorization;
1408
+ return {
1409
+ address,
1410
+ chainId: fromNumber(chainId),
1411
+ nonce: fromNumber(nonce),
1412
+ ...toRpc$1(signature)
1413
+ };
1414
+ }
1415
+ /**
1416
+ * Converts an {@link ox#Authorization.List} to an {@link ox#Authorization.ListRpc}.
1417
+ *
1418
+ * @example
1419
+ * ```ts twoslash
1420
+ * import { Authorization } from 'ox'
1421
+ *
1422
+ * const authorization = Authorization.toRpcList([{
1423
+ * address: '0x0000000000000000000000000000000000000000',
1424
+ * chainId: 1,
1425
+ * nonce: 1n,
1426
+ * r: 44944627813007772897391531230081695102703289123332187696115181104739239197517n,
1427
+ * s: 36528503505192438307355164441104001310566505351980369085208178712678799181120n,
1428
+ * yParity: 0,
1429
+ * }])
1430
+ * ```
1431
+ *
1432
+ * @param authorizationList - An Authorization List.
1433
+ * @returns An RPC-formatted Authorization List.
1434
+ */
1435
+ function toRpcList(authorizationList) {
1436
+ return authorizationList.map(toRpc);
1437
+ }
1438
+ /** Suffix ABI parameters for the ERC-8010 wrapped signature. */
1439
+ const suffixParameters = from$1("(uint256 chainId, address delegation, uint256 nonce, uint8 yParity, uint256 r, uint256 s), address to, bytes data");
1440
+ /**
1441
+ * Asserts that the wrapped signature is valid.
1442
+ *
1443
+ * @example
1444
+ * ```ts twoslash
1445
+ * import { SignatureErc8010 } from 'ox/erc8010'
1446
+ *
1447
+ * SignatureErc8010.assert('0xdeadbeef')
1448
+ * // @error: InvalidWrappedSignatureError: Value `0xdeadbeef` is an invalid ERC-8010 wrapped signature.
1449
+ * ```
1450
+ *
1451
+ * @param value - The value to assert.
1452
+ */
1453
+ function assert$1(value) {
1454
+ if (typeof value === "string") {
1455
+ if (slice(value, -32) !== "0x8010801080108010801080108010801080108010801080108010801080108010") throw new InvalidWrappedSignatureError$1(value);
1456
+ } else assert$2(value.authorization);
1457
+ }
1458
+ /**
1459
+ * Unwraps an [ERC-8010 wrapped signature](https://github.com/jxom/ERCs/blob/16f7e3891fff2e1e9c25dea0485497739db8a816/ERCS/erc-8010.md) into its constituent parts.
1460
+ *
1461
+ * @example
1462
+ * ```ts twoslash
1463
+ * import { SignatureErc8010 } from 'ox/erc8010'
1464
+ *
1465
+ * const { authorization, data, signature } = SignatureErc8010.unwrap('0x...')
1466
+ * ```
1467
+ *
1468
+ * @param wrapped - Wrapped signature to unwrap.
1469
+ * @returns Unwrapped signature.
1470
+ */
1471
+ function unwrap(wrapped) {
1472
+ assert$1(wrapped);
1473
+ const suffixLength = toNumber(slice(wrapped, -64, -32));
1474
+ const suffix = slice(wrapped, -suffixLength - 64, -64);
1475
+ const signature = slice(wrapped, 0, -suffixLength - 64);
1476
+ const [auth, to, data] = decode(suffixParameters, suffix);
1477
+ return {
1478
+ authorization: from({
1479
+ address: auth.delegation,
1480
+ chainId: Number(auth.chainId),
1481
+ nonce: auth.nonce,
1482
+ yParity: auth.yParity,
1483
+ r: auth.r,
1484
+ s: auth.s
1485
+ }),
1486
+ signature,
1487
+ ...data && data !== "0x" ? {
1488
+ data,
1489
+ to
1490
+ } : {}
1491
+ };
1492
+ }
1493
+ /**
1494
+ * Validates a wrapped signature. Returns `true` if the wrapped signature is valid, `false` otherwise.
1495
+ *
1496
+ * @example
1497
+ * ```ts twoslash
1498
+ * import { SignatureErc8010 } from 'ox/erc8010'
1499
+ *
1500
+ * const valid = SignatureErc8010.validate('0xdeadbeef')
1501
+ * // @log: false
1502
+ * ```
1503
+ *
1504
+ * @param value - The value to validate.
1505
+ * @returns `true` if the value is valid, `false` otherwise.
1506
+ */
1507
+ function validate$1(value) {
1508
+ try {
1509
+ assert$1(value);
1510
+ return true;
1511
+ } catch {
1512
+ return false;
1513
+ }
1514
+ }
1515
+ /** Thrown when the ERC-8010 wrapped signature is invalid. */
1516
+ var InvalidWrappedSignatureError$1 = class extends BaseError {
1517
+ constructor(wrapped) {
1518
+ super(`Value \`${wrapped}\` is an invalid ERC-8010 wrapped signature.`);
1519
+ Object.defineProperty(this, "name", {
1520
+ enumerable: true,
1521
+ configurable: true,
1522
+ writable: true,
1523
+ value: "SignatureErc8010.InvalidWrappedSignatureError"
1524
+ });
1525
+ }
1526
+ };
1527
+ //#endregion
1528
+ //#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/actions/public/getTransactionReceipt.js
1529
+ /**
1530
+ * Returns the [Transaction Receipt](https://viem.sh/docs/glossary/terms#transaction-receipt) given a [Transaction](https://viem.sh/docs/glossary/terms#transaction) hash.
1531
+ *
1532
+ * - Docs: https://viem.sh/docs/actions/public/getTransactionReceipt
1533
+ * - Example: https://stackblitz.com/github/wevm/viem/tree/main/examples/transactions_fetching-transactions
1534
+ * - JSON-RPC Methods: [`eth_getTransactionReceipt`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_gettransactionreceipt)
1535
+ *
1536
+ * @param client - Client to use
1537
+ * @param parameters - {@link GetTransactionReceiptParameters}
1538
+ * @returns The transaction receipt. {@link GetTransactionReceiptReturnType}
1539
+ *
1540
+ * @example
1541
+ * import { createPublicClient, http } from 'viem'
1542
+ * import { mainnet } from 'viem/chains'
1543
+ * import { getTransactionReceipt } from 'viem/public'
1544
+ *
1545
+ * const client = createPublicClient({
1546
+ * chain: mainnet,
1547
+ * transport: http(),
1548
+ * })
1549
+ * const transactionReceipt = await getTransactionReceipt(client, {
1550
+ * hash: '0x4ca7ee652d57678f26e887c149ab0735f41de37bcad58c9f6d3ed5824f15b74d',
1551
+ * })
1552
+ */
1553
+ async function getTransactionReceipt(client, { hash }) {
1554
+ const receipt = await client.request({
1555
+ method: "eth_getTransactionReceipt",
1556
+ params: [hash]
1557
+ }, { dedupe: true });
1558
+ if (!receipt) throw new TransactionReceiptNotFoundError({ hash });
1559
+ return (client.chain?.formatters?.transactionReceipt?.format || formatTransactionReceipt)(receipt, "getTransactionReceipt");
1560
+ }
1561
+ //#endregion
1562
+ //#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/actions/public/multicall.js
1563
+ /**
1564
+ * Similar to [`readContract`](https://viem.sh/docs/contract/readContract), but batches up multiple functions on a contract in a single RPC call via the [`multicall3` contract](https://github.com/mds1/multicall).
1565
+ *
1566
+ * - Docs: https://viem.sh/docs/contract/multicall
1567
+ *
1568
+ * @param client - Client to use
1569
+ * @param parameters - {@link MulticallParameters}
1570
+ * @returns An array of results with accompanying status. {@link MulticallReturnType}
1571
+ *
1572
+ * @example
1573
+ * import { createPublicClient, http, parseAbi } from 'viem'
1574
+ * import { mainnet } from 'viem/chains'
1575
+ * import { multicall } from 'viem/contract'
1576
+ *
1577
+ * const client = createPublicClient({
1578
+ * chain: mainnet,
1579
+ * transport: http(),
1580
+ * })
1581
+ * const abi = parseAbi([
1582
+ * 'function balanceOf(address) view returns (uint256)',
1583
+ * 'function totalSupply() view returns (uint256)',
1584
+ * ])
1585
+ * const results = await multicall(client, {
1586
+ * contracts: [
1587
+ * {
1588
+ * address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
1589
+ * abi,
1590
+ * functionName: 'balanceOf',
1591
+ * args: ['0xA0Cf798816D4b9b9866b5330EEa46a18382f251e'],
1592
+ * },
1593
+ * {
1594
+ * address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
1595
+ * abi,
1596
+ * functionName: 'totalSupply',
1597
+ * },
1598
+ * ],
1599
+ * })
1600
+ * // [{ result: 424122n, status: 'success' }, { result: 1000000n, status: 'success' }]
1601
+ */
1602
+ async function multicall(client, parameters) {
1603
+ const { account, authorizationList, allowFailure = true, blockNumber, blockOverrides, blockTag, stateOverride } = parameters;
1604
+ const contracts = parameters.contracts;
1605
+ const { batchSize = parameters.batchSize ?? 1024, deployless = parameters.deployless ?? false } = typeof client.batch?.multicall === "object" ? client.batch.multicall : {};
1606
+ const multicallAddress = (() => {
1607
+ if (parameters.multicallAddress) return parameters.multicallAddress;
1608
+ if (deployless) return null;
1609
+ if (client.chain) return getChainContractAddress({
1610
+ blockNumber,
1611
+ chain: client.chain,
1612
+ contract: "multicall3"
1613
+ });
1614
+ throw new Error("client chain not configured. multicallAddress is required.");
1615
+ })();
1616
+ const chunkedCalls = [[]];
1617
+ let currentChunk = 0;
1618
+ let currentChunkSize = 0;
1619
+ for (let i = 0; i < contracts.length; i++) {
1620
+ const { abi, address, args, functionName } = contracts[i];
1621
+ try {
1622
+ const callData = encodeFunctionData({
1623
+ abi,
1624
+ args,
1625
+ functionName
1626
+ });
1627
+ currentChunkSize += (callData.length - 2) / 2;
1628
+ if (batchSize > 0 && currentChunkSize > batchSize && chunkedCalls[currentChunk].length > 0) {
1629
+ currentChunk++;
1630
+ currentChunkSize = (callData.length - 2) / 2;
1631
+ chunkedCalls[currentChunk] = [];
1632
+ }
1633
+ chunkedCalls[currentChunk] = [...chunkedCalls[currentChunk], {
1634
+ allowFailure: true,
1635
+ callData,
1636
+ target: address
1637
+ }];
1638
+ } catch (err) {
1639
+ const error = getContractError(err, {
1640
+ abi,
1641
+ address,
1642
+ args,
1643
+ docsPath: "/docs/contract/multicall",
1644
+ functionName,
1645
+ sender: account
1646
+ });
1647
+ if (!allowFailure) throw error;
1648
+ chunkedCalls[currentChunk] = [...chunkedCalls[currentChunk], {
1649
+ allowFailure: true,
1650
+ callData: "0x",
1651
+ target: address
1652
+ }];
1653
+ }
1654
+ }
1655
+ const aggregate3Results = await Promise.allSettled(chunkedCalls.map((calls) => getAction(client, readContract, "readContract")({
1656
+ ...multicallAddress === null ? { code: multicall3Bytecode } : { address: multicallAddress },
1657
+ abi: multicall3Abi,
1658
+ account,
1659
+ args: [calls],
1660
+ authorizationList,
1661
+ blockNumber,
1662
+ blockOverrides,
1663
+ blockTag,
1664
+ functionName: "aggregate3",
1665
+ stateOverride
1666
+ })));
1667
+ const results = [];
1668
+ for (let i = 0; i < aggregate3Results.length; i++) {
1669
+ const result = aggregate3Results[i];
1670
+ if (result.status === "rejected") {
1671
+ if (!allowFailure) throw result.reason;
1672
+ for (let j = 0; j < chunkedCalls[i].length; j++) results.push({
1673
+ status: "failure",
1674
+ error: result.reason,
1675
+ result: void 0
1676
+ });
1677
+ continue;
1678
+ }
1679
+ const aggregate3Result = result.value;
1680
+ for (let j = 0; j < aggregate3Result.length; j++) {
1681
+ const { returnData, success } = aggregate3Result[j];
1682
+ const { callData } = chunkedCalls[i][j];
1683
+ const { abi, address, functionName, args } = contracts[results.length];
1684
+ try {
1685
+ if (callData === "0x") throw new AbiDecodingZeroDataError();
1686
+ if (!success) throw new RawContractError({ data: returnData });
1687
+ const result = decodeFunctionResult({
1688
+ abi,
1689
+ args,
1690
+ data: returnData,
1691
+ functionName
1692
+ });
1693
+ results.push(allowFailure ? {
1694
+ result,
1695
+ status: "success"
1696
+ } : result);
1697
+ } catch (err) {
1698
+ const error = getContractError(err, {
1699
+ abi,
1700
+ address,
1701
+ args,
1702
+ docsPath: "/docs/contract/multicall",
1703
+ functionName
1704
+ });
1705
+ if (!allowFailure) throw error;
1706
+ results.push({
1707
+ error,
1708
+ result: void 0,
1709
+ status: "failure"
1710
+ });
1711
+ }
1712
+ }
1713
+ }
1714
+ if (results.length !== contracts.length) throw new BaseError$1("multicall results mismatch");
1715
+ return results;
1716
+ }
1717
+ //#endregion
1718
+ //#region node_modules/.pnpm/ox@0.14.7_typescript@5.9.3_zod@4.3.6/node_modules/ox/_esm/erc6492/SignatureErc6492.js
1719
+ /**
1720
+ * Magic bytes used to identify ERC-6492 wrapped signatures.
1721
+ */
1722
+ const magicBytes = "0x6492649264926492649264926492649264926492649264926492649264926492";
1723
+ /**
1724
+ * Asserts that the wrapped signature is valid.
1725
+ *
1726
+ * @example
1727
+ * ```ts twoslash
1728
+ * import { SignatureErc6492 } from 'ox/erc6492'
1729
+ *
1730
+ * SignatureErc6492.assert('0xdeadbeef')
1731
+ * // @error: InvalidWrappedSignatureError: Value `0xdeadbeef` is an invalid ERC-6492 wrapped signature.
1732
+ * ```
1733
+ *
1734
+ * @param wrapped - The wrapped signature to assert.
1735
+ */
1736
+ function assert(wrapped) {
1737
+ if (slice(wrapped, -32) !== "0x6492649264926492649264926492649264926492649264926492649264926492") throw new InvalidWrappedSignatureError(wrapped);
1738
+ }
1739
+ /**
1740
+ * Serializes an [ERC-6492 wrapped signature](https://eips.ethereum.org/EIPS/eip-6492#specification).
1741
+ *
1742
+ * @example
1743
+ * ```ts twoslash
1744
+ * import { Secp256k1, Signature } from 'ox'
1745
+ * import { SignatureErc6492 } from 'ox/erc6492' // [!code focus]
1746
+ *
1747
+ * const signature = Secp256k1.sign({
1748
+ * payload: '0x...',
1749
+ * privateKey: '0x...',
1750
+ * })
1751
+ *
1752
+ * const wrapped = SignatureErc6492.wrap({ // [!code focus]
1753
+ * data: '0xdeadbeef', // [!code focus]
1754
+ * signature: Signature.toHex(signature), // [!code focus]
1755
+ * to: '0x00000000219ab540356cBB839Cbe05303d7705Fa', // [!code focus]
1756
+ * }) // [!code focus]
1757
+ * ```
1758
+ *
1759
+ * @param value - Wrapped signature to serialize.
1760
+ * @returns Serialized wrapped signature.
1761
+ */
1762
+ function wrap(value) {
1763
+ const { data, signature, to } = value;
1764
+ return concat(encode(from$1("address, bytes, bytes"), [
1765
+ to,
1766
+ data,
1767
+ signature
1768
+ ]), magicBytes);
1769
+ }
1770
+ /**
1771
+ * Validates a wrapped signature. Returns `true` if the wrapped signature is valid, `false` otherwise.
1772
+ *
1773
+ * @example
1774
+ * ```ts twoslash
1775
+ * import { SignatureErc6492 } from 'ox/erc6492'
1776
+ *
1777
+ * const valid = SignatureErc6492.validate('0xdeadbeef')
1778
+ * // @log: false
1779
+ * ```
1780
+ *
1781
+ * @param wrapped - The wrapped signature to validate.
1782
+ * @returns `true` if the wrapped signature is valid, `false` otherwise.
1783
+ */
1784
+ function validate(wrapped) {
1785
+ try {
1786
+ assert(wrapped);
1787
+ return true;
1788
+ } catch {
1789
+ return false;
1790
+ }
1791
+ }
1792
+ /** Thrown when the ERC-6492 wrapped signature is invalid. */
1793
+ var InvalidWrappedSignatureError = class extends BaseError {
1794
+ constructor(wrapped) {
1795
+ super(`Value \`${wrapped}\` is an invalid ERC-6492 wrapped signature.`);
1796
+ Object.defineProperty(this, "name", {
1797
+ enumerable: true,
1798
+ configurable: true,
1799
+ writable: true,
1800
+ value: "SignatureErc6492.InvalidWrappedSignatureError"
1801
+ });
1802
+ }
1803
+ };
1804
+ //#endregion
1805
+ //#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/actions/public/verifyHash.js
1806
+ /**
1807
+ * Verifies a message hash onchain using ERC-6492.
1808
+ *
1809
+ * @param client - Client to use.
1810
+ * @param parameters - {@link VerifyHashParameters}
1811
+ * @returns Whether or not the signature is valid. {@link VerifyHashReturnType}
1812
+ */
1813
+ async function verifyHash(client, parameters) {
1814
+ const { address, chain = client.chain, hash, erc6492VerifierAddress: verifierAddress = parameters.universalSignatureVerifierAddress ?? chain?.contracts?.erc6492Verifier?.address, multicallAddress = parameters.multicallAddress ?? chain?.contracts?.multicall3?.address, mode = "auto" } = parameters;
1815
+ if (chain?.verifyHash) return await chain.verifyHash(client, parameters);
1816
+ const signature = (() => {
1817
+ const signature = parameters.signature;
1818
+ if (isHex(signature)) return signature;
1819
+ if (typeof signature === "object" && "r" in signature && "s" in signature) return serializeSignature(signature);
1820
+ return bytesToHex(signature);
1821
+ })();
1822
+ try {
1823
+ if (mode === "eoa") try {
1824
+ if (isAddressEqual(getAddress(address), await recoverAddress({
1825
+ hash,
1826
+ signature
1827
+ }))) return true;
1828
+ } catch {}
1829
+ if (validate$1(signature)) return await verifyErc8010(client, {
1830
+ ...parameters,
1831
+ multicallAddress,
1832
+ signature
1833
+ });
1834
+ return await verifyErc6492(client, {
1835
+ ...parameters,
1836
+ verifierAddress,
1837
+ signature
1838
+ });
1839
+ } catch (error) {
1840
+ if (mode !== "eoa") try {
1841
+ if (isAddressEqual(getAddress(address), await recoverAddress({
1842
+ hash,
1843
+ signature
1844
+ }))) return true;
1845
+ } catch {}
1846
+ if (error instanceof VerificationError) return false;
1847
+ throw error;
1848
+ }
1849
+ }
1850
+ /** @internal */
1851
+ async function verifyErc8010(client, parameters) {
1852
+ const { address, blockNumber, blockTag, hash, multicallAddress } = parameters;
1853
+ const { authorization: authorization_ox, data: initData, signature, to } = unwrap(parameters.signature);
1854
+ if (await getCode(client, {
1855
+ address,
1856
+ blockNumber,
1857
+ blockTag
1858
+ }) === concatHex(["0xef0100", authorization_ox.address])) return await verifyErc1271(client, {
1859
+ address,
1860
+ blockNumber,
1861
+ blockTag,
1862
+ hash,
1863
+ signature
1864
+ });
1865
+ const authorization = {
1866
+ address: authorization_ox.address,
1867
+ chainId: Number(authorization_ox.chainId),
1868
+ nonce: Number(authorization_ox.nonce),
1869
+ r: numberToHex(authorization_ox.r, { size: 32 }),
1870
+ s: numberToHex(authorization_ox.s, { size: 32 }),
1871
+ yParity: authorization_ox.yParity
1872
+ };
1873
+ if (!await verifyAuthorization({
1874
+ address,
1875
+ authorization
1876
+ })) throw new VerificationError();
1877
+ const results = await getAction(client, readContract, "readContract")({
1878
+ ...multicallAddress ? { address: multicallAddress } : { code: multicall3Bytecode },
1879
+ authorizationList: [authorization],
1880
+ abi: multicall3Abi,
1881
+ blockNumber,
1882
+ blockTag: "pending",
1883
+ functionName: "aggregate3",
1884
+ args: [[...initData ? [{
1885
+ allowFailure: true,
1886
+ target: to ?? address,
1887
+ callData: initData
1888
+ }] : [], {
1889
+ allowFailure: true,
1890
+ target: address,
1891
+ callData: encodeFunctionData({
1892
+ abi: erc1271Abi,
1893
+ functionName: "isValidSignature",
1894
+ args: [hash, signature]
1895
+ })
1896
+ }]]
1897
+ });
1898
+ if ((results[results.length - 1]?.returnData)?.startsWith("0x1626ba7e")) return true;
1899
+ throw new VerificationError();
1900
+ }
1901
+ /** @internal */
1902
+ async function verifyErc6492(client, parameters) {
1903
+ const { address, factory, factoryData, hash, signature, verifierAddress, ...rest } = parameters;
1904
+ const wrappedSignature = await (async () => {
1905
+ if (!factory && !factoryData) return signature;
1906
+ if (validate(signature)) return signature;
1907
+ return wrap({
1908
+ data: factoryData,
1909
+ signature,
1910
+ to: factory
1911
+ });
1912
+ })();
1913
+ const args = verifierAddress ? {
1914
+ to: verifierAddress,
1915
+ data: encodeFunctionData({
1916
+ abi: erc6492SignatureValidatorAbi,
1917
+ functionName: "isValidSig",
1918
+ args: [
1919
+ address,
1920
+ hash,
1921
+ wrappedSignature
1922
+ ]
1923
+ }),
1924
+ ...rest
1925
+ } : {
1926
+ data: encodeDeployData({
1927
+ abi: erc6492SignatureValidatorAbi,
1928
+ args: [
1929
+ address,
1930
+ hash,
1931
+ wrappedSignature
1932
+ ],
1933
+ bytecode: erc6492SignatureValidatorByteCode
1934
+ }),
1935
+ ...rest
1936
+ };
1937
+ const { data } = await getAction(client, call, "call")(args).catch((error) => {
1938
+ if (error instanceof CallExecutionError) throw new VerificationError();
1939
+ throw error;
1940
+ });
1941
+ if (hexToBool(data ?? "0x0")) return true;
1942
+ throw new VerificationError();
1943
+ }
1944
+ /** @internal */
1945
+ async function verifyErc1271(client, parameters) {
1946
+ const { address, blockNumber, blockTag, hash, signature } = parameters;
1947
+ if ((await getAction(client, readContract, "readContract")({
1948
+ address,
1949
+ abi: erc1271Abi,
1950
+ args: [hash, signature],
1951
+ blockNumber,
1952
+ blockTag,
1953
+ functionName: "isValidSignature"
1954
+ }).catch((error) => {
1955
+ if (error instanceof ContractFunctionExecutionError) throw new VerificationError();
1956
+ throw error;
1957
+ })).startsWith("0x1626ba7e")) return true;
1958
+ throw new VerificationError();
1959
+ }
1960
+ var VerificationError = class extends Error {};
1961
+ //#endregion
1962
+ //#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/clients/transports/createTransport.js
1963
+ /**
1964
+ * @description Creates an transport intended to be used with a client.
1965
+ */
1966
+ function createTransport({ key, methods, name, request, retryCount = 3, retryDelay = 150, timeout, type }, value) {
1967
+ const uid$1 = uid();
1968
+ return {
1969
+ config: {
1970
+ key,
1971
+ methods,
1972
+ name,
1973
+ request,
1974
+ retryCount,
1975
+ retryDelay,
1976
+ timeout,
1977
+ type
1978
+ },
1979
+ request: buildRequest(request, {
1980
+ methods,
1981
+ retryCount,
1982
+ retryDelay,
1983
+ uid: uid$1
1984
+ }),
1985
+ value
1986
+ };
1987
+ }
1988
+ //#endregion
1989
+ //#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/errors/transport.js
1990
+ var UrlRequiredError = class extends BaseError$1 {
1991
+ constructor() {
1992
+ super("No URL was provided to the Transport. Please provide a valid RPC URL to the Transport.", {
1993
+ docsPath: "/docs/clients/intro",
1994
+ name: "UrlRequiredError"
1995
+ });
1996
+ }
1997
+ };
1998
+ //#endregion
1999
+ //#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/clients/transports/http.js
2000
+ /**
2001
+ * @description Creates a HTTP transport that connects to a JSON-RPC API.
2002
+ */
2003
+ function http(url, config = {}) {
2004
+ const { batch, fetchFn, fetchOptions, key = "http", methods, name = "HTTP JSON-RPC", onFetchRequest, onFetchResponse, retryDelay, raw } = config;
2005
+ return ({ chain, retryCount: retryCount_, timeout: timeout_ }) => {
2006
+ const { batchSize = 1e3, wait = 0 } = typeof batch === "object" ? batch : {};
2007
+ const retryCount = config.retryCount ?? retryCount_;
2008
+ const timeout = timeout_ ?? config.timeout ?? 1e4;
2009
+ const url_ = url || chain?.rpcUrls.default.http[0];
2010
+ if (!url_) throw new UrlRequiredError();
2011
+ const rpcClient = getHttpRpcClient(url_, {
2012
+ fetchFn,
2013
+ fetchOptions,
2014
+ onRequest: onFetchRequest,
2015
+ onResponse: onFetchResponse,
2016
+ timeout
2017
+ });
2018
+ return createTransport({
2019
+ key,
2020
+ methods,
2021
+ name,
2022
+ async request({ method, params }) {
2023
+ const body = {
2024
+ method,
2025
+ params
2026
+ };
2027
+ const { schedule } = createBatchScheduler({
2028
+ id: url_,
2029
+ wait,
2030
+ shouldSplitBatch(requests) {
2031
+ return requests.length > batchSize;
2032
+ },
2033
+ fn: (body) => rpcClient.request({ body }),
2034
+ sort: (a, b) => a.id - b.id
2035
+ });
2036
+ const fn = async (body) => batch ? schedule(body) : [await rpcClient.request({ body })];
2037
+ const [{ error, result }] = await fn(body);
2038
+ if (raw) return {
2039
+ error,
2040
+ result
2041
+ };
2042
+ if (error) throw new RpcRequestError({
2043
+ body,
2044
+ error,
2045
+ url: url_
2046
+ });
2047
+ return result;
2048
+ },
2049
+ retryCount,
2050
+ retryDelay,
2051
+ timeout,
2052
+ type: "http"
2053
+ }, {
2054
+ fetchOptions,
2055
+ url: url_
2056
+ });
2057
+ };
2058
+ }
2059
+ //#endregion
2060
+ export { createContractEventFilter as C, decodeEventLog as S, encodeEventTopics as T, poll as _, getTransactionReceipt as a, getLogs as b, defineChain as c, createClient as d, withRetry as f, getBlockNumber as g, getFilterChanges as h, multicall as i, extendSchema as l, uninstallFilter as m, createTransport as n, fromRpcList as o, watchContractEvent as p, verifyHash as r, toRpcList as s, http as t, getCode as u, observe as v, createFilterRequestScope as w, parseEventLogs as x, getContractEvents as y };