@deloraprotocol/widget 1.0.0 → 1.0.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/README.md +90 -28
- package/dist/index.d.ts +84 -3
- package/dist/index.js +1278 -1036
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +11 -11
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
throw TypeError(
|
|
1
|
+
var kt = Object.defineProperty;
|
|
2
|
+
var Ye = (e) => {
|
|
3
|
+
throw TypeError(e);
|
|
4
4
|
};
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
import { jsxs as
|
|
9
|
-
import { useState as
|
|
10
|
-
const
|
|
5
|
+
var bt = (e, t, n) => t in e ? kt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
6
|
+
var Fe = (e, t, n) => bt(e, typeof t != "symbol" ? t + "" : t, n), Re = (e, t, n) => t.has(e) || Ye("Cannot " + n);
|
|
7
|
+
var x = (e, t, n) => (Re(e, t, "read from private field"), n ? n.call(e) : t.get(e)), Ne = (e, t, n) => t.has(e) ? Ye("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, n), Te = (e, t, n, r) => (Re(e, t, "write to private field"), r ? r.call(e, n) : t.set(e, n), n), j = (e, t, n) => (Re(e, t, "access private method"), n);
|
|
8
|
+
import { jsxs as A, jsx as d, Fragment as xt } from "react/jsx-runtime";
|
|
9
|
+
import { useState as B, useRef as X, useMemo as ue, useEffect as re, useCallback as M, useLayoutEffect as yt } from "react";
|
|
10
|
+
const At = {
|
|
11
11
|
bg: "#ffffff",
|
|
12
12
|
fg: "#111216",
|
|
13
13
|
accent: "#7ca7f5",
|
|
@@ -27,7 +27,7 @@ const pt = {
|
|
|
27
27
|
fontSize: "13px",
|
|
28
28
|
lineHeight: "1.2",
|
|
29
29
|
letterSpacing: "-0.05em"
|
|
30
|
-
},
|
|
30
|
+
}, vt = {
|
|
31
31
|
bg: "#090909",
|
|
32
32
|
fg: "#ffffff",
|
|
33
33
|
accent: "#7ca7f5",
|
|
@@ -47,14 +47,14 @@ const pt = {
|
|
|
47
47
|
fontSize: "13px",
|
|
48
48
|
lineHeight: "1.2",
|
|
49
49
|
letterSpacing: "-0.05em"
|
|
50
|
-
},
|
|
51
|
-
light:
|
|
52
|
-
dark:
|
|
50
|
+
}, Nt = {
|
|
51
|
+
light: At,
|
|
52
|
+
dark: vt
|
|
53
53
|
};
|
|
54
|
-
function
|
|
55
|
-
return { ...
|
|
54
|
+
function dt(e, t) {
|
|
55
|
+
return { ...Nt[e], ...t };
|
|
56
56
|
}
|
|
57
|
-
const
|
|
57
|
+
const St = {
|
|
58
58
|
bg: "--dw-bg",
|
|
59
59
|
fg: "--dw-fg",
|
|
60
60
|
accent: "--dw-accent",
|
|
@@ -75,32 +75,32 @@ const bt = {
|
|
|
75
75
|
lineHeight: "--dw-line-height",
|
|
76
76
|
letterSpacing: "--dw-letter-spacing"
|
|
77
77
|
};
|
|
78
|
-
function
|
|
79
|
-
const
|
|
80
|
-
for (const [n, r] of Object.entries(
|
|
81
|
-
const s =
|
|
82
|
-
s && r != null && (
|
|
78
|
+
function lt(e) {
|
|
79
|
+
const t = {};
|
|
80
|
+
for (const [n, r] of Object.entries(e)) {
|
|
81
|
+
const s = St[n];
|
|
82
|
+
s && r != null && (t[s] = r);
|
|
83
83
|
}
|
|
84
|
-
return
|
|
84
|
+
return t;
|
|
85
85
|
}
|
|
86
|
-
function
|
|
86
|
+
function An(e) {
|
|
87
87
|
const {
|
|
88
|
-
theme:
|
|
88
|
+
theme: t = "light",
|
|
89
89
|
vars: n,
|
|
90
90
|
className: r,
|
|
91
91
|
style: s,
|
|
92
|
-
...
|
|
93
|
-
} =
|
|
94
|
-
...
|
|
92
|
+
...l
|
|
93
|
+
} = e, i = dt(t, n), p = {
|
|
94
|
+
...lt(i),
|
|
95
95
|
...s
|
|
96
96
|
};
|
|
97
|
-
return /* @__PURE__ */
|
|
97
|
+
return /* @__PURE__ */ A(
|
|
98
98
|
"div",
|
|
99
99
|
{
|
|
100
100
|
"data-delora-widget-root": !0,
|
|
101
101
|
className: `dw-flex dw-flex-col dw-gap-3 dw-rounded-[var(--dw-radius)] dw-border dw-border-[var(--dw-border)] dw-bg-[var(--dw-bg)] dw-p-4 dw-shadow-sm ${r ?? ""}`,
|
|
102
|
-
style:
|
|
103
|
-
...
|
|
102
|
+
style: p,
|
|
103
|
+
...l,
|
|
104
104
|
children: [
|
|
105
105
|
/* @__PURE__ */ d("h3", { className: "dw-text-base dw-font-semibold dw-text-[var(--dw-fg)]", children: "Delora" }),
|
|
106
106
|
/* @__PURE__ */ d("p", { className: "dw-text-sm dw-text-[var(--dw-muted)]", children: "A simple widget with theme support." }),
|
|
@@ -116,513 +116,633 @@ function hn(t) {
|
|
|
116
116
|
}
|
|
117
117
|
);
|
|
118
118
|
}
|
|
119
|
-
|
|
119
|
+
const Be = "https://api.delora.build", at = "0x1111111111111111111111111111111111111111", it = "11111111111111111111111111111111", ct = "1111111111111111111111111111111111111111111111111111111111111111";
|
|
120
|
+
function wt(e) {
|
|
121
|
+
return (e || Be).replace(/\/$/, "");
|
|
122
|
+
}
|
|
123
|
+
function Ct(e, t, n) {
|
|
124
|
+
if (!e) return;
|
|
125
|
+
const r = e.replace(/\/+$/, "");
|
|
126
|
+
return r.includes("/token/") || r.includes("/coin/") ? `${r}/` : t === "MVM" || n === "sui" ? `${r}/coin/` : `${r}/token/`;
|
|
127
|
+
}
|
|
128
|
+
function It(e) {
|
|
129
|
+
var t, n, r;
|
|
130
|
+
return {
|
|
131
|
+
id: e.id,
|
|
132
|
+
name: e.name,
|
|
133
|
+
rpcUrls: e.rpcUrls ?? [],
|
|
134
|
+
logoURI: e.logoURI,
|
|
135
|
+
idHex: e.idHex,
|
|
136
|
+
chainType: e.chainType,
|
|
137
|
+
explorerUrl: Ct(
|
|
138
|
+
e.blockExplorerUrls,
|
|
139
|
+
e.chainType,
|
|
140
|
+
e.key
|
|
141
|
+
),
|
|
142
|
+
key: e.key,
|
|
143
|
+
nativeCurrency: {
|
|
144
|
+
name: ((t = e.nativeToken) == null ? void 0 : t.name) ?? e.name,
|
|
145
|
+
symbol: ((n = e.nativeToken) == null ? void 0 : n.symbol) ?? "",
|
|
146
|
+
decimals: ((r = e.nativeToken) == null ? void 0 : r.decimals) ?? 18
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
function Tt(e) {
|
|
120
151
|
return {
|
|
121
|
-
symbol:
|
|
122
|
-
name:
|
|
123
|
-
contractAddress:
|
|
124
|
-
chainId:
|
|
125
|
-
imageUrl:
|
|
126
|
-
decimals:
|
|
127
|
-
priceUSD:
|
|
152
|
+
symbol: e.symbol,
|
|
153
|
+
name: e.name,
|
|
154
|
+
contractAddress: e.address,
|
|
155
|
+
chainId: e.chainId,
|
|
156
|
+
imageUrl: e.logoURI ?? "",
|
|
157
|
+
decimals: e.decimals,
|
|
158
|
+
priceUSD: e.priceUSD
|
|
128
159
|
};
|
|
129
160
|
}
|
|
130
|
-
async function
|
|
131
|
-
const
|
|
161
|
+
async function Bt(e) {
|
|
162
|
+
const t = wt(e), n = await fetch(`${t}/v1/chains`);
|
|
132
163
|
if (!n.ok) throw new Error(`Failed to fetch networks: ${n.status}`);
|
|
133
|
-
return n.json();
|
|
164
|
+
return ((await n.json()).chains ?? []).map(It);
|
|
134
165
|
}
|
|
135
|
-
async function
|
|
136
|
-
const
|
|
166
|
+
async function Ut(e) {
|
|
167
|
+
const t = wt(e), n = await fetch(`${t}/v1/tokens`);
|
|
137
168
|
if (!n.ok) throw new Error(`Failed to fetch tokens: ${n.status}`);
|
|
138
|
-
return n.json();
|
|
169
|
+
return { byChainId: await n.json() };
|
|
139
170
|
}
|
|
140
|
-
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
return n.json();
|
|
171
|
+
function ke(e, t) {
|
|
172
|
+
const n = String(t);
|
|
173
|
+
return (e.byChainId[n] ?? []).map(Tt);
|
|
144
174
|
}
|
|
145
|
-
function
|
|
146
|
-
|
|
147
|
-
const n = String(e), r = ((w = t.tokensEVM) == null ? void 0 : w[n]) ?? [], s = ((h = t.tokensSVM) == null ? void 0 : h[n]) ?? [], a = ((p = t.tokensMVM) == null ? void 0 : p[n]) ?? [];
|
|
148
|
-
return (r.length ? r : s.length ? s : a.length ? a : []).map(xt);
|
|
175
|
+
function Ft(e, t) {
|
|
176
|
+
return ke(e, t);
|
|
149
177
|
}
|
|
150
|
-
function
|
|
151
|
-
|
|
178
|
+
function Rt(e) {
|
|
179
|
+
const t = "0x0000000000000000000000000000000000000000", n = "11111111111111111111111111111111", r = "1111111111111111111111111111111111111111111111111111111111111111";
|
|
180
|
+
return e.find(
|
|
181
|
+
(s) => s.contractAddress === t || s.contractAddress === n || s.contractAddress === r
|
|
182
|
+
) ?? e[0];
|
|
152
183
|
}
|
|
153
|
-
function
|
|
154
|
-
|
|
155
|
-
return t.find(
|
|
156
|
-
(s) => s.contractAddress === e || s.contractAddress === n || s.contractAddress === r
|
|
157
|
-
) ?? t[0];
|
|
184
|
+
function Je(e) {
|
|
185
|
+
return e.startsWith("0x");
|
|
158
186
|
}
|
|
159
|
-
function
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
187
|
+
function Et(e, t) {
|
|
188
|
+
return Je(e) || Je(t) ? e.toLowerCase() === t.toLowerCase() : e === t;
|
|
189
|
+
}
|
|
190
|
+
function Ge(e, t) {
|
|
191
|
+
if (t)
|
|
192
|
+
return e.find(
|
|
193
|
+
(n) => n.chainId === t.chainId && Et(n.contractAddress, t.address)
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
function Lt(e) {
|
|
197
|
+
const [t, n] = B([]), [r, s] = B(null), [l, i] = B(
|
|
198
|
+
null
|
|
199
|
+
), [u, p] = B(!0), [g, C] = B(null), [I, k] = B(), [m, y] = B(), [v, $] = B(), [D, T] = B(), O = X(""), K = X(""), q = X(""), L = X(""), c = X(/* @__PURE__ */ new Set()), h = !!(e.lockSellNetwork || e.lockSellToken), b = !!(e.lockBuyNetwork || e.lockBuyToken), N = ue(
|
|
200
|
+
() => {
|
|
201
|
+
var w;
|
|
202
|
+
return e.initialSellNetworkId ?? ((w = e.initialSellToken) == null ? void 0 : w.chainId);
|
|
203
|
+
},
|
|
204
|
+
[e.initialSellNetworkId, e.initialSellToken]
|
|
205
|
+
), o = ue(
|
|
206
|
+
() => {
|
|
207
|
+
var w;
|
|
208
|
+
return e.initialBuyNetworkId ?? ((w = e.initialBuyToken) == null ? void 0 : w.chainId);
|
|
209
|
+
},
|
|
210
|
+
[e.initialBuyNetworkId, e.initialBuyToken]
|
|
211
|
+
);
|
|
212
|
+
re(() => {
|
|
213
|
+
let w = !1;
|
|
214
|
+
return p(!0), C(null), Promise.all([Bt(e.apiBase), Ut(e.apiBase)]).then(([a, S]) => {
|
|
215
|
+
w || (n(a), s(S), i(S), a.length >= 2 ? (k(a[0]), y(a[1])) : a.length === 1 && (k(a[0]), y(a[0])));
|
|
216
|
+
}).catch((a) => {
|
|
217
|
+
var W;
|
|
218
|
+
if (w) return;
|
|
219
|
+
const S = (a == null ? void 0 : a.message) ?? "Failed to load data";
|
|
220
|
+
C(S), (W = e.onError) == null || W.call(e, {
|
|
221
|
+
source: "metadata",
|
|
222
|
+
message: S,
|
|
223
|
+
status: a == null ? void 0 : a.status,
|
|
224
|
+
statusCode: a == null ? void 0 : a.statusCode,
|
|
225
|
+
error: a
|
|
226
|
+
});
|
|
171
227
|
}).finally(() => {
|
|
172
|
-
|
|
228
|
+
w || p(!1);
|
|
173
229
|
}), () => {
|
|
174
|
-
|
|
230
|
+
w = !0;
|
|
175
231
|
};
|
|
176
|
-
}, [
|
|
177
|
-
if (!
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
if (
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
232
|
+
}, [e.apiBase, e.onError]), re(() => {
|
|
233
|
+
if (!t.length || !N) return;
|
|
234
|
+
const w = String(N);
|
|
235
|
+
if (O.current === w) return;
|
|
236
|
+
const a = t.find((S) => S.id === N);
|
|
237
|
+
a && (k(a), O.current = w);
|
|
238
|
+
}, [N, t]), re(() => {
|
|
239
|
+
if (!t.length || !o) return;
|
|
240
|
+
const w = String(o);
|
|
241
|
+
if (K.current === w) return;
|
|
242
|
+
const a = t.find((S) => S.id === o);
|
|
243
|
+
a && (y(a), K.current = w);
|
|
244
|
+
}, [o, t]), re(() => {
|
|
245
|
+
var W;
|
|
246
|
+
if (!I || !r) return;
|
|
247
|
+
const w = ke(r, I.id), a = e.initialSellToken ? `${e.initialSellToken.chainId}:${e.initialSellToken.address}` : "", S = Ge(w, e.initialSellToken);
|
|
248
|
+
if (S && q.current !== a) {
|
|
249
|
+
$(S), q.current = a;
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
e.initialSellToken && !S && !c.current.has(`sell:${a}`) && (c.current.add(`sell:${a}`), (W = e.onError) == null || W.call(e, {
|
|
253
|
+
source: "selection",
|
|
254
|
+
message: `Initial sell token ${e.initialSellToken.address} was not found on chain ${e.initialSellToken.chainId}`
|
|
255
|
+
})), (w.length && !v || v && !w.some(
|
|
256
|
+
(Q) => Q.contractAddress === v.contractAddress && Q.chainId === v.chainId
|
|
257
|
+
)) && $(w[0]);
|
|
258
|
+
}, [e.initialSellToken, e.onError, I, v, r]), re(() => {
|
|
259
|
+
var W;
|
|
260
|
+
if (!m || !r) return;
|
|
261
|
+
const w = ke(r, m.id), a = e.initialBuyToken ? `${e.initialBuyToken.chainId}:${e.initialBuyToken.address}` : "", S = Ge(w, e.initialBuyToken);
|
|
262
|
+
if (S && L.current !== a) {
|
|
263
|
+
T(S), L.current = a;
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
if (e.initialBuyToken && !S && !c.current.has(`buy:${a}`) && (c.current.add(`buy:${a}`), (W = e.onError) == null || W.call(e, {
|
|
267
|
+
source: "selection",
|
|
268
|
+
message: `Initial buy token ${e.initialBuyToken.address} was not found on chain ${e.initialBuyToken.chainId}`
|
|
269
|
+
})), w.length && !D) {
|
|
270
|
+
const Q = v ? w.find(
|
|
271
|
+
(z) => !(z.contractAddress === v.contractAddress && z.chainId === v.chainId)
|
|
272
|
+
) : void 0;
|
|
273
|
+
T(Q ?? w[0]);
|
|
274
|
+
} else if (D && !w.some(
|
|
275
|
+
(Q) => Q.contractAddress === D.contractAddress && Q.chainId === D.chainId
|
|
276
|
+
)) {
|
|
277
|
+
const Q = v ? w.find(
|
|
278
|
+
(z) => !(z.contractAddress === v.contractAddress && z.chainId === v.chainId)
|
|
279
|
+
) : void 0;
|
|
280
|
+
T(Q ?? w[0]);
|
|
189
281
|
}
|
|
190
|
-
}, [
|
|
191
|
-
const
|
|
192
|
-
(
|
|
282
|
+
}, [D, e.initialBuyToken, e.onError, m, v, r]);
|
|
283
|
+
const E = M(
|
|
284
|
+
(w) => r ? ke(r, w) : [],
|
|
193
285
|
[r]
|
|
194
|
-
),
|
|
195
|
-
(
|
|
196
|
-
[
|
|
197
|
-
),
|
|
198
|
-
(
|
|
199
|
-
const
|
|
200
|
-
return
|
|
286
|
+
), V = M(
|
|
287
|
+
(w) => l ? Ft(l, w) : ke(r ?? { byChainId: {} }, w),
|
|
288
|
+
[l, r]
|
|
289
|
+
), J = M(
|
|
290
|
+
(w) => {
|
|
291
|
+
const a = ke(r ?? { byChainId: {} }, w);
|
|
292
|
+
return Rt(a);
|
|
201
293
|
},
|
|
202
294
|
[r]
|
|
203
|
-
),
|
|
204
|
-
(
|
|
205
|
-
[
|
|
206
|
-
),
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
295
|
+
), G = M(
|
|
296
|
+
(w) => t.find((a) => a.id === w),
|
|
297
|
+
[t]
|
|
298
|
+
), ie = M(
|
|
299
|
+
(w) => {
|
|
300
|
+
if (h) return;
|
|
301
|
+
const a = t.find((S) => S.id === w);
|
|
302
|
+
a && k(a);
|
|
303
|
+
},
|
|
304
|
+
[t, h]
|
|
305
|
+
), fe = M(
|
|
306
|
+
(w) => {
|
|
307
|
+
if (b) return;
|
|
308
|
+
const a = t.find((S) => S.id === w);
|
|
309
|
+
a && y(a);
|
|
310
|
+
},
|
|
311
|
+
[b, t]
|
|
312
|
+
), ee = M(
|
|
313
|
+
(w) => {
|
|
314
|
+
h || k(w);
|
|
315
|
+
},
|
|
316
|
+
[h]
|
|
317
|
+
), ce = M(
|
|
318
|
+
(w) => {
|
|
319
|
+
b || y(w);
|
|
320
|
+
},
|
|
321
|
+
[b]
|
|
322
|
+
), de = M(
|
|
323
|
+
(w) => {
|
|
324
|
+
e.lockSellToken || $(w);
|
|
325
|
+
},
|
|
326
|
+
[e.lockSellToken]
|
|
327
|
+
), oe = M(
|
|
328
|
+
(w) => {
|
|
329
|
+
e.lockBuyToken || T(w);
|
|
330
|
+
},
|
|
331
|
+
[e.lockBuyToken]
|
|
332
|
+
);
|
|
215
333
|
return {
|
|
216
|
-
networks:
|
|
217
|
-
networkSell:
|
|
218
|
-
networkBuy:
|
|
219
|
-
sellToken:
|
|
220
|
-
buyToken:
|
|
221
|
-
setSellToken:
|
|
222
|
-
setBuyToken:
|
|
223
|
-
setNetworkSell:
|
|
224
|
-
setNetworkBuy:
|
|
225
|
-
updateNetworkSell:
|
|
226
|
-
updateNetworkBuy:
|
|
227
|
-
getTokensForNetworkId:
|
|
228
|
-
getAllTokensForNetworkId:
|
|
229
|
-
getNativeToken:
|
|
230
|
-
getNetworkById:
|
|
231
|
-
|
|
232
|
-
|
|
334
|
+
networks: t,
|
|
335
|
+
networkSell: I,
|
|
336
|
+
networkBuy: m,
|
|
337
|
+
sellToken: v,
|
|
338
|
+
buyToken: D,
|
|
339
|
+
setSellToken: de,
|
|
340
|
+
setBuyToken: oe,
|
|
341
|
+
setNetworkSell: ee,
|
|
342
|
+
setNetworkBuy: ce,
|
|
343
|
+
updateNetworkSell: ie,
|
|
344
|
+
updateNetworkBuy: fe,
|
|
345
|
+
getTokensForNetworkId: E,
|
|
346
|
+
getAllTokensForNetworkId: V,
|
|
347
|
+
getNativeToken: J,
|
|
348
|
+
getNetworkById: G,
|
|
349
|
+
sellNetworkLocked: h,
|
|
350
|
+
buyNetworkLocked: b,
|
|
351
|
+
loading: u,
|
|
352
|
+
error: g
|
|
233
353
|
};
|
|
234
354
|
}
|
|
235
|
-
const
|
|
236
|
-
function
|
|
237
|
-
for (let r in
|
|
238
|
-
let s =
|
|
239
|
-
Object.defineProperty(
|
|
355
|
+
const Mt = "6.16.0";
|
|
356
|
+
function Pe(e, t, n) {
|
|
357
|
+
for (let r in t) {
|
|
358
|
+
let s = t[r];
|
|
359
|
+
Object.defineProperty(e, r, { enumerable: !0, value: s, writable: !1 });
|
|
240
360
|
}
|
|
241
361
|
}
|
|
242
|
-
function
|
|
243
|
-
if (
|
|
362
|
+
function be(e, t) {
|
|
363
|
+
if (e == null)
|
|
244
364
|
return "null";
|
|
245
|
-
if (
|
|
246
|
-
if (
|
|
365
|
+
if (t == null && (t = /* @__PURE__ */ new Set()), typeof e == "object") {
|
|
366
|
+
if (t.has(e))
|
|
247
367
|
return "[Circular]";
|
|
248
|
-
|
|
368
|
+
t.add(e);
|
|
249
369
|
}
|
|
250
|
-
if (Array.isArray(
|
|
251
|
-
return "[ " +
|
|
252
|
-
if (
|
|
370
|
+
if (Array.isArray(e))
|
|
371
|
+
return "[ " + e.map((n) => be(n, t)).join(", ") + " ]";
|
|
372
|
+
if (e instanceof Uint8Array) {
|
|
253
373
|
const n = "0123456789abcdef";
|
|
254
374
|
let r = "0x";
|
|
255
|
-
for (let s = 0; s <
|
|
256
|
-
r += n[
|
|
375
|
+
for (let s = 0; s < e.length; s++)
|
|
376
|
+
r += n[e[s] >> 4], r += n[e[s] & 15];
|
|
257
377
|
return r;
|
|
258
378
|
}
|
|
259
|
-
if (typeof
|
|
260
|
-
return
|
|
261
|
-
switch (typeof
|
|
379
|
+
if (typeof e == "object" && typeof e.toJSON == "function")
|
|
380
|
+
return be(e.toJSON(), t);
|
|
381
|
+
switch (typeof e) {
|
|
262
382
|
case "boolean":
|
|
263
383
|
case "number":
|
|
264
384
|
case "symbol":
|
|
265
|
-
return
|
|
385
|
+
return e.toString();
|
|
266
386
|
case "bigint":
|
|
267
|
-
return BigInt(
|
|
387
|
+
return BigInt(e).toString();
|
|
268
388
|
case "string":
|
|
269
|
-
return JSON.stringify(
|
|
389
|
+
return JSON.stringify(e);
|
|
270
390
|
case "object": {
|
|
271
|
-
const n = Object.keys(
|
|
272
|
-
return n.sort(), "{ " + n.map((r) => `${
|
|
391
|
+
const n = Object.keys(e);
|
|
392
|
+
return n.sort(), "{ " + n.map((r) => `${be(r, t)}: ${be(e[r], t)}`).join(", ") + " }";
|
|
273
393
|
}
|
|
274
394
|
}
|
|
275
395
|
return "[ COULD NOT SERIALIZE ]";
|
|
276
396
|
}
|
|
277
|
-
function
|
|
278
|
-
let r =
|
|
397
|
+
function $t(e, t, n) {
|
|
398
|
+
let r = e;
|
|
279
399
|
{
|
|
280
|
-
const
|
|
400
|
+
const l = [];
|
|
281
401
|
if (n) {
|
|
282
402
|
if ("message" in n || "code" in n || "name" in n)
|
|
283
|
-
throw new Error(`value will overwrite populated values: ${
|
|
403
|
+
throw new Error(`value will overwrite populated values: ${be(n)}`);
|
|
284
404
|
for (const i in n) {
|
|
285
405
|
if (i === "shortMessage")
|
|
286
406
|
continue;
|
|
287
|
-
const
|
|
288
|
-
|
|
407
|
+
const u = n[i];
|
|
408
|
+
l.push(i + "=" + be(u));
|
|
289
409
|
}
|
|
290
410
|
}
|
|
291
|
-
|
|
411
|
+
l.push(`code=${t}`), l.push(`version=${Mt}`), l.length && (e += " (" + l.join(", ") + ")");
|
|
292
412
|
}
|
|
293
413
|
let s;
|
|
294
|
-
switch (
|
|
414
|
+
switch (t) {
|
|
295
415
|
case "INVALID_ARGUMENT":
|
|
296
|
-
s = new TypeError(
|
|
416
|
+
s = new TypeError(e);
|
|
297
417
|
break;
|
|
298
418
|
case "NUMERIC_FAULT":
|
|
299
419
|
case "BUFFER_OVERRUN":
|
|
300
|
-
s = new RangeError(
|
|
420
|
+
s = new RangeError(e);
|
|
301
421
|
break;
|
|
302
422
|
default:
|
|
303
|
-
s = new Error(
|
|
423
|
+
s = new Error(e);
|
|
304
424
|
}
|
|
305
|
-
return
|
|
425
|
+
return Pe(s, { code: t }), n && Object.assign(s, n), s.shortMessage == null && Pe(s, { shortMessage: r }), s;
|
|
306
426
|
}
|
|
307
|
-
function
|
|
308
|
-
if (!
|
|
309
|
-
throw
|
|
427
|
+
function Z(e, t, n, r) {
|
|
428
|
+
if (!e)
|
|
429
|
+
throw $t(t, n, r);
|
|
310
430
|
}
|
|
311
|
-
function
|
|
312
|
-
|
|
431
|
+
function H(e, t, n, r) {
|
|
432
|
+
Z(e, t, "INVALID_ARGUMENT", { argument: n, value: r });
|
|
313
433
|
}
|
|
314
|
-
["NFD", "NFC", "NFKD", "NFKC"].reduce((
|
|
434
|
+
["NFD", "NFC", "NFKD", "NFKC"].reduce((e, t) => {
|
|
315
435
|
try {
|
|
316
|
-
if ("test".normalize(
|
|
436
|
+
if ("test".normalize(t) !== "test")
|
|
317
437
|
throw new Error("bad");
|
|
318
|
-
if (
|
|
438
|
+
if (t === "NFD" && "é".normalize("NFD") !== "é")
|
|
319
439
|
throw new Error("broken");
|
|
320
|
-
|
|
440
|
+
e.push(t);
|
|
321
441
|
} catch {
|
|
322
442
|
}
|
|
323
|
-
return
|
|
443
|
+
return e;
|
|
324
444
|
}, []);
|
|
325
|
-
function
|
|
326
|
-
if (
|
|
445
|
+
function Dt(e, t, n) {
|
|
446
|
+
if (e !== t) {
|
|
327
447
|
let r = n, s = "new";
|
|
328
|
-
r += ".", s += " " + n,
|
|
448
|
+
r += ".", s += " " + n, Z(!1, `private constructor; use ${r}from* methods`, "UNSUPPORTED_OPERATION", {
|
|
329
449
|
operation: s
|
|
330
450
|
});
|
|
331
451
|
}
|
|
332
452
|
}
|
|
333
|
-
function
|
|
334
|
-
if (
|
|
335
|
-
return
|
|
336
|
-
if (typeof
|
|
337
|
-
const r = new Uint8Array((
|
|
453
|
+
function Ot(e, t, n) {
|
|
454
|
+
if (e instanceof Uint8Array)
|
|
455
|
+
return e;
|
|
456
|
+
if (typeof e == "string" && e.length % 2 === 0 && e.match(/^0x[0-9a-f]*$/i)) {
|
|
457
|
+
const r = new Uint8Array((e.length - 2) / 2);
|
|
338
458
|
let s = 2;
|
|
339
|
-
for (let
|
|
340
|
-
r[
|
|
459
|
+
for (let l = 0; l < r.length; l++)
|
|
460
|
+
r[l] = parseInt(e.substring(s, s + 2), 16), s += 2;
|
|
341
461
|
return r;
|
|
342
462
|
}
|
|
343
|
-
|
|
463
|
+
H(!1, "invalid BytesLike value", t, e);
|
|
344
464
|
}
|
|
345
|
-
function
|
|
346
|
-
return
|
|
465
|
+
function Pt(e, t) {
|
|
466
|
+
return Ot(e, t);
|
|
347
467
|
}
|
|
348
|
-
const
|
|
349
|
-
function
|
|
350
|
-
const n =
|
|
351
|
-
if (
|
|
468
|
+
const ut = BigInt(0), xe = BigInt(1), ye = 9007199254740991;
|
|
469
|
+
function je(e, t) {
|
|
470
|
+
const n = ft(e, "value"), r = BigInt(Ie(t, "width"));
|
|
471
|
+
if (Z(n >> r === ut, "overflow", "NUMERIC_FAULT", {
|
|
352
472
|
operation: "fromTwos",
|
|
353
473
|
fault: "overflow",
|
|
354
|
-
value:
|
|
355
|
-
}), n >> r -
|
|
356
|
-
const s = (
|
|
357
|
-
return -((~n & s) +
|
|
474
|
+
value: e
|
|
475
|
+
}), n >> r - xe) {
|
|
476
|
+
const s = (xe << r) - xe;
|
|
477
|
+
return -((~n & s) + xe);
|
|
358
478
|
}
|
|
359
479
|
return n;
|
|
360
480
|
}
|
|
361
|
-
function
|
|
362
|
-
const n =
|
|
363
|
-
return n & (
|
|
481
|
+
function _e(e, t) {
|
|
482
|
+
const n = ft(e, "value"), r = BigInt(Ie(t, "bits"));
|
|
483
|
+
return n & (xe << r) - xe;
|
|
364
484
|
}
|
|
365
|
-
function
|
|
366
|
-
switch (typeof
|
|
485
|
+
function Ke(e, t) {
|
|
486
|
+
switch (typeof e) {
|
|
367
487
|
case "bigint":
|
|
368
|
-
return
|
|
488
|
+
return e;
|
|
369
489
|
case "number":
|
|
370
|
-
return
|
|
490
|
+
return H(Number.isInteger(e), "underflow", t || "value", e), H(e >= -ye && e <= ye, "overflow", t || "value", e), BigInt(e);
|
|
371
491
|
case "string":
|
|
372
492
|
try {
|
|
373
|
-
if (
|
|
493
|
+
if (e === "")
|
|
374
494
|
throw new Error("empty string");
|
|
375
|
-
return
|
|
495
|
+
return e[0] === "-" && e[1] !== "-" ? -BigInt(e.substring(1)) : BigInt(e);
|
|
376
496
|
} catch (n) {
|
|
377
|
-
|
|
497
|
+
H(!1, `invalid BigNumberish string: ${n.message}`, t || "value", e);
|
|
378
498
|
}
|
|
379
499
|
}
|
|
380
|
-
|
|
500
|
+
H(!1, "invalid BigNumberish value", t || "value", e);
|
|
381
501
|
}
|
|
382
|
-
function
|
|
383
|
-
const n =
|
|
384
|
-
return
|
|
502
|
+
function ft(e, t) {
|
|
503
|
+
const n = Ke(e, t);
|
|
504
|
+
return Z(n >= ut, "unsigned value cannot be negative", "NUMERIC_FAULT", {
|
|
385
505
|
fault: "overflow",
|
|
386
506
|
operation: "getUint",
|
|
387
|
-
value:
|
|
507
|
+
value: e
|
|
388
508
|
}), n;
|
|
389
509
|
}
|
|
390
|
-
const
|
|
391
|
-
function
|
|
392
|
-
if (
|
|
393
|
-
let
|
|
394
|
-
for (const n of
|
|
395
|
-
|
|
396
|
-
return BigInt(
|
|
510
|
+
const Xe = "0123456789abcdef";
|
|
511
|
+
function jt(e) {
|
|
512
|
+
if (e instanceof Uint8Array) {
|
|
513
|
+
let t = "0x0";
|
|
514
|
+
for (const n of e)
|
|
515
|
+
t += Xe[n >> 4], t += Xe[n & 15];
|
|
516
|
+
return BigInt(t);
|
|
397
517
|
}
|
|
398
|
-
return
|
|
518
|
+
return Ke(e);
|
|
399
519
|
}
|
|
400
|
-
function
|
|
401
|
-
switch (typeof
|
|
520
|
+
function Ie(e, t) {
|
|
521
|
+
switch (typeof e) {
|
|
402
522
|
case "bigint":
|
|
403
|
-
return
|
|
523
|
+
return H(e >= -ye && e <= ye, "overflow", t || "value", e), Number(e);
|
|
404
524
|
case "number":
|
|
405
|
-
return
|
|
525
|
+
return H(Number.isInteger(e), "underflow", t || "value", e), H(e >= -ye && e <= ye, "overflow", t || "value", e), e;
|
|
406
526
|
case "string":
|
|
407
527
|
try {
|
|
408
|
-
if (
|
|
528
|
+
if (e === "")
|
|
409
529
|
throw new Error("empty string");
|
|
410
|
-
return
|
|
530
|
+
return Ie(BigInt(e), t);
|
|
411
531
|
} catch (n) {
|
|
412
|
-
|
|
532
|
+
H(!1, `invalid numeric string: ${n.message}`, t || "value", e);
|
|
413
533
|
}
|
|
414
534
|
}
|
|
415
|
-
|
|
535
|
+
H(!1, "invalid numeric value", t || "value", e);
|
|
416
536
|
}
|
|
417
|
-
const
|
|
418
|
-
let
|
|
419
|
-
for (;
|
|
420
|
-
|
|
421
|
-
function
|
|
422
|
-
let
|
|
423
|
-
for (;
|
|
424
|
-
|
|
425
|
-
return BigInt("1" +
|
|
537
|
+
const Vt = BigInt(-1), te = BigInt(0), Ae = BigInt(1), Wt = BigInt(5), ge = {};
|
|
538
|
+
let ve = "0000";
|
|
539
|
+
for (; ve.length < 80; )
|
|
540
|
+
ve += ve;
|
|
541
|
+
function pe(e) {
|
|
542
|
+
let t = ve;
|
|
543
|
+
for (; t.length < e; )
|
|
544
|
+
t += t;
|
|
545
|
+
return BigInt("1" + t.substring(0, e));
|
|
426
546
|
}
|
|
427
|
-
function
|
|
428
|
-
const r = BigInt(
|
|
429
|
-
if (
|
|
430
|
-
const s =
|
|
431
|
-
|
|
547
|
+
function Se(e, t, n) {
|
|
548
|
+
const r = BigInt(t.width);
|
|
549
|
+
if (t.signed) {
|
|
550
|
+
const s = Ae << r - Ae;
|
|
551
|
+
Z(n == null || e >= -s && e < s, "overflow", "NUMERIC_FAULT", {
|
|
432
552
|
operation: n,
|
|
433
553
|
fault: "overflow",
|
|
434
|
-
value:
|
|
435
|
-
}),
|
|
554
|
+
value: e
|
|
555
|
+
}), e > te ? e = je(_e(e, r), r) : e = -je(_e(-e, r), r);
|
|
436
556
|
} else {
|
|
437
|
-
const s =
|
|
438
|
-
|
|
557
|
+
const s = Ae << r;
|
|
558
|
+
Z(n == null || e >= 0 && e < s, "overflow", "NUMERIC_FAULT", {
|
|
439
559
|
operation: n,
|
|
440
560
|
fault: "overflow",
|
|
441
|
-
value:
|
|
442
|
-
}),
|
|
561
|
+
value: e
|
|
562
|
+
}), e = (e % s + s) % s & s - Ae;
|
|
443
563
|
}
|
|
444
|
-
return
|
|
564
|
+
return e;
|
|
445
565
|
}
|
|
446
|
-
function
|
|
447
|
-
typeof
|
|
448
|
-
let
|
|
449
|
-
if (typeof
|
|
450
|
-
if (
|
|
451
|
-
|
|
566
|
+
function Ee(e) {
|
|
567
|
+
typeof e == "number" && (e = `fixed128x${e}`);
|
|
568
|
+
let t = !0, n = 128, r = 18;
|
|
569
|
+
if (typeof e == "string") {
|
|
570
|
+
if (e !== "fixed") if (e === "ufixed")
|
|
571
|
+
t = !1;
|
|
452
572
|
else {
|
|
453
|
-
const
|
|
454
|
-
|
|
573
|
+
const l = e.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);
|
|
574
|
+
H(l, "invalid fixed format", "format", e), t = l[1] !== "u", n = parseInt(l[2]), r = parseInt(l[3]);
|
|
455
575
|
}
|
|
456
|
-
} else if (
|
|
457
|
-
const
|
|
458
|
-
|
|
576
|
+
} else if (e) {
|
|
577
|
+
const l = e, i = (u, p, g) => l[u] == null ? g : (H(typeof l[u] === p, "invalid fixed format (" + u + " not " + p + ")", "format." + u, l[u]), l[u]);
|
|
578
|
+
t = i("signed", "boolean", t), n = i("width", "number", n), r = i("decimals", "number", r);
|
|
459
579
|
}
|
|
460
|
-
|
|
461
|
-
const s = (
|
|
462
|
-
return { signed:
|
|
580
|
+
H(n % 8 === 0, "invalid FixedNumber width (not byte aligned)", "format.width", n), H(r <= 80, "invalid FixedNumber decimals (too large)", "format.decimals", r);
|
|
581
|
+
const s = (t ? "" : "u") + "fixed" + String(n) + "x" + String(r);
|
|
582
|
+
return { signed: t, width: n, decimals: r, name: s };
|
|
463
583
|
}
|
|
464
|
-
function
|
|
584
|
+
function Qt(e, t) {
|
|
465
585
|
let n = "";
|
|
466
|
-
|
|
467
|
-
let r =
|
|
468
|
-
if (
|
|
586
|
+
e < te && (n = "-", e *= Vt);
|
|
587
|
+
let r = e.toString();
|
|
588
|
+
if (t === 0)
|
|
469
589
|
return n + r;
|
|
470
|
-
for (; r.length <=
|
|
471
|
-
r =
|
|
472
|
-
const s = r.length -
|
|
590
|
+
for (; r.length <= t; )
|
|
591
|
+
r = ve + r;
|
|
592
|
+
const s = r.length - t;
|
|
473
593
|
for (r = r.substring(0, s) + "." + r.substring(s); r[0] === "0" && r[1] !== "."; )
|
|
474
594
|
r = r.substring(1);
|
|
475
595
|
for (; r[r.length - 1] === "0" && r[r.length - 2] !== "."; )
|
|
476
596
|
r = r.substring(0, r.length - 1);
|
|
477
597
|
return n + r;
|
|
478
598
|
}
|
|
479
|
-
var
|
|
480
|
-
const
|
|
599
|
+
var ne, R, Y, U, he, ae, We, Qe, qe, He;
|
|
600
|
+
const we = class we {
|
|
481
601
|
// Use this when changing this file to get some typing info,
|
|
482
602
|
// but then switch to any to mask the internal type
|
|
483
603
|
//constructor(guard: any, value: bigint, format: _FixedFormat) {
|
|
484
604
|
/**
|
|
485
605
|
* @private
|
|
486
606
|
*/
|
|
487
|
-
constructor(
|
|
488
|
-
|
|
607
|
+
constructor(t, n, r) {
|
|
608
|
+
Ne(this, U);
|
|
489
609
|
/**
|
|
490
610
|
* The specific fixed-point arithmetic field for this value.
|
|
491
611
|
*/
|
|
492
|
-
|
|
493
|
-
|
|
612
|
+
Fe(this, "format");
|
|
613
|
+
Ne(this, ne);
|
|
494
614
|
// The actual value (accounting for decimals)
|
|
495
|
-
|
|
615
|
+
Ne(this, R);
|
|
496
616
|
// A base-10 value to multiple values by to maintain the magnitude
|
|
497
|
-
|
|
617
|
+
Ne(this, Y);
|
|
498
618
|
/**
|
|
499
619
|
* This is a property so console.log shows a human-meaningful value.
|
|
500
620
|
*
|
|
501
621
|
* @private
|
|
502
622
|
*/
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
const s =
|
|
506
|
-
|
|
623
|
+
Fe(this, "_value");
|
|
624
|
+
Dt(t, ge, "FixedNumber"), Te(this, R, n), Te(this, ne, r);
|
|
625
|
+
const s = Qt(n, r.decimals);
|
|
626
|
+
Pe(this, { format: r.name, _value: s }), Te(this, Y, pe(r.decimals));
|
|
507
627
|
}
|
|
508
628
|
/**
|
|
509
629
|
* If true, negative values are permitted, otherwise only
|
|
510
630
|
* positive values and zero are allowed.
|
|
511
631
|
*/
|
|
512
632
|
get signed() {
|
|
513
|
-
return
|
|
633
|
+
return x(this, ne).signed;
|
|
514
634
|
}
|
|
515
635
|
/**
|
|
516
636
|
* The number of bits available to store the value.
|
|
517
637
|
*/
|
|
518
638
|
get width() {
|
|
519
|
-
return
|
|
639
|
+
return x(this, ne).width;
|
|
520
640
|
}
|
|
521
641
|
/**
|
|
522
642
|
* The number of decimal places in the fixed-point arithment field.
|
|
523
643
|
*/
|
|
524
644
|
get decimals() {
|
|
525
|
-
return
|
|
645
|
+
return x(this, ne).decimals;
|
|
526
646
|
}
|
|
527
647
|
/**
|
|
528
648
|
* The value as an integer, based on the smallest unit the
|
|
529
649
|
* [[decimals]] allow.
|
|
530
650
|
*/
|
|
531
651
|
get value() {
|
|
532
|
-
return
|
|
652
|
+
return x(this, R);
|
|
533
653
|
}
|
|
534
654
|
/**
|
|
535
655
|
* Returns a new [[FixedNumber]] with the result of %%this%% added
|
|
536
656
|
* to %%other%%, ignoring overflow.
|
|
537
657
|
*/
|
|
538
|
-
addUnsafe(
|
|
539
|
-
return
|
|
658
|
+
addUnsafe(t) {
|
|
659
|
+
return j(this, U, We).call(this, t);
|
|
540
660
|
}
|
|
541
661
|
/**
|
|
542
662
|
* Returns a new [[FixedNumber]] with the result of %%this%% added
|
|
543
663
|
* to %%other%%. A [[NumericFaultError]] is thrown if overflow
|
|
544
664
|
* occurs.
|
|
545
665
|
*/
|
|
546
|
-
add(
|
|
547
|
-
return
|
|
666
|
+
add(t) {
|
|
667
|
+
return j(this, U, We).call(this, t, "add");
|
|
548
668
|
}
|
|
549
669
|
/**
|
|
550
670
|
* Returns a new [[FixedNumber]] with the result of %%other%% subtracted
|
|
551
671
|
* from %%this%%, ignoring overflow.
|
|
552
672
|
*/
|
|
553
|
-
subUnsafe(
|
|
554
|
-
return
|
|
673
|
+
subUnsafe(t) {
|
|
674
|
+
return j(this, U, Qe).call(this, t);
|
|
555
675
|
}
|
|
556
676
|
/**
|
|
557
677
|
* Returns a new [[FixedNumber]] with the result of %%other%% subtracted
|
|
558
678
|
* from %%this%%. A [[NumericFaultError]] is thrown if overflow
|
|
559
679
|
* occurs.
|
|
560
680
|
*/
|
|
561
|
-
sub(
|
|
562
|
-
return
|
|
681
|
+
sub(t) {
|
|
682
|
+
return j(this, U, Qe).call(this, t, "sub");
|
|
563
683
|
}
|
|
564
684
|
/**
|
|
565
685
|
* Returns a new [[FixedNumber]] with the result of %%this%% multiplied
|
|
566
686
|
* by %%other%%, ignoring overflow and underflow (precision loss).
|
|
567
687
|
*/
|
|
568
|
-
mulUnsafe(
|
|
569
|
-
return
|
|
688
|
+
mulUnsafe(t) {
|
|
689
|
+
return j(this, U, qe).call(this, t);
|
|
570
690
|
}
|
|
571
691
|
/**
|
|
572
692
|
* Returns a new [[FixedNumber]] with the result of %%this%% multiplied
|
|
573
693
|
* by %%other%%. A [[NumericFaultError]] is thrown if overflow
|
|
574
694
|
* occurs.
|
|
575
695
|
*/
|
|
576
|
-
mul(
|
|
577
|
-
return
|
|
696
|
+
mul(t) {
|
|
697
|
+
return j(this, U, qe).call(this, t, "mul");
|
|
578
698
|
}
|
|
579
699
|
/**
|
|
580
700
|
* Returns a new [[FixedNumber]] with the result of %%this%% multiplied
|
|
581
701
|
* by %%other%%. A [[NumericFaultError]] is thrown if overflow
|
|
582
702
|
* occurs or if underflow (precision loss) occurs.
|
|
583
703
|
*/
|
|
584
|
-
mulSignal(
|
|
585
|
-
|
|
586
|
-
const n =
|
|
587
|
-
return
|
|
704
|
+
mulSignal(t) {
|
|
705
|
+
j(this, U, he).call(this, t);
|
|
706
|
+
const n = x(this, R) * x(t, R);
|
|
707
|
+
return Z(n % x(this, Y) === te, "precision lost during signalling mul", "NUMERIC_FAULT", {
|
|
588
708
|
operation: "mulSignal",
|
|
589
709
|
fault: "underflow",
|
|
590
710
|
value: this
|
|
591
|
-
}),
|
|
711
|
+
}), j(this, U, ae).call(this, n / x(this, Y), "mulSignal");
|
|
592
712
|
}
|
|
593
713
|
/**
|
|
594
714
|
* Returns a new [[FixedNumber]] with the result of %%this%% divided
|
|
595
715
|
* by %%other%%, ignoring underflow (precision loss). A
|
|
596
716
|
* [[NumericFaultError]] is thrown if overflow occurs.
|
|
597
717
|
*/
|
|
598
|
-
divUnsafe(
|
|
599
|
-
return
|
|
718
|
+
divUnsafe(t) {
|
|
719
|
+
return j(this, U, He).call(this, t);
|
|
600
720
|
}
|
|
601
721
|
/**
|
|
602
722
|
* Returns a new [[FixedNumber]] with the result of %%this%% divided
|
|
603
723
|
* by %%other%%, ignoring underflow (precision loss). A
|
|
604
724
|
* [[NumericFaultError]] is thrown if overflow occurs.
|
|
605
725
|
*/
|
|
606
|
-
div(
|
|
607
|
-
return
|
|
726
|
+
div(t) {
|
|
727
|
+
return j(this, U, He).call(this, t, "div");
|
|
608
728
|
}
|
|
609
729
|
/**
|
|
610
730
|
* Returns a new [[FixedNumber]] with the result of %%this%% divided
|
|
611
731
|
* by %%other%%. A [[NumericFaultError]] is thrown if underflow
|
|
612
732
|
* (precision loss) occurs.
|
|
613
733
|
*/
|
|
614
|
-
divSignal(
|
|
615
|
-
|
|
734
|
+
divSignal(t) {
|
|
735
|
+
Z(x(t, R) !== te, "division by zero", "NUMERIC_FAULT", {
|
|
616
736
|
operation: "div",
|
|
617
737
|
fault: "divide-by-zero",
|
|
618
738
|
value: this
|
|
619
|
-
}),
|
|
620
|
-
const n =
|
|
621
|
-
return
|
|
739
|
+
}), j(this, U, he).call(this, t);
|
|
740
|
+
const n = x(this, R) * x(this, Y);
|
|
741
|
+
return Z(n % x(t, R) === te, "precision lost during signalling div", "NUMERIC_FAULT", {
|
|
622
742
|
operation: "divSignal",
|
|
623
743
|
fault: "underflow",
|
|
624
744
|
value: this
|
|
625
|
-
}),
|
|
745
|
+
}), j(this, U, ae).call(this, n / x(t, R), "divSignal");
|
|
626
746
|
}
|
|
627
747
|
/**
|
|
628
748
|
* Returns a comparison result between %%this%% and %%other%%.
|
|
@@ -631,40 +751,40 @@ const Z = class Z {
|
|
|
631
751
|
* is smaller, ``1`` implies %%this%% is larger and ``0`` implies
|
|
632
752
|
* both are equal.
|
|
633
753
|
*/
|
|
634
|
-
cmp(
|
|
635
|
-
let n = this.value, r =
|
|
636
|
-
const s = this.decimals -
|
|
637
|
-
return s > 0 ? r *=
|
|
754
|
+
cmp(t) {
|
|
755
|
+
let n = this.value, r = t.value;
|
|
756
|
+
const s = this.decimals - t.decimals;
|
|
757
|
+
return s > 0 ? r *= pe(s) : s < 0 && (n *= pe(-s)), n < r ? -1 : n > r ? 1 : 0;
|
|
638
758
|
}
|
|
639
759
|
/**
|
|
640
760
|
* Returns true if %%other%% is equal to %%this%%.
|
|
641
761
|
*/
|
|
642
|
-
eq(
|
|
643
|
-
return this.cmp(
|
|
762
|
+
eq(t) {
|
|
763
|
+
return this.cmp(t) === 0;
|
|
644
764
|
}
|
|
645
765
|
/**
|
|
646
766
|
* Returns true if %%other%% is less than to %%this%%.
|
|
647
767
|
*/
|
|
648
|
-
lt(
|
|
649
|
-
return this.cmp(
|
|
768
|
+
lt(t) {
|
|
769
|
+
return this.cmp(t) < 0;
|
|
650
770
|
}
|
|
651
771
|
/**
|
|
652
772
|
* Returns true if %%other%% is less than or equal to %%this%%.
|
|
653
773
|
*/
|
|
654
|
-
lte(
|
|
655
|
-
return this.cmp(
|
|
774
|
+
lte(t) {
|
|
775
|
+
return this.cmp(t) <= 0;
|
|
656
776
|
}
|
|
657
777
|
/**
|
|
658
778
|
* Returns true if %%other%% is greater than to %%this%%.
|
|
659
779
|
*/
|
|
660
|
-
gt(
|
|
661
|
-
return this.cmp(
|
|
780
|
+
gt(t) {
|
|
781
|
+
return this.cmp(t) > 0;
|
|
662
782
|
}
|
|
663
783
|
/**
|
|
664
784
|
* Returns true if %%other%% is greater than or equal to %%this%%.
|
|
665
785
|
*/
|
|
666
|
-
gte(
|
|
667
|
-
return this.cmp(
|
|
786
|
+
gte(t) {
|
|
787
|
+
return this.cmp(t) >= 0;
|
|
668
788
|
}
|
|
669
789
|
/**
|
|
670
790
|
* Returns a new [[FixedNumber]] which is the largest **integer**
|
|
@@ -673,8 +793,8 @@ const Z = class Z {
|
|
|
673
793
|
* The decimal component of the result will always be ``0``.
|
|
674
794
|
*/
|
|
675
795
|
floor() {
|
|
676
|
-
let
|
|
677
|
-
return
|
|
796
|
+
let t = x(this, R);
|
|
797
|
+
return x(this, R) < te && (t -= x(this, Y) - Ae), t = x(this, R) / x(this, Y) * x(this, Y), j(this, U, ae).call(this, t, "floor");
|
|
678
798
|
}
|
|
679
799
|
/**
|
|
680
800
|
* Returns a new [[FixedNumber]] which is the smallest **integer**
|
|
@@ -683,32 +803,32 @@ const Z = class Z {
|
|
|
683
803
|
* The decimal component of the result will always be ``0``.
|
|
684
804
|
*/
|
|
685
805
|
ceiling() {
|
|
686
|
-
let
|
|
687
|
-
return
|
|
806
|
+
let t = x(this, R);
|
|
807
|
+
return x(this, R) > te && (t += x(this, Y) - Ae), t = x(this, R) / x(this, Y) * x(this, Y), j(this, U, ae).call(this, t, "ceiling");
|
|
688
808
|
}
|
|
689
809
|
/**
|
|
690
810
|
* Returns a new [[FixedNumber]] with the decimal component
|
|
691
811
|
* rounded up on ties at %%decimals%% places.
|
|
692
812
|
*/
|
|
693
|
-
round(
|
|
694
|
-
if (
|
|
813
|
+
round(t) {
|
|
814
|
+
if (t == null && (t = 0), t >= this.decimals)
|
|
695
815
|
return this;
|
|
696
|
-
const n = this.decimals -
|
|
816
|
+
const n = this.decimals - t, r = Wt * pe(n - 1);
|
|
697
817
|
let s = this.value + r;
|
|
698
|
-
const
|
|
699
|
-
return s = s /
|
|
818
|
+
const l = pe(n);
|
|
819
|
+
return s = s / l * l, Se(s, x(this, ne), "round"), new we(ge, s, x(this, ne));
|
|
700
820
|
}
|
|
701
821
|
/**
|
|
702
822
|
* Returns true if %%this%% is equal to ``0``.
|
|
703
823
|
*/
|
|
704
824
|
isZero() {
|
|
705
|
-
return
|
|
825
|
+
return x(this, R) === te;
|
|
706
826
|
}
|
|
707
827
|
/**
|
|
708
828
|
* Returns true if %%this%% is less than ``0``.
|
|
709
829
|
*/
|
|
710
830
|
isNegative() {
|
|
711
|
-
return
|
|
831
|
+
return x(this, R) < te;
|
|
712
832
|
}
|
|
713
833
|
/**
|
|
714
834
|
* Returns the string representation of %%this%%.
|
|
@@ -732,8 +852,8 @@ const Z = class Z {
|
|
|
732
852
|
*
|
|
733
853
|
* This will throw if the value cannot fit into %%format%%.
|
|
734
854
|
*/
|
|
735
|
-
toFormat(
|
|
736
|
-
return
|
|
855
|
+
toFormat(t) {
|
|
856
|
+
return we.fromString(this.toString(), t);
|
|
737
857
|
}
|
|
738
858
|
/**
|
|
739
859
|
* Creates a new [[FixedNumber]] for %%value%% divided by
|
|
@@ -743,19 +863,19 @@ const Z = class Z {
|
|
|
743
863
|
* for %%decimals%%) cannot fit in %%format%%, either due to overflow
|
|
744
864
|
* or underflow (precision loss).
|
|
745
865
|
*/
|
|
746
|
-
static fromValue(
|
|
747
|
-
const s = n == null ? 0 :
|
|
748
|
-
let i =
|
|
749
|
-
const
|
|
750
|
-
if (
|
|
751
|
-
const
|
|
752
|
-
|
|
866
|
+
static fromValue(t, n, r) {
|
|
867
|
+
const s = n == null ? 0 : Ie(n), l = Ee(r);
|
|
868
|
+
let i = Ke(t, "value");
|
|
869
|
+
const u = s - l.decimals;
|
|
870
|
+
if (u > 0) {
|
|
871
|
+
const p = pe(u);
|
|
872
|
+
Z(i % p === te, "value loses precision for format", "NUMERIC_FAULT", {
|
|
753
873
|
operation: "fromValue",
|
|
754
874
|
fault: "underflow",
|
|
755
|
-
value:
|
|
756
|
-
}), i /=
|
|
757
|
-
} else
|
|
758
|
-
return
|
|
875
|
+
value: t
|
|
876
|
+
}), i /= p;
|
|
877
|
+
} else u < 0 && (i *= pe(-u));
|
|
878
|
+
return Se(i, l, "fromValue"), new we(ge, i, l);
|
|
759
879
|
}
|
|
760
880
|
/**
|
|
761
881
|
* Creates a new [[FixedNumber]] for %%value%% with %%format%%.
|
|
@@ -763,20 +883,20 @@ const Z = class Z {
|
|
|
763
883
|
* This will throw a [[NumericFaultError]] if %%value%% cannot fit
|
|
764
884
|
* in %%format%%, either due to overflow or underflow (precision loss).
|
|
765
885
|
*/
|
|
766
|
-
static fromString(
|
|
767
|
-
const r =
|
|
768
|
-
|
|
769
|
-
const s =
|
|
770
|
-
let
|
|
886
|
+
static fromString(t, n) {
|
|
887
|
+
const r = t.match(/^(-?)([0-9]*)\.?([0-9]*)$/);
|
|
888
|
+
H(r && r[2].length + r[3].length > 0, "invalid FixedNumber string value", "value", t);
|
|
889
|
+
const s = Ee(n);
|
|
890
|
+
let l = r[2] || "0", i = r[3] || "";
|
|
771
891
|
for (; i.length < s.decimals; )
|
|
772
|
-
i +=
|
|
773
|
-
|
|
892
|
+
i += ve;
|
|
893
|
+
Z(i.substring(s.decimals).match(/^0*$/), "too many decimals for format", "NUMERIC_FAULT", {
|
|
774
894
|
operation: "fromString",
|
|
775
895
|
fault: "underflow",
|
|
776
|
-
value:
|
|
896
|
+
value: t
|
|
777
897
|
}), i = i.substring(0, s.decimals);
|
|
778
|
-
const
|
|
779
|
-
return
|
|
898
|
+
const u = BigInt(r[1] + l + i);
|
|
899
|
+
return Se(u, s, "fromString"), new we(ge, u, s);
|
|
780
900
|
}
|
|
781
901
|
/**
|
|
782
902
|
* Creates a new [[FixedNumber]] with the big-endian representation
|
|
@@ -785,31 +905,31 @@ const Z = class Z {
|
|
|
785
905
|
* This will throw a [[NumericFaultError]] if %%value%% cannot fit
|
|
786
906
|
* in %%format%% due to overflow.
|
|
787
907
|
*/
|
|
788
|
-
static fromBytes(
|
|
789
|
-
let r =
|
|
790
|
-
const s =
|
|
791
|
-
return s.signed && (r =
|
|
908
|
+
static fromBytes(t, n) {
|
|
909
|
+
let r = jt(Pt(t, "value"));
|
|
910
|
+
const s = Ee(n);
|
|
911
|
+
return s.signed && (r = je(r, s.width)), Se(r, s, "fromBytes"), new we(ge, r, s);
|
|
792
912
|
}
|
|
793
913
|
};
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
},
|
|
797
|
-
return
|
|
798
|
-
},
|
|
799
|
-
return
|
|
800
|
-
},
|
|
801
|
-
return
|
|
802
|
-
},
|
|
803
|
-
return
|
|
804
|
-
},
|
|
805
|
-
return
|
|
914
|
+
ne = new WeakMap(), R = new WeakMap(), Y = new WeakMap(), U = new WeakSet(), he = function(t) {
|
|
915
|
+
H(this.format === t.format, "incompatible format; use fixedNumber.toFormat", "other", t);
|
|
916
|
+
}, ae = function(t, n) {
|
|
917
|
+
return t = Se(t, x(this, ne), n), new we(ge, t, x(this, ne));
|
|
918
|
+
}, We = function(t, n) {
|
|
919
|
+
return j(this, U, he).call(this, t), j(this, U, ae).call(this, x(this, R) + x(t, R), n);
|
|
920
|
+
}, Qe = function(t, n) {
|
|
921
|
+
return j(this, U, he).call(this, t), j(this, U, ae).call(this, x(this, R) - x(t, R), n);
|
|
922
|
+
}, qe = function(t, n) {
|
|
923
|
+
return j(this, U, he).call(this, t), j(this, U, ae).call(this, x(this, R) * x(t, R) / x(this, Y), n);
|
|
924
|
+
}, He = function(t, n) {
|
|
925
|
+
return Z(x(t, R) !== te, "division by zero", "NUMERIC_FAULT", {
|
|
806
926
|
operation: "div",
|
|
807
927
|
fault: "divide-by-zero",
|
|
808
928
|
value: this
|
|
809
|
-
}),
|
|
929
|
+
}), j(this, U, he).call(this, t), j(this, U, ae).call(this, x(this, R) * x(this, Y) / x(t, R), n);
|
|
810
930
|
};
|
|
811
|
-
let
|
|
812
|
-
const
|
|
931
|
+
let Ve = we;
|
|
932
|
+
const qt = [
|
|
813
933
|
"wei",
|
|
814
934
|
"kwei",
|
|
815
935
|
"mwei",
|
|
@@ -818,293 +938,314 @@ const Lt = [
|
|
|
818
938
|
"finney",
|
|
819
939
|
"ether"
|
|
820
940
|
];
|
|
821
|
-
function
|
|
822
|
-
|
|
941
|
+
function Ht(e, t) {
|
|
942
|
+
H(typeof e == "string", "value must be a string", "value", e);
|
|
823
943
|
let n = 18;
|
|
824
|
-
if (typeof
|
|
825
|
-
const r =
|
|
826
|
-
|
|
827
|
-
} else
|
|
828
|
-
return
|
|
944
|
+
if (typeof t == "string") {
|
|
945
|
+
const r = qt.indexOf(t);
|
|
946
|
+
H(r >= 0, "invalid unit", "unit", t), n = 3 * r;
|
|
947
|
+
} else t != null && (n = Ie(t, "unit"));
|
|
948
|
+
return Ve.fromString(e, { decimals: n, width: 512 }).value;
|
|
829
949
|
}
|
|
830
|
-
const
|
|
831
|
-
function
|
|
832
|
-
return (Number(
|
|
950
|
+
const Kt = "0x0000000000000000000000000000000000000000";
|
|
951
|
+
function Le(e, t) {
|
|
952
|
+
return (Number(e) / Math.pow(10, t)).toString();
|
|
833
953
|
}
|
|
834
|
-
async function
|
|
954
|
+
async function zt(e, t = Be) {
|
|
835
955
|
const n = new URLSearchParams({
|
|
836
|
-
senderAddress:
|
|
837
|
-
receiverAddress:
|
|
838
|
-
originChainId: String(
|
|
839
|
-
destinationChainId: String(
|
|
840
|
-
amount:
|
|
841
|
-
originCurrency:
|
|
842
|
-
destinationCurrency:
|
|
956
|
+
senderAddress: e.senderAddress,
|
|
957
|
+
receiverAddress: e.receiverAddress ?? e.senderAddress,
|
|
958
|
+
originChainId: String(e.originChainId),
|
|
959
|
+
destinationChainId: String(e.destinationChainId),
|
|
960
|
+
amount: e.amount,
|
|
961
|
+
originCurrency: e.originCurrency,
|
|
962
|
+
destinationCurrency: e.destinationCurrency
|
|
843
963
|
});
|
|
844
|
-
|
|
845
|
-
const r = `${
|
|
964
|
+
e.slippage != null && n.set("slippage", String(e.slippage));
|
|
965
|
+
const r = `${t}/v1/quotes?${n.toString()}`, s = await fetch(r);
|
|
846
966
|
if (!s.ok) {
|
|
847
|
-
const
|
|
848
|
-
throw i.status = s.status, i.statusCode =
|
|
967
|
+
const l = await s.json().catch(() => ({})), i = new Error((l == null ? void 0 : l.message) ?? `HTTP ${s.status}`);
|
|
968
|
+
throw i.status = s.status, i.statusCode = l == null ? void 0 : l.statusCode, i.error = l, i;
|
|
849
969
|
}
|
|
850
970
|
return s.json();
|
|
851
971
|
}
|
|
852
|
-
function
|
|
853
|
-
if (
|
|
854
|
-
const [n, r] =
|
|
855
|
-
if (!r || r.length <=
|
|
856
|
-
const s = r.slice(0,
|
|
972
|
+
function Yt(e, t) {
|
|
973
|
+
if (t < 0 || !e.includes(".")) return e;
|
|
974
|
+
const [n, r] = e.split(".");
|
|
975
|
+
if (!r || r.length <= t) return e;
|
|
976
|
+
const s = r.slice(0, t);
|
|
857
977
|
return s ? `${n}.${s}` : n || "0";
|
|
858
978
|
}
|
|
859
|
-
function
|
|
860
|
-
const [t,
|
|
861
|
-
var
|
|
862
|
-
(
|
|
863
|
-
}, []), L =
|
|
864
|
-
|
|
865
|
-
}, []),
|
|
866
|
-
(
|
|
867
|
-
|
|
868
|
-
const
|
|
869
|
-
|
|
979
|
+
function Jt(e = {}) {
|
|
980
|
+
const [t, n] = B(null), [r, s] = B(null), [l, i] = B(""), [u, p] = B(""), [g, C] = B(0), [I, k] = B(null), [m, y] = B(), [v, $] = B(), [D, T] = B("swap"), O = X(null), K = X(0), q = M(() => {
|
|
981
|
+
var h;
|
|
982
|
+
(h = O.current) == null || h.abort(), O.current = null;
|
|
983
|
+
}, []), L = M(() => {
|
|
984
|
+
n(null), s(null), T("finding");
|
|
985
|
+
}, []), c = M(
|
|
986
|
+
(h) => {
|
|
987
|
+
q();
|
|
988
|
+
const b = ++K.current, N = new AbortController();
|
|
989
|
+
O.current = N;
|
|
870
990
|
const {
|
|
871
|
-
sellNetworkId:
|
|
872
|
-
buyNetworkId:
|
|
873
|
-
sellToken:
|
|
874
|
-
buyToken:
|
|
875
|
-
sellAmountStr:
|
|
876
|
-
slippage:
|
|
877
|
-
fromAddress:
|
|
878
|
-
toAddress:
|
|
879
|
-
apiBase:
|
|
880
|
-
} =
|
|
881
|
-
|
|
882
|
-
|
|
991
|
+
sellNetworkId: o,
|
|
992
|
+
buyNetworkId: E,
|
|
993
|
+
sellToken: V,
|
|
994
|
+
buyToken: J,
|
|
995
|
+
sellAmountStr: G,
|
|
996
|
+
slippage: ie,
|
|
997
|
+
fromAddress: fe,
|
|
998
|
+
toAddress: ee,
|
|
999
|
+
apiBase: ce = Be
|
|
1000
|
+
} = h, de = Yt(
|
|
1001
|
+
G || "0",
|
|
1002
|
+
V.decimals
|
|
883
1003
|
);
|
|
884
|
-
let
|
|
1004
|
+
let oe;
|
|
885
1005
|
try {
|
|
886
|
-
|
|
1006
|
+
oe = Ht(de, V.decimals);
|
|
887
1007
|
} catch {
|
|
888
|
-
|
|
1008
|
+
T("swap");
|
|
889
1009
|
return;
|
|
890
1010
|
}
|
|
891
|
-
if (
|
|
892
|
-
|
|
1011
|
+
if (oe <= 0n) {
|
|
1012
|
+
T("swap");
|
|
893
1013
|
return;
|
|
894
1014
|
}
|
|
895
|
-
|
|
896
|
-
const
|
|
897
|
-
|
|
1015
|
+
T("finding"), n(null), s(null), y(void 0), $(void 0);
|
|
1016
|
+
const w = ee && ee !== "" ? ee : void 0;
|
|
1017
|
+
zt(
|
|
898
1018
|
{
|
|
899
|
-
originChainId:
|
|
900
|
-
destinationChainId:
|
|
901
|
-
originCurrency:
|
|
902
|
-
destinationCurrency:
|
|
903
|
-
amount:
|
|
904
|
-
senderAddress:
|
|
905
|
-
receiverAddress:
|
|
906
|
-
slippage:
|
|
1019
|
+
originChainId: o,
|
|
1020
|
+
destinationChainId: E,
|
|
1021
|
+
originCurrency: V.contractAddress,
|
|
1022
|
+
destinationCurrency: J.contractAddress,
|
|
1023
|
+
amount: oe.toString(),
|
|
1024
|
+
senderAddress: fe,
|
|
1025
|
+
receiverAddress: w,
|
|
1026
|
+
slippage: ie ?? 5e-3
|
|
907
1027
|
},
|
|
908
|
-
|
|
909
|
-
).then((
|
|
910
|
-
var
|
|
911
|
-
if (
|
|
912
|
-
|
|
913
|
-
|
|
1028
|
+
ce
|
|
1029
|
+
).then((a) => {
|
|
1030
|
+
var W, Q, z, f, F, P;
|
|
1031
|
+
if (b !== K.current) return;
|
|
1032
|
+
n(a);
|
|
1033
|
+
const S = (Q = (W = a == null ? void 0 : a.fees) == null ? void 0 : W.breakdown) == null ? void 0 : Q.find(
|
|
1034
|
+
(_) => _.type === "gas"
|
|
914
1035
|
);
|
|
915
|
-
if (
|
|
916
|
-
const
|
|
917
|
-
|
|
918
|
-
String(
|
|
919
|
-
|
|
1036
|
+
if (S && ($(String(S.amount)), S.gasPrice !== void 0 && y(String(S.gasPrice))), a != null && a.calldata) {
|
|
1037
|
+
const _ = a.outputAmount ?? "0", se = (String(_).includes(".") ? Number(_) : Number(
|
|
1038
|
+
Le(
|
|
1039
|
+
String(_),
|
|
1040
|
+
J.decimals
|
|
920
1041
|
)
|
|
921
|
-
)).toFixed(
|
|
922
|
-
|
|
923
|
-
const
|
|
924
|
-
((
|
|
925
|
-
),
|
|
926
|
-
((
|
|
927
|
-
),
|
|
928
|
-
|
|
929
|
-
|
|
1042
|
+
)).toFixed(J.decimals).replace(/\.?0+$/, "");
|
|
1043
|
+
i(se), p(se);
|
|
1044
|
+
const pt = Number(
|
|
1045
|
+
((f = (z = a.fees) == null ? void 0 : z.total) == null ? void 0 : f.amount) || "0"
|
|
1046
|
+
), ht = Number(
|
|
1047
|
+
((P = (F = a.fees) == null ? void 0 : F.total) == null ? void 0 : P.decimals) ?? 18
|
|
1048
|
+
), Ue = pt / Math.pow(10, ht);
|
|
1049
|
+
k(
|
|
1050
|
+
Ue <= 0 ? null : Ue < 0.01 ? "$<0.01" : `$${Ue.toFixed(2)}`
|
|
930
1051
|
);
|
|
931
|
-
const
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
1052
|
+
const ze = parseFloat(
|
|
1053
|
+
Le(
|
|
1054
|
+
a.inputAmount ?? "0",
|
|
1055
|
+
V.decimals
|
|
935
1056
|
)
|
|
936
|
-
),
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
1057
|
+
), mt = parseFloat(
|
|
1058
|
+
Le(
|
|
1059
|
+
a.outputAmount ?? "0",
|
|
1060
|
+
J.decimals
|
|
940
1061
|
)
|
|
941
1062
|
);
|
|
942
|
-
|
|
943
|
-
const
|
|
944
|
-
|
|
1063
|
+
ze > 0 && C(Number((mt / ze).toFixed(3))), s(a.calldata ?? null);
|
|
1064
|
+
const gt = V.contractAddress === "0x0000000000000000000000000000000000000000";
|
|
1065
|
+
T(gt ? "swap" : "approve");
|
|
945
1066
|
}
|
|
946
|
-
}).catch((
|
|
947
|
-
var
|
|
948
|
-
if (
|
|
949
|
-
const
|
|
950
|
-
|
|
1067
|
+
}).catch((a) => {
|
|
1068
|
+
var Q, z;
|
|
1069
|
+
if (b !== K.current || (a == null ? void 0 : a.name) === "AbortError") return;
|
|
1070
|
+
const S = String(((Q = a == null ? void 0 : a.error) == null ? void 0 : Q.message) ?? (a == null ? void 0 : a.message) ?? ""), W = (a == null ? void 0 : a.statusCode) ?? (a == null ? void 0 : a.status);
|
|
1071
|
+
S.includes("No available quotes") || W === 422 ? T("no-available-quotes") : S.includes("Invalid toAddress") || S.includes("Invalid fromAddress") ? T("wrong-address") : W === 429 || S.includes("Rate limit") ? T("rate-limit") : T("no-available-quotes"), (z = e.onError) == null || z.call(e, {
|
|
1072
|
+
source: "quote",
|
|
1073
|
+
message: S || "Failed to fetch quote",
|
|
1074
|
+
status: a == null ? void 0 : a.status,
|
|
1075
|
+
statusCode: W,
|
|
1076
|
+
error: a
|
|
1077
|
+
});
|
|
951
1078
|
});
|
|
952
1079
|
},
|
|
953
|
-
[
|
|
1080
|
+
[q, e]
|
|
954
1081
|
);
|
|
955
1082
|
return {
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
1083
|
+
quote: t,
|
|
1084
|
+
txData: r,
|
|
1085
|
+
buyAmount: l,
|
|
1086
|
+
buyAmountForInput: u,
|
|
1087
|
+
setBuyAmount: i,
|
|
1088
|
+
setBuyAmountForInput: p,
|
|
1089
|
+
price: g,
|
|
1090
|
+
gasCostUSD: I,
|
|
1091
|
+
gasPriceRaw: m,
|
|
1092
|
+
gasLimitRaw: v,
|
|
1093
|
+
buttonState: D,
|
|
1094
|
+
setButtonState: T,
|
|
1095
|
+
fetchQuote: c,
|
|
1096
|
+
cancelRequest: q,
|
|
969
1097
|
invalidateQuote: L
|
|
970
1098
|
};
|
|
971
1099
|
}
|
|
972
|
-
const
|
|
973
|
-
function
|
|
974
|
-
const [
|
|
975
|
-
|
|
976
|
-
const
|
|
977
|
-
|
|
1100
|
+
const Me = "delora-slippage-selectedIndex", $e = "delora-slippage-customValue", Ze = "delora-slippage-value", et = ["Auto", "0.1%", "0.5%"], De = 5e-3;
|
|
1101
|
+
function Gt() {
|
|
1102
|
+
const [e, t] = B(0), [n, r] = B(""), [s, l] = B(De);
|
|
1103
|
+
re(() => {
|
|
1104
|
+
const g = localStorage.getItem(Me), C = localStorage.getItem($e);
|
|
1105
|
+
g !== null && t(JSON.parse(g)), C && r(C);
|
|
978
1106
|
}, []);
|
|
979
|
-
const i =
|
|
980
|
-
|
|
981
|
-
}, []),
|
|
982
|
-
|
|
983
|
-
const
|
|
984
|
-
!isNaN(
|
|
985
|
-
}, []),
|
|
986
|
-
(
|
|
987
|
-
if (
|
|
988
|
-
const
|
|
989
|
-
return
|
|
1107
|
+
const i = M((g) => {
|
|
1108
|
+
t(g), r(""), localStorage.setItem(Me, JSON.stringify(g)), localStorage.setItem($e, ""), l(g === 0 ? De : parseFloat(et[g].replace("%", "")) / 100);
|
|
1109
|
+
}, []), u = M((g) => {
|
|
1110
|
+
t(null), r(g), localStorage.setItem(Me, "null"), localStorage.setItem($e, g);
|
|
1111
|
+
const C = parseFloat(g.replace("%", ""));
|
|
1112
|
+
!isNaN(C) && C <= 49.9 && l(C / 100);
|
|
1113
|
+
}, []), p = M(
|
|
1114
|
+
(g) => {
|
|
1115
|
+
if (g === "Auto") {
|
|
1116
|
+
const k = De;
|
|
1117
|
+
return l(k), localStorage.setItem(Ze, g), k;
|
|
990
1118
|
}
|
|
991
|
-
const
|
|
992
|
-
if (
|
|
993
|
-
const
|
|
994
|
-
return
|
|
1119
|
+
const C = parseFloat(g.replace("%", ""));
|
|
1120
|
+
if (C > 49.9) throw new Error("Slippage is too high!");
|
|
1121
|
+
const I = C / 100;
|
|
1122
|
+
return l(I), localStorage.setItem(Ze, g), I;
|
|
995
1123
|
},
|
|
996
1124
|
[]
|
|
997
1125
|
);
|
|
998
1126
|
return {
|
|
999
|
-
options:
|
|
1000
|
-
selectedIndex:
|
|
1127
|
+
options: et,
|
|
1128
|
+
selectedIndex: e,
|
|
1001
1129
|
customValue: n,
|
|
1002
1130
|
slippage: s,
|
|
1003
1131
|
selectOption: i,
|
|
1004
|
-
setCustom:
|
|
1005
|
-
save:
|
|
1132
|
+
setCustom: u,
|
|
1133
|
+
save: p
|
|
1006
1134
|
};
|
|
1007
1135
|
}
|
|
1008
|
-
const
|
|
1009
|
-
function
|
|
1010
|
-
if (!
|
|
1011
|
-
const [n, r] =
|
|
1012
|
-
return `${n}.${(r ?? "").slice(0,
|
|
1136
|
+
const _t = 1e3;
|
|
1137
|
+
function Ce(e, t) {
|
|
1138
|
+
if (!e.includes(".")) return e;
|
|
1139
|
+
const [n, r] = e.split(".");
|
|
1140
|
+
return `${n}.${(r ?? "").slice(0, t)}`;
|
|
1013
1141
|
}
|
|
1014
|
-
function
|
|
1015
|
-
return
|
|
1142
|
+
function tt(e) {
|
|
1143
|
+
return e === "EVM" ? at : e === "SVM" ? it : ct;
|
|
1016
1144
|
}
|
|
1017
|
-
function
|
|
1018
|
-
var
|
|
1019
|
-
const
|
|
1020
|
-
|
|
1145
|
+
function Xt(e) {
|
|
1146
|
+
var q, L, c, h;
|
|
1147
|
+
const t = Lt({
|
|
1148
|
+
apiBase: e.apiBase,
|
|
1149
|
+
initialSellToken: e.initialSellToken,
|
|
1150
|
+
initialBuyToken: e.initialBuyToken,
|
|
1151
|
+
initialSellNetworkId: e.initialSellNetworkId,
|
|
1152
|
+
initialBuyNetworkId: e.initialBuyNetworkId,
|
|
1153
|
+
lockBuyToken: e.lockBuyToken,
|
|
1154
|
+
lockSellToken: e.lockSellToken,
|
|
1155
|
+
lockBuyNetwork: e.lockBuyNetwork,
|
|
1156
|
+
lockSellNetwork: e.lockSellNetwork,
|
|
1157
|
+
onError: e.onError
|
|
1158
|
+
}), n = Jt({ onError: e.onError }), r = Gt(), s = !!e.lockBuyToken || !!e.lockSellToken || !!e.lockBuyNetwork || !!e.lockSellNetwork, [l, i] = B(""), [u, p] = B(0), [g, C] = B(!1), I = X(null), k = 0, m = 0, y = !!t.sellToken && !!t.buyToken && u > 0, v = M(() => {
|
|
1159
|
+
if (!t.networkSell || !t.networkBuy || !t.sellToken || !t.buyToken || u <= 0 || g)
|
|
1021
1160
|
return;
|
|
1022
|
-
const
|
|
1161
|
+
const b = tt(t.networkSell.chainType), N = tt(t.networkBuy.chainType);
|
|
1023
1162
|
n.fetchQuote({
|
|
1024
|
-
sellNetworkId:
|
|
1025
|
-
buyNetworkId:
|
|
1026
|
-
sellToken:
|
|
1027
|
-
buyToken:
|
|
1028
|
-
sellAmountStr:
|
|
1163
|
+
sellNetworkId: t.networkSell.id,
|
|
1164
|
+
buyNetworkId: t.networkBuy.id,
|
|
1165
|
+
sellToken: t.sellToken,
|
|
1166
|
+
buyToken: t.buyToken,
|
|
1167
|
+
sellAmountStr: l || "0",
|
|
1029
1168
|
slippage: r.slippage,
|
|
1030
|
-
fromAddress:
|
|
1031
|
-
toAddress:
|
|
1032
|
-
apiBase:
|
|
1169
|
+
fromAddress: b,
|
|
1170
|
+
toAddress: N,
|
|
1171
|
+
apiBase: e.apiBase ?? Be
|
|
1033
1172
|
});
|
|
1034
1173
|
}, [
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1174
|
+
t.networkSell,
|
|
1175
|
+
t.networkBuy,
|
|
1176
|
+
t.sellToken,
|
|
1177
|
+
t.buyToken,
|
|
1178
|
+
u,
|
|
1179
|
+
l,
|
|
1041
1180
|
r.slippage,
|
|
1042
|
-
|
|
1043
|
-
|
|
1181
|
+
g,
|
|
1182
|
+
e.apiBase,
|
|
1044
1183
|
n
|
|
1045
1184
|
]);
|
|
1046
|
-
|
|
1047
|
-
if (!
|
|
1185
|
+
re(() => {
|
|
1186
|
+
if (!y) {
|
|
1048
1187
|
n.cancelRequest(), n.setBuyAmount(""), n.setBuyAmountForInput(""), n.setButtonState("swap");
|
|
1049
1188
|
return;
|
|
1050
1189
|
}
|
|
1051
|
-
|
|
1190
|
+
v();
|
|
1052
1191
|
}, [
|
|
1192
|
+
y,
|
|
1193
|
+
(q = t.networkSell) == null ? void 0 : q.id,
|
|
1194
|
+
(L = t.networkBuy) == null ? void 0 : L.id,
|
|
1195
|
+
(c = t.sellToken) == null ? void 0 : c.contractAddress,
|
|
1196
|
+
(h = t.buyToken) == null ? void 0 : h.contractAddress,
|
|
1053
1197
|
u,
|
|
1054
|
-
|
|
1055
|
-
(j = e.networkBuy) == null ? void 0 : j.id,
|
|
1056
|
-
(l = e.sellToken) == null ? void 0 : l.contractAddress,
|
|
1057
|
-
(S = e.buyToken) == null ? void 0 : S.contractAddress,
|
|
1058
|
-
i,
|
|
1059
|
-
s,
|
|
1198
|
+
l,
|
|
1060
1199
|
r.slippage,
|
|
1061
|
-
|
|
1062
|
-
]),
|
|
1063
|
-
|
|
1064
|
-
}, [
|
|
1065
|
-
const
|
|
1066
|
-
const
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
},
|
|
1070
|
-
}, [n]),
|
|
1071
|
-
|
|
1072
|
-
}, [
|
|
1073
|
-
(
|
|
1074
|
-
const
|
|
1075
|
-
|
|
1200
|
+
g
|
|
1201
|
+
]), re(() => {
|
|
1202
|
+
u === 0 && (n.setBuyAmount(""), n.setBuyAmountForInput(""));
|
|
1203
|
+
}, [u]);
|
|
1204
|
+
const $ = M((b) => {
|
|
1205
|
+
const N = b.replace(/[^0-9.]/g, "").replace(/\.+/g, ".").replace(/^(\.)/g, ""), o = Ce(N, 6), E = Number(o);
|
|
1206
|
+
i(o), p(isNaN(E) ? 0 : E), C(!0), n.invalidateQuote(), I.current && clearTimeout(I.current), I.current = setTimeout(() => {
|
|
1207
|
+
C(!1), I.current = null;
|
|
1208
|
+
}, _t);
|
|
1209
|
+
}, [n]), D = M(() => {
|
|
1210
|
+
i(String(k)), p(k), C(!1), y && v();
|
|
1211
|
+
}, [k, y, v]), T = M(
|
|
1212
|
+
(b) => {
|
|
1213
|
+
const N = k * b / 100, o = Ce(String(N), 6);
|
|
1214
|
+
i(o), p(N), C(!1), y && v();
|
|
1076
1215
|
},
|
|
1077
|
-
[
|
|
1078
|
-
),
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1216
|
+
[k, y, v]
|
|
1217
|
+
), O = M(() => {
|
|
1218
|
+
if (s) return;
|
|
1219
|
+
const b = t.sellToken, N = t.buyToken;
|
|
1220
|
+
if (!b || !N) return;
|
|
1221
|
+
const o = l || "0", E = n.buyAmountForInput || n.buyAmount || "0";
|
|
1222
|
+
if (n.cancelRequest(), n.invalidateQuote(), t.updateNetworkSell(N.chainId), t.updateNetworkBuy(b.chainId), t.setSellToken(N), t.setBuyToken(b), E !== "0" && E !== "0.0") {
|
|
1223
|
+
const V = Ce(E, 6);
|
|
1224
|
+
i(V), p(Number(V));
|
|
1085
1225
|
} else
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
}, [
|
|
1226
|
+
i(""), p(0);
|
|
1227
|
+
o !== "0" && o !== "0.0" ? (n.setBuyAmount(Ce(o, 6)), n.setBuyAmountForInput(Ce(o, 6))) : (n.setBuyAmount(""), n.setBuyAmountForInput(""));
|
|
1228
|
+
}, [t, n, l, s]);
|
|
1089
1229
|
return {
|
|
1090
|
-
...
|
|
1230
|
+
...t,
|
|
1091
1231
|
...n,
|
|
1092
1232
|
slippage: r,
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1233
|
+
swapLocked: s,
|
|
1234
|
+
sellAmountForInput: l,
|
|
1235
|
+
setSellAmountForInput: i,
|
|
1236
|
+
validatedSellAmount: u,
|
|
1237
|
+
processSellInput: $,
|
|
1238
|
+
setMaxSellAmount: D,
|
|
1239
|
+
setSellAmountByPercent: T,
|
|
1240
|
+
swapTokens: O,
|
|
1241
|
+
balance: k,
|
|
1101
1242
|
balanceBuy: m,
|
|
1102
|
-
allFieldsReady:
|
|
1103
|
-
isProcessingInput:
|
|
1104
|
-
isSameToken: (
|
|
1243
|
+
allFieldsReady: y,
|
|
1244
|
+
isProcessingInput: g,
|
|
1245
|
+
isSameToken: (b, N) => !!b && !!N && b.contractAddress === N.contractAddress && b.chainId === N.chainId
|
|
1105
1246
|
};
|
|
1106
1247
|
}
|
|
1107
|
-
const
|
|
1248
|
+
const Zt = {
|
|
1108
1249
|
trade: {
|
|
1109
1250
|
possibleChars: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+{}:"<>?|',
|
|
1110
1251
|
glitchChars: '!@#$%^&*()_+{}:"<>?|\\',
|
|
@@ -1120,72 +1261,72 @@ const Ht = {
|
|
|
1120
1261
|
animationSpeed: 25
|
|
1121
1262
|
}
|
|
1122
1263
|
};
|
|
1123
|
-
function
|
|
1124
|
-
ref:
|
|
1125
|
-
text:
|
|
1264
|
+
function en({
|
|
1265
|
+
ref: e,
|
|
1266
|
+
text: t,
|
|
1126
1267
|
enabled: n,
|
|
1127
1268
|
preset: r = "trade",
|
|
1128
1269
|
onAnimationStart: s,
|
|
1129
|
-
onAnimationEnd:
|
|
1270
|
+
onAnimationEnd: l
|
|
1130
1271
|
}) {
|
|
1131
|
-
const i =
|
|
1132
|
-
|
|
1133
|
-
const
|
|
1134
|
-
|
|
1135
|
-
}, [
|
|
1136
|
-
const
|
|
1137
|
-
if (!
|
|
1138
|
-
if (!n || !
|
|
1139
|
-
|
|
1272
|
+
const i = X(null);
|
|
1273
|
+
yt(() => {
|
|
1274
|
+
const u = e.current;
|
|
1275
|
+
u && (!n || !t || t === "0" || t === "0.0") && (u.textContent = t);
|
|
1276
|
+
}, [e, t, n]), re(() => {
|
|
1277
|
+
const u = e.current;
|
|
1278
|
+
if (!u) return;
|
|
1279
|
+
if (!n || !t || t === "0" || t === "0.0") {
|
|
1280
|
+
u.textContent = t;
|
|
1140
1281
|
return;
|
|
1141
1282
|
}
|
|
1142
|
-
const { possibleChars:
|
|
1283
|
+
const { possibleChars: p, glitchChars: g, cyberChars: C, animationFrames: I, animationSpeed: k } = Zt[r], m = String(t);
|
|
1143
1284
|
i.current && (clearTimeout(i.current), i.current = null);
|
|
1144
|
-
let
|
|
1145
|
-
const
|
|
1146
|
-
if (!
|
|
1147
|
-
if (
|
|
1148
|
-
|
|
1285
|
+
let y = 0;
|
|
1286
|
+
const v = Array(m.length).fill(!1), $ = Array(m.length).fill(!1), D = () => {
|
|
1287
|
+
if (!e.current) return;
|
|
1288
|
+
if (y >= I) {
|
|
1289
|
+
e.current.textContent = m, i.current = null, l == null || l();
|
|
1149
1290
|
return;
|
|
1150
1291
|
}
|
|
1151
|
-
|
|
1152
|
-
let
|
|
1153
|
-
const
|
|
1154
|
-
for (let
|
|
1155
|
-
|
|
1156
|
-
if (
|
|
1157
|
-
const
|
|
1158
|
-
for (let
|
|
1159
|
-
Math.random() <
|
|
1292
|
+
y === 0 && (s == null || s());
|
|
1293
|
+
let O = "";
|
|
1294
|
+
const K = y / I, q = Math.pow(K, 0.6), L = Math.floor(m.length * q);
|
|
1295
|
+
for (let h = 0; h < L; h++)
|
|
1296
|
+
$[h] || ($[h] = !0);
|
|
1297
|
+
if (y % 2 === 0) {
|
|
1298
|
+
const h = 0.05 + K * 0.1;
|
|
1299
|
+
for (let b = 0; b < m.length; b++)
|
|
1300
|
+
Math.random() < h && (v[b] = !v[b]);
|
|
1160
1301
|
}
|
|
1161
|
-
for (let
|
|
1162
|
-
if (
|
|
1163
|
-
|
|
1164
|
-
else if (
|
|
1165
|
-
|
|
1302
|
+
for (let h = 0; h < m.length; h++)
|
|
1303
|
+
if ($[h])
|
|
1304
|
+
v[h] && y < I * 0.95 && m[h] !== " " ? Math.random() < 0.3 ? O += C[Math.floor(Math.random() * C.length)] : O += g[Math.floor(Math.random() * g.length)] : O += m[h];
|
|
1305
|
+
else if (m[h] === " ")
|
|
1306
|
+
O += " ";
|
|
1166
1307
|
else {
|
|
1167
|
-
const
|
|
1168
|
-
|
|
1308
|
+
const b = Math.random();
|
|
1309
|
+
b < 0.2 ? O += g[Math.floor(Math.random() * g.length)] : b < 0.4 ? O += C[Math.floor(Math.random() * C.length)] : O += p[Math.floor(Math.random() * p.length)];
|
|
1169
1310
|
}
|
|
1170
|
-
|
|
1171
|
-
let
|
|
1172
|
-
|
|
1173
|
-
},
|
|
1174
|
-
|
|
1311
|
+
e.current.textContent = O, y++;
|
|
1312
|
+
let c = k;
|
|
1313
|
+
K < 0.3 ? c = k * 0.8 : K > 0.7 ? c = k * 0.7 : c = k * 1.2, i.current = setTimeout(D, c);
|
|
1314
|
+
}, T = setTimeout(() => {
|
|
1315
|
+
e.current && D();
|
|
1175
1316
|
}, 0);
|
|
1176
1317
|
return () => {
|
|
1177
|
-
clearTimeout(
|
|
1318
|
+
clearTimeout(T), i.current && (clearTimeout(i.current), i.current = null), l == null || l();
|
|
1178
1319
|
};
|
|
1179
|
-
}, [
|
|
1320
|
+
}, [e, t, n, r]);
|
|
1180
1321
|
}
|
|
1181
|
-
function
|
|
1182
|
-
if (!
|
|
1183
|
-
if (
|
|
1184
|
-
return
|
|
1185
|
-
const n = (
|
|
1186
|
-
return
|
|
1322
|
+
function me(e, t) {
|
|
1323
|
+
if (!e) return "";
|
|
1324
|
+
if (e.startsWith("http://") || e.startsWith("https://") || e.startsWith("data:"))
|
|
1325
|
+
return e;
|
|
1326
|
+
const n = (t == null ? void 0 : t.replace(/\/$/, "")) ?? "";
|
|
1327
|
+
return e.startsWith("/") ? `${n}${e}` : `${n}/${e}`;
|
|
1187
1328
|
}
|
|
1188
|
-
const
|
|
1329
|
+
const tn = "data:image/svg+xml,%3csvg%20width='27'%20height='27'%20viewBox='0%200%2027%2027'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M7.42142%203.29834C6.61961%203.29834%205.85064%203.61686%205.28367%204.18383C4.71671%204.75079%204.39819%205.51976%204.39819%206.32158V22.5371H4.12335C3.90467%2022.5371%203.69495%2022.624%203.54032%2022.7786C3.3857%2022.9332%203.29883%2023.143%203.29883%2023.3616C3.29883%2023.5803%203.3857%2023.79%203.54032%2023.9447C3.69495%2024.0993%203.90467%2024.1862%204.12335%2024.1862H18.9647C19.1834%2024.1862%2019.3931%2024.0993%2019.5477%2023.9447C19.7023%2023.79%2019.7892%2023.5803%2019.7892%2023.3616C19.7892%2023.143%2019.7023%2022.9332%2019.5477%2022.7786C19.3931%2022.624%2019.1834%2022.5371%2018.9647%2022.5371H18.6899V20.555C19.1499%2020.7915%2019.6631%2020.9058%2020.1801%2020.8868C20.697%2020.8679%2021.2005%2020.7163%2021.642%2020.4468C22.0835%2020.1772%2022.4484%2019.7987%2022.7015%2019.3475C22.9546%2018.8963%2023.0874%2018.3877%2023.0873%2017.8703V11.4523C23.0873%2010.7981%2022.8751%2010.1617%2022.4826%209.63834L21.2733%208.02558C21.1421%207.85064%2020.9468%207.73499%2020.7303%207.70406C20.5139%207.67314%2020.294%207.72947%2020.119%207.86068C19.9441%207.99189%2019.8284%208.18721%2019.7975%208.40369C19.7666%208.62017%2019.8229%208.84007%2019.9541%209.01501L21.1634%2010.6278C21.3415%2010.8652%2021.4383%2011.1555%2021.4383%2011.4523V17.8703C21.4383%2018.0501%2021.4028%2018.2281%2021.3341%2018.3941C21.2653%2018.5602%2021.1645%2018.7111%2021.0374%2018.8382C20.9103%2018.9653%2020.7594%2019.0661%2020.5933%2019.1349C20.4273%2019.2036%2020.2493%2019.239%2020.0695%2019.239C19.8898%2019.239%2019.7118%2019.2036%2019.5458%2019.1349C19.3797%2019.0661%2019.2288%2018.9653%2019.1017%2018.8382C18.9746%2018.7111%2018.8738%2018.5602%2018.805%2018.3941C18.7363%2018.2281%2018.7008%2018.0501%2018.7008%2017.8703V15.941C18.6999%2015.8964%2018.6962%2015.852%2018.6899%2015.8079V6.32158C18.6899%205.92456%2018.6117%205.53143%2018.4597%205.16463C18.3078%204.79784%2018.0851%204.46456%2017.8044%204.18383C17.5236%203.90309%2017.1904%203.6804%2016.8236%203.52847C16.4568%203.37654%2016.0636%203.29834%2015.6666%203.29834H7.42142ZM7.69626%207.42094C7.69626%207.20226%207.78313%206.99254%207.93776%206.83791C8.09239%206.68329%208.30211%206.59642%208.52078%206.59642H14.5673C14.7859%206.59642%2014.9957%206.68329%2015.1503%206.83791C15.3049%206.99254%2015.3918%207.20226%2015.3918%207.42094V11.2687C15.3918%2011.4874%2015.3049%2011.6971%2015.1503%2011.8517C14.9957%2012.0063%2014.7859%2012.0932%2014.5673%2012.0932H8.52078C8.30211%2012.0932%208.09239%2012.0063%207.93776%2011.8517C7.78313%2011.6971%207.69626%2011.4874%207.69626%2011.2687V7.42094Z'%20fill='white'/%3e%3c/svg%3e", nn = {
|
|
1189
1330
|
swap: "Swap",
|
|
1190
1331
|
finding: "Finding Routes...",
|
|
1191
1332
|
approve: "Approve",
|
|
@@ -1195,75 +1336,79 @@ const Kt = "data:image/svg+xml,%3csvg%20width='27'%20height='27'%20viewBox='0%20
|
|
|
1195
1336
|
"wrong-address": "Wrong address",
|
|
1196
1337
|
"rate-limit": "Try later"
|
|
1197
1338
|
};
|
|
1198
|
-
function
|
|
1339
|
+
function rn(e) {
|
|
1199
1340
|
const {
|
|
1200
|
-
sellToken:
|
|
1341
|
+
sellToken: t,
|
|
1201
1342
|
buyToken: n,
|
|
1202
1343
|
networkSellLogo: r,
|
|
1203
1344
|
networkBuyLogo: s,
|
|
1204
|
-
assetBaseUrl:
|
|
1345
|
+
assetBaseUrl: l,
|
|
1205
1346
|
sellAmountForInput: i,
|
|
1206
|
-
buyAmountForInput:
|
|
1207
|
-
onSellAmountChange:
|
|
1208
|
-
onSellInputProcess:
|
|
1209
|
-
onOpenSellToken:
|
|
1210
|
-
onOpenBuyToken:
|
|
1211
|
-
onSwapTokens:
|
|
1212
|
-
onRefresh:
|
|
1213
|
-
onOpenSettings:
|
|
1214
|
-
balance:
|
|
1215
|
-
balanceBuy:
|
|
1216
|
-
sellPriceUsd:
|
|
1217
|
-
buyPriceUsd:
|
|
1218
|
-
onMaxClick:
|
|
1219
|
-
onSet50Percent:
|
|
1220
|
-
onSet25Percent:
|
|
1221
|
-
buttonState:
|
|
1222
|
-
txData:
|
|
1223
|
-
loading:
|
|
1224
|
-
price:
|
|
1225
|
-
gasCostUSD:
|
|
1226
|
-
truncateTo6Decimals:
|
|
1227
|
-
isWalletConnected:
|
|
1228
|
-
onConnectWallet:
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1347
|
+
buyAmountForInput: u,
|
|
1348
|
+
onSellAmountChange: p,
|
|
1349
|
+
onSellInputProcess: g,
|
|
1350
|
+
onOpenSellToken: C,
|
|
1351
|
+
onOpenBuyToken: I,
|
|
1352
|
+
onSwapTokens: k,
|
|
1353
|
+
onRefresh: m,
|
|
1354
|
+
onOpenSettings: y,
|
|
1355
|
+
balance: v,
|
|
1356
|
+
balanceBuy: $,
|
|
1357
|
+
sellPriceUsd: D,
|
|
1358
|
+
buyPriceUsd: T,
|
|
1359
|
+
onMaxClick: O,
|
|
1360
|
+
onSet50Percent: K,
|
|
1361
|
+
onSet25Percent: q,
|
|
1362
|
+
buttonState: L,
|
|
1363
|
+
txData: c,
|
|
1364
|
+
loading: h,
|
|
1365
|
+
price: b,
|
|
1366
|
+
gasCostUSD: N,
|
|
1367
|
+
truncateTo6Decimals: o,
|
|
1368
|
+
isWalletConnected: E = !1,
|
|
1369
|
+
onConnectWallet: V,
|
|
1370
|
+
onAction: J,
|
|
1371
|
+
swapDisabled: G = !1,
|
|
1372
|
+
sellTokenLocked: ie = !1,
|
|
1373
|
+
buyTokenLocked: fe = !1
|
|
1374
|
+
} = e, ee = !!i && Number(i) > 0, ce = L === "insufficient" || L === "no-available-quotes" || L === "wrong-address", de = !ee || h || E && !c && L !== "finding" || L === "no-available-quotes" || L === "insufficient", oe = E ? de : !1, w = X(null), a = X(null), S = X(0), W = () => {
|
|
1375
|
+
m(), S.current += 1;
|
|
1376
|
+
const f = a.current;
|
|
1377
|
+
f && (f.style.transform = `rotate(${S.current * -720}deg)`);
|
|
1233
1378
|
};
|
|
1234
|
-
|
|
1235
|
-
ref:
|
|
1236
|
-
text:
|
|
1237
|
-
enabled: !!(n != null && n.symbol) && Number(i) > 0 && !!
|
|
1379
|
+
en({
|
|
1380
|
+
ref: w,
|
|
1381
|
+
text: u || "0.0",
|
|
1382
|
+
enabled: !!(n != null && n.symbol) && Number(i) > 0 && !!u && u !== "0" && u !== "0.0",
|
|
1238
1383
|
preset: "trade"
|
|
1239
1384
|
});
|
|
1240
|
-
const
|
|
1241
|
-
if ([",", ".", "/", "б", "ю"].includes(
|
|
1242
|
-
|
|
1243
|
-
const
|
|
1244
|
-
if (
|
|
1245
|
-
const
|
|
1246
|
-
|
|
1385
|
+
const Q = (f) => {
|
|
1386
|
+
if ([",", ".", "/", "б", "ю"].includes(f.key)) {
|
|
1387
|
+
f.preventDefault();
|
|
1388
|
+
const P = f.target;
|
|
1389
|
+
if (P.value.includes(".")) return;
|
|
1390
|
+
const _ = P.selectionStart ?? P.value.length, le = P.value.slice(0, _) + "." + P.value.slice(_);
|
|
1391
|
+
p(le), g(le);
|
|
1247
1392
|
}
|
|
1248
|
-
},
|
|
1249
|
-
return /* @__PURE__ */
|
|
1250
|
-
/* @__PURE__ */
|
|
1393
|
+
}, z = E ? `dw-w-full dw-h-[38px] dw-rounded-[var(--dw-radius)] dw-border dw-text-[13px] dw-font-normal dw-transition-colors ${ce ? "dw-bg-[var(--dw-danger)] dw-border-[var(--dw-danger)] dw-text-white" : de ? "dw-bg-[var(--dw-surface-hover)] dw-border-[var(--dw-border)] dw-text-[var(--dw-muted)]" : "dw-bg-[var(--dw-accent)] dw-border-[var(--dw-accent)] dw-text-white hover:dw-bg-[var(--dw-accent-hover)] hover:dw-border-[var(--dw-accent-hover)]"}` : "dw-w-full dw-h-[38px] dw-rounded-[var(--dw-radius)] dw-border dw-border-[var(--dw-accent)] dw-text-[13px] dw-font-normal dw-transition-colors dw-bg-[var(--dw-accent)] dw-text-white hover:dw-bg-[var(--dw-accent-hover)] hover:dw-border-[var(--dw-accent-hover)]";
|
|
1394
|
+
return /* @__PURE__ */ A("div", { className: "dw-widget-shell dw-elevated-surface dw-flex dw-flex-col dw-gap-1.5 dw-font-mono", children: [
|
|
1395
|
+
/* @__PURE__ */ A("div", { className: "dw-flex dw-items-center dw-justify-between dw-mb-0.5", children: [
|
|
1251
1396
|
/* @__PURE__ */ d("h3", { className: "dw-text-[14px] dw-font-normal dw-text-[var(--dw-fg)]", children: "Trade" }),
|
|
1252
|
-
/* @__PURE__ */
|
|
1397
|
+
/* @__PURE__ */ A("div", { className: "dw-flex dw-items-center dw-gap-1", children: [
|
|
1253
1398
|
/* @__PURE__ */ d(
|
|
1254
1399
|
"button",
|
|
1255
1400
|
{
|
|
1256
1401
|
type: "button",
|
|
1257
1402
|
className: "dw-icon-button dw-w-4 dw-h-4 dw-flex dw-items-center dw-justify-center dw-rounded-[4px] dw-cursor-pointer dw-opacity-70",
|
|
1258
|
-
onMouseDown:
|
|
1403
|
+
onMouseDown: W,
|
|
1259
1404
|
"aria-label": "Refresh",
|
|
1260
1405
|
children: /* @__PURE__ */ d(
|
|
1261
1406
|
"span",
|
|
1262
1407
|
{
|
|
1263
|
-
ref:
|
|
1408
|
+
ref: a,
|
|
1264
1409
|
className: "dw-w-full dw-h-full dw-flex dw-items-center dw-justify-center",
|
|
1265
1410
|
style: { transition: "transform 1s ease-in-out" },
|
|
1266
|
-
children: /* @__PURE__ */ d(
|
|
1411
|
+
children: /* @__PURE__ */ d(dn, {})
|
|
1267
1412
|
}
|
|
1268
1413
|
)
|
|
1269
1414
|
}
|
|
@@ -1273,62 +1418,65 @@ function qt(t) {
|
|
|
1273
1418
|
{
|
|
1274
1419
|
type: "button",
|
|
1275
1420
|
className: "dw-icon-button dw-w-4 dw-h-4 dw-flex dw-items-center dw-justify-center dw-rounded-[4px] dw-cursor-pointer dw-opacity-70",
|
|
1276
|
-
onClick:
|
|
1421
|
+
onClick: y,
|
|
1277
1422
|
"aria-label": "Settings",
|
|
1278
|
-
children: /* @__PURE__ */ d(
|
|
1423
|
+
children: /* @__PURE__ */ d(ln, {})
|
|
1279
1424
|
}
|
|
1280
1425
|
)
|
|
1281
1426
|
] })
|
|
1282
1427
|
] }),
|
|
1283
|
-
/* @__PURE__ */
|
|
1428
|
+
/* @__PURE__ */ A("div", { className: "dw-relative dw-flex dw-flex-col dw-gap-1.5", children: [
|
|
1284
1429
|
/* @__PURE__ */ d(
|
|
1285
1430
|
"button",
|
|
1286
1431
|
{
|
|
1287
1432
|
type: "button",
|
|
1288
|
-
className:
|
|
1289
|
-
onClick:
|
|
1433
|
+
className: `dw-widget-section dw-group dw-w-[30px] dw-h-[30px] dw-absolute dw-left-1/2 dw-top-1/2 dw-z-10 dw--translate-x-1/2 dw--translate-y-1/2 dw-flex dw-justify-center dw-items-center ${G ? "dw-cursor-not-allowed dw-opacity-40" : "dw-cursor-pointer"}`,
|
|
1434
|
+
onClick: k,
|
|
1290
1435
|
"aria-label": "Swap tokens",
|
|
1291
|
-
|
|
1436
|
+
disabled: G,
|
|
1437
|
+
children: /* @__PURE__ */ d(sn, {})
|
|
1292
1438
|
}
|
|
1293
1439
|
),
|
|
1294
1440
|
/* @__PURE__ */ d(
|
|
1295
|
-
|
|
1441
|
+
nt,
|
|
1296
1442
|
{
|
|
1297
1443
|
label: "From",
|
|
1298
1444
|
labelTone: "danger",
|
|
1299
|
-
token:
|
|
1445
|
+
token: t,
|
|
1300
1446
|
networkLogo: r,
|
|
1301
|
-
assetBaseUrl:
|
|
1447
|
+
assetBaseUrl: l,
|
|
1302
1448
|
amount: i,
|
|
1303
1449
|
amountPlaceholder: "0.0",
|
|
1304
|
-
usdValue:
|
|
1305
|
-
balance:
|
|
1306
|
-
onOpenToken:
|
|
1307
|
-
|
|
1308
|
-
|
|
1450
|
+
usdValue: D || "$0.000",
|
|
1451
|
+
balance: o(v),
|
|
1452
|
+
onOpenToken: C,
|
|
1453
|
+
tokenLocked: ie,
|
|
1454
|
+
onInputChange: (f) => {
|
|
1455
|
+
p(f), g(f);
|
|
1309
1456
|
},
|
|
1310
|
-
onKeyDown:
|
|
1311
|
-
amountToneClassName:
|
|
1312
|
-
quickActions: /* @__PURE__ */
|
|
1313
|
-
/* @__PURE__ */ d(
|
|
1314
|
-
/* @__PURE__ */ d(
|
|
1315
|
-
/* @__PURE__ */ d(
|
|
1457
|
+
onKeyDown: Q,
|
|
1458
|
+
amountToneClassName: ce ? "dw-text-[var(--dw-danger)]" : "dw-text-[var(--dw-fg)]",
|
|
1459
|
+
quickActions: /* @__PURE__ */ A(xt, { children: [
|
|
1460
|
+
/* @__PURE__ */ d(Oe, { label: "MAX", onClick: O }),
|
|
1461
|
+
/* @__PURE__ */ d(Oe, { label: "50%", onClick: K }),
|
|
1462
|
+
/* @__PURE__ */ d(Oe, { label: "25%", onClick: q })
|
|
1316
1463
|
] })
|
|
1317
1464
|
}
|
|
1318
1465
|
),
|
|
1319
1466
|
/* @__PURE__ */ d(
|
|
1320
|
-
|
|
1467
|
+
nt,
|
|
1321
1468
|
{
|
|
1322
1469
|
label: "To",
|
|
1323
1470
|
labelTone: "success",
|
|
1324
1471
|
token: n,
|
|
1325
1472
|
networkLogo: s,
|
|
1326
|
-
assetBaseUrl:
|
|
1327
|
-
amount:
|
|
1328
|
-
usdValue:
|
|
1329
|
-
balance:
|
|
1330
|
-
onOpenToken:
|
|
1331
|
-
|
|
1473
|
+
assetBaseUrl: l,
|
|
1474
|
+
amount: u || "0.0",
|
|
1475
|
+
usdValue: T || "$0.000",
|
|
1476
|
+
balance: o($),
|
|
1477
|
+
onOpenToken: I,
|
|
1478
|
+
tokenLocked: fe,
|
|
1479
|
+
amountRef: w,
|
|
1332
1480
|
readOnly: !0
|
|
1333
1481
|
}
|
|
1334
1482
|
),
|
|
@@ -1336,124 +1484,125 @@ function qt(t) {
|
|
|
1336
1484
|
"button",
|
|
1337
1485
|
{
|
|
1338
1486
|
type: "button",
|
|
1339
|
-
className:
|
|
1340
|
-
disabled:
|
|
1341
|
-
onClick:
|
|
1342
|
-
|
|
1343
|
-
children: C ? zt[l] : "Connect Wallet"
|
|
1487
|
+
className: z,
|
|
1488
|
+
disabled: oe,
|
|
1489
|
+
onClick: E ? J : V,
|
|
1490
|
+
children: E ? nn[L] : "Connect Wallet"
|
|
1344
1491
|
}
|
|
1345
1492
|
),
|
|
1346
|
-
/* @__PURE__ */
|
|
1347
|
-
/* @__PURE__ */
|
|
1348
|
-
/* @__PURE__ */ d("img", { src:
|
|
1349
|
-
/* @__PURE__ */ d("p", { className: "dw-font-normal dw-text-[10px] dw-text-[var(--dw-fg)]", children:
|
|
1493
|
+
/* @__PURE__ */ A("div", { className: "dw-flex dw-items-center dw-justify-between dw-min-h-[12px] dw-px-0.5", children: [
|
|
1494
|
+
/* @__PURE__ */ A("div", { className: "dw-flex dw-items-center dw-gap-1 dw-min-w-0", children: [
|
|
1495
|
+
/* @__PURE__ */ d("img", { src: tn, alt: "", className: "dw-w-[10px] dw-h-[10px]" }),
|
|
1496
|
+
/* @__PURE__ */ d("p", { className: "dw-font-normal dw-text-[10px] dw-text-[var(--dw-fg)]", children: c ? N ?? "—" : "$<0.01" })
|
|
1350
1497
|
] }),
|
|
1351
|
-
/* @__PURE__ */ d("p", { className: "dw-font-normal dw-text-[10px] dw-text-[var(--dw-text-subtle)] dw-truncate dw-ml-3", children:
|
|
1498
|
+
/* @__PURE__ */ d("p", { className: "dw-font-normal dw-text-[10px] dw-text-[var(--dw-text-subtle)] dw-truncate dw-ml-3", children: c && (t != null && t.symbol) && (n != null && n.symbol) ? `1 ${t.symbol} = ${b} ${n.symbol}` : "" })
|
|
1352
1499
|
] })
|
|
1353
1500
|
] })
|
|
1354
1501
|
] });
|
|
1355
1502
|
}
|
|
1356
|
-
function
|
|
1503
|
+
function nt(e) {
|
|
1357
1504
|
const {
|
|
1358
|
-
label:
|
|
1505
|
+
label: t,
|
|
1359
1506
|
labelTone: n,
|
|
1360
1507
|
token: r,
|
|
1361
1508
|
networkLogo: s,
|
|
1362
|
-
assetBaseUrl:
|
|
1509
|
+
assetBaseUrl: l,
|
|
1363
1510
|
amount: i,
|
|
1364
|
-
amountPlaceholder:
|
|
1365
|
-
usdValue:
|
|
1366
|
-
balance:
|
|
1367
|
-
onOpenToken:
|
|
1368
|
-
onInputChange:
|
|
1369
|
-
onKeyDown:
|
|
1370
|
-
amountToneClassName:
|
|
1371
|
-
amountRef:
|
|
1372
|
-
readOnly:
|
|
1373
|
-
quickActions:
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1511
|
+
amountPlaceholder: u = "0.0",
|
|
1512
|
+
usdValue: p,
|
|
1513
|
+
balance: g,
|
|
1514
|
+
onOpenToken: C,
|
|
1515
|
+
onInputChange: I,
|
|
1516
|
+
onKeyDown: k,
|
|
1517
|
+
amountToneClassName: m = "dw-text-[var(--dw-fg)]",
|
|
1518
|
+
amountRef: y,
|
|
1519
|
+
readOnly: v = !1,
|
|
1520
|
+
quickActions: $,
|
|
1521
|
+
tokenLocked: D = !1
|
|
1522
|
+
} = e;
|
|
1523
|
+
return /* @__PURE__ */ A("div", { className: "dw-widget-section dw-relative dw-flex dw-flex-col dw-w-full dw-min-h-[91px] dw-px-4 dw-py-3", children: [
|
|
1524
|
+
/* @__PURE__ */ A("div", { className: "dw-flex dw-items-start dw-justify-between", children: [
|
|
1525
|
+
/* @__PURE__ */ A("div", { className: "dw-flex dw-flex-col dw-gap-2", children: [
|
|
1378
1526
|
/* @__PURE__ */ d(
|
|
1379
1527
|
"h6",
|
|
1380
1528
|
{
|
|
1381
1529
|
className: `dw-font-normal dw-text-[11px] ${n === "danger" ? "dw-text-[var(--dw-danger)]" : "dw-text-[var(--dw-success)]"}`,
|
|
1382
|
-
children:
|
|
1530
|
+
children: t
|
|
1383
1531
|
}
|
|
1384
1532
|
),
|
|
1385
|
-
/* @__PURE__ */
|
|
1533
|
+
/* @__PURE__ */ A(
|
|
1386
1534
|
"button",
|
|
1387
1535
|
{
|
|
1388
1536
|
type: "button",
|
|
1389
|
-
className:
|
|
1390
|
-
onClick:
|
|
1537
|
+
className: `dw-flex dw-items-center dw-gap-2 ${D ? "dw-cursor-not-allowed dw-opacity-60" : "dw-cursor-pointer"}`,
|
|
1538
|
+
onClick: C,
|
|
1539
|
+
disabled: D,
|
|
1391
1540
|
children: [
|
|
1392
1541
|
/* @__PURE__ */ d(
|
|
1393
|
-
|
|
1542
|
+
on,
|
|
1394
1543
|
{
|
|
1395
1544
|
token: r,
|
|
1396
1545
|
networkLogo: s,
|
|
1397
|
-
assetBaseUrl:
|
|
1546
|
+
assetBaseUrl: l,
|
|
1398
1547
|
sizeClassName: "dw-w-[28px] dw-h-[28px]",
|
|
1399
1548
|
badgeClassName: "dw-w-[10px] dw-h-[10px]"
|
|
1400
1549
|
}
|
|
1401
1550
|
),
|
|
1402
1551
|
/* @__PURE__ */ d("p", { className: "dw-font-normal dw-text-[13px] dw-text-[var(--dw-fg)]", children: (r == null ? void 0 : r.symbol) ?? "Select" }),
|
|
1403
|
-
/* @__PURE__ */ d("span", { className: "dw-text-[10px] dw-text-[var(--dw-text-subtle)]", children: "▼" })
|
|
1552
|
+
/* @__PURE__ */ d("span", { className: "dw-text-[10px] dw-text-[var(--dw-text-subtle)]", children: D ? "LOCK" : "▼" })
|
|
1404
1553
|
]
|
|
1405
1554
|
}
|
|
1406
1555
|
)
|
|
1407
1556
|
] }),
|
|
1408
|
-
/* @__PURE__ */
|
|
1409
|
-
|
|
1557
|
+
/* @__PURE__ */ A("div", { className: "dw-flex dw-flex-col dw-items-end dw-min-w-0", children: [
|
|
1558
|
+
v ? /* @__PURE__ */ d(
|
|
1410
1559
|
"p",
|
|
1411
1560
|
{
|
|
1412
|
-
ref:
|
|
1413
|
-
className: `dw-font-normal dw-text-[20px] dw-min-w-[70px] dw-max-w-[124px] dw-text-right dw-truncate ${
|
|
1414
|
-
children: i ||
|
|
1561
|
+
ref: y,
|
|
1562
|
+
className: `dw-font-normal dw-text-[20px] dw-min-w-[70px] dw-max-w-[124px] dw-text-right dw-truncate ${m}`,
|
|
1563
|
+
children: i || u
|
|
1415
1564
|
}
|
|
1416
1565
|
) : /* @__PURE__ */ d(
|
|
1417
1566
|
"input",
|
|
1418
1567
|
{
|
|
1419
1568
|
type: "text",
|
|
1420
|
-
placeholder:
|
|
1569
|
+
placeholder: u,
|
|
1421
1570
|
value: i,
|
|
1422
|
-
onChange: (
|
|
1423
|
-
onKeyDown:
|
|
1424
|
-
className: `dw-h-[28px] dw-w-[124px] dw-font-normal dw-text-right dw-bg-transparent dw-outline-none dw-border-none dw-text-[20px] ${
|
|
1571
|
+
onChange: (T) => I == null ? void 0 : I(T.target.value),
|
|
1572
|
+
onKeyDown: k,
|
|
1573
|
+
className: `dw-h-[28px] dw-w-[124px] dw-font-normal dw-text-right dw-bg-transparent dw-outline-none dw-border-none dw-text-[20px] ${m}`
|
|
1425
1574
|
}
|
|
1426
1575
|
),
|
|
1427
|
-
/* @__PURE__ */ d("p", { className: "dw-mt-1 dw-text-[10px] dw-text-[var(--dw-text-subtle)]", children:
|
|
1576
|
+
/* @__PURE__ */ d("p", { className: "dw-mt-1 dw-text-[10px] dw-text-[var(--dw-text-subtle)]", children: p })
|
|
1428
1577
|
] })
|
|
1429
1578
|
] }),
|
|
1430
|
-
/* @__PURE__ */ d("div", { className: "dw-w-full dw-flex dw-items-center dw-justify-between dw-mt-2 dw-min-h-[12px]", children: /* @__PURE__ */
|
|
1431
|
-
/* @__PURE__ */ d("p", { className: "dw-font-normal dw-text-[10px] dw-text-[var(--dw-text-subtle)]", children:
|
|
1432
|
-
|
|
1579
|
+
/* @__PURE__ */ d("div", { className: "dw-w-full dw-flex dw-items-center dw-justify-between dw-mt-2 dw-min-h-[12px]", children: /* @__PURE__ */ A("div", { className: "dw-flex dw-gap-2 dw-items-center dw-min-w-0", children: [
|
|
1580
|
+
/* @__PURE__ */ d("p", { className: "dw-font-normal dw-text-[10px] dw-text-[var(--dw-text-subtle)]", children: g }),
|
|
1581
|
+
$
|
|
1433
1582
|
] }) })
|
|
1434
1583
|
] });
|
|
1435
1584
|
}
|
|
1436
|
-
function
|
|
1585
|
+
function Oe(e) {
|
|
1437
1586
|
return /* @__PURE__ */ d(
|
|
1438
1587
|
"button",
|
|
1439
1588
|
{
|
|
1440
1589
|
type: "button",
|
|
1441
1590
|
className: "dw-font-normal dw-text-[10px] dw-text-[var(--dw-fg)] dw-cursor-pointer hover:dw-text-[var(--dw-text-subtle)]",
|
|
1442
|
-
onClick:
|
|
1443
|
-
children:
|
|
1591
|
+
onClick: e.onClick,
|
|
1592
|
+
children: e.label
|
|
1444
1593
|
}
|
|
1445
1594
|
);
|
|
1446
1595
|
}
|
|
1447
|
-
function
|
|
1448
|
-
var
|
|
1596
|
+
function on(e) {
|
|
1597
|
+
var p;
|
|
1449
1598
|
const {
|
|
1450
|
-
token:
|
|
1599
|
+
token: t,
|
|
1451
1600
|
networkLogo: n,
|
|
1452
1601
|
assetBaseUrl: r,
|
|
1453
1602
|
sizeClassName: s = "dw-w-[28px] dw-h-[28px]",
|
|
1454
|
-
badgeClassName:
|
|
1455
|
-
} =
|
|
1456
|
-
if (!
|
|
1603
|
+
badgeClassName: l = "dw-w-[10px] dw-h-[10px]"
|
|
1604
|
+
} = e;
|
|
1605
|
+
if (!t)
|
|
1457
1606
|
return /* @__PURE__ */ d(
|
|
1458
1607
|
"div",
|
|
1459
1608
|
{
|
|
@@ -1461,28 +1610,28 @@ function Jt(t) {
|
|
|
1461
1610
|
children: /* @__PURE__ */ d("span", { className: "dw-text-[10px] dw-font-normal dw-text-[var(--dw-fg)]", children: "?" })
|
|
1462
1611
|
}
|
|
1463
1612
|
);
|
|
1464
|
-
const i =
|
|
1465
|
-
return /* @__PURE__ */
|
|
1613
|
+
const i = me(t.imageUrl, r), u = me(n, r);
|
|
1614
|
+
return /* @__PURE__ */ A("div", { className: "dw-relative", children: [
|
|
1466
1615
|
/* @__PURE__ */ d(
|
|
1467
1616
|
"div",
|
|
1468
1617
|
{
|
|
1469
1618
|
className: `${s} dw-rounded-full dw-bg-cover dw-flex dw-items-center dw-justify-center dw-border dw-border-[var(--dw-border)] dw-bg-[var(--dw-surface-hover)]`,
|
|
1470
1619
|
style: { backgroundImage: i ? `url(${i})` : "none" },
|
|
1471
|
-
children: !i && /* @__PURE__ */ d("span", { className: "dw-text-[10px] dw-font-normal dw-text-[var(--dw-fg)]", children: ((
|
|
1620
|
+
children: !i && /* @__PURE__ */ d("span", { className: "dw-text-[10px] dw-font-normal dw-text-[var(--dw-fg)]", children: ((p = t.symbol[0]) == null ? void 0 : p.toUpperCase()) ?? "?" })
|
|
1472
1621
|
}
|
|
1473
1622
|
),
|
|
1474
|
-
|
|
1623
|
+
u && /* @__PURE__ */ d(
|
|
1475
1624
|
"div",
|
|
1476
1625
|
{
|
|
1477
|
-
className: `dw-absolute dw--bottom-0.5 dw--left-0.5 ${
|
|
1478
|
-
style: { backgroundImage: `url(${
|
|
1626
|
+
className: `dw-absolute dw--bottom-0.5 dw--left-0.5 ${l} dw-rounded-full dw-bg-cover dw-border dw-border-[var(--dw-surface)]`,
|
|
1627
|
+
style: { backgroundImage: `url(${u})` }
|
|
1479
1628
|
}
|
|
1480
1629
|
)
|
|
1481
1630
|
] });
|
|
1482
1631
|
}
|
|
1483
|
-
function
|
|
1484
|
-
return /* @__PURE__ */
|
|
1485
|
-
/* @__PURE__ */
|
|
1632
|
+
function sn() {
|
|
1633
|
+
return /* @__PURE__ */ A("div", { className: "dw-flex dw-flex-row dw-justify-center dw-items-center dw-w-[14px] dw-h-[14px] dw-gap-0", children: [
|
|
1634
|
+
/* @__PURE__ */ A(
|
|
1486
1635
|
"svg",
|
|
1487
1636
|
{
|
|
1488
1637
|
className: "dw-w-[7px] dw-h-[10px] dw-flex-shrink-0 dw-transition-[transform] dw-duration-200 group-hover:dw-translate-y-[-1px] dw-text-[var(--dw-fg)]",
|
|
@@ -1506,7 +1655,7 @@ function Gt() {
|
|
|
1506
1655
|
]
|
|
1507
1656
|
}
|
|
1508
1657
|
),
|
|
1509
|
-
/* @__PURE__ */
|
|
1658
|
+
/* @__PURE__ */ A(
|
|
1510
1659
|
"svg",
|
|
1511
1660
|
{
|
|
1512
1661
|
className: "dw-w-[7px] dw-h-[10px] dw-flex-shrink-0 dw-transition-[transform] dw-duration-200 group-hover:dw-translate-y-[1px] dw-text-[var(--dw-fg)]",
|
|
@@ -1540,7 +1689,7 @@ function Gt() {
|
|
|
1540
1689
|
)
|
|
1541
1690
|
] });
|
|
1542
1691
|
}
|
|
1543
|
-
function
|
|
1692
|
+
function dn() {
|
|
1544
1693
|
return /* @__PURE__ */ d("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ d(
|
|
1545
1694
|
"path",
|
|
1546
1695
|
{
|
|
@@ -1552,7 +1701,7 @@ function _t() {
|
|
|
1552
1701
|
}
|
|
1553
1702
|
) });
|
|
1554
1703
|
}
|
|
1555
|
-
function
|
|
1704
|
+
function ln() {
|
|
1556
1705
|
return /* @__PURE__ */ d("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ d(
|
|
1557
1706
|
"path",
|
|
1558
1707
|
{
|
|
@@ -1564,213 +1713,216 @@ function Xt() {
|
|
|
1564
1713
|
}
|
|
1565
1714
|
) });
|
|
1566
1715
|
}
|
|
1567
|
-
const
|
|
1568
|
-
function
|
|
1716
|
+
const an = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAHaSURBVHgB7Zj/dYIwEMcPX/+vGzRuYDewG3QD7QS1G3SDugF0go4AG+gG4ASywfUi4XnEBAkJ4h983ruXQMjlm19ADuDBicARRJxTMgdHoigqIDRSDNmWLCbL0Z+YTEAIyNE72QmHYd1VR2QR90nJzlKnVOaK0K7faNozcEVOgdbbnOybbInV+uuF8pszv/su9SKDo5iSjbosyF6pp6WtUXBDkP3BZZO5j6LWy5VWJkfhB8NsmHp24s4dVdNYc9LK1jjcppEYN86Tds3X2IGPHCWJoX4B/TC9SxNq59g65fTAhvUoZvdTbE7LCj02jPI5V35y5ju9VWnLHt4xRxwBAcHrt0aj4zPteV5Y79wlu5eF/mQpfxm7teLlM7iNYPkChuHI8q0jaEJYHIWktLTXSeA9sH46H0WglUmgL5NAXyaBvkwCfZkE+qIL5N9Erx/SUOgCDyy/Dv1z2oeGQHUeqEXKEZS/4C8wIqY1+MXyAi5nZMndp/1KoBrFD8vzzzAMguULXmDcxSQyoWRB9tviKCR8GRXgwtinuq5O0rHOxZ0irFjFaEyH6r6hOFuUdtH7WIvNqENoZMxnA75gtV5kDGWPYcixij0KW5vOQXRNcK+A+rnhIYLqY/APHpl3hlZpXEMAAAAASUVORK5CYII=", cn = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAERSURBVHgB7dShDoMwEAbgK0EgJiYmEAgEAjGx93+KCR4AMTkxMYEgYXdJSbqOo4WVgrg/uRRo034pTQEkEolk3yiInGEYMmyuWNS2SqmH2Z9AxGjMDeuElWKV9phoIAOTGZ972APEYDqsuz128zM0h8Hz00FMEGLorIwH2InZFKQxtDOpL2Yz0FoMJeEm1P8+KoaiJiassCn0K11cLUTCUKZ2qDCeS1ykhEgYDvSy3p2oUBgO1GC9wRMVEkNRzCI0Od0fZ6vr60zhuBybKhSGBRkL1tjkMIHSmNrqo51t1mKcoBnUE+sCvxjamR7+iNfFyKCCY7xBDlQwzCIQgwqKWQzSqPEmp/uqCYmRSCSSI+QD+pyUWCGG+FwAAAAASUVORK5CYII=", wn = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAwCAYAAAAhOEsMAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAABZSURBVHgB7c7RCQAgCEVRa5JGbONGKT8KgtQsCPp4FwQRDkh0WRhL5eigSC/jZxJPqVOnqLiggNIWSqjfdaghE1pIhTskQg9aoBdJMHvQAidsIoQQQgj9VgNcp//kKP+JUgAAAABJRU5ErkJggg==";
|
|
1717
|
+
function rt(e) {
|
|
1569
1718
|
const {
|
|
1570
|
-
mode:
|
|
1719
|
+
mode: t,
|
|
1571
1720
|
selectedNetworkId: n,
|
|
1572
1721
|
selectedToken: r,
|
|
1573
1722
|
excludeToken: s,
|
|
1574
|
-
getAllTokensForNetwork:
|
|
1723
|
+
getAllTokensForNetwork: l,
|
|
1575
1724
|
getNetworkById: i,
|
|
1576
|
-
onSelectToken:
|
|
1577
|
-
onSelectNetwork:
|
|
1578
|
-
onOpenNetworkSelector:
|
|
1579
|
-
onClose:
|
|
1580
|
-
assetBaseUrl:
|
|
1581
|
-
displayedNetworks:
|
|
1582
|
-
additionalNetworksCount:
|
|
1583
|
-
|
|
1725
|
+
onSelectToken: u,
|
|
1726
|
+
onSelectNetwork: p,
|
|
1727
|
+
onOpenNetworkSelector: g,
|
|
1728
|
+
onClose: C,
|
|
1729
|
+
assetBaseUrl: I,
|
|
1730
|
+
displayedNetworks: k,
|
|
1731
|
+
additionalNetworksCount: m,
|
|
1732
|
+
networkSelectionLocked: y = !1
|
|
1733
|
+
} = e, [v, $] = B(""), [D, T] = B(
|
|
1584
1734
|
/* @__PURE__ */ new Set()
|
|
1585
|
-
),
|
|
1586
|
-
(
|
|
1587
|
-
const
|
|
1588
|
-
return
|
|
1735
|
+
), O = M(
|
|
1736
|
+
(c) => {
|
|
1737
|
+
const h = i(c.chainId);
|
|
1738
|
+
return h ? h.chainType === "SVM" ? c.symbol === "SOL" : h.chainType === "MVM" ? c.symbol === "SUI" : c.contractAddress === Kt : !1;
|
|
1589
1739
|
},
|
|
1590
1740
|
[i]
|
|
1591
|
-
),
|
|
1592
|
-
(
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
const
|
|
1597
|
-
return
|
|
1741
|
+
), K = M(
|
|
1742
|
+
(c, h) => {
|
|
1743
|
+
h.stopPropagation(), navigator.clipboard.writeText(c).then(() => {
|
|
1744
|
+
T((b) => new Set(b).add(c)), setTimeout(() => {
|
|
1745
|
+
T((b) => {
|
|
1746
|
+
const N = new Set(b);
|
|
1747
|
+
return N.delete(c), N;
|
|
1598
1748
|
});
|
|
1599
1749
|
}, 2e3);
|
|
1600
1750
|
}).catch(() => console.error("Failed to copy to clipboard"));
|
|
1601
1751
|
},
|
|
1602
1752
|
[]
|
|
1603
|
-
),
|
|
1604
|
-
var
|
|
1605
|
-
const
|
|
1606
|
-
if (!
|
|
1607
|
-
const
|
|
1608
|
-
if (!
|
|
1609
|
-
return
|
|
1610
|
-
(
|
|
1753
|
+
), L = ue(() => {
|
|
1754
|
+
var N;
|
|
1755
|
+
const c = n ?? ((N = k[0]) == null ? void 0 : N.id);
|
|
1756
|
+
if (!c) return [];
|
|
1757
|
+
const h = l(c);
|
|
1758
|
+
if (!v.trim())
|
|
1759
|
+
return h.filter(
|
|
1760
|
+
(o) => !s || !(o.contractAddress === s.contractAddress && o.chainId === s.chainId)
|
|
1611
1761
|
);
|
|
1612
|
-
const
|
|
1613
|
-
return
|
|
1614
|
-
(
|
|
1615
|
-
var
|
|
1616
|
-
return (((
|
|
1762
|
+
const b = v.toLowerCase();
|
|
1763
|
+
return h.filter(
|
|
1764
|
+
(o) => {
|
|
1765
|
+
var E, V;
|
|
1766
|
+
return (((E = o.symbol) == null ? void 0 : E.toLowerCase().includes(b)) || ((V = o.contractAddress) == null ? void 0 : V.toLowerCase().includes(b))) && (!s || !(o.contractAddress === s.contractAddress && o.chainId === s.chainId));
|
|
1617
1767
|
}
|
|
1618
1768
|
);
|
|
1619
1769
|
}, [
|
|
1620
1770
|
n,
|
|
1621
|
-
|
|
1622
|
-
|
|
1771
|
+
l,
|
|
1772
|
+
v,
|
|
1623
1773
|
s,
|
|
1624
|
-
|
|
1774
|
+
k
|
|
1625
1775
|
]);
|
|
1626
|
-
return /* @__PURE__ */ d("div", { className: "dw-popup-backdrop dw-absolute dw-top-0 dw-left-1/2 dw--translate-x-1/2 dw-max-h-[420px] dw-h-full dw-z-50 dw-flex dw-items-start dw-justify-center", children: /* @__PURE__ */
|
|
1776
|
+
return /* @__PURE__ */ d("div", { className: "dw-popup-backdrop dw-absolute dw-top-0 dw-left-1/2 dw--translate-x-1/2 dw-max-h-[420px] dw-h-full dw-z-50 dw-flex dw-items-start dw-justify-center", children: /* @__PURE__ */ A(
|
|
1627
1777
|
"div",
|
|
1628
1778
|
{
|
|
1629
1779
|
className: "dw-modal-surface dw-popup-content dw-w-[304px] dw-h-full dw-flex dw-flex-col dw-rounded-[var(--dw-radius)] dw-p-3 dw-overflow-hidden",
|
|
1630
|
-
onClick: (
|
|
1780
|
+
onClick: (c) => c.stopPropagation(),
|
|
1631
1781
|
children: [
|
|
1632
|
-
/* @__PURE__ */
|
|
1633
|
-
/* @__PURE__ */ d("h3", { className: "dw-text-[14px] dw-font-normal dw-text-[var(--dw-fg)]", children:
|
|
1782
|
+
/* @__PURE__ */ A("div", { className: "dw-flex dw-items-center dw-justify-between", children: [
|
|
1783
|
+
/* @__PURE__ */ d("h3", { className: "dw-text-[14px] dw-font-normal dw-text-[var(--dw-fg)]", children: t === "sell" ? "Exchange from" : "Exchange to" }),
|
|
1634
1784
|
/* @__PURE__ */ d(
|
|
1635
1785
|
"button",
|
|
1636
1786
|
{
|
|
1637
1787
|
type: "button",
|
|
1638
1788
|
className: "dw-icon-button dw-w-4 dw-h-4 dw-rounded-[4px] dw-opacity-70 dw-cursor-pointer",
|
|
1639
|
-
onClick:
|
|
1789
|
+
onClick: C,
|
|
1640
1790
|
"aria-label": "Close",
|
|
1641
|
-
children: /* @__PURE__ */ d(
|
|
1791
|
+
children: /* @__PURE__ */ d(un, {})
|
|
1642
1792
|
}
|
|
1643
1793
|
)
|
|
1644
1794
|
] }),
|
|
1645
|
-
/* @__PURE__ */
|
|
1646
|
-
|
|
1795
|
+
/* @__PURE__ */ A("div", { className: "dw-flex dw-gap-1 dw-mt-3 dw-flex-wrap", children: [
|
|
1796
|
+
k.map((c) => /* @__PURE__ */ d(
|
|
1647
1797
|
"button",
|
|
1648
1798
|
{
|
|
1649
1799
|
type: "button",
|
|
1650
|
-
className: `dw-w-[34px] dw-h-[34px] dw-flex dw-items-center dw-justify-center dw-border dw-rounded-[6px] dw-transition ${n ===
|
|
1651
|
-
onClick: () =>
|
|
1652
|
-
title:
|
|
1653
|
-
|
|
1800
|
+
className: `dw-w-[34px] dw-h-[34px] dw-flex dw-items-center dw-justify-center dw-border dw-rounded-[6px] dw-transition ${n === c.id ? "dw-bg-[var(--dw-surface-hover)] dw-border-[var(--dw-accent)]" : "dw-bg-[var(--dw-surface-alt)] dw-border-[var(--dw-border)] hover:dw-bg-[var(--dw-surface-hover)]"} ${y ? "dw-cursor-not-allowed dw-opacity-50" : ""}`,
|
|
1801
|
+
onClick: () => p(c),
|
|
1802
|
+
title: c.name,
|
|
1803
|
+
disabled: y,
|
|
1804
|
+
children: c.logoURI && /* @__PURE__ */ d(
|
|
1654
1805
|
"img",
|
|
1655
1806
|
{
|
|
1656
|
-
src:
|
|
1807
|
+
src: me(c.logoURI, I),
|
|
1657
1808
|
alt: "",
|
|
1658
1809
|
className: "dw-w-5 dw-h-5 dw-object-cover"
|
|
1659
1810
|
}
|
|
1660
1811
|
)
|
|
1661
1812
|
},
|
|
1662
|
-
|
|
1813
|
+
c.id
|
|
1663
1814
|
)),
|
|
1664
|
-
|
|
1815
|
+
m > 0 && /* @__PURE__ */ d(
|
|
1665
1816
|
"button",
|
|
1666
1817
|
{
|
|
1667
1818
|
type: "button",
|
|
1668
|
-
className:
|
|
1669
|
-
onClick:
|
|
1819
|
+
className: `dw-min-w-[34px] dw-h-[34px] dw-px-2 dw-flex dw-items-center dw-justify-center dw-rounded-[6px] dw-border dw-border-[var(--dw-border)] dw-bg-[var(--dw-surface-alt)] hover:dw-bg-[var(--dw-surface-hover)] dw-transition ${y ? "dw-cursor-not-allowed dw-opacity-50" : "dw-cursor-pointer"}`,
|
|
1820
|
+
onClick: g,
|
|
1670
1821
|
title: "More networks",
|
|
1671
|
-
|
|
1672
|
-
|
|
1822
|
+
disabled: y,
|
|
1823
|
+
children: /* @__PURE__ */ A("p", { className: "dw-font-normal dw-text-[11px] dw-text-[var(--dw-fg)]", children: [
|
|
1824
|
+
m,
|
|
1673
1825
|
"+"
|
|
1674
1826
|
] })
|
|
1675
1827
|
}
|
|
1676
1828
|
)
|
|
1677
1829
|
] }),
|
|
1678
|
-
/* @__PURE__ */
|
|
1830
|
+
/* @__PURE__ */ A("div", { className: "dw-field-shell dw-flex dw-items-center dw-gap-2 dw-h-[34px] dw-mt-3 dw-rounded-[6px] dw-px-3", children: [
|
|
1679
1831
|
/* @__PURE__ */ d(
|
|
1680
1832
|
"input",
|
|
1681
1833
|
{
|
|
1682
1834
|
type: "text",
|
|
1683
1835
|
placeholder: "Search by name or contract address",
|
|
1684
|
-
value:
|
|
1685
|
-
onChange: (
|
|
1836
|
+
value: v,
|
|
1837
|
+
onChange: (c) => $(c.target.value),
|
|
1686
1838
|
className: "dw-flex-1 dw-h-5 dw-font-normal dw-text-[11px] dw-text-[var(--dw-fg)] dw-bg-transparent dw-outline-none dw-border-none"
|
|
1687
1839
|
}
|
|
1688
1840
|
),
|
|
1689
|
-
/* @__PURE__ */ d(
|
|
1841
|
+
/* @__PURE__ */ d(fn, {})
|
|
1690
1842
|
] }),
|
|
1691
|
-
/* @__PURE__ */
|
|
1843
|
+
/* @__PURE__ */ A("div", { className: "dw-flex dw-items-center dw-justify-between dw-mt-2.5 dw-px-0.5", children: [
|
|
1692
1844
|
/* @__PURE__ */ d("p", { className: "dw-font-normal dw-text-[11px] dw-text-[var(--dw-text-subtle)]", children: "Token list" }),
|
|
1693
1845
|
/* @__PURE__ */ d("p", { className: "dw-font-normal dw-text-[11px] dw-text-[var(--dw-text-subtle)]", children: "Contracts" })
|
|
1694
1846
|
] }),
|
|
1695
|
-
/* @__PURE__ */ d("div", { className: "dw-widget-list dw-flex-1 dw-overflow-y-auto dw-mt-2 dw-pr-1 dw-flex dw-flex-col dw-gap-1", children:
|
|
1696
|
-
var
|
|
1697
|
-
const
|
|
1698
|
-
return /* @__PURE__ */
|
|
1847
|
+
/* @__PURE__ */ d("div", { className: "dw-widget-list dw-flex-1 dw-overflow-y-auto dw-mt-2 dw-pr-1 dw-flex dw-flex-col dw-gap-1", children: L.map((c) => {
|
|
1848
|
+
var J;
|
|
1849
|
+
const h = i(c.chainId), N = `${(h == null ? void 0 : h.explorerUrl) ?? "https://etherscan.io/token/"}${c.contractAddress}`, o = c.contractAddress.length > 10 ? `${c.contractAddress.slice(0, 4)}…${c.contractAddress.slice(-3)}` : c.contractAddress, E = D.has(c.contractAddress), V = !O(c);
|
|
1850
|
+
return /* @__PURE__ */ A(
|
|
1699
1851
|
"button",
|
|
1700
1852
|
{
|
|
1701
1853
|
type: "button",
|
|
1702
|
-
className: `dw-w-full dw-min-h-[48px] dw-flex dw-items-center dw-justify-between dw-rounded-[6px] dw-px-3 dw-py-2 dw-text-left dw-transition dw-cursor-pointer dw-border ${(r == null ? void 0 : r.contractAddress) ===
|
|
1703
|
-
onClick: () =>
|
|
1854
|
+
className: `dw-w-full dw-min-h-[48px] dw-flex dw-items-center dw-justify-between dw-rounded-[6px] dw-px-3 dw-py-2 dw-text-left dw-transition dw-cursor-pointer dw-border ${(r == null ? void 0 : r.contractAddress) === c.contractAddress && (r == null ? void 0 : r.chainId) === c.chainId ? "dw-bg-[var(--dw-surface-hover)] dw-border-[var(--dw-accent)]" : "dw-bg-transparent dw-border-transparent hover:dw-bg-[var(--dw-surface-alt)] hover:dw-border-[var(--dw-border)]"}`,
|
|
1855
|
+
onClick: () => u(c),
|
|
1704
1856
|
children: [
|
|
1705
|
-
/* @__PURE__ */
|
|
1857
|
+
/* @__PURE__ */ A("div", { className: "dw-flex dw-items-center dw-gap-2 dw-min-w-0", children: [
|
|
1706
1858
|
/* @__PURE__ */ d(
|
|
1707
1859
|
"div",
|
|
1708
1860
|
{
|
|
1709
1861
|
className: "dw-w-[28px] dw-h-[28px] dw-rounded-full dw-flex dw-items-center dw-justify-center dw-bg-cover dw-bg-[var(--dw-surface-hover)] dw-border dw-border-[var(--dw-border)] dw-flex-shrink-0",
|
|
1710
1862
|
style: {
|
|
1711
|
-
backgroundImage:
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
) ? `url(${
|
|
1863
|
+
backgroundImage: me(
|
|
1864
|
+
c.imageUrl,
|
|
1865
|
+
I
|
|
1866
|
+
) ? `url(${me(c.imageUrl, I)})` : "none"
|
|
1715
1867
|
},
|
|
1716
|
-
children: !
|
|
1868
|
+
children: !me(c.imageUrl, I) && /* @__PURE__ */ d("span", { className: "dw-font-normal dw-text-[10px] dw-text-[var(--dw-fg)]", children: ((J = c.symbol[0]) == null ? void 0 : J.toUpperCase()) ?? "?" })
|
|
1717
1869
|
}
|
|
1718
1870
|
),
|
|
1719
|
-
/* @__PURE__ */
|
|
1720
|
-
/* @__PURE__ */ d("p", { className: "dw-font-normal dw-text-[12px] dw-text-[var(--dw-fg)] dw-truncate", children:
|
|
1721
|
-
|
|
1871
|
+
/* @__PURE__ */ A("div", { className: "dw-min-w-0", children: [
|
|
1872
|
+
/* @__PURE__ */ d("p", { className: "dw-font-normal dw-text-[12px] dw-text-[var(--dw-fg)] dw-truncate", children: c.symbol }),
|
|
1873
|
+
c.name && /* @__PURE__ */ d("p", { className: "dw-font-normal dw-text-[10px] dw-text-[var(--dw-text-subtle)] dw-truncate", children: c.name })
|
|
1722
1874
|
] })
|
|
1723
1875
|
] }),
|
|
1724
|
-
/* @__PURE__ */
|
|
1725
|
-
|
|
1876
|
+
/* @__PURE__ */ A("div", { className: "dw-flex dw-flex-col dw-items-end dw-gap-1 dw-flex-shrink-0", children: [
|
|
1877
|
+
V && /* @__PURE__ */ A("div", { className: "dw-flex dw-items-center dw-gap-2.5", children: [
|
|
1726
1878
|
/* @__PURE__ */ d(
|
|
1727
1879
|
"button",
|
|
1728
1880
|
{
|
|
1729
1881
|
type: "button",
|
|
1730
|
-
className: `dw-w-[12px] dw-h-[12px] dw-flex-shrink-0 dw-bg-cover dw-bg-no-repeat dw-cursor-pointer dw-transition-opacity hover:dw-opacity-100 ${
|
|
1882
|
+
className: `dw-w-[12px] dw-h-[12px] dw-flex-shrink-0 dw-bg-cover dw-bg-no-repeat dw-cursor-pointer dw-transition-opacity hover:dw-opacity-100 ${E ? "dw-opacity-100" : "dw-opacity-50"}`,
|
|
1731
1883
|
style: {
|
|
1732
|
-
backgroundImage: `url(${
|
|
1884
|
+
backgroundImage: `url(${E ? cn : an})`
|
|
1733
1885
|
},
|
|
1734
|
-
onClick: (
|
|
1886
|
+
onClick: (G) => K(c.contractAddress, G),
|
|
1735
1887
|
"aria-label": "Copy address"
|
|
1736
1888
|
}
|
|
1737
1889
|
),
|
|
1738
|
-
/* @__PURE__ */
|
|
1890
|
+
/* @__PURE__ */ A(
|
|
1739
1891
|
"a",
|
|
1740
1892
|
{
|
|
1741
|
-
href:
|
|
1893
|
+
href: N,
|
|
1742
1894
|
target: "_blank",
|
|
1743
1895
|
rel: "noopener noreferrer",
|
|
1744
1896
|
className: "dw-flex dw-items-center dw-gap-1 dw-font-normal dw-text-[10px] dw-text-[var(--dw-text-subtle)] hover:dw-text-[var(--dw-fg)] dw-transition-colors",
|
|
1745
|
-
onClick: (
|
|
1897
|
+
onClick: (G) => G.stopPropagation(),
|
|
1746
1898
|
children: [
|
|
1747
|
-
/* @__PURE__ */ d("span", { children:
|
|
1899
|
+
/* @__PURE__ */ d("span", { children: o }),
|
|
1748
1900
|
/* @__PURE__ */ d(
|
|
1749
1901
|
"span",
|
|
1750
1902
|
{
|
|
1751
1903
|
className: "dw-w-[6px] dw-h-[10px] dw-flex-shrink-0 dw-bg-cover dw-bg-no-repeat",
|
|
1752
|
-
style: { backgroundImage: `url(${
|
|
1904
|
+
style: { backgroundImage: `url(${wn})` }
|
|
1753
1905
|
}
|
|
1754
1906
|
)
|
|
1755
1907
|
]
|
|
1756
1908
|
}
|
|
1757
1909
|
)
|
|
1758
1910
|
] }),
|
|
1759
|
-
!
|
|
1911
|
+
!V && /* @__PURE__ */ d("p", { className: "dw-font-normal dw-text-[10px] dw-text-[var(--dw-text-subtle)]", children: "Native" })
|
|
1760
1912
|
] })
|
|
1761
1913
|
]
|
|
1762
1914
|
},
|
|
1763
|
-
`${
|
|
1915
|
+
`${c.chainId}-${c.contractAddress}`
|
|
1764
1916
|
);
|
|
1765
1917
|
}) })
|
|
1766
1918
|
]
|
|
1767
1919
|
}
|
|
1768
1920
|
) });
|
|
1769
1921
|
}
|
|
1770
|
-
function
|
|
1922
|
+
function un() {
|
|
1771
1923
|
return /* @__PURE__ */ d("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ d("path", { d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" }) });
|
|
1772
1924
|
}
|
|
1773
|
-
function
|
|
1925
|
+
function fn() {
|
|
1774
1926
|
return /* @__PURE__ */ d("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ d(
|
|
1775
1927
|
"path",
|
|
1776
1928
|
{
|
|
@@ -1782,19 +1934,19 @@ function rn() {
|
|
|
1782
1934
|
}
|
|
1783
1935
|
) });
|
|
1784
1936
|
}
|
|
1785
|
-
function
|
|
1786
|
-
const { networks:
|
|
1787
|
-
if (!
|
|
1788
|
-
const
|
|
1789
|
-
return
|
|
1790
|
-
}, [
|
|
1791
|
-
return /* @__PURE__ */ d("div", { className: "dw-popup-backdrop dw-absolute dw-top-0 dw-left-1/2 dw--translate-x-1/2 dw-max-h-[420px] dw-h-full dw-z-[60] dw-flex dw-items-start dw-justify-center", children: /* @__PURE__ */
|
|
1937
|
+
function ot(e) {
|
|
1938
|
+
const { networks: t, onSelectNetwork: n, onClose: r, assetBaseUrl: s } = e, [l, i] = B(""), u = ue(() => {
|
|
1939
|
+
if (!l.trim()) return t;
|
|
1940
|
+
const p = l.toLowerCase();
|
|
1941
|
+
return t.filter((g) => g.name.toLowerCase().includes(p));
|
|
1942
|
+
}, [t, l]);
|
|
1943
|
+
return /* @__PURE__ */ d("div", { className: "dw-popup-backdrop dw-absolute dw-top-0 dw-left-1/2 dw--translate-x-1/2 dw-max-h-[420px] dw-h-full dw-z-[60] dw-flex dw-items-start dw-justify-center", children: /* @__PURE__ */ A(
|
|
1792
1944
|
"div",
|
|
1793
1945
|
{
|
|
1794
1946
|
className: "dw-modal-surface dw-popup-content dw-w-[304px] dw-h-full dw-flex dw-flex-col dw-rounded-[var(--dw-radius)] dw-p-3 dw-overflow-hidden",
|
|
1795
|
-
onClick: (
|
|
1947
|
+
onClick: (p) => p.stopPropagation(),
|
|
1796
1948
|
children: [
|
|
1797
|
-
/* @__PURE__ */
|
|
1949
|
+
/* @__PURE__ */ A("div", { className: "dw-flex dw-items-center dw-justify-between", children: [
|
|
1798
1950
|
/* @__PURE__ */ d("h3", { className: "dw-text-[14px] dw-font-normal dw-text-[var(--dw-fg)]", children: "Select ecosystem" }),
|
|
1799
1951
|
/* @__PURE__ */ d(
|
|
1800
1952
|
"button",
|
|
@@ -1803,52 +1955,52 @@ function Xe(t) {
|
|
|
1803
1955
|
className: "dw-icon-button dw-w-4 dw-h-4 dw-rounded-[4px] dw-opacity-70 dw-cursor-pointer",
|
|
1804
1956
|
onClick: r,
|
|
1805
1957
|
"aria-label": "Close",
|
|
1806
|
-
children: /* @__PURE__ */ d(
|
|
1958
|
+
children: /* @__PURE__ */ d(pn, {})
|
|
1807
1959
|
}
|
|
1808
1960
|
)
|
|
1809
1961
|
] }),
|
|
1810
|
-
/* @__PURE__ */
|
|
1962
|
+
/* @__PURE__ */ A("div", { className: "dw-field-shell dw-flex dw-items-center dw-gap-2 dw-h-[34px] dw-mt-3 dw-rounded-[6px] dw-px-3", children: [
|
|
1811
1963
|
/* @__PURE__ */ d(
|
|
1812
1964
|
"input",
|
|
1813
1965
|
{
|
|
1814
1966
|
type: "text",
|
|
1815
1967
|
placeholder: "Search by name",
|
|
1816
|
-
value:
|
|
1817
|
-
onChange: (
|
|
1968
|
+
value: l,
|
|
1969
|
+
onChange: (p) => i(p.target.value),
|
|
1818
1970
|
className: "dw-flex-1 dw-h-5 dw-font-normal dw-text-[11px] dw-text-[var(--dw-fg)] dw-bg-transparent dw-outline-none dw-border-none"
|
|
1819
1971
|
}
|
|
1820
1972
|
),
|
|
1821
|
-
/* @__PURE__ */ d(
|
|
1973
|
+
/* @__PURE__ */ d(hn, {})
|
|
1822
1974
|
] }),
|
|
1823
|
-
/* @__PURE__ */ d("div", { className: "dw-widget-list dw-flex-1 dw-overflow-y-auto dw-mt-3 dw-pr-1 dw-grid dw-grid-cols-2 dw-gap-1.5", children:
|
|
1975
|
+
/* @__PURE__ */ d("div", { className: "dw-widget-list dw-flex-1 dw-overflow-y-auto dw-mt-3 dw-pr-1 dw-grid dw-grid-cols-2 dw-gap-1.5", children: u.map((p) => /* @__PURE__ */ A(
|
|
1824
1976
|
"button",
|
|
1825
1977
|
{
|
|
1826
1978
|
type: "button",
|
|
1827
1979
|
className: "dw-w-full dw-min-h-[36px] dw-flex dw-items-center dw-gap-2 dw-rounded-[6px] dw-px-2.5 dw-py-2 dw-text-left dw-transition dw-cursor-pointer dw-bg-transparent dw-border dw-border-transparent hover:dw-bg-[var(--dw-surface-alt)] hover:dw-border-[var(--dw-border)]",
|
|
1828
|
-
onClick: () => n(
|
|
1980
|
+
onClick: () => n(p),
|
|
1829
1981
|
children: [
|
|
1830
1982
|
/* @__PURE__ */ d(
|
|
1831
1983
|
"div",
|
|
1832
1984
|
{
|
|
1833
1985
|
className: "dw-w-[18px] dw-h-[18px] dw-rounded-[4px] dw-flex-shrink-0 dw-bg-cover dw-bg-center",
|
|
1834
1986
|
style: {
|
|
1835
|
-
backgroundImage:
|
|
1987
|
+
backgroundImage: p.logoURI ? `url(${me(p.logoURI, s)})` : "none"
|
|
1836
1988
|
}
|
|
1837
1989
|
}
|
|
1838
1990
|
),
|
|
1839
|
-
/* @__PURE__ */ d("h6", { className: "dw-font-normal dw-text-[12px] dw-text-[var(--dw-fg)] dw-truncate", children:
|
|
1991
|
+
/* @__PURE__ */ d("h6", { className: "dw-font-normal dw-text-[12px] dw-text-[var(--dw-fg)] dw-truncate", children: p.name })
|
|
1840
1992
|
]
|
|
1841
1993
|
},
|
|
1842
|
-
|
|
1994
|
+
p.id
|
|
1843
1995
|
)) })
|
|
1844
1996
|
]
|
|
1845
1997
|
}
|
|
1846
1998
|
) });
|
|
1847
1999
|
}
|
|
1848
|
-
function
|
|
2000
|
+
function pn() {
|
|
1849
2001
|
return /* @__PURE__ */ d("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ d("path", { d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" }) });
|
|
1850
2002
|
}
|
|
1851
|
-
function
|
|
2003
|
+
function hn() {
|
|
1852
2004
|
return /* @__PURE__ */ d("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ d(
|
|
1853
2005
|
"path",
|
|
1854
2006
|
{
|
|
@@ -1860,94 +2012,94 @@ function sn() {
|
|
|
1860
2012
|
}
|
|
1861
2013
|
) });
|
|
1862
2014
|
}
|
|
1863
|
-
const
|
|
1864
|
-
function
|
|
2015
|
+
const mn = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAAmCAYAAACoPemuAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAIFSURBVHgB7Vf/VcMgEL5MYJxAnMBuIBvYDewIbtJukG5QnSB1AusEwQkaJzjvBF5ICg1Jaf/ie+979KUHHNwvDiAj47ooIDEQsaRhQXwhCvNbOCItURl+EvdFURzGFl0QBcxTSBIr4hGnoyGuQguvHcHKbFSOKCOIb8Qa02Bn1y6cTTCwP1+zvX4La56zihu0DsHMESFhMmvfvRKemk1ZEVcYcAv6XqK2CN9248z98gmzWbY4H7XZKOYWh3vL4dzCdxoaJHFJfAJtNh/YNGxmG1l7SIiodOExSUuKtJCRMY7kJcnC+KUEnbcezMh++Qtd4Bxu4qsm7Nc4rSzVeCbn8aKvqJNdxRtAJFAnyxRlqWEd7LpuSWqgXyoUdHlqWP1ZzuY4CenAaeh+qNgR4mpfLPbEb9CHUoP/+EDPcPokUqTYY0/S2LnBy1DjxLKE2i+3OPL0EUbBOl6Xf0ff4AS/jEEwXWD3EmWWhnegw12BDnmukQoyMsK4WkmyML7ai9IYv7xG+yZB5ygebeD4cDD8AB1EbWhBW1okTFcmRVmq0Fcv6ePOEWqskhhIltjlvArn9ZI+1Hb92JKkoN9+lRDfuvFct9YKM9fbS/jat0s6pN6pUd+2gDNAbf7lYN9NSHhuvbS9pIQZQO0WvRssAoL2OcPRJeC061agzfNDfIdbvUQzMhLiDyT6chuOT10RAAAAAElFTkSuQmCC";
|
|
2016
|
+
function gn(e) {
|
|
1865
2017
|
const {
|
|
1866
|
-
options:
|
|
2018
|
+
options: t,
|
|
1867
2019
|
selectedIndex: n,
|
|
1868
2020
|
customValue: r,
|
|
1869
2021
|
onSelectOption: s,
|
|
1870
|
-
onCustomChange:
|
|
2022
|
+
onCustomChange: l,
|
|
1871
2023
|
onSave: i,
|
|
1872
|
-
onClose:
|
|
1873
|
-
} =
|
|
1874
|
-
let
|
|
1875
|
-
|
|
1876
|
-
const
|
|
1877
|
-
|
|
1878
|
-
},
|
|
1879
|
-
let
|
|
2024
|
+
onClose: u
|
|
2025
|
+
} = e, [p, g] = B(r), C = (k) => {
|
|
2026
|
+
let m = k.target.value.replace(/,/g, ".");
|
|
2027
|
+
m.startsWith(".") && (m = "0" + m), m = m.replace(/[^0-9.]/g, "");
|
|
2028
|
+
const y = m.indexOf(".");
|
|
2029
|
+
y >= 0 && (m = m.slice(0, y + 1) + m.slice(y + 1).replace(/\./g, "")), m = m.slice(0, 4), g(m), l(m);
|
|
2030
|
+
}, I = () => {
|
|
2031
|
+
let k;
|
|
1880
2032
|
if (n !== null)
|
|
1881
|
-
|
|
1882
|
-
else if (
|
|
1883
|
-
|
|
2033
|
+
k = t[n];
|
|
2034
|
+
else if (p)
|
|
2035
|
+
k = p + "%";
|
|
1884
2036
|
else
|
|
1885
2037
|
return;
|
|
1886
2038
|
try {
|
|
1887
|
-
i(
|
|
1888
|
-
} catch (
|
|
1889
|
-
console.error(
|
|
2039
|
+
i(k), u();
|
|
2040
|
+
} catch (m) {
|
|
2041
|
+
console.error(m);
|
|
1890
2042
|
}
|
|
1891
2043
|
};
|
|
1892
|
-
return /* @__PURE__ */ d("div", { className: "dw-popup-backdrop dw-absolute dw-inset-0 dw-z-50 dw-flex dw-items-center dw-justify-center", children: /* @__PURE__ */
|
|
2044
|
+
return /* @__PURE__ */ d("div", { className: "dw-popup-backdrop dw-absolute dw-inset-0 dw-z-50 dw-flex dw-items-center dw-justify-center", children: /* @__PURE__ */ A(
|
|
1893
2045
|
"div",
|
|
1894
2046
|
{
|
|
1895
2047
|
className: "dw-modal-surface dw-popup-content dw-w-[304px] dw-flex dw-flex-col dw-rounded-[var(--dw-radius)] dw-p-3",
|
|
1896
|
-
onClick: (
|
|
2048
|
+
onClick: (k) => k.stopPropagation(),
|
|
1897
2049
|
children: [
|
|
1898
|
-
/* @__PURE__ */
|
|
2050
|
+
/* @__PURE__ */ A("div", { className: "dw-flex dw-items-center dw-justify-between", children: [
|
|
1899
2051
|
/* @__PURE__ */ d("h3", { className: "dw-font-normal dw-text-[14px] dw-text-[var(--dw-fg)]", children: "Settings" }),
|
|
1900
2052
|
/* @__PURE__ */ d(
|
|
1901
2053
|
"button",
|
|
1902
2054
|
{
|
|
1903
2055
|
type: "button",
|
|
1904
2056
|
className: "dw-icon-button dw-w-4 dw-h-4 dw-rounded-[4px] dw-opacity-70 dw-cursor-pointer",
|
|
1905
|
-
onClick:
|
|
2057
|
+
onClick: u,
|
|
1906
2058
|
"aria-label": "Close",
|
|
1907
|
-
children: /* @__PURE__ */ d(
|
|
2059
|
+
children: /* @__PURE__ */ d(kn, {})
|
|
1908
2060
|
}
|
|
1909
2061
|
)
|
|
1910
2062
|
] }),
|
|
1911
|
-
/* @__PURE__ */
|
|
2063
|
+
/* @__PURE__ */ A("div", { className: "dw-flex dw-items-center dw-gap-2 dw-mt-3", children: [
|
|
1912
2064
|
/* @__PURE__ */ d(
|
|
1913
2065
|
"img",
|
|
1914
2066
|
{
|
|
1915
|
-
src:
|
|
2067
|
+
src: mn,
|
|
1916
2068
|
alt: "",
|
|
1917
2069
|
className: "dw-w-[14px] dw-h-[14px] dw-object-cover"
|
|
1918
2070
|
}
|
|
1919
2071
|
),
|
|
1920
2072
|
/* @__PURE__ */ d("p", { className: "dw-font-normal dw-text-[12px] dw-text-[var(--dw-fg)]", children: "Slippage limit" })
|
|
1921
2073
|
] }),
|
|
1922
|
-
/* @__PURE__ */
|
|
1923
|
-
|
|
2074
|
+
/* @__PURE__ */ A("div", { className: "dw-flex dw-items-center dw-gap-1 dw-mt-3 dw-flex-wrap", children: [
|
|
2075
|
+
t.map((k, m) => /* @__PURE__ */ d(
|
|
1924
2076
|
"button",
|
|
1925
2077
|
{
|
|
1926
2078
|
type: "button",
|
|
1927
|
-
className: `dw-font-normal dw-text-[11px] dw-px-3 dw-py-1.5 dw-rounded-[6px] dw-border dw-transition ${n ===
|
|
1928
|
-
onClick: () => s(
|
|
1929
|
-
children:
|
|
2079
|
+
className: `dw-font-normal dw-text-[11px] dw-px-3 dw-py-1.5 dw-rounded-[6px] dw-border dw-transition ${n === m ? "dw-bg-[var(--dw-surface-hover)] dw-border-[var(--dw-accent)] dw-text-[var(--dw-fg)]" : "dw-bg-transparent dw-border-[var(--dw-border)] dw-text-[var(--dw-text-subtle)] hover:dw-bg-[var(--dw-surface-alt)] hover:dw-text-[var(--dw-fg)]"}`,
|
|
2080
|
+
onClick: () => s(m),
|
|
2081
|
+
children: k
|
|
1930
2082
|
},
|
|
1931
|
-
|
|
2083
|
+
k
|
|
1932
2084
|
)),
|
|
1933
|
-
/* @__PURE__ */
|
|
2085
|
+
/* @__PURE__ */ A(
|
|
1934
2086
|
"div",
|
|
1935
2087
|
{
|
|
1936
|
-
className: `dw-relative dw-w-[72px] dw-h-[30px] dw-flex dw-items-center dw-justify-center dw-rounded-[6px] dw-border ${n === null &&
|
|
2088
|
+
className: `dw-relative dw-w-[72px] dw-h-[30px] dw-flex dw-items-center dw-justify-center dw-rounded-[6px] dw-border ${n === null && p ? "dw-border-[var(--dw-accent)] dw-bg-[var(--dw-surface-hover)]" : "dw-border-[var(--dw-border)] dw-bg-[var(--dw-surface-alt)]"}`,
|
|
1937
2089
|
children: [
|
|
1938
2090
|
/* @__PURE__ */ d(
|
|
1939
2091
|
"input",
|
|
1940
2092
|
{
|
|
1941
2093
|
type: "text",
|
|
1942
2094
|
placeholder: "Custom",
|
|
1943
|
-
value:
|
|
1944
|
-
onChange:
|
|
1945
|
-
onFocus: () =>
|
|
2095
|
+
value: p,
|
|
2096
|
+
onChange: C,
|
|
2097
|
+
onFocus: () => l(""),
|
|
1946
2098
|
maxLength: 4,
|
|
1947
2099
|
className: "dw-w-10 dw-font-normal dw-text-[11px] dw-text-[var(--dw-fg)] dw-bg-transparent dw-border-none dw-outline-none dw-text-center"
|
|
1948
2100
|
}
|
|
1949
2101
|
),
|
|
1950
|
-
|
|
2102
|
+
p && /* @__PURE__ */ d("span", { className: "dw-absolute dw-right-2 dw-pointer-events-none dw-font-normal dw-text-[11px] dw-text-[var(--dw-fg)]", children: "%" })
|
|
1951
2103
|
]
|
|
1952
2104
|
}
|
|
1953
2105
|
)
|
|
@@ -1957,7 +2109,7 @@ function an(t) {
|
|
|
1957
2109
|
{
|
|
1958
2110
|
type: "button",
|
|
1959
2111
|
className: "dw-w-full dw-h-[34px] dw-mt-4 dw-bg-[var(--dw-accent)] dw-border dw-border-transparent dw-rounded-[6px] dw-font-normal dw-text-[12px] dw-text-white hover:dw-bg-[var(--dw-accent-hover)] dw-cursor-pointer",
|
|
1960
|
-
onClick:
|
|
2112
|
+
onClick: I,
|
|
1961
2113
|
children: "Save"
|
|
1962
2114
|
}
|
|
1963
2115
|
)
|
|
@@ -1965,53 +2117,129 @@ function an(t) {
|
|
|
1965
2117
|
}
|
|
1966
2118
|
) });
|
|
1967
2119
|
}
|
|
1968
|
-
function
|
|
2120
|
+
function kn() {
|
|
1969
2121
|
return /* @__PURE__ */ d("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ d("path", { d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" }) });
|
|
1970
2122
|
}
|
|
1971
|
-
function
|
|
1972
|
-
return
|
|
2123
|
+
function st(e) {
|
|
2124
|
+
return e === "EVM" ? at : e === "SVM" ? it : ct;
|
|
1973
2125
|
}
|
|
1974
|
-
function
|
|
1975
|
-
var
|
|
2126
|
+
function vn(e) {
|
|
2127
|
+
var de, oe, w, a, S, W, Q, z;
|
|
1976
2128
|
const {
|
|
1977
|
-
theme:
|
|
2129
|
+
theme: t = "dark",
|
|
1978
2130
|
vars: n,
|
|
1979
2131
|
className: r,
|
|
1980
2132
|
style: s,
|
|
1981
|
-
config:
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
2133
|
+
config: l,
|
|
2134
|
+
initialSellToken: i,
|
|
2135
|
+
initialBuyToken: u,
|
|
2136
|
+
initialSellNetworkId: p,
|
|
2137
|
+
initialBuyNetworkId: g,
|
|
2138
|
+
lockBuyToken: C = !1,
|
|
2139
|
+
lockSellToken: I = !1,
|
|
2140
|
+
lockBuyNetwork: k = !1,
|
|
2141
|
+
lockSellNetwork: m = !1,
|
|
2142
|
+
onApprove: y,
|
|
2143
|
+
onSwap: v,
|
|
2144
|
+
onQuote: $,
|
|
2145
|
+
onError: D,
|
|
2146
|
+
...T
|
|
2147
|
+
} = e, O = dt(t, n), q = {
|
|
2148
|
+
...lt(O),
|
|
1985
2149
|
...s
|
|
1986
|
-
},
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2150
|
+
}, L = l.assetBaseUrl ?? l.dataBaseUrl ?? l.apiBase ?? (typeof window < "u" ? window.location.origin : ""), [c, h] = B(null), [b, N] = B(null), o = Xt({
|
|
2151
|
+
apiBase: l.apiBase,
|
|
2152
|
+
initialSellToken: i,
|
|
2153
|
+
initialBuyToken: u,
|
|
2154
|
+
initialSellNetworkId: p,
|
|
2155
|
+
initialBuyNetworkId: g,
|
|
2156
|
+
lockBuyToken: C,
|
|
2157
|
+
lockSellToken: I,
|
|
2158
|
+
lockBuyNetwork: k,
|
|
2159
|
+
lockSellNetwork: m,
|
|
2160
|
+
onError: D
|
|
2161
|
+
}), E = X(""), V = ue(() => {
|
|
2162
|
+
var le;
|
|
2163
|
+
const f = o.networks, F = (le = o.networkSell) == null ? void 0 : le.id, P = f.slice(0, 6);
|
|
2164
|
+
if (!F || P.some((se) => se.id === F)) return P;
|
|
2165
|
+
const _ = f.find((se) => se.id === F);
|
|
2166
|
+
return _ ? [...P.slice(0, 5), _] : P;
|
|
2167
|
+
}, [o.networks, (de = o.networkSell) == null ? void 0 : de.id]), J = ue(() => {
|
|
2168
|
+
const f = new Set(V.map((F) => F.id));
|
|
2169
|
+
return o.networks.filter((F) => !f.has(F.id));
|
|
2170
|
+
}, [o.networks, V]), G = ue(() => {
|
|
2171
|
+
var le;
|
|
2172
|
+
const f = o.networks, F = (le = o.networkBuy) == null ? void 0 : le.id, P = f.slice(0, 6);
|
|
2173
|
+
if (!F || P.some((se) => se.id === F)) return P;
|
|
2174
|
+
const _ = f.find((se) => se.id === F);
|
|
2175
|
+
return _ ? [...P.slice(0, 5), _] : P;
|
|
2176
|
+
}, [o.networks, (oe = o.networkBuy) == null ? void 0 : oe.id]), ie = ue(() => {
|
|
2177
|
+
const f = new Set(G.map((F) => F.id));
|
|
2178
|
+
return o.networks.filter((F) => !f.has(F.id));
|
|
2179
|
+
}, [o.networks, G]), fe = (f) => Math.trunc(f * 1e6) / 1e6, ee = M(
|
|
2180
|
+
(f) => !o.networkSell || !o.networkBuy || !o.sellToken || !o.buyToken ? null : {
|
|
2181
|
+
action: f,
|
|
2182
|
+
sellNetwork: o.networkSell,
|
|
2183
|
+
buyNetwork: o.networkBuy,
|
|
2184
|
+
sellToken: o.sellToken,
|
|
2185
|
+
buyToken: o.buyToken,
|
|
2186
|
+
sellAmount: o.sellAmountForInput,
|
|
2187
|
+
buyAmount: o.buyAmountForInput,
|
|
2188
|
+
slippage: o.slippage.slippage,
|
|
2189
|
+
quote: o.quote,
|
|
2190
|
+
txData: o.txData,
|
|
2191
|
+
price: o.price,
|
|
2192
|
+
gasCostUSD: o.gasCostUSD
|
|
2193
|
+
},
|
|
2194
|
+
[o]
|
|
2195
|
+
);
|
|
2196
|
+
re(() => {
|
|
2197
|
+
o.quote || (E.current = "");
|
|
2198
|
+
}, [o.quote]), re(() => {
|
|
2199
|
+
var F, P;
|
|
2200
|
+
if (!$ || !o.quote || !o.networkSell || !o.networkBuy || !o.sellToken || !o.buyToken)
|
|
2201
|
+
return;
|
|
2202
|
+
const f = [
|
|
2203
|
+
o.networkSell.id,
|
|
2204
|
+
o.networkBuy.id,
|
|
2205
|
+
o.sellToken.contractAddress,
|
|
2206
|
+
o.buyToken.contractAddress,
|
|
2207
|
+
o.sellAmountForInput,
|
|
2208
|
+
o.buyAmountForInput,
|
|
2209
|
+
o.quote.inputAmount ?? "",
|
|
2210
|
+
o.quote.outputAmount ?? "",
|
|
2211
|
+
((F = o.txData) == null ? void 0 : F.to) ?? "",
|
|
2212
|
+
((P = o.txData) == null ? void 0 : P.data) ?? ""
|
|
2213
|
+
].join("|");
|
|
2214
|
+
E.current !== f && (E.current = f, $({
|
|
2215
|
+
sellNetwork: o.networkSell,
|
|
2216
|
+
buyNetwork: o.networkBuy,
|
|
2217
|
+
sellToken: o.sellToken,
|
|
2218
|
+
buyToken: o.buyToken,
|
|
2219
|
+
sellAmount: o.sellAmountForInput,
|
|
2220
|
+
buyAmount: o.buyAmountForInput,
|
|
2221
|
+
slippage: o.slippage.slippage,
|
|
2222
|
+
quote: o.quote
|
|
2223
|
+
}));
|
|
2224
|
+
}, [$, o]);
|
|
2225
|
+
const ce = M(() => {
|
|
2226
|
+
if (o.buttonState === "approve") {
|
|
2227
|
+
const f = ee("approve");
|
|
2228
|
+
f && (y == null || y(f));
|
|
2229
|
+
return;
|
|
2230
|
+
}
|
|
2231
|
+
if (o.buttonState === "swap") {
|
|
2232
|
+
const f = ee("swap");
|
|
2233
|
+
f && (v == null || v(f));
|
|
2234
|
+
}
|
|
2235
|
+
}, [ee, y, v, o.buttonState]);
|
|
2008
2236
|
return o.loading ? /* @__PURE__ */ d(
|
|
2009
2237
|
"div",
|
|
2010
2238
|
{
|
|
2011
2239
|
"data-delora-widget-root": !0,
|
|
2012
2240
|
className: `dw-flex dw-items-center dw-justify-center dw-p-8 ${r ?? ""}`,
|
|
2013
|
-
style:
|
|
2014
|
-
...
|
|
2241
|
+
style: q,
|
|
2242
|
+
...T,
|
|
2015
2243
|
children: /* @__PURE__ */ d("p", { className: "dw-text-[var(--dw-muted)]", children: "Loading..." })
|
|
2016
2244
|
}
|
|
2017
2245
|
) : o.error ? /* @__PURE__ */ d(
|
|
@@ -2019,32 +2247,36 @@ function pn(t) {
|
|
|
2019
2247
|
{
|
|
2020
2248
|
"data-delora-widget-root": !0,
|
|
2021
2249
|
className: `dw-flex dw-items-center dw-justify-center dw-p-8 ${r ?? ""}`,
|
|
2022
|
-
style:
|
|
2023
|
-
...
|
|
2250
|
+
style: q,
|
|
2251
|
+
...T,
|
|
2024
2252
|
children: /* @__PURE__ */ d("p", { className: "dw-text-[#ff7e7e]", children: o.error })
|
|
2025
2253
|
}
|
|
2026
|
-
) : /* @__PURE__ */
|
|
2254
|
+
) : /* @__PURE__ */ A(
|
|
2027
2255
|
"div",
|
|
2028
2256
|
{
|
|
2029
2257
|
"data-delora-widget-root": !0,
|
|
2030
2258
|
className: `dw-font-mono dw-relative dw-inline-block ${r ?? ""}`,
|
|
2031
|
-
style:
|
|
2032
|
-
...
|
|
2259
|
+
style: q,
|
|
2260
|
+
...T,
|
|
2033
2261
|
children: [
|
|
2034
2262
|
/* @__PURE__ */ d(
|
|
2035
|
-
|
|
2263
|
+
rn,
|
|
2036
2264
|
{
|
|
2037
|
-
assetBaseUrl:
|
|
2265
|
+
assetBaseUrl: L,
|
|
2038
2266
|
sellToken: o.sellToken,
|
|
2039
2267
|
buyToken: o.buyToken,
|
|
2040
|
-
networkSellLogo: (
|
|
2041
|
-
networkBuyLogo: (
|
|
2268
|
+
networkSellLogo: (w = o.networkSell) == null ? void 0 : w.logoURI,
|
|
2269
|
+
networkBuyLogo: (a = o.networkBuy) == null ? void 0 : a.logoURI,
|
|
2042
2270
|
sellAmountForInput: o.sellAmountForInput,
|
|
2043
2271
|
buyAmountForInput: o.buyAmountForInput,
|
|
2044
|
-
onSellAmountChange: (
|
|
2272
|
+
onSellAmountChange: (f) => o.setSellAmountForInput(f),
|
|
2045
2273
|
onSellInputProcess: o.processSellInput,
|
|
2046
|
-
onOpenSellToken: () =>
|
|
2047
|
-
|
|
2274
|
+
onOpenSellToken: () => {
|
|
2275
|
+
I || h("tokenSell");
|
|
2276
|
+
},
|
|
2277
|
+
onOpenBuyToken: () => {
|
|
2278
|
+
C || h("tokenBuy");
|
|
2279
|
+
},
|
|
2048
2280
|
onSwapTokens: o.swapTokens,
|
|
2049
2281
|
onRefresh: () => {
|
|
2050
2282
|
o.networkSell && o.networkBuy && o.sellToken && o.buyToken && o.validatedSellAmount > 0 && o.fetchQuote({
|
|
@@ -2054,16 +2286,16 @@ function pn(t) {
|
|
|
2054
2286
|
buyToken: o.buyToken,
|
|
2055
2287
|
sellAmountStr: o.sellAmountForInput || "0",
|
|
2056
2288
|
slippage: o.slippage.slippage,
|
|
2057
|
-
fromAddress:
|
|
2058
|
-
toAddress:
|
|
2059
|
-
apiBase:
|
|
2289
|
+
fromAddress: st(o.networkSell.chainType),
|
|
2290
|
+
toAddress: st(o.networkBuy.chainType),
|
|
2291
|
+
apiBase: l.apiBase
|
|
2060
2292
|
});
|
|
2061
2293
|
},
|
|
2062
|
-
onOpenSettings: () =>
|
|
2294
|
+
onOpenSettings: () => h("settings"),
|
|
2063
2295
|
balance: o.balance,
|
|
2064
2296
|
balanceBuy: o.balanceBuy,
|
|
2065
|
-
sellPriceUsd: (
|
|
2066
|
-
buyPriceUsd: (
|
|
2297
|
+
sellPriceUsd: (S = o.sellToken) != null && S.priceUSD && o.sellAmountForInput && Number(o.sellAmountForInput) > 0 ? `$${(Number(o.sellAmountForInput) * Number(o.sellToken.priceUSD)).toFixed(3)}` : "",
|
|
2298
|
+
buyPriceUsd: (W = o.buyToken) != null && W.priceUSD && o.buyAmountForInput && Number(o.buyAmountForInput) > 0 ? `$${(Number(o.buyAmountForInput) * Number(o.buyToken.priceUSD)).toFixed(3)}` : "",
|
|
2067
2299
|
onMaxClick: o.setMaxSellAmount,
|
|
2068
2300
|
onSet50Percent: () => o.setSellAmountByPercent(50),
|
|
2069
2301
|
onSet25Percent: () => o.setSellAmountByPercent(25),
|
|
@@ -2072,93 +2304,103 @@ function pn(t) {
|
|
|
2072
2304
|
loading: o.buttonState === "finding",
|
|
2073
2305
|
price: o.price,
|
|
2074
2306
|
gasCostUSD: o.gasCostUSD,
|
|
2075
|
-
truncateTo6Decimals:
|
|
2076
|
-
isWalletConnected: !!
|
|
2077
|
-
onConnectWallet:
|
|
2307
|
+
truncateTo6Decimals: fe,
|
|
2308
|
+
isWalletConnected: !!l.isWalletConnected,
|
|
2309
|
+
onConnectWallet: l.onConnectWallet,
|
|
2310
|
+
onAction: ce,
|
|
2311
|
+
swapDisabled: o.swapLocked,
|
|
2312
|
+
sellTokenLocked: I,
|
|
2313
|
+
buyTokenLocked: C
|
|
2078
2314
|
}
|
|
2079
2315
|
),
|
|
2080
|
-
|
|
2081
|
-
|
|
2316
|
+
c === "tokenSell" && /* @__PURE__ */ d(
|
|
2317
|
+
rt,
|
|
2082
2318
|
{
|
|
2083
2319
|
mode: "sell",
|
|
2084
2320
|
networks: o.networks,
|
|
2085
|
-
selectedNetworkId: (
|
|
2321
|
+
selectedNetworkId: (Q = o.networkSell) == null ? void 0 : Q.id,
|
|
2086
2322
|
selectedToken: o.sellToken,
|
|
2087
2323
|
excludeToken: o.buyToken,
|
|
2088
2324
|
getAllTokensForNetwork: o.getAllTokensForNetworkId,
|
|
2089
2325
|
getNetworkById: o.getNetworkById,
|
|
2090
|
-
displayedNetworks:
|
|
2091
|
-
additionalNetworksCount:
|
|
2092
|
-
onOpenNetworkSelector: () =>
|
|
2093
|
-
|
|
2094
|
-
|
|
2326
|
+
displayedNetworks: V,
|
|
2327
|
+
additionalNetworksCount: J.length,
|
|
2328
|
+
onOpenNetworkSelector: () => {
|
|
2329
|
+
o.sellNetworkLocked || N("sell");
|
|
2330
|
+
},
|
|
2331
|
+
onSelectToken: (f) => {
|
|
2332
|
+
o.setSellToken(f), o.cancelRequest(), h(null);
|
|
2095
2333
|
},
|
|
2096
|
-
onSelectNetwork: (
|
|
2097
|
-
var
|
|
2098
|
-
o.updateNetworkSell(
|
|
2334
|
+
onSelectNetwork: (f) => {
|
|
2335
|
+
var F;
|
|
2336
|
+
o.updateNetworkSell(f.id), ((F = o.networkBuy) == null ? void 0 : F.id) !== f.id && o.setNetworkBuy(f);
|
|
2099
2337
|
},
|
|
2100
|
-
onClose: () =>
|
|
2101
|
-
assetBaseUrl:
|
|
2338
|
+
onClose: () => h(null),
|
|
2339
|
+
assetBaseUrl: L,
|
|
2340
|
+
networkSelectionLocked: o.sellNetworkLocked
|
|
2102
2341
|
}
|
|
2103
2342
|
),
|
|
2104
|
-
|
|
2105
|
-
|
|
2343
|
+
c === "tokenBuy" && /* @__PURE__ */ d(
|
|
2344
|
+
rt,
|
|
2106
2345
|
{
|
|
2107
2346
|
mode: "buy",
|
|
2108
2347
|
networks: o.networks,
|
|
2109
|
-
selectedNetworkId: (
|
|
2348
|
+
selectedNetworkId: (z = o.networkBuy) == null ? void 0 : z.id,
|
|
2110
2349
|
selectedToken: o.buyToken,
|
|
2111
2350
|
excludeToken: o.sellToken,
|
|
2112
2351
|
getAllTokensForNetwork: o.getAllTokensForNetworkId,
|
|
2113
2352
|
getNetworkById: o.getNetworkById,
|
|
2114
|
-
displayedNetworks:
|
|
2115
|
-
additionalNetworksCount:
|
|
2116
|
-
onOpenNetworkSelector: () =>
|
|
2117
|
-
|
|
2118
|
-
|
|
2353
|
+
displayedNetworks: G,
|
|
2354
|
+
additionalNetworksCount: ie.length,
|
|
2355
|
+
onOpenNetworkSelector: () => {
|
|
2356
|
+
o.buyNetworkLocked || N("buy");
|
|
2357
|
+
},
|
|
2358
|
+
onSelectToken: (f) => {
|
|
2359
|
+
o.setBuyToken(f), o.cancelRequest(), h(null);
|
|
2119
2360
|
},
|
|
2120
|
-
onSelectNetwork: (
|
|
2121
|
-
o.setNetworkBuy(
|
|
2361
|
+
onSelectNetwork: (f) => {
|
|
2362
|
+
o.setNetworkBuy(f);
|
|
2122
2363
|
},
|
|
2123
|
-
onClose: () =>
|
|
2124
|
-
assetBaseUrl:
|
|
2364
|
+
onClose: () => h(null),
|
|
2365
|
+
assetBaseUrl: L,
|
|
2366
|
+
networkSelectionLocked: o.buyNetworkLocked
|
|
2125
2367
|
}
|
|
2126
2368
|
),
|
|
2127
|
-
|
|
2128
|
-
|
|
2369
|
+
b === "sell" && c === "tokenSell" && /* @__PURE__ */ d(
|
|
2370
|
+
ot,
|
|
2129
2371
|
{
|
|
2130
|
-
networks:
|
|
2131
|
-
assetBaseUrl:
|
|
2132
|
-
onSelectNetwork: (
|
|
2133
|
-
var
|
|
2134
|
-
o.updateNetworkSell(
|
|
2372
|
+
networks: J,
|
|
2373
|
+
assetBaseUrl: L,
|
|
2374
|
+
onSelectNetwork: (f) => {
|
|
2375
|
+
var F;
|
|
2376
|
+
o.updateNetworkSell(f.id), ((F = o.networkBuy) == null ? void 0 : F.id) !== f.id && o.setNetworkBuy(f), N(null);
|
|
2135
2377
|
},
|
|
2136
|
-
onClose: () =>
|
|
2378
|
+
onClose: () => N(null)
|
|
2137
2379
|
}
|
|
2138
2380
|
),
|
|
2139
|
-
|
|
2140
|
-
|
|
2381
|
+
b === "buy" && c === "tokenBuy" && /* @__PURE__ */ d(
|
|
2382
|
+
ot,
|
|
2141
2383
|
{
|
|
2142
|
-
networks:
|
|
2143
|
-
assetBaseUrl:
|
|
2144
|
-
onSelectNetwork: (
|
|
2145
|
-
o.setNetworkBuy(
|
|
2384
|
+
networks: ie,
|
|
2385
|
+
assetBaseUrl: L,
|
|
2386
|
+
onSelectNetwork: (f) => {
|
|
2387
|
+
o.setNetworkBuy(f), N(null);
|
|
2146
2388
|
},
|
|
2147
|
-
onClose: () =>
|
|
2389
|
+
onClose: () => N(null)
|
|
2148
2390
|
}
|
|
2149
2391
|
),
|
|
2150
|
-
|
|
2151
|
-
|
|
2392
|
+
c === "settings" && /* @__PURE__ */ d(
|
|
2393
|
+
gn,
|
|
2152
2394
|
{
|
|
2153
2395
|
options: o.slippage.options,
|
|
2154
2396
|
selectedIndex: o.slippage.selectedIndex,
|
|
2155
2397
|
customValue: o.slippage.customValue,
|
|
2156
2398
|
onSelectOption: o.slippage.selectOption,
|
|
2157
2399
|
onCustomChange: o.slippage.setCustom,
|
|
2158
|
-
onSave: (
|
|
2159
|
-
o.slippage.save(
|
|
2400
|
+
onSave: (f) => {
|
|
2401
|
+
o.slippage.save(f), h(null);
|
|
2160
2402
|
},
|
|
2161
|
-
onClose: () =>
|
|
2403
|
+
onClose: () => h(null)
|
|
2162
2404
|
}
|
|
2163
2405
|
)
|
|
2164
2406
|
]
|
|
@@ -2166,7 +2408,7 @@ function pn(t) {
|
|
|
2166
2408
|
);
|
|
2167
2409
|
}
|
|
2168
2410
|
export {
|
|
2169
|
-
|
|
2170
|
-
|
|
2411
|
+
An as MyWidget,
|
|
2412
|
+
vn as TradeWidget
|
|
2171
2413
|
};
|
|
2172
2414
|
//# sourceMappingURL=index.js.map
|