@manifoldxyz/client-sdk 0.1.0-beta.1 → 0.1.0-beta.3
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/dist/ccip-7L74i3uJ.cjs +262 -0
- package/dist/ccip-7L74i3uJ.cjs.map +1 -0
- package/dist/ccip-DVZrkzQy.js +262 -0
- package/dist/ccip-DVZrkzQy.js.map +1 -0
- package/dist/index-BqwTebqK.cjs +17230 -0
- package/dist/index-BqwTebqK.cjs.map +1 -0
- package/dist/index-DIesYZZz.js +17215 -0
- package/dist/index-DIesYZZz.js.map +1 -0
- package/dist/index.cjs +9 -12597
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -10
- package/dist/index.mjs +9 -12581
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const index = require("./index-BqwTebqK.cjs");
|
|
4
|
+
function decodeFunctionData(parameters) {
|
|
5
|
+
const { abi, data } = parameters;
|
|
6
|
+
const signature = index.slice(data, 0, 4);
|
|
7
|
+
const description = abi.find((x) => x.type === "function" && signature === index.toFunctionSelector(index.formatAbiItem(x)));
|
|
8
|
+
if (!description)
|
|
9
|
+
throw new index.AbiFunctionSignatureNotFoundError(signature, {
|
|
10
|
+
docsPath: "/docs/contract/decodeFunctionData"
|
|
11
|
+
});
|
|
12
|
+
return {
|
|
13
|
+
functionName: description.name,
|
|
14
|
+
args: "inputs" in description && description.inputs && description.inputs.length > 0 ? index.decodeAbiParameters(description.inputs, index.slice(data, 4)) : void 0
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
const docsPath$1 = "/docs/contract/encodeErrorResult";
|
|
18
|
+
function encodeErrorResult(parameters) {
|
|
19
|
+
const { abi, errorName, args } = parameters;
|
|
20
|
+
let abiItem = abi[0];
|
|
21
|
+
if (errorName) {
|
|
22
|
+
const item = index.getAbiItem({ abi, args, name: errorName });
|
|
23
|
+
if (!item)
|
|
24
|
+
throw new index.AbiErrorNotFoundError(errorName, { docsPath: docsPath$1 });
|
|
25
|
+
abiItem = item;
|
|
26
|
+
}
|
|
27
|
+
if (abiItem.type !== "error")
|
|
28
|
+
throw new index.AbiErrorNotFoundError(void 0, { docsPath: docsPath$1 });
|
|
29
|
+
const definition = index.formatAbiItem(abiItem);
|
|
30
|
+
const signature = index.toFunctionSelector(definition);
|
|
31
|
+
let data = "0x";
|
|
32
|
+
if (args && args.length > 0) {
|
|
33
|
+
if (!abiItem.inputs)
|
|
34
|
+
throw new index.AbiErrorInputsNotFoundError(abiItem.name, { docsPath: docsPath$1 });
|
|
35
|
+
data = index.encodeAbiParameters(abiItem.inputs, args);
|
|
36
|
+
}
|
|
37
|
+
return index.concatHex([signature, data]);
|
|
38
|
+
}
|
|
39
|
+
const docsPath = "/docs/contract/encodeFunctionResult";
|
|
40
|
+
function encodeFunctionResult(parameters) {
|
|
41
|
+
const { abi, functionName, result } = parameters;
|
|
42
|
+
let abiItem = abi[0];
|
|
43
|
+
if (functionName) {
|
|
44
|
+
const item = index.getAbiItem({ abi, name: functionName });
|
|
45
|
+
if (!item)
|
|
46
|
+
throw new index.AbiFunctionNotFoundError(functionName, { docsPath });
|
|
47
|
+
abiItem = item;
|
|
48
|
+
}
|
|
49
|
+
if (abiItem.type !== "function")
|
|
50
|
+
throw new index.AbiFunctionNotFoundError(void 0, { docsPath });
|
|
51
|
+
if (!abiItem.outputs)
|
|
52
|
+
throw new index.AbiFunctionOutputsNotFoundError(abiItem.name, { docsPath });
|
|
53
|
+
const values = (() => {
|
|
54
|
+
if (abiItem.outputs.length === 0)
|
|
55
|
+
return [];
|
|
56
|
+
if (abiItem.outputs.length === 1)
|
|
57
|
+
return [result];
|
|
58
|
+
if (Array.isArray(result))
|
|
59
|
+
return result;
|
|
60
|
+
throw new index.InvalidArrayError(result);
|
|
61
|
+
})();
|
|
62
|
+
return index.encodeAbiParameters(abiItem.outputs, values);
|
|
63
|
+
}
|
|
64
|
+
const localBatchGatewayUrl = "x-batch-gateway:true";
|
|
65
|
+
async function localBatchGatewayRequest(parameters) {
|
|
66
|
+
const { data, ccipRequest: ccipRequest2 } = parameters;
|
|
67
|
+
const { args: [queries] } = decodeFunctionData({ abi: index.batchGatewayAbi, data });
|
|
68
|
+
const failures = [];
|
|
69
|
+
const responses = [];
|
|
70
|
+
await Promise.all(queries.map(async (query, i) => {
|
|
71
|
+
try {
|
|
72
|
+
responses[i] = query.urls.includes(localBatchGatewayUrl) ? await localBatchGatewayRequest({ data: query.data, ccipRequest: ccipRequest2 }) : await ccipRequest2(query);
|
|
73
|
+
failures[i] = false;
|
|
74
|
+
} catch (err) {
|
|
75
|
+
failures[i] = true;
|
|
76
|
+
responses[i] = encodeError(err);
|
|
77
|
+
}
|
|
78
|
+
}));
|
|
79
|
+
return encodeFunctionResult({
|
|
80
|
+
abi: index.batchGatewayAbi,
|
|
81
|
+
functionName: "query",
|
|
82
|
+
result: [failures, responses]
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
function encodeError(error) {
|
|
86
|
+
if (error.name === "HttpRequestError" && error.status)
|
|
87
|
+
return encodeErrorResult({
|
|
88
|
+
abi: index.batchGatewayAbi,
|
|
89
|
+
errorName: "HttpError",
|
|
90
|
+
args: [error.status, error.shortMessage]
|
|
91
|
+
});
|
|
92
|
+
return encodeErrorResult({
|
|
93
|
+
abi: [index.solidityError],
|
|
94
|
+
errorName: "Error",
|
|
95
|
+
args: ["shortMessage" in error ? error.shortMessage : error.message]
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
function isAddressEqual(a, b) {
|
|
99
|
+
if (!index.isAddress(a, { strict: false }))
|
|
100
|
+
throw new index.InvalidAddressError({ address: a });
|
|
101
|
+
if (!index.isAddress(b, { strict: false }))
|
|
102
|
+
throw new index.InvalidAddressError({ address: b });
|
|
103
|
+
return a.toLowerCase() === b.toLowerCase();
|
|
104
|
+
}
|
|
105
|
+
class OffchainLookupError extends index.BaseError {
|
|
106
|
+
constructor({ callbackSelector, cause, data, extraData, sender, urls }) {
|
|
107
|
+
super(cause.shortMessage || "An error occurred while fetching for an offchain result.", {
|
|
108
|
+
cause,
|
|
109
|
+
metaMessages: [
|
|
110
|
+
...cause.metaMessages || [],
|
|
111
|
+
cause.metaMessages?.length ? "" : [],
|
|
112
|
+
"Offchain Gateway Call:",
|
|
113
|
+
urls && [
|
|
114
|
+
" Gateway URL(s):",
|
|
115
|
+
...urls.map((url) => ` ${index.getUrl(url)}`)
|
|
116
|
+
],
|
|
117
|
+
` Sender: ${sender}`,
|
|
118
|
+
` Data: ${data}`,
|
|
119
|
+
` Callback selector: ${callbackSelector}`,
|
|
120
|
+
` Extra data: ${extraData}`
|
|
121
|
+
].flat(),
|
|
122
|
+
name: "OffchainLookupError"
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
class OffchainLookupResponseMalformedError extends index.BaseError {
|
|
127
|
+
constructor({ result, url }) {
|
|
128
|
+
super("Offchain gateway response is malformed. Response data must be a hex value.", {
|
|
129
|
+
metaMessages: [
|
|
130
|
+
`Gateway URL: ${index.getUrl(url)}`,
|
|
131
|
+
`Response: ${index.stringify(result)}`
|
|
132
|
+
],
|
|
133
|
+
name: "OffchainLookupResponseMalformedError"
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
class OffchainLookupSenderMismatchError extends index.BaseError {
|
|
138
|
+
constructor({ sender, to }) {
|
|
139
|
+
super("Reverted sender address does not match target contract address (`to`).", {
|
|
140
|
+
metaMessages: [
|
|
141
|
+
`Contract address: ${to}`,
|
|
142
|
+
`OffchainLookup sender address: ${sender}`
|
|
143
|
+
],
|
|
144
|
+
name: "OffchainLookupSenderMismatchError"
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
const offchainLookupSignature = "0x556f1830";
|
|
149
|
+
const offchainLookupAbiItem = {
|
|
150
|
+
name: "OffchainLookup",
|
|
151
|
+
type: "error",
|
|
152
|
+
inputs: [
|
|
153
|
+
{
|
|
154
|
+
name: "sender",
|
|
155
|
+
type: "address"
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
name: "urls",
|
|
159
|
+
type: "string[]"
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
name: "callData",
|
|
163
|
+
type: "bytes"
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
name: "callbackFunction",
|
|
167
|
+
type: "bytes4"
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
name: "extraData",
|
|
171
|
+
type: "bytes"
|
|
172
|
+
}
|
|
173
|
+
]
|
|
174
|
+
};
|
|
175
|
+
async function offchainLookup(client, { blockNumber, blockTag, data, to }) {
|
|
176
|
+
const { args } = index.decodeErrorResult({
|
|
177
|
+
data,
|
|
178
|
+
abi: [offchainLookupAbiItem]
|
|
179
|
+
});
|
|
180
|
+
const [sender, urls, callData, callbackSelector, extraData] = args;
|
|
181
|
+
const { ccipRead } = client;
|
|
182
|
+
const ccipRequest_ = ccipRead && typeof ccipRead?.request === "function" ? ccipRead.request : ccipRequest;
|
|
183
|
+
try {
|
|
184
|
+
if (!isAddressEqual(to, sender))
|
|
185
|
+
throw new OffchainLookupSenderMismatchError({ sender, to });
|
|
186
|
+
const result = urls.includes(localBatchGatewayUrl) ? await localBatchGatewayRequest({
|
|
187
|
+
data: callData,
|
|
188
|
+
ccipRequest: ccipRequest_
|
|
189
|
+
}) : await ccipRequest_({ data: callData, sender, urls });
|
|
190
|
+
const { data: data_ } = await index.call(client, {
|
|
191
|
+
blockNumber,
|
|
192
|
+
blockTag,
|
|
193
|
+
data: index.concat([
|
|
194
|
+
callbackSelector,
|
|
195
|
+
index.encodeAbiParameters([{ type: "bytes" }, { type: "bytes" }], [result, extraData])
|
|
196
|
+
]),
|
|
197
|
+
to
|
|
198
|
+
});
|
|
199
|
+
return data_;
|
|
200
|
+
} catch (err) {
|
|
201
|
+
throw new OffchainLookupError({
|
|
202
|
+
callbackSelector,
|
|
203
|
+
cause: err,
|
|
204
|
+
data,
|
|
205
|
+
extraData,
|
|
206
|
+
sender,
|
|
207
|
+
urls
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
async function ccipRequest({ data, sender, urls }) {
|
|
212
|
+
let error = new Error("An unknown error occurred.");
|
|
213
|
+
for (let i = 0; i < urls.length; i++) {
|
|
214
|
+
const url = urls[i];
|
|
215
|
+
const method = url.includes("{data}") ? "GET" : "POST";
|
|
216
|
+
const body = method === "POST" ? { data, sender } : void 0;
|
|
217
|
+
const headers = method === "POST" ? { "Content-Type": "application/json" } : {};
|
|
218
|
+
try {
|
|
219
|
+
const response = await fetch(url.replace("{sender}", sender.toLowerCase()).replace("{data}", data), {
|
|
220
|
+
body: JSON.stringify(body),
|
|
221
|
+
headers,
|
|
222
|
+
method
|
|
223
|
+
});
|
|
224
|
+
let result;
|
|
225
|
+
if (response.headers.get("Content-Type")?.startsWith("application/json")) {
|
|
226
|
+
result = (await response.json()).data;
|
|
227
|
+
} else {
|
|
228
|
+
result = await response.text();
|
|
229
|
+
}
|
|
230
|
+
if (!response.ok) {
|
|
231
|
+
error = new index.HttpRequestError({
|
|
232
|
+
body,
|
|
233
|
+
details: result?.error ? index.stringify(result.error) : response.statusText,
|
|
234
|
+
headers: response.headers,
|
|
235
|
+
status: response.status,
|
|
236
|
+
url
|
|
237
|
+
});
|
|
238
|
+
continue;
|
|
239
|
+
}
|
|
240
|
+
if (!index.isHex(result)) {
|
|
241
|
+
error = new OffchainLookupResponseMalformedError({
|
|
242
|
+
result,
|
|
243
|
+
url
|
|
244
|
+
});
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
return result;
|
|
248
|
+
} catch (err) {
|
|
249
|
+
error = new index.HttpRequestError({
|
|
250
|
+
body,
|
|
251
|
+
details: err.message,
|
|
252
|
+
url
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
throw error;
|
|
257
|
+
}
|
|
258
|
+
exports.ccipRequest = ccipRequest;
|
|
259
|
+
exports.offchainLookup = offchainLookup;
|
|
260
|
+
exports.offchainLookupAbiItem = offchainLookupAbiItem;
|
|
261
|
+
exports.offchainLookupSignature = offchainLookupSignature;
|
|
262
|
+
//# sourceMappingURL=ccip-7L74i3uJ.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ccip-7L74i3uJ.cjs","sources":["../node_modules/viem/_esm/utils/abi/decodeFunctionData.js","../node_modules/viem/_esm/utils/abi/encodeErrorResult.js","../node_modules/viem/_esm/utils/abi/encodeFunctionResult.js","../node_modules/viem/_esm/utils/ens/localBatchGatewayRequest.js","../node_modules/viem/_esm/utils/address/isAddressEqual.js","../node_modules/viem/_esm/errors/ccip.js","../node_modules/viem/_esm/utils/ccip.js"],"sourcesContent":["import { AbiFunctionSignatureNotFoundError } from '../../errors/abi.js';\nimport { slice } from '../data/slice.js';\nimport { toFunctionSelector, } from '../hash/toFunctionSelector.js';\nimport { decodeAbiParameters, } from './decodeAbiParameters.js';\nimport { formatAbiItem } from './formatAbiItem.js';\nexport function decodeFunctionData(parameters) {\n const { abi, data } = parameters;\n const signature = slice(data, 0, 4);\n const description = abi.find((x) => x.type === 'function' &&\n signature === toFunctionSelector(formatAbiItem(x)));\n if (!description)\n throw new AbiFunctionSignatureNotFoundError(signature, {\n docsPath: '/docs/contract/decodeFunctionData',\n });\n return {\n functionName: description.name,\n args: ('inputs' in description &&\n description.inputs &&\n description.inputs.length > 0\n ? decodeAbiParameters(description.inputs, slice(data, 4))\n : undefined),\n };\n}\n//# sourceMappingURL=decodeFunctionData.js.map","import { AbiErrorInputsNotFoundError, AbiErrorNotFoundError, } from '../../errors/abi.js';\nimport { concatHex } from '../data/concat.js';\nimport { toFunctionSelector, } from '../hash/toFunctionSelector.js';\nimport { encodeAbiParameters, } from './encodeAbiParameters.js';\nimport { formatAbiItem } from './formatAbiItem.js';\nimport { getAbiItem } from './getAbiItem.js';\nconst docsPath = '/docs/contract/encodeErrorResult';\nexport function encodeErrorResult(parameters) {\n const { abi, errorName, args } = parameters;\n let abiItem = abi[0];\n if (errorName) {\n const item = getAbiItem({ abi, args, name: errorName });\n if (!item)\n throw new AbiErrorNotFoundError(errorName, { docsPath });\n abiItem = item;\n }\n if (abiItem.type !== 'error')\n throw new AbiErrorNotFoundError(undefined, { docsPath });\n const definition = formatAbiItem(abiItem);\n const signature = toFunctionSelector(definition);\n let data = '0x';\n if (args && args.length > 0) {\n if (!abiItem.inputs)\n throw new AbiErrorInputsNotFoundError(abiItem.name, { docsPath });\n data = encodeAbiParameters(abiItem.inputs, args);\n }\n return concatHex([signature, data]);\n}\n//# sourceMappingURL=encodeErrorResult.js.map","import { AbiFunctionNotFoundError, AbiFunctionOutputsNotFoundError, InvalidArrayError, } from '../../errors/abi.js';\nimport { encodeAbiParameters, } from './encodeAbiParameters.js';\nimport { getAbiItem } from './getAbiItem.js';\nconst docsPath = '/docs/contract/encodeFunctionResult';\nexport function encodeFunctionResult(parameters) {\n const { abi, functionName, result } = parameters;\n let abiItem = abi[0];\n if (functionName) {\n const item = getAbiItem({ abi, name: functionName });\n if (!item)\n throw new AbiFunctionNotFoundError(functionName, { docsPath });\n abiItem = item;\n }\n if (abiItem.type !== 'function')\n throw new AbiFunctionNotFoundError(undefined, { docsPath });\n if (!abiItem.outputs)\n throw new AbiFunctionOutputsNotFoundError(abiItem.name, { docsPath });\n const values = (() => {\n if (abiItem.outputs.length === 0)\n return [];\n if (abiItem.outputs.length === 1)\n return [result];\n if (Array.isArray(result))\n return result;\n throw new InvalidArrayError(result);\n })();\n return encodeAbiParameters(abiItem.outputs, values);\n}\n//# sourceMappingURL=encodeFunctionResult.js.map","import { batchGatewayAbi } from '../../constants/abis.js';\nimport { solidityError } from '../../constants/solidity.js';\nimport { decodeFunctionData } from '../abi/decodeFunctionData.js';\nimport { encodeErrorResult } from '../abi/encodeErrorResult.js';\nimport { encodeFunctionResult } from '../abi/encodeFunctionResult.js';\nexport const localBatchGatewayUrl = 'x-batch-gateway:true';\nexport async function localBatchGatewayRequest(parameters) {\n const { data, ccipRequest } = parameters;\n const { args: [queries], } = decodeFunctionData({ abi: batchGatewayAbi, data });\n const failures = [];\n const responses = [];\n await Promise.all(queries.map(async (query, i) => {\n try {\n responses[i] = query.urls.includes(localBatchGatewayUrl)\n ? await localBatchGatewayRequest({ data: query.data, ccipRequest })\n : await ccipRequest(query);\n failures[i] = false;\n }\n catch (err) {\n failures[i] = true;\n responses[i] = encodeError(err);\n }\n }));\n return encodeFunctionResult({\n abi: batchGatewayAbi,\n functionName: 'query',\n result: [failures, responses],\n });\n}\nfunction encodeError(error) {\n if (error.name === 'HttpRequestError' && error.status)\n return encodeErrorResult({\n abi: batchGatewayAbi,\n errorName: 'HttpError',\n args: [error.status, error.shortMessage],\n });\n return encodeErrorResult({\n abi: [solidityError],\n errorName: 'Error',\n args: ['shortMessage' in error ? error.shortMessage : error.message],\n });\n}\n//# sourceMappingURL=localBatchGatewayRequest.js.map","import { InvalidAddressError, } from '../../errors/address.js';\nimport { isAddress } from './isAddress.js';\nexport function isAddressEqual(a, b) {\n if (!isAddress(a, { strict: false }))\n throw new InvalidAddressError({ address: a });\n if (!isAddress(b, { strict: false }))\n throw new InvalidAddressError({ address: b });\n return a.toLowerCase() === b.toLowerCase();\n}\n//# sourceMappingURL=isAddressEqual.js.map","import { stringify } from '../utils/stringify.js';\nimport { BaseError } from './base.js';\nimport { getUrl } from './utils.js';\nexport class OffchainLookupError extends BaseError {\n constructor({ callbackSelector, cause, data, extraData, sender, urls, }) {\n super(cause.shortMessage ||\n 'An error occurred while fetching for an offchain result.', {\n cause,\n metaMessages: [\n ...(cause.metaMessages || []),\n cause.metaMessages?.length ? '' : [],\n 'Offchain Gateway Call:',\n urls && [\n ' Gateway URL(s):',\n ...urls.map((url) => ` ${getUrl(url)}`),\n ],\n ` Sender: ${sender}`,\n ` Data: ${data}`,\n ` Callback selector: ${callbackSelector}`,\n ` Extra data: ${extraData}`,\n ].flat(),\n name: 'OffchainLookupError',\n });\n }\n}\nexport class OffchainLookupResponseMalformedError extends BaseError {\n constructor({ result, url }) {\n super('Offchain gateway response is malformed. Response data must be a hex value.', {\n metaMessages: [\n `Gateway URL: ${getUrl(url)}`,\n `Response: ${stringify(result)}`,\n ],\n name: 'OffchainLookupResponseMalformedError',\n });\n }\n}\nexport class OffchainLookupSenderMismatchError extends BaseError {\n constructor({ sender, to }) {\n super('Reverted sender address does not match target contract address (`to`).', {\n metaMessages: [\n `Contract address: ${to}`,\n `OffchainLookup sender address: ${sender}`,\n ],\n name: 'OffchainLookupSenderMismatchError',\n });\n }\n}\n//# sourceMappingURL=ccip.js.map","import { call } from '../actions/public/call.js';\nimport { OffchainLookupError, OffchainLookupResponseMalformedError, OffchainLookupSenderMismatchError, } from '../errors/ccip.js';\nimport { HttpRequestError, } from '../errors/request.js';\nimport { decodeErrorResult } from './abi/decodeErrorResult.js';\nimport { encodeAbiParameters } from './abi/encodeAbiParameters.js';\nimport { isAddressEqual } from './address/isAddressEqual.js';\nimport { concat } from './data/concat.js';\nimport { isHex } from './data/isHex.js';\nimport { localBatchGatewayRequest, localBatchGatewayUrl, } from './ens/localBatchGatewayRequest.js';\nimport { stringify } from './stringify.js';\nexport const offchainLookupSignature = '0x556f1830';\nexport const offchainLookupAbiItem = {\n name: 'OffchainLookup',\n type: 'error',\n inputs: [\n {\n name: 'sender',\n type: 'address',\n },\n {\n name: 'urls',\n type: 'string[]',\n },\n {\n name: 'callData',\n type: 'bytes',\n },\n {\n name: 'callbackFunction',\n type: 'bytes4',\n },\n {\n name: 'extraData',\n type: 'bytes',\n },\n ],\n};\nexport async function offchainLookup(client, { blockNumber, blockTag, data, to, }) {\n const { args } = decodeErrorResult({\n data,\n abi: [offchainLookupAbiItem],\n });\n const [sender, urls, callData, callbackSelector, extraData] = args;\n const { ccipRead } = client;\n const ccipRequest_ = ccipRead && typeof ccipRead?.request === 'function'\n ? ccipRead.request\n : ccipRequest;\n try {\n if (!isAddressEqual(to, sender))\n throw new OffchainLookupSenderMismatchError({ sender, to });\n const result = urls.includes(localBatchGatewayUrl)\n ? await localBatchGatewayRequest({\n data: callData,\n ccipRequest: ccipRequest_,\n })\n : await ccipRequest_({ data: callData, sender, urls });\n const { data: data_ } = await call(client, {\n blockNumber,\n blockTag,\n data: concat([\n callbackSelector,\n encodeAbiParameters([{ type: 'bytes' }, { type: 'bytes' }], [result, extraData]),\n ]),\n to,\n });\n return data_;\n }\n catch (err) {\n throw new OffchainLookupError({\n callbackSelector,\n cause: err,\n data,\n extraData,\n sender,\n urls,\n });\n }\n}\nexport async function ccipRequest({ data, sender, urls, }) {\n let error = new Error('An unknown error occurred.');\n for (let i = 0; i < urls.length; i++) {\n const url = urls[i];\n const method = url.includes('{data}') ? 'GET' : 'POST';\n const body = method === 'POST' ? { data, sender } : undefined;\n const headers = method === 'POST' ? { 'Content-Type': 'application/json' } : {};\n try {\n const response = await fetch(url.replace('{sender}', sender.toLowerCase()).replace('{data}', data), {\n body: JSON.stringify(body),\n headers,\n method,\n });\n let result;\n if (response.headers.get('Content-Type')?.startsWith('application/json')) {\n result = (await response.json()).data;\n }\n else {\n result = (await response.text());\n }\n if (!response.ok) {\n error = new HttpRequestError({\n body,\n details: result?.error\n ? stringify(result.error)\n : response.statusText,\n headers: response.headers,\n status: response.status,\n url,\n });\n continue;\n }\n if (!isHex(result)) {\n error = new OffchainLookupResponseMalformedError({\n result,\n url,\n });\n continue;\n }\n return result;\n }\n catch (err) {\n error = new HttpRequestError({\n body,\n details: err.message,\n url,\n });\n }\n }\n throw error;\n}\n//# sourceMappingURL=ccip.js.map"],"names":["slice","toFunctionSelector","formatAbiItem","AbiFunctionSignatureNotFoundError","decodeAbiParameters","docsPath","getAbiItem","AbiErrorNotFoundError","AbiErrorInputsNotFoundError","encodeAbiParameters","concatHex","AbiFunctionNotFoundError","AbiFunctionOutputsNotFoundError","InvalidArrayError","ccipRequest","batchGatewayAbi","solidityError","isAddress","InvalidAddressError","BaseError","getUrl","stringify","decodeErrorResult","call","concat","HttpRequestError","isHex"],"mappings":";;;AAKO,SAAS,mBAAmB,YAAY;AAC3C,QAAM,EAAE,KAAK,KAAI,IAAK;AACtB,QAAM,YAAYA,MAAAA,MAAM,MAAM,GAAG,CAAC;AAClC,QAAM,cAAc,IAAI,KAAK,CAAC,MAAM,EAAE,SAAS,cAC3C,cAAcC,MAAAA,mBAAmBC,oBAAc,CAAC,CAAC,CAAC;AACtD,MAAI,CAAC;AACD,UAAM,IAAIC,MAAAA,kCAAkC,WAAW;AAAA,MACnD,UAAU;AAAA,IACtB,CAAS;AACL,SAAO;AAAA,IACH,cAAc,YAAY;AAAA,IAC1B,MAAO,YAAY,eACf,YAAY,UACZ,YAAY,OAAO,SAAS,IAC1BC,MAAAA,oBAAoB,YAAY,QAAQJ,MAAAA,MAAM,MAAM,CAAC,CAAC,IACtD;AAAA,EACd;AACA;AChBA,MAAMK,aAAW;AACV,SAAS,kBAAkB,YAAY;AAC1C,QAAM,EAAE,KAAK,WAAW,KAAI,IAAK;AACjC,MAAI,UAAU,IAAI,CAAC;AACnB,MAAI,WAAW;AACX,UAAM,OAAOC,MAAAA,WAAW,EAAE,KAAK,MAAM,MAAM,WAAW;AACtD,QAAI,CAAC;AACD,YAAM,IAAIC,MAAAA,sBAAsB,WAAW,EAAA,UAAEF,WAAQ,CAAE;AAC3D,cAAU;AAAA,EACd;AACA,MAAI,QAAQ,SAAS;AACjB,UAAM,IAAIE,MAAAA,sBAAsB,QAAW,EAAA,UAAEF,WAAQ,CAAE;AAC3D,QAAM,aAAaH,MAAAA,cAAc,OAAO;AACxC,QAAM,YAAYD,MAAAA,mBAAmB,UAAU;AAC/C,MAAI,OAAO;AACX,MAAI,QAAQ,KAAK,SAAS,GAAG;AACzB,QAAI,CAAC,QAAQ;AACT,YAAM,IAAIO,MAAA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,UAAM,SAAS,IAAI,SAAS,QAAQ,IAAI,QAAQ;AAChD,UAAM,OAAO,WAAW,SAAS,EAAE,MAAM,OAAM,IAAK;AACpD,UAAM,UAAU,WAAW,SAAS,EAAE,gBAAgB,mBAAkB,IAAK,CAAA;AAC7E,QAAI;AACA,YAAM,WAAW,MAAM,MAAM,IAAI,QAAQ,YAAY,OAAO,YAAW,CAAE,EAAE,QAAQ,UAAU,IAAI,GAAG;AAAA,QAChG,MAAM,KAAK,UAAU,IAAI;AAAA,QACzB;AAAA,QACA;AAAA,MAChB,CAAa;AACD,UAAI;AACJ,UAAI,SAAS,QAAQ,IAAI,cAAc,GAAG,WAAW,kBAAkB,GAAG;AACtE,kBAAU,MAAM,SAAS,KAAI,GAAI;AAAA,MACrC,OACK;AACD,iBAAU,MAAM,SAAS;MAC7B;AACA,UAAI,CAAC,SAAS,IAAI;AACd,gBAAQ,IAAIgB,MAAAA,iBAAiB;AAAA,UACzB;AAAA,UACA,SAAS,QAAQ,QACXJ,MAAAA,UAAU,OAAO,KAAK,IACtB,SAAS;AAAA,UACf,SAAS,SAAS;AAAA,UAClB,QAAQ,SAAS;AAAA,UACjB;AAAA,QACpB,CAAiB;AACD;AAAA,MACJ;AACA,UAAI,CAACK,MAAAA,MAAM,MAAM,GAAG;AAChB,gBAAQ,IAAI,qCAAqC;AAAA,UAC7C;AAAA,UACA;AAAA,QACpB,CAAiB;AACD;AAAA,MACJ;AACA,aAAO;AAAA,IACX,SACO,KAAK;AACR,cAAQ,IAAID,MAAAA,iBAAiB;AAAA,QACzB;AAAA,QACA,SAAS,IAAI;AAAA,QACb;AAAA,MAChB,CAAa;AAAA,IACL;AAAA,EACJ;AACA,QAAM;AACV;;;;;","x_google_ignoreList":[0,1,2,3,4,5,6]}
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import { s as slice, t as toFunctionSelector, f as formatAbiItem, A as AbiFunctionSignatureNotFoundError, d as decodeAbiParameters, g as getAbiItem, a as AbiErrorNotFoundError, b as AbiErrorInputsNotFoundError, e as encodeAbiParameters, c as concatHex, h as AbiFunctionNotFoundError, i as AbiFunctionOutputsNotFoundError, I as InvalidArrayError, j as batchGatewayAbi, k as solidityError, l as isAddress, m as InvalidAddressError, B as BaseError, n as getUrl, o as stringify, p as decodeErrorResult, q as call, r as concat, H as HttpRequestError, u as isHex } from "./index-DIesYZZz.js";
|
|
2
|
+
function decodeFunctionData(parameters) {
|
|
3
|
+
const { abi, data } = parameters;
|
|
4
|
+
const signature = slice(data, 0, 4);
|
|
5
|
+
const description = abi.find((x) => x.type === "function" && signature === toFunctionSelector(formatAbiItem(x)));
|
|
6
|
+
if (!description)
|
|
7
|
+
throw new AbiFunctionSignatureNotFoundError(signature, {
|
|
8
|
+
docsPath: "/docs/contract/decodeFunctionData"
|
|
9
|
+
});
|
|
10
|
+
return {
|
|
11
|
+
functionName: description.name,
|
|
12
|
+
args: "inputs" in description && description.inputs && description.inputs.length > 0 ? decodeAbiParameters(description.inputs, slice(data, 4)) : void 0
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
const docsPath$1 = "/docs/contract/encodeErrorResult";
|
|
16
|
+
function encodeErrorResult(parameters) {
|
|
17
|
+
const { abi, errorName, args } = parameters;
|
|
18
|
+
let abiItem = abi[0];
|
|
19
|
+
if (errorName) {
|
|
20
|
+
const item = getAbiItem({ abi, args, name: errorName });
|
|
21
|
+
if (!item)
|
|
22
|
+
throw new AbiErrorNotFoundError(errorName, { docsPath: docsPath$1 });
|
|
23
|
+
abiItem = item;
|
|
24
|
+
}
|
|
25
|
+
if (abiItem.type !== "error")
|
|
26
|
+
throw new AbiErrorNotFoundError(void 0, { docsPath: docsPath$1 });
|
|
27
|
+
const definition = formatAbiItem(abiItem);
|
|
28
|
+
const signature = toFunctionSelector(definition);
|
|
29
|
+
let data = "0x";
|
|
30
|
+
if (args && args.length > 0) {
|
|
31
|
+
if (!abiItem.inputs)
|
|
32
|
+
throw new AbiErrorInputsNotFoundError(abiItem.name, { docsPath: docsPath$1 });
|
|
33
|
+
data = encodeAbiParameters(abiItem.inputs, args);
|
|
34
|
+
}
|
|
35
|
+
return concatHex([signature, data]);
|
|
36
|
+
}
|
|
37
|
+
const docsPath = "/docs/contract/encodeFunctionResult";
|
|
38
|
+
function encodeFunctionResult(parameters) {
|
|
39
|
+
const { abi, functionName, result } = parameters;
|
|
40
|
+
let abiItem = abi[0];
|
|
41
|
+
if (functionName) {
|
|
42
|
+
const item = getAbiItem({ abi, name: functionName });
|
|
43
|
+
if (!item)
|
|
44
|
+
throw new AbiFunctionNotFoundError(functionName, { docsPath });
|
|
45
|
+
abiItem = item;
|
|
46
|
+
}
|
|
47
|
+
if (abiItem.type !== "function")
|
|
48
|
+
throw new AbiFunctionNotFoundError(void 0, { docsPath });
|
|
49
|
+
if (!abiItem.outputs)
|
|
50
|
+
throw new AbiFunctionOutputsNotFoundError(abiItem.name, { docsPath });
|
|
51
|
+
const values = (() => {
|
|
52
|
+
if (abiItem.outputs.length === 0)
|
|
53
|
+
return [];
|
|
54
|
+
if (abiItem.outputs.length === 1)
|
|
55
|
+
return [result];
|
|
56
|
+
if (Array.isArray(result))
|
|
57
|
+
return result;
|
|
58
|
+
throw new InvalidArrayError(result);
|
|
59
|
+
})();
|
|
60
|
+
return encodeAbiParameters(abiItem.outputs, values);
|
|
61
|
+
}
|
|
62
|
+
const localBatchGatewayUrl = "x-batch-gateway:true";
|
|
63
|
+
async function localBatchGatewayRequest(parameters) {
|
|
64
|
+
const { data, ccipRequest: ccipRequest2 } = parameters;
|
|
65
|
+
const { args: [queries] } = decodeFunctionData({ abi: batchGatewayAbi, data });
|
|
66
|
+
const failures = [];
|
|
67
|
+
const responses = [];
|
|
68
|
+
await Promise.all(queries.map(async (query, i) => {
|
|
69
|
+
try {
|
|
70
|
+
responses[i] = query.urls.includes(localBatchGatewayUrl) ? await localBatchGatewayRequest({ data: query.data, ccipRequest: ccipRequest2 }) : await ccipRequest2(query);
|
|
71
|
+
failures[i] = false;
|
|
72
|
+
} catch (err) {
|
|
73
|
+
failures[i] = true;
|
|
74
|
+
responses[i] = encodeError(err);
|
|
75
|
+
}
|
|
76
|
+
}));
|
|
77
|
+
return encodeFunctionResult({
|
|
78
|
+
abi: batchGatewayAbi,
|
|
79
|
+
functionName: "query",
|
|
80
|
+
result: [failures, responses]
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
function encodeError(error) {
|
|
84
|
+
if (error.name === "HttpRequestError" && error.status)
|
|
85
|
+
return encodeErrorResult({
|
|
86
|
+
abi: batchGatewayAbi,
|
|
87
|
+
errorName: "HttpError",
|
|
88
|
+
args: [error.status, error.shortMessage]
|
|
89
|
+
});
|
|
90
|
+
return encodeErrorResult({
|
|
91
|
+
abi: [solidityError],
|
|
92
|
+
errorName: "Error",
|
|
93
|
+
args: ["shortMessage" in error ? error.shortMessage : error.message]
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
function isAddressEqual(a, b) {
|
|
97
|
+
if (!isAddress(a, { strict: false }))
|
|
98
|
+
throw new InvalidAddressError({ address: a });
|
|
99
|
+
if (!isAddress(b, { strict: false }))
|
|
100
|
+
throw new InvalidAddressError({ address: b });
|
|
101
|
+
return a.toLowerCase() === b.toLowerCase();
|
|
102
|
+
}
|
|
103
|
+
class OffchainLookupError extends BaseError {
|
|
104
|
+
constructor({ callbackSelector, cause, data, extraData, sender, urls }) {
|
|
105
|
+
super(cause.shortMessage || "An error occurred while fetching for an offchain result.", {
|
|
106
|
+
cause,
|
|
107
|
+
metaMessages: [
|
|
108
|
+
...cause.metaMessages || [],
|
|
109
|
+
cause.metaMessages?.length ? "" : [],
|
|
110
|
+
"Offchain Gateway Call:",
|
|
111
|
+
urls && [
|
|
112
|
+
" Gateway URL(s):",
|
|
113
|
+
...urls.map((url) => ` ${getUrl(url)}`)
|
|
114
|
+
],
|
|
115
|
+
` Sender: ${sender}`,
|
|
116
|
+
` Data: ${data}`,
|
|
117
|
+
` Callback selector: ${callbackSelector}`,
|
|
118
|
+
` Extra data: ${extraData}`
|
|
119
|
+
].flat(),
|
|
120
|
+
name: "OffchainLookupError"
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
class OffchainLookupResponseMalformedError extends BaseError {
|
|
125
|
+
constructor({ result, url }) {
|
|
126
|
+
super("Offchain gateway response is malformed. Response data must be a hex value.", {
|
|
127
|
+
metaMessages: [
|
|
128
|
+
`Gateway URL: ${getUrl(url)}`,
|
|
129
|
+
`Response: ${stringify(result)}`
|
|
130
|
+
],
|
|
131
|
+
name: "OffchainLookupResponseMalformedError"
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
class OffchainLookupSenderMismatchError extends BaseError {
|
|
136
|
+
constructor({ sender, to }) {
|
|
137
|
+
super("Reverted sender address does not match target contract address (`to`).", {
|
|
138
|
+
metaMessages: [
|
|
139
|
+
`Contract address: ${to}`,
|
|
140
|
+
`OffchainLookup sender address: ${sender}`
|
|
141
|
+
],
|
|
142
|
+
name: "OffchainLookupSenderMismatchError"
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
const offchainLookupSignature = "0x556f1830";
|
|
147
|
+
const offchainLookupAbiItem = {
|
|
148
|
+
name: "OffchainLookup",
|
|
149
|
+
type: "error",
|
|
150
|
+
inputs: [
|
|
151
|
+
{
|
|
152
|
+
name: "sender",
|
|
153
|
+
type: "address"
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
name: "urls",
|
|
157
|
+
type: "string[]"
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
name: "callData",
|
|
161
|
+
type: "bytes"
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
name: "callbackFunction",
|
|
165
|
+
type: "bytes4"
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
name: "extraData",
|
|
169
|
+
type: "bytes"
|
|
170
|
+
}
|
|
171
|
+
]
|
|
172
|
+
};
|
|
173
|
+
async function offchainLookup(client, { blockNumber, blockTag, data, to }) {
|
|
174
|
+
const { args } = decodeErrorResult({
|
|
175
|
+
data,
|
|
176
|
+
abi: [offchainLookupAbiItem]
|
|
177
|
+
});
|
|
178
|
+
const [sender, urls, callData, callbackSelector, extraData] = args;
|
|
179
|
+
const { ccipRead } = client;
|
|
180
|
+
const ccipRequest_ = ccipRead && typeof ccipRead?.request === "function" ? ccipRead.request : ccipRequest;
|
|
181
|
+
try {
|
|
182
|
+
if (!isAddressEqual(to, sender))
|
|
183
|
+
throw new OffchainLookupSenderMismatchError({ sender, to });
|
|
184
|
+
const result = urls.includes(localBatchGatewayUrl) ? await localBatchGatewayRequest({
|
|
185
|
+
data: callData,
|
|
186
|
+
ccipRequest: ccipRequest_
|
|
187
|
+
}) : await ccipRequest_({ data: callData, sender, urls });
|
|
188
|
+
const { data: data_ } = await call(client, {
|
|
189
|
+
blockNumber,
|
|
190
|
+
blockTag,
|
|
191
|
+
data: concat([
|
|
192
|
+
callbackSelector,
|
|
193
|
+
encodeAbiParameters([{ type: "bytes" }, { type: "bytes" }], [result, extraData])
|
|
194
|
+
]),
|
|
195
|
+
to
|
|
196
|
+
});
|
|
197
|
+
return data_;
|
|
198
|
+
} catch (err) {
|
|
199
|
+
throw new OffchainLookupError({
|
|
200
|
+
callbackSelector,
|
|
201
|
+
cause: err,
|
|
202
|
+
data,
|
|
203
|
+
extraData,
|
|
204
|
+
sender,
|
|
205
|
+
urls
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
async function ccipRequest({ data, sender, urls }) {
|
|
210
|
+
let error = new Error("An unknown error occurred.");
|
|
211
|
+
for (let i = 0; i < urls.length; i++) {
|
|
212
|
+
const url = urls[i];
|
|
213
|
+
const method = url.includes("{data}") ? "GET" : "POST";
|
|
214
|
+
const body = method === "POST" ? { data, sender } : void 0;
|
|
215
|
+
const headers = method === "POST" ? { "Content-Type": "application/json" } : {};
|
|
216
|
+
try {
|
|
217
|
+
const response = await fetch(url.replace("{sender}", sender.toLowerCase()).replace("{data}", data), {
|
|
218
|
+
body: JSON.stringify(body),
|
|
219
|
+
headers,
|
|
220
|
+
method
|
|
221
|
+
});
|
|
222
|
+
let result;
|
|
223
|
+
if (response.headers.get("Content-Type")?.startsWith("application/json")) {
|
|
224
|
+
result = (await response.json()).data;
|
|
225
|
+
} else {
|
|
226
|
+
result = await response.text();
|
|
227
|
+
}
|
|
228
|
+
if (!response.ok) {
|
|
229
|
+
error = new HttpRequestError({
|
|
230
|
+
body,
|
|
231
|
+
details: result?.error ? stringify(result.error) : response.statusText,
|
|
232
|
+
headers: response.headers,
|
|
233
|
+
status: response.status,
|
|
234
|
+
url
|
|
235
|
+
});
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
if (!isHex(result)) {
|
|
239
|
+
error = new OffchainLookupResponseMalformedError({
|
|
240
|
+
result,
|
|
241
|
+
url
|
|
242
|
+
});
|
|
243
|
+
continue;
|
|
244
|
+
}
|
|
245
|
+
return result;
|
|
246
|
+
} catch (err) {
|
|
247
|
+
error = new HttpRequestError({
|
|
248
|
+
body,
|
|
249
|
+
details: err.message,
|
|
250
|
+
url
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
throw error;
|
|
255
|
+
}
|
|
256
|
+
export {
|
|
257
|
+
ccipRequest,
|
|
258
|
+
offchainLookup,
|
|
259
|
+
offchainLookupAbiItem,
|
|
260
|
+
offchainLookupSignature
|
|
261
|
+
};
|
|
262
|
+
//# sourceMappingURL=ccip-DVZrkzQy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ccip-DVZrkzQy.js","sources":["../node_modules/viem/_esm/utils/abi/decodeFunctionData.js","../node_modules/viem/_esm/utils/abi/encodeErrorResult.js","../node_modules/viem/_esm/utils/abi/encodeFunctionResult.js","../node_modules/viem/_esm/utils/ens/localBatchGatewayRequest.js","../node_modules/viem/_esm/utils/address/isAddressEqual.js","../node_modules/viem/_esm/errors/ccip.js","../node_modules/viem/_esm/utils/ccip.js"],"sourcesContent":["import { AbiFunctionSignatureNotFoundError } from '../../errors/abi.js';\nimport { slice } from '../data/slice.js';\nimport { toFunctionSelector, } from '../hash/toFunctionSelector.js';\nimport { decodeAbiParameters, } from './decodeAbiParameters.js';\nimport { formatAbiItem } from './formatAbiItem.js';\nexport function decodeFunctionData(parameters) {\n const { abi, data } = parameters;\n const signature = slice(data, 0, 4);\n const description = abi.find((x) => x.type === 'function' &&\n signature === toFunctionSelector(formatAbiItem(x)));\n if (!description)\n throw new AbiFunctionSignatureNotFoundError(signature, {\n docsPath: '/docs/contract/decodeFunctionData',\n });\n return {\n functionName: description.name,\n args: ('inputs' in description &&\n description.inputs &&\n description.inputs.length > 0\n ? decodeAbiParameters(description.inputs, slice(data, 4))\n : undefined),\n };\n}\n//# sourceMappingURL=decodeFunctionData.js.map","import { AbiErrorInputsNotFoundError, AbiErrorNotFoundError, } from '../../errors/abi.js';\nimport { concatHex } from '../data/concat.js';\nimport { toFunctionSelector, } from '../hash/toFunctionSelector.js';\nimport { encodeAbiParameters, } from './encodeAbiParameters.js';\nimport { formatAbiItem } from './formatAbiItem.js';\nimport { getAbiItem } from './getAbiItem.js';\nconst docsPath = '/docs/contract/encodeErrorResult';\nexport function encodeErrorResult(parameters) {\n const { abi, errorName, args } = parameters;\n let abiItem = abi[0];\n if (errorName) {\n const item = getAbiItem({ abi, args, name: errorName });\n if (!item)\n throw new AbiErrorNotFoundError(errorName, { docsPath });\n abiItem = item;\n }\n if (abiItem.type !== 'error')\n throw new AbiErrorNotFoundError(undefined, { docsPath });\n const definition = formatAbiItem(abiItem);\n const signature = toFunctionSelector(definition);\n let data = '0x';\n if (args && args.length > 0) {\n if (!abiItem.inputs)\n throw new AbiErrorInputsNotFoundError(abiItem.name, { docsPath });\n data = encodeAbiParameters(abiItem.inputs, args);\n }\n return concatHex([signature, data]);\n}\n//# sourceMappingURL=encodeErrorResult.js.map","import { AbiFunctionNotFoundError, AbiFunctionOutputsNotFoundError, InvalidArrayError, } from '../../errors/abi.js';\nimport { encodeAbiParameters, } from './encodeAbiParameters.js';\nimport { getAbiItem } from './getAbiItem.js';\nconst docsPath = '/docs/contract/encodeFunctionResult';\nexport function encodeFunctionResult(parameters) {\n const { abi, functionName, result } = parameters;\n let abiItem = abi[0];\n if (functionName) {\n const item = getAbiItem({ abi, name: functionName });\n if (!item)\n throw new AbiFunctionNotFoundError(functionName, { docsPath });\n abiItem = item;\n }\n if (abiItem.type !== 'function')\n throw new AbiFunctionNotFoundError(undefined, { docsPath });\n if (!abiItem.outputs)\n throw new AbiFunctionOutputsNotFoundError(abiItem.name, { docsPath });\n const values = (() => {\n if (abiItem.outputs.length === 0)\n return [];\n if (abiItem.outputs.length === 1)\n return [result];\n if (Array.isArray(result))\n return result;\n throw new InvalidArrayError(result);\n })();\n return encodeAbiParameters(abiItem.outputs, values);\n}\n//# sourceMappingURL=encodeFunctionResult.js.map","import { batchGatewayAbi } from '../../constants/abis.js';\nimport { solidityError } from '../../constants/solidity.js';\nimport { decodeFunctionData } from '../abi/decodeFunctionData.js';\nimport { encodeErrorResult } from '../abi/encodeErrorResult.js';\nimport { encodeFunctionResult } from '../abi/encodeFunctionResult.js';\nexport const localBatchGatewayUrl = 'x-batch-gateway:true';\nexport async function localBatchGatewayRequest(parameters) {\n const { data, ccipRequest } = parameters;\n const { args: [queries], } = decodeFunctionData({ abi: batchGatewayAbi, data });\n const failures = [];\n const responses = [];\n await Promise.all(queries.map(async (query, i) => {\n try {\n responses[i] = query.urls.includes(localBatchGatewayUrl)\n ? await localBatchGatewayRequest({ data: query.data, ccipRequest })\n : await ccipRequest(query);\n failures[i] = false;\n }\n catch (err) {\n failures[i] = true;\n responses[i] = encodeError(err);\n }\n }));\n return encodeFunctionResult({\n abi: batchGatewayAbi,\n functionName: 'query',\n result: [failures, responses],\n });\n}\nfunction encodeError(error) {\n if (error.name === 'HttpRequestError' && error.status)\n return encodeErrorResult({\n abi: batchGatewayAbi,\n errorName: 'HttpError',\n args: [error.status, error.shortMessage],\n });\n return encodeErrorResult({\n abi: [solidityError],\n errorName: 'Error',\n args: ['shortMessage' in error ? error.shortMessage : error.message],\n });\n}\n//# sourceMappingURL=localBatchGatewayRequest.js.map","import { InvalidAddressError, } from '../../errors/address.js';\nimport { isAddress } from './isAddress.js';\nexport function isAddressEqual(a, b) {\n if (!isAddress(a, { strict: false }))\n throw new InvalidAddressError({ address: a });\n if (!isAddress(b, { strict: false }))\n throw new InvalidAddressError({ address: b });\n return a.toLowerCase() === b.toLowerCase();\n}\n//# sourceMappingURL=isAddressEqual.js.map","import { stringify } from '../utils/stringify.js';\nimport { BaseError } from './base.js';\nimport { getUrl } from './utils.js';\nexport class OffchainLookupError extends BaseError {\n constructor({ callbackSelector, cause, data, extraData, sender, urls, }) {\n super(cause.shortMessage ||\n 'An error occurred while fetching for an offchain result.', {\n cause,\n metaMessages: [\n ...(cause.metaMessages || []),\n cause.metaMessages?.length ? '' : [],\n 'Offchain Gateway Call:',\n urls && [\n ' Gateway URL(s):',\n ...urls.map((url) => ` ${getUrl(url)}`),\n ],\n ` Sender: ${sender}`,\n ` Data: ${data}`,\n ` Callback selector: ${callbackSelector}`,\n ` Extra data: ${extraData}`,\n ].flat(),\n name: 'OffchainLookupError',\n });\n }\n}\nexport class OffchainLookupResponseMalformedError extends BaseError {\n constructor({ result, url }) {\n super('Offchain gateway response is malformed. Response data must be a hex value.', {\n metaMessages: [\n `Gateway URL: ${getUrl(url)}`,\n `Response: ${stringify(result)}`,\n ],\n name: 'OffchainLookupResponseMalformedError',\n });\n }\n}\nexport class OffchainLookupSenderMismatchError extends BaseError {\n constructor({ sender, to }) {\n super('Reverted sender address does not match target contract address (`to`).', {\n metaMessages: [\n `Contract address: ${to}`,\n `OffchainLookup sender address: ${sender}`,\n ],\n name: 'OffchainLookupSenderMismatchError',\n });\n }\n}\n//# sourceMappingURL=ccip.js.map","import { call } from '../actions/public/call.js';\nimport { OffchainLookupError, OffchainLookupResponseMalformedError, OffchainLookupSenderMismatchError, } from '../errors/ccip.js';\nimport { HttpRequestError, } from '../errors/request.js';\nimport { decodeErrorResult } from './abi/decodeErrorResult.js';\nimport { encodeAbiParameters } from './abi/encodeAbiParameters.js';\nimport { isAddressEqual } from './address/isAddressEqual.js';\nimport { concat } from './data/concat.js';\nimport { isHex } from './data/isHex.js';\nimport { localBatchGatewayRequest, localBatchGatewayUrl, } from './ens/localBatchGatewayRequest.js';\nimport { stringify } from './stringify.js';\nexport const offchainLookupSignature = '0x556f1830';\nexport const offchainLookupAbiItem = {\n name: 'OffchainLookup',\n type: 'error',\n inputs: [\n {\n name: 'sender',\n type: 'address',\n },\n {\n name: 'urls',\n type: 'string[]',\n },\n {\n name: 'callData',\n type: 'bytes',\n },\n {\n name: 'callbackFunction',\n type: 'bytes4',\n },\n {\n name: 'extraData',\n type: 'bytes',\n },\n ],\n};\nexport async function offchainLookup(client, { blockNumber, blockTag, data, to, }) {\n const { args } = decodeErrorResult({\n data,\n abi: [offchainLookupAbiItem],\n });\n const [sender, urls, callData, callbackSelector, extraData] = args;\n const { ccipRead } = client;\n const ccipRequest_ = ccipRead && typeof ccipRead?.request === 'function'\n ? ccipRead.request\n : ccipRequest;\n try {\n if (!isAddressEqual(to, sender))\n throw new OffchainLookupSenderMismatchError({ sender, to });\n const result = urls.includes(localBatchGatewayUrl)\n ? await localBatchGatewayRequest({\n data: callData,\n ccipRequest: ccipRequest_,\n })\n : await ccipRequest_({ data: callData, sender, urls });\n const { data: data_ } = await call(client, {\n blockNumber,\n blockTag,\n data: concat([\n callbackSelector,\n encodeAbiParameters([{ type: 'bytes' }, { type: 'bytes' }], [result, extraData]),\n ]),\n to,\n });\n return data_;\n }\n catch (err) {\n throw new OffchainLookupError({\n callbackSelector,\n cause: err,\n data,\n extraData,\n sender,\n urls,\n });\n }\n}\nexport async function ccipRequest({ data, sender, urls, }) {\n let error = new Error('An unknown error occurred.');\n for (let i = 0; i < urls.length; i++) {\n const url = urls[i];\n const method = url.includes('{data}') ? 'GET' : 'POST';\n const body = method === 'POST' ? { data, sender } : undefined;\n const headers = method === 'POST' ? { 'Content-Type': 'application/json' } : {};\n try {\n const response = await fetch(url.replace('{sender}', sender.toLowerCase()).replace('{data}', data), {\n body: JSON.stringify(body),\n headers,\n method,\n });\n let result;\n if (response.headers.get('Content-Type')?.startsWith('application/json')) {\n result = (await response.json()).data;\n }\n else {\n result = (await response.text());\n }\n if (!response.ok) {\n error = new HttpRequestError({\n body,\n details: result?.error\n ? stringify(result.error)\n : response.statusText,\n headers: response.headers,\n status: response.status,\n url,\n });\n continue;\n }\n if (!isHex(result)) {\n error = new OffchainLookupResponseMalformedError({\n result,\n url,\n });\n continue;\n }\n return result;\n }\n catch (err) {\n error = new HttpRequestError({\n body,\n details: err.message,\n url,\n });\n }\n }\n throw error;\n}\n//# sourceMappingURL=ccip.js.map"],"names":["docsPath","ccipRequest"],"mappings":";AAKO,SAAS,mBAAmB,YAAY;AAC3C,QAAM,EAAE,KAAK,KAAI,IAAK;AACtB,QAAM,YAAY,MAAM,MAAM,GAAG,CAAC;AAClC,QAAM,cAAc,IAAI,KAAK,CAAC,MAAM,EAAE,SAAS,cAC3C,cAAc,mBAAmB,cAAc,CAAC,CAAC,CAAC;AACtD,MAAI,CAAC;AACD,UAAM,IAAI,kCAAkC,WAAW;AAAA,MACnD,UAAU;AAAA,IACtB,CAAS;AACL,SAAO;AAAA,IACH,cAAc,YAAY;AAAA,IAC1B,MAAO,YAAY,eACf,YAAY,UACZ,YAAY,OAAO,SAAS,IAC1B,oBAAoB,YAAY,QAAQ,MAAM,MAAM,CAAC,CAAC,IACtD;AAAA,EACd;AACA;AChBA,MAAMA,aAAW;AACV,SAAS,kBAAkB,YAAY;AAC1C,QAAM,EAAE,KAAK,WAAW,KAAI,IAAK;AACjC,MAAI,UAAU,IAAI,CAAC;AACnB,MAAI,WAAW;AACX,UAAM,OAAO,WAAW,EAAE,KAAK,MAAM,MAAM,WAAW;AACt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