@blockend/widget 1.0.55-beta.1 → 1.0.55-beta.2
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/{AllRoutes-D6S-NFxZ.js → AllRoutes-DIde2MHr.js} +910 -929
- package/dist/{Box-DESo1bHm.js → Box-DQB1ZyEK.js} +15 -15
- package/dist/EstGas-C7sLxEX_.js +1523 -0
- package/dist/{Grow-DzEr7XrA.js → Grow-CxaAxl6-.js} +300 -303
- package/dist/InputComp-CDuJJKaD.js +105 -0
- package/dist/LoadRoute-CVas28CM.js +123 -0
- package/dist/QuotesProgress-DaL4L4Db.js +27 -0
- package/dist/{SwapAsset-MBXcdeBf.js → SwapAsset-DSV6l90O.js} +13 -14
- package/dist/{Tooltip-DSAJT2x7.js → Tooltip-PAQ9gquY.js} +35 -35
- package/dist/TxnButton-BiO4vJ-y.js +207 -0
- package/dist/ccip-B6-4PQvj.js +226 -0
- package/dist/core-SB441dD5.js +13166 -0
- package/dist/{down-BFx-Bg5Q.js → down-DJH_apvy.js} +267 -270
- package/dist/{getChainIds-CeLEUxe0.js → getChainIds-CBclVfs9.js} +221 -223
- package/dist/getCosmosAddress-CI7CTn-0.js +57 -0
- package/dist/{hamburger-BzMrQx9y.js → hamburger-Dp-PI6Yn.js} +153 -153
- package/dist/{index-DpHhW0_2.js → index-5WTwgH9q.js} +3 -3
- package/dist/index-B-FRPlBv.js +3240 -0
- package/dist/index-B158Vaz9.js +146 -0
- package/dist/{index-BK0BZT6j.js → index-B9PIELoY.js} +5118 -5241
- package/dist/{index-DHYWnqST.js → index-BGt3GtoG.js} +1 -1
- package/dist/index-BuGCRLd5.js +198 -0
- package/dist/index-CRhXLwtt.js +7445 -0
- package/dist/{index-A8ClQmZo.js → index-Dmf6i8k4.js} +3 -4
- package/dist/{index-SkYFFVLL.js → index-PxQusjX0.js} +3368 -3415
- package/dist/{index-C5bv1F_u.js → index-UFdEurQ_.js} +12086 -12350
- package/dist/{index.es-DB9y_DEM.js → index.es-AaEds8Wm.js} +81 -83
- package/dist/{index.es-vIyUKt0W.js → index.es-Df0KTgu4.js} +4523 -4628
- package/dist/index.es.js +1 -1
- package/dist/{unsupportedProp-BLzY2-w_.js → unsupportedProp-BlS305Lt.js} +1 -1
- package/dist/{useRegisterError-Cf6oylnR.js → useRegisterError-BvjIv1Yc.js} +1668 -1701
- package/dist/widget.css +1 -1
- package/package.json +4 -5
- package/dist/EstGas-Dy3XfCzY.js +0 -1496
- package/dist/InputComp-GcnDqx_s.js +0 -105
- package/dist/LoadRoute-BmUgvDid.js +0 -125
- package/dist/QuotesProgress-E5JnUMS0.js +0 -28
- package/dist/TxnButton-Br8R19rF.js +0 -215
- package/dist/add-BryKCrpI.js +0 -19
- package/dist/all-wallets-BMVOK2Ci.js +0 -10
- package/dist/app-store-3WurbJdI.js +0 -21
- package/dist/apple-eM872Ubz.js +0 -22
- package/dist/arrow-bottom-HMc73fJ8.js +0 -12
- package/dist/arrow-bottom-circle-B1N_R8Ux.js +0 -15
- package/dist/arrow-left-Q7GAZkD7.js +0 -12
- package/dist/arrow-right-ft3TcIM3.js +0 -12
- package/dist/arrow-top-C2xmF6tK.js +0 -12
- package/dist/bank-Bk-2ZR5E.js +0 -18
- package/dist/basic-CWrKgDAB.js +0 -5783
- package/dist/browser-BFB3TFfv.js +0 -18
- package/dist/card-DCx59si8.js +0 -18
- package/dist/ccip-CXr08uP1.js +0 -228
- package/dist/checkmark-BGsuJuhE.js +0 -15
- package/dist/checkmark-bold-DvjIl-51.js +0 -12
- package/dist/chevron-bottom-DAEnG7QP.js +0 -12
- package/dist/chevron-left-D33h2ppx.js +0 -12
- package/dist/chevron-right-C8Z_feNK.js +0 -12
- package/dist/chevron-top-DwDMd3p9.js +0 -12
- package/dist/chrome-store-B7ZDs2Fj.js +0 -65
- package/dist/clock-DnELUxSR.js +0 -12
- package/dist/close-Dnt29Pss.js +0 -12
- package/dist/coinPlaceholder-C09pzuXv.js +0 -12
- package/dist/compass-D8ZY16nH.js +0 -12
- package/dist/copy-DEh4RBKI.js +0 -19
- package/dist/core-CgIQaiRa.js +0 -14966
- package/dist/cursor-BtzkAOER.js +0 -7
- package/dist/cursor-transparent-B0nCflmb.js +0 -16
- package/dist/desktop-toTG92uH.js +0 -13
- package/dist/disconnect-C97lbAtY.js +0 -12
- package/dist/discord-BNJ3JePY.js +0 -21
- package/dist/etherscan-CK87TQMS.js +0 -10
- package/dist/exclamation-triangle-LWnOk0uz.js +0 -8
- package/dist/extension-5eIZU28A.js +0 -12
- package/dist/external-link-DDlCfigP.js +0 -12
- package/dist/facebook-1lTMXKeH.js +0 -30
- package/dist/farcaster-Di2TUKlZ.js +0 -16
- package/dist/filters-B_THnHaX.js +0 -12
- package/dist/getCosmosAddress-B8s9Ycj4.js +0 -6075
- package/dist/github-D5B1FE4K.js +0 -22
- package/dist/google-C8_WSUfw.js +0 -22
- package/dist/help-circle-C-ZOzjAP.js +0 -16
- package/dist/id-BynpKmej.js +0 -16
- package/dist/image-BRYUh760.js +0 -8
- package/dist/index-BFUVWgoD.js +0 -992
- package/dist/index-CN6pVc2G.js +0 -1483
- package/dist/index-CZwuzz6v.js +0 -6712
- package/dist/index-Dnyeih-W.js +0 -3261
- package/dist/index-krrwn6Pi.js +0 -206
- package/dist/info-DSQyHS8b.js +0 -7
- package/dist/info-circle-BfpWcI4c.js +0 -16
- package/dist/lightbulb-DEMYYsZd.js +0 -7
- package/dist/mail-DNZ2to_6.js +0 -12
- package/dist/mobile-qsyS8oMK.js +0 -13
- package/dist/more-CnBuKwll.js +0 -15
- package/dist/network-placeholder-DhJITakA.js +0 -18
- package/dist/nftPlaceholder-DD3-Cc9U.js +0 -12
- package/dist/off-CBApAdDk.js +0 -12
- package/dist/play-store-DDoeRc-b.js +0 -36
- package/dist/plus-C3J-XWCn.js +0 -17
- package/dist/qr-code-CEoOYtHk.js +0 -10
- package/dist/recycle-horizontal-BHJ_s9Yx.js +0 -13
- package/dist/refresh-CtzOoHls.js +0 -12
- package/dist/reown-logo-BOj4YDUQ.js +0 -16
- package/dist/search--Miza3A_.js +0 -12
- package/dist/send-Bhl1lz4j.js +0 -19
- package/dist/swapHorizontal-CCvKCngz.js +0 -12
- package/dist/swapHorizontalBold-B90V-dXL.js +0 -12
- package/dist/swapHorizontalMedium-CYjeHjnI.js +0 -20
- package/dist/swapHorizontalRoundedBold-DSMWeXdW.js +0 -12
- package/dist/swapVertical-DOJUNIvk.js +0 -12
- package/dist/telegram-CufEY_4d.js +0 -20
- package/dist/three-dots-J2ngva7G.js +0 -9
- package/dist/twitch-B4vTKVf5.js +0 -22
- package/dist/twitterIcon-DLrxpAGg.js +0 -10
- package/dist/verify-CbHqPQKs.js +0 -12
- package/dist/verify-filled-CzKx9Cph.js +0 -12
- package/dist/w3m-modal-DhpjK4cG.js +0 -1471
- package/dist/wallet-CvIeO6On.js +0 -12
- package/dist/wallet-placeholder-BqELXTBj.js +0 -18
- package/dist/walletconnect-BN4c4XQ5.js +0 -36
- package/dist/warning-circle--dqxXujk.js +0 -16
- package/dist/x-CkCp5gtL.js +0 -16
@@ -0,0 +1,207 @@
|
|
1
|
+
import { jsx as x } from "react/jsx-runtime";
|
2
|
+
import { useState as S, useEffect as $ } from "react";
|
3
|
+
import { useDynamicContext as te, useSwitchNetwork as pe, useIsLoggedIn as ge } from "@dynamic-labs/sdk-react-core";
|
4
|
+
import { v as M, u as b, w as ye, x as Y } from "./index-UFdEurQ_.js";
|
5
|
+
import { s as T } from "./WidgetForm.module-QHJ0-m5f.js";
|
6
|
+
import { useAccount as xe, useConfig as Te, useSwitchChain as ke, useBalance as Ie } from "wagmi";
|
7
|
+
import { u as Z, c as Ne, a as Ce, C as ee } from "./useRegisterError-BvjIv1Yc.js";
|
8
|
+
import { v as Be } from "./validError-CDlJpg_f.js";
|
9
|
+
import { u as ve, g as Ge, p as Se } from "./index-CRhXLwtt.js";
|
10
|
+
function $e(i) {
|
11
|
+
const { address: w } = M(), [c, h] = S(0);
|
12
|
+
async function f() {
|
13
|
+
const l = await window.tronWeb.trx.getBalance(w);
|
14
|
+
h(l / Math.pow(10, 6));
|
15
|
+
}
|
16
|
+
return $(() => {
|
17
|
+
w && i?.networkType === "tron" && f();
|
18
|
+
}, [w, i?.networkType]), { tronBal: c };
|
19
|
+
}
|
20
|
+
function G(i) {
|
21
|
+
if (i.key.toLowerCase() === "backpacksol")
|
22
|
+
return !0;
|
23
|
+
}
|
24
|
+
function Ee() {
|
25
|
+
const [i, w] = S(0), c = b((l) => l.fromChain), { primaryWallet: h } = te();
|
26
|
+
async function f() {
|
27
|
+
let l = await h.getBalance();
|
28
|
+
w(Number(l) || 0);
|
29
|
+
}
|
30
|
+
return $(() => {
|
31
|
+
(c.networkType === "btc" || c.networkType === "sui") && f();
|
32
|
+
}, [c.networkType, h]), i;
|
33
|
+
}
|
34
|
+
function Ve({ routesData: i, routes: w, amount: c, isAmountTyped: h, handleShowWallet: f, setConnectWalletField: l, handleConfirmClose: O, balanceSol: C, getCoinBalance: ne, handleSuccess: R }) {
|
35
|
+
const a = b((t) => t.gradient), p = b((t) => t.configuration), e = b((t) => t.fromChain), m = b((t) => t.fromCoin), s = b((t) => t.toChain), k = b((t) => t.toCoin), { isConnected: B, address: V, chain: E } = xe(), { address: P } = M(), re = Te(), oe = pe(), { getBothWalletConnection: se, getConnectWallet: ae } = Z({
|
36
|
+
chainData: e
|
37
|
+
}), { connected: _, address: q } = M(), F = b((t) => t.toDisconnect), u = b((t) => t.customWallet), { getWallet: ie } = Z({ chainData: e }), ce = ae(e, s), [L, le] = S("101"), { tronBal: W } = $e(e), { cosmosBalance: Q } = ve(), H = Ee(), j = e.chain?.length && s.chain?.length, A = m.address?.length && k.address?.length, de = Ne(), J = ye(), { switchChainAsync: we, isPending: me } = ke({
|
38
|
+
chainId: Number(e?.chainId || "0"),
|
39
|
+
config: re,
|
40
|
+
throwForSwitchChainNotSupported: !0,
|
41
|
+
onError(t) {
|
42
|
+
Be(t.message) && de({ module: "wallet-error-switch", error: t.message });
|
43
|
+
}
|
44
|
+
}), I = Ie({
|
45
|
+
address: V,
|
46
|
+
token: "",
|
47
|
+
chainId: Number(e?.chainId || 0),
|
48
|
+
enabled: e?.networkType == "evm"
|
49
|
+
}), K = Ce(ne || 0, 11), [g, o] = S({
|
50
|
+
text: "",
|
51
|
+
isGradient: !1,
|
52
|
+
color: "bw-bg-border-primary"
|
53
|
+
});
|
54
|
+
async function ue() {
|
55
|
+
if (e?.networkType === "evm" && Number(e?.chainId || "0") !== E?.id)
|
56
|
+
try {
|
57
|
+
await we({ chainId: Number(e?.chainId || "0") });
|
58
|
+
} catch {
|
59
|
+
}
|
60
|
+
else if (e?.networkType === "sol" && L !== (e?.chainId == "eclipse-svm" ? "201" : "101"))
|
61
|
+
try {
|
62
|
+
let t = await oe({ wallet: d, network: e.chainId == "eclipse-svm" ? "201" : "101" });
|
63
|
+
U();
|
64
|
+
} catch {
|
65
|
+
}
|
66
|
+
else e?.networkType === "sui" ? (J.emit(Y.TransactionStarted, {
|
67
|
+
...i
|
68
|
+
}), N && (R(!1), O())) : (J.emit(Y.TransactionStarted, {
|
69
|
+
...i
|
70
|
+
}), N && (R(!1), O()));
|
71
|
+
}
|
72
|
+
const { primaryWallet: d } = te(), z = ge(), N = e?.networkType === s.networkType ? !!ie(e)?.address?.length : se(e?.networkType, u?.length > 30 ? "customWallet" : s?.networkType), U = async () => {
|
73
|
+
if (d)
|
74
|
+
try {
|
75
|
+
const t = await d.getNetwork();
|
76
|
+
le(t);
|
77
|
+
} catch {
|
78
|
+
}
|
79
|
+
else
|
80
|
+
return;
|
81
|
+
};
|
82
|
+
$(() => {
|
83
|
+
U();
|
84
|
+
}, [d]);
|
85
|
+
function X(t, v) {
|
86
|
+
let y = t / Math.pow(10, v);
|
87
|
+
return y < 1e-6 ? y.toFixed(20) : y;
|
88
|
+
}
|
89
|
+
function be() {
|
90
|
+
return Number(I?.data?.formatted || 0);
|
91
|
+
}
|
92
|
+
function he(t) {
|
93
|
+
return Number(Q[Se(t.address)]?.amount || 0) / Math.pow(10, t.decimals);
|
94
|
+
}
|
95
|
+
function fe() {
|
96
|
+
let t = {};
|
97
|
+
async function v(n, r) {
|
98
|
+
let D = Object.keys(t);
|
99
|
+
t[n?.chainId] ? (t[n?.chainId].amountInToken += r.amountInToken, t[n?.chainId].gas += X(r.amountInToken, n?.decimals)) : t[n?.chainId] = {
|
100
|
+
amountInToken: r.amountInToken,
|
101
|
+
gas: X(r.amountInToken, n?.decimals),
|
102
|
+
token: n,
|
103
|
+
nativeBal: u?.length > 30 && !F && n?.chainId == s?.chainId && s?.chainId !== e?.chainId ? 0 : n?.networkType == "sol" ? C : n?.networkType == "tron" ? W : n?.networkType == "btc" || n?.networkType == "sui" ? H : n?.networkType == "cosmos" ? he(n) : n?.networkType == "tron" ? Ge(P) : be(),
|
104
|
+
isFromChain: e?.chainId === n?.chainId.toString(),
|
105
|
+
order: e?.chainId === n?.chainId ? 1 : s?.chainId === n?.chainId ? 2 : D.length > 2 ? 3 : 2
|
106
|
+
};
|
107
|
+
}
|
108
|
+
i?.fee?.forEach((n) => {
|
109
|
+
const { token: r } = n;
|
110
|
+
n.source.toLowerCase() == "from_source_wallet" && v(r, n);
|
111
|
+
});
|
112
|
+
let y = K;
|
113
|
+
if (Number(c) > Number(y))
|
114
|
+
o({
|
115
|
+
text: `Insufficient Balance ${m.coin || ""}`,
|
116
|
+
isGradient: !1,
|
117
|
+
color: "bw-bg-border-primary"
|
118
|
+
});
|
119
|
+
else if ((I?.isLoading || I.isFetching) && e?.networkType === "evm" || (typeof C > "u" || C === null) && e?.networkType === "sol" || !W && e?.networkType === "tron")
|
120
|
+
o({
|
121
|
+
text: "Fetching Balance..",
|
122
|
+
isGradient: !1,
|
123
|
+
color: "bw-bg-border-primary"
|
124
|
+
});
|
125
|
+
else {
|
126
|
+
let n = Object.values(t).sort((r, D) => r.order - D.order);
|
127
|
+
n.some((r) => r?.isFromChain && Number(c) <= Number(y) && Number(r.nativeBal) - Number(c) < r.gas && m?.isNative || Number(c) <= Number(y) && Number(r.nativeBal) < r.gas && !m?.isNative && r?.isFromChain ? (o({
|
128
|
+
text: `Insufficient ${r?.token?.symbol || ""} for gas on ${r.token.blockchain}`,
|
129
|
+
isGradient: !1,
|
130
|
+
color: "bw-bg-border-primary"
|
131
|
+
}), !0) : r.nativeBal < r.gas && !(u?.length > 30 && r?.token?.chainId == s?.chainId) ? (o({
|
132
|
+
text: `Insufficient ${r?.token?.symbol || ""} for gas on ${r.token.blockchain}`,
|
133
|
+
isGradient: !1,
|
134
|
+
color: "bw-bg-border-primary"
|
135
|
+
}), !0) : (o({
|
136
|
+
text: "",
|
137
|
+
isGradient: !0,
|
138
|
+
color: a || T.gradientbutton
|
139
|
+
}), !0)), n.length == 0 && (i?.gasless || i?.provider == "meson") && o({
|
140
|
+
text: "",
|
141
|
+
isGradient: !0,
|
142
|
+
color: a || T.gradientbutton
|
143
|
+
});
|
144
|
+
}
|
145
|
+
}
|
146
|
+
return $(() => {
|
147
|
+
!m.coin.length || !k?.coin.length ? o({
|
148
|
+
text: "Select Token",
|
149
|
+
isGradient: !0,
|
150
|
+
color: a || T.gradientbutton
|
151
|
+
}) : N ? typeof c < "u" && Number(c || 0) <= 0 ? o({
|
152
|
+
text: "Enter Amount",
|
153
|
+
isGradient: !1,
|
154
|
+
color: "bw-bg-border-primary"
|
155
|
+
}) : w.isFetching || !h ? o({
|
156
|
+
text: "Loading Routes...",
|
157
|
+
isGradient: !1,
|
158
|
+
color: "bw-bg-border-primary"
|
159
|
+
}) : e.chainId === "eclipse-svm" && !G(d) ? o({
|
160
|
+
text: `Select ${e.name} wallet`,
|
161
|
+
isGradient: !0,
|
162
|
+
color: a || T.gradientbutton
|
163
|
+
}) : s.chainId === "eclipse-svm" && e.chainId !== "eclipse-svm" && !G(d) && u.length < 30 ? o({
|
164
|
+
text: "Enter recipient wallet address",
|
165
|
+
isGradient: !0,
|
166
|
+
color: a || T.gradientbutton
|
167
|
+
}) : m?.address == k?.address && e?.chainId == s?.chainId && !u?.length || e?.networkType == "evm" && V === u && m?.address == k?.address || e?.networkType == "sol" && d?.address === u && m?.address == k?.address ? o({
|
168
|
+
text: "From and To asset can not be the same!",
|
169
|
+
isGradient: !1,
|
170
|
+
color: "bw-bg-border-primary"
|
171
|
+
}) : w?.data?.data?.quotes?.length ? w?.error ? o({
|
172
|
+
text: "Failed to fetch Quotes",
|
173
|
+
isGradient: !1,
|
174
|
+
color: "bw-bg-border-primary"
|
175
|
+
}) : B && Number(e?.chainId || "0") !== E?.id && e?.networkType === "evm" || z && (e?.chainId === "eclipse-svm" ? "201" : "101") !== L && e?.networkType === "sol" ? o({
|
176
|
+
text: `Switch Chain to ${e.chain}`,
|
177
|
+
isGradient: !0,
|
178
|
+
color: a || T.gradientbutton
|
179
|
+
}) : fe() : o({
|
180
|
+
text: "No Routes Found",
|
181
|
+
isGradient: !1,
|
182
|
+
color: "bw-bg-border-primary"
|
183
|
+
}) : o({
|
184
|
+
text: "",
|
185
|
+
isGradient: !0,
|
186
|
+
color: a || T.gradientbutton
|
187
|
+
});
|
188
|
+
}, [L, d, m, k, c, e, s, I.data?.formatted, i, I.isFetching, I.isLoading, B, K, N, w.isFetching, E?.id, h, W, C, u, H, Q, P]), `${e.chain?.toLowerCase()}`, `${e.chain?.toLowerCase()}`, /* @__PURE__ */ x(
|
189
|
+
"button",
|
190
|
+
{
|
191
|
+
style: g?.isGradient && j && A ? {
|
192
|
+
...p?.gradientStyle,
|
193
|
+
boxShadow: p && p.customTheme && p.customTheme?.shadow?.boxShadow || "1px 1px 7px rgba(0, 0, 0, 0.15)"
|
194
|
+
} : {
|
195
|
+
boxShadow: p && p.customTheme && p.customTheme?.shadow?.boxShadow || "1px 1px 7px rgba(0, 0, 0, 0.15)"
|
196
|
+
},
|
197
|
+
className: `bw-w-full bw-rounded-sm bw-h-[52px] ${g?.isGradient ? "bw-p-[3px]" : "bw-p-[1px]"} bw-mt-3 bw-border-0 bw-relative bw-z-0 disabled:bw-opacity-70 ${j && A && g.color} ${g.text.length > 29 ? "bw-text-xl" : "bw-text-2xl"} ${g?.isGradient ? "bw-font-bold bw-text-text-primary" : "bw-font-normal bw-text-text-secondary"}`,
|
198
|
+
onClick: () => {
|
199
|
+
N || (f(!0), (e?.networkType !== "evm" && B || e?.networkType !== "sol" && z && d !== null || e?.networkType !== "tron" && _ && q) && !F ? l("from") : B && s?.networkType !== "evm" || z && s?.networkType !== "sol" || s?.networkType !== "tron" && _ && q || F ? l("to") : l("from")), e.chainId === "eclipse-svm" && !G(d) ? (f(!0), l("from")) : s.chainId === "eclipse-svm" && e.chainId !== "eclipse-svm" && !G(d) && u.length < 30 ? (f(!0), l("to")) : ue();
|
200
|
+
},
|
201
|
+
children: /* @__PURE__ */ x("div", { className: "bw-rounded-sm bw-bg-background-container bw-flex bw-items-center bw-justify-center b-w-full bw-h-full", children: /* @__PURE__ */ x("p", { className: "bw-relative bw-z-20", children: j && A ? me ? /* @__PURE__ */ x("div", { className: "bw-w-[30px] bw-flex bw-text-text-secondary bw-justify-center bw-items-center bw-h-[30px]", children: /* @__PURE__ */ x(ee, { size: 22, thickness: 5, color: "inherit" }) }) : N ? g.text.length ? g.text : "Start Transaction" : `Connect ${ce} Wallet` : /* @__PURE__ */ x("div", { className: "bw-w-[30px] bw-flex bw-text-text-secondary bw-justify-center bw-items-center bw-h-[30px]", children: /* @__PURE__ */ x(ee, { size: 22, thickness: 5, color: "inherit" }) }) }) })
|
202
|
+
}
|
203
|
+
);
|
204
|
+
}
|
205
|
+
export {
|
206
|
+
Ve as default
|
207
|
+
};
|
@@ -0,0 +1,226 @@
|
|
1
|
+
import { A as O, B as b, D as F, E as N, F as $, G as w, H as P, I as E, J as S, K as I, L as C, M as m, N as G, O as R, Q as A, R as y, U as x, V as M, W as D, X as T, Y as H, Z as L, $ as v } from "./index-UFdEurQ_.js";
|
2
|
+
const p = "/docs/contract/encodeErrorResult";
|
3
|
+
function k(t) {
|
4
|
+
const { abi: s, errorName: a, args: r } = t;
|
5
|
+
let e = s[0];
|
6
|
+
if (a) {
|
7
|
+
const d = O({ abi: s, args: r, name: a });
|
8
|
+
if (!d)
|
9
|
+
throw new b(a, { docsPath: p });
|
10
|
+
e = d;
|
11
|
+
}
|
12
|
+
if (e.type !== "error")
|
13
|
+
throw new b(void 0, { docsPath: p });
|
14
|
+
const o = F(e), n = N(o);
|
15
|
+
let c = "0x";
|
16
|
+
if (r && r.length > 0) {
|
17
|
+
if (!e.inputs)
|
18
|
+
throw new $(e.name, { docsPath: p });
|
19
|
+
c = w(e.inputs, r);
|
20
|
+
}
|
21
|
+
return P([n, c]);
|
22
|
+
}
|
23
|
+
const h = "/docs/contract/encodeFunctionResult";
|
24
|
+
function U(t) {
|
25
|
+
const { abi: s, functionName: a, result: r } = t;
|
26
|
+
let e = s[0];
|
27
|
+
if (a) {
|
28
|
+
const n = O({ abi: s, name: a });
|
29
|
+
if (!n)
|
30
|
+
throw new E(a, { docsPath: h });
|
31
|
+
e = n;
|
32
|
+
}
|
33
|
+
if (e.type !== "function")
|
34
|
+
throw new E(void 0, { docsPath: h });
|
35
|
+
if (!e.outputs)
|
36
|
+
throw new S(e.name, { docsPath: h });
|
37
|
+
const o = (() => {
|
38
|
+
if (e.outputs.length === 0)
|
39
|
+
return [];
|
40
|
+
if (e.outputs.length === 1)
|
41
|
+
return [r];
|
42
|
+
if (Array.isArray(r))
|
43
|
+
return r;
|
44
|
+
throw new I(r);
|
45
|
+
})();
|
46
|
+
return w(e.outputs, o);
|
47
|
+
}
|
48
|
+
const B = "x-batch-gateway:true";
|
49
|
+
async function j(t) {
|
50
|
+
const { data: s, ccipRequest: a } = t, { args: [r] } = C({ abi: m, data: s }), e = [], o = [];
|
51
|
+
return await Promise.all(r.map(async (n, c) => {
|
52
|
+
try {
|
53
|
+
o[c] = await a(n), e[c] = !1;
|
54
|
+
} catch (d) {
|
55
|
+
e[c] = !0, o[c] = J(d);
|
56
|
+
}
|
57
|
+
})), U({
|
58
|
+
abi: m,
|
59
|
+
functionName: "query",
|
60
|
+
result: [e, o]
|
61
|
+
});
|
62
|
+
}
|
63
|
+
function J(t) {
|
64
|
+
return t.name === "HttpRequestError" && t.status ? k({
|
65
|
+
abi: m,
|
66
|
+
errorName: "HttpError",
|
67
|
+
args: [t.status, t.shortMessage]
|
68
|
+
}) : k({
|
69
|
+
abi: [G],
|
70
|
+
errorName: "Error",
|
71
|
+
args: ["shortMessage" in t ? t.shortMessage : t.message]
|
72
|
+
});
|
73
|
+
}
|
74
|
+
function W(t, s) {
|
75
|
+
if (!R(t, { strict: !1 }))
|
76
|
+
throw new A({ address: t });
|
77
|
+
if (!R(s, { strict: !1 }))
|
78
|
+
throw new A({ address: s });
|
79
|
+
return t.toLowerCase() === s.toLowerCase();
|
80
|
+
}
|
81
|
+
class _ extends y {
|
82
|
+
constructor({ callbackSelector: s, cause: a, data: r, extraData: e, sender: o, urls: n }) {
|
83
|
+
super(a.shortMessage || "An error occurred while fetching for an offchain result.", {
|
84
|
+
cause: a,
|
85
|
+
metaMessages: [
|
86
|
+
...a.metaMessages || [],
|
87
|
+
a.metaMessages?.length ? "" : [],
|
88
|
+
"Offchain Gateway Call:",
|
89
|
+
n && [
|
90
|
+
" Gateway URL(s):",
|
91
|
+
...n.map((c) => ` ${x(c)}`)
|
92
|
+
],
|
93
|
+
` Sender: ${o}`,
|
94
|
+
` Data: ${r}`,
|
95
|
+
` Callback selector: ${s}`,
|
96
|
+
` Extra data: ${e}`
|
97
|
+
].flat(),
|
98
|
+
name: "OffchainLookupError"
|
99
|
+
});
|
100
|
+
}
|
101
|
+
}
|
102
|
+
class K extends y {
|
103
|
+
constructor({ result: s, url: a }) {
|
104
|
+
super("Offchain gateway response is malformed. Response data must be a hex value.", {
|
105
|
+
metaMessages: [
|
106
|
+
`Gateway URL: ${x(a)}`,
|
107
|
+
`Response: ${M(s)}`
|
108
|
+
],
|
109
|
+
name: "OffchainLookupResponseMalformedError"
|
110
|
+
});
|
111
|
+
}
|
112
|
+
}
|
113
|
+
class Q extends y {
|
114
|
+
constructor({ sender: s, to: a }) {
|
115
|
+
super("Reverted sender address does not match target contract address (`to`).", {
|
116
|
+
metaMessages: [
|
117
|
+
`Contract address: ${a}`,
|
118
|
+
`OffchainLookup sender address: ${s}`
|
119
|
+
],
|
120
|
+
name: "OffchainLookupSenderMismatchError"
|
121
|
+
});
|
122
|
+
}
|
123
|
+
}
|
124
|
+
const Z = "0x556f1830", V = {
|
125
|
+
name: "OffchainLookup",
|
126
|
+
type: "error",
|
127
|
+
inputs: [
|
128
|
+
{
|
129
|
+
name: "sender",
|
130
|
+
type: "address"
|
131
|
+
},
|
132
|
+
{
|
133
|
+
name: "urls",
|
134
|
+
type: "string[]"
|
135
|
+
},
|
136
|
+
{
|
137
|
+
name: "callData",
|
138
|
+
type: "bytes"
|
139
|
+
},
|
140
|
+
{
|
141
|
+
name: "callbackFunction",
|
142
|
+
type: "bytes4"
|
143
|
+
},
|
144
|
+
{
|
145
|
+
name: "extraData",
|
146
|
+
type: "bytes"
|
147
|
+
}
|
148
|
+
]
|
149
|
+
};
|
150
|
+
async function z(t, { blockNumber: s, blockTag: a, data: r, to: e }) {
|
151
|
+
const { args: o } = D({
|
152
|
+
data: r,
|
153
|
+
abi: [V]
|
154
|
+
}), [n, c, d, i, u] = o, { ccipRead: f } = t, g = f && typeof f?.request == "function" ? f.request : X;
|
155
|
+
try {
|
156
|
+
if (!W(e, n))
|
157
|
+
throw new Q({ sender: n, to: e });
|
158
|
+
const l = c.includes(B) ? await j({
|
159
|
+
data: d,
|
160
|
+
ccipRequest: g
|
161
|
+
}) : await g({ data: d, sender: n, urls: c }), { data: q } = await T(t, {
|
162
|
+
blockNumber: s,
|
163
|
+
blockTag: a,
|
164
|
+
data: H([
|
165
|
+
i,
|
166
|
+
w([{ type: "bytes" }, { type: "bytes" }], [l, u])
|
167
|
+
]),
|
168
|
+
to: e
|
169
|
+
});
|
170
|
+
return q;
|
171
|
+
} catch (l) {
|
172
|
+
throw new _({
|
173
|
+
callbackSelector: i,
|
174
|
+
cause: l,
|
175
|
+
data: r,
|
176
|
+
extraData: u,
|
177
|
+
sender: n,
|
178
|
+
urls: c
|
179
|
+
});
|
180
|
+
}
|
181
|
+
}
|
182
|
+
async function X({ data: t, sender: s, urls: a }) {
|
183
|
+
let r = new Error("An unknown error occurred.");
|
184
|
+
for (let e = 0; e < a.length; e++) {
|
185
|
+
const o = a[e], n = o.includes("{data}") ? "GET" : "POST", c = n === "POST" ? { data: t, sender: s } : void 0, d = n === "POST" ? { "Content-Type": "application/json" } : {};
|
186
|
+
try {
|
187
|
+
const i = await fetch(o.replace("{sender}", s.toLowerCase()).replace("{data}", t), {
|
188
|
+
body: JSON.stringify(c),
|
189
|
+
headers: d,
|
190
|
+
method: n
|
191
|
+
});
|
192
|
+
let u;
|
193
|
+
if (i.headers.get("Content-Type")?.startsWith("application/json") ? u = (await i.json()).data : u = await i.text(), !i.ok) {
|
194
|
+
r = new L({
|
195
|
+
body: c,
|
196
|
+
details: u?.error ? M(u.error) : i.statusText,
|
197
|
+
headers: i.headers,
|
198
|
+
status: i.status,
|
199
|
+
url: o
|
200
|
+
});
|
201
|
+
continue;
|
202
|
+
}
|
203
|
+
if (!v(u)) {
|
204
|
+
r = new K({
|
205
|
+
result: u,
|
206
|
+
url: o
|
207
|
+
});
|
208
|
+
continue;
|
209
|
+
}
|
210
|
+
return u;
|
211
|
+
} catch (i) {
|
212
|
+
r = new L({
|
213
|
+
body: c,
|
214
|
+
details: i.message,
|
215
|
+
url: o
|
216
|
+
});
|
217
|
+
}
|
218
|
+
}
|
219
|
+
throw r;
|
220
|
+
}
|
221
|
+
export {
|
222
|
+
X as ccipRequest,
|
223
|
+
z as offchainLookup,
|
224
|
+
V as offchainLookupAbiItem,
|
225
|
+
Z as offchainLookupSignature
|
226
|
+
};
|