x402-proxy 0.10.12 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/{Credential-0iRzpJkF.js → Mcp-CKylLH8N.js} +209 -211
- package/dist/accounts-D5u2KBgr.js +4 -0
- package/dist/{hashTypedData-CtEdfx4y.js → accounts-D9KsVVpJ.js} +228 -3
- package/dist/{auth-J9VuNMoG.js → auth-CaCZiNCk.js} +3 -3
- package/dist/bin/cli.js +46 -51
- package/dist/{decodeFunctionData-JPOUdvil.js → call-CNxk2xpg.js} +2084 -144
- package/dist/{decodeFunctionData-DuFcwhC_.js → call-DdUUzMfg.js} +11 -16
- package/dist/{ccip-C6CQOJYv.js → ccip-Cc1Fdazz.js} +1 -1
- package/dist/{ccip-Bx-zoUCJ.js → ccip-IumNC20V.js} +13 -3
- package/dist/{ccip-C2k1DD1T.js → ccip-JDVib6lf.js} +1 -1
- package/dist/{ccip-RZzsZ5Mv.js → ccip-RzF9aX_O.js} +3 -4
- package/dist/{chain-CafcHffR.js → chain-C_3Km9Dx.js} +1 -1
- package/dist/{client-Bcl2uC6u.js → client-C2DwSbYN.js} +1 -2
- package/dist/{Sse-DGR-tH7K.js → client-DqtxTnu6.js} +10249 -6224
- package/dist/client-DuqEc8Iw.js +3 -0
- package/dist/{client-DZV1cVsW.js → client-uAaF6lv2.js} +2 -2
- package/dist/{derive-DNUl8LU9.js → config-cyNyKO4-.js} +1024 -919
- package/dist/{dist-DM5_F3r5.js → dist-CFt2UZ4W.js} +1 -1
- package/dist/{dist-DxJCYyL5.js → dist-Cwt2qrTK.js} +2 -2
- package/dist/{helpers-ChcFbdC0.js → helpers-DebIs_21.js} +2 -2
- package/dist/{sendRawTransactionSync-DvSkhZtW.js → http-J0KYM-2Y.js} +2186 -169
- package/dist/index.d.ts +0 -1
- package/dist/index.js +30107 -771
- package/dist/{index.node-l8K03uWn.js → index.node-xc-jRJ78.js} +1 -1
- package/dist/{localBatchGatewayRequest-DOdQ9bR7.js → localBatchGatewayRequest-0gr8vzH3.js} +14 -2
- package/dist/{localBatchGatewayRequest-DQkbZaSy.js → localBatchGatewayRequest-CBsFXIAU.js} +2 -2
- package/dist/{localBatchGatewayRequest-C-RPJyDO.js → localBatchGatewayRequest-CPqqSJcB.js} +2 -2
- package/dist/{schemas-BxMFYNbH.js → schemas-DzZjufD1.js} +1 -1
- package/dist/{secp256k1-BZpiyffY.js → secp256k1-Bp7LcNvI.js} +2 -7
- package/dist/secp256k1-BsaSkXlH.js +2 -0
- package/dist/{secp256k1-BjenrLl5.js → secp256k1-BwSAYyif.js} +2 -2
- package/dist/secp256k1-CHAXu2gP.js +3 -0
- package/dist/{server-D2apWWY9.js → server-Dbsk9dql.js} +2 -2
- package/dist/setup-BdSfEdx4.js +3 -0
- package/dist/{setup-BY4J49Lv.js → setup-C10O8N36.js} +16 -33
- package/dist/{hmac-59IlS_by.js → sha2-XLg3s2a9.js} +81 -81
- package/dist/{sha256-FAs0qeni.js → sha256-DCLdwsRU.js} +1 -1
- package/dist/{sha3-DbMJRJ3C.js → sha3-03id956K.js} +1 -1
- package/dist/{sha3-CYkWM8Xa.js → sha3-VSia5eGE.js} +1 -1
- package/dist/{sse-qIEKrJEZ.js → sse-kba68iqF.js} +2 -2
- package/dist/status-B2xUewrq.js +3 -0
- package/dist/{status-CD_fCzGf.js → status-DjZdIeES.js} +2 -3
- package/dist/{stdio-BfDjLLnd.js → stdio-CdmkLt8r.js} +3 -3
- package/dist/{streamableHttp-BkayeoEQ.js → streamableHttp-DRntYTFN.js} +2 -2
- package/dist/{types-BmyZIQ8G.js → types-BQ17ZF7g.js} +1 -1
- package/dist/{types-DlqDf-zE.js → types-DH9rDVeP.js} +1 -1
- package/dist/{utils-SeGHMW9O.js → utils-psFtUKLa.js} +53 -53
- package/dist/wallet-BsCgqUun.js +3 -0
- package/dist/{wallet-C4RiduwM.js → wallet-CUCoLEqs.js} +179 -147
- package/package.json +1 -1
- package/dist/Mcp-CSyD7Hxz.js +0 -10
- package/dist/Sse-C-KDPYh0.js +0 -16482
- package/dist/accounts-DsuvWwph.js +0 -232
- package/dist/accounts-DzvAlQRn.js +0 -5
- package/dist/accounts-IG-Cmrwy.js +0 -229
- package/dist/chain-DwfP5RGZ.js +0 -1968
- package/dist/chunk-DBEY4PJZ.js +0 -16
- package/dist/client-1XQsO-Eh.js +0 -5152
- package/dist/client-Co7Fg1lv.js +0 -6388
- package/dist/config-BUQsit4s.js +0 -3
- package/dist/config-DR1Fs_wL.js +0 -6600
- package/dist/config-rvKA3SYT.js +0 -96
- package/dist/hashTypedData-BHmP9dBd.js +0 -859
- package/dist/http-BAtucMbS.js +0 -2060
- package/dist/isAddressEqual-BLrd1Hg1.js +0 -9
- package/dist/isAddressEqual-DsAqfQOD.js +0 -10
- package/dist/parseUnits-CApwcKSD.js +0 -49
- package/dist/parseUnits-cMO2udMe.js +0 -48
- package/dist/secp256k1-CLPUX17u.js +0 -3
- package/dist/setup-wMOAgrsN.js +0 -3
- package/dist/status-_TcPMyzr.js +0 -3
- package/dist/tempo-BcTkftHK.js +0 -17
- package/dist/tempo-Bs_aydgm.js +0 -18
- package/dist/wallet-BymEHYms.js +0 -3
- /package/dist/{api-CUzmQvTQ.js → api-B5mo8tpE.js} +0 -0
- /package/dist/{dist-C2YO6HSQ.js → dist-CvV4mGO6.js} +0 -0
- /package/dist/{index.node-DPDV8w2j.js → index.node-DCvOPMK7.js} +0 -0
- /package/dist/{utils-BYjkXZDF.js → utils-B1qOlJzL.js} +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { $ as
|
|
3
|
-
import {
|
|
4
|
-
import { t as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
2
|
+
import { $ as BaseError, $t as parseAbiParameter, At as UnknownRpcError, B as from$6, Bt as ContractFunctionExecutionError, C as from$7, Ct as ProviderDisconnectedError, D as fromString$1, Dt as TransactionRejectedRpcError, E as fromNumber, Et as SwitchChainError, F as toNumber$1, Ft as WalletConnectSessionSettlementError, G as slice$1, H as fromString, Ht as ContractFunctionZeroDataError, It as HttpRequestError, J as toNumber, Jt as encodeFunctionData, K as toBigInt, Kt as decodeAbiParameters, L as trimLeft$1, Lt as RpcRequestError, M as slice, Mt as UnsupportedNonOptionalCapabilityError, Nt as UnsupportedProviderMethodError, O as padLeft, Ot as UnauthorizedProviderError, Pt as UserRejectedRequestError, Q as stringify, Qt as parseStructs, R as validate$4, Rt as TimeoutError, S as concat, St as ParseRpcError, T as fromBytes$2, Tt as ResourceUnavailableRpcError, Ut as RawContractError, V as fromHex$3, Vt as ContractFunctionRevertedError, W as size$2, X as trimLeft, Y as toString, Yt as getAbiItem, Z as validate$5, Zt as toEventSelector, _t as InvalidRequestRpcError, a as getChainContractAddress, an as modifiers, at as formatTransactionRequest, b as InvalidLengthError, bt as MethodNotFoundRpcError, c as erc6492SignatureValidatorByteCode, ct as getNodeError, dt as BundleTooLargeError, et as decodeFunctionResult, f as erc1271Abi, ft as ChainDisconnectedError, gt as InvalidParamsRpcError, ht as InvalidInputRpcError, in as isStructSignature, j as size$1, jt as UnsupportedChainIdError, k as padRight, kt as UnknownBundleIdError, l as multicall3Bytecode, lt as AtomicReadyWalletRejectedUpgradeError, m as multicall3Abi, mt as InternalRpcError, n as createBatchScheduler, nn as InvalidAbiParametersError, nt as assertRequest, o as encodeDeployData, ot as defineFormatter, p as erc6492SignatureValidatorAbi, pt as DuplicateIdError, q as toBoolean, rt as serializeStateOverride, sn as formatAbiParameters, st as extract$1, t as call, tn as splitParameters, tt as isAddressEqual, ut as AtomicityNotSupportedError, vt as JsonRpcVersionUnsupportedError, w as fromBoolean, wt as ResourceNotFoundRpcError, xt as MethodNotSupportedRpcError, y as IntegerOutOfRangeError, yt as LimitExceededRpcError, zt as CallExecutionError } from "./call-DdUUzMfg.js";
|
|
3
|
+
import { t as keccak_256 } from "./sha3-VSia5eGE.js";
|
|
4
|
+
import { t as sha256$1 } from "./sha256-DCLdwsRU.js";
|
|
5
|
+
import { t as secp256k1 } from "./secp256k1-BwSAYyif.js";
|
|
6
|
+
import { $ as toBytes$1, A as formatGwei, E as TransactionReceiptNotFoundError, F as parseAccount, Ft as formatAbiItem, I as encodeAbiParameters, J as LruMap$1, M as stringify$1, Mt as BaseError$1, Nt as size$3, Ot as DecodeLogDataMismatch, P as PositionOutOfBoundsError$1, Pt as isHex, St as AbiEventSignatureNotFoundError, W as concatHex, X as keccak256$1, at as hexToBigInt, bt as AbiEventNotFoundError, et as bytesToHex, gt as AbiDecodingZeroDataError, ht as AbiDecodingDataSizeTooSmallError, j as formatEther, k as prettyPrint, kt as DecodeLogTopicsMismatch, nt as stringToHex, ot as hexToBool, q as getAddress, rt as toHex$3, st as hexToNumber, tt as numberToHex, v as UnknownNodeError, w as TransactionExecutionError, xt as AbiEventSignatureEmptyTopicsError } from "./chain-C_3Km9Dx.js";
|
|
7
|
+
import { C as blobsToProofs, D as publicKeyToAddress, S as commitmentsToVersionedHashes, T as hashAuthorization, b as getTransactionType, c as serializeSignature, w as blobsToCommitments, x as toBlobSidecars } from "./accounts-D9KsVVpJ.js";
|
|
8
8
|
//#region node_modules/.pnpm/abitype@1.2.3_typescript@5.9.3_zod@4.3.6/node_modules/abitype/dist/esm/human-readable/parseAbiParameters.js
|
|
9
9
|
/**
|
|
10
10
|
* Parses human-readable ABI parameters into {@link AbiParameter}s
|
|
@@ -63,6 +63,116 @@ function getAction(client, actionFn, name) {
|
|
|
63
63
|
return (params) => actionFn(client, params);
|
|
64
64
|
}
|
|
65
65
|
//#endregion
|
|
66
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/errors/log.js
|
|
67
|
+
var FilterTypeNotSupportedError = class extends BaseError$1 {
|
|
68
|
+
constructor(type) {
|
|
69
|
+
super(`Filter type "${type}" is not supported.`, { name: "FilterTypeNotSupportedError" });
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/utils/abi/encodeEventTopics.js
|
|
74
|
+
const docsPath$1 = "/docs/contract/encodeEventTopics";
|
|
75
|
+
function encodeEventTopics(parameters) {
|
|
76
|
+
const { abi, eventName, args } = parameters;
|
|
77
|
+
let abiItem = abi[0];
|
|
78
|
+
if (eventName) {
|
|
79
|
+
const item = getAbiItem({
|
|
80
|
+
abi,
|
|
81
|
+
name: eventName
|
|
82
|
+
});
|
|
83
|
+
if (!item) throw new AbiEventNotFoundError(eventName, { docsPath: docsPath$1 });
|
|
84
|
+
abiItem = item;
|
|
85
|
+
}
|
|
86
|
+
if (abiItem.type !== "event") throw new AbiEventNotFoundError(void 0, { docsPath: docsPath$1 });
|
|
87
|
+
const signature = toEventSelector(formatAbiItem(abiItem));
|
|
88
|
+
let topics = [];
|
|
89
|
+
if (args && "inputs" in abiItem) {
|
|
90
|
+
const indexedInputs = abiItem.inputs?.filter((param) => "indexed" in param && param.indexed);
|
|
91
|
+
const args_ = Array.isArray(args) ? args : Object.values(args).length > 0 ? indexedInputs?.map((x) => args[x.name]) ?? [] : [];
|
|
92
|
+
if (args_.length > 0) topics = indexedInputs?.map((param, i) => {
|
|
93
|
+
if (Array.isArray(args_[i])) return args_[i].map((_, j) => encodeArg({
|
|
94
|
+
param,
|
|
95
|
+
value: args_[i][j]
|
|
96
|
+
}));
|
|
97
|
+
return typeof args_[i] !== "undefined" && args_[i] !== null ? encodeArg({
|
|
98
|
+
param,
|
|
99
|
+
value: args_[i]
|
|
100
|
+
}) : null;
|
|
101
|
+
}) ?? [];
|
|
102
|
+
}
|
|
103
|
+
return [signature, ...topics];
|
|
104
|
+
}
|
|
105
|
+
function encodeArg({ param, value }) {
|
|
106
|
+
if (param.type === "string" || param.type === "bytes") return keccak256$1(toBytes$1(value));
|
|
107
|
+
if (param.type === "tuple" || param.type.match(/^(.*)\[(\d+)?\]$/)) throw new FilterTypeNotSupportedError(param.type);
|
|
108
|
+
return encodeAbiParameters([param], [value]);
|
|
109
|
+
}
|
|
110
|
+
//#endregion
|
|
111
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/utils/filters/createFilterRequestScope.js
|
|
112
|
+
/**
|
|
113
|
+
* Scopes `request` to the filter ID. If the client is a fallback, it will
|
|
114
|
+
* listen for responses and scope the child transport `request` function
|
|
115
|
+
* to the successful filter ID.
|
|
116
|
+
*/
|
|
117
|
+
function createFilterRequestScope(client, { method }) {
|
|
118
|
+
const requestMap = {};
|
|
119
|
+
if (client.transport.type === "fallback") client.transport.onResponse?.(({ method: method_, response: id, status, transport }) => {
|
|
120
|
+
if (status === "success" && method === method_) requestMap[id] = transport.request;
|
|
121
|
+
});
|
|
122
|
+
return ((id) => requestMap[id] || client.request);
|
|
123
|
+
}
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/actions/public/createContractEventFilter.js
|
|
126
|
+
/**
|
|
127
|
+
* 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).
|
|
128
|
+
*
|
|
129
|
+
* - Docs: https://viem.sh/docs/contract/createContractEventFilter
|
|
130
|
+
*
|
|
131
|
+
* @param client - Client to use
|
|
132
|
+
* @param parameters - {@link CreateContractEventFilterParameters}
|
|
133
|
+
* @returns [`Filter`](https://viem.sh/docs/glossary/types#filter). {@link CreateContractEventFilterReturnType}
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* import { createPublicClient, http, parseAbi } from 'viem'
|
|
137
|
+
* import { mainnet } from 'viem/chains'
|
|
138
|
+
* import { createContractEventFilter } from 'viem/contract'
|
|
139
|
+
*
|
|
140
|
+
* const client = createPublicClient({
|
|
141
|
+
* chain: mainnet,
|
|
142
|
+
* transport: http(),
|
|
143
|
+
* })
|
|
144
|
+
* const filter = await createContractEventFilter(client, {
|
|
145
|
+
* abi: parseAbi(['event Transfer(address indexed, address indexed, uint256)']),
|
|
146
|
+
* })
|
|
147
|
+
*/
|
|
148
|
+
async function createContractEventFilter(client, parameters) {
|
|
149
|
+
const { address, abi, args, eventName, fromBlock, strict, toBlock } = parameters;
|
|
150
|
+
const getRequest = createFilterRequestScope(client, { method: "eth_newFilter" });
|
|
151
|
+
const topics = eventName ? encodeEventTopics({
|
|
152
|
+
abi,
|
|
153
|
+
args,
|
|
154
|
+
eventName
|
|
155
|
+
}) : void 0;
|
|
156
|
+
const id = await client.request({
|
|
157
|
+
method: "eth_newFilter",
|
|
158
|
+
params: [{
|
|
159
|
+
address,
|
|
160
|
+
fromBlock: typeof fromBlock === "bigint" ? numberToHex(fromBlock) : fromBlock,
|
|
161
|
+
toBlock: typeof toBlock === "bigint" ? numberToHex(toBlock) : toBlock,
|
|
162
|
+
topics
|
|
163
|
+
}]
|
|
164
|
+
});
|
|
165
|
+
return {
|
|
166
|
+
abi,
|
|
167
|
+
args,
|
|
168
|
+
eventName,
|
|
169
|
+
id,
|
|
170
|
+
request: getRequest(id),
|
|
171
|
+
strict: Boolean(strict),
|
|
172
|
+
type: "event"
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
//#endregion
|
|
66
176
|
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/utils/errors/getContractError.js
|
|
67
177
|
const EXECUTION_REVERTED_ERROR_CODE = 3;
|
|
68
178
|
function getContractError(err, { abi, address, args, docsPath, functionName, sender }) {
|
|
@@ -94,7 +204,7 @@ function getContractError(err, { abi, address, args, docsPath, functionName, sen
|
|
|
94
204
|
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/utils/signature/recoverPublicKey.js
|
|
95
205
|
async function recoverPublicKey$1({ hash, signature }) {
|
|
96
206
|
const hashHex = isHex(hash) ? hash : toHex$3(hash);
|
|
97
|
-
const { secp256k1 } = await import("./secp256k1-
|
|
207
|
+
const { secp256k1 } = await import("./secp256k1-CHAXu2gP.js");
|
|
98
208
|
return `0x${(() => {
|
|
99
209
|
if (typeof signature === "object" && "r" in signature && "s" in signature) {
|
|
100
210
|
const { r, s, v, yParity } = signature;
|
|
@@ -102,7 +212,7 @@ async function recoverPublicKey$1({ hash, signature }) {
|
|
|
102
212
|
return new secp256k1.Signature(hexToBigInt(r), hexToBigInt(s)).addRecoveryBit(recoveryBit);
|
|
103
213
|
}
|
|
104
214
|
const signatureHex = isHex(signature) ? signature : toHex$3(signature);
|
|
105
|
-
if (size$
|
|
215
|
+
if (size$3(signatureHex) !== 65) throw new Error("invalid signature length");
|
|
106
216
|
const recoveryBit = toRecoveryBit(hexToNumber(`0x${signatureHex.slice(130)}`));
|
|
107
217
|
return secp256k1.Signature.fromCompact(signatureHex.substring(2, 130)).addRecoveryBit(recoveryBit);
|
|
108
218
|
})().recoverPublicKey(hashHex.substring(2)).toHex(false)}`;
|
|
@@ -984,6 +1094,295 @@ function formatLog(log, { args, eventName } = {}) {
|
|
|
984
1094
|
};
|
|
985
1095
|
}
|
|
986
1096
|
//#endregion
|
|
1097
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/utils/abi/decodeEventLog.js
|
|
1098
|
+
const docsPath = "/docs/contract/decodeEventLog";
|
|
1099
|
+
function decodeEventLog(parameters) {
|
|
1100
|
+
const { abi, data, strict: strict_, topics } = parameters;
|
|
1101
|
+
const strict = strict_ ?? true;
|
|
1102
|
+
const [signature, ...argTopics] = topics;
|
|
1103
|
+
if (!signature) throw new AbiEventSignatureEmptyTopicsError({ docsPath });
|
|
1104
|
+
const abiItem = abi.find((x) => x.type === "event" && signature === toEventSelector(formatAbiItem(x)));
|
|
1105
|
+
if (!(abiItem && "name" in abiItem) || abiItem.type !== "event") throw new AbiEventSignatureNotFoundError(signature, { docsPath });
|
|
1106
|
+
const { name, inputs } = abiItem;
|
|
1107
|
+
const isUnnamed = inputs?.some((x) => !("name" in x && x.name));
|
|
1108
|
+
const args = isUnnamed ? [] : {};
|
|
1109
|
+
const indexedInputs = inputs.map((x, i) => [x, i]).filter(([x]) => "indexed" in x && x.indexed);
|
|
1110
|
+
const missingIndexedInputs = [];
|
|
1111
|
+
for (let i = 0; i < indexedInputs.length; i++) {
|
|
1112
|
+
const [param, argIndex] = indexedInputs[i];
|
|
1113
|
+
const topic = argTopics[i];
|
|
1114
|
+
if (!topic) {
|
|
1115
|
+
if (strict) throw new DecodeLogTopicsMismatch({
|
|
1116
|
+
abiItem,
|
|
1117
|
+
param
|
|
1118
|
+
});
|
|
1119
|
+
missingIndexedInputs.push([param, argIndex]);
|
|
1120
|
+
continue;
|
|
1121
|
+
}
|
|
1122
|
+
args[isUnnamed ? argIndex : param.name || argIndex] = decodeTopic({
|
|
1123
|
+
param,
|
|
1124
|
+
value: topic
|
|
1125
|
+
});
|
|
1126
|
+
}
|
|
1127
|
+
const nonIndexedInputs = inputs.filter((x) => !("indexed" in x && x.indexed));
|
|
1128
|
+
const inputsToDecode = strict ? nonIndexedInputs : [...missingIndexedInputs.map(([param]) => param), ...nonIndexedInputs];
|
|
1129
|
+
if (inputsToDecode.length > 0) {
|
|
1130
|
+
if (data && data !== "0x") try {
|
|
1131
|
+
const decodedData = decodeAbiParameters(inputsToDecode, data);
|
|
1132
|
+
if (decodedData) {
|
|
1133
|
+
let dataIndex = 0;
|
|
1134
|
+
if (!strict) for (const [param, argIndex] of missingIndexedInputs) args[isUnnamed ? argIndex : param.name || argIndex] = decodedData[dataIndex++];
|
|
1135
|
+
if (isUnnamed) {
|
|
1136
|
+
for (let i = 0; i < inputs.length; i++) if (args[i] === void 0 && dataIndex < decodedData.length) args[i] = decodedData[dataIndex++];
|
|
1137
|
+
} else for (let i = 0; i < nonIndexedInputs.length; i++) args[nonIndexedInputs[i].name] = decodedData[dataIndex++];
|
|
1138
|
+
}
|
|
1139
|
+
} catch (err) {
|
|
1140
|
+
if (strict) {
|
|
1141
|
+
if (err instanceof AbiDecodingDataSizeTooSmallError || err instanceof PositionOutOfBoundsError$1) throw new DecodeLogDataMismatch({
|
|
1142
|
+
abiItem,
|
|
1143
|
+
data,
|
|
1144
|
+
params: inputsToDecode,
|
|
1145
|
+
size: size$3(data)
|
|
1146
|
+
});
|
|
1147
|
+
throw err;
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
else if (strict) throw new DecodeLogDataMismatch({
|
|
1151
|
+
abiItem,
|
|
1152
|
+
data: "0x",
|
|
1153
|
+
params: inputsToDecode,
|
|
1154
|
+
size: 0
|
|
1155
|
+
});
|
|
1156
|
+
}
|
|
1157
|
+
return {
|
|
1158
|
+
eventName: name,
|
|
1159
|
+
args: Object.values(args).length > 0 ? args : void 0
|
|
1160
|
+
};
|
|
1161
|
+
}
|
|
1162
|
+
function decodeTopic({ param, value }) {
|
|
1163
|
+
if (param.type === "string" || param.type === "bytes" || param.type === "tuple" || param.type.match(/^(.*)\[(\d+)?\]$/)) return value;
|
|
1164
|
+
return (decodeAbiParameters([param], value) || [])[0];
|
|
1165
|
+
}
|
|
1166
|
+
//#endregion
|
|
1167
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/utils/abi/parseEventLogs.js
|
|
1168
|
+
/**
|
|
1169
|
+
* Extracts & decodes logs matching the provided signature(s) (`abi` + optional `eventName`)
|
|
1170
|
+
* from a set of opaque logs.
|
|
1171
|
+
*
|
|
1172
|
+
* @param parameters - {@link ParseEventLogsParameters}
|
|
1173
|
+
* @returns The logs. {@link ParseEventLogsReturnType}
|
|
1174
|
+
*
|
|
1175
|
+
* @example
|
|
1176
|
+
* import { createClient, http } from 'viem'
|
|
1177
|
+
* import { mainnet } from 'viem/chains'
|
|
1178
|
+
* import { parseEventLogs } from 'viem/op-stack'
|
|
1179
|
+
*
|
|
1180
|
+
* const client = createClient({
|
|
1181
|
+
* chain: mainnet,
|
|
1182
|
+
* transport: http(),
|
|
1183
|
+
* })
|
|
1184
|
+
*
|
|
1185
|
+
* const receipt = await getTransactionReceipt(client, {
|
|
1186
|
+
* hash: '0xec23b2ba4bc59ba61554507c1b1bc91649e6586eb2dd00c728e8ed0db8bb37ea',
|
|
1187
|
+
* })
|
|
1188
|
+
*
|
|
1189
|
+
* const logs = parseEventLogs({ logs: receipt.logs })
|
|
1190
|
+
* // [{ args: { ... }, eventName: 'TransactionDeposited', ... }, ...]
|
|
1191
|
+
*/
|
|
1192
|
+
function parseEventLogs(parameters) {
|
|
1193
|
+
const { abi, args, logs, strict = true } = parameters;
|
|
1194
|
+
const eventName = (() => {
|
|
1195
|
+
if (!parameters.eventName) return void 0;
|
|
1196
|
+
if (Array.isArray(parameters.eventName)) return parameters.eventName;
|
|
1197
|
+
return [parameters.eventName];
|
|
1198
|
+
})();
|
|
1199
|
+
const abiTopics = abi.filter((abiItem) => abiItem.type === "event").map((abiItem) => ({
|
|
1200
|
+
abi: abiItem,
|
|
1201
|
+
selector: toEventSelector(abiItem)
|
|
1202
|
+
}));
|
|
1203
|
+
return logs.map((log) => {
|
|
1204
|
+
const formattedLog = typeof log.blockNumber === "string" ? formatLog(log) : log;
|
|
1205
|
+
const abiItems = abiTopics.filter((abiTopic) => formattedLog.topics[0] === abiTopic.selector);
|
|
1206
|
+
if (abiItems.length === 0) return null;
|
|
1207
|
+
let event;
|
|
1208
|
+
let abiItem;
|
|
1209
|
+
for (const item of abiItems) try {
|
|
1210
|
+
event = decodeEventLog({
|
|
1211
|
+
...formattedLog,
|
|
1212
|
+
abi: [item.abi],
|
|
1213
|
+
strict: true
|
|
1214
|
+
});
|
|
1215
|
+
abiItem = item;
|
|
1216
|
+
break;
|
|
1217
|
+
} catch {}
|
|
1218
|
+
if (!event && !strict) {
|
|
1219
|
+
abiItem = abiItems[0];
|
|
1220
|
+
try {
|
|
1221
|
+
event = decodeEventLog({
|
|
1222
|
+
data: formattedLog.data,
|
|
1223
|
+
topics: formattedLog.topics,
|
|
1224
|
+
abi: [abiItem.abi],
|
|
1225
|
+
strict: false
|
|
1226
|
+
});
|
|
1227
|
+
} catch {
|
|
1228
|
+
const isUnnamed = abiItem.abi.inputs?.some((x) => !("name" in x && x.name));
|
|
1229
|
+
return {
|
|
1230
|
+
...formattedLog,
|
|
1231
|
+
args: isUnnamed ? [] : {},
|
|
1232
|
+
eventName: abiItem.abi.name
|
|
1233
|
+
};
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
if (!event || !abiItem) return null;
|
|
1237
|
+
if (eventName && !eventName.includes(event.eventName)) return null;
|
|
1238
|
+
if (!includesArgs({
|
|
1239
|
+
args: event.args,
|
|
1240
|
+
inputs: abiItem.abi.inputs,
|
|
1241
|
+
matchArgs: args
|
|
1242
|
+
})) return null;
|
|
1243
|
+
return {
|
|
1244
|
+
...event,
|
|
1245
|
+
...formattedLog
|
|
1246
|
+
};
|
|
1247
|
+
}).filter(Boolean);
|
|
1248
|
+
}
|
|
1249
|
+
function includesArgs(parameters) {
|
|
1250
|
+
const { args, inputs, matchArgs } = parameters;
|
|
1251
|
+
if (!matchArgs) return true;
|
|
1252
|
+
if (!args) return false;
|
|
1253
|
+
function isEqual(input, value, arg) {
|
|
1254
|
+
try {
|
|
1255
|
+
if (input.type === "address") return isAddressEqual(value, arg);
|
|
1256
|
+
if (input.type === "string" || input.type === "bytes") return keccak256$1(toBytes$1(value)) === arg;
|
|
1257
|
+
return value === arg;
|
|
1258
|
+
} catch {
|
|
1259
|
+
return false;
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1262
|
+
if (Array.isArray(args) && Array.isArray(matchArgs)) return matchArgs.every((value, index) => {
|
|
1263
|
+
if (value === null || value === void 0) return true;
|
|
1264
|
+
const input = inputs[index];
|
|
1265
|
+
if (!input) return false;
|
|
1266
|
+
return (Array.isArray(value) ? value : [value]).some((value) => isEqual(input, value, args[index]));
|
|
1267
|
+
});
|
|
1268
|
+
if (typeof args === "object" && !Array.isArray(args) && typeof matchArgs === "object" && !Array.isArray(matchArgs)) return Object.entries(matchArgs).every(([key, value]) => {
|
|
1269
|
+
if (value === null || value === void 0) return true;
|
|
1270
|
+
const input = inputs.find((input) => input.name === key);
|
|
1271
|
+
if (!input) return false;
|
|
1272
|
+
return (Array.isArray(value) ? value : [value]).some((value) => isEqual(input, value, args[key]));
|
|
1273
|
+
});
|
|
1274
|
+
return false;
|
|
1275
|
+
}
|
|
1276
|
+
//#endregion
|
|
1277
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/actions/public/getLogs.js
|
|
1278
|
+
/**
|
|
1279
|
+
* Returns a list of event logs matching the provided parameters.
|
|
1280
|
+
*
|
|
1281
|
+
* - Docs: https://viem.sh/docs/actions/public/getLogs
|
|
1282
|
+
* - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/logs_event-logs
|
|
1283
|
+
* - JSON-RPC Methods: [`eth_getLogs`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getlogs)
|
|
1284
|
+
*
|
|
1285
|
+
* @param client - Client to use
|
|
1286
|
+
* @param parameters - {@link GetLogsParameters}
|
|
1287
|
+
* @returns A list of event logs. {@link GetLogsReturnType}
|
|
1288
|
+
*
|
|
1289
|
+
* @example
|
|
1290
|
+
* import { createPublicClient, http, parseAbiItem } from 'viem'
|
|
1291
|
+
* import { mainnet } from 'viem/chains'
|
|
1292
|
+
* import { getLogs } from 'viem/public'
|
|
1293
|
+
*
|
|
1294
|
+
* const client = createPublicClient({
|
|
1295
|
+
* chain: mainnet,
|
|
1296
|
+
* transport: http(),
|
|
1297
|
+
* })
|
|
1298
|
+
* const logs = await getLogs(client)
|
|
1299
|
+
*/
|
|
1300
|
+
async function getLogs(client, { address, blockHash, fromBlock, toBlock, event, events: events_, args, strict: strict_ } = {}) {
|
|
1301
|
+
const strict = strict_ ?? false;
|
|
1302
|
+
const events = events_ ?? (event ? [event] : void 0);
|
|
1303
|
+
let topics = [];
|
|
1304
|
+
if (events) {
|
|
1305
|
+
topics = [events.flatMap((event) => encodeEventTopics({
|
|
1306
|
+
abi: [event],
|
|
1307
|
+
eventName: event.name,
|
|
1308
|
+
args: events_ ? void 0 : args
|
|
1309
|
+
}))];
|
|
1310
|
+
if (event) topics = topics[0];
|
|
1311
|
+
}
|
|
1312
|
+
let logs;
|
|
1313
|
+
if (blockHash) logs = await client.request({
|
|
1314
|
+
method: "eth_getLogs",
|
|
1315
|
+
params: [{
|
|
1316
|
+
address,
|
|
1317
|
+
topics,
|
|
1318
|
+
blockHash
|
|
1319
|
+
}]
|
|
1320
|
+
});
|
|
1321
|
+
else logs = await client.request({
|
|
1322
|
+
method: "eth_getLogs",
|
|
1323
|
+
params: [{
|
|
1324
|
+
address,
|
|
1325
|
+
topics,
|
|
1326
|
+
fromBlock: typeof fromBlock === "bigint" ? numberToHex(fromBlock) : fromBlock,
|
|
1327
|
+
toBlock: typeof toBlock === "bigint" ? numberToHex(toBlock) : toBlock
|
|
1328
|
+
}]
|
|
1329
|
+
});
|
|
1330
|
+
const formattedLogs = logs.map((log) => formatLog(log));
|
|
1331
|
+
if (!events) return formattedLogs;
|
|
1332
|
+
return parseEventLogs({
|
|
1333
|
+
abi: events,
|
|
1334
|
+
args,
|
|
1335
|
+
logs: formattedLogs,
|
|
1336
|
+
strict
|
|
1337
|
+
});
|
|
1338
|
+
}
|
|
1339
|
+
//#endregion
|
|
1340
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/actions/public/getContractEvents.js
|
|
1341
|
+
/**
|
|
1342
|
+
* Returns a list of event logs emitted by a contract.
|
|
1343
|
+
*
|
|
1344
|
+
* - Docs: https://viem.sh/docs/contract/getContractEvents#getcontractevents
|
|
1345
|
+
* - JSON-RPC Methods: [`eth_getLogs`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getlogs)
|
|
1346
|
+
*
|
|
1347
|
+
* @param client - Client to use
|
|
1348
|
+
* @param parameters - {@link GetContractEventsParameters}
|
|
1349
|
+
* @returns A list of event logs. {@link GetContractEventsReturnType}
|
|
1350
|
+
*
|
|
1351
|
+
* @example
|
|
1352
|
+
* import { createClient, http } from 'viem'
|
|
1353
|
+
* import { mainnet } from 'viem/chains'
|
|
1354
|
+
* import { getContractEvents } from 'viem/public'
|
|
1355
|
+
* import { wagmiAbi } from './abi'
|
|
1356
|
+
*
|
|
1357
|
+
* const client = createClient({
|
|
1358
|
+
* chain: mainnet,
|
|
1359
|
+
* transport: http(),
|
|
1360
|
+
* })
|
|
1361
|
+
* const logs = await getContractEvents(client, {
|
|
1362
|
+
* address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
|
|
1363
|
+
* abi: wagmiAbi,
|
|
1364
|
+
* eventName: 'Transfer'
|
|
1365
|
+
* })
|
|
1366
|
+
*/
|
|
1367
|
+
async function getContractEvents(client, parameters) {
|
|
1368
|
+
const { abi, address, args, blockHash, eventName, fromBlock, toBlock, strict } = parameters;
|
|
1369
|
+
const event = eventName ? getAbiItem({
|
|
1370
|
+
abi,
|
|
1371
|
+
name: eventName
|
|
1372
|
+
}) : void 0;
|
|
1373
|
+
const events = !event ? abi.filter((x) => x.type === "event") : void 0;
|
|
1374
|
+
return getAction(client, getLogs, "getLogs")({
|
|
1375
|
+
address,
|
|
1376
|
+
args,
|
|
1377
|
+
blockHash,
|
|
1378
|
+
event,
|
|
1379
|
+
events,
|
|
1380
|
+
fromBlock,
|
|
1381
|
+
toBlock,
|
|
1382
|
+
strict
|
|
1383
|
+
});
|
|
1384
|
+
}
|
|
1385
|
+
//#endregion
|
|
987
1386
|
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/actions/public/readContract.js
|
|
988
1387
|
/**
|
|
989
1388
|
* Calls a read-only function on a contract, and returns the response.
|
|
@@ -1046,119 +1445,995 @@ async function readContract(client, parameters) {
|
|
|
1046
1445
|
}
|
|
1047
1446
|
}
|
|
1048
1447
|
//#endregion
|
|
1049
|
-
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/
|
|
1448
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/utils/observe.js
|
|
1449
|
+
/** @internal */
|
|
1450
|
+
const listenersCache = /* @__PURE__ */ new Map();
|
|
1451
|
+
/** @internal */
|
|
1452
|
+
const cleanupCache = /* @__PURE__ */ new Map();
|
|
1453
|
+
let callbackCount = 0;
|
|
1050
1454
|
/**
|
|
1051
|
-
*
|
|
1052
|
-
*
|
|
1053
|
-
*
|
|
1054
|
-
* - JSON-RPC Method: [`eth_sendRawTransaction`](https://ethereum.github.io/execution-apis/api-documentation/)
|
|
1055
|
-
*
|
|
1056
|
-
* @param client - Client to use
|
|
1057
|
-
* @param parameters - {@link SendRawTransactionParameters}
|
|
1058
|
-
* @returns The transaction hash. {@link SendRawTransactionReturnType}
|
|
1059
|
-
*
|
|
1060
|
-
* @example
|
|
1061
|
-
* import { createWalletClient, custom } from 'viem'
|
|
1062
|
-
* import { mainnet } from 'viem/chains'
|
|
1063
|
-
* import { sendRawTransaction } from 'viem/wallet'
|
|
1064
|
-
*
|
|
1065
|
-
* const client = createWalletClient({
|
|
1066
|
-
* chain: mainnet,
|
|
1067
|
-
* transport: custom(window.ethereum),
|
|
1068
|
-
* })
|
|
1069
|
-
*
|
|
1070
|
-
* const hash = await sendRawTransaction(client, {
|
|
1071
|
-
* serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33'
|
|
1072
|
-
* })
|
|
1455
|
+
* @description Sets up an observer for a given function. If another function
|
|
1456
|
+
* is set up under the same observer id, the function will only be called once
|
|
1457
|
+
* for both instances of the observer.
|
|
1073
1458
|
*/
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1459
|
+
function observe(observerId, callbacks, fn) {
|
|
1460
|
+
const callbackId = ++callbackCount;
|
|
1461
|
+
const getListeners = () => listenersCache.get(observerId) || [];
|
|
1462
|
+
const unsubscribe = () => {
|
|
1463
|
+
const listeners = getListeners();
|
|
1464
|
+
listenersCache.set(observerId, listeners.filter((cb) => cb.id !== callbackId));
|
|
1465
|
+
};
|
|
1466
|
+
const unwatch = () => {
|
|
1467
|
+
const listeners = getListeners();
|
|
1468
|
+
if (!listeners.some((cb) => cb.id === callbackId)) return;
|
|
1469
|
+
const cleanup = cleanupCache.get(observerId);
|
|
1470
|
+
if (listeners.length === 1 && cleanup) {
|
|
1471
|
+
const p = cleanup();
|
|
1472
|
+
if (p instanceof Promise) p.catch(() => {});
|
|
1473
|
+
}
|
|
1474
|
+
unsubscribe();
|
|
1475
|
+
};
|
|
1476
|
+
const listeners = getListeners();
|
|
1477
|
+
listenersCache.set(observerId, [...listeners, {
|
|
1478
|
+
id: callbackId,
|
|
1479
|
+
fns: callbacks
|
|
1480
|
+
}]);
|
|
1481
|
+
if (listeners && listeners.length > 0) return unwatch;
|
|
1482
|
+
const emit = {};
|
|
1483
|
+
for (const key in callbacks) emit[key] = ((...args) => {
|
|
1484
|
+
const listeners = getListeners();
|
|
1485
|
+
if (listeners.length === 0) return;
|
|
1486
|
+
for (const listener of listeners) listener.fns[key]?.(...args);
|
|
1487
|
+
});
|
|
1488
|
+
const cleanup = fn(emit);
|
|
1489
|
+
if (typeof cleanup === "function") cleanupCache.set(observerId, cleanup);
|
|
1490
|
+
return unwatch;
|
|
1079
1491
|
}
|
|
1080
1492
|
//#endregion
|
|
1081
|
-
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/utils/
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1493
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/utils/wait.js
|
|
1494
|
+
async function wait(time) {
|
|
1495
|
+
return new Promise((res) => setTimeout(res, time));
|
|
1496
|
+
}
|
|
1497
|
+
//#endregion
|
|
1498
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/utils/poll.js
|
|
1499
|
+
/**
|
|
1500
|
+
* @description Polls a function at a specified interval.
|
|
1501
|
+
*/
|
|
1502
|
+
function poll(fn, { emitOnBegin, initialWaitTime, interval }) {
|
|
1503
|
+
let active = true;
|
|
1504
|
+
const unwatch = () => active = false;
|
|
1505
|
+
const watch = async () => {
|
|
1506
|
+
let data;
|
|
1507
|
+
if (emitOnBegin) data = await fn({ unpoll: unwatch });
|
|
1508
|
+
await wait(await initialWaitTime?.(data) ?? interval);
|
|
1509
|
+
const poll = async () => {
|
|
1510
|
+
if (!active) return;
|
|
1511
|
+
await fn({ unpoll: unwatch });
|
|
1512
|
+
await wait(interval);
|
|
1513
|
+
poll();
|
|
1514
|
+
};
|
|
1515
|
+
poll();
|
|
1099
1516
|
};
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
return receipt;
|
|
1517
|
+
watch();
|
|
1518
|
+
return unwatch;
|
|
1103
1519
|
}
|
|
1104
|
-
const defineTransactionReceipt = /* @__PURE__ */ defineFormatter("transactionReceipt", formatTransactionReceipt);
|
|
1105
1520
|
//#endregion
|
|
1106
|
-
//#region node_modules/.pnpm/
|
|
1521
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/utils/promise/withCache.js
|
|
1522
|
+
/** @internal */
|
|
1523
|
+
const promiseCache$1 = /* @__PURE__ */ new Map();
|
|
1524
|
+
/** @internal */
|
|
1525
|
+
const responseCache = /* @__PURE__ */ new Map();
|
|
1526
|
+
function getCache(cacheKey) {
|
|
1527
|
+
const buildCache = (cacheKey, cache) => ({
|
|
1528
|
+
clear: () => cache.delete(cacheKey),
|
|
1529
|
+
get: () => cache.get(cacheKey),
|
|
1530
|
+
set: (data) => cache.set(cacheKey, data)
|
|
1531
|
+
});
|
|
1532
|
+
const promise = buildCache(cacheKey, promiseCache$1);
|
|
1533
|
+
const response = buildCache(cacheKey, responseCache);
|
|
1534
|
+
return {
|
|
1535
|
+
clear: () => {
|
|
1536
|
+
promise.clear();
|
|
1537
|
+
response.clear();
|
|
1538
|
+
},
|
|
1539
|
+
promise,
|
|
1540
|
+
response
|
|
1541
|
+
};
|
|
1542
|
+
}
|
|
1107
1543
|
/**
|
|
1108
|
-
* @
|
|
1109
|
-
*
|
|
1110
|
-
* Map with a LRU (Least recently used) policy.
|
|
1111
|
-
* @see https://en.wikipedia.org/wiki/Cache_replacement_policies#LRU
|
|
1544
|
+
* @description Returns the result of a given promise, and caches the result for
|
|
1545
|
+
* subsequent invocations against a provided cache key.
|
|
1112
1546
|
*/
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
configurable: true,
|
|
1119
|
-
writable: true,
|
|
1120
|
-
value: void 0
|
|
1121
|
-
});
|
|
1122
|
-
this.maxSize = size;
|
|
1547
|
+
async function withCache(fn, { cacheKey, cacheTime = Number.POSITIVE_INFINITY }) {
|
|
1548
|
+
const cache = getCache(cacheKey);
|
|
1549
|
+
const response = cache.response.get();
|
|
1550
|
+
if (response && cacheTime > 0) {
|
|
1551
|
+
if (Date.now() - response.created.getTime() < cacheTime) return response.data;
|
|
1123
1552
|
}
|
|
1124
|
-
get(
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
super.set(key, value);
|
|
1129
|
-
}
|
|
1130
|
-
return value;
|
|
1553
|
+
let promise = cache.promise.get();
|
|
1554
|
+
if (!promise) {
|
|
1555
|
+
promise = fn();
|
|
1556
|
+
cache.promise.set(promise);
|
|
1131
1557
|
}
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
}
|
|
1138
|
-
return
|
|
1558
|
+
try {
|
|
1559
|
+
const data = await promise;
|
|
1560
|
+
cache.response.set({
|
|
1561
|
+
created: /* @__PURE__ */ new Date(),
|
|
1562
|
+
data
|
|
1563
|
+
});
|
|
1564
|
+
return data;
|
|
1565
|
+
} finally {
|
|
1566
|
+
cache.promise.clear();
|
|
1139
1567
|
}
|
|
1140
|
-
}
|
|
1141
|
-
const checksum$1 = { checksum: /* @__PURE__ */ new LruMap(8192) }.checksum;
|
|
1568
|
+
}
|
|
1142
1569
|
//#endregion
|
|
1143
|
-
//#region node_modules/.pnpm/
|
|
1570
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/actions/public/getBlockNumber.js
|
|
1571
|
+
const cacheKey = (id) => `blockNumber.${id}`;
|
|
1144
1572
|
/**
|
|
1145
|
-
*
|
|
1573
|
+
* Returns the number of the most recent block seen.
|
|
1146
1574
|
*
|
|
1147
|
-
*
|
|
1575
|
+
* - Docs: https://viem.sh/docs/actions/public/getBlockNumber
|
|
1576
|
+
* - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/blocks_fetching-blocks
|
|
1577
|
+
* - JSON-RPC Methods: [`eth_blockNumber`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_blocknumber)
|
|
1578
|
+
*
|
|
1579
|
+
* @param client - Client to use
|
|
1580
|
+
* @param parameters - {@link GetBlockNumberParameters}
|
|
1581
|
+
* @returns The number of the block. {@link GetBlockNumberReturnType}
|
|
1148
1582
|
*
|
|
1149
1583
|
* @example
|
|
1150
|
-
*
|
|
1151
|
-
* import {
|
|
1584
|
+
* import { createPublicClient, http } from 'viem'
|
|
1585
|
+
* import { mainnet } from 'viem/chains'
|
|
1586
|
+
* import { getBlockNumber } from 'viem/public'
|
|
1152
1587
|
*
|
|
1153
|
-
*
|
|
1154
|
-
*
|
|
1155
|
-
*
|
|
1588
|
+
* const client = createPublicClient({
|
|
1589
|
+
* chain: mainnet,
|
|
1590
|
+
* transport: http(),
|
|
1591
|
+
* })
|
|
1592
|
+
* const blockNumber = await getBlockNumber(client)
|
|
1593
|
+
* // 69420n
|
|
1594
|
+
*/
|
|
1595
|
+
async function getBlockNumber(client, { cacheTime = client.cacheTime } = {}) {
|
|
1596
|
+
const blockNumberHex = await withCache(() => client.request({ method: "eth_blockNumber" }), {
|
|
1597
|
+
cacheKey: cacheKey(client.uid),
|
|
1598
|
+
cacheTime
|
|
1599
|
+
});
|
|
1600
|
+
return BigInt(blockNumberHex);
|
|
1601
|
+
}
|
|
1602
|
+
//#endregion
|
|
1603
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/actions/public/getFilterChanges.js
|
|
1604
|
+
/**
|
|
1605
|
+
* Returns a list of logs or hashes based on a [Filter](/docs/glossary/terms#filter) since the last time it was called.
|
|
1156
1606
|
*
|
|
1157
|
-
*
|
|
1158
|
-
*
|
|
1607
|
+
* - Docs: https://viem.sh/docs/actions/public/getFilterChanges
|
|
1608
|
+
* - JSON-RPC Methods: [`eth_getFilterChanges`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getfilterchanges)
|
|
1159
1609
|
*
|
|
1160
|
-
*
|
|
1161
|
-
*
|
|
1610
|
+
* A Filter can be created from the following actions:
|
|
1611
|
+
*
|
|
1612
|
+
* - [`createBlockFilter`](https://viem.sh/docs/actions/public/createBlockFilter)
|
|
1613
|
+
* - [`createContractEventFilter`](https://viem.sh/docs/contract/createContractEventFilter)
|
|
1614
|
+
* - [`createEventFilter`](https://viem.sh/docs/actions/public/createEventFilter)
|
|
1615
|
+
* - [`createPendingTransactionFilter`](https://viem.sh/docs/actions/public/createPendingTransactionFilter)
|
|
1616
|
+
*
|
|
1617
|
+
* Depending on the type of filter, the return value will be different:
|
|
1618
|
+
*
|
|
1619
|
+
* - If the filter was created with `createContractEventFilter` or `createEventFilter`, it returns a list of logs.
|
|
1620
|
+
* - If the filter was created with `createPendingTransactionFilter`, it returns a list of transaction hashes.
|
|
1621
|
+
* - If the filter was created with `createBlockFilter`, it returns a list of block hashes.
|
|
1622
|
+
*
|
|
1623
|
+
* @param client - Client to use
|
|
1624
|
+
* @param parameters - {@link GetFilterChangesParameters}
|
|
1625
|
+
* @returns Logs or hashes. {@link GetFilterChangesReturnType}
|
|
1626
|
+
*
|
|
1627
|
+
* @example
|
|
1628
|
+
* // Blocks
|
|
1629
|
+
* import { createPublicClient, http } from 'viem'
|
|
1630
|
+
* import { mainnet } from 'viem/chains'
|
|
1631
|
+
* import { createBlockFilter, getFilterChanges } from 'viem/public'
|
|
1632
|
+
*
|
|
1633
|
+
* const client = createPublicClient({
|
|
1634
|
+
* chain: mainnet,
|
|
1635
|
+
* transport: http(),
|
|
1636
|
+
* })
|
|
1637
|
+
* const filter = await createBlockFilter(client)
|
|
1638
|
+
* const hashes = await getFilterChanges(client, { filter })
|
|
1639
|
+
*
|
|
1640
|
+
* @example
|
|
1641
|
+
* // Contract Events
|
|
1642
|
+
* import { createPublicClient, http, parseAbi } from 'viem'
|
|
1643
|
+
* import { mainnet } from 'viem/chains'
|
|
1644
|
+
* import { createContractEventFilter, getFilterChanges } from 'viem/public'
|
|
1645
|
+
*
|
|
1646
|
+
* const client = createPublicClient({
|
|
1647
|
+
* chain: mainnet,
|
|
1648
|
+
* transport: http(),
|
|
1649
|
+
* })
|
|
1650
|
+
* const filter = await createContractEventFilter(client, {
|
|
1651
|
+
* address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1652
|
+
* abi: parseAbi(['event Transfer(address indexed, address indexed, uint256)']),
|
|
1653
|
+
* eventName: 'Transfer',
|
|
1654
|
+
* })
|
|
1655
|
+
* const logs = await getFilterChanges(client, { filter })
|
|
1656
|
+
*
|
|
1657
|
+
* @example
|
|
1658
|
+
* // Raw Events
|
|
1659
|
+
* import { createPublicClient, http, parseAbiItem } from 'viem'
|
|
1660
|
+
* import { mainnet } from 'viem/chains'
|
|
1661
|
+
* import { createEventFilter, getFilterChanges } from 'viem/public'
|
|
1662
|
+
*
|
|
1663
|
+
* const client = createPublicClient({
|
|
1664
|
+
* chain: mainnet,
|
|
1665
|
+
* transport: http(),
|
|
1666
|
+
* })
|
|
1667
|
+
* const filter = await createEventFilter(client, {
|
|
1668
|
+
* address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1669
|
+
* event: parseAbiItem('event Transfer(address indexed, address indexed, uint256)'),
|
|
1670
|
+
* })
|
|
1671
|
+
* const logs = await getFilterChanges(client, { filter })
|
|
1672
|
+
*
|
|
1673
|
+
* @example
|
|
1674
|
+
* // Transactions
|
|
1675
|
+
* import { createPublicClient, http } from 'viem'
|
|
1676
|
+
* import { mainnet } from 'viem/chains'
|
|
1677
|
+
* import { createPendingTransactionFilter, getFilterChanges } from 'viem/public'
|
|
1678
|
+
*
|
|
1679
|
+
* const client = createPublicClient({
|
|
1680
|
+
* chain: mainnet,
|
|
1681
|
+
* transport: http(),
|
|
1682
|
+
* })
|
|
1683
|
+
* const filter = await createPendingTransactionFilter(client)
|
|
1684
|
+
* const hashes = await getFilterChanges(client, { filter })
|
|
1685
|
+
*/
|
|
1686
|
+
async function getFilterChanges(_client, { filter }) {
|
|
1687
|
+
const strict = "strict" in filter && filter.strict;
|
|
1688
|
+
const logs = await filter.request({
|
|
1689
|
+
method: "eth_getFilterChanges",
|
|
1690
|
+
params: [filter.id]
|
|
1691
|
+
});
|
|
1692
|
+
if (typeof logs[0] === "string") return logs;
|
|
1693
|
+
const formattedLogs = logs.map((log) => formatLog(log));
|
|
1694
|
+
if (!("abi" in filter) || !filter.abi) return formattedLogs;
|
|
1695
|
+
return parseEventLogs({
|
|
1696
|
+
abi: filter.abi,
|
|
1697
|
+
logs: formattedLogs,
|
|
1698
|
+
strict
|
|
1699
|
+
});
|
|
1700
|
+
}
|
|
1701
|
+
//#endregion
|
|
1702
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/actions/public/uninstallFilter.js
|
|
1703
|
+
/**
|
|
1704
|
+
* Destroys a [`Filter`](https://viem.sh/docs/glossary/types#filter).
|
|
1705
|
+
*
|
|
1706
|
+
* - Docs: https://viem.sh/docs/actions/public/uninstallFilter
|
|
1707
|
+
* - JSON-RPC Methods: [`eth_uninstallFilter`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_uninstallFilter)
|
|
1708
|
+
*
|
|
1709
|
+
* Destroys a Filter that was created from one of the following Actions:
|
|
1710
|
+
* - [`createBlockFilter`](https://viem.sh/docs/actions/public/createBlockFilter)
|
|
1711
|
+
* - [`createEventFilter`](https://viem.sh/docs/actions/public/createEventFilter)
|
|
1712
|
+
* - [`createPendingTransactionFilter`](https://viem.sh/docs/actions/public/createPendingTransactionFilter)
|
|
1713
|
+
*
|
|
1714
|
+
* @param client - Client to use
|
|
1715
|
+
* @param parameters - {@link UninstallFilterParameters}
|
|
1716
|
+
* @returns A boolean indicating if the Filter was successfully uninstalled. {@link UninstallFilterReturnType}
|
|
1717
|
+
*
|
|
1718
|
+
* @example
|
|
1719
|
+
* import { createPublicClient, http } from 'viem'
|
|
1720
|
+
* import { mainnet } from 'viem/chains'
|
|
1721
|
+
* import { createPendingTransactionFilter, uninstallFilter } from 'viem/public'
|
|
1722
|
+
*
|
|
1723
|
+
* const filter = await createPendingTransactionFilter(client)
|
|
1724
|
+
* const uninstalled = await uninstallFilter(client, { filter })
|
|
1725
|
+
* // true
|
|
1726
|
+
*/
|
|
1727
|
+
async function uninstallFilter(_client, { filter }) {
|
|
1728
|
+
return filter.request({
|
|
1729
|
+
method: "eth_uninstallFilter",
|
|
1730
|
+
params: [filter.id]
|
|
1731
|
+
});
|
|
1732
|
+
}
|
|
1733
|
+
//#endregion
|
|
1734
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/actions/public/watchContractEvent.js
|
|
1735
|
+
/**
|
|
1736
|
+
* Watches and returns emitted contract event logs.
|
|
1737
|
+
*
|
|
1738
|
+
* - Docs: https://viem.sh/docs/contract/watchContractEvent
|
|
1739
|
+
*
|
|
1740
|
+
* 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).
|
|
1741
|
+
*
|
|
1742
|
+
* `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.
|
|
1743
|
+
*
|
|
1744
|
+
* @param client - Client to use
|
|
1745
|
+
* @param parameters - {@link WatchContractEventParameters}
|
|
1746
|
+
* @returns A function that can be invoked to stop watching for new event logs. {@link WatchContractEventReturnType}
|
|
1747
|
+
*
|
|
1748
|
+
* @example
|
|
1749
|
+
* import { createPublicClient, http, parseAbi } from 'viem'
|
|
1750
|
+
* import { mainnet } from 'viem/chains'
|
|
1751
|
+
* import { watchContractEvent } from 'viem/contract'
|
|
1752
|
+
*
|
|
1753
|
+
* const client = createPublicClient({
|
|
1754
|
+
* chain: mainnet,
|
|
1755
|
+
* transport: http(),
|
|
1756
|
+
* })
|
|
1757
|
+
* const unwatch = watchContractEvent(client, {
|
|
1758
|
+
* address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
|
|
1759
|
+
* abi: parseAbi(['event Transfer(address indexed from, address indexed to, uint256 value)']),
|
|
1760
|
+
* eventName: 'Transfer',
|
|
1761
|
+
* args: { from: '0xc961145a54C96E3aE9bAA048c4F4D6b04C13916b' },
|
|
1762
|
+
* onLogs: (logs) => console.log(logs),
|
|
1763
|
+
* })
|
|
1764
|
+
*/
|
|
1765
|
+
function watchContractEvent(client, parameters) {
|
|
1766
|
+
const { abi, address, args, batch = true, eventName, fromBlock, onError, onLogs, poll: poll_, pollingInterval = client.pollingInterval, strict: strict_ } = parameters;
|
|
1767
|
+
const enablePolling = (() => {
|
|
1768
|
+
if (typeof poll_ !== "undefined") return poll_;
|
|
1769
|
+
if (typeof fromBlock === "bigint") return true;
|
|
1770
|
+
if (client.transport.type === "webSocket" || client.transport.type === "ipc") return false;
|
|
1771
|
+
if (client.transport.type === "fallback" && (client.transport.transports[0].config.type === "webSocket" || client.transport.transports[0].config.type === "ipc")) return false;
|
|
1772
|
+
return true;
|
|
1773
|
+
})();
|
|
1774
|
+
const pollContractEvent = () => {
|
|
1775
|
+
const strict = strict_ ?? false;
|
|
1776
|
+
return observe(stringify$1([
|
|
1777
|
+
"watchContractEvent",
|
|
1778
|
+
address,
|
|
1779
|
+
args,
|
|
1780
|
+
batch,
|
|
1781
|
+
client.uid,
|
|
1782
|
+
eventName,
|
|
1783
|
+
pollingInterval,
|
|
1784
|
+
strict,
|
|
1785
|
+
fromBlock
|
|
1786
|
+
]), {
|
|
1787
|
+
onLogs,
|
|
1788
|
+
onError
|
|
1789
|
+
}, (emit) => {
|
|
1790
|
+
let previousBlockNumber;
|
|
1791
|
+
if (fromBlock !== void 0) previousBlockNumber = fromBlock - 1n;
|
|
1792
|
+
let filter;
|
|
1793
|
+
let initialized = false;
|
|
1794
|
+
const unwatch = poll(async () => {
|
|
1795
|
+
if (!initialized) {
|
|
1796
|
+
try {
|
|
1797
|
+
filter = await getAction(client, createContractEventFilter, "createContractEventFilter")({
|
|
1798
|
+
abi,
|
|
1799
|
+
address,
|
|
1800
|
+
args,
|
|
1801
|
+
eventName,
|
|
1802
|
+
strict,
|
|
1803
|
+
fromBlock
|
|
1804
|
+
});
|
|
1805
|
+
} catch {}
|
|
1806
|
+
initialized = true;
|
|
1807
|
+
return;
|
|
1808
|
+
}
|
|
1809
|
+
try {
|
|
1810
|
+
let logs;
|
|
1811
|
+
if (filter) logs = await getAction(client, getFilterChanges, "getFilterChanges")({ filter });
|
|
1812
|
+
else {
|
|
1813
|
+
const blockNumber = await getAction(client, getBlockNumber, "getBlockNumber")({});
|
|
1814
|
+
if (previousBlockNumber && previousBlockNumber < blockNumber) logs = await getAction(client, getContractEvents, "getContractEvents")({
|
|
1815
|
+
abi,
|
|
1816
|
+
address,
|
|
1817
|
+
args,
|
|
1818
|
+
eventName,
|
|
1819
|
+
fromBlock: previousBlockNumber + 1n,
|
|
1820
|
+
toBlock: blockNumber,
|
|
1821
|
+
strict
|
|
1822
|
+
});
|
|
1823
|
+
else logs = [];
|
|
1824
|
+
previousBlockNumber = blockNumber;
|
|
1825
|
+
}
|
|
1826
|
+
if (logs.length === 0) return;
|
|
1827
|
+
if (batch) emit.onLogs(logs);
|
|
1828
|
+
else for (const log of logs) emit.onLogs([log]);
|
|
1829
|
+
} catch (err) {
|
|
1830
|
+
if (filter && err instanceof InvalidInputRpcError) initialized = false;
|
|
1831
|
+
emit.onError?.(err);
|
|
1832
|
+
}
|
|
1833
|
+
}, {
|
|
1834
|
+
emitOnBegin: true,
|
|
1835
|
+
interval: pollingInterval
|
|
1836
|
+
});
|
|
1837
|
+
return async () => {
|
|
1838
|
+
if (filter) await getAction(client, uninstallFilter, "uninstallFilter")({ filter });
|
|
1839
|
+
unwatch();
|
|
1840
|
+
};
|
|
1841
|
+
});
|
|
1842
|
+
};
|
|
1843
|
+
const subscribeContractEvent = () => {
|
|
1844
|
+
const strict = strict_ ?? false;
|
|
1845
|
+
const observerId = stringify$1([
|
|
1846
|
+
"watchContractEvent",
|
|
1847
|
+
address,
|
|
1848
|
+
args,
|
|
1849
|
+
batch,
|
|
1850
|
+
client.uid,
|
|
1851
|
+
eventName,
|
|
1852
|
+
pollingInterval,
|
|
1853
|
+
strict
|
|
1854
|
+
]);
|
|
1855
|
+
let active = true;
|
|
1856
|
+
let unsubscribe = () => active = false;
|
|
1857
|
+
return observe(observerId, {
|
|
1858
|
+
onLogs,
|
|
1859
|
+
onError
|
|
1860
|
+
}, (emit) => {
|
|
1861
|
+
(async () => {
|
|
1862
|
+
try {
|
|
1863
|
+
const transport = (() => {
|
|
1864
|
+
if (client.transport.type === "fallback") {
|
|
1865
|
+
const transport = client.transport.transports.find((transport) => transport.config.type === "webSocket" || transport.config.type === "ipc");
|
|
1866
|
+
if (!transport) return client.transport;
|
|
1867
|
+
return transport.value;
|
|
1868
|
+
}
|
|
1869
|
+
return client.transport;
|
|
1870
|
+
})();
|
|
1871
|
+
const topics = eventName ? encodeEventTopics({
|
|
1872
|
+
abi,
|
|
1873
|
+
eventName,
|
|
1874
|
+
args
|
|
1875
|
+
}) : [];
|
|
1876
|
+
const { unsubscribe: unsubscribe_ } = await transport.subscribe({
|
|
1877
|
+
params: ["logs", {
|
|
1878
|
+
address,
|
|
1879
|
+
topics
|
|
1880
|
+
}],
|
|
1881
|
+
onData(data) {
|
|
1882
|
+
if (!active) return;
|
|
1883
|
+
const log = data.result;
|
|
1884
|
+
try {
|
|
1885
|
+
const { eventName, args } = decodeEventLog({
|
|
1886
|
+
abi,
|
|
1887
|
+
data: log.data,
|
|
1888
|
+
topics: log.topics,
|
|
1889
|
+
strict: strict_
|
|
1890
|
+
});
|
|
1891
|
+
const formatted = formatLog(log, {
|
|
1892
|
+
args,
|
|
1893
|
+
eventName
|
|
1894
|
+
});
|
|
1895
|
+
emit.onLogs([formatted]);
|
|
1896
|
+
} catch (err) {
|
|
1897
|
+
let eventName;
|
|
1898
|
+
let isUnnamed;
|
|
1899
|
+
if (err instanceof DecodeLogDataMismatch || err instanceof DecodeLogTopicsMismatch) {
|
|
1900
|
+
if (strict_) return;
|
|
1901
|
+
eventName = err.abiItem.name;
|
|
1902
|
+
isUnnamed = err.abiItem.inputs?.some((x) => !("name" in x && x.name));
|
|
1903
|
+
}
|
|
1904
|
+
const formatted = formatLog(log, {
|
|
1905
|
+
args: isUnnamed ? [] : {},
|
|
1906
|
+
eventName
|
|
1907
|
+
});
|
|
1908
|
+
emit.onLogs([formatted]);
|
|
1909
|
+
}
|
|
1910
|
+
},
|
|
1911
|
+
onError(error) {
|
|
1912
|
+
emit.onError?.(error);
|
|
1913
|
+
}
|
|
1914
|
+
});
|
|
1915
|
+
unsubscribe = unsubscribe_;
|
|
1916
|
+
if (!active) unsubscribe();
|
|
1917
|
+
} catch (err) {
|
|
1918
|
+
onError?.(err);
|
|
1919
|
+
}
|
|
1920
|
+
})();
|
|
1921
|
+
return () => unsubscribe();
|
|
1922
|
+
});
|
|
1923
|
+
};
|
|
1924
|
+
return enablePolling ? pollContractEvent() : subscribeContractEvent();
|
|
1925
|
+
}
|
|
1926
|
+
//#endregion
|
|
1927
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/actions/wallet/sendRawTransaction.js
|
|
1928
|
+
/**
|
|
1929
|
+
* Sends a **signed** transaction to the network
|
|
1930
|
+
*
|
|
1931
|
+
* - Docs: https://viem.sh/docs/actions/wallet/sendRawTransaction
|
|
1932
|
+
* - JSON-RPC Method: [`eth_sendRawTransaction`](https://ethereum.github.io/execution-apis/api-documentation/)
|
|
1933
|
+
*
|
|
1934
|
+
* @param client - Client to use
|
|
1935
|
+
* @param parameters - {@link SendRawTransactionParameters}
|
|
1936
|
+
* @returns The transaction hash. {@link SendRawTransactionReturnType}
|
|
1937
|
+
*
|
|
1938
|
+
* @example
|
|
1939
|
+
* import { createWalletClient, custom } from 'viem'
|
|
1940
|
+
* import { mainnet } from 'viem/chains'
|
|
1941
|
+
* import { sendRawTransaction } from 'viem/wallet'
|
|
1942
|
+
*
|
|
1943
|
+
* const client = createWalletClient({
|
|
1944
|
+
* chain: mainnet,
|
|
1945
|
+
* transport: custom(window.ethereum),
|
|
1946
|
+
* })
|
|
1947
|
+
*
|
|
1948
|
+
* const hash = await sendRawTransaction(client, {
|
|
1949
|
+
* serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33'
|
|
1950
|
+
* })
|
|
1951
|
+
*/
|
|
1952
|
+
async function sendRawTransaction(client, { serializedTransaction }) {
|
|
1953
|
+
return client.request({
|
|
1954
|
+
method: "eth_sendRawTransaction",
|
|
1955
|
+
params: [serializedTransaction]
|
|
1956
|
+
}, { retryCount: 0 });
|
|
1957
|
+
}
|
|
1958
|
+
//#endregion
|
|
1959
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/utils/promise/withRetry.js
|
|
1960
|
+
function withRetry(fn, { delay: delay_ = 100, retryCount = 2, shouldRetry = () => true } = {}) {
|
|
1961
|
+
return new Promise((resolve, reject) => {
|
|
1962
|
+
const attemptRetry = async ({ count = 0 } = {}) => {
|
|
1963
|
+
const retry = async ({ error }) => {
|
|
1964
|
+
const delay = typeof delay_ === "function" ? delay_({
|
|
1965
|
+
count,
|
|
1966
|
+
error
|
|
1967
|
+
}) : delay_;
|
|
1968
|
+
if (delay) await wait(delay);
|
|
1969
|
+
attemptRetry({ count: count + 1 });
|
|
1970
|
+
};
|
|
1971
|
+
try {
|
|
1972
|
+
resolve(await fn());
|
|
1973
|
+
} catch (err) {
|
|
1974
|
+
if (count < retryCount && await shouldRetry({
|
|
1975
|
+
count,
|
|
1976
|
+
error: err
|
|
1977
|
+
})) return retry({ error: err });
|
|
1978
|
+
reject(err);
|
|
1979
|
+
}
|
|
1980
|
+
};
|
|
1981
|
+
attemptRetry();
|
|
1982
|
+
});
|
|
1983
|
+
}
|
|
1984
|
+
//#endregion
|
|
1985
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/utils/formatters/transactionReceipt.js
|
|
1986
|
+
const receiptStatuses = {
|
|
1987
|
+
"0x0": "reverted",
|
|
1988
|
+
"0x1": "success"
|
|
1989
|
+
};
|
|
1990
|
+
function formatTransactionReceipt(transactionReceipt, _) {
|
|
1991
|
+
const receipt = {
|
|
1992
|
+
...transactionReceipt,
|
|
1993
|
+
blockNumber: transactionReceipt.blockNumber ? BigInt(transactionReceipt.blockNumber) : null,
|
|
1994
|
+
contractAddress: transactionReceipt.contractAddress ? transactionReceipt.contractAddress : null,
|
|
1995
|
+
cumulativeGasUsed: transactionReceipt.cumulativeGasUsed ? BigInt(transactionReceipt.cumulativeGasUsed) : null,
|
|
1996
|
+
effectiveGasPrice: transactionReceipt.effectiveGasPrice ? BigInt(transactionReceipt.effectiveGasPrice) : null,
|
|
1997
|
+
gasUsed: transactionReceipt.gasUsed ? BigInt(transactionReceipt.gasUsed) : null,
|
|
1998
|
+
logs: transactionReceipt.logs ? transactionReceipt.logs.map((log) => formatLog(log)) : null,
|
|
1999
|
+
to: transactionReceipt.to ? transactionReceipt.to : null,
|
|
2000
|
+
transactionIndex: transactionReceipt.transactionIndex ? hexToNumber(transactionReceipt.transactionIndex) : null,
|
|
2001
|
+
status: transactionReceipt.status ? receiptStatuses[transactionReceipt.status] : null,
|
|
2002
|
+
type: transactionReceipt.type ? transactionType[transactionReceipt.type] || transactionReceipt.type : null
|
|
2003
|
+
};
|
|
2004
|
+
if (transactionReceipt.blobGasPrice) receipt.blobGasPrice = BigInt(transactionReceipt.blobGasPrice);
|
|
2005
|
+
if (transactionReceipt.blobGasUsed) receipt.blobGasUsed = BigInt(transactionReceipt.blobGasUsed);
|
|
2006
|
+
return receipt;
|
|
2007
|
+
}
|
|
2008
|
+
const defineTransactionReceipt = /* @__PURE__ */ defineFormatter("transactionReceipt", formatTransactionReceipt);
|
|
2009
|
+
//#endregion
|
|
2010
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/utils/uid.js
|
|
2011
|
+
const size = 256;
|
|
2012
|
+
let index = size;
|
|
2013
|
+
let buffer;
|
|
2014
|
+
function uid(length = 11) {
|
|
2015
|
+
if (!buffer || index + length > size * 2) {
|
|
2016
|
+
buffer = "";
|
|
2017
|
+
index = 0;
|
|
2018
|
+
for (let i = 0; i < size; i++) buffer += (256 + Math.random() * 256 | 0).toString(16).substring(1);
|
|
2019
|
+
}
|
|
2020
|
+
return buffer.substring(index, index++ + length);
|
|
2021
|
+
}
|
|
2022
|
+
//#endregion
|
|
2023
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/clients/createClient.js
|
|
2024
|
+
function createClient(parameters) {
|
|
2025
|
+
const { batch, chain, ccipRead, dataSuffix, key = "base", name = "Base Client", type = "base" } = parameters;
|
|
2026
|
+
const experimental_blockTag = parameters.experimental_blockTag ?? (typeof chain?.experimental_preconfirmationTime === "number" ? "pending" : void 0);
|
|
2027
|
+
const blockTime = chain?.blockTime ?? 12e3;
|
|
2028
|
+
const defaultPollingInterval = Math.min(Math.max(Math.floor(blockTime / 2), 500), 4e3);
|
|
2029
|
+
const pollingInterval = parameters.pollingInterval ?? defaultPollingInterval;
|
|
2030
|
+
const cacheTime = parameters.cacheTime ?? pollingInterval;
|
|
2031
|
+
const account = parameters.account ? parseAccount(parameters.account) : void 0;
|
|
2032
|
+
const { config, request, value } = parameters.transport({
|
|
2033
|
+
account,
|
|
2034
|
+
chain,
|
|
2035
|
+
pollingInterval
|
|
2036
|
+
});
|
|
2037
|
+
const client = {
|
|
2038
|
+
account,
|
|
2039
|
+
batch,
|
|
2040
|
+
cacheTime,
|
|
2041
|
+
ccipRead,
|
|
2042
|
+
chain,
|
|
2043
|
+
dataSuffix,
|
|
2044
|
+
key,
|
|
2045
|
+
name,
|
|
2046
|
+
pollingInterval,
|
|
2047
|
+
request,
|
|
2048
|
+
transport: {
|
|
2049
|
+
...config,
|
|
2050
|
+
...value
|
|
2051
|
+
},
|
|
2052
|
+
type,
|
|
2053
|
+
uid: uid(),
|
|
2054
|
+
...experimental_blockTag ? { experimental_blockTag } : {}
|
|
2055
|
+
};
|
|
2056
|
+
function extend(base) {
|
|
2057
|
+
return (extendFn) => {
|
|
2058
|
+
const extended = extendFn(base);
|
|
2059
|
+
for (const key in client) delete extended[key];
|
|
2060
|
+
const combined = {
|
|
2061
|
+
...base,
|
|
2062
|
+
...extended
|
|
2063
|
+
};
|
|
2064
|
+
return Object.assign(combined, { extend: extend(combined) });
|
|
2065
|
+
};
|
|
2066
|
+
}
|
|
2067
|
+
return Object.assign(client, { extend: extend(client) });
|
|
2068
|
+
}
|
|
2069
|
+
//#endregion
|
|
2070
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/actions/public/getCode.js
|
|
2071
|
+
/**
|
|
2072
|
+
* Retrieves the bytecode at an address.
|
|
2073
|
+
*
|
|
2074
|
+
* - Docs: https://viem.sh/docs/contract/getCode
|
|
2075
|
+
* - JSON-RPC Methods: [`eth_getCode`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getcode)
|
|
2076
|
+
*
|
|
2077
|
+
* @param client - Client to use
|
|
2078
|
+
* @param parameters - {@link GetCodeParameters}
|
|
2079
|
+
* @returns The contract's bytecode. {@link GetCodeReturnType}
|
|
2080
|
+
*
|
|
2081
|
+
* @example
|
|
2082
|
+
* import { createPublicClient, http } from 'viem'
|
|
2083
|
+
* import { mainnet } from 'viem/chains'
|
|
2084
|
+
* import { getCode } from 'viem/contract'
|
|
2085
|
+
*
|
|
2086
|
+
* const client = createPublicClient({
|
|
2087
|
+
* chain: mainnet,
|
|
2088
|
+
* transport: http(),
|
|
2089
|
+
* })
|
|
2090
|
+
* const code = await getCode(client, {
|
|
2091
|
+
* address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
|
|
2092
|
+
* })
|
|
2093
|
+
*/
|
|
2094
|
+
async function getCode(client, { address, blockNumber, blockTag = "latest" }) {
|
|
2095
|
+
const blockNumberHex = blockNumber !== void 0 ? numberToHex(blockNumber) : void 0;
|
|
2096
|
+
const hex = await client.request({
|
|
2097
|
+
method: "eth_getCode",
|
|
2098
|
+
params: [address, blockNumberHex || blockTag]
|
|
2099
|
+
}, { dedupe: Boolean(blockNumberHex) });
|
|
2100
|
+
if (hex === "0x") return void 0;
|
|
2101
|
+
return hex;
|
|
2102
|
+
}
|
|
2103
|
+
//#endregion
|
|
2104
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/utils/authorization/verifyAuthorization.js
|
|
2105
|
+
/**
|
|
2106
|
+
* Verify that an Authorization object was signed by the provided address.
|
|
2107
|
+
*
|
|
2108
|
+
* - Docs {@link https://viem.sh/docs/utilities/verifyAuthorization}
|
|
2109
|
+
*
|
|
2110
|
+
* @param parameters - {@link VerifyAuthorizationParameters}
|
|
2111
|
+
* @returns Whether or not the signature is valid. {@link VerifyAuthorizationReturnType}
|
|
2112
|
+
*/
|
|
2113
|
+
async function verifyAuthorization({ address, authorization, signature }) {
|
|
2114
|
+
return isAddressEqual(getAddress(address), await recoverAuthorizationAddress({
|
|
2115
|
+
authorization,
|
|
2116
|
+
signature
|
|
2117
|
+
}));
|
|
2118
|
+
}
|
|
2119
|
+
//#endregion
|
|
2120
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/utils/promise/withDedupe.js
|
|
2121
|
+
/** @internal */
|
|
2122
|
+
const promiseCache = /* @__PURE__ */ new LruMap$1(8192);
|
|
2123
|
+
/** Deduplicates in-flight promises. */
|
|
2124
|
+
function withDedupe(fn, { enabled = true, id }) {
|
|
2125
|
+
if (!enabled || !id) return fn();
|
|
2126
|
+
if (promiseCache.get(id)) return promiseCache.get(id);
|
|
2127
|
+
const promise = fn().finally(() => promiseCache.delete(id));
|
|
2128
|
+
promiseCache.set(id, promise);
|
|
2129
|
+
return promise;
|
|
2130
|
+
}
|
|
2131
|
+
//#endregion
|
|
2132
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/utils/buildRequest.js
|
|
2133
|
+
function buildRequest(request, options = {}) {
|
|
2134
|
+
return async (args, overrideOptions = {}) => {
|
|
2135
|
+
const { dedupe = false, methods, retryDelay = 150, retryCount = 3, uid } = {
|
|
2136
|
+
...options,
|
|
2137
|
+
...overrideOptions
|
|
2138
|
+
};
|
|
2139
|
+
const { method } = args;
|
|
2140
|
+
if (methods?.exclude?.includes(method)) throw new MethodNotSupportedRpcError(/* @__PURE__ */ new Error("method not supported"), { method });
|
|
2141
|
+
if (methods?.include && !methods.include.includes(method)) throw new MethodNotSupportedRpcError(/* @__PURE__ */ new Error("method not supported"), { method });
|
|
2142
|
+
return withDedupe(() => withRetry(async () => {
|
|
2143
|
+
try {
|
|
2144
|
+
return await request(args);
|
|
2145
|
+
} catch (err_) {
|
|
2146
|
+
const err = err_;
|
|
2147
|
+
switch (err.code) {
|
|
2148
|
+
case ParseRpcError.code: throw new ParseRpcError(err);
|
|
2149
|
+
case InvalidRequestRpcError.code: throw new InvalidRequestRpcError(err);
|
|
2150
|
+
case MethodNotFoundRpcError.code: throw new MethodNotFoundRpcError(err, { method: args.method });
|
|
2151
|
+
case InvalidParamsRpcError.code: throw new InvalidParamsRpcError(err);
|
|
2152
|
+
case InternalRpcError.code: throw new InternalRpcError(err);
|
|
2153
|
+
case InvalidInputRpcError.code: throw new InvalidInputRpcError(err);
|
|
2154
|
+
case ResourceNotFoundRpcError.code: throw new ResourceNotFoundRpcError(err);
|
|
2155
|
+
case ResourceUnavailableRpcError.code: throw new ResourceUnavailableRpcError(err);
|
|
2156
|
+
case TransactionRejectedRpcError.code: throw new TransactionRejectedRpcError(err);
|
|
2157
|
+
case MethodNotSupportedRpcError.code: throw new MethodNotSupportedRpcError(err, { method: args.method });
|
|
2158
|
+
case LimitExceededRpcError.code: throw new LimitExceededRpcError(err);
|
|
2159
|
+
case JsonRpcVersionUnsupportedError.code: throw new JsonRpcVersionUnsupportedError(err);
|
|
2160
|
+
case UserRejectedRequestError.code: throw new UserRejectedRequestError(err);
|
|
2161
|
+
case UnauthorizedProviderError.code: throw new UnauthorizedProviderError(err);
|
|
2162
|
+
case UnsupportedProviderMethodError.code: throw new UnsupportedProviderMethodError(err);
|
|
2163
|
+
case ProviderDisconnectedError.code: throw new ProviderDisconnectedError(err);
|
|
2164
|
+
case ChainDisconnectedError.code: throw new ChainDisconnectedError(err);
|
|
2165
|
+
case SwitchChainError.code: throw new SwitchChainError(err);
|
|
2166
|
+
case UnsupportedNonOptionalCapabilityError.code: throw new UnsupportedNonOptionalCapabilityError(err);
|
|
2167
|
+
case UnsupportedChainIdError.code: throw new UnsupportedChainIdError(err);
|
|
2168
|
+
case DuplicateIdError.code: throw new DuplicateIdError(err);
|
|
2169
|
+
case UnknownBundleIdError.code: throw new UnknownBundleIdError(err);
|
|
2170
|
+
case BundleTooLargeError.code: throw new BundleTooLargeError(err);
|
|
2171
|
+
case AtomicReadyWalletRejectedUpgradeError.code: throw new AtomicReadyWalletRejectedUpgradeError(err);
|
|
2172
|
+
case AtomicityNotSupportedError.code: throw new AtomicityNotSupportedError(err);
|
|
2173
|
+
case 5e3: throw new UserRejectedRequestError(err);
|
|
2174
|
+
case WalletConnectSessionSettlementError.code: throw new WalletConnectSessionSettlementError(err);
|
|
2175
|
+
default:
|
|
2176
|
+
if (err_ instanceof BaseError$1) throw err_;
|
|
2177
|
+
throw new UnknownRpcError(err);
|
|
2178
|
+
}
|
|
2179
|
+
}
|
|
2180
|
+
}, {
|
|
2181
|
+
delay: ({ count, error }) => {
|
|
2182
|
+
if (error && error instanceof HttpRequestError) {
|
|
2183
|
+
const retryAfter = error?.headers?.get("Retry-After");
|
|
2184
|
+
if (retryAfter?.match(/\d/)) return Number.parseInt(retryAfter, 10) * 1e3;
|
|
2185
|
+
}
|
|
2186
|
+
return ~~(1 << count) * retryDelay;
|
|
2187
|
+
},
|
|
2188
|
+
retryCount,
|
|
2189
|
+
shouldRetry: ({ error }) => shouldRetry(error)
|
|
2190
|
+
}), {
|
|
2191
|
+
enabled: dedupe,
|
|
2192
|
+
id: dedupe ? stringToHex(`${uid}.${stringify$1(args)}`) : void 0
|
|
2193
|
+
});
|
|
2194
|
+
};
|
|
2195
|
+
}
|
|
2196
|
+
/** @internal */
|
|
2197
|
+
function shouldRetry(error) {
|
|
2198
|
+
if ("code" in error && typeof error.code === "number") {
|
|
2199
|
+
if (error.code === -1) return true;
|
|
2200
|
+
if (error.code === LimitExceededRpcError.code) return true;
|
|
2201
|
+
if (error.code === InternalRpcError.code) return true;
|
|
2202
|
+
return false;
|
|
2203
|
+
}
|
|
2204
|
+
if (error instanceof HttpRequestError && error.status) {
|
|
2205
|
+
if (error.status === 403) return true;
|
|
2206
|
+
if (error.status === 408) return true;
|
|
2207
|
+
if (error.status === 413) return true;
|
|
2208
|
+
if (error.status === 429) return true;
|
|
2209
|
+
if (error.status === 500) return true;
|
|
2210
|
+
if (error.status === 502) return true;
|
|
2211
|
+
if (error.status === 503) return true;
|
|
2212
|
+
if (error.status === 504) return true;
|
|
2213
|
+
return false;
|
|
2214
|
+
}
|
|
2215
|
+
return true;
|
|
2216
|
+
}
|
|
2217
|
+
//#endregion
|
|
2218
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/utils/chain/defineChain.js
|
|
2219
|
+
function defineChain(chain) {
|
|
2220
|
+
const chainInstance = {
|
|
2221
|
+
formatters: void 0,
|
|
2222
|
+
fees: void 0,
|
|
2223
|
+
serializers: void 0,
|
|
2224
|
+
...chain
|
|
2225
|
+
};
|
|
2226
|
+
function extend(base) {
|
|
2227
|
+
return (fnOrExtended) => {
|
|
2228
|
+
const properties = typeof fnOrExtended === "function" ? fnOrExtended(base) : fnOrExtended;
|
|
2229
|
+
const combined = {
|
|
2230
|
+
...base,
|
|
2231
|
+
...properties
|
|
2232
|
+
};
|
|
2233
|
+
return Object.assign(combined, { extend: extend(combined) });
|
|
2234
|
+
};
|
|
2235
|
+
}
|
|
2236
|
+
return Object.assign(chainInstance, { extend: extend(chainInstance) });
|
|
2237
|
+
}
|
|
2238
|
+
function extendSchema() {
|
|
2239
|
+
return {};
|
|
2240
|
+
}
|
|
2241
|
+
//#endregion
|
|
2242
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/utils/promise/withTimeout.js
|
|
2243
|
+
function withTimeout(fn, { errorInstance = /* @__PURE__ */ new Error("timed out"), timeout, signal }) {
|
|
2244
|
+
return new Promise((resolve, reject) => {
|
|
2245
|
+
(async () => {
|
|
2246
|
+
let timeoutId;
|
|
2247
|
+
try {
|
|
2248
|
+
const controller = new AbortController();
|
|
2249
|
+
if (timeout > 0) timeoutId = setTimeout(() => {
|
|
2250
|
+
if (signal) controller.abort();
|
|
2251
|
+
else reject(errorInstance);
|
|
2252
|
+
}, timeout);
|
|
2253
|
+
resolve(await fn({ signal: controller?.signal || null }));
|
|
2254
|
+
} catch (err) {
|
|
2255
|
+
if (err?.name === "AbortError") reject(errorInstance);
|
|
2256
|
+
reject(err);
|
|
2257
|
+
} finally {
|
|
2258
|
+
clearTimeout(timeoutId);
|
|
2259
|
+
}
|
|
2260
|
+
})();
|
|
2261
|
+
});
|
|
2262
|
+
}
|
|
2263
|
+
//#endregion
|
|
2264
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/utils/rpc/id.js
|
|
2265
|
+
function createIdStore() {
|
|
2266
|
+
return {
|
|
2267
|
+
current: 0,
|
|
2268
|
+
take() {
|
|
2269
|
+
return this.current++;
|
|
2270
|
+
},
|
|
2271
|
+
reset() {
|
|
2272
|
+
this.current = 0;
|
|
2273
|
+
}
|
|
2274
|
+
};
|
|
2275
|
+
}
|
|
2276
|
+
const idCache = /* @__PURE__ */ createIdStore();
|
|
2277
|
+
//#endregion
|
|
2278
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/utils/rpc/http.js
|
|
2279
|
+
function getHttpRpcClient(url_, options = {}) {
|
|
2280
|
+
const { url, headers: headers_url } = parseUrl(url_);
|
|
2281
|
+
return { async request(params) {
|
|
2282
|
+
const { body, fetchFn = options.fetchFn ?? fetch, onRequest = options.onRequest, onResponse = options.onResponse, timeout = options.timeout ?? 1e4 } = params;
|
|
2283
|
+
const fetchOptions = {
|
|
2284
|
+
...options.fetchOptions ?? {},
|
|
2285
|
+
...params.fetchOptions ?? {}
|
|
2286
|
+
};
|
|
2287
|
+
const { headers, method, signal: signal_ } = fetchOptions;
|
|
2288
|
+
try {
|
|
2289
|
+
const response = await withTimeout(async ({ signal }) => {
|
|
2290
|
+
const init = {
|
|
2291
|
+
...fetchOptions,
|
|
2292
|
+
body: Array.isArray(body) ? stringify$1(body.map((body) => ({
|
|
2293
|
+
jsonrpc: "2.0",
|
|
2294
|
+
id: body.id ?? idCache.take(),
|
|
2295
|
+
...body
|
|
2296
|
+
}))) : stringify$1({
|
|
2297
|
+
jsonrpc: "2.0",
|
|
2298
|
+
id: body.id ?? idCache.take(),
|
|
2299
|
+
...body
|
|
2300
|
+
}),
|
|
2301
|
+
headers: {
|
|
2302
|
+
...headers_url,
|
|
2303
|
+
"Content-Type": "application/json",
|
|
2304
|
+
...headers
|
|
2305
|
+
},
|
|
2306
|
+
method: method || "POST",
|
|
2307
|
+
signal: signal_ || (timeout > 0 ? signal : null)
|
|
2308
|
+
};
|
|
2309
|
+
const request = new Request(url, init);
|
|
2310
|
+
const args = await onRequest?.(request, init) ?? {
|
|
2311
|
+
...init,
|
|
2312
|
+
url
|
|
2313
|
+
};
|
|
2314
|
+
return await fetchFn(args.url ?? url, args);
|
|
2315
|
+
}, {
|
|
2316
|
+
errorInstance: new TimeoutError({
|
|
2317
|
+
body,
|
|
2318
|
+
url
|
|
2319
|
+
}),
|
|
2320
|
+
timeout,
|
|
2321
|
+
signal: true
|
|
2322
|
+
});
|
|
2323
|
+
if (onResponse) await onResponse(response);
|
|
2324
|
+
let data;
|
|
2325
|
+
if (response.headers.get("Content-Type")?.startsWith("application/json")) data = await response.json();
|
|
2326
|
+
else {
|
|
2327
|
+
data = await response.text();
|
|
2328
|
+
try {
|
|
2329
|
+
data = JSON.parse(data || "{}");
|
|
2330
|
+
} catch (err) {
|
|
2331
|
+
if (response.ok) throw err;
|
|
2332
|
+
data = { error: data };
|
|
2333
|
+
}
|
|
2334
|
+
}
|
|
2335
|
+
if (!response.ok) {
|
|
2336
|
+
if (typeof data.error?.code === "number" && typeof data.error?.message === "string") return data;
|
|
2337
|
+
throw new HttpRequestError({
|
|
2338
|
+
body,
|
|
2339
|
+
details: stringify$1(data.error) || response.statusText,
|
|
2340
|
+
headers: response.headers,
|
|
2341
|
+
status: response.status,
|
|
2342
|
+
url
|
|
2343
|
+
});
|
|
2344
|
+
}
|
|
2345
|
+
return data;
|
|
2346
|
+
} catch (err) {
|
|
2347
|
+
if (err instanceof HttpRequestError) throw err;
|
|
2348
|
+
if (err instanceof TimeoutError) throw err;
|
|
2349
|
+
throw new HttpRequestError({
|
|
2350
|
+
body,
|
|
2351
|
+
cause: err,
|
|
2352
|
+
url
|
|
2353
|
+
});
|
|
2354
|
+
}
|
|
2355
|
+
} };
|
|
2356
|
+
}
|
|
2357
|
+
/** @internal */
|
|
2358
|
+
function parseUrl(url_) {
|
|
2359
|
+
try {
|
|
2360
|
+
const url = new URL(url_);
|
|
2361
|
+
const result = (() => {
|
|
2362
|
+
if (url.username) {
|
|
2363
|
+
const credentials = `${decodeURIComponent(url.username)}:${decodeURIComponent(url.password)}`;
|
|
2364
|
+
url.username = "";
|
|
2365
|
+
url.password = "";
|
|
2366
|
+
return {
|
|
2367
|
+
url: url.toString(),
|
|
2368
|
+
headers: { Authorization: `Basic ${btoa(credentials)}` }
|
|
2369
|
+
};
|
|
2370
|
+
}
|
|
2371
|
+
})();
|
|
2372
|
+
return {
|
|
2373
|
+
url: url.toString(),
|
|
2374
|
+
...result
|
|
2375
|
+
};
|
|
2376
|
+
} catch {
|
|
2377
|
+
return { url: url_ };
|
|
2378
|
+
}
|
|
2379
|
+
}
|
|
2380
|
+
//#endregion
|
|
2381
|
+
//#region node_modules/.pnpm/ox@0.14.7_typescript@5.9.3_zod@4.3.6/node_modules/ox/_esm/core/internal/lru.js
|
|
2382
|
+
/**
|
|
2383
|
+
* @internal
|
|
2384
|
+
*
|
|
2385
|
+
* Map with a LRU (Least recently used) policy.
|
|
2386
|
+
* @see https://en.wikipedia.org/wiki/Cache_replacement_policies#LRU
|
|
2387
|
+
*/
|
|
2388
|
+
var LruMap = class extends Map {
|
|
2389
|
+
constructor(size) {
|
|
2390
|
+
super();
|
|
2391
|
+
Object.defineProperty(this, "maxSize", {
|
|
2392
|
+
enumerable: true,
|
|
2393
|
+
configurable: true,
|
|
2394
|
+
writable: true,
|
|
2395
|
+
value: void 0
|
|
2396
|
+
});
|
|
2397
|
+
this.maxSize = size;
|
|
2398
|
+
}
|
|
2399
|
+
get(key) {
|
|
2400
|
+
const value = super.get(key);
|
|
2401
|
+
if (super.has(key) && value !== void 0) {
|
|
2402
|
+
this.delete(key);
|
|
2403
|
+
super.set(key, value);
|
|
2404
|
+
}
|
|
2405
|
+
return value;
|
|
2406
|
+
}
|
|
2407
|
+
set(key, value) {
|
|
2408
|
+
super.set(key, value);
|
|
2409
|
+
if (this.maxSize && this.size > this.maxSize) {
|
|
2410
|
+
const firstKey = this.keys().next().value;
|
|
2411
|
+
if (firstKey) this.delete(firstKey);
|
|
2412
|
+
}
|
|
2413
|
+
return this;
|
|
2414
|
+
}
|
|
2415
|
+
};
|
|
2416
|
+
const checksum$1 = { checksum: /* @__PURE__ */ new LruMap(8192) }.checksum;
|
|
2417
|
+
//#endregion
|
|
2418
|
+
//#region node_modules/.pnpm/ox@0.14.7_typescript@5.9.3_zod@4.3.6/node_modules/ox/_esm/core/Hash.js
|
|
2419
|
+
/**
|
|
2420
|
+
* Calculates the [Keccak256](https://en.wikipedia.org/wiki/SHA-3) hash of a {@link ox#Bytes.Bytes} or {@link ox#Hex.Hex} value.
|
|
2421
|
+
*
|
|
2422
|
+
* This function is a re-export of `keccak_256` from [`@noble/hashes`](https://github.com/paulmillr/noble-hashes), an audited & minimal JS hashing library.
|
|
2423
|
+
*
|
|
2424
|
+
* @example
|
|
2425
|
+
* ```ts twoslash
|
|
2426
|
+
* import { Hash } from 'ox'
|
|
2427
|
+
*
|
|
2428
|
+
* Hash.keccak256('0xdeadbeef')
|
|
2429
|
+
* // @log: '0xd4fd4e189132273036449fc9e11198c739161b4c0116a9a2dccdfa1c492006f1'
|
|
2430
|
+
* ```
|
|
2431
|
+
*
|
|
2432
|
+
* @example
|
|
2433
|
+
* ### Calculate Hash of a String
|
|
2434
|
+
*
|
|
2435
|
+
* ```ts twoslash
|
|
2436
|
+
* import { Hash, Hex } from 'ox'
|
|
1162
2437
|
*
|
|
1163
2438
|
* Hash.keccak256(Hex.fromString('hello world'))
|
|
1164
2439
|
* // @log: '0x3ea2f1d0abf3fc66cf29eebb70cbd4e7fe762ef8a09bcc06c8edf641230afec0'
|
|
@@ -1180,7 +2455,7 @@ const checksum$1 = { checksum: /* @__PURE__ */ new LruMap(8192) }.checksum;
|
|
|
1180
2455
|
*/
|
|
1181
2456
|
function keccak256(value, options = {}) {
|
|
1182
2457
|
const { as = typeof value === "string" ? "Hex" : "Bytes" } = options;
|
|
1183
|
-
const bytes = keccak_256(from$
|
|
2458
|
+
const bytes = keccak_256(from$6(value));
|
|
1184
2459
|
if (as === "Bytes") return bytes;
|
|
1185
2460
|
return fromBytes$2(bytes);
|
|
1186
2461
|
}
|
|
@@ -1203,7 +2478,7 @@ function keccak256(value, options = {}) {
|
|
|
1203
2478
|
*/
|
|
1204
2479
|
function sha256(value, options = {}) {
|
|
1205
2480
|
const { as = typeof value === "string" ? "Hex" : "Bytes" } = options;
|
|
1206
|
-
const bytes = sha256$1(from$
|
|
2481
|
+
const bytes = sha256$1(from$6(value));
|
|
1207
2482
|
if (as === "Bytes") return bytes;
|
|
1208
2483
|
return fromBytes$2(bytes);
|
|
1209
2484
|
}
|
|
@@ -1224,8 +2499,8 @@ function sha256(value, options = {}) {
|
|
|
1224
2499
|
* @param value - Value to check.
|
|
1225
2500
|
* @returns Whether the value is a valid hash.
|
|
1226
2501
|
*/
|
|
1227
|
-
function validate$
|
|
1228
|
-
return validate$
|
|
2502
|
+
function validate$3(value) {
|
|
2503
|
+
return validate$4(value) && size$1(value) === 32;
|
|
1229
2504
|
}
|
|
1230
2505
|
//#endregion
|
|
1231
2506
|
//#region node_modules/.pnpm/ox@0.14.7_typescript@5.9.3_zod@4.3.6/node_modules/ox/_esm/core/PublicKey.js
|
|
@@ -1248,7 +2523,7 @@ function validate$1(value) {
|
|
|
1248
2523
|
*
|
|
1249
2524
|
* @param publicKey - The public key object to assert.
|
|
1250
2525
|
*/
|
|
1251
|
-
function assert$
|
|
2526
|
+
function assert$4(publicKey, options = {}) {
|
|
1252
2527
|
const { compressed } = options;
|
|
1253
2528
|
const { prefix, x, y } = publicKey;
|
|
1254
2529
|
if (compressed === false || typeof x === "bigint" && typeof y === "bigint") {
|
|
@@ -1303,10 +2578,10 @@ function assert$2(publicKey, options = {}) {
|
|
|
1303
2578
|
* @param value - The public key value to instantiate.
|
|
1304
2579
|
* @returns The instantiated {@link ox#PublicKey.PublicKey}.
|
|
1305
2580
|
*/
|
|
1306
|
-
function from$
|
|
2581
|
+
function from$5(value) {
|
|
1307
2582
|
const publicKey = (() => {
|
|
1308
|
-
if (validate$
|
|
1309
|
-
if (validate$
|
|
2583
|
+
if (validate$4(value)) return fromHex$2(value);
|
|
2584
|
+
if (validate$5(value)) return fromBytes$1(value);
|
|
1310
2585
|
const { prefix, x, y } = value;
|
|
1311
2586
|
if (typeof x === "bigint" && typeof y === "bigint") return {
|
|
1312
2587
|
prefix: prefix ?? 4,
|
|
@@ -1318,7 +2593,7 @@ function from$4(value) {
|
|
|
1318
2593
|
x
|
|
1319
2594
|
};
|
|
1320
2595
|
})();
|
|
1321
|
-
assert$
|
|
2596
|
+
assert$4(publicKey);
|
|
1322
2597
|
return publicKey;
|
|
1323
2598
|
}
|
|
1324
2599
|
/**
|
|
@@ -1435,7 +2710,7 @@ function toBytes(publicKey, options = {}) {
|
|
|
1435
2710
|
* @returns The serialized public key.
|
|
1436
2711
|
*/
|
|
1437
2712
|
function toHex$2(publicKey, options = {}) {
|
|
1438
|
-
assert$
|
|
2713
|
+
assert$4(publicKey);
|
|
1439
2714
|
const { prefix, x, y } = publicKey;
|
|
1440
2715
|
const { includePrefix = true } = options;
|
|
1441
2716
|
return concat(includePrefix ? fromNumber(prefix, { size: 1 }) : "0x", fromNumber(x, { size: 32 }), typeof y === "bigint" ? fromNumber(y, { size: 32 }) : "0x");
|
|
@@ -1508,7 +2783,7 @@ var InvalidUncompressedPrefixError = class extends BaseError {
|
|
|
1508
2783
|
/** Thrown when the public key has an invalid serialized size. */
|
|
1509
2784
|
var InvalidSerializedSizeError$1 = class extends BaseError {
|
|
1510
2785
|
constructor({ publicKey }) {
|
|
1511
|
-
super(`Value \`${publicKey}\` is an invalid public key size.`, { metaMessages: ["Expected: 33 bytes (compressed + prefix), 64 bytes (uncompressed) or 65 bytes (uncompressed + prefix).", `Received ${size(from$
|
|
2786
|
+
super(`Value \`${publicKey}\` is an invalid public key size.`, { metaMessages: ["Expected: 33 bytes (compressed + prefix), 64 bytes (uncompressed) or 65 bytes (uncompressed + prefix).", `Received ${size$1(from$7(publicKey))} bytes.`] });
|
|
1512
2787
|
Object.defineProperty(this, "name", {
|
|
1513
2788
|
enumerable: true,
|
|
1514
2789
|
configurable: true,
|
|
@@ -1541,7 +2816,7 @@ const addressRegex = /^0x[a-fA-F0-9]{40}$/;
|
|
|
1541
2816
|
* @param value - Value to assert if it is a valid address.
|
|
1542
2817
|
* @param options - Assertion options.
|
|
1543
2818
|
*/
|
|
1544
|
-
function assert$
|
|
2819
|
+
function assert$3(value, options = {}) {
|
|
1545
2820
|
const { strict = true } = options;
|
|
1546
2821
|
if (!addressRegex.test(value)) throw new InvalidAddressError({
|
|
1547
2822
|
address: value,
|
|
@@ -1571,7 +2846,7 @@ function assert$1(value, options = {}) {
|
|
|
1571
2846
|
*/
|
|
1572
2847
|
function checksum(address) {
|
|
1573
2848
|
if (checksum$1.has(address)) return checksum$1.get(address);
|
|
1574
|
-
assert$
|
|
2849
|
+
assert$3(address, { strict: false });
|
|
1575
2850
|
const hexAddress = address.substring(2).toLowerCase();
|
|
1576
2851
|
const hash = keccak256(fromString(hexAddress), { as: "Bytes" });
|
|
1577
2852
|
const characters = hexAddress.split("");
|
|
@@ -1616,9 +2891,9 @@ function checksum(address) {
|
|
|
1616
2891
|
* @param options - Conversion options.
|
|
1617
2892
|
* @returns The typed Address.
|
|
1618
2893
|
*/
|
|
1619
|
-
function from$
|
|
2894
|
+
function from$4(address, options = {}) {
|
|
1620
2895
|
const { checksum: checksumVal = false } = options;
|
|
1621
|
-
assert$
|
|
2896
|
+
assert$3(address);
|
|
1622
2897
|
if (checksumVal) return checksum(address);
|
|
1623
2898
|
return address;
|
|
1624
2899
|
}
|
|
@@ -1641,7 +2916,7 @@ function from$3(address, options = {}) {
|
|
|
1641
2916
|
* @returns The {@link ox#Address.Address} corresponding to the public key.
|
|
1642
2917
|
*/
|
|
1643
2918
|
function fromPublicKey(publicKey, options = {}) {
|
|
1644
|
-
return from$
|
|
2919
|
+
return from$4(`0x${keccak256(`0x${toHex$2(publicKey).slice(4)}`).substring(26)}`, options);
|
|
1645
2920
|
}
|
|
1646
2921
|
/**
|
|
1647
2922
|
* Checks if two {@link ox#Address.Address} are equal.
|
|
@@ -1673,8 +2948,8 @@ function fromPublicKey(publicKey, options = {}) {
|
|
|
1673
2948
|
* @returns Whether the addresses are equal.
|
|
1674
2949
|
*/
|
|
1675
2950
|
function isEqual(addressA, addressB) {
|
|
1676
|
-
assert$
|
|
1677
|
-
assert$
|
|
2951
|
+
assert$3(addressA, { strict: false });
|
|
2952
|
+
assert$3(addressB, { strict: false });
|
|
1678
2953
|
return addressA.toLowerCase() === addressB.toLowerCase();
|
|
1679
2954
|
}
|
|
1680
2955
|
/**
|
|
@@ -1700,10 +2975,10 @@ function isEqual(addressA, addressB) {
|
|
|
1700
2975
|
* @param options - Check options.
|
|
1701
2976
|
* @returns Whether the address is a valid address.
|
|
1702
2977
|
*/
|
|
1703
|
-
function validate(address, options = {}) {
|
|
2978
|
+
function validate$2(address, options = {}) {
|
|
1704
2979
|
const { strict = true } = options ?? {};
|
|
1705
2980
|
try {
|
|
1706
|
-
assert$
|
|
2981
|
+
assert$3(address, { strict });
|
|
1707
2982
|
return true;
|
|
1708
2983
|
} catch {
|
|
1709
2984
|
return false;
|
|
@@ -2033,7 +3308,7 @@ function encode$1(preparedParameters) {
|
|
|
2033
3308
|
for (let i = 0; i < preparedParameters.length; i++) {
|
|
2034
3309
|
const { dynamic, encoded } = preparedParameters[i];
|
|
2035
3310
|
if (dynamic) staticSize += 32;
|
|
2036
|
-
else staticSize += size(encoded);
|
|
3311
|
+
else staticSize += size$1(encoded);
|
|
2037
3312
|
}
|
|
2038
3313
|
const staticParameters = [];
|
|
2039
3314
|
const dynamicParameters = [];
|
|
@@ -2043,7 +3318,7 @@ function encode$1(preparedParameters) {
|
|
|
2043
3318
|
if (dynamic) {
|
|
2044
3319
|
staticParameters.push(fromNumber(staticSize + dynamicSize, { size: 32 }));
|
|
2045
3320
|
dynamicParameters.push(encoded);
|
|
2046
|
-
dynamicSize += size(encoded);
|
|
3321
|
+
dynamicSize += size$1(encoded);
|
|
2047
3322
|
} else staticParameters.push(encoded);
|
|
2048
3323
|
}
|
|
2049
3324
|
return concat(...staticParameters, ...dynamicParameters);
|
|
@@ -2051,7 +3326,7 @@ function encode$1(preparedParameters) {
|
|
|
2051
3326
|
/** @internal */
|
|
2052
3327
|
function encodeAddress(value, options) {
|
|
2053
3328
|
const { checksum = false } = options;
|
|
2054
|
-
assert$
|
|
3329
|
+
assert$3(value, { strict: checksum });
|
|
2055
3330
|
return {
|
|
2056
3331
|
dynamic: false,
|
|
2057
3332
|
encoded: padLeft(value.toLowerCase())
|
|
@@ -2100,7 +3375,7 @@ function encodeArray(value, options) {
|
|
|
2100
3375
|
/** @internal */
|
|
2101
3376
|
function encodeBytes(value, { type }) {
|
|
2102
3377
|
const [, parametersize] = type.split("bytes");
|
|
2103
|
-
const bytesSize = size(value);
|
|
3378
|
+
const bytesSize = size$1(value);
|
|
2104
3379
|
if (!parametersize) {
|
|
2105
3380
|
let value_ = value;
|
|
2106
3381
|
if (bytesSize % 32 !== 0) value_ = padRight(value_, Math.ceil((value.length - 2) / 2 / 32) * 32);
|
|
@@ -2150,12 +3425,12 @@ function encodeNumber(value, { signed, size }) {
|
|
|
2150
3425
|
/** @internal */
|
|
2151
3426
|
function encodeString(value) {
|
|
2152
3427
|
const hexValue = fromString$1(value);
|
|
2153
|
-
const partsLength = Math.ceil(size(hexValue) / 32);
|
|
3428
|
+
const partsLength = Math.ceil(size$1(hexValue) / 32);
|
|
2154
3429
|
const parts = [];
|
|
2155
3430
|
for (let i = 0; i < partsLength; i++) parts.push(padRight(slice(hexValue, i * 32, (i + 1) * 32)));
|
|
2156
3431
|
return {
|
|
2157
3432
|
dynamic: true,
|
|
2158
|
-
encoded: concat(padRight(fromNumber(size(hexValue), { size: 32 })), ...parts)
|
|
3433
|
+
encoded: concat(padRight(fromNumber(size$1(hexValue), { size: 32 })), ...parts)
|
|
2159
3434
|
};
|
|
2160
3435
|
}
|
|
2161
3436
|
/** @internal */
|
|
@@ -2403,11 +3678,11 @@ function decode(parameters, data, options = {}) {
|
|
|
2403
3678
|
const { as = "Array", checksumAddress = false } = options;
|
|
2404
3679
|
const bytes = typeof data === "string" ? fromHex$3(data) : data;
|
|
2405
3680
|
const cursor = create(bytes);
|
|
2406
|
-
if (size$
|
|
2407
|
-
if (size$
|
|
3681
|
+
if (size$2(bytes) === 0 && parameters.length > 0) throw new ZeroDataError();
|
|
3682
|
+
if (size$2(bytes) && size$2(bytes) < 32) throw new DataSizeTooSmallError({
|
|
2408
3683
|
data: typeof data === "string" ? data : fromBytes$2(data),
|
|
2409
3684
|
parameters,
|
|
2410
|
-
size: size$
|
|
3685
|
+
size: size$2(bytes)
|
|
2411
3686
|
});
|
|
2412
3687
|
let consumed = 0;
|
|
2413
3688
|
const values = as === "Array" ? [] : {};
|
|
@@ -2508,7 +3783,7 @@ function encodePacked(types, values) {
|
|
|
2508
3783
|
function encode(type, value, isArray = false) {
|
|
2509
3784
|
if (type === "address") {
|
|
2510
3785
|
const address = value;
|
|
2511
|
-
assert$
|
|
3786
|
+
assert$3(address);
|
|
2512
3787
|
return padLeft(address.toLowerCase(), isArray ? 32 : 0);
|
|
2513
3788
|
}
|
|
2514
3789
|
if (type === "string") return fromString$1(value);
|
|
@@ -2628,7 +3903,7 @@ function encodePacked(types, values) {
|
|
|
2628
3903
|
* @param parameters - The ABI Parameters to parse.
|
|
2629
3904
|
* @returns The typed ABI Parameters.
|
|
2630
3905
|
*/
|
|
2631
|
-
function from$
|
|
3906
|
+
function from$3(parameters) {
|
|
2632
3907
|
if (Array.isArray(parameters) && typeof parameters[0] === "string") return parseAbiParameters(parameters);
|
|
2633
3908
|
if (typeof parameters === "string") return parseAbiParameters(parameters);
|
|
2634
3909
|
return parameters;
|
|
@@ -2770,7 +4045,7 @@ var ArrayLengthMismatchError = class extends BaseError {
|
|
|
2770
4045
|
*/
|
|
2771
4046
|
var BytesSizeMismatchError = class extends BaseError {
|
|
2772
4047
|
constructor({ expectedSize, value }) {
|
|
2773
|
-
super(`Size of bytes "${value}" (bytes${size(value)}) does not match expected size (bytes${expectedSize}).`);
|
|
4048
|
+
super(`Size of bytes "${value}" (bytes${size$1(value)}) does not match expected size (bytes${expectedSize}).`);
|
|
2774
4049
|
Object.defineProperty(this, "name", {
|
|
2775
4050
|
enumerable: true,
|
|
2776
4051
|
configurable: true,
|
|
@@ -2944,7 +4219,7 @@ function readList(cursor, length, to) {
|
|
|
2944
4219
|
* @param options - Options.
|
|
2945
4220
|
* @returns The RLP value.
|
|
2946
4221
|
*/
|
|
2947
|
-
function from$
|
|
4222
|
+
function from$2(value, options) {
|
|
2948
4223
|
const { as } = options;
|
|
2949
4224
|
const encodable = getEncodable(value);
|
|
2950
4225
|
const cursor = create(new Uint8Array(encodable.length));
|
|
@@ -2969,7 +4244,7 @@ function from$1(value, options) {
|
|
|
2969
4244
|
*/
|
|
2970
4245
|
function fromHex$1(hex, options = {}) {
|
|
2971
4246
|
const { as = "Hex" } = options;
|
|
2972
|
-
return from$
|
|
4247
|
+
return from$2(hex, { as });
|
|
2973
4248
|
}
|
|
2974
4249
|
function getEncodable(bytes) {
|
|
2975
4250
|
if (Array.isArray(bytes)) return getEncodableList(bytes.map((x) => getEncodable(x)));
|
|
@@ -3049,7 +4324,7 @@ function getSizeOfLength(length) {
|
|
|
3049
4324
|
*
|
|
3050
4325
|
* @param signature - The signature object to assert.
|
|
3051
4326
|
*/
|
|
3052
|
-
function assert(signature, options = {}) {
|
|
4327
|
+
function assert$2(signature, options = {}) {
|
|
3053
4328
|
const { recovered } = options;
|
|
3054
4329
|
if (typeof signature.r === "undefined") throw new MissingPropertiesError({ signature });
|
|
3055
4330
|
if (typeof signature.s === "undefined") throw new MissingPropertiesError({ signature });
|
|
@@ -3142,7 +4417,7 @@ function fromHex(signature) {
|
|
|
3142
4417
|
function extract(value) {
|
|
3143
4418
|
if (typeof value.r === "undefined") return void 0;
|
|
3144
4419
|
if (typeof value.s === "undefined") return void 0;
|
|
3145
|
-
return from(value);
|
|
4420
|
+
return from$1(value);
|
|
3146
4421
|
}
|
|
3147
4422
|
/**
|
|
3148
4423
|
* Instantiates a typed {@link ox#Signature.Signature} object from a {@link ox#Signature.Signature}, {@link ox#Signature.Legacy}, {@link ox#Bytes.Bytes}, or {@link ox#Hex.Hex}.
|
|
@@ -3198,11 +4473,11 @@ function extract(value) {
|
|
|
3198
4473
|
* @param signature - The signature value to instantiate.
|
|
3199
4474
|
* @returns The instantiated {@link ox#Signature.Signature}.
|
|
3200
4475
|
*/
|
|
3201
|
-
function from(signature) {
|
|
4476
|
+
function from$1(signature) {
|
|
3202
4477
|
const signature_ = (() => {
|
|
3203
4478
|
if (typeof signature === "string") return fromHex(signature);
|
|
3204
4479
|
if (signature instanceof Uint8Array) return fromBytes(signature);
|
|
3205
|
-
if (typeof signature.r === "string") return fromRpc(signature);
|
|
4480
|
+
if (typeof signature.r === "string") return fromRpc$1(signature);
|
|
3206
4481
|
if (signature.v) return fromLegacy(signature);
|
|
3207
4482
|
return {
|
|
3208
4483
|
r: signature.r,
|
|
@@ -3210,7 +4485,7 @@ function from(signature) {
|
|
|
3210
4485
|
...typeof signature.yParity !== "undefined" ? { yParity: signature.yParity } : {}
|
|
3211
4486
|
};
|
|
3212
4487
|
})();
|
|
3213
|
-
assert(signature_);
|
|
4488
|
+
assert$2(signature_);
|
|
3214
4489
|
return signature_;
|
|
3215
4490
|
}
|
|
3216
4491
|
/**
|
|
@@ -3251,7 +4526,7 @@ function fromLegacy(signature) {
|
|
|
3251
4526
|
* @param signature - The {@link ox#Signature.Rpc} to convert.
|
|
3252
4527
|
* @returns The converted {@link ox#Signature.Signature}.
|
|
3253
4528
|
*/
|
|
3254
|
-
function fromRpc(signature) {
|
|
4529
|
+
function fromRpc$1(signature) {
|
|
3255
4530
|
const yParity = (() => {
|
|
3256
4531
|
const v = signature.v ? Number(signature.v) : void 0;
|
|
3257
4532
|
let yParity = signature.yParity ? Number(signature.yParity) : void 0;
|
|
@@ -3285,7 +4560,7 @@ function fromRpc(signature) {
|
|
|
3285
4560
|
*/
|
|
3286
4561
|
function fromTuple(tuple) {
|
|
3287
4562
|
const [yParity, r, s] = tuple;
|
|
3288
|
-
return from({
|
|
4563
|
+
return from$1({
|
|
3289
4564
|
r: r === "0x" ? 0n : BigInt(r),
|
|
3290
4565
|
s: s === "0x" ? 0n : BigInt(s),
|
|
3291
4566
|
yParity: yParity === "0x" ? 0 : Number(yParity)
|
|
@@ -3310,7 +4585,7 @@ function fromTuple(tuple) {
|
|
|
3310
4585
|
* @returns The serialized signature.
|
|
3311
4586
|
*/
|
|
3312
4587
|
function toHex(signature) {
|
|
3313
|
-
assert(signature);
|
|
4588
|
+
assert$2(signature);
|
|
3314
4589
|
const r = signature.r;
|
|
3315
4590
|
const s = signature.s;
|
|
3316
4591
|
return concat(fromNumber(r, { size: 32 }), fromNumber(s, { size: 32 }), typeof signature.yParity === "number" ? fromNumber(yParityToV(signature.yParity), { size: 1 }) : "0x");
|
|
@@ -3332,7 +4607,7 @@ function toHex(signature) {
|
|
|
3332
4607
|
* @param signature - The {@link ox#Signature.Signature} to convert.
|
|
3333
4608
|
* @returns The converted {@link ox#Signature.Rpc}.
|
|
3334
4609
|
*/
|
|
3335
|
-
function toRpc(signature) {
|
|
4610
|
+
function toRpc$1(signature) {
|
|
3336
4611
|
const { r, s, yParity } = signature;
|
|
3337
4612
|
return {
|
|
3338
4613
|
r: fromNumber(r, { size: 32 }),
|
|
@@ -3408,7 +4683,7 @@ function yParityToV(yParity) {
|
|
|
3408
4683
|
/** Thrown when the serialized signature is of an invalid size. */
|
|
3409
4684
|
var InvalidSerializedSizeError = class extends BaseError {
|
|
3410
4685
|
constructor({ signature }) {
|
|
3411
|
-
super(`Value \`${signature}\` is an invalid signature size.`, { metaMessages: ["Expected: 64 bytes or 65 bytes.", `Received ${size(from$
|
|
4686
|
+
super(`Value \`${signature}\` is an invalid signature size.`, { metaMessages: ["Expected: 64 bytes or 65 bytes.", `Received ${size$1(from$7(signature))} bytes.`] });
|
|
3412
4687
|
Object.defineProperty(this, "name", {
|
|
3413
4688
|
enumerable: true,
|
|
3414
4689
|
configurable: true,
|
|
@@ -3478,6 +4753,163 @@ var InvalidVError = class extends BaseError {
|
|
|
3478
4753
|
}
|
|
3479
4754
|
};
|
|
3480
4755
|
//#endregion
|
|
4756
|
+
//#region node_modules/.pnpm/ox@0.14.7_typescript@5.9.3_zod@4.3.6/node_modules/ox/_esm/core/Authorization.js
|
|
4757
|
+
/**
|
|
4758
|
+
* Converts an [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702) Authorization object into a typed {@link ox#Authorization.Authorization}.
|
|
4759
|
+
*
|
|
4760
|
+
* @example
|
|
4761
|
+
* An Authorization can be instantiated from an [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702) Authorization tuple in object format.
|
|
4762
|
+
*
|
|
4763
|
+
* ```ts twoslash
|
|
4764
|
+
* import { Authorization } from 'ox'
|
|
4765
|
+
*
|
|
4766
|
+
* const authorization = Authorization.from({
|
|
4767
|
+
* address: '0x1234567890abcdef1234567890abcdef12345678',
|
|
4768
|
+
* chainId: 1,
|
|
4769
|
+
* nonce: 69n,
|
|
4770
|
+
* })
|
|
4771
|
+
* ```
|
|
4772
|
+
*
|
|
4773
|
+
* @example
|
|
4774
|
+
* ### Attaching Signatures
|
|
4775
|
+
*
|
|
4776
|
+
* A {@link ox#Signature.Signature} can be attached with the `signature` option. The example below demonstrates signing
|
|
4777
|
+
* an Authorization with {@link ox#Secp256k1.(sign:function)}.
|
|
4778
|
+
*
|
|
4779
|
+
* ```ts twoslash
|
|
4780
|
+
* import { Authorization, Secp256k1 } from 'ox'
|
|
4781
|
+
*
|
|
4782
|
+
* const authorization = Authorization.from({
|
|
4783
|
+
* address: '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',
|
|
4784
|
+
* chainId: 1,
|
|
4785
|
+
* nonce: 40n,
|
|
4786
|
+
* })
|
|
4787
|
+
*
|
|
4788
|
+
* const signature = Secp256k1.sign({
|
|
4789
|
+
* payload: Authorization.getSignPayload(authorization),
|
|
4790
|
+
* privateKey: '0x...',
|
|
4791
|
+
* })
|
|
4792
|
+
*
|
|
4793
|
+
* const authorization_signed = Authorization.from(authorization, { signature }) // [!code focus]
|
|
4794
|
+
* ```
|
|
4795
|
+
*
|
|
4796
|
+
* @param authorization - An [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702) Authorization tuple in object format.
|
|
4797
|
+
* @param options - Authorization options.
|
|
4798
|
+
* @returns The {@link ox#Authorization.Authorization}.
|
|
4799
|
+
*/
|
|
4800
|
+
function from(authorization, options = {}) {
|
|
4801
|
+
if (typeof authorization.chainId === "string") return fromRpc(authorization);
|
|
4802
|
+
return {
|
|
4803
|
+
...authorization,
|
|
4804
|
+
...options.signature
|
|
4805
|
+
};
|
|
4806
|
+
}
|
|
4807
|
+
/**
|
|
4808
|
+
* Converts an {@link ox#Authorization.Rpc} to an {@link ox#Authorization.Authorization}.
|
|
4809
|
+
*
|
|
4810
|
+
* @example
|
|
4811
|
+
* ```ts twoslash
|
|
4812
|
+
* import { Authorization } from 'ox'
|
|
4813
|
+
*
|
|
4814
|
+
* const authorization = Authorization.fromRpc({
|
|
4815
|
+
* address: '0x0000000000000000000000000000000000000000',
|
|
4816
|
+
* chainId: '0x1',
|
|
4817
|
+
* nonce: '0x1',
|
|
4818
|
+
* r: '0x635dc2033e60185bb36709c29c75d64ea51dfbd91c32ef4be198e4ceb169fb4d',
|
|
4819
|
+
* s: '0x50c2667ac4c771072746acfdcf1f1483336dcca8bd2df47cd83175dbe60f0540',
|
|
4820
|
+
* yParity: '0x0',
|
|
4821
|
+
* })
|
|
4822
|
+
* ```
|
|
4823
|
+
*
|
|
4824
|
+
* @param authorization - The RPC-formatted Authorization.
|
|
4825
|
+
* @returns A signed {@link ox#Authorization.Authorization}.
|
|
4826
|
+
*/
|
|
4827
|
+
function fromRpc(authorization) {
|
|
4828
|
+
const { address, chainId, nonce } = authorization;
|
|
4829
|
+
const signature = extract(authorization);
|
|
4830
|
+
return {
|
|
4831
|
+
address,
|
|
4832
|
+
chainId: Number(chainId),
|
|
4833
|
+
nonce: BigInt(nonce),
|
|
4834
|
+
...signature
|
|
4835
|
+
};
|
|
4836
|
+
}
|
|
4837
|
+
/**
|
|
4838
|
+
* Converts an {@link ox#Authorization.ListRpc} to an {@link ox#Authorization.List}.
|
|
4839
|
+
*
|
|
4840
|
+
* @example
|
|
4841
|
+
* ```ts twoslash
|
|
4842
|
+
* import { Authorization } from 'ox'
|
|
4843
|
+
*
|
|
4844
|
+
* const authorizationList = Authorization.fromRpcList([{
|
|
4845
|
+
* address: '0x0000000000000000000000000000000000000000',
|
|
4846
|
+
* chainId: '0x1',
|
|
4847
|
+
* nonce: '0x1',
|
|
4848
|
+
* r: '0x635dc2033e60185bb36709c29c75d64ea51dfbd91c32ef4be198e4ceb169fb4d',
|
|
4849
|
+
* s: '0x50c2667ac4c771072746acfdcf1f1483336dcca8bd2df47cd83175dbe60f0540',
|
|
4850
|
+
* yParity: '0x0',
|
|
4851
|
+
* }])
|
|
4852
|
+
* ```
|
|
4853
|
+
*
|
|
4854
|
+
* @param authorizationList - The RPC-formatted Authorization list.
|
|
4855
|
+
* @returns A signed {@link ox#Authorization.List}.
|
|
4856
|
+
*/
|
|
4857
|
+
function fromRpcList(authorizationList) {
|
|
4858
|
+
return authorizationList.map(fromRpc);
|
|
4859
|
+
}
|
|
4860
|
+
/**
|
|
4861
|
+
* Converts an {@link ox#Authorization.Authorization} to an {@link ox#Authorization.Rpc}.
|
|
4862
|
+
*
|
|
4863
|
+
* @example
|
|
4864
|
+
* ```ts twoslash
|
|
4865
|
+
* import { Authorization } from 'ox'
|
|
4866
|
+
*
|
|
4867
|
+
* const authorization = Authorization.toRpc({
|
|
4868
|
+
* address: '0x0000000000000000000000000000000000000000',
|
|
4869
|
+
* chainId: 1,
|
|
4870
|
+
* nonce: 1n,
|
|
4871
|
+
* r: 44944627813007772897391531230081695102703289123332187696115181104739239197517n,
|
|
4872
|
+
* s: 36528503505192438307355164441104001310566505351980369085208178712678799181120n,
|
|
4873
|
+
* yParity: 0,
|
|
4874
|
+
* })
|
|
4875
|
+
* ```
|
|
4876
|
+
*
|
|
4877
|
+
* @param authorization - An Authorization.
|
|
4878
|
+
* @returns An RPC-formatted Authorization.
|
|
4879
|
+
*/
|
|
4880
|
+
function toRpc(authorization) {
|
|
4881
|
+
const { address, chainId, nonce, ...signature } = authorization;
|
|
4882
|
+
return {
|
|
4883
|
+
address,
|
|
4884
|
+
chainId: fromNumber(chainId),
|
|
4885
|
+
nonce: fromNumber(nonce),
|
|
4886
|
+
...toRpc$1(signature)
|
|
4887
|
+
};
|
|
4888
|
+
}
|
|
4889
|
+
/**
|
|
4890
|
+
* Converts an {@link ox#Authorization.List} to an {@link ox#Authorization.ListRpc}.
|
|
4891
|
+
*
|
|
4892
|
+
* @example
|
|
4893
|
+
* ```ts twoslash
|
|
4894
|
+
* import { Authorization } from 'ox'
|
|
4895
|
+
*
|
|
4896
|
+
* const authorization = Authorization.toRpcList([{
|
|
4897
|
+
* address: '0x0000000000000000000000000000000000000000',
|
|
4898
|
+
* chainId: 1,
|
|
4899
|
+
* nonce: 1n,
|
|
4900
|
+
* r: 44944627813007772897391531230081695102703289123332187696115181104739239197517n,
|
|
4901
|
+
* s: 36528503505192438307355164441104001310566505351980369085208178712678799181120n,
|
|
4902
|
+
* yParity: 0,
|
|
4903
|
+
* }])
|
|
4904
|
+
* ```
|
|
4905
|
+
*
|
|
4906
|
+
* @param authorizationList - An Authorization List.
|
|
4907
|
+
* @returns An RPC-formatted Authorization List.
|
|
4908
|
+
*/
|
|
4909
|
+
function toRpcList(authorizationList) {
|
|
4910
|
+
return authorizationList.map(toRpc);
|
|
4911
|
+
}
|
|
4912
|
+
//#endregion
|
|
3481
4913
|
//#region node_modules/.pnpm/ox@0.14.7_typescript@5.9.3_zod@4.3.6/node_modules/ox/_esm/core/Secp256k1.js
|
|
3482
4914
|
/**
|
|
3483
4915
|
* Recovers the signing address from the signed payload and signature.
|
|
@@ -3521,7 +4953,7 @@ function recoverAddress(options) {
|
|
|
3521
4953
|
function recoverPublicKey(options) {
|
|
3522
4954
|
const { payload, signature } = options;
|
|
3523
4955
|
const { r, s, yParity } = signature;
|
|
3524
|
-
return from$
|
|
4956
|
+
return from$5(new secp256k1.Signature(BigInt(r), BigInt(s)).addRecoveryBit(yParity).recoverPublicKey(from$7(payload).substring(2)));
|
|
3525
4957
|
}
|
|
3526
4958
|
/**
|
|
3527
4959
|
* Verifies a payload was signed by the provided address.
|
|
@@ -3567,46 +4999,631 @@ function verify(options) {
|
|
|
3567
4999
|
payload,
|
|
3568
5000
|
signature
|
|
3569
5001
|
}));
|
|
3570
|
-
return secp256k1.verify(signature, from$
|
|
5002
|
+
return secp256k1.verify(signature, from$6(payload), toBytes(publicKey), ...hash ? [{
|
|
3571
5003
|
prehash: true,
|
|
3572
5004
|
lowS: true
|
|
3573
5005
|
}] : []);
|
|
3574
5006
|
}
|
|
5007
|
+
/** Suffix ABI parameters for the ERC-8010 wrapped signature. */
|
|
5008
|
+
const suffixParameters = from$3("(uint256 chainId, address delegation, uint256 nonce, uint8 yParity, uint256 r, uint256 s), address to, bytes data");
|
|
5009
|
+
/**
|
|
5010
|
+
* Asserts that the wrapped signature is valid.
|
|
5011
|
+
*
|
|
5012
|
+
* @example
|
|
5013
|
+
* ```ts twoslash
|
|
5014
|
+
* import { SignatureErc8010 } from 'ox/erc8010'
|
|
5015
|
+
*
|
|
5016
|
+
* SignatureErc8010.assert('0xdeadbeef')
|
|
5017
|
+
* // @error: InvalidWrappedSignatureError: Value `0xdeadbeef` is an invalid ERC-8010 wrapped signature.
|
|
5018
|
+
* ```
|
|
5019
|
+
*
|
|
5020
|
+
* @param value - The value to assert.
|
|
5021
|
+
*/
|
|
5022
|
+
function assert$1(value) {
|
|
5023
|
+
if (typeof value === "string") {
|
|
5024
|
+
if (slice(value, -32) !== "0x8010801080108010801080108010801080108010801080108010801080108010") throw new InvalidWrappedSignatureError$1(value);
|
|
5025
|
+
} else assert$2(value.authorization);
|
|
5026
|
+
}
|
|
5027
|
+
/**
|
|
5028
|
+
* Unwraps an [ERC-8010 wrapped signature](https://github.com/jxom/ERCs/blob/16f7e3891fff2e1e9c25dea0485497739db8a816/ERCS/erc-8010.md) into its constituent parts.
|
|
5029
|
+
*
|
|
5030
|
+
* @example
|
|
5031
|
+
* ```ts twoslash
|
|
5032
|
+
* import { SignatureErc8010 } from 'ox/erc8010'
|
|
5033
|
+
*
|
|
5034
|
+
* const { authorization, data, signature } = SignatureErc8010.unwrap('0x...')
|
|
5035
|
+
* ```
|
|
5036
|
+
*
|
|
5037
|
+
* @param wrapped - Wrapped signature to unwrap.
|
|
5038
|
+
* @returns Unwrapped signature.
|
|
5039
|
+
*/
|
|
5040
|
+
function unwrap(wrapped) {
|
|
5041
|
+
assert$1(wrapped);
|
|
5042
|
+
const suffixLength = toNumber$1(slice(wrapped, -64, -32));
|
|
5043
|
+
const suffix = slice(wrapped, -suffixLength - 64, -64);
|
|
5044
|
+
const signature = slice(wrapped, 0, -suffixLength - 64);
|
|
5045
|
+
const [auth, to, data] = decode(suffixParameters, suffix);
|
|
5046
|
+
return {
|
|
5047
|
+
authorization: from({
|
|
5048
|
+
address: auth.delegation,
|
|
5049
|
+
chainId: Number(auth.chainId),
|
|
5050
|
+
nonce: auth.nonce,
|
|
5051
|
+
yParity: auth.yParity,
|
|
5052
|
+
r: auth.r,
|
|
5053
|
+
s: auth.s
|
|
5054
|
+
}),
|
|
5055
|
+
signature,
|
|
5056
|
+
...data && data !== "0x" ? {
|
|
5057
|
+
data,
|
|
5058
|
+
to
|
|
5059
|
+
} : {}
|
|
5060
|
+
};
|
|
5061
|
+
}
|
|
5062
|
+
/**
|
|
5063
|
+
* Validates a wrapped signature. Returns `true` if the wrapped signature is valid, `false` otherwise.
|
|
5064
|
+
*
|
|
5065
|
+
* @example
|
|
5066
|
+
* ```ts twoslash
|
|
5067
|
+
* import { SignatureErc8010 } from 'ox/erc8010'
|
|
5068
|
+
*
|
|
5069
|
+
* const valid = SignatureErc8010.validate('0xdeadbeef')
|
|
5070
|
+
* // @log: false
|
|
5071
|
+
* ```
|
|
5072
|
+
*
|
|
5073
|
+
* @param value - The value to validate.
|
|
5074
|
+
* @returns `true` if the value is valid, `false` otherwise.
|
|
5075
|
+
*/
|
|
5076
|
+
function validate$1(value) {
|
|
5077
|
+
try {
|
|
5078
|
+
assert$1(value);
|
|
5079
|
+
return true;
|
|
5080
|
+
} catch {
|
|
5081
|
+
return false;
|
|
5082
|
+
}
|
|
5083
|
+
}
|
|
5084
|
+
/** Thrown when the ERC-8010 wrapped signature is invalid. */
|
|
5085
|
+
var InvalidWrappedSignatureError$1 = class extends BaseError {
|
|
5086
|
+
constructor(wrapped) {
|
|
5087
|
+
super(`Value \`${wrapped}\` is an invalid ERC-8010 wrapped signature.`);
|
|
5088
|
+
Object.defineProperty(this, "name", {
|
|
5089
|
+
enumerable: true,
|
|
5090
|
+
configurable: true,
|
|
5091
|
+
writable: true,
|
|
5092
|
+
value: "SignatureErc8010.InvalidWrappedSignatureError"
|
|
5093
|
+
});
|
|
5094
|
+
}
|
|
5095
|
+
};
|
|
3575
5096
|
//#endregion
|
|
3576
|
-
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/actions/
|
|
5097
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/actions/public/getTransactionReceipt.js
|
|
3577
5098
|
/**
|
|
3578
|
-
*
|
|
3579
|
-
* and waits for the transaction to be included in a block.
|
|
5099
|
+
* Returns the [Transaction Receipt](https://viem.sh/docs/glossary/terms#transaction-receipt) given a [Transaction](https://viem.sh/docs/glossary/terms#transaction) hash.
|
|
3580
5100
|
*
|
|
3581
|
-
* - Docs: https://viem.sh/docs/actions/
|
|
3582
|
-
* -
|
|
5101
|
+
* - Docs: https://viem.sh/docs/actions/public/getTransactionReceipt
|
|
5102
|
+
* - Example: https://stackblitz.com/github/wevm/viem/tree/main/examples/transactions_fetching-transactions
|
|
5103
|
+
* - JSON-RPC Methods: [`eth_getTransactionReceipt`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_gettransactionreceipt)
|
|
3583
5104
|
*
|
|
3584
5105
|
* @param client - Client to use
|
|
3585
|
-
* @param parameters - {@link
|
|
3586
|
-
* @returns The transaction receipt. {@link
|
|
5106
|
+
* @param parameters - {@link GetTransactionReceiptParameters}
|
|
5107
|
+
* @returns The transaction receipt. {@link GetTransactionReceiptReturnType}
|
|
3587
5108
|
*
|
|
3588
5109
|
* @example
|
|
3589
|
-
* import {
|
|
5110
|
+
* import { createPublicClient, http } from 'viem'
|
|
3590
5111
|
* import { mainnet } from 'viem/chains'
|
|
3591
|
-
* import {
|
|
5112
|
+
* import { getTransactionReceipt } from 'viem/public'
|
|
3592
5113
|
*
|
|
3593
|
-
* const client =
|
|
5114
|
+
* const client = createPublicClient({
|
|
3594
5115
|
* chain: mainnet,
|
|
3595
|
-
* transport:
|
|
5116
|
+
* transport: http(),
|
|
3596
5117
|
* })
|
|
3597
|
-
*
|
|
3598
|
-
*
|
|
3599
|
-
* serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33'
|
|
5118
|
+
* const transactionReceipt = await getTransactionReceipt(client, {
|
|
5119
|
+
* hash: '0x4ca7ee652d57678f26e887c149ab0735f41de37bcad58c9f6d3ed5824f15b74d',
|
|
3600
5120
|
* })
|
|
3601
5121
|
*/
|
|
3602
|
-
async function
|
|
5122
|
+
async function getTransactionReceipt(client, { hash }) {
|
|
3603
5123
|
const receipt = await client.request({
|
|
3604
|
-
method: "
|
|
3605
|
-
params:
|
|
3606
|
-
}, {
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
5124
|
+
method: "eth_getTransactionReceipt",
|
|
5125
|
+
params: [hash]
|
|
5126
|
+
}, { dedupe: true });
|
|
5127
|
+
if (!receipt) throw new TransactionReceiptNotFoundError({ hash });
|
|
5128
|
+
return (client.chain?.formatters?.transactionReceipt?.format || formatTransactionReceipt)(receipt, "getTransactionReceipt");
|
|
5129
|
+
}
|
|
5130
|
+
//#endregion
|
|
5131
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/actions/public/multicall.js
|
|
5132
|
+
/**
|
|
5133
|
+
* 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).
|
|
5134
|
+
*
|
|
5135
|
+
* - Docs: https://viem.sh/docs/contract/multicall
|
|
5136
|
+
*
|
|
5137
|
+
* @param client - Client to use
|
|
5138
|
+
* @param parameters - {@link MulticallParameters}
|
|
5139
|
+
* @returns An array of results with accompanying status. {@link MulticallReturnType}
|
|
5140
|
+
*
|
|
5141
|
+
* @example
|
|
5142
|
+
* import { createPublicClient, http, parseAbi } from 'viem'
|
|
5143
|
+
* import { mainnet } from 'viem/chains'
|
|
5144
|
+
* import { multicall } from 'viem/contract'
|
|
5145
|
+
*
|
|
5146
|
+
* const client = createPublicClient({
|
|
5147
|
+
* chain: mainnet,
|
|
5148
|
+
* transport: http(),
|
|
5149
|
+
* })
|
|
5150
|
+
* const abi = parseAbi([
|
|
5151
|
+
* 'function balanceOf(address) view returns (uint256)',
|
|
5152
|
+
* 'function totalSupply() view returns (uint256)',
|
|
5153
|
+
* ])
|
|
5154
|
+
* const results = await multicall(client, {
|
|
5155
|
+
* contracts: [
|
|
5156
|
+
* {
|
|
5157
|
+
* address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
|
|
5158
|
+
* abi,
|
|
5159
|
+
* functionName: 'balanceOf',
|
|
5160
|
+
* args: ['0xA0Cf798816D4b9b9866b5330EEa46a18382f251e'],
|
|
5161
|
+
* },
|
|
5162
|
+
* {
|
|
5163
|
+
* address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
|
|
5164
|
+
* abi,
|
|
5165
|
+
* functionName: 'totalSupply',
|
|
5166
|
+
* },
|
|
5167
|
+
* ],
|
|
5168
|
+
* })
|
|
5169
|
+
* // [{ result: 424122n, status: 'success' }, { result: 1000000n, status: 'success' }]
|
|
5170
|
+
*/
|
|
5171
|
+
async function multicall(client, parameters) {
|
|
5172
|
+
const { account, authorizationList, allowFailure = true, blockNumber, blockOverrides, blockTag, stateOverride } = parameters;
|
|
5173
|
+
const contracts = parameters.contracts;
|
|
5174
|
+
const { batchSize = parameters.batchSize ?? 1024, deployless = parameters.deployless ?? false } = typeof client.batch?.multicall === "object" ? client.batch.multicall : {};
|
|
5175
|
+
const multicallAddress = (() => {
|
|
5176
|
+
if (parameters.multicallAddress) return parameters.multicallAddress;
|
|
5177
|
+
if (deployless) return null;
|
|
5178
|
+
if (client.chain) return getChainContractAddress({
|
|
5179
|
+
blockNumber,
|
|
5180
|
+
chain: client.chain,
|
|
5181
|
+
contract: "multicall3"
|
|
5182
|
+
});
|
|
5183
|
+
throw new Error("client chain not configured. multicallAddress is required.");
|
|
5184
|
+
})();
|
|
5185
|
+
const chunkedCalls = [[]];
|
|
5186
|
+
let currentChunk = 0;
|
|
5187
|
+
let currentChunkSize = 0;
|
|
5188
|
+
for (let i = 0; i < contracts.length; i++) {
|
|
5189
|
+
const { abi, address, args, functionName } = contracts[i];
|
|
5190
|
+
try {
|
|
5191
|
+
const callData = encodeFunctionData({
|
|
5192
|
+
abi,
|
|
5193
|
+
args,
|
|
5194
|
+
functionName
|
|
5195
|
+
});
|
|
5196
|
+
currentChunkSize += (callData.length - 2) / 2;
|
|
5197
|
+
if (batchSize > 0 && currentChunkSize > batchSize && chunkedCalls[currentChunk].length > 0) {
|
|
5198
|
+
currentChunk++;
|
|
5199
|
+
currentChunkSize = (callData.length - 2) / 2;
|
|
5200
|
+
chunkedCalls[currentChunk] = [];
|
|
5201
|
+
}
|
|
5202
|
+
chunkedCalls[currentChunk] = [...chunkedCalls[currentChunk], {
|
|
5203
|
+
allowFailure: true,
|
|
5204
|
+
callData,
|
|
5205
|
+
target: address
|
|
5206
|
+
}];
|
|
5207
|
+
} catch (err) {
|
|
5208
|
+
const error = getContractError(err, {
|
|
5209
|
+
abi,
|
|
5210
|
+
address,
|
|
5211
|
+
args,
|
|
5212
|
+
docsPath: "/docs/contract/multicall",
|
|
5213
|
+
functionName,
|
|
5214
|
+
sender: account
|
|
5215
|
+
});
|
|
5216
|
+
if (!allowFailure) throw error;
|
|
5217
|
+
chunkedCalls[currentChunk] = [...chunkedCalls[currentChunk], {
|
|
5218
|
+
allowFailure: true,
|
|
5219
|
+
callData: "0x",
|
|
5220
|
+
target: address
|
|
5221
|
+
}];
|
|
5222
|
+
}
|
|
5223
|
+
}
|
|
5224
|
+
const aggregate3Results = await Promise.allSettled(chunkedCalls.map((calls) => getAction(client, readContract, "readContract")({
|
|
5225
|
+
...multicallAddress === null ? { code: multicall3Bytecode } : { address: multicallAddress },
|
|
5226
|
+
abi: multicall3Abi,
|
|
5227
|
+
account,
|
|
5228
|
+
args: [calls],
|
|
5229
|
+
authorizationList,
|
|
5230
|
+
blockNumber,
|
|
5231
|
+
blockOverrides,
|
|
5232
|
+
blockTag,
|
|
5233
|
+
functionName: "aggregate3",
|
|
5234
|
+
stateOverride
|
|
5235
|
+
})));
|
|
5236
|
+
const results = [];
|
|
5237
|
+
for (let i = 0; i < aggregate3Results.length; i++) {
|
|
5238
|
+
const result = aggregate3Results[i];
|
|
5239
|
+
if (result.status === "rejected") {
|
|
5240
|
+
if (!allowFailure) throw result.reason;
|
|
5241
|
+
for (let j = 0; j < chunkedCalls[i].length; j++) results.push({
|
|
5242
|
+
status: "failure",
|
|
5243
|
+
error: result.reason,
|
|
5244
|
+
result: void 0
|
|
5245
|
+
});
|
|
5246
|
+
continue;
|
|
5247
|
+
}
|
|
5248
|
+
const aggregate3Result = result.value;
|
|
5249
|
+
for (let j = 0; j < aggregate3Result.length; j++) {
|
|
5250
|
+
const { returnData, success } = aggregate3Result[j];
|
|
5251
|
+
const { callData } = chunkedCalls[i][j];
|
|
5252
|
+
const { abi, address, functionName, args } = contracts[results.length];
|
|
5253
|
+
try {
|
|
5254
|
+
if (callData === "0x") throw new AbiDecodingZeroDataError();
|
|
5255
|
+
if (!success) throw new RawContractError({ data: returnData });
|
|
5256
|
+
const result = decodeFunctionResult({
|
|
5257
|
+
abi,
|
|
5258
|
+
args,
|
|
5259
|
+
data: returnData,
|
|
5260
|
+
functionName
|
|
5261
|
+
});
|
|
5262
|
+
results.push(allowFailure ? {
|
|
5263
|
+
result,
|
|
5264
|
+
status: "success"
|
|
5265
|
+
} : result);
|
|
5266
|
+
} catch (err) {
|
|
5267
|
+
const error = getContractError(err, {
|
|
5268
|
+
abi,
|
|
5269
|
+
address,
|
|
5270
|
+
args,
|
|
5271
|
+
docsPath: "/docs/contract/multicall",
|
|
5272
|
+
functionName
|
|
5273
|
+
});
|
|
5274
|
+
if (!allowFailure) throw error;
|
|
5275
|
+
results.push({
|
|
5276
|
+
error,
|
|
5277
|
+
result: void 0,
|
|
5278
|
+
status: "failure"
|
|
5279
|
+
});
|
|
5280
|
+
}
|
|
5281
|
+
}
|
|
5282
|
+
}
|
|
5283
|
+
if (results.length !== contracts.length) throw new BaseError$1("multicall results mismatch");
|
|
5284
|
+
return results;
|
|
5285
|
+
}
|
|
5286
|
+
//#endregion
|
|
5287
|
+
//#region node_modules/.pnpm/ox@0.14.7_typescript@5.9.3_zod@4.3.6/node_modules/ox/_esm/erc6492/SignatureErc6492.js
|
|
5288
|
+
/**
|
|
5289
|
+
* Magic bytes used to identify ERC-6492 wrapped signatures.
|
|
5290
|
+
*/
|
|
5291
|
+
const magicBytes = "0x6492649264926492649264926492649264926492649264926492649264926492";
|
|
5292
|
+
/**
|
|
5293
|
+
* Asserts that the wrapped signature is valid.
|
|
5294
|
+
*
|
|
5295
|
+
* @example
|
|
5296
|
+
* ```ts twoslash
|
|
5297
|
+
* import { SignatureErc6492 } from 'ox/erc6492'
|
|
5298
|
+
*
|
|
5299
|
+
* SignatureErc6492.assert('0xdeadbeef')
|
|
5300
|
+
* // @error: InvalidWrappedSignatureError: Value `0xdeadbeef` is an invalid ERC-6492 wrapped signature.
|
|
5301
|
+
* ```
|
|
5302
|
+
*
|
|
5303
|
+
* @param wrapped - The wrapped signature to assert.
|
|
5304
|
+
*/
|
|
5305
|
+
function assert(wrapped) {
|
|
5306
|
+
if (slice(wrapped, -32) !== "0x6492649264926492649264926492649264926492649264926492649264926492") throw new InvalidWrappedSignatureError(wrapped);
|
|
5307
|
+
}
|
|
5308
|
+
/**
|
|
5309
|
+
* Serializes an [ERC-6492 wrapped signature](https://eips.ethereum.org/EIPS/eip-6492#specification).
|
|
5310
|
+
*
|
|
5311
|
+
* @example
|
|
5312
|
+
* ```ts twoslash
|
|
5313
|
+
* import { Secp256k1, Signature } from 'ox'
|
|
5314
|
+
* import { SignatureErc6492 } from 'ox/erc6492' // [!code focus]
|
|
5315
|
+
*
|
|
5316
|
+
* const signature = Secp256k1.sign({
|
|
5317
|
+
* payload: '0x...',
|
|
5318
|
+
* privateKey: '0x...',
|
|
5319
|
+
* })
|
|
5320
|
+
*
|
|
5321
|
+
* const wrapped = SignatureErc6492.wrap({ // [!code focus]
|
|
5322
|
+
* data: '0xdeadbeef', // [!code focus]
|
|
5323
|
+
* signature: Signature.toHex(signature), // [!code focus]
|
|
5324
|
+
* to: '0x00000000219ab540356cBB839Cbe05303d7705Fa', // [!code focus]
|
|
5325
|
+
* }) // [!code focus]
|
|
5326
|
+
* ```
|
|
5327
|
+
*
|
|
5328
|
+
* @param value - Wrapped signature to serialize.
|
|
5329
|
+
* @returns Serialized wrapped signature.
|
|
5330
|
+
*/
|
|
5331
|
+
function wrap(value) {
|
|
5332
|
+
const { data, signature, to } = value;
|
|
5333
|
+
return concat(encode(from$3("address, bytes, bytes"), [
|
|
5334
|
+
to,
|
|
5335
|
+
data,
|
|
5336
|
+
signature
|
|
5337
|
+
]), magicBytes);
|
|
5338
|
+
}
|
|
5339
|
+
/**
|
|
5340
|
+
* Validates a wrapped signature. Returns `true` if the wrapped signature is valid, `false` otherwise.
|
|
5341
|
+
*
|
|
5342
|
+
* @example
|
|
5343
|
+
* ```ts twoslash
|
|
5344
|
+
* import { SignatureErc6492 } from 'ox/erc6492'
|
|
5345
|
+
*
|
|
5346
|
+
* const valid = SignatureErc6492.validate('0xdeadbeef')
|
|
5347
|
+
* // @log: false
|
|
5348
|
+
* ```
|
|
5349
|
+
*
|
|
5350
|
+
* @param wrapped - The wrapped signature to validate.
|
|
5351
|
+
* @returns `true` if the wrapped signature is valid, `false` otherwise.
|
|
5352
|
+
*/
|
|
5353
|
+
function validate(wrapped) {
|
|
5354
|
+
try {
|
|
5355
|
+
assert(wrapped);
|
|
5356
|
+
return true;
|
|
5357
|
+
} catch {
|
|
5358
|
+
return false;
|
|
5359
|
+
}
|
|
5360
|
+
}
|
|
5361
|
+
/** Thrown when the ERC-6492 wrapped signature is invalid. */
|
|
5362
|
+
var InvalidWrappedSignatureError = class extends BaseError {
|
|
5363
|
+
constructor(wrapped) {
|
|
5364
|
+
super(`Value \`${wrapped}\` is an invalid ERC-6492 wrapped signature.`);
|
|
5365
|
+
Object.defineProperty(this, "name", {
|
|
5366
|
+
enumerable: true,
|
|
5367
|
+
configurable: true,
|
|
5368
|
+
writable: true,
|
|
5369
|
+
value: "SignatureErc6492.InvalidWrappedSignatureError"
|
|
5370
|
+
});
|
|
5371
|
+
}
|
|
5372
|
+
};
|
|
5373
|
+
//#endregion
|
|
5374
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/actions/public/verifyHash.js
|
|
5375
|
+
/**
|
|
5376
|
+
* Verifies a message hash onchain using ERC-6492.
|
|
5377
|
+
*
|
|
5378
|
+
* @param client - Client to use.
|
|
5379
|
+
* @param parameters - {@link VerifyHashParameters}
|
|
5380
|
+
* @returns Whether or not the signature is valid. {@link VerifyHashReturnType}
|
|
5381
|
+
*/
|
|
5382
|
+
async function verifyHash(client, parameters) {
|
|
5383
|
+
const { address, chain = client.chain, hash, erc6492VerifierAddress: verifierAddress = parameters.universalSignatureVerifierAddress ?? chain?.contracts?.erc6492Verifier?.address, multicallAddress = parameters.multicallAddress ?? chain?.contracts?.multicall3?.address, mode = "auto" } = parameters;
|
|
5384
|
+
if (chain?.verifyHash) return await chain.verifyHash(client, parameters);
|
|
5385
|
+
const signature = (() => {
|
|
5386
|
+
const signature = parameters.signature;
|
|
5387
|
+
if (isHex(signature)) return signature;
|
|
5388
|
+
if (typeof signature === "object" && "r" in signature && "s" in signature) return serializeSignature(signature);
|
|
5389
|
+
return bytesToHex(signature);
|
|
5390
|
+
})();
|
|
5391
|
+
try {
|
|
5392
|
+
if (mode === "eoa") try {
|
|
5393
|
+
if (isAddressEqual(getAddress(address), await recoverAddress$1({
|
|
5394
|
+
hash,
|
|
5395
|
+
signature
|
|
5396
|
+
}))) return true;
|
|
5397
|
+
} catch {}
|
|
5398
|
+
if (validate$1(signature)) return await verifyErc8010(client, {
|
|
5399
|
+
...parameters,
|
|
5400
|
+
multicallAddress,
|
|
5401
|
+
signature
|
|
5402
|
+
});
|
|
5403
|
+
return await verifyErc6492(client, {
|
|
5404
|
+
...parameters,
|
|
5405
|
+
verifierAddress,
|
|
5406
|
+
signature
|
|
5407
|
+
});
|
|
5408
|
+
} catch (error) {
|
|
5409
|
+
if (mode !== "eoa") try {
|
|
5410
|
+
if (isAddressEqual(getAddress(address), await recoverAddress$1({
|
|
5411
|
+
hash,
|
|
5412
|
+
signature
|
|
5413
|
+
}))) return true;
|
|
5414
|
+
} catch {}
|
|
5415
|
+
if (error instanceof VerificationError) return false;
|
|
5416
|
+
throw error;
|
|
5417
|
+
}
|
|
5418
|
+
}
|
|
5419
|
+
/** @internal */
|
|
5420
|
+
async function verifyErc8010(client, parameters) {
|
|
5421
|
+
const { address, blockNumber, blockTag, hash, multicallAddress } = parameters;
|
|
5422
|
+
const { authorization: authorization_ox, data: initData, signature, to } = unwrap(parameters.signature);
|
|
5423
|
+
if (await getCode(client, {
|
|
5424
|
+
address,
|
|
5425
|
+
blockNumber,
|
|
5426
|
+
blockTag
|
|
5427
|
+
}) === concatHex(["0xef0100", authorization_ox.address])) return await verifyErc1271(client, {
|
|
5428
|
+
address,
|
|
5429
|
+
blockNumber,
|
|
5430
|
+
blockTag,
|
|
5431
|
+
hash,
|
|
5432
|
+
signature
|
|
5433
|
+
});
|
|
5434
|
+
const authorization = {
|
|
5435
|
+
address: authorization_ox.address,
|
|
5436
|
+
chainId: Number(authorization_ox.chainId),
|
|
5437
|
+
nonce: Number(authorization_ox.nonce),
|
|
5438
|
+
r: numberToHex(authorization_ox.r, { size: 32 }),
|
|
5439
|
+
s: numberToHex(authorization_ox.s, { size: 32 }),
|
|
5440
|
+
yParity: authorization_ox.yParity
|
|
5441
|
+
};
|
|
5442
|
+
if (!await verifyAuthorization({
|
|
5443
|
+
address,
|
|
5444
|
+
authorization
|
|
5445
|
+
})) throw new VerificationError();
|
|
5446
|
+
const results = await getAction(client, readContract, "readContract")({
|
|
5447
|
+
...multicallAddress ? { address: multicallAddress } : { code: multicall3Bytecode },
|
|
5448
|
+
authorizationList: [authorization],
|
|
5449
|
+
abi: multicall3Abi,
|
|
5450
|
+
blockNumber,
|
|
5451
|
+
blockTag: "pending",
|
|
5452
|
+
functionName: "aggregate3",
|
|
5453
|
+
args: [[...initData ? [{
|
|
5454
|
+
allowFailure: true,
|
|
5455
|
+
target: to ?? address,
|
|
5456
|
+
callData: initData
|
|
5457
|
+
}] : [], {
|
|
5458
|
+
allowFailure: true,
|
|
5459
|
+
target: address,
|
|
5460
|
+
callData: encodeFunctionData({
|
|
5461
|
+
abi: erc1271Abi,
|
|
5462
|
+
functionName: "isValidSignature",
|
|
5463
|
+
args: [hash, signature]
|
|
5464
|
+
})
|
|
5465
|
+
}]]
|
|
5466
|
+
});
|
|
5467
|
+
if ((results[results.length - 1]?.returnData)?.startsWith("0x1626ba7e")) return true;
|
|
5468
|
+
throw new VerificationError();
|
|
5469
|
+
}
|
|
5470
|
+
/** @internal */
|
|
5471
|
+
async function verifyErc6492(client, parameters) {
|
|
5472
|
+
const { address, factory, factoryData, hash, signature, verifierAddress, ...rest } = parameters;
|
|
5473
|
+
const wrappedSignature = await (async () => {
|
|
5474
|
+
if (!factory && !factoryData) return signature;
|
|
5475
|
+
if (validate(signature)) return signature;
|
|
5476
|
+
return wrap({
|
|
5477
|
+
data: factoryData,
|
|
5478
|
+
signature,
|
|
5479
|
+
to: factory
|
|
5480
|
+
});
|
|
5481
|
+
})();
|
|
5482
|
+
const args = verifierAddress ? {
|
|
5483
|
+
to: verifierAddress,
|
|
5484
|
+
data: encodeFunctionData({
|
|
5485
|
+
abi: erc6492SignatureValidatorAbi,
|
|
5486
|
+
functionName: "isValidSig",
|
|
5487
|
+
args: [
|
|
5488
|
+
address,
|
|
5489
|
+
hash,
|
|
5490
|
+
wrappedSignature
|
|
5491
|
+
]
|
|
5492
|
+
}),
|
|
5493
|
+
...rest
|
|
5494
|
+
} : {
|
|
5495
|
+
data: encodeDeployData({
|
|
5496
|
+
abi: erc6492SignatureValidatorAbi,
|
|
5497
|
+
args: [
|
|
5498
|
+
address,
|
|
5499
|
+
hash,
|
|
5500
|
+
wrappedSignature
|
|
5501
|
+
],
|
|
5502
|
+
bytecode: erc6492SignatureValidatorByteCode
|
|
5503
|
+
}),
|
|
5504
|
+
...rest
|
|
5505
|
+
};
|
|
5506
|
+
const { data } = await getAction(client, call, "call")(args).catch((error) => {
|
|
5507
|
+
if (error instanceof CallExecutionError) throw new VerificationError();
|
|
5508
|
+
throw error;
|
|
5509
|
+
});
|
|
5510
|
+
if (hexToBool(data ?? "0x0")) return true;
|
|
5511
|
+
throw new VerificationError();
|
|
5512
|
+
}
|
|
5513
|
+
/** @internal */
|
|
5514
|
+
async function verifyErc1271(client, parameters) {
|
|
5515
|
+
const { address, blockNumber, blockTag, hash, signature } = parameters;
|
|
5516
|
+
if ((await getAction(client, readContract, "readContract")({
|
|
5517
|
+
address,
|
|
5518
|
+
abi: erc1271Abi,
|
|
5519
|
+
args: [hash, signature],
|
|
5520
|
+
blockNumber,
|
|
5521
|
+
blockTag,
|
|
5522
|
+
functionName: "isValidSignature"
|
|
5523
|
+
}).catch((error) => {
|
|
5524
|
+
if (error instanceof ContractFunctionExecutionError) throw new VerificationError();
|
|
5525
|
+
throw error;
|
|
5526
|
+
})).startsWith("0x1626ba7e")) return true;
|
|
5527
|
+
throw new VerificationError();
|
|
5528
|
+
}
|
|
5529
|
+
var VerificationError = class extends Error {};
|
|
5530
|
+
//#endregion
|
|
5531
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/clients/transports/createTransport.js
|
|
5532
|
+
/**
|
|
5533
|
+
* @description Creates an transport intended to be used with a client.
|
|
5534
|
+
*/
|
|
5535
|
+
function createTransport({ key, methods, name, request, retryCount = 3, retryDelay = 150, timeout, type }, value) {
|
|
5536
|
+
const uid$1 = uid();
|
|
5537
|
+
return {
|
|
5538
|
+
config: {
|
|
5539
|
+
key,
|
|
5540
|
+
methods,
|
|
5541
|
+
name,
|
|
5542
|
+
request,
|
|
5543
|
+
retryCount,
|
|
5544
|
+
retryDelay,
|
|
5545
|
+
timeout,
|
|
5546
|
+
type
|
|
5547
|
+
},
|
|
5548
|
+
request: buildRequest(request, {
|
|
5549
|
+
methods,
|
|
5550
|
+
retryCount,
|
|
5551
|
+
retryDelay,
|
|
5552
|
+
uid: uid$1
|
|
5553
|
+
}),
|
|
5554
|
+
value
|
|
5555
|
+
};
|
|
5556
|
+
}
|
|
5557
|
+
//#endregion
|
|
5558
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/errors/transport.js
|
|
5559
|
+
var UrlRequiredError = class extends BaseError$1 {
|
|
5560
|
+
constructor() {
|
|
5561
|
+
super("No URL was provided to the Transport. Please provide a valid RPC URL to the Transport.", {
|
|
5562
|
+
docsPath: "/docs/clients/intro",
|
|
5563
|
+
name: "UrlRequiredError"
|
|
5564
|
+
});
|
|
5565
|
+
}
|
|
5566
|
+
};
|
|
5567
|
+
//#endregion
|
|
5568
|
+
//#region node_modules/.pnpm/viem@2.47.6_typescript@5.9.3_zod@4.3.6/node_modules/viem/_esm/clients/transports/http.js
|
|
5569
|
+
/**
|
|
5570
|
+
* @description Creates a HTTP transport that connects to a JSON-RPC API.
|
|
5571
|
+
*/
|
|
5572
|
+
function http(url, config = {}) {
|
|
5573
|
+
const { batch, fetchFn, fetchOptions, key = "http", methods, name = "HTTP JSON-RPC", onFetchRequest, onFetchResponse, retryDelay, raw } = config;
|
|
5574
|
+
return ({ chain, retryCount: retryCount_, timeout: timeout_ }) => {
|
|
5575
|
+
const { batchSize = 1e3, wait = 0 } = typeof batch === "object" ? batch : {};
|
|
5576
|
+
const retryCount = config.retryCount ?? retryCount_;
|
|
5577
|
+
const timeout = timeout_ ?? config.timeout ?? 1e4;
|
|
5578
|
+
const url_ = url || chain?.rpcUrls.default.http[0];
|
|
5579
|
+
if (!url_) throw new UrlRequiredError();
|
|
5580
|
+
const rpcClient = getHttpRpcClient(url_, {
|
|
5581
|
+
fetchFn,
|
|
5582
|
+
fetchOptions,
|
|
5583
|
+
onRequest: onFetchRequest,
|
|
5584
|
+
onResponse: onFetchResponse,
|
|
5585
|
+
timeout
|
|
5586
|
+
});
|
|
5587
|
+
return createTransport({
|
|
5588
|
+
key,
|
|
5589
|
+
methods,
|
|
5590
|
+
name,
|
|
5591
|
+
async request({ method, params }) {
|
|
5592
|
+
const body = {
|
|
5593
|
+
method,
|
|
5594
|
+
params
|
|
5595
|
+
};
|
|
5596
|
+
const { schedule } = createBatchScheduler({
|
|
5597
|
+
id: url_,
|
|
5598
|
+
wait,
|
|
5599
|
+
shouldSplitBatch(requests) {
|
|
5600
|
+
return requests.length > batchSize;
|
|
5601
|
+
},
|
|
5602
|
+
fn: (body) => rpcClient.request({ body }),
|
|
5603
|
+
sort: (a, b) => a.id - b.id
|
|
5604
|
+
});
|
|
5605
|
+
const fn = async (body) => batch ? schedule(body) : [await rpcClient.request({ body })];
|
|
5606
|
+
const [{ error, result }] = await fn(body);
|
|
5607
|
+
if (raw) return {
|
|
5608
|
+
error,
|
|
5609
|
+
result
|
|
5610
|
+
};
|
|
5611
|
+
if (error) throw new RpcRequestError({
|
|
5612
|
+
body,
|
|
5613
|
+
error,
|
|
5614
|
+
url: url_
|
|
5615
|
+
});
|
|
5616
|
+
return result;
|
|
5617
|
+
},
|
|
5618
|
+
retryCount,
|
|
5619
|
+
retryDelay,
|
|
5620
|
+
timeout,
|
|
5621
|
+
type: "http"
|
|
5622
|
+
}, {
|
|
5623
|
+
fetchOptions,
|
|
5624
|
+
url: url_
|
|
5625
|
+
});
|
|
5626
|
+
};
|
|
3610
5627
|
}
|
|
3611
5628
|
//#endregion
|
|
3612
|
-
export {
|
|
5629
|
+
export { parseEventLogs as $, toBytes as A, formatTransactionReceipt as B, encode as C, getAction as Ct, fromPublicKey as D, checksum as E, defineChain as F, uninstallFilter as G, withRetry as H, extendSchema as I, poll as J, getFilterChanges as K, getCode as L, keccak256 as M, sha256 as N, isEqual as O, validate$3 as P, getLogs as Q, createClient as R, toHex$1 as S, encodeEventTopics as St, assert$3 as T, sendRawTransaction as U, receiptStatuses as V, watchContractEvent as W, readContract as X, observe as Y, getContractEvents as Z, toHex as _, BlockNotFoundError as _t, getTransactionReceipt as a, fillTransaction as at, yParityToV as b, createContractEventFilter as bt, verify as c, getTransactionCount as ct, assert$2 as d, getGasPrice as dt, decodeEventLog as et, extract as f, getBlock as ft, fromTuple as g, formatTransaction as gt, fromRpc$1 as h, defineTransaction as ht, multicall as i, prepareTransactionRequest as it, toHex$2 as j, validate$2 as k, fromRpcList as l, estimateFeesPerGas as lt, fromHex as m, formatBlock as mt, createTransport as n, estimateGas as nt, recoverAddress as o, getChainId as ot, from$1 as p, defineBlock as pt, getBlockNumber as q, verifyHash as r, defaultParameters as rt, recoverPublicKey as s, getTransactionError as st, http as t, formatLog as tt, toRpcList as u, estimateMaxPriorityFeePerGas as ut, toRpc$1 as v, recoverAuthorizationAddress as vt, create as w, parseAbiParameters as wt, fromHex$1 as x, createFilterRequestScope as xt, toTuple as y, getContractError as yt, defineTransactionReceipt as z };
|