@use-glyph/sdk-react 2.0.17-rc.4 → 2.0.17-rc.5
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/glyph-widget.es.js +22 -22
- package/dist/glyph-widget.umd.js +52 -95
- package/dist/glyph-widget.umd.js.map +1 -1
- package/dist/index.js +17670 -46315
- package/dist/index.js.map +1 -1
- package/dist/types/lib/rpcPublic.d.ts +2 -0
- package/package.json +3 -3
- package/dist/ccip.js +0 -231
- package/dist/ccip.js.map +0 -1
|
@@ -56,6 +56,7 @@ export declare function createDefaultPublicClient(chainId: number): {
|
|
|
56
56
|
sourceId?: number | undefined;
|
|
57
57
|
testnet?: boolean | undefined;
|
|
58
58
|
} & import('viem').ChainConfig<import('viem').ChainFormatters | undefined, Record<string, unknown> | undefined>;
|
|
59
|
+
dataSuffix?: import('viem').DataSuffix | undefined;
|
|
59
60
|
experimental_blockTag?: import('viem').BlockTag | undefined;
|
|
60
61
|
key: string;
|
|
61
62
|
name: string;
|
|
@@ -4380,6 +4381,7 @@ export declare function createDefaultPublicClient(chainId: number): {
|
|
|
4380
4381
|
cacheTime?: undefined;
|
|
4381
4382
|
ccipRead?: undefined;
|
|
4382
4383
|
chain?: undefined;
|
|
4384
|
+
dataSuffix?: undefined;
|
|
4383
4385
|
experimental_blockTag?: undefined;
|
|
4384
4386
|
key?: undefined;
|
|
4385
4387
|
name?: undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@use-glyph/sdk-react",
|
|
3
|
-
"version": "2.0.17-rc.
|
|
3
|
+
"version": "2.0.17-rc.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "GLYPH-1.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"@privy-io/cross-app-connect": ">=0.2.1",
|
|
56
|
-
"@privy-io/react-auth": "
|
|
57
|
-
"@privy-io/wagmi": ">=
|
|
56
|
+
"@privy-io/react-auth": ">=3.9.0",
|
|
57
|
+
"@privy-io/wagmi": ">=2.0.0",
|
|
58
58
|
"@rainbow-me/rainbowkit": ">=2.2.8",
|
|
59
59
|
"@tanstack/react-query": ">=5.76.0",
|
|
60
60
|
"@types/react": "^18.x || ^19.x",
|
package/dist/ccip.js
DELETED
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
import { s as b, t as x, f as O, A as S, d as $, g as F, e as E, h as I, j as w, k as D, l as R, m as G, I as T, n as m, o as C, B as y, p as L, q as M, r as H, u as v, v as j, w as B, H as A, x as U } from "./index.js";
|
|
2
|
-
function _(a) {
|
|
3
|
-
const { abi: r, data: e } = a, s = b(e, 0, 4), t = r.find((n) => n.type === "function" && s === x(O(n)));
|
|
4
|
-
if (!t)
|
|
5
|
-
throw new S(s, {
|
|
6
|
-
docsPath: "/docs/contract/decodeFunctionData"
|
|
7
|
-
});
|
|
8
|
-
return {
|
|
9
|
-
functionName: t.name,
|
|
10
|
-
args: "inputs" in t && t.inputs && t.inputs.length > 0 ? $(t.inputs, b(e, 4)) : void 0
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
const p = "/docs/contract/encodeErrorResult";
|
|
14
|
-
function k(a) {
|
|
15
|
-
const { abi: r, errorName: e, args: s } = a;
|
|
16
|
-
let t = r[0];
|
|
17
|
-
if (e) {
|
|
18
|
-
const d = F({ abi: r, args: s, name: e });
|
|
19
|
-
if (!d)
|
|
20
|
-
throw new E(e, { docsPath: p });
|
|
21
|
-
t = d;
|
|
22
|
-
}
|
|
23
|
-
if (t.type !== "error")
|
|
24
|
-
throw new E(void 0, { docsPath: p });
|
|
25
|
-
const n = O(t), o = x(n);
|
|
26
|
-
let c = "0x";
|
|
27
|
-
if (s && s.length > 0) {
|
|
28
|
-
if (!t.inputs)
|
|
29
|
-
throw new I(t.name, { docsPath: p });
|
|
30
|
-
c = w(t.inputs, s);
|
|
31
|
-
}
|
|
32
|
-
return D([o, c]);
|
|
33
|
-
}
|
|
34
|
-
const h = "/docs/contract/encodeFunctionResult";
|
|
35
|
-
function J(a) {
|
|
36
|
-
const { abi: r, functionName: e, result: s } = a;
|
|
37
|
-
let t = r[0];
|
|
38
|
-
if (e) {
|
|
39
|
-
const o = F({ abi: r, name: e });
|
|
40
|
-
if (!o)
|
|
41
|
-
throw new R(e, { docsPath: h });
|
|
42
|
-
t = o;
|
|
43
|
-
}
|
|
44
|
-
if (t.type !== "function")
|
|
45
|
-
throw new R(void 0, { docsPath: h });
|
|
46
|
-
if (!t.outputs)
|
|
47
|
-
throw new G(t.name, { docsPath: h });
|
|
48
|
-
const n = (() => {
|
|
49
|
-
if (t.outputs.length === 0)
|
|
50
|
-
return [];
|
|
51
|
-
if (t.outputs.length === 1)
|
|
52
|
-
return [s];
|
|
53
|
-
if (Array.isArray(s))
|
|
54
|
-
return s;
|
|
55
|
-
throw new T(s);
|
|
56
|
-
})();
|
|
57
|
-
return w(t.outputs, n);
|
|
58
|
-
}
|
|
59
|
-
const N = "x-batch-gateway:true";
|
|
60
|
-
async function P(a) {
|
|
61
|
-
const { data: r, ccipRequest: e } = a, { args: [s] } = _({ abi: m, data: r }), t = [], n = [];
|
|
62
|
-
return await Promise.all(s.map(async (o, c) => {
|
|
63
|
-
try {
|
|
64
|
-
n[c] = o.urls.includes(N) ? await P({ data: o.data, ccipRequest: e }) : await e(o), t[c] = !1;
|
|
65
|
-
} catch (d) {
|
|
66
|
-
t[c] = !0, n[c] = W(d);
|
|
67
|
-
}
|
|
68
|
-
})), J({
|
|
69
|
-
abi: m,
|
|
70
|
-
functionName: "query",
|
|
71
|
-
result: [t, n]
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
function W(a) {
|
|
75
|
-
return a.name === "HttpRequestError" && a.status ? k({
|
|
76
|
-
abi: m,
|
|
77
|
-
errorName: "HttpError",
|
|
78
|
-
args: [a.status, a.shortMessage]
|
|
79
|
-
}) : k({
|
|
80
|
-
abi: [C],
|
|
81
|
-
errorName: "Error",
|
|
82
|
-
args: ["shortMessage" in a ? a.shortMessage : a.message]
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
class z extends y {
|
|
86
|
-
constructor({ callbackSelector: r, cause: e, data: s, extraData: t, sender: n, urls: o }) {
|
|
87
|
-
super(e.shortMessage || "An error occurred while fetching for an offchain result.", {
|
|
88
|
-
cause: e,
|
|
89
|
-
metaMessages: [
|
|
90
|
-
...e.metaMessages || [],
|
|
91
|
-
e.metaMessages?.length ? "" : [],
|
|
92
|
-
"Offchain Gateway Call:",
|
|
93
|
-
o && [
|
|
94
|
-
" Gateway URL(s):",
|
|
95
|
-
...o.map((c) => ` ${L(c)}`)
|
|
96
|
-
],
|
|
97
|
-
` Sender: ${n}`,
|
|
98
|
-
` Data: ${s}`,
|
|
99
|
-
` Callback selector: ${r}`,
|
|
100
|
-
` Extra data: ${t}`
|
|
101
|
-
].flat(),
|
|
102
|
-
name: "OffchainLookupError"
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
class K extends y {
|
|
107
|
-
constructor({ result: r, url: e }) {
|
|
108
|
-
super("Offchain gateway response is malformed. Response data must be a hex value.", {
|
|
109
|
-
metaMessages: [
|
|
110
|
-
`Gateway URL: ${L(e)}`,
|
|
111
|
-
`Response: ${M(r)}`
|
|
112
|
-
],
|
|
113
|
-
name: "OffchainLookupResponseMalformedError"
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
class Q extends y {
|
|
118
|
-
constructor({ sender: r, to: e }) {
|
|
119
|
-
super("Reverted sender address does not match target contract address (`to`).", {
|
|
120
|
-
metaMessages: [
|
|
121
|
-
`Contract address: ${e}`,
|
|
122
|
-
`OffchainLookup sender address: ${r}`
|
|
123
|
-
],
|
|
124
|
-
name: "OffchainLookupSenderMismatchError"
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
const Z = "0x556f1830", V = {
|
|
129
|
-
name: "OffchainLookup",
|
|
130
|
-
type: "error",
|
|
131
|
-
inputs: [
|
|
132
|
-
{
|
|
133
|
-
name: "sender",
|
|
134
|
-
type: "address"
|
|
135
|
-
},
|
|
136
|
-
{
|
|
137
|
-
name: "urls",
|
|
138
|
-
type: "string[]"
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
name: "callData",
|
|
142
|
-
type: "bytes"
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
name: "callbackFunction",
|
|
146
|
-
type: "bytes4"
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
name: "extraData",
|
|
150
|
-
type: "bytes"
|
|
151
|
-
}
|
|
152
|
-
]
|
|
153
|
-
};
|
|
154
|
-
async function tt(a, { blockNumber: r, blockTag: e, data: s, to: t }) {
|
|
155
|
-
const { args: n } = H({
|
|
156
|
-
data: s,
|
|
157
|
-
abi: [V]
|
|
158
|
-
}), [o, c, d, i, u] = n, { ccipRead: f } = a, g = f && typeof f?.request == "function" ? f.request : X;
|
|
159
|
-
try {
|
|
160
|
-
if (!v(t, o))
|
|
161
|
-
throw new Q({ sender: o, to: t });
|
|
162
|
-
const l = c.includes(N) ? await P({
|
|
163
|
-
data: d,
|
|
164
|
-
ccipRequest: g
|
|
165
|
-
}) : await g({ data: d, sender: o, urls: c }), { data: q } = await j(a, {
|
|
166
|
-
blockNumber: r,
|
|
167
|
-
blockTag: e,
|
|
168
|
-
data: B([
|
|
169
|
-
i,
|
|
170
|
-
w([{ type: "bytes" }, { type: "bytes" }], [l, u])
|
|
171
|
-
]),
|
|
172
|
-
to: t
|
|
173
|
-
});
|
|
174
|
-
return q;
|
|
175
|
-
} catch (l) {
|
|
176
|
-
throw new z({
|
|
177
|
-
callbackSelector: i,
|
|
178
|
-
cause: l,
|
|
179
|
-
data: s,
|
|
180
|
-
extraData: u,
|
|
181
|
-
sender: o,
|
|
182
|
-
urls: c
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
async function X({ data: a, sender: r, urls: e }) {
|
|
187
|
-
let s = new Error("An unknown error occurred.");
|
|
188
|
-
for (let t = 0; t < e.length; t++) {
|
|
189
|
-
const n = e[t], o = n.includes("{data}") ? "GET" : "POST", c = o === "POST" ? { data: a, sender: r } : void 0, d = o === "POST" ? { "Content-Type": "application/json" } : {};
|
|
190
|
-
try {
|
|
191
|
-
const i = await fetch(n.replace("{sender}", r.toLowerCase()).replace("{data}", a), {
|
|
192
|
-
body: JSON.stringify(c),
|
|
193
|
-
headers: d,
|
|
194
|
-
method: o
|
|
195
|
-
});
|
|
196
|
-
let u;
|
|
197
|
-
if (i.headers.get("Content-Type")?.startsWith("application/json") ? u = (await i.json()).data : u = await i.text(), !i.ok) {
|
|
198
|
-
s = new A({
|
|
199
|
-
body: c,
|
|
200
|
-
details: u?.error ? M(u.error) : i.statusText,
|
|
201
|
-
headers: i.headers,
|
|
202
|
-
status: i.status,
|
|
203
|
-
url: n
|
|
204
|
-
});
|
|
205
|
-
continue;
|
|
206
|
-
}
|
|
207
|
-
if (!U(u)) {
|
|
208
|
-
s = new K({
|
|
209
|
-
result: u,
|
|
210
|
-
url: n
|
|
211
|
-
});
|
|
212
|
-
continue;
|
|
213
|
-
}
|
|
214
|
-
return u;
|
|
215
|
-
} catch (i) {
|
|
216
|
-
s = new A({
|
|
217
|
-
body: c,
|
|
218
|
-
details: i.message,
|
|
219
|
-
url: n
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
throw s;
|
|
224
|
-
}
|
|
225
|
-
export {
|
|
226
|
-
X as ccipRequest,
|
|
227
|
-
tt as offchainLookup,
|
|
228
|
-
V as offchainLookupAbiItem,
|
|
229
|
-
Z as offchainLookupSignature
|
|
230
|
-
};
|
|
231
|
-
//# sourceMappingURL=ccip.js.map
|
package/dist/ccip.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ccip.js","sources":["../../node_modules/.pnpm/viem@2.44.1_bufferutil@4.1.0_typescript@5.9.3_utf-8-validate@5.0.10_zod@3.25.76/node_modules/viem/_esm/utils/abi/decodeFunctionData.js","../../node_modules/.pnpm/viem@2.44.1_bufferutil@4.1.0_typescript@5.9.3_utf-8-validate@5.0.10_zod@3.25.76/node_modules/viem/_esm/utils/abi/encodeErrorResult.js","../../node_modules/.pnpm/viem@2.44.1_bufferutil@4.1.0_typescript@5.9.3_utf-8-validate@5.0.10_zod@3.25.76/node_modules/viem/_esm/utils/abi/encodeFunctionResult.js","../../node_modules/.pnpm/viem@2.44.1_bufferutil@4.1.0_typescript@5.9.3_utf-8-validate@5.0.10_zod@3.25.76/node_modules/viem/_esm/utils/ens/localBatchGatewayRequest.js","../../node_modules/.pnpm/viem@2.44.1_bufferutil@4.1.0_typescript@5.9.3_utf-8-validate@5.0.10_zod@3.25.76/node_modules/viem/_esm/errors/ccip.js","../../node_modules/.pnpm/viem@2.44.1_bufferutil@4.1.0_typescript@5.9.3_utf-8-validate@5.0.10_zod@3.25.76/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 { 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":["decodeFunctionData","parameters","abi","data","signature","slice","description","x","toFunctionSelector","formatAbiItem","AbiFunctionSignatureNotFoundError","decodeAbiParameters","docsPath","encodeErrorResult","errorName","args","abiItem","item","getAbiItem","AbiErrorNotFoundError","definition","AbiErrorInputsNotFoundError","encodeAbiParameters","concatHex","encodeFunctionResult","functionName","result","AbiFunctionNotFoundError","AbiFunctionOutputsNotFoundError","values","InvalidArrayError","localBatchGatewayUrl","localBatchGatewayRequest","ccipRequest","queries","batchGatewayAbi","failures","responses","query","i","err","encodeError","error","solidityError","OffchainLookupError","BaseError","callbackSelector","cause","extraData","sender","urls","url","getUrl","OffchainLookupResponseMalformedError","stringify","OffchainLookupSenderMismatchError","to","offchainLookupSignature","offchainLookupAbiItem","offchainLookup","client","blockNumber","blockTag","decodeErrorResult","callData","ccipRead","ccipRequest_","isAddressEqual","data_","call","concat","method","body","headers","response","HttpRequestError","isHex"],"mappings":";AAKO,SAASA,EAAmBC,GAAY;AAC3C,QAAM,EAAE,KAAAC,GAAK,MAAAC,EAAI,IAAKF,GAChBG,IAAYC,EAAMF,GAAM,GAAG,CAAC,GAC5BG,IAAcJ,EAAI,KAAK,CAACK,MAAMA,EAAE,SAAS,cAC3CH,MAAcI,EAAmBC,EAAcF,CAAC,CAAC,CAAC;AACtD,MAAI,CAACD;AACD,UAAM,IAAII,EAAkCN,GAAW;AAAA,MACnD,UAAU;AAAA,IACtB,CAAS;AACL,SAAO;AAAA,IACH,cAAcE,EAAY;AAAA,IAC1B,MAAO,YAAYA,KACfA,EAAY,UACZA,EAAY,OAAO,SAAS,IAC1BK,EAAoBL,EAAY,QAAQD,EAAMF,GAAM,CAAC,CAAC,IACtD;AAAA,EACd;AACA;AChBA,MAAMS,IAAW;AACV,SAASC,EAAkBZ,GAAY;AAC1C,QAAM,EAAE,KAAAC,GAAK,WAAAY,GAAW,MAAAC,EAAI,IAAKd;AACjC,MAAIe,IAAUd,EAAI,CAAC;AACnB,MAAIY,GAAW;AACX,UAAMG,IAAOC,EAAW,EAAE,KAAAhB,GAAK,MAAAa,GAAM,MAAMD,GAAW;AACtD,QAAI,CAACG;AACD,YAAM,IAAIE,EAAsBL,GAAW,EAAA,UAAEF,EAAQ,CAAE;AAC3D,IAAAI,IAAUC;AAAA,EACd;AACA,MAAID,EAAQ,SAAS;AACjB,UAAM,IAAIG,EAAsB,QAAW,EAAA,UAAEP,EAAQ,CAAE;AAC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