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