@rhinestone/deposit-modal 0.8.1 → 0.9.0
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 +193 -29
- package/dist/{chunk-2JPB3PLB.mjs → DepositModalReown-6KUAO5ZC.mjs} +56 -4
- package/dist/{chunk-Q3W53BKR.cjs → DepositModalReown-XC5RIU7Z.cjs} +62 -10
- package/dist/{caip-C_ZYFIGa.d.cts → caip-523Zrc3r.d.cts} +1 -3
- package/dist/{caip-C_ZYFIGa.d.ts → caip-523Zrc3r.d.ts} +1 -3
- package/dist/{chunk-D3Y7ZBED.cjs → chunk-22RV33LK.cjs} +2170 -1460
- package/dist/chunk-4WB2FHGC.mjs +865 -0
- package/dist/chunk-A223BLVC.mjs +801 -0
- package/dist/{chunk-HQWZCOMS.cjs → chunk-DIX7M3SP.cjs} +232 -601
- package/dist/{chunk-T43VUEJH.mjs → chunk-E4G5BOZP.mjs} +167 -536
- package/dist/chunk-H577RJN5.cjs +801 -0
- package/dist/{chunk-DABKCJVL.mjs → chunk-ILT2PITN.mjs} +60 -3
- package/dist/{chunk-7KHEIMWD.mjs → chunk-KKHLNFSA.mjs} +2436 -1726
- package/dist/chunk-LGVJWVSS.mjs +81 -0
- package/dist/chunk-NEXUCY4B.cjs +11 -0
- package/dist/chunk-NMIMRASD.cjs +1785 -0
- package/dist/chunk-OSI2CFGL.mjs +11 -0
- package/dist/chunk-PAGMU4RQ.cjs +865 -0
- package/dist/chunk-T7LGQFP3.cjs +81 -0
- package/dist/chunk-VN4BLZYC.cjs +2273 -0
- package/dist/chunk-VOGZAZB2.mjs +2273 -0
- package/dist/chunk-WYXBY2MQ.mjs +1785 -0
- package/dist/{chunk-4NN7UTWQ.cjs → chunk-YEBXUUH3.cjs} +63 -6
- package/dist/claim.cjs +10 -0
- package/dist/claim.d.cts +8 -0
- package/dist/claim.d.ts +8 -0
- package/dist/claim.mjs +10 -0
- package/dist/constants.cjs +3 -3
- package/dist/constants.d.cts +4 -2
- package/dist/constants.d.ts +4 -2
- package/dist/constants.mjs +5 -5
- package/dist/deposit.cjs +8 -6
- package/dist/deposit.d.cts +2 -2
- package/dist/deposit.d.ts +2 -2
- package/dist/deposit.mjs +7 -5
- package/dist/index.cjs +22 -12
- package/dist/index.d.cts +15 -2
- package/dist/index.d.ts +15 -2
- package/dist/index.mjs +21 -11
- package/dist/polymarket.cjs +5 -6
- package/dist/polymarket.mjs +2 -3
- package/dist/server.cjs +96 -0
- package/dist/server.d.cts +65 -0
- package/dist/server.d.ts +65 -0
- package/dist/server.mjs +96 -0
- package/dist/styles.css +263 -12
- package/dist/types-C0SGf-21.d.cts +606 -0
- package/dist/types-C0SGf-21.d.ts +606 -0
- package/dist/withdraw.cjs +6 -5
- package/dist/withdraw.d.cts +3 -6
- package/dist/withdraw.d.ts +3 -6
- package/dist/withdraw.mjs +5 -4
- package/package.json +53 -6
- package/dist/DepositModalReown-4BSHOQ5Y.mjs +0 -63
- package/dist/DepositModalReown-UND3DEJH.cjs +0 -63
- package/dist/WithdrawModalReown-FVXSSGY5.mjs +0 -46
- package/dist/WithdrawModalReown-TVZWJKQI.cjs +0 -46
- package/dist/chunk-7OKA6GNA.cjs +0 -4537
- package/dist/chunk-NASHLEVQ.mjs +0 -4537
- package/dist/chunk-O5OKA27M.mjs +0 -800
- package/dist/chunk-U7SVYWVD.cjs +0 -800
- package/dist/chunk-WK5AFRSP.mjs +0 -295
- package/dist/chunk-XRWQMIBY.cjs +0 -295
- package/dist/types--LQWg_4W.d.cts +0 -468
- package/dist/types--LQWg_4W.d.ts +0 -468
|
@@ -0,0 +1,2273 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
var _chunkNEXUCY4Bcjs = require('./chunk-NEXUCY4B.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
var _chunkH577RJN5cjs = require('./chunk-H577RJN5.cjs');
|
|
21
|
+
|
|
22
|
+
// src/components/ui/Modal.tsx
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
var _react = require('react');
|
|
28
|
+
var _reactdom = require('react-dom');
|
|
29
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
30
|
+
function getFocusableElements(container) {
|
|
31
|
+
const elements = container.querySelectorAll(
|
|
32
|
+
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
|
|
33
|
+
);
|
|
34
|
+
return Array.from(elements).filter(
|
|
35
|
+
(el) => !el.hasAttribute("disabled") && el.offsetParent !== null
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
function Modal({
|
|
39
|
+
isOpen,
|
|
40
|
+
onClose,
|
|
41
|
+
children,
|
|
42
|
+
className = "",
|
|
43
|
+
inline = false,
|
|
44
|
+
closeOnOverlayClick = false
|
|
45
|
+
}) {
|
|
46
|
+
const overlayRef = _react.useRef.call(void 0, null);
|
|
47
|
+
const contentRef = _react.useRef.call(void 0, null);
|
|
48
|
+
const previousActiveElement = _react.useRef.call(void 0, null);
|
|
49
|
+
_react.useEffect.call(void 0, () => {
|
|
50
|
+
if (isOpen) {
|
|
51
|
+
previousActiveElement.current = document.activeElement;
|
|
52
|
+
}
|
|
53
|
+
}, [isOpen]);
|
|
54
|
+
_react.useEffect.call(void 0, () => {
|
|
55
|
+
if (!isOpen && previousActiveElement.current) {
|
|
56
|
+
previousActiveElement.current.focus();
|
|
57
|
+
previousActiveElement.current = null;
|
|
58
|
+
}
|
|
59
|
+
}, [isOpen]);
|
|
60
|
+
_react.useEffect.call(void 0, () => {
|
|
61
|
+
if (isOpen && contentRef.current) {
|
|
62
|
+
const focusable = getFocusableElements(contentRef.current);
|
|
63
|
+
if (focusable.length > 0) {
|
|
64
|
+
focusable[0].focus();
|
|
65
|
+
} else {
|
|
66
|
+
contentRef.current.focus();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}, [isOpen]);
|
|
70
|
+
_react.useEffect.call(void 0, () => {
|
|
71
|
+
if (isOpen && !inline) {
|
|
72
|
+
const originalOverflow = document.body.style.overflow;
|
|
73
|
+
document.body.style.overflow = "hidden";
|
|
74
|
+
return () => {
|
|
75
|
+
document.body.style.overflow = originalOverflow;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}, [isOpen, inline]);
|
|
79
|
+
const handleKeyDown = _react.useCallback.call(void 0,
|
|
80
|
+
(event) => {
|
|
81
|
+
if (event.key === "Escape") {
|
|
82
|
+
event.preventDefault();
|
|
83
|
+
onClose();
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (event.key === "Tab" && contentRef.current) {
|
|
87
|
+
const focusable = getFocusableElements(contentRef.current);
|
|
88
|
+
if (focusable.length === 0) return;
|
|
89
|
+
const firstElement = focusable[0];
|
|
90
|
+
const lastElement = focusable[focusable.length - 1];
|
|
91
|
+
if (event.shiftKey) {
|
|
92
|
+
if (document.activeElement === firstElement) {
|
|
93
|
+
event.preventDefault();
|
|
94
|
+
lastElement.focus();
|
|
95
|
+
}
|
|
96
|
+
} else {
|
|
97
|
+
if (document.activeElement === lastElement) {
|
|
98
|
+
event.preventDefault();
|
|
99
|
+
firstElement.focus();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
[onClose]
|
|
105
|
+
);
|
|
106
|
+
const handleOverlayClick = _react.useCallback.call(void 0,
|
|
107
|
+
(event) => {
|
|
108
|
+
if (closeOnOverlayClick && event.target === overlayRef.current) {
|
|
109
|
+
onClose();
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
[closeOnOverlayClick, onClose]
|
|
113
|
+
);
|
|
114
|
+
if (!isOpen) return null;
|
|
115
|
+
if (inline) {
|
|
116
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
117
|
+
"div",
|
|
118
|
+
{
|
|
119
|
+
ref: contentRef,
|
|
120
|
+
className: `rs-modal-content rs-modal-content--inline ${className}`,
|
|
121
|
+
tabIndex: -1,
|
|
122
|
+
children
|
|
123
|
+
}
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
return _reactdom.createPortal.call(void 0,
|
|
127
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
128
|
+
"div",
|
|
129
|
+
{
|
|
130
|
+
ref: overlayRef,
|
|
131
|
+
className: `rs-modal-overlay ${isOpen ? "rs-modal-overlay--open" : ""}`,
|
|
132
|
+
onClick: handleOverlayClick,
|
|
133
|
+
onKeyDown: handleKeyDown,
|
|
134
|
+
role: "dialog",
|
|
135
|
+
"aria-modal": "true",
|
|
136
|
+
"aria-labelledby": "rs-modal-title",
|
|
137
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
138
|
+
"div",
|
|
139
|
+
{
|
|
140
|
+
ref: contentRef,
|
|
141
|
+
className: `rs-modal-content ${className}`,
|
|
142
|
+
tabIndex: -1,
|
|
143
|
+
children
|
|
144
|
+
}
|
|
145
|
+
)
|
|
146
|
+
}
|
|
147
|
+
),
|
|
148
|
+
document.body
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
Modal.displayName = "Modal";
|
|
152
|
+
|
|
153
|
+
// src/components/ui/Icons.tsx
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
var _lucidereact = require('lucide-react');
|
|
178
|
+
|
|
179
|
+
var WalletIcon = _lucidereact.Wallet;
|
|
180
|
+
var ExternalLinkIcon = _lucidereact.ExternalLink;
|
|
181
|
+
var CheckIcon = _lucidereact.Check;
|
|
182
|
+
function TransferCryptoIcon() {
|
|
183
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
184
|
+
"svg",
|
|
185
|
+
{
|
|
186
|
+
width: "24",
|
|
187
|
+
height: "24",
|
|
188
|
+
viewBox: "8 8 24 24",
|
|
189
|
+
fill: "none",
|
|
190
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
191
|
+
"aria-hidden": "true",
|
|
192
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
193
|
+
"path",
|
|
194
|
+
{
|
|
195
|
+
d: "M26.08 18.37C27.03 18.72 27.87 19.30 28.53 20.07C29.19 20.83 29.65 21.75 29.86 22.73C30.07 23.72 30.03 24.74 29.74 25.71C29.45 26.68 28.92 27.55 28.20 28.26C27.48 28.97 26.59 29.49 25.62 29.76C24.65 30.04 23.63 30.06 22.64 29.83C21.66 29.61 20.75 29.14 20.00 28.47C19.24 27.80 18.67 26.95 18.33 26.00M15 14H16V18M24.70 21.87L25.40 22.58L22.58 25.40M22 16C22 19.31 19.31 22 16 22C12.68 22 10 19.31 10 16C10 12.68 12.68 10 16 10C19.31 10 22 12.68 22 16Z",
|
|
196
|
+
stroke: "currentColor",
|
|
197
|
+
strokeWidth: "2",
|
|
198
|
+
strokeLinecap: "round",
|
|
199
|
+
strokeLinejoin: "round"
|
|
200
|
+
}
|
|
201
|
+
)
|
|
202
|
+
}
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
var ChevronRightIcon = _lucidereact.ChevronRight;
|
|
206
|
+
var ChevronLeftIcon = _lucidereact.ChevronLeft;
|
|
207
|
+
var ChevronDownIcon = _lucidereact.ChevronDown;
|
|
208
|
+
var CloseIcon = _lucidereact.X;
|
|
209
|
+
var HandCoinsIcon = _lucidereact.HandCoins;
|
|
210
|
+
var CoinsIcon = _lucidereact.Coins;
|
|
211
|
+
var HistoryIcon = _lucidereact.History;
|
|
212
|
+
var InfoIcon = _lucidereact.Info;
|
|
213
|
+
var CopyIcon = _lucidereact.Copy;
|
|
214
|
+
var ArrowUpRightIcon = _lucidereact.ArrowUpRight;
|
|
215
|
+
var AlertTriangleIcon = _lucidereact.AlertTriangle;
|
|
216
|
+
var PercentIcon = _lucidereact.Percent;
|
|
217
|
+
var ClockIcon = _lucidereact.Clock;
|
|
218
|
+
var PlusCircleIcon = _lucidereact.CirclePlus;
|
|
219
|
+
var CircleArrowOutUpLeftIcon = _lucidereact.CircleArrowOutUpLeft;
|
|
220
|
+
var CardIcon = _lucidereact.CreditCard;
|
|
221
|
+
var BankIcon = _lucidereact.Landmark;
|
|
222
|
+
var UnplugIcon = _lucidereact.Unplug;
|
|
223
|
+
function MigrateAssetsIcon() {
|
|
224
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
225
|
+
"svg",
|
|
226
|
+
{
|
|
227
|
+
width: "24",
|
|
228
|
+
height: "24",
|
|
229
|
+
viewBox: "0 0 24 24",
|
|
230
|
+
fill: "none",
|
|
231
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
232
|
+
"aria-hidden": "true",
|
|
233
|
+
children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
234
|
+
"g",
|
|
235
|
+
{
|
|
236
|
+
stroke: "currentColor",
|
|
237
|
+
strokeWidth: "2",
|
|
238
|
+
strokeLinecap: "round",
|
|
239
|
+
strokeLinejoin: "round",
|
|
240
|
+
children: [
|
|
241
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
242
|
+
"path",
|
|
243
|
+
{
|
|
244
|
+
d: "M19 4.344V3C19 2.46957 18.7893 1.96086 18.4142 1.58579C18.0391 1.21071 17.5304 1 17 1H3C2.46957 1 1.96086 1.21071 1.58579 1.58579C1.21071 1.96086 1 2.46957 1 3V17C1 17.5304 1.21071 18.0391 1.58579 18.4142C1.96086 18.7893 2.46957 19 3 19H17C17.5304 19 18.0391 18.7893 18.4142 18.4142C18.7893 18.0391 19 17.5304 19 17V15.656",
|
|
245
|
+
transform: "translate(2 2)"
|
|
246
|
+
}
|
|
247
|
+
),
|
|
248
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "M1 1H12", transform: "translate(9 11)" }),
|
|
249
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "M1 9L5 5L1 1", transform: "translate(16 7)" })
|
|
250
|
+
]
|
|
251
|
+
}
|
|
252
|
+
)
|
|
253
|
+
}
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
function AppleIcon() {
|
|
257
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
258
|
+
"svg",
|
|
259
|
+
{
|
|
260
|
+
width: "24",
|
|
261
|
+
height: "24",
|
|
262
|
+
viewBox: "0 0 24 24",
|
|
263
|
+
fill: "none",
|
|
264
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
265
|
+
"aria-hidden": "true",
|
|
266
|
+
children: [
|
|
267
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
268
|
+
"path",
|
|
269
|
+
{
|
|
270
|
+
d: "M16.36 1.43c0 1.14-.49 2.27-1.18 3.08-.74.9-1.99 1.57-2.98 1.57-.12 0-.23-.02-.3-.03-.01-.06-.04-.22-.04-.39 0-1.15.57-2.27 1.2-2.98.8-.94 2.15-1.64 3.25-1.68.03.13.05.28.05.43z",
|
|
271
|
+
stroke: "currentColor",
|
|
272
|
+
strokeWidth: "1.6",
|
|
273
|
+
strokeLinejoin: "round"
|
|
274
|
+
}
|
|
275
|
+
),
|
|
276
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
277
|
+
"path",
|
|
278
|
+
{
|
|
279
|
+
d: "M20.93 17.14c-.03.07-.46 1.58-1.52 3.12-.94 1.34-1.94 2.71-3.43 2.71-1.51 0-1.9-.88-3.63-.88-1.7 0-2.3.91-3.67.91-1.38 0-2.33-1.26-3.43-2.8-1.29-1.82-2.32-4.63-2.32-7.28 0-4.28 2.8-6.55 5.55-6.55 1.45 0 2.68.95 3.6.95.86 0 2.22-1.01 3.9-1.01.61 0 2.89.06 4.37 2.19-.13.09-2.38 1.37-2.38 4.19 0 3.26 2.85 4.42 2.96 4.45z",
|
|
280
|
+
stroke: "currentColor",
|
|
281
|
+
strokeWidth: "1.6",
|
|
282
|
+
strokeLinejoin: "round"
|
|
283
|
+
}
|
|
284
|
+
)
|
|
285
|
+
]
|
|
286
|
+
}
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// src/components/ui/BodyHeader.tsx
|
|
291
|
+
|
|
292
|
+
function BodyHeader({
|
|
293
|
+
icon,
|
|
294
|
+
title,
|
|
295
|
+
subtitle,
|
|
296
|
+
variant = "default",
|
|
297
|
+
aside
|
|
298
|
+
}) {
|
|
299
|
+
const iconClasses = [
|
|
300
|
+
"rs-body-header-icon",
|
|
301
|
+
variant === "success" ? "rs-body-header-icon--success" : "",
|
|
302
|
+
variant === "error" ? "rs-body-header-icon--error" : ""
|
|
303
|
+
].filter(Boolean).join(" ");
|
|
304
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-body-header", children: [
|
|
305
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: iconClasses, children: icon }),
|
|
306
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-body-header-main", children: [
|
|
307
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-body-header-text", children: [
|
|
308
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h2", { className: "rs-body-header-title", children: title }),
|
|
309
|
+
subtitle && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "rs-body-header-subtitle", children: subtitle })
|
|
310
|
+
] }),
|
|
311
|
+
aside && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-body-header-aside", children: aside })
|
|
312
|
+
] })
|
|
313
|
+
] });
|
|
314
|
+
}
|
|
315
|
+
BodyHeader.displayName = "BodyHeader";
|
|
316
|
+
|
|
317
|
+
// src/components/ui/CdnIcon.tsx
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
function preconnectIconCdn() {
|
|
321
|
+
if (typeof document === "undefined") return;
|
|
322
|
+
if (document.getElementById("rs-icon-cdn-preconnect")) return;
|
|
323
|
+
const link = document.createElement("link");
|
|
324
|
+
link.id = "rs-icon-cdn-preconnect";
|
|
325
|
+
link.rel = "preconnect";
|
|
326
|
+
link.href = _chunkH577RJN5cjs.ICON_CDN;
|
|
327
|
+
link.crossOrigin = "anonymous";
|
|
328
|
+
document.head.appendChild(link);
|
|
329
|
+
}
|
|
330
|
+
preconnectIconCdn();
|
|
331
|
+
function CdnIcon({
|
|
332
|
+
src,
|
|
333
|
+
alt = "",
|
|
334
|
+
className,
|
|
335
|
+
fallback,
|
|
336
|
+
loading = "eager"
|
|
337
|
+
}) {
|
|
338
|
+
const [loadedSrc, setLoadedSrc] = _react.useState.call(void 0, null);
|
|
339
|
+
const [erroredSrc, setErroredSrc] = _react.useState.call(void 0, null);
|
|
340
|
+
if (!src || erroredSrc === src) {
|
|
341
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children: fallback });
|
|
342
|
+
}
|
|
343
|
+
const isLoading = loadedSrc !== src;
|
|
344
|
+
const settleIfAlreadyComplete = (el) => {
|
|
345
|
+
if (_optionalChain([el, 'optionalAccess', _ => _.complete])) setLoadedSrc(src);
|
|
346
|
+
};
|
|
347
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
348
|
+
"img",
|
|
349
|
+
{
|
|
350
|
+
ref: settleIfAlreadyComplete,
|
|
351
|
+
src,
|
|
352
|
+
alt,
|
|
353
|
+
className: `rs-cdn-icon ${_nullishCoalesce(className, () => ( ""))}`.trimEnd(),
|
|
354
|
+
loading,
|
|
355
|
+
decoding: "async",
|
|
356
|
+
"data-loading": isLoading ? "" : void 0,
|
|
357
|
+
onLoad: () => setLoadedSrc(src),
|
|
358
|
+
onError: () => setErroredSrc(src)
|
|
359
|
+
},
|
|
360
|
+
src
|
|
361
|
+
);
|
|
362
|
+
}
|
|
363
|
+
CdnIcon.displayName = "CdnIcon";
|
|
364
|
+
|
|
365
|
+
// src/components/ui/PoweredBy.tsx
|
|
366
|
+
|
|
367
|
+
var rhinestoneLogo = /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
368
|
+
"svg",
|
|
369
|
+
{
|
|
370
|
+
className: "rs-powered-by-logo",
|
|
371
|
+
viewBox: "0 0 72 16",
|
|
372
|
+
fill: "none",
|
|
373
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
374
|
+
"aria-hidden": "true",
|
|
375
|
+
children: [
|
|
376
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "g", { fill: "currentColor", clipPath: "url(#rs-pb-clip)", children: [
|
|
377
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
378
|
+
"path",
|
|
379
|
+
{
|
|
380
|
+
opacity: "0.5",
|
|
381
|
+
fillRule: "evenodd",
|
|
382
|
+
clipRule: "evenodd",
|
|
383
|
+
d: "M10.48 14.82a4.3 4.3 0 0 1-2.9 1 4.3 4.3 0 0 1-2.4-1 25 25 0 0 1-2.08-1.95l-.13-.13c-.78-.78-1.46-1.46-1.94-2.08a4.3 4.3 0 0 1-1-2.9c.05-.96.48-1.72 1-2.4a25 25 0 0 1 1.94-2.08l.07-.06.06-.07a25 25 0 0 1 2.08-1.94 4.3 4.3 0 0 1 2.9-1c.96.05 1.73.48 2.4 1 .62.49 1.3 1.17 2.08 1.94l.13.13c.77.78 1.46 1.46 1.94 2.09a4.3 4.3 0 0 1 1 2.9 4.3 4.3 0 0 1-1 2.39c-.48.62-1.17 1.3-1.94 2.08l-.07.07-.06.06c-.78.78-1.46 1.46-2.08 1.94m-8.9-6.63c.07 1.02.9 1.86 2.56 3.52s2.5 2.5 3.53 2.56h.32c1.03-.06 1.86-.9 3.53-2.56s2.5-2.5 2.56-3.52v-.33c-.07-1.03-.9-1.86-2.56-3.52-1.67-1.67-2.5-2.5-3.53-2.56h-.32c-1.03.06-1.86.89-3.53 2.56-1.66 1.66-2.5 2.5-2.56 3.52z"
|
|
384
|
+
}
|
|
385
|
+
),
|
|
386
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "M3.66 8.01q.02-.27.28-.35a4.6 4.6 0 0 0 2.53-1.48q.72-.8 1-2.05a.4.4 0 0 1 .36-.29c.17 0 .32.12.36.29a4.6 4.6 0 0 0 1.47 2.52c.55.49 1.21.8 2.06 1a.4.4 0 0 1 .28.36.4.4 0 0 1-.28.36 4.6 4.6 0 0 0-2.53 1.47 4.6 4.6 0 0 0-1 2.06.4.4 0 0 1-.36.28.4.4 0 0 1-.36-.28A4.6 4.6 0 0 0 6 9.38a4.6 4.6 0 0 0-2.06-1.01.4.4 0 0 1-.28-.36m26.46-3.44c0 .51.38.87.96.87s.95-.36.95-.87c0-.52-.37-.86-.95-.86s-.96.34-.96.86m.2 1.44v5.33h1.53V6.01zm-4.4 5.33h-1.55V3.88h1.54v2.98c.25-.5.8-1.01 1.6-1.01 1.29 0 1.87.83 1.87 2.28v3.21h-1.54V8.3c0-.77-.34-1.16-.92-1.16-.67 0-1 .53-1 1.3zm-4.45 0h-1.54V6.01h1.54l-.27 1.22a.1.1 0 0 0 .02.1.1.1 0 0 0 .1.04q.09 0 .1-.09c.24-.84.93-1.36 1.64-1.36q.4.01.57.05v1.42l-.67-.04c-.67 0-1.5.31-1.5 2zm13 0h-1.55V6.01h1.54l-.02.9a1.8 1.8 0 0 1 1.61-1.06c1.3 0 1.88.83 1.88 2.28v3.21H36.4V8.3c0-.77-.35-1.16-.93-1.16-.67 0-1 .53-1 1.3z" }),
|
|
387
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
388
|
+
"path",
|
|
389
|
+
{
|
|
390
|
+
fillRule: "evenodd",
|
|
391
|
+
clipRule: "evenodd",
|
|
392
|
+
d: "M38.74 8.69c0 1.63 1.01 2.82 2.7 2.82 1.51 0 2.32-.82 2.55-1.73l-1.43-.26c-.1.37-.47.82-1.12.82-.67 0-1.23-.6-1.24-1.31H44q.05-.19.06-.56a2.55 2.55 0 0 0-2.6-2.63c-1.5 0-2.72 1.2-2.72 2.85m3.82-.58h-2.3a1.2 1.2 0 0 1 1.18-1.13c.6 0 1.14.45 1.12 1.13"
|
|
393
|
+
}
|
|
394
|
+
),
|
|
395
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "M47.1 11.51c-1.2 0-2.33-.41-2.55-1.65l1.43-.21q.27.8 1.1.79c.5 0 .77-.24.77-.55 0-.27-.2-.45-.75-.55l-.5-.1c-1.1-.24-1.77-.74-1.77-1.63 0-1.06.91-1.78 2.25-1.78 1.26 0 2.2.59 2.32 1.68l-1.41.22c-.07-.52-.43-.82-.91-.82-.5 0-.75.26-.75.57 0 .25.17.42.63.51l.5.1c1.28.26 1.94.77 1.94 1.75 0 1.01-1.03 1.66-2.3 1.66" }),
|
|
396
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
397
|
+
"path",
|
|
398
|
+
{
|
|
399
|
+
fillRule: "evenodd",
|
|
400
|
+
clipRule: "evenodd",
|
|
401
|
+
d: "M54.44 8.68c0 1.53 1.08 2.83 2.78 2.83s2.79-1.3 2.79-2.83c0-1.55-1.1-2.84-2.79-2.84-1.7 0-2.78 1.29-2.78 2.84m4.02 0c0 .98-.59 1.45-1.24 1.45-.64 0-1.23-.47-1.23-1.45 0-.97.59-1.47 1.23-1.47.65 0 1.24.48 1.24 1.47"
|
|
402
|
+
}
|
|
403
|
+
),
|
|
404
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "M62.4 11.34h-1.53V6.01h1.54l-.02.9a1.8 1.8 0 0 1 1.6-1.06c1.3 0 1.89.83 1.89 2.28v3.21h-1.54V8.3c0-.77-.34-1.16-.93-1.16-.66 0-1 .53-1 1.3z" }),
|
|
405
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
406
|
+
"path",
|
|
407
|
+
{
|
|
408
|
+
fillRule: "evenodd",
|
|
409
|
+
clipRule: "evenodd",
|
|
410
|
+
d: "M66.68 8.69c0 1.63 1.02 2.82 2.71 2.82 1.51 0 2.31-.82 2.55-1.73l-1.44-.26c-.1.37-.47.82-1.12.82-.67 0-1.23-.6-1.24-1.31h3.8q.06-.19.06-.56a2.55 2.55 0 0 0-2.6-2.63c-1.5 0-2.72 1.2-2.72 2.85m3.82-.58h-2.3a1.2 1.2 0 0 1 1.18-1.13c.6 0 1.15.45 1.12 1.13"
|
|
411
|
+
}
|
|
412
|
+
),
|
|
413
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "M52.44 9.05V7.26h1.53V6h-1.53V4.42h-1.53V6h-1.1v1.26h1.1v1.85l.02.49a1.9 1.9 0 0 0 1.67 1.67c.22.03.47.03.62.03h.65V9.87h-.61c-.4 0-.59 0-.7-.12-.12-.11-.12-.3-.12-.64z" })
|
|
414
|
+
] }),
|
|
415
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "defs", { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "clipPath", { id: "rs-pb-clip", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { fill: "#fff", d: "M0 0h72v16H0z" }) }) })
|
|
416
|
+
]
|
|
417
|
+
}
|
|
418
|
+
);
|
|
419
|
+
function PoweredBy() {
|
|
420
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-powered-by", "aria-label": "Powered by Rhinestone", children: [
|
|
421
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "Powered by" }),
|
|
422
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
423
|
+
"a",
|
|
424
|
+
{
|
|
425
|
+
className: "rs-powered-by-link",
|
|
426
|
+
href: "https://www.rhinestone.dev",
|
|
427
|
+
target: "_blank",
|
|
428
|
+
rel: "noopener noreferrer",
|
|
429
|
+
children: rhinestoneLogo
|
|
430
|
+
}
|
|
431
|
+
)
|
|
432
|
+
] });
|
|
433
|
+
}
|
|
434
|
+
PoweredBy.displayName = "PoweredBy";
|
|
435
|
+
|
|
436
|
+
// src/core/useLatestRef.ts
|
|
437
|
+
|
|
438
|
+
function useLatestRef(value) {
|
|
439
|
+
const ref = _react.useRef.call(void 0, value);
|
|
440
|
+
_react.useEffect.call(void 0, () => {
|
|
441
|
+
ref.current = value;
|
|
442
|
+
}, [value]);
|
|
443
|
+
return ref;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
// src/components/ui/Spinner.tsx
|
|
447
|
+
|
|
448
|
+
function Spinner({ className }) {
|
|
449
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
450
|
+
"svg",
|
|
451
|
+
{
|
|
452
|
+
className: `rs-spinner ${className || ""}`,
|
|
453
|
+
fill: "none",
|
|
454
|
+
viewBox: "0 0 20 21",
|
|
455
|
+
children: [
|
|
456
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
457
|
+
"path",
|
|
458
|
+
{
|
|
459
|
+
d: "M10 0.5C8.02 0.5 6.08 1.08 4.44 2.18C2.79 3.28 1.51 4.84 0.76 6.67C0.00 8.50 -0.19 10.51 0.19 12.45C0.57 14.39 1.53 16.17 2.92 17.57C4.32 18.96 6.10 19.92 8.04 20.30C9.98 20.69 11.99 20.49 13.82 19.73C15.65 18.98 17.21 17.70 18.31 16.05C19.41 14.41 20 12.47 20 10.5C20 7.84 18.94 5.30 17.07 3.42C15.19 1.55 12.65 0.5 10 0.5ZM10 17.77C8.56 17.77 7.15 17.34 5.95 16.54C4.76 15.74 3.83 14.61 3.28 13.28C2.73 11.95 2.58 10.49 2.86 9.08C3.14 7.67 3.84 6.37 4.85 5.35C5.87 4.34 7.17 3.64 8.58 3.36C9.99 3.08 11.45 3.23 12.78 3.78C14.11 4.33 15.24 5.26 16.04 6.45C16.84 7.65 17.27 9.06 17.27 10.5C17.27 12.42 16.50 14.27 15.14 15.64C13.77 17.00 11.92 17.77 10 17.77Z",
|
|
460
|
+
fill: "currentColor",
|
|
461
|
+
opacity: 0.3
|
|
462
|
+
}
|
|
463
|
+
),
|
|
464
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
465
|
+
"path",
|
|
466
|
+
{
|
|
467
|
+
d: "M10 3.22C11.74 3.22 13.42 3.84 14.75 4.95C16.08 6.07 16.96 7.61 17.25 9.31C17.30 9.64 17.46 9.94 17.71 10.15C17.96 10.37 18.28 10.49 18.62 10.5C18.82 10.50 19.01 10.45 19.20 10.37C19.38 10.29 19.54 10.16 19.67 10.01C19.80 9.86 19.89 9.68 19.95 9.49C20.00 9.30 20.01 9.10 19.98 8.90C19.59 6.56 18.38 4.42 16.55 2.88C14.72 1.34 12.40 0.5 10 0.5C7.59 0.5 5.27 1.34 3.44 2.88C1.61 4.42 0.40 6.56 0.01 8.90C-0.01 9.10 -0.00 9.30 0.04 9.49C0.10 9.68 0.19 9.86 0.32 10.01C0.45 10.16 0.61 10.29 0.79 10.37C0.98 10.45 1.17 10.50 1.37 10.5C1.71 10.49 2.03 10.37 2.28 10.15C2.53 9.94 2.69 9.64 2.74 9.31C3.03 7.61 3.91 6.07 5.24 4.95C6.57 3.84 8.25 3.22 10 3.22Z",
|
|
468
|
+
fill: "currentColor"
|
|
469
|
+
}
|
|
470
|
+
)
|
|
471
|
+
]
|
|
472
|
+
}
|
|
473
|
+
);
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
// src/components/ui/Button.tsx
|
|
477
|
+
|
|
478
|
+
function Button({
|
|
479
|
+
children,
|
|
480
|
+
variant = "accent",
|
|
481
|
+
size = "default",
|
|
482
|
+
loading = false,
|
|
483
|
+
loadingText,
|
|
484
|
+
fullWidth = false,
|
|
485
|
+
disabled,
|
|
486
|
+
className = "",
|
|
487
|
+
...props
|
|
488
|
+
}) {
|
|
489
|
+
const classes = [
|
|
490
|
+
"rs-button",
|
|
491
|
+
`rs-button--${variant}`,
|
|
492
|
+
`rs-button--size-${size}`,
|
|
493
|
+
fullWidth ? "rs-button--full-width" : "",
|
|
494
|
+
className
|
|
495
|
+
].filter(Boolean).join(" ");
|
|
496
|
+
const showInlineLoadingText = loading && loadingText !== void 0;
|
|
497
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
498
|
+
"button",
|
|
499
|
+
{
|
|
500
|
+
className: classes,
|
|
501
|
+
disabled: disabled || loading,
|
|
502
|
+
"aria-busy": loading || void 0,
|
|
503
|
+
...props,
|
|
504
|
+
children: showInlineLoadingText ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "rs-button__loading-row", children: [
|
|
505
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Spinner, { className: "rs-spinner--sm" }),
|
|
506
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: loadingText })
|
|
507
|
+
] }) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
508
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: loading ? "rs-button__content--hidden" : "", children }),
|
|
509
|
+
loading && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-button__spinner", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Spinner, { className: "rs-spinner--sm" }) })
|
|
510
|
+
] })
|
|
511
|
+
}
|
|
512
|
+
);
|
|
513
|
+
}
|
|
514
|
+
Button.displayName = "Button";
|
|
515
|
+
|
|
516
|
+
// src/components/ui/Callout.tsx
|
|
517
|
+
|
|
518
|
+
function CircleAlertIcon() {
|
|
519
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
520
|
+
"svg",
|
|
521
|
+
{
|
|
522
|
+
width: "16",
|
|
523
|
+
height: "16",
|
|
524
|
+
viewBox: "0 0 16 16",
|
|
525
|
+
fill: "none",
|
|
526
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
527
|
+
"aria-hidden": "true",
|
|
528
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
529
|
+
"path",
|
|
530
|
+
{
|
|
531
|
+
d: "M10 5.99L6 9.99M6 5.99L10 9.99M14.66 7.99C14.66 11.68 11.68 14.66 8 14.66C4.31 14.66 1.33 11.68 1.33 7.99C1.33 4.31 4.31 1.33 8 1.33C11.68 1.33 14.66 4.31 14.66 7.99Z",
|
|
532
|
+
stroke: "currentColor",
|
|
533
|
+
strokeWidth: "1.33",
|
|
534
|
+
strokeLinecap: "round",
|
|
535
|
+
strokeLinejoin: "round"
|
|
536
|
+
}
|
|
537
|
+
)
|
|
538
|
+
}
|
|
539
|
+
);
|
|
540
|
+
}
|
|
541
|
+
function Callout({ variant = "error", children, role }) {
|
|
542
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
543
|
+
"div",
|
|
544
|
+
{
|
|
545
|
+
className: `rs-callout rs-callout--${variant}`,
|
|
546
|
+
role: _nullishCoalesce(role, () => ( (variant === "error" ? "alert" : "status"))),
|
|
547
|
+
children: [
|
|
548
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-callout-icon", children: variant === "error" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CircleAlertIcon, {}) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AlertTriangleIcon, {}) }),
|
|
549
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-callout-text", children })
|
|
550
|
+
]
|
|
551
|
+
}
|
|
552
|
+
);
|
|
553
|
+
}
|
|
554
|
+
Callout.displayName = "Callout";
|
|
555
|
+
|
|
556
|
+
// src/components/ui/TokenIcon.tsx
|
|
557
|
+
|
|
558
|
+
function TokenIcon({ symbol, className, fallback }) {
|
|
559
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
560
|
+
CdnIcon,
|
|
561
|
+
{
|
|
562
|
+
src: _chunkH577RJN5cjs.tokenIconUrl.call(void 0, symbol),
|
|
563
|
+
className: `rs-token-icon ${_nullishCoalesce(className, () => ( ""))}`.trimEnd(),
|
|
564
|
+
fallback
|
|
565
|
+
}
|
|
566
|
+
);
|
|
567
|
+
}
|
|
568
|
+
TokenIcon.displayName = "TokenIcon";
|
|
569
|
+
|
|
570
|
+
// src/core/deposit-service.ts
|
|
571
|
+
var _viem = require('viem');
|
|
572
|
+
|
|
573
|
+
// src/core/debug.ts
|
|
574
|
+
function truncateString(value, max = 240) {
|
|
575
|
+
if (value.length <= max) return value;
|
|
576
|
+
return `${value.slice(0, max)}...`;
|
|
577
|
+
}
|
|
578
|
+
function normalizeForLog(value, depth = 0) {
|
|
579
|
+
if (depth > 3) return "[MaxDepth]";
|
|
580
|
+
if (value === null || value === void 0) return value;
|
|
581
|
+
if (typeof value === "bigint") return value.toString();
|
|
582
|
+
if (typeof value === "string") return truncateString(value);
|
|
583
|
+
if (typeof value === "number" || typeof value === "boolean") return value;
|
|
584
|
+
if (value instanceof Error) {
|
|
585
|
+
return {
|
|
586
|
+
name: value.name,
|
|
587
|
+
message: value.message,
|
|
588
|
+
stack: value.stack ? truncateString(value.stack, 600) : void 0
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
if (Array.isArray(value)) {
|
|
592
|
+
return value.slice(0, 12).map((entry) => normalizeForLog(entry, depth + 1));
|
|
593
|
+
}
|
|
594
|
+
if (typeof value === "object") {
|
|
595
|
+
const input = value;
|
|
596
|
+
const output = {};
|
|
597
|
+
for (const [key, raw] of Object.entries(input)) {
|
|
598
|
+
const keyLower = key.toLowerCase();
|
|
599
|
+
if (keyLower.includes("signature") || keyLower.includes("privatekey") || keyLower.includes("sessiondetails")) {
|
|
600
|
+
output[key] = "[Redacted]";
|
|
601
|
+
continue;
|
|
602
|
+
}
|
|
603
|
+
output[key] = normalizeForLog(raw, depth + 1);
|
|
604
|
+
}
|
|
605
|
+
return output;
|
|
606
|
+
}
|
|
607
|
+
return String(value);
|
|
608
|
+
}
|
|
609
|
+
function debugLog(enabled, scope, message, data) {
|
|
610
|
+
if (!enabled) return;
|
|
611
|
+
if (data === void 0) {
|
|
612
|
+
console.log(`[deposit-modal:${scope}] ${message}`);
|
|
613
|
+
return;
|
|
614
|
+
}
|
|
615
|
+
console.log(
|
|
616
|
+
`[deposit-modal:${scope}] ${message}`,
|
|
617
|
+
normalizeForLog(data)
|
|
618
|
+
);
|
|
619
|
+
}
|
|
620
|
+
function debugError(enabled, scope, message, error, data) {
|
|
621
|
+
if (!enabled) return;
|
|
622
|
+
const payload = data === void 0 ? { error: normalizeForLog(error) } : { error: normalizeForLog(error), meta: normalizeForLog(data) };
|
|
623
|
+
console.error(`[deposit-modal:${scope}] ${message}`, payload);
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
// src/core/deposit-asset-helpers.ts
|
|
627
|
+
function getAssetId(asset) {
|
|
628
|
+
return `${asset.chainId}:${asset.token.toLowerCase()}`;
|
|
629
|
+
}
|
|
630
|
+
function chainIdsByValue(tokens) {
|
|
631
|
+
const usdByChain = /* @__PURE__ */ new Map();
|
|
632
|
+
for (const token of tokens) {
|
|
633
|
+
if (typeof token.chainId !== "number") continue;
|
|
634
|
+
const usd = Number.isFinite(token.balanceUsd) ? token.balanceUsd : 0;
|
|
635
|
+
if (usd <= 0) continue;
|
|
636
|
+
usdByChain.set(token.chainId, (_nullishCoalesce(usdByChain.get(token.chainId), () => ( 0))) + usd);
|
|
637
|
+
}
|
|
638
|
+
return [...usdByChain.entries()].sort((a, b) => b[1] - a[1]).map(([chainId]) => chainId);
|
|
639
|
+
}
|
|
640
|
+
function isEvmAddress(value) {
|
|
641
|
+
return /^0x[a-fA-F0-9]{40}$/.test(value);
|
|
642
|
+
}
|
|
643
|
+
function portfolioTokenToAsset(token) {
|
|
644
|
+
if (typeof token.chainId !== "number") return null;
|
|
645
|
+
if (!isEvmAddress(token.address)) return null;
|
|
646
|
+
return {
|
|
647
|
+
id: getAssetId({ chainId: token.chainId, token: token.address }),
|
|
648
|
+
chainId: token.chainId,
|
|
649
|
+
token: token.address,
|
|
650
|
+
symbol: token.symbol,
|
|
651
|
+
name: token.name,
|
|
652
|
+
decimals: token.decimals,
|
|
653
|
+
balance: token.balance,
|
|
654
|
+
balanceUsd: token.balanceUsd
|
|
655
|
+
};
|
|
656
|
+
}
|
|
657
|
+
function safeBigInt(value) {
|
|
658
|
+
if (!value) return BigInt(0);
|
|
659
|
+
try {
|
|
660
|
+
return BigInt(value);
|
|
661
|
+
} catch (e) {
|
|
662
|
+
return BigInt(0);
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
function portfolioToAssets(tokens) {
|
|
666
|
+
return tokens.map(portfolioTokenToAsset).filter((token) => token !== null).sort((a, b) => {
|
|
667
|
+
const balanceA = safeBigInt(a.balance);
|
|
668
|
+
const balanceB = safeBigInt(b.balance);
|
|
669
|
+
if (balanceB > balanceA) return 1;
|
|
670
|
+
if (balanceB < balanceA) return -1;
|
|
671
|
+
return 0;
|
|
672
|
+
});
|
|
673
|
+
}
|
|
674
|
+
function isNativeAsset(asset) {
|
|
675
|
+
return asset.token.toLowerCase() === "0x0000000000000000000000000000000000000000";
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
// src/core/deposit-service.ts
|
|
679
|
+
function depositRowToEvent(row) {
|
|
680
|
+
const status = row.status;
|
|
681
|
+
if (!status) return void 0;
|
|
682
|
+
const deposit = {
|
|
683
|
+
transactionHash: row.txHash,
|
|
684
|
+
chain: row.chain,
|
|
685
|
+
amount: _nullishCoalesce(row.sourceAmount, () => ( row.amount)),
|
|
686
|
+
asset: row.token,
|
|
687
|
+
token: row.token
|
|
688
|
+
};
|
|
689
|
+
const source = row.sourceTxHash ? { transactionHash: row.sourceTxHash, chain: row.chain } : { transactionHash: row.txHash, chain: row.chain };
|
|
690
|
+
const destination = row.destinationTxHash ? {
|
|
691
|
+
transactionHash: row.destinationTxHash,
|
|
692
|
+
chain: row.targetChain,
|
|
693
|
+
amount: _nullishCoalesce(row.destinationAmount, () => ( void 0))
|
|
694
|
+
} : void 0;
|
|
695
|
+
const time = _nullishCoalesce(_nullishCoalesce(row.completedAt, () => ( row.createdAt)), () => ( void 0));
|
|
696
|
+
if (status === "completed") {
|
|
697
|
+
return {
|
|
698
|
+
type: "bridge-complete",
|
|
699
|
+
time: _nullishCoalesce(time, () => ( void 0)),
|
|
700
|
+
data: {
|
|
701
|
+
deposit,
|
|
702
|
+
source,
|
|
703
|
+
...destination && { destination }
|
|
704
|
+
}
|
|
705
|
+
};
|
|
706
|
+
}
|
|
707
|
+
if (status === "failed" || status === "refunded") {
|
|
708
|
+
return {
|
|
709
|
+
type: "bridge-failed",
|
|
710
|
+
time: _nullishCoalesce(time, () => ( void 0)),
|
|
711
|
+
data: {
|
|
712
|
+
deposit,
|
|
713
|
+
source,
|
|
714
|
+
...row.errorCode && { error: { code: row.errorCode } }
|
|
715
|
+
}
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
if (status === "processing") {
|
|
719
|
+
return {
|
|
720
|
+
type: "bridge-started",
|
|
721
|
+
time: _nullishCoalesce(time, () => ( void 0)),
|
|
722
|
+
data: {
|
|
723
|
+
deposit,
|
|
724
|
+
source
|
|
725
|
+
}
|
|
726
|
+
};
|
|
727
|
+
}
|
|
728
|
+
return {
|
|
729
|
+
type: "deposit-received",
|
|
730
|
+
time: _nullishCoalesce(time, () => ( void 0)),
|
|
731
|
+
data: {
|
|
732
|
+
transactionHash: row.txHash,
|
|
733
|
+
chain: row.chain,
|
|
734
|
+
amount: row.amount,
|
|
735
|
+
token: row.token
|
|
736
|
+
}
|
|
737
|
+
};
|
|
738
|
+
}
|
|
739
|
+
function normalizeEvmAddress(value) {
|
|
740
|
+
try {
|
|
741
|
+
return _viem.getAddress.call(void 0, value);
|
|
742
|
+
} catch (e2) {
|
|
743
|
+
return value;
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
function userPaidUsd(fees) {
|
|
747
|
+
let sum = 0;
|
|
748
|
+
for (const line of Object.values(fees.breakdown)) {
|
|
749
|
+
if (line.sponsored || line.internal) continue;
|
|
750
|
+
if (Number.isFinite(line.usd) && line.usd > 0) sum += line.usd;
|
|
751
|
+
}
|
|
752
|
+
return sum;
|
|
753
|
+
}
|
|
754
|
+
function formatFeeUsd(usd) {
|
|
755
|
+
const value = Number.isFinite(usd) && usd > 0 ? usd : 0;
|
|
756
|
+
if (value > 0 && value < 0.01) return "<$0.01";
|
|
757
|
+
return `$${value.toFixed(2)}`;
|
|
758
|
+
}
|
|
759
|
+
function quoteFeeRow(fees) {
|
|
760
|
+
if (!fees) return { display: null, struck: false };
|
|
761
|
+
const userUsd = userPaidUsd(fees);
|
|
762
|
+
const totalUsd = Number.isFinite(fees.total.usd) ? fees.total.usd : 0;
|
|
763
|
+
const struck = userUsd === 0 && totalUsd > 0;
|
|
764
|
+
return { display: formatFeeUsd(struck ? totalUsd : userUsd), struck };
|
|
765
|
+
}
|
|
766
|
+
function quoteFeeGroups(breakdown) {
|
|
767
|
+
const groups = /* @__PURE__ */ new Map();
|
|
768
|
+
for (const [category, line] of Object.entries(breakdown)) {
|
|
769
|
+
if (line.internal || !Number.isFinite(line.usd) || line.usd < 0) continue;
|
|
770
|
+
const label = _optionalChain([line, 'access', _2 => _2.label, 'optionalAccess', _3 => _3.trim, 'call', _4 => _4()]) || titleCaseFeeCategory(category);
|
|
771
|
+
const group = _nullishCoalesce(groups.get(label), () => ( {
|
|
772
|
+
label,
|
|
773
|
+
chargedUsd: 0,
|
|
774
|
+
sponsoredUsd: 0
|
|
775
|
+
}));
|
|
776
|
+
if (line.sponsored) group.sponsoredUsd += line.usd;
|
|
777
|
+
else group.chargedUsd += line.usd;
|
|
778
|
+
groups.set(label, group);
|
|
779
|
+
}
|
|
780
|
+
return [...groups.values()];
|
|
781
|
+
}
|
|
782
|
+
function titleCaseFeeCategory(category) {
|
|
783
|
+
return category.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[-_]+/g, " ").split(" ").filter(Boolean).map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
|
|
784
|
+
}
|
|
785
|
+
function parseQuotePreview(raw) {
|
|
786
|
+
if (typeof raw !== "object" || raw === null) return null;
|
|
787
|
+
const obj = raw;
|
|
788
|
+
if (typeof obj.settlementLayer !== "string") return null;
|
|
789
|
+
if (typeof obj.expiresAt !== "number" || !Number.isFinite(obj.expiresAt)) {
|
|
790
|
+
return null;
|
|
791
|
+
}
|
|
792
|
+
if (typeof obj.estimatedFillTimeSeconds !== "number" || !Number.isFinite(obj.estimatedFillTimeSeconds)) {
|
|
793
|
+
return null;
|
|
794
|
+
}
|
|
795
|
+
const output = parseQuoteOutput(obj.output);
|
|
796
|
+
if (!output) return null;
|
|
797
|
+
const fees = obj.fees;
|
|
798
|
+
if (typeof fees !== "object" || fees === null) return null;
|
|
799
|
+
const total = fees.total;
|
|
800
|
+
if (typeof total !== "object" || total === null) return null;
|
|
801
|
+
const totalUsd = total.usd;
|
|
802
|
+
if (typeof totalUsd !== "number" || !Number.isFinite(totalUsd) || totalUsd < 0) {
|
|
803
|
+
return null;
|
|
804
|
+
}
|
|
805
|
+
const rawBreakdown = fees.breakdown;
|
|
806
|
+
if (typeof rawBreakdown !== "object" || rawBreakdown === null || Array.isArray(rawBreakdown)) {
|
|
807
|
+
return null;
|
|
808
|
+
}
|
|
809
|
+
const entries = Object.entries(rawBreakdown);
|
|
810
|
+
const parsedEntries = [];
|
|
811
|
+
for (const [key, value] of entries) {
|
|
812
|
+
const line = parseFeeLine(value);
|
|
813
|
+
if (!line) return null;
|
|
814
|
+
parsedEntries.push([key, line]);
|
|
815
|
+
}
|
|
816
|
+
const breakdownTotalUsd = parsedEntries.reduce(
|
|
817
|
+
(sum, [, line]) => sum + line.usd,
|
|
818
|
+
0
|
|
819
|
+
);
|
|
820
|
+
if (Math.abs(totalUsd - breakdownTotalUsd) > 1e-6) return null;
|
|
821
|
+
const breakdown = Object.fromEntries(parsedEntries);
|
|
822
|
+
return {
|
|
823
|
+
settlementLayer: obj.settlementLayer,
|
|
824
|
+
expiresAt: obj.expiresAt,
|
|
825
|
+
estimatedFillTimeSeconds: obj.estimatedFillTimeSeconds,
|
|
826
|
+
fees: { total: { usd: totalUsd }, breakdown },
|
|
827
|
+
output
|
|
828
|
+
};
|
|
829
|
+
}
|
|
830
|
+
function parseQuoteOutput(raw) {
|
|
831
|
+
if (typeof raw !== "object" || raw === null) return null;
|
|
832
|
+
const o = raw;
|
|
833
|
+
if (typeof o.token !== "string") return null;
|
|
834
|
+
if (typeof o.amount !== "string") return null;
|
|
835
|
+
if (o.symbol !== null && typeof o.symbol !== "string") return null;
|
|
836
|
+
if (o.decimals !== null && typeof o.decimals !== "number") return null;
|
|
837
|
+
return {
|
|
838
|
+
token: o.token,
|
|
839
|
+
amount: o.amount,
|
|
840
|
+
symbol: o.symbol,
|
|
841
|
+
decimals: o.decimals
|
|
842
|
+
};
|
|
843
|
+
}
|
|
844
|
+
function parseFeeLine(raw) {
|
|
845
|
+
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) return null;
|
|
846
|
+
const line = raw;
|
|
847
|
+
const usd = line.usd;
|
|
848
|
+
if (typeof usd !== "number" || !Number.isFinite(usd) || usd < 0) return null;
|
|
849
|
+
const sponsored = line.sponsored;
|
|
850
|
+
if (typeof sponsored !== "boolean") return null;
|
|
851
|
+
if (line.label !== void 0 && typeof line.label !== "string") return null;
|
|
852
|
+
if (line.internal !== void 0 && typeof line.internal !== "boolean") {
|
|
853
|
+
return null;
|
|
854
|
+
}
|
|
855
|
+
return {
|
|
856
|
+
usd,
|
|
857
|
+
sponsored,
|
|
858
|
+
...line.label !== void 0 && { label: line.label },
|
|
859
|
+
...line.internal !== void 0 && { internal: line.internal }
|
|
860
|
+
};
|
|
861
|
+
}
|
|
862
|
+
var SwappedConnectFeeChangedError = class extends Error {
|
|
863
|
+
constructor(exchangeFeeBps, message = "The Exchange Fee changed") {
|
|
864
|
+
super(message);
|
|
865
|
+
this.exchangeFeeBps = exchangeFeeBps;
|
|
866
|
+
this.name = "SwappedConnectFeeChangedError";
|
|
867
|
+
}
|
|
868
|
+
};
|
|
869
|
+
function parseExchangeFeeBps(value) {
|
|
870
|
+
return typeof value === "number" && Number.isInteger(value) && value >= 0 && value <= 1e4 ? value : void 0;
|
|
871
|
+
}
|
|
872
|
+
function resolveAppFeeBps(appFees, sourceChainCaip2, sourceToken) {
|
|
873
|
+
const override = _optionalChain([appFees, 'optionalAccess', _5 => _5.tokens, 'optionalAccess', _6 => _6[sourceChainCaip2], 'optionalAccess', _7 => _7[sourceToken.toLowerCase()]]);
|
|
874
|
+
const bps = _nullishCoalesce(_nullishCoalesce(override, () => ( _optionalChain([appFees, 'optionalAccess', _8 => _8.feeBps]))), () => ( 0));
|
|
875
|
+
return bps > 0 ? bps : 0;
|
|
876
|
+
}
|
|
877
|
+
function createDepositService(baseUrl, options) {
|
|
878
|
+
const normalizedBaseUrl = baseUrl.replace(/\/$/, "");
|
|
879
|
+
const debug = _optionalChain([options, 'optionalAccess', _9 => _9.debug]) === true;
|
|
880
|
+
const scope = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _10 => _10.debugScope]), () => ( "service"));
|
|
881
|
+
function apiUrl(path) {
|
|
882
|
+
const normalizedPath = path.startsWith("/") ? path : `/${path}`;
|
|
883
|
+
return `${normalizedBaseUrl}${normalizedPath}`;
|
|
884
|
+
}
|
|
885
|
+
function shortRef(value) {
|
|
886
|
+
if (value.length <= 20) return value;
|
|
887
|
+
return `${value.slice(0, 10)}...${value.slice(-8)}`;
|
|
888
|
+
}
|
|
889
|
+
const PORTFOLIO_CACHE_TTL_MS = 3e4;
|
|
890
|
+
const portfolioCache = /* @__PURE__ */ new Map();
|
|
891
|
+
let topTokensPromise = null;
|
|
892
|
+
function parseTopTokens(value) {
|
|
893
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
894
|
+
return null;
|
|
895
|
+
}
|
|
896
|
+
const parsed = {};
|
|
897
|
+
for (const [chainKey, list] of Object.entries(value)) {
|
|
898
|
+
if (!Array.isArray(list)) return null;
|
|
899
|
+
const tokens = [];
|
|
900
|
+
for (const entry of list) {
|
|
901
|
+
if (typeof entry !== "object" || entry === null) return null;
|
|
902
|
+
const { symbol, address, decimals } = entry;
|
|
903
|
+
if (typeof symbol !== "string" || typeof address !== "string" || typeof decimals !== "number") {
|
|
904
|
+
return null;
|
|
905
|
+
}
|
|
906
|
+
tokens.push({ symbol, address, decimals });
|
|
907
|
+
}
|
|
908
|
+
parsed[chainKey] = tokens;
|
|
909
|
+
}
|
|
910
|
+
return parsed;
|
|
911
|
+
}
|
|
912
|
+
async function requestTopTokens() {
|
|
913
|
+
try {
|
|
914
|
+
const response = await fetch(apiUrl("/qr/tokens"), {
|
|
915
|
+
method: "GET",
|
|
916
|
+
headers: _chunkNEXUCY4Bcjs.SERVICE_HEADERS
|
|
917
|
+
});
|
|
918
|
+
if (!response.ok) {
|
|
919
|
+
debugLog(debug, scope, "getTopTokens:unavailable", {
|
|
920
|
+
status: response.status
|
|
921
|
+
});
|
|
922
|
+
return null;
|
|
923
|
+
}
|
|
924
|
+
const data = await response.json();
|
|
925
|
+
const tokens = parseTopTokens(data.tokens);
|
|
926
|
+
if (!tokens) {
|
|
927
|
+
debugLog(debug, scope, "getTopTokens:malformed");
|
|
928
|
+
return null;
|
|
929
|
+
}
|
|
930
|
+
debugLog(debug, scope, "getTopTokens:success", {
|
|
931
|
+
chains: Object.keys(tokens).length
|
|
932
|
+
});
|
|
933
|
+
return tokens;
|
|
934
|
+
} catch (error) {
|
|
935
|
+
debugError(debug, scope, "getTopTokens:error", error);
|
|
936
|
+
return null;
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
function cachedPortfolio(key, fetcher, forceRefresh = false) {
|
|
940
|
+
const now = Date.now();
|
|
941
|
+
const entry = portfolioCache.get(key);
|
|
942
|
+
if (!forceRefresh && entry && entry.expiresAt > now) {
|
|
943
|
+
debugLog(debug, scope, "portfolio:cache-hit", { key });
|
|
944
|
+
return entry.promise;
|
|
945
|
+
}
|
|
946
|
+
let promise;
|
|
947
|
+
promise = fetcher().catch((err) => {
|
|
948
|
+
if (_optionalChain([portfolioCache, 'access', _11 => _11.get, 'call', _12 => _12(key), 'optionalAccess', _13 => _13.promise]) === promise) {
|
|
949
|
+
portfolioCache.delete(key);
|
|
950
|
+
}
|
|
951
|
+
throw err;
|
|
952
|
+
});
|
|
953
|
+
portfolioCache.set(key, {
|
|
954
|
+
promise,
|
|
955
|
+
expiresAt: now + PORTFOLIO_CACHE_TTL_MS
|
|
956
|
+
});
|
|
957
|
+
return promise;
|
|
958
|
+
}
|
|
959
|
+
return {
|
|
960
|
+
async registerManagedAccount(params) {
|
|
961
|
+
const url = apiUrl("/register-managed");
|
|
962
|
+
debugLog(debug, scope, "registerManagedAccount:request", {
|
|
963
|
+
url,
|
|
964
|
+
salt: params.salt,
|
|
965
|
+
targetChain: params.target.chain,
|
|
966
|
+
targetToken: params.target.token,
|
|
967
|
+
recipient: shortRef(params.target.recipient)
|
|
968
|
+
});
|
|
969
|
+
const response = await fetch(url, {
|
|
970
|
+
method: "POST",
|
|
971
|
+
headers: _chunkNEXUCY4Bcjs.SERVICE_HEADERS,
|
|
972
|
+
body: JSON.stringify({ account: params })
|
|
973
|
+
});
|
|
974
|
+
if (!response.ok) {
|
|
975
|
+
const error = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
976
|
+
debugError(
|
|
977
|
+
debug,
|
|
978
|
+
scope,
|
|
979
|
+
"registerManagedAccount:failed",
|
|
980
|
+
error,
|
|
981
|
+
{ status: response.status, salt: params.salt }
|
|
982
|
+
);
|
|
983
|
+
const detail = Array.isArray(error.details) ? error.details.map((d) => _optionalChain([d, 'optionalAccess', _14 => _14.message])).filter(Boolean).join("; ") : void 0;
|
|
984
|
+
const base = error.error || `Account registration failed: ${response.status}`;
|
|
985
|
+
throw new Error(detail ? `${base}: ${detail}` : base);
|
|
986
|
+
}
|
|
987
|
+
const result = await response.json();
|
|
988
|
+
debugLog(debug, scope, "registerManagedAccount:success", {
|
|
989
|
+
evmDepositAddress: _optionalChain([result, 'optionalAccess', _15 => _15.evmDepositAddress]),
|
|
990
|
+
hasSolanaDepositAddress: Boolean(_optionalChain([result, 'optionalAccess', _16 => _16.solanaDepositAddress])),
|
|
991
|
+
hasTronDepositAddress: Boolean(_optionalChain([result, 'optionalAccess', _17 => _17.tronDepositAddress]))
|
|
992
|
+
});
|
|
993
|
+
return {
|
|
994
|
+
...result,
|
|
995
|
+
evmDepositAddress: normalizeEvmAddress(_optionalChain([result, 'optionalAccess', _18 => _18.evmDepositAddress]))
|
|
996
|
+
};
|
|
997
|
+
},
|
|
998
|
+
async fetchPortfolio(address, options2) {
|
|
999
|
+
return cachedPortfolio(`evm:${address.toLowerCase()}`, async () => {
|
|
1000
|
+
const url = apiUrl(`/portfolio/${address}?includeUnsupported=true`);
|
|
1001
|
+
debugLog(debug, scope, "fetchPortfolio:request", { url, address });
|
|
1002
|
+
const response = await fetch(url, {
|
|
1003
|
+
method: "GET",
|
|
1004
|
+
headers: _chunkNEXUCY4Bcjs.SERVICE_HEADERS
|
|
1005
|
+
});
|
|
1006
|
+
if (!response.ok) {
|
|
1007
|
+
const error = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
1008
|
+
debugError(
|
|
1009
|
+
debug,
|
|
1010
|
+
scope,
|
|
1011
|
+
"fetchPortfolio:failed",
|
|
1012
|
+
error,
|
|
1013
|
+
{ status: response.status, address }
|
|
1014
|
+
);
|
|
1015
|
+
throw new Error(
|
|
1016
|
+
error.error || `Portfolio fetch failed: ${response.status}`
|
|
1017
|
+
);
|
|
1018
|
+
}
|
|
1019
|
+
const data = await response.json();
|
|
1020
|
+
const direct = normalizeDirectPortfolio(data);
|
|
1021
|
+
if (direct.tokens.length > 0) {
|
|
1022
|
+
debugLog(debug, scope, "fetchPortfolio:success", {
|
|
1023
|
+
address,
|
|
1024
|
+
source: "direct",
|
|
1025
|
+
tokenCount: direct.tokens.length,
|
|
1026
|
+
totalUsd: direct.totalUsd
|
|
1027
|
+
});
|
|
1028
|
+
return direct;
|
|
1029
|
+
}
|
|
1030
|
+
const portfolioData = extractOrchestratorPortfolio(data);
|
|
1031
|
+
if (portfolioData) {
|
|
1032
|
+
const normalized = normalizeOrchestratorPortfolio(portfolioData);
|
|
1033
|
+
debugLog(debug, scope, "fetchPortfolio:success", {
|
|
1034
|
+
address,
|
|
1035
|
+
source: "orchestrator",
|
|
1036
|
+
tokenCount: normalized.tokens.length,
|
|
1037
|
+
totalUsd: normalized.totalUsd
|
|
1038
|
+
});
|
|
1039
|
+
return normalized;
|
|
1040
|
+
}
|
|
1041
|
+
debugLog(debug, scope, "fetchPortfolio:empty", { address });
|
|
1042
|
+
return { tokens: [], totalUsd: 0 };
|
|
1043
|
+
}, _optionalChain([options2, 'optionalAccess', _19 => _19.forceRefresh]));
|
|
1044
|
+
},
|
|
1045
|
+
async fetchSolanaPortfolio(address, options2) {
|
|
1046
|
+
return cachedPortfolio(`sol:${address}`, async () => {
|
|
1047
|
+
const url = apiUrl(`/portfolio/solana/${address}`);
|
|
1048
|
+
debugLog(debug, scope, "fetchSolanaPortfolio:request", { url, address });
|
|
1049
|
+
const response = await fetch(url, {
|
|
1050
|
+
method: "GET",
|
|
1051
|
+
headers: _chunkNEXUCY4Bcjs.SERVICE_HEADERS
|
|
1052
|
+
});
|
|
1053
|
+
if (!response.ok) {
|
|
1054
|
+
const error = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
1055
|
+
debugError(
|
|
1056
|
+
debug,
|
|
1057
|
+
scope,
|
|
1058
|
+
"fetchSolanaPortfolio:failed",
|
|
1059
|
+
error,
|
|
1060
|
+
{ status: response.status, address }
|
|
1061
|
+
);
|
|
1062
|
+
throw new Error(
|
|
1063
|
+
error.error || `Solana portfolio fetch failed: ${response.status}`
|
|
1064
|
+
);
|
|
1065
|
+
}
|
|
1066
|
+
const data = await response.json();
|
|
1067
|
+
const normalized = normalizeDirectPortfolio(data);
|
|
1068
|
+
debugLog(debug, scope, "fetchSolanaPortfolio:success", {
|
|
1069
|
+
address,
|
|
1070
|
+
tokenCount: normalized.tokens.length,
|
|
1071
|
+
totalUsd: normalized.totalUsd
|
|
1072
|
+
});
|
|
1073
|
+
return normalized;
|
|
1074
|
+
}, _optionalChain([options2, 'optionalAccess', _20 => _20.forceRefresh]));
|
|
1075
|
+
},
|
|
1076
|
+
async checkAccount(address) {
|
|
1077
|
+
const url = apiUrl(`/check/${address}`);
|
|
1078
|
+
debugLog(debug, scope, "checkAccount:request", { url, address });
|
|
1079
|
+
const response = await fetch(url, {
|
|
1080
|
+
method: "GET",
|
|
1081
|
+
headers: _chunkNEXUCY4Bcjs.SERVICE_HEADERS
|
|
1082
|
+
});
|
|
1083
|
+
if (!response.ok) {
|
|
1084
|
+
const error = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
1085
|
+
debugError(
|
|
1086
|
+
debug,
|
|
1087
|
+
scope,
|
|
1088
|
+
"checkAccount:failed",
|
|
1089
|
+
error,
|
|
1090
|
+
{ status: response.status, address }
|
|
1091
|
+
);
|
|
1092
|
+
throw new Error(error.error || `Account check failed: ${response.status}`);
|
|
1093
|
+
}
|
|
1094
|
+
const data = await response.json();
|
|
1095
|
+
const result = {
|
|
1096
|
+
isRegistered: _optionalChain([data, 'optionalAccess', _21 => _21.isRegistered]) === true,
|
|
1097
|
+
targetChain: _optionalChain([data, 'optionalAccess', _22 => _22.targetChain]),
|
|
1098
|
+
targetToken: _optionalChain([data, 'optionalAccess', _23 => _23.targetToken])
|
|
1099
|
+
};
|
|
1100
|
+
debugLog(debug, scope, "checkAccount:success", {
|
|
1101
|
+
address,
|
|
1102
|
+
isRegistered: result.isRegistered,
|
|
1103
|
+
targetChain: result.targetChain,
|
|
1104
|
+
targetToken: result.targetToken
|
|
1105
|
+
});
|
|
1106
|
+
return result;
|
|
1107
|
+
},
|
|
1108
|
+
async fetchStatus(address, txHash) {
|
|
1109
|
+
const normalized = txHash.startsWith("0x") || txHash.startsWith("0X") ? txHash.toLowerCase() : txHash;
|
|
1110
|
+
const txHashParam = encodeURIComponent(normalized);
|
|
1111
|
+
const url = apiUrl(
|
|
1112
|
+
`/deposits?account=${encodeURIComponent(address)}&txHash=${txHashParam}&limit=1`
|
|
1113
|
+
);
|
|
1114
|
+
const response = await fetch(url, {
|
|
1115
|
+
method: "GET",
|
|
1116
|
+
headers: _chunkNEXUCY4Bcjs.SERVICE_HEADERS,
|
|
1117
|
+
cache: "no-store"
|
|
1118
|
+
});
|
|
1119
|
+
if (!response.ok) {
|
|
1120
|
+
debugLog(debug, scope, "fetchStatus:miss", {
|
|
1121
|
+
address,
|
|
1122
|
+
txHash: shortRef(normalized),
|
|
1123
|
+
status: response.status
|
|
1124
|
+
});
|
|
1125
|
+
return { lastEvent: void 0 };
|
|
1126
|
+
}
|
|
1127
|
+
const body = await response.json();
|
|
1128
|
+
const row = _optionalChain([body, 'access', _24 => _24.deposits, 'optionalAccess', _25 => _25[0]]);
|
|
1129
|
+
const lastEvent = row ? depositRowToEvent(row) : void 0;
|
|
1130
|
+
debugLog(debug, scope, "fetchStatus:success", {
|
|
1131
|
+
address,
|
|
1132
|
+
txHash: shortRef(normalized),
|
|
1133
|
+
eventType: _optionalChain([lastEvent, 'optionalAccess', _26 => _26.type])
|
|
1134
|
+
});
|
|
1135
|
+
return { lastEvent };
|
|
1136
|
+
},
|
|
1137
|
+
async lookupRecoverableDeposits(params) {
|
|
1138
|
+
const txHashParam = params.txHash.startsWith("0x") ? params.txHash.toLowerCase() : params.txHash;
|
|
1139
|
+
const url = apiUrl(
|
|
1140
|
+
`/deposits?txHash=${encodeURIComponent(txHashParam)}&includeSpam=true`
|
|
1141
|
+
);
|
|
1142
|
+
const response = await fetch(url, {
|
|
1143
|
+
method: "GET",
|
|
1144
|
+
headers: _chunkNEXUCY4Bcjs.SERVICE_HEADERS,
|
|
1145
|
+
cache: "no-store"
|
|
1146
|
+
});
|
|
1147
|
+
if (!response.ok) {
|
|
1148
|
+
const error = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
1149
|
+
debugError(debug, scope, "lookupRecoverableDeposits:failed", error, {
|
|
1150
|
+
status: response.status
|
|
1151
|
+
});
|
|
1152
|
+
throw new Error(error.error || `Lookup failed: ${response.status}`);
|
|
1153
|
+
}
|
|
1154
|
+
const body = await response.json();
|
|
1155
|
+
const deposits = _nullishCoalesce(body.deposits, () => ( []));
|
|
1156
|
+
debugLog(debug, scope, "lookupRecoverableDeposits:success", {
|
|
1157
|
+
txHash: shortRef(txHashParam),
|
|
1158
|
+
count: deposits.length
|
|
1159
|
+
});
|
|
1160
|
+
return deposits;
|
|
1161
|
+
},
|
|
1162
|
+
async fetchLatestStatus(address) {
|
|
1163
|
+
const url = apiUrl(
|
|
1164
|
+
`/deposits?account=${encodeURIComponent(address)}&limit=1`
|
|
1165
|
+
);
|
|
1166
|
+
const response = await fetch(url, {
|
|
1167
|
+
method: "GET",
|
|
1168
|
+
headers: _chunkNEXUCY4Bcjs.SERVICE_HEADERS,
|
|
1169
|
+
cache: "no-store"
|
|
1170
|
+
});
|
|
1171
|
+
if (!response.ok) {
|
|
1172
|
+
debugLog(debug, scope, "fetchLatestStatus:miss", {
|
|
1173
|
+
address,
|
|
1174
|
+
status: response.status
|
|
1175
|
+
});
|
|
1176
|
+
return { lastEvent: void 0 };
|
|
1177
|
+
}
|
|
1178
|
+
const body = await response.json();
|
|
1179
|
+
const row = _optionalChain([body, 'access', _27 => _27.deposits, 'optionalAccess', _28 => _28[0]]);
|
|
1180
|
+
const lastEvent = row ? depositRowToEvent(row) : void 0;
|
|
1181
|
+
debugLog(debug, scope, "fetchLatestStatus:success", {
|
|
1182
|
+
address,
|
|
1183
|
+
eventType: _optionalChain([lastEvent, 'optionalAccess', _29 => _29.type])
|
|
1184
|
+
});
|
|
1185
|
+
return { lastEvent };
|
|
1186
|
+
},
|
|
1187
|
+
async submitPolymarketWithdraw(params) {
|
|
1188
|
+
const { depositWallet, owner, nonce, deadline, calls, signature } = params;
|
|
1189
|
+
const url = apiUrl(`/polymarket/withdraw`);
|
|
1190
|
+
debugLog(debug, scope, "submitPolymarketWithdraw:request", {
|
|
1191
|
+
url,
|
|
1192
|
+
depositWallet,
|
|
1193
|
+
owner,
|
|
1194
|
+
nonce,
|
|
1195
|
+
callCount: calls.length
|
|
1196
|
+
});
|
|
1197
|
+
const response = await fetch(url, {
|
|
1198
|
+
method: "POST",
|
|
1199
|
+
headers: _chunkNEXUCY4Bcjs.SERVICE_HEADERS,
|
|
1200
|
+
body: JSON.stringify({
|
|
1201
|
+
depositWallet,
|
|
1202
|
+
owner,
|
|
1203
|
+
nonce,
|
|
1204
|
+
deadline,
|
|
1205
|
+
calls,
|
|
1206
|
+
signature
|
|
1207
|
+
})
|
|
1208
|
+
});
|
|
1209
|
+
if (!response.ok) {
|
|
1210
|
+
const error = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
1211
|
+
debugError(debug, scope, "submitPolymarketWithdraw:failed", error, {
|
|
1212
|
+
status: response.status,
|
|
1213
|
+
depositWallet,
|
|
1214
|
+
owner
|
|
1215
|
+
});
|
|
1216
|
+
throw new Error(
|
|
1217
|
+
error.error || `Polymarket withdraw failed: ${response.status}`
|
|
1218
|
+
);
|
|
1219
|
+
}
|
|
1220
|
+
const result = await response.json();
|
|
1221
|
+
debugLog(debug, scope, "submitPolymarketWithdraw:success", {
|
|
1222
|
+
depositWallet,
|
|
1223
|
+
txHash: _optionalChain([result, 'optionalAccess', _30 => _30.txHash]) ? shortRef(result.txHash) : void 0
|
|
1224
|
+
});
|
|
1225
|
+
return result;
|
|
1226
|
+
},
|
|
1227
|
+
async fetchDepositHistory(params) {
|
|
1228
|
+
const searchParams = new URLSearchParams({ recipient: params.recipient });
|
|
1229
|
+
searchParams.set("limit", String(_nullishCoalesce(params.limit, () => ( 20))));
|
|
1230
|
+
if (params.cursor) {
|
|
1231
|
+
searchParams.set("cursor", params.cursor);
|
|
1232
|
+
}
|
|
1233
|
+
const url = apiUrl(`/deposits?${searchParams.toString()}`);
|
|
1234
|
+
debugLog(debug, scope, "fetchDepositHistory:request", {
|
|
1235
|
+
url,
|
|
1236
|
+
recipient: shortRef(params.recipient),
|
|
1237
|
+
cursor: params.cursor
|
|
1238
|
+
});
|
|
1239
|
+
const response = await fetch(url, {
|
|
1240
|
+
method: "GET",
|
|
1241
|
+
headers: _chunkNEXUCY4Bcjs.SERVICE_HEADERS,
|
|
1242
|
+
cache: "no-store"
|
|
1243
|
+
});
|
|
1244
|
+
if (!response.ok) {
|
|
1245
|
+
const error = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
1246
|
+
debugError(
|
|
1247
|
+
debug,
|
|
1248
|
+
scope,
|
|
1249
|
+
"fetchDepositHistory:failed",
|
|
1250
|
+
error,
|
|
1251
|
+
{ status: response.status, recipient: shortRef(params.recipient) }
|
|
1252
|
+
);
|
|
1253
|
+
throw new Error(
|
|
1254
|
+
error.error || `Deposit history fetch failed: ${response.status}`
|
|
1255
|
+
);
|
|
1256
|
+
}
|
|
1257
|
+
const data = await response.json();
|
|
1258
|
+
const deposits = Array.isArray(_optionalChain([data, 'optionalAccess', _31 => _31.deposits])) ? data.deposits : [];
|
|
1259
|
+
const nextCursor = _nullishCoalesce(_nullishCoalesce(_optionalChain([data, 'optionalAccess', _32 => _32.nextCursor]), () => ( _optionalChain([data, 'optionalAccess', _33 => _33.next_cursor]))), () => ( null));
|
|
1260
|
+
debugLog(debug, scope, "fetchDepositHistory:success", {
|
|
1261
|
+
recipient: shortRef(params.recipient),
|
|
1262
|
+
count: deposits.length,
|
|
1263
|
+
hasMore: Boolean(nextCursor)
|
|
1264
|
+
});
|
|
1265
|
+
return { deposits, nextCursor };
|
|
1266
|
+
},
|
|
1267
|
+
async checkLiquidity(params) {
|
|
1268
|
+
if (params.destinationChainId === "solana") {
|
|
1269
|
+
const token = _chunkH577RJN5cjs.getSolanaTokenByMint.call(void 0, params.destinationToken);
|
|
1270
|
+
return {
|
|
1271
|
+
hasLiquidity: true,
|
|
1272
|
+
symbol: _nullishCoalesce(_optionalChain([token, 'optionalAccess', _34 => _34.symbol]), () => ( "Token")),
|
|
1273
|
+
decimals: _nullishCoalesce(_optionalChain([token, 'optionalAccess', _35 => _35.decimals]), () => ( 9)),
|
|
1274
|
+
unlimited: true,
|
|
1275
|
+
maxAmount: null
|
|
1276
|
+
};
|
|
1277
|
+
}
|
|
1278
|
+
const searchParams = new URLSearchParams({
|
|
1279
|
+
sourceChainId: String(params.sourceChainId),
|
|
1280
|
+
sourceToken: params.sourceToken,
|
|
1281
|
+
destinationChainId: String(params.destinationChainId),
|
|
1282
|
+
destinationToken: params.destinationToken,
|
|
1283
|
+
amount: params.amount
|
|
1284
|
+
});
|
|
1285
|
+
const url = apiUrl(`/liquidity?${searchParams.toString()}`);
|
|
1286
|
+
debugLog(debug, scope, "checkLiquidity:request", {
|
|
1287
|
+
url,
|
|
1288
|
+
sourceChainId: params.sourceChainId,
|
|
1289
|
+
destinationChainId: params.destinationChainId,
|
|
1290
|
+
amount: params.amount
|
|
1291
|
+
});
|
|
1292
|
+
const response = await fetch(url, {
|
|
1293
|
+
method: "GET",
|
|
1294
|
+
headers: _chunkNEXUCY4Bcjs.SERVICE_HEADERS,
|
|
1295
|
+
cache: "no-store"
|
|
1296
|
+
});
|
|
1297
|
+
if (!response.ok) {
|
|
1298
|
+
const error = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
1299
|
+
debugError(debug, scope, "checkLiquidity:failed", error, {
|
|
1300
|
+
status: response.status
|
|
1301
|
+
});
|
|
1302
|
+
throw new Error(
|
|
1303
|
+
error.error || `Liquidity check failed: ${response.status}`
|
|
1304
|
+
);
|
|
1305
|
+
}
|
|
1306
|
+
const data = await response.json();
|
|
1307
|
+
const result = {
|
|
1308
|
+
hasLiquidity: data.hasLiquidity === true,
|
|
1309
|
+
symbol: typeof data.symbol === "string" ? data.symbol : "",
|
|
1310
|
+
decimals: typeof data.decimals === "number" ? data.decimals : 0,
|
|
1311
|
+
unlimited: data.unlimited === true,
|
|
1312
|
+
maxAmount: typeof data.maxAmount === "string" ? data.maxAmount : null
|
|
1313
|
+
};
|
|
1314
|
+
debugLog(debug, scope, "checkLiquidity:success", {
|
|
1315
|
+
hasLiquidity: result.hasLiquidity,
|
|
1316
|
+
unlimited: result.unlimited,
|
|
1317
|
+
maxAmount: result.maxAmount
|
|
1318
|
+
});
|
|
1319
|
+
return result;
|
|
1320
|
+
},
|
|
1321
|
+
async getQuotePreview(params) {
|
|
1322
|
+
const url = apiUrl("/quotes/preview");
|
|
1323
|
+
const body = {
|
|
1324
|
+
account: params.account,
|
|
1325
|
+
// HyperCore has its own CAIP-2 namespace — never the eip155 placeholder.
|
|
1326
|
+
sourceChainId: params.sourceChainId === "hypercore" ? _chunkH577RJN5cjs.HYPERCORE_MAINNET_CAIP2 : `eip155:${params.sourceChainId}`,
|
|
1327
|
+
sourceToken: params.sourceToken,
|
|
1328
|
+
amount: params.amount
|
|
1329
|
+
};
|
|
1330
|
+
debugLog(debug, scope, "getQuotePreview:request", {
|
|
1331
|
+
url,
|
|
1332
|
+
sourceChainId: body.sourceChainId,
|
|
1333
|
+
sourceToken: params.sourceToken,
|
|
1334
|
+
amount: params.amount
|
|
1335
|
+
});
|
|
1336
|
+
try {
|
|
1337
|
+
const response = await fetch(url, {
|
|
1338
|
+
method: "POST",
|
|
1339
|
+
headers: _chunkNEXUCY4Bcjs.SERVICE_HEADERS,
|
|
1340
|
+
body: JSON.stringify(body),
|
|
1341
|
+
cache: "no-store"
|
|
1342
|
+
});
|
|
1343
|
+
if (!response.ok) {
|
|
1344
|
+
debugLog(debug, scope, "getQuotePreview:unavailable", {
|
|
1345
|
+
status: response.status
|
|
1346
|
+
});
|
|
1347
|
+
return null;
|
|
1348
|
+
}
|
|
1349
|
+
const quote = parseQuotePreview(await response.json());
|
|
1350
|
+
if (!quote) {
|
|
1351
|
+
debugLog(debug, scope, "getQuotePreview:unavailable", {
|
|
1352
|
+
status: response.status,
|
|
1353
|
+
reason: "malformed"
|
|
1354
|
+
});
|
|
1355
|
+
return null;
|
|
1356
|
+
}
|
|
1357
|
+
debugLog(debug, scope, "getQuotePreview:success", {
|
|
1358
|
+
settlementLayer: quote.settlementLayer,
|
|
1359
|
+
totalUsd: quote.fees.total.usd
|
|
1360
|
+
});
|
|
1361
|
+
return quote;
|
|
1362
|
+
} catch (error) {
|
|
1363
|
+
debugError(debug, scope, "getQuotePreview:error", error);
|
|
1364
|
+
return null;
|
|
1365
|
+
}
|
|
1366
|
+
},
|
|
1367
|
+
async fetchPrices(symbols) {
|
|
1368
|
+
const list = symbols.filter((s) => s.length > 0);
|
|
1369
|
+
if (list.length === 0) return {};
|
|
1370
|
+
const url = apiUrl(
|
|
1371
|
+
`/prices?${new URLSearchParams({ symbols: list.join(",") }).toString()}`
|
|
1372
|
+
);
|
|
1373
|
+
try {
|
|
1374
|
+
const response = await fetch(url, {
|
|
1375
|
+
method: "GET",
|
|
1376
|
+
headers: _chunkNEXUCY4Bcjs.SERVICE_HEADERS,
|
|
1377
|
+
cache: "no-store"
|
|
1378
|
+
});
|
|
1379
|
+
if (!response.ok) {
|
|
1380
|
+
debugError(debug, scope, "fetchPrices:failed", {
|
|
1381
|
+
status: response.status
|
|
1382
|
+
});
|
|
1383
|
+
return {};
|
|
1384
|
+
}
|
|
1385
|
+
const data = await response.json();
|
|
1386
|
+
return Object.fromEntries(
|
|
1387
|
+
Object.entries(_nullishCoalesce(data.prices, () => ( {}))).map(([symbol, price]) => [
|
|
1388
|
+
symbol.toUpperCase(),
|
|
1389
|
+
price
|
|
1390
|
+
])
|
|
1391
|
+
);
|
|
1392
|
+
} catch (err) {
|
|
1393
|
+
debugError(debug, scope, "fetchPrices:error", err);
|
|
1394
|
+
return {};
|
|
1395
|
+
}
|
|
1396
|
+
},
|
|
1397
|
+
async fetchPricesByAddress(caip2Ids) {
|
|
1398
|
+
const list = caip2Ids.filter((id) => id.length > 0);
|
|
1399
|
+
if (list.length === 0) return {};
|
|
1400
|
+
const url = apiUrl(
|
|
1401
|
+
`/prices?${new URLSearchParams({ addresses: list.join(",") }).toString()}`
|
|
1402
|
+
);
|
|
1403
|
+
try {
|
|
1404
|
+
const response = await fetch(url, {
|
|
1405
|
+
method: "GET",
|
|
1406
|
+
headers: _chunkNEXUCY4Bcjs.SERVICE_HEADERS,
|
|
1407
|
+
cache: "no-store"
|
|
1408
|
+
});
|
|
1409
|
+
if (!response.ok) {
|
|
1410
|
+
debugError(debug, scope, "fetchPricesByAddress:failed", {
|
|
1411
|
+
status: response.status
|
|
1412
|
+
});
|
|
1413
|
+
return {};
|
|
1414
|
+
}
|
|
1415
|
+
const data = await response.json();
|
|
1416
|
+
return _nullishCoalesce(data.prices, () => ( {}));
|
|
1417
|
+
} catch (err) {
|
|
1418
|
+
debugError(debug, scope, "fetchPricesByAddress:error", err);
|
|
1419
|
+
return {};
|
|
1420
|
+
}
|
|
1421
|
+
},
|
|
1422
|
+
async getSwappedWidgetUrl(params) {
|
|
1423
|
+
const url = apiUrl("/onramp/swapped/widget-url");
|
|
1424
|
+
debugLog(debug, scope, "getSwappedWidgetUrl:request", {
|
|
1425
|
+
smartAccount: shortRef(params.smartAccount),
|
|
1426
|
+
method: params.method,
|
|
1427
|
+
methodSelectionSource: params.methodSelectionSource
|
|
1428
|
+
});
|
|
1429
|
+
const response = await fetch(url, {
|
|
1430
|
+
method: "POST",
|
|
1431
|
+
headers: _chunkNEXUCY4Bcjs.SERVICE_HEADERS,
|
|
1432
|
+
body: JSON.stringify(params)
|
|
1433
|
+
});
|
|
1434
|
+
if (!response.ok) {
|
|
1435
|
+
const error = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
1436
|
+
debugError(debug, scope, "getSwappedWidgetUrl:failed", error, {
|
|
1437
|
+
status: response.status
|
|
1438
|
+
});
|
|
1439
|
+
throw new Error(
|
|
1440
|
+
error.error || `Swapped widget URL failed: ${response.status}`
|
|
1441
|
+
);
|
|
1442
|
+
}
|
|
1443
|
+
const body = await response.json();
|
|
1444
|
+
if (typeof body.url !== "string" || typeof body.currencyCode !== "string" || typeof body.externalCustomerId !== "string") {
|
|
1445
|
+
throw new Error("Swapped widget URL: malformed response");
|
|
1446
|
+
}
|
|
1447
|
+
return {
|
|
1448
|
+
url: body.url,
|
|
1449
|
+
currencyCode: body.currencyCode,
|
|
1450
|
+
sandbox: body.sandbox === true,
|
|
1451
|
+
externalCustomerId: body.externalCustomerId,
|
|
1452
|
+
expiresAt: body.expiresAt
|
|
1453
|
+
};
|
|
1454
|
+
},
|
|
1455
|
+
async getSwappedConnectUrl(params) {
|
|
1456
|
+
const url = apiUrl("/onramp/swapped/connect-url");
|
|
1457
|
+
debugLog(debug, scope, "getSwappedConnectUrl:request", {
|
|
1458
|
+
smartAccount: shortRef(params.smartAccount),
|
|
1459
|
+
connection: params.connection
|
|
1460
|
+
});
|
|
1461
|
+
const response = await fetch(url, {
|
|
1462
|
+
method: "POST",
|
|
1463
|
+
headers: _chunkNEXUCY4Bcjs.SERVICE_HEADERS,
|
|
1464
|
+
body: JSON.stringify(params)
|
|
1465
|
+
});
|
|
1466
|
+
if (!response.ok) {
|
|
1467
|
+
const error = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
1468
|
+
debugError(debug, scope, "getSwappedConnectUrl:failed", error, {
|
|
1469
|
+
status: response.status
|
|
1470
|
+
});
|
|
1471
|
+
const currentFeeBps = parseExchangeFeeBps(error.exchangeFeeBps);
|
|
1472
|
+
if (response.status === 409 && currentFeeBps !== void 0) {
|
|
1473
|
+
throw new SwappedConnectFeeChangedError(
|
|
1474
|
+
currentFeeBps,
|
|
1475
|
+
typeof error.error === "string" ? error.error : void 0
|
|
1476
|
+
);
|
|
1477
|
+
}
|
|
1478
|
+
throw new Error(
|
|
1479
|
+
typeof error.error === "string" && error.error || `Swapped Connect URL failed: ${response.status}`
|
|
1480
|
+
);
|
|
1481
|
+
}
|
|
1482
|
+
const body = await response.json();
|
|
1483
|
+
if (typeof body.url !== "string" || typeof body.currencyCode !== "string" || typeof body.externalCustomerId !== "string") {
|
|
1484
|
+
throw new Error("Swapped Connect URL: malformed response");
|
|
1485
|
+
}
|
|
1486
|
+
return {
|
|
1487
|
+
url: body.url,
|
|
1488
|
+
currencyCode: body.currencyCode,
|
|
1489
|
+
sandbox: body.sandbox === true,
|
|
1490
|
+
externalCustomerId: body.externalCustomerId,
|
|
1491
|
+
expiresAt: body.expiresAt,
|
|
1492
|
+
exchangeFeeBps: parseExchangeFeeBps(body.exchangeFeeBps)
|
|
1493
|
+
};
|
|
1494
|
+
},
|
|
1495
|
+
async getSwappedConnectExchanges() {
|
|
1496
|
+
const url = apiUrl("/onramp/swapped/connect-exchanges");
|
|
1497
|
+
debugLog(debug, scope, "getSwappedConnectExchanges:request");
|
|
1498
|
+
const response = await fetch(url, {
|
|
1499
|
+
method: "GET",
|
|
1500
|
+
headers: _chunkNEXUCY4Bcjs.SERVICE_HEADERS,
|
|
1501
|
+
cache: "no-store"
|
|
1502
|
+
});
|
|
1503
|
+
if (!response.ok) {
|
|
1504
|
+
const error = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
1505
|
+
debugError(debug, scope, "getSwappedConnectExchanges:failed", error, {
|
|
1506
|
+
status: response.status
|
|
1507
|
+
});
|
|
1508
|
+
throw new Error(
|
|
1509
|
+
error.error || `Swapped Connect exchanges failed: ${response.status}`
|
|
1510
|
+
);
|
|
1511
|
+
}
|
|
1512
|
+
const body = await response.json();
|
|
1513
|
+
const rawExchanges = Array.isArray(body.exchanges) ? body.exchanges : null;
|
|
1514
|
+
const exchanges = [];
|
|
1515
|
+
let hasMalformedExchange = rawExchanges === null;
|
|
1516
|
+
for (const exchange of _nullishCoalesce(rawExchanges, () => ( []))) {
|
|
1517
|
+
if (!exchange || typeof exchange !== "object") {
|
|
1518
|
+
hasMalformedExchange = true;
|
|
1519
|
+
continue;
|
|
1520
|
+
}
|
|
1521
|
+
const raw = exchange;
|
|
1522
|
+
const connection = typeof raw.connection === "string" ? raw.connection : "";
|
|
1523
|
+
const name = typeof raw.name === "string" ? raw.name : "";
|
|
1524
|
+
const logoUrl = typeof raw.logoUrl === "string" || raw.logoUrl === null ? raw.logoUrl : null;
|
|
1525
|
+
if (!connection || !name) {
|
|
1526
|
+
hasMalformedExchange = true;
|
|
1527
|
+
continue;
|
|
1528
|
+
}
|
|
1529
|
+
exchanges.push({ connection, name, logoUrl });
|
|
1530
|
+
}
|
|
1531
|
+
if (hasMalformedExchange || typeof body.fetchedAt !== "string" || typeof body.expiresAt !== "string") {
|
|
1532
|
+
throw new Error("Swapped Connect exchanges: malformed response");
|
|
1533
|
+
}
|
|
1534
|
+
return {
|
|
1535
|
+
exchanges,
|
|
1536
|
+
fetchedAt: body.fetchedAt,
|
|
1537
|
+
expiresAt: body.expiresAt,
|
|
1538
|
+
stale: body.stale === true ? true : void 0,
|
|
1539
|
+
exchangeFeeBps: parseExchangeFeeBps(body.exchangeFeeBps)
|
|
1540
|
+
};
|
|
1541
|
+
},
|
|
1542
|
+
async getSwappedPaymentMethods() {
|
|
1543
|
+
const empty = {
|
|
1544
|
+
country: null,
|
|
1545
|
+
methods: [],
|
|
1546
|
+
recommendedMethod: null
|
|
1547
|
+
};
|
|
1548
|
+
const url = apiUrl("/onramp/swapped/payment-methods");
|
|
1549
|
+
debugLog(debug, scope, "getSwappedPaymentMethods:request");
|
|
1550
|
+
try {
|
|
1551
|
+
const response = await fetch(url, {
|
|
1552
|
+
method: "GET",
|
|
1553
|
+
headers: _chunkNEXUCY4Bcjs.SERVICE_HEADERS,
|
|
1554
|
+
cache: "no-store"
|
|
1555
|
+
});
|
|
1556
|
+
if (!response.ok) {
|
|
1557
|
+
debugLog(debug, scope, "getSwappedPaymentMethods:unavailable", {
|
|
1558
|
+
status: response.status
|
|
1559
|
+
});
|
|
1560
|
+
return empty;
|
|
1561
|
+
}
|
|
1562
|
+
const body = await response.json();
|
|
1563
|
+
if (!body || typeof body !== "object" || Array.isArray(body)) {
|
|
1564
|
+
return empty;
|
|
1565
|
+
}
|
|
1566
|
+
const rawBody = body;
|
|
1567
|
+
const rawCountry = rawBody.country;
|
|
1568
|
+
const country = typeof rawCountry === "string" ? rawCountry.trim().toUpperCase() : rawCountry === null ? null : void 0;
|
|
1569
|
+
if (country === void 0 || country !== null && !/^[A-Z]{2}$/.test(country)) {
|
|
1570
|
+
return empty;
|
|
1571
|
+
}
|
|
1572
|
+
const rawRecommendedMethod = rawBody.recommendedMethod;
|
|
1573
|
+
const recommendedMethod = typeof rawRecommendedMethod === "string" && /^[a-z0-9][a-z0-9_-]{0,63}$/.test(rawRecommendedMethod) ? rawRecommendedMethod : rawRecommendedMethod === null ? null : void 0;
|
|
1574
|
+
if (recommendedMethod === void 0 || !Array.isArray(rawBody.methods)) {
|
|
1575
|
+
return empty;
|
|
1576
|
+
}
|
|
1577
|
+
const methods = [];
|
|
1578
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1579
|
+
for (const raw of rawBody.methods) {
|
|
1580
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
|
|
1581
|
+
return empty;
|
|
1582
|
+
}
|
|
1583
|
+
const m = raw;
|
|
1584
|
+
const method = typeof m.method === "string" && /^[a-z0-9][a-z0-9_-]{0,63}$/.test(m.method) ? m.method : null;
|
|
1585
|
+
const label = typeof m.label === "string" && m.label.trim().length > 0 ? m.label.trim() : null;
|
|
1586
|
+
const iconUrl = typeof m.iconUrl === "string" ? m.iconUrl : m.iconUrl === null ? null : void 0;
|
|
1587
|
+
const iconUrlLight = typeof m.iconUrlLight === "string" ? m.iconUrlLight : m.iconUrlLight === null ? null : void 0;
|
|
1588
|
+
const minAmount = typeof m.minAmount === "number" && Number.isFinite(m.minAmount) && m.minAmount >= 0 ? m.minAmount : m.minAmount === null ? null : void 0;
|
|
1589
|
+
const maxAmount = typeof m.maxAmount === "number" && Number.isFinite(m.maxAmount) && m.maxAmount >= 0 ? m.maxAmount : m.maxAmount === null ? null : void 0;
|
|
1590
|
+
const badge = m.badge === "Popular" ? "Popular" : m.badge === null ? null : void 0;
|
|
1591
|
+
if (!method || !label || iconUrl === void 0 || iconUrlLight === void 0 || minAmount === void 0 || maxAmount === void 0 || badge === void 0 || seen.has(method)) {
|
|
1592
|
+
return empty;
|
|
1593
|
+
}
|
|
1594
|
+
seen.add(method);
|
|
1595
|
+
methods.push({
|
|
1596
|
+
method,
|
|
1597
|
+
label,
|
|
1598
|
+
iconUrl,
|
|
1599
|
+
iconUrlLight,
|
|
1600
|
+
minAmount,
|
|
1601
|
+
maxAmount,
|
|
1602
|
+
badge
|
|
1603
|
+
});
|
|
1604
|
+
}
|
|
1605
|
+
if (country === null && (methods.length > 0 || recommendedMethod !== null) || recommendedMethod !== null && !seen.has(recommendedMethod)) {
|
|
1606
|
+
return empty;
|
|
1607
|
+
}
|
|
1608
|
+
return { country, methods, recommendedMethod };
|
|
1609
|
+
} catch (error) {
|
|
1610
|
+
debugError(debug, scope, "getSwappedPaymentMethods:error", error);
|
|
1611
|
+
return empty;
|
|
1612
|
+
}
|
|
1613
|
+
},
|
|
1614
|
+
getTopTokens() {
|
|
1615
|
+
if (!topTokensPromise) {
|
|
1616
|
+
const attempt = requestTopTokens().then((tokens) => {
|
|
1617
|
+
if (!tokens && topTokensPromise === attempt) topTokensPromise = null;
|
|
1618
|
+
return tokens;
|
|
1619
|
+
});
|
|
1620
|
+
topTokensPromise = attempt;
|
|
1621
|
+
}
|
|
1622
|
+
return topTokensPromise;
|
|
1623
|
+
},
|
|
1624
|
+
async getSetup() {
|
|
1625
|
+
const url = apiUrl("/setup");
|
|
1626
|
+
try {
|
|
1627
|
+
const response = await fetch(url, {
|
|
1628
|
+
method: "GET",
|
|
1629
|
+
headers: _chunkNEXUCY4Bcjs.SERVICE_HEADERS,
|
|
1630
|
+
cache: "no-store"
|
|
1631
|
+
});
|
|
1632
|
+
if (!response.ok) {
|
|
1633
|
+
debugLog(debug, scope, "getSetup:unavailable", {
|
|
1634
|
+
status: response.status
|
|
1635
|
+
});
|
|
1636
|
+
return null;
|
|
1637
|
+
}
|
|
1638
|
+
const data = await response.json();
|
|
1639
|
+
debugLog(debug, scope, "getSetup:success", {
|
|
1640
|
+
hasWhitelist: Boolean(data.depositWhitelist),
|
|
1641
|
+
whitelistChains: data.depositWhitelist ? Object.keys(data.depositWhitelist).length : 0,
|
|
1642
|
+
minDepositUsd: data.minDepositUsd
|
|
1643
|
+
});
|
|
1644
|
+
return data;
|
|
1645
|
+
} catch (error) {
|
|
1646
|
+
debugError(debug, scope, "getSetup:error", error);
|
|
1647
|
+
return null;
|
|
1648
|
+
}
|
|
1649
|
+
},
|
|
1650
|
+
async fetchSwappedOrderStatus(smartAccount) {
|
|
1651
|
+
const url = apiUrl(
|
|
1652
|
+
`/onramp/swapped/status/${encodeURIComponent(smartAccount)}`
|
|
1653
|
+
);
|
|
1654
|
+
const response = await fetch(url, {
|
|
1655
|
+
method: "GET",
|
|
1656
|
+
headers: _chunkNEXUCY4Bcjs.SERVICE_HEADERS,
|
|
1657
|
+
cache: "no-store"
|
|
1658
|
+
});
|
|
1659
|
+
if (!response.ok) return null;
|
|
1660
|
+
let body = null;
|
|
1661
|
+
try {
|
|
1662
|
+
body = await response.json();
|
|
1663
|
+
} catch (e3) {
|
|
1664
|
+
return null;
|
|
1665
|
+
}
|
|
1666
|
+
if (!body || body.ok !== true) return null;
|
|
1667
|
+
const status = typeof body.status === "string" ? body.status : null;
|
|
1668
|
+
const orderId = typeof body.orderId === "string" ? body.orderId : null;
|
|
1669
|
+
if (!status || !orderId) return null;
|
|
1670
|
+
const numericOrNull = (v) => {
|
|
1671
|
+
if (typeof v === "number") {
|
|
1672
|
+
return Number.isFinite(v) ? v : null;
|
|
1673
|
+
}
|
|
1674
|
+
if (typeof v === "string" && v.trim().length > 0) {
|
|
1675
|
+
const parsed = Number(v);
|
|
1676
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
1677
|
+
}
|
|
1678
|
+
return null;
|
|
1679
|
+
};
|
|
1680
|
+
return {
|
|
1681
|
+
orderId,
|
|
1682
|
+
status,
|
|
1683
|
+
orderCrypto: typeof body.orderCrypto === "string" ? body.orderCrypto : null,
|
|
1684
|
+
orderCryptoAmount: typeof body.orderCryptoAmount === "string" ? body.orderCryptoAmount : null,
|
|
1685
|
+
transactionId: typeof body.transactionId === "string" ? body.transactionId : null,
|
|
1686
|
+
receivedAt: typeof body.receivedAt === "string" ? body.receivedAt : null,
|
|
1687
|
+
paidAmountUsd: numericOrNull(body.paidAmountUsd),
|
|
1688
|
+
paidAmountEur: numericOrNull(body.paidAmountEur),
|
|
1689
|
+
onrampFeeUsd: numericOrNull(body.onrampFeeUsd),
|
|
1690
|
+
paymentMethod: typeof body.paymentMethod === "string" ? body.paymentMethod : null
|
|
1691
|
+
};
|
|
1692
|
+
}
|
|
1693
|
+
};
|
|
1694
|
+
}
|
|
1695
|
+
function normalizeDirectPortfolio(data) {
|
|
1696
|
+
const rawTokens = _nullishCoalesce(_nullishCoalesce(extractArray(data, "tokens"), () => ( extractArray(
|
|
1697
|
+
_optionalChain([data, 'optionalAccess', _36 => _36.data]),
|
|
1698
|
+
"tokens"
|
|
1699
|
+
))), () => ( []));
|
|
1700
|
+
const totalUsd = _nullishCoalesce(_nullishCoalesce(extractNumber(data, "totalUsd"), () => ( extractNumber(_optionalChain([data, 'optionalAccess', _37 => _37.data]), "totalUsd"))), () => ( 0));
|
|
1701
|
+
const tokens = rawTokens.map((token) => normalizeDirectToken(token)).filter((token) => Boolean(token));
|
|
1702
|
+
return { tokens, totalUsd };
|
|
1703
|
+
}
|
|
1704
|
+
function extractOrchestratorPortfolio(data) {
|
|
1705
|
+
const portfolio = _nullishCoalesce(extractArray(data, "portfolio"), () => ( extractArray(
|
|
1706
|
+
_optionalChain([data, 'optionalAccess', _38 => _38.data]),
|
|
1707
|
+
"portfolio"
|
|
1708
|
+
)));
|
|
1709
|
+
if (!portfolio || !Array.isArray(portfolio)) return null;
|
|
1710
|
+
return { portfolio };
|
|
1711
|
+
}
|
|
1712
|
+
function normalizeOrchestratorPortfolio(data) {
|
|
1713
|
+
const tokens = [];
|
|
1714
|
+
for (const tokenData of data.portfolio || []) {
|
|
1715
|
+
const chainBalances = _nullishCoalesce(_nullishCoalesce(tokenData.tokenChainBalance, () => ( tokenData.chainBalances)), () => ( []));
|
|
1716
|
+
for (const chainBalance of chainBalances) {
|
|
1717
|
+
const unlocked = _nullishCoalesce(_optionalChain([chainBalance, 'access', _39 => _39.balance, 'optionalAccess', _40 => _40.unlocked]), () => ( "0"));
|
|
1718
|
+
const normalizedName = tokenData.tokenName.trim();
|
|
1719
|
+
const isNativeSymbol = normalizedName.toUpperCase() === "ETH" || normalizedName.toUpperCase() === "ETHER";
|
|
1720
|
+
const tokenAddress = _nullishCoalesce(_nullishCoalesce(chainBalance.tokenAddress, () => ( extractTokenAddress(tokenData, chainBalance.chainId))), () => ( _chunkH577RJN5cjs.getTokenAddress.call(void 0, tokenData.tokenName, chainBalance.chainId)));
|
|
1721
|
+
const resolvedTokenAddress = isNativeSymbol ? _chunkH577RJN5cjs.NATIVE_TOKEN_ADDRESS : tokenAddress;
|
|
1722
|
+
if (!resolvedTokenAddress) {
|
|
1723
|
+
continue;
|
|
1724
|
+
}
|
|
1725
|
+
const registrySymbol = _chunkH577RJN5cjs.getTokenSymbol.call(void 0, resolvedTokenAddress, chainBalance.chainId);
|
|
1726
|
+
const symbol = registrySymbol !== "Token" ? registrySymbol : normalizedName || "Token";
|
|
1727
|
+
const decimals = registrySymbol !== "Token" ? _chunkH577RJN5cjs.getTokenDecimalsByAddress.call(void 0, resolvedTokenAddress, chainBalance.chainId) : _nullishCoalesce(tokenData.tokenDecimals, () => ( 18));
|
|
1728
|
+
tokens.push({
|
|
1729
|
+
chainId: chainBalance.chainId,
|
|
1730
|
+
address: resolvedTokenAddress,
|
|
1731
|
+
symbol,
|
|
1732
|
+
name: symbol,
|
|
1733
|
+
decimals,
|
|
1734
|
+
balance: unlocked,
|
|
1735
|
+
balanceUsd: 0
|
|
1736
|
+
});
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1739
|
+
return {
|
|
1740
|
+
tokens,
|
|
1741
|
+
totalUsd: 0
|
|
1742
|
+
};
|
|
1743
|
+
}
|
|
1744
|
+
function normalizeDirectToken(token) {
|
|
1745
|
+
const rawChainId = _nullishCoalesce(extractNumber(token, "chainId"), () => ( extractNumber(token.chain, "id")));
|
|
1746
|
+
const rawChainString = _nullishCoalesce(extractString(token, "chainId"), () => ( extractString(token.chain, "id")));
|
|
1747
|
+
const chainId = _nullishCoalesce(rawChainId, () => ( (rawChainString ? _chunkH577RJN5cjs.isSolanaCaip2.call(void 0, rawChainString) || rawChainString.toLowerCase() === "solana" ? "solana" : (
|
|
1748
|
+
// HyperCore (`hypercore:mainnet`) is a non-EVM source; keep its USDC
|
|
1749
|
+
// instead of dropping it as an unparseable chain string.
|
|
1750
|
+
_chunkH577RJN5cjs.isHyperCoreCaip2.call(void 0, rawChainString) || rawChainString.toLowerCase() === "hypercore" ? "hypercore" : _chunkH577RJN5cjs.parseEvmChainId.call(void 0, rawChainString)
|
|
1751
|
+
) : null)));
|
|
1752
|
+
if (chainId === null) return null;
|
|
1753
|
+
const registryChainId = typeof chainId === "number" ? chainId : chainId === "hypercore" ? _chunkH577RJN5cjs.HYPERCORE_CHAIN_ID : void 0;
|
|
1754
|
+
const symbol = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(extractString(token, "symbol"), () => ( extractString(token, "tokenSymbol"))), () => ( extractString(token, "tokenName"))), () => ( extractString(token, "name")));
|
|
1755
|
+
if (!symbol) return null;
|
|
1756
|
+
const balanceValue = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(extractString(token, "balance"), () => ( extractString(token, "amount"))), () => ( extractString(token, "value"))), () => ( extractString(token, "rawBalance"))), () => ( _optionalChain([extractNumber, 'call', _41 => _41(token, "balance"), 'optionalAccess', _42 => _42.toString, 'call', _43 => _43()]))), () => ( _optionalChain([extractNumber, 'call', _44 => _44(token, "amount"), 'optionalAccess', _45 => _45.toString, 'call', _46 => _46()]))), () => ( _optionalChain([extractNumber, 'call', _47 => _47(token, "value"), 'optionalAccess', _48 => _48.toString, 'call', _49 => _49()]))), () => ( _optionalChain([extractNumber, 'call', _50 => _50(token, "rawBalance"), 'optionalAccess', _51 => _51.toString, 'call', _52 => _52()])));
|
|
1757
|
+
if (!balanceValue) return null;
|
|
1758
|
+
const address = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(extractString(token, "address"), () => ( extractString(token, "tokenAddress"))), () => ( extractString(
|
|
1759
|
+
token.token,
|
|
1760
|
+
"address"
|
|
1761
|
+
))), () => ( (registryChainId !== void 0 ? _chunkH577RJN5cjs.getTokenAddress.call(void 0, symbol, registryChainId) : void 0)));
|
|
1762
|
+
if (!address) return null;
|
|
1763
|
+
const balanceUsd = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(extractNumber(token, "balanceUsd"), () => ( extractNumber(token, "usdValue"))), () => ( extractNumber(token, "valueUsd"))), () => ( extractNumericString(token, "balanceUsd"))), () => ( extractNumericString(token, "usdValue"))), () => ( extractNumericString(token, "valueUsd"))), () => ( 0));
|
|
1764
|
+
const isSolanaToken = chainId === "solana";
|
|
1765
|
+
const registrySymbol = isSolanaToken ? "Token" : _chunkH577RJN5cjs.getTokenSymbol.call(void 0, address, registryChainId);
|
|
1766
|
+
const resolvedSymbol = isSolanaToken ? symbol : registrySymbol !== "Token" ? registrySymbol : symbol;
|
|
1767
|
+
const backendDecimals = _nullishCoalesce(extractNumber(token, "decimals"), () => ( extractNumber(token, "tokenDecimals")));
|
|
1768
|
+
const resolvedDecimals = !isSolanaToken && registrySymbol !== "Token" ? _chunkH577RJN5cjs.getTokenDecimalsByAddress.call(void 0, address, registryChainId) : _nullishCoalesce(backendDecimals, () => ( 18));
|
|
1769
|
+
return {
|
|
1770
|
+
chainId,
|
|
1771
|
+
address,
|
|
1772
|
+
symbol: resolvedSymbol,
|
|
1773
|
+
name: resolvedSymbol,
|
|
1774
|
+
decimals: resolvedDecimals,
|
|
1775
|
+
balance: balanceValue,
|
|
1776
|
+
balanceUsd
|
|
1777
|
+
};
|
|
1778
|
+
}
|
|
1779
|
+
function extractTokenAddress(tokenData, chainId) {
|
|
1780
|
+
const token = tokenData;
|
|
1781
|
+
return _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(token.tokenAddress, () => ( token.address)), () => ( _optionalChain([token, 'access', _53 => _53.addresses, 'optionalAccess', _54 => _54[chainId]]))), () => ( _optionalChain([token, 'access', _55 => _55.token, 'optionalAccess', _56 => _56.address]))), () => ( _optionalChain([token, 'access', _57 => _57.token, 'optionalAccess', _58 => _58.addresses, 'optionalAccess', _59 => _59[chainId]])));
|
|
1782
|
+
}
|
|
1783
|
+
function extractArray(data, key) {
|
|
1784
|
+
if (!data || typeof data !== "object") return null;
|
|
1785
|
+
const record = data;
|
|
1786
|
+
const value = record[key];
|
|
1787
|
+
return Array.isArray(value) ? value : null;
|
|
1788
|
+
}
|
|
1789
|
+
function extractNumber(data, key) {
|
|
1790
|
+
if (!data || typeof data !== "object") return null;
|
|
1791
|
+
const record = data;
|
|
1792
|
+
const value = record[key];
|
|
1793
|
+
return typeof value === "number" ? value : null;
|
|
1794
|
+
}
|
|
1795
|
+
function extractString(data, key) {
|
|
1796
|
+
if (!data || typeof data !== "object") return null;
|
|
1797
|
+
const record = data;
|
|
1798
|
+
const value = record[key];
|
|
1799
|
+
return typeof value === "string" ? value : null;
|
|
1800
|
+
}
|
|
1801
|
+
function extractNumericString(data, key) {
|
|
1802
|
+
const value = extractString(data, key);
|
|
1803
|
+
if (!value) return null;
|
|
1804
|
+
const parsed = Number(value);
|
|
1805
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
1806
|
+
}
|
|
1807
|
+
|
|
1808
|
+
// src/core/formatters.ts
|
|
1809
|
+
var currencyFormatter = new Intl.NumberFormat("en-US", {
|
|
1810
|
+
style: "currency",
|
|
1811
|
+
currency: "USD",
|
|
1812
|
+
maximumFractionDigits: 2
|
|
1813
|
+
});
|
|
1814
|
+
var tokenFormatter = new Intl.NumberFormat("en-US", {
|
|
1815
|
+
minimumFractionDigits: 2,
|
|
1816
|
+
maximumFractionDigits: 5
|
|
1817
|
+
});
|
|
1818
|
+
function isUnsupportedChainSwitchError(error) {
|
|
1819
|
+
if (!error) return false;
|
|
1820
|
+
const name = error instanceof Error ? error.name : "";
|
|
1821
|
+
const message = (error instanceof Error ? error.message : String(error)).toLowerCase();
|
|
1822
|
+
return name === "SwitchChainNotSupportedError" || message.includes("does not support programmatic chain switching") || message.includes("switch chain not supported") || message.includes("method not found") || message.includes("does not exist") || message.includes("is not available");
|
|
1823
|
+
}
|
|
1824
|
+
function formatUserError(raw) {
|
|
1825
|
+
const lower = raw.toLowerCase();
|
|
1826
|
+
if (lower.includes("user rejected") || lower.includes("user denied")) {
|
|
1827
|
+
return "Transaction cancelled";
|
|
1828
|
+
}
|
|
1829
|
+
if (lower.includes("insufficient funds")) {
|
|
1830
|
+
return "Insufficient funds for this transaction";
|
|
1831
|
+
}
|
|
1832
|
+
if (lower.includes("nonce too low") || lower.includes("nonce too high")) {
|
|
1833
|
+
return "Transaction conflict \u2014 please try again";
|
|
1834
|
+
}
|
|
1835
|
+
if (lower.includes("execution reverted")) {
|
|
1836
|
+
return "Transaction would fail on-chain";
|
|
1837
|
+
}
|
|
1838
|
+
if (lower.includes("timed out") || lower.includes("took too long")) {
|
|
1839
|
+
return "Request timed out \u2014 please try again";
|
|
1840
|
+
}
|
|
1841
|
+
if (lower.includes("econnrefused") || lower.includes("econnreset") || lower.includes("enotfound") || lower.includes("fetch failed")) {
|
|
1842
|
+
return "Service unavailable \u2014 please try again";
|
|
1843
|
+
}
|
|
1844
|
+
if (lower.includes("recent blockhash") || lower.includes("latest blockhash")) {
|
|
1845
|
+
return "Solana RPC unavailable \u2014 please retry";
|
|
1846
|
+
}
|
|
1847
|
+
if (lower.includes("network") || lower.includes("disconnected")) {
|
|
1848
|
+
return "Network error \u2014 check your connection";
|
|
1849
|
+
}
|
|
1850
|
+
if (lower.includes("rate limit") || lower.includes("429")) {
|
|
1851
|
+
return "Rate limited \u2014 please try again shortly";
|
|
1852
|
+
}
|
|
1853
|
+
let cleaned = raw;
|
|
1854
|
+
const stripMarkers = [
|
|
1855
|
+
"\n\nRequest Arguments:",
|
|
1856
|
+
"\nRaw Call Arguments:",
|
|
1857
|
+
"\nRequest body:",
|
|
1858
|
+
"\nContract Call:",
|
|
1859
|
+
"\nDocs:",
|
|
1860
|
+
"\nDetails:",
|
|
1861
|
+
"\nVersion:",
|
|
1862
|
+
"\nURL:"
|
|
1863
|
+
];
|
|
1864
|
+
for (const marker of stripMarkers) {
|
|
1865
|
+
const idx = cleaned.indexOf(marker);
|
|
1866
|
+
if (idx !== -1) {
|
|
1867
|
+
cleaned = cleaned.slice(0, idx).trim();
|
|
1868
|
+
}
|
|
1869
|
+
}
|
|
1870
|
+
cleaned = cleaned.replace(/https?:\/\/\S+/g, "").trim();
|
|
1871
|
+
if (cleaned.length === 0) {
|
|
1872
|
+
return "An unexpected error occurred";
|
|
1873
|
+
}
|
|
1874
|
+
if (cleaned.length > 120) {
|
|
1875
|
+
return cleaned.slice(0, 120) + "...";
|
|
1876
|
+
}
|
|
1877
|
+
return cleaned;
|
|
1878
|
+
}
|
|
1879
|
+
|
|
1880
|
+
// src/core/token-amount.ts
|
|
1881
|
+
|
|
1882
|
+
var STABLECOIN_SYMBOLS = /* @__PURE__ */ new Set([
|
|
1883
|
+
"USDC",
|
|
1884
|
+
"USDT",
|
|
1885
|
+
"USDT0",
|
|
1886
|
+
"DAI",
|
|
1887
|
+
"FRAX",
|
|
1888
|
+
"PYUSD",
|
|
1889
|
+
"USDP",
|
|
1890
|
+
"TUSD",
|
|
1891
|
+
"GUSD",
|
|
1892
|
+
"USDS",
|
|
1893
|
+
"LUSD",
|
|
1894
|
+
"BUSD",
|
|
1895
|
+
"USDE"
|
|
1896
|
+
]);
|
|
1897
|
+
var EVM_ADDRESS_RE = /^0x[a-fA-F0-9]{40}$/;
|
|
1898
|
+
function resolveTokenDisplay(token, chain, fallback) {
|
|
1899
|
+
if (token !== void 0) {
|
|
1900
|
+
if (chain === "solana") {
|
|
1901
|
+
const solanaToken = _chunkH577RJN5cjs.getSolanaTokenByMint.call(void 0, token);
|
|
1902
|
+
if (solanaToken) {
|
|
1903
|
+
return { symbol: solanaToken.symbol, decimals: solanaToken.decimals };
|
|
1904
|
+
}
|
|
1905
|
+
} else if (chain === "hypercore") {
|
|
1906
|
+
const t = _chunkH577RJN5cjs.HYPERCORE_SOURCE_TOKENS.find(
|
|
1907
|
+
(x) => x.address.toLowerCase() === token.toLowerCase()
|
|
1908
|
+
);
|
|
1909
|
+
if (t) return { symbol: t.symbol, decimals: t.decimals };
|
|
1910
|
+
} else if (EVM_ADDRESS_RE.test(token)) {
|
|
1911
|
+
const symbol = _chunkH577RJN5cjs.getTokenSymbol.call(void 0, token, chain);
|
|
1912
|
+
const decimals = _chunkH577RJN5cjs.findTokenDecimals.call(void 0, token, chain);
|
|
1913
|
+
if (symbol !== "Token" || decimals !== void 0) {
|
|
1914
|
+
return {
|
|
1915
|
+
symbol: symbol !== "Token" ? symbol : _nullishCoalesce(_optionalChain([fallback, 'optionalAccess', _60 => _60.symbol]), () => ( symbol)),
|
|
1916
|
+
decimals: _nullishCoalesce(decimals, () => ( _optionalChain([fallback, 'optionalAccess', _61 => _61.decimals])))
|
|
1917
|
+
};
|
|
1918
|
+
}
|
|
1919
|
+
}
|
|
1920
|
+
}
|
|
1921
|
+
return {
|
|
1922
|
+
symbol: _nullishCoalesce(_optionalChain([fallback, 'optionalAccess', _62 => _62.symbol]), () => ( "Token")),
|
|
1923
|
+
decimals: _optionalChain([fallback, 'optionalAccess', _63 => _63.decimals])
|
|
1924
|
+
};
|
|
1925
|
+
}
|
|
1926
|
+
function maxFractionDigitsFor(symbol) {
|
|
1927
|
+
if (!symbol) return 6;
|
|
1928
|
+
return STABLECOIN_SYMBOLS.has(symbol.toUpperCase()) ? 3 : 6;
|
|
1929
|
+
}
|
|
1930
|
+
function formatTokenAmount(amount, symbol) {
|
|
1931
|
+
if (!Number.isFinite(amount)) return void 0;
|
|
1932
|
+
return amount.toLocaleString("en-US", {
|
|
1933
|
+
minimumFractionDigits: 2,
|
|
1934
|
+
maximumFractionDigits: maxFractionDigitsFor(symbol)
|
|
1935
|
+
});
|
|
1936
|
+
}
|
|
1937
|
+
function tokenAmountToNumber(rawAmount, decimals) {
|
|
1938
|
+
if (decimals === void 0) return void 0;
|
|
1939
|
+
try {
|
|
1940
|
+
const value = Number(_viem.formatUnits.call(void 0, BigInt(rawAmount), decimals));
|
|
1941
|
+
return Number.isFinite(value) ? value : void 0;
|
|
1942
|
+
} catch (e4) {
|
|
1943
|
+
return void 0;
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
1946
|
+
function formatRawTokenAmount(rawAmount, token) {
|
|
1947
|
+
const value = tokenAmountToNumber(rawAmount, token.decimals);
|
|
1948
|
+
if (value === void 0) return void 0;
|
|
1949
|
+
return formatTokenAmount(value, token.symbol);
|
|
1950
|
+
}
|
|
1951
|
+
function isDisplayStablecoinSymbol(symbol) {
|
|
1952
|
+
return symbol !== void 0 && STABLECOIN_SYMBOLS.has(symbol.toUpperCase());
|
|
1953
|
+
}
|
|
1954
|
+
function priceUsdFor(symbol, prices) {
|
|
1955
|
+
if (!symbol) return void 0;
|
|
1956
|
+
const quoted = prices[symbol.toUpperCase()];
|
|
1957
|
+
return typeof quoted === "number" && quoted > 0 ? quoted : void 0;
|
|
1958
|
+
}
|
|
1959
|
+
function isRecognizedToken(address, chain) {
|
|
1960
|
+
if (address === void 0 || chain === void 0) return false;
|
|
1961
|
+
if (chain === "solana") return _chunkH577RJN5cjs.getSolanaTokenByMint.call(void 0, address) !== void 0;
|
|
1962
|
+
if (chain === "hypercore") {
|
|
1963
|
+
return _chunkH577RJN5cjs.HYPERCORE_SOURCE_TOKENS.some(
|
|
1964
|
+
(t) => t.address.toLowerCase() === address.toLowerCase()
|
|
1965
|
+
);
|
|
1966
|
+
}
|
|
1967
|
+
return EVM_ADDRESS_RE.test(address) && _chunkH577RJN5cjs.isRegistryTokenOnChain.call(void 0, address, chain);
|
|
1968
|
+
}
|
|
1969
|
+
function estimateReceiveAmount(params) {
|
|
1970
|
+
const {
|
|
1971
|
+
sourceAmount,
|
|
1972
|
+
sourceSymbol,
|
|
1973
|
+
targetSymbol,
|
|
1974
|
+
sourceAmountUsd,
|
|
1975
|
+
prices,
|
|
1976
|
+
sourceTrusted
|
|
1977
|
+
} = params;
|
|
1978
|
+
const trusted = sourceTrusted !== false;
|
|
1979
|
+
if (trusted && sourceSymbol !== void 0 && sourceSymbol.toUpperCase() === targetSymbol.toUpperCase()) {
|
|
1980
|
+
return sourceAmount;
|
|
1981
|
+
}
|
|
1982
|
+
if (!trusted) return void 0;
|
|
1983
|
+
const usdValue = sourceAmountUsd !== void 0 && Number.isFinite(sourceAmountUsd) ? sourceAmountUsd : sourceAmount !== void 0 ? (() => {
|
|
1984
|
+
const sourcePrice = priceUsdFor(sourceSymbol, prices);
|
|
1985
|
+
return sourcePrice !== void 0 ? sourceAmount * sourcePrice : void 0;
|
|
1986
|
+
})() : void 0;
|
|
1987
|
+
if (usdValue === void 0) return void 0;
|
|
1988
|
+
const targetPrice = priceUsdFor(targetSymbol, prices);
|
|
1989
|
+
if (targetPrice === void 0) return void 0;
|
|
1990
|
+
return usdValue / targetPrice;
|
|
1991
|
+
}
|
|
1992
|
+
function formatQuotedReceive(output, fallbackSymbol) {
|
|
1993
|
+
if (output.decimals === null) return void 0;
|
|
1994
|
+
let raw;
|
|
1995
|
+
try {
|
|
1996
|
+
raw = BigInt(output.amount);
|
|
1997
|
+
} catch (e5) {
|
|
1998
|
+
return void 0;
|
|
1999
|
+
}
|
|
2000
|
+
if (raw <= 0n) return void 0;
|
|
2001
|
+
const symbol = _nullishCoalesce(output.symbol, () => ( fallbackSymbol));
|
|
2002
|
+
const formatted = formatRawTokenAmount(raw, {
|
|
2003
|
+
symbol,
|
|
2004
|
+
decimals: output.decimals
|
|
2005
|
+
});
|
|
2006
|
+
if (formatted === void 0) return void 0;
|
|
2007
|
+
return `~${formatted} ${symbol}`;
|
|
2008
|
+
}
|
|
2009
|
+
function formatReceiveEstimate(params) {
|
|
2010
|
+
const estimate = estimateReceiveAmount(params);
|
|
2011
|
+
if (estimate === void 0) return void 0;
|
|
2012
|
+
const formatted = formatTokenAmount(estimate, params.targetSymbol);
|
|
2013
|
+
if (formatted === void 0) return void 0;
|
|
2014
|
+
const sameSymbol = params.sourceSymbol.toUpperCase() === params.targetSymbol.toUpperCase();
|
|
2015
|
+
return sameSymbol ? `${formatted} ${params.targetSymbol}` : `~${formatted} ${params.targetSymbol}`;
|
|
2016
|
+
}
|
|
2017
|
+
|
|
2018
|
+
// src/core/rpc.ts
|
|
2019
|
+
|
|
2020
|
+
function rpcUrlFor(rpcUrls, chain) {
|
|
2021
|
+
const url = _optionalChain([rpcUrls, 'optionalAccess', _64 => _64[chain], 'optionalAccess', _65 => _65.trim, 'call', _66 => _66()]);
|
|
2022
|
+
return url ? url : void 0;
|
|
2023
|
+
}
|
|
2024
|
+
var RpcUrlsContext = _react.createContext.call(void 0, void 0);
|
|
2025
|
+
var RpcUrlsProvider = RpcUrlsContext.Provider;
|
|
2026
|
+
function useRpcUrls() {
|
|
2027
|
+
return _react.useContext.call(void 0, RpcUrlsContext);
|
|
2028
|
+
}
|
|
2029
|
+
function rpcUrlsKey(rpcUrls) {
|
|
2030
|
+
if (!rpcUrls) return "";
|
|
2031
|
+
return Object.entries(rpcUrls).map(([chain, url]) => [chain, _nullishCoalesce(_optionalChain([url, 'optionalAccess', _67 => _67.trim, 'call', _68 => _68()]), () => ( ""))]).filter(([, url]) => url !== "").map(([chain, url]) => `${chain}=${url}`).sort().join("|");
|
|
2032
|
+
}
|
|
2033
|
+
function useStableRpcUrls(rpcUrls) {
|
|
2034
|
+
const key = rpcUrlsKey(rpcUrls);
|
|
2035
|
+
return _react.useMemo.call(void 0, () => rpcUrls, [key]);
|
|
2036
|
+
}
|
|
2037
|
+
|
|
2038
|
+
// src/core/theme.ts
|
|
2039
|
+
var RADIUS_SCALE = {
|
|
2040
|
+
none: { sm: "0", md: "0", lg: "0" },
|
|
2041
|
+
sm: { sm: "4px", md: "6px", lg: "8px" },
|
|
2042
|
+
md: { sm: "8px", md: "10px", lg: "14px" },
|
|
2043
|
+
lg: { sm: "10px", md: "14px", lg: "18px" },
|
|
2044
|
+
full: { sm: "9999px", md: "9999px", lg: "9999px" }
|
|
2045
|
+
};
|
|
2046
|
+
function setVar(targets, prop, value) {
|
|
2047
|
+
for (const el of targets) {
|
|
2048
|
+
el.style.setProperty(prop, value);
|
|
2049
|
+
}
|
|
2050
|
+
}
|
|
2051
|
+
function clearVar(targets, prop) {
|
|
2052
|
+
for (const el of targets) {
|
|
2053
|
+
el.style.removeProperty(prop);
|
|
2054
|
+
}
|
|
2055
|
+
}
|
|
2056
|
+
function normalizeHex(input) {
|
|
2057
|
+
const v = input.trim().replace(/^#/, "");
|
|
2058
|
+
if (/^[0-9a-fA-F]{3}$/.test(v)) {
|
|
2059
|
+
return v.split("").map((c) => c + c).join("").toLowerCase();
|
|
2060
|
+
}
|
|
2061
|
+
if (/^[0-9a-fA-F]{6}$/.test(v)) return v.toLowerCase();
|
|
2062
|
+
return null;
|
|
2063
|
+
}
|
|
2064
|
+
function hexToHsl(hex) {
|
|
2065
|
+
const normalized = normalizeHex(hex);
|
|
2066
|
+
if (!normalized) return null;
|
|
2067
|
+
const r = parseInt(normalized.slice(0, 2), 16) / 255;
|
|
2068
|
+
const g = parseInt(normalized.slice(2, 4), 16) / 255;
|
|
2069
|
+
const b = parseInt(normalized.slice(4, 6), 16) / 255;
|
|
2070
|
+
const max = Math.max(r, g, b);
|
|
2071
|
+
const min = Math.min(r, g, b);
|
|
2072
|
+
const l = (max + min) / 2;
|
|
2073
|
+
let h = 0;
|
|
2074
|
+
let s = 0;
|
|
2075
|
+
if (max !== min) {
|
|
2076
|
+
const d = max - min;
|
|
2077
|
+
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
|
2078
|
+
switch (max) {
|
|
2079
|
+
case r:
|
|
2080
|
+
h = (g - b) / d + (g < b ? 6 : 0);
|
|
2081
|
+
break;
|
|
2082
|
+
case g:
|
|
2083
|
+
h = (b - r) / d + 2;
|
|
2084
|
+
break;
|
|
2085
|
+
case b:
|
|
2086
|
+
h = (r - g) / d + 4;
|
|
2087
|
+
break;
|
|
2088
|
+
}
|
|
2089
|
+
h *= 60;
|
|
2090
|
+
}
|
|
2091
|
+
return { h, s: s * 100, l: l * 100 };
|
|
2092
|
+
}
|
|
2093
|
+
var clamp = (n, lo, hi) => Math.max(lo, Math.min(hi, n));
|
|
2094
|
+
var hsl = ({ h, s, l }) => `hsl(${h.toFixed(1)} ${clamp(s, 0, 100).toFixed(1)}% ${clamp(l, 0, 100).toFixed(1)}%)`;
|
|
2095
|
+
function deriveCustomPrimary(baseHex) {
|
|
2096
|
+
const base = hexToHsl(baseHex);
|
|
2097
|
+
if (!base) return null;
|
|
2098
|
+
const { h, s, l } = base;
|
|
2099
|
+
const direction = l < 25 ? 1 : -1;
|
|
2100
|
+
const hoverL = clamp(l + 8 * direction, 4, 96);
|
|
2101
|
+
const activeL = clamp(l + 14 * direction, 2, 98);
|
|
2102
|
+
const disabledBg = {
|
|
2103
|
+
h,
|
|
2104
|
+
s: clamp(s * 0.25, 0, 20),
|
|
2105
|
+
l: clamp(l > 75 ? l - 15 : 88, 12, 92)
|
|
2106
|
+
};
|
|
2107
|
+
const disabledFg = {
|
|
2108
|
+
h,
|
|
2109
|
+
s: clamp(s * 0.35, 0, 25),
|
|
2110
|
+
l: clamp(l > 75 ? 35 : 45, 30, 60)
|
|
2111
|
+
};
|
|
2112
|
+
const norm = normalizeHex(baseHex);
|
|
2113
|
+
const ch = (i) => {
|
|
2114
|
+
const v = parseInt(norm.slice(i, i + 2), 16) / 255;
|
|
2115
|
+
return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4);
|
|
2116
|
+
};
|
|
2117
|
+
const y = 0.2126 * ch(0) + 0.7152 * ch(2) + 0.0722 * ch(4);
|
|
2118
|
+
const foreground = y > 0.45 ? "#18181b" : "#fafafa";
|
|
2119
|
+
return {
|
|
2120
|
+
base: hsl({ h, s, l }),
|
|
2121
|
+
hover: hsl({ h, s, l: hoverL }),
|
|
2122
|
+
active: hsl({ h, s, l: activeL }),
|
|
2123
|
+
disabledBg: hsl(disabledBg),
|
|
2124
|
+
disabledFg: hsl(disabledFg),
|
|
2125
|
+
foreground
|
|
2126
|
+
};
|
|
2127
|
+
}
|
|
2128
|
+
var CUSTOM_PRIMARY_VARS = [
|
|
2129
|
+
"--rs-primary",
|
|
2130
|
+
"--rs-primary-hover",
|
|
2131
|
+
"--rs-primary-active",
|
|
2132
|
+
"--rs-primary-disabled-bg",
|
|
2133
|
+
"--rs-primary-disabled-fg",
|
|
2134
|
+
"--rs-primary-foreground",
|
|
2135
|
+
"--rs-border-accent"
|
|
2136
|
+
];
|
|
2137
|
+
function applyTheme(element, theme) {
|
|
2138
|
+
if (!element) return;
|
|
2139
|
+
const parent = element.parentElement;
|
|
2140
|
+
const targets = _optionalChain([parent, 'optionalAccess', _69 => _69.classList, 'access', _70 => _70.contains, 'call', _71 => _71("rs-modal-content")]) ? [element, parent] : [element];
|
|
2141
|
+
if (_optionalChain([theme, 'optionalAccess', _72 => _72.mode])) {
|
|
2142
|
+
for (const t of targets) t.setAttribute("data-theme", theme.mode);
|
|
2143
|
+
} else {
|
|
2144
|
+
for (const t of targets) t.removeAttribute("data-theme");
|
|
2145
|
+
}
|
|
2146
|
+
if (_optionalChain([theme, 'optionalAccess', _73 => _73.fontColor])) {
|
|
2147
|
+
setVar(targets, "--rs-foreground", theme.fontColor);
|
|
2148
|
+
}
|
|
2149
|
+
if (_optionalChain([theme, 'optionalAccess', _74 => _74.iconColor])) {
|
|
2150
|
+
setVar(targets, "--rs-icon", theme.iconColor);
|
|
2151
|
+
}
|
|
2152
|
+
if (_optionalChain([theme, 'optionalAccess', _75 => _75.ctaColor])) {
|
|
2153
|
+
const derived = deriveCustomPrimary(theme.ctaColor);
|
|
2154
|
+
if (derived) {
|
|
2155
|
+
setVar(targets, "--rs-primary", derived.base);
|
|
2156
|
+
setVar(
|
|
2157
|
+
targets,
|
|
2158
|
+
"--rs-primary-hover",
|
|
2159
|
+
_nullishCoalesce(theme.ctaHoverColor, () => ( derived.hover))
|
|
2160
|
+
);
|
|
2161
|
+
setVar(targets, "--rs-primary-active", derived.active);
|
|
2162
|
+
setVar(targets, "--rs-primary-disabled-bg", derived.disabledBg);
|
|
2163
|
+
setVar(targets, "--rs-primary-disabled-fg", derived.disabledFg);
|
|
2164
|
+
setVar(targets, "--rs-primary-foreground", derived.foreground);
|
|
2165
|
+
setVar(targets, "--rs-border-accent", derived.base);
|
|
2166
|
+
} else {
|
|
2167
|
+
setVar(targets, "--rs-primary", theme.ctaColor);
|
|
2168
|
+
setVar(targets, "--rs-border-accent", theme.ctaColor);
|
|
2169
|
+
setVar(
|
|
2170
|
+
targets,
|
|
2171
|
+
"--rs-primary-hover",
|
|
2172
|
+
_nullishCoalesce(theme.ctaHoverColor, () => ( theme.ctaColor))
|
|
2173
|
+
);
|
|
2174
|
+
}
|
|
2175
|
+
} else {
|
|
2176
|
+
for (const v of CUSTOM_PRIMARY_VARS) clearVar(targets, v);
|
|
2177
|
+
if (_optionalChain([theme, 'optionalAccess', _76 => _76.ctaHoverColor])) {
|
|
2178
|
+
setVar(targets, "--rs-primary-hover", theme.ctaHoverColor);
|
|
2179
|
+
}
|
|
2180
|
+
}
|
|
2181
|
+
if (_optionalChain([theme, 'optionalAccess', _77 => _77.borderColor])) {
|
|
2182
|
+
setVar(targets, "--rs-border", theme.borderColor);
|
|
2183
|
+
setVar(targets, "--rs-border-surface", theme.borderColor);
|
|
2184
|
+
}
|
|
2185
|
+
if (_optionalChain([theme, 'optionalAccess', _78 => _78.backgroundColor])) {
|
|
2186
|
+
setVar(targets, "--rs-background", theme.backgroundColor);
|
|
2187
|
+
}
|
|
2188
|
+
if (_optionalChain([theme, 'optionalAccess', _79 => _79.radius])) {
|
|
2189
|
+
const scale = RADIUS_SCALE[theme.radius];
|
|
2190
|
+
setVar(targets, "--rs-radius-sm", scale.sm);
|
|
2191
|
+
setVar(targets, "--rs-radius-md", scale.md);
|
|
2192
|
+
setVar(targets, "--rs-radius-lg", scale.lg);
|
|
2193
|
+
setVar(targets, "--rs-radius", scale.md);
|
|
2194
|
+
}
|
|
2195
|
+
}
|
|
2196
|
+
|
|
2197
|
+
// src/core/backend-url.ts
|
|
2198
|
+
var warned = /* @__PURE__ */ new Set();
|
|
2199
|
+
function checkBackendUrl(component, backendUrl) {
|
|
2200
|
+
if (typeof backendUrl === "string" && backendUrl.trim() !== "") return;
|
|
2201
|
+
if (warned.has(component)) return;
|
|
2202
|
+
warned.add(component);
|
|
2203
|
+
console.error(
|
|
2204
|
+
`[rhinestone] <${component}> requires \`backendUrl\`. Point it at a proxy that holds your Rhinestone API key and forwards to the deposit processor \u2014 every request the modal makes goes there, so nothing will work without it.`
|
|
2205
|
+
);
|
|
2206
|
+
}
|
|
2207
|
+
|
|
2208
|
+
|
|
2209
|
+
|
|
2210
|
+
|
|
2211
|
+
|
|
2212
|
+
|
|
2213
|
+
|
|
2214
|
+
|
|
2215
|
+
|
|
2216
|
+
|
|
2217
|
+
|
|
2218
|
+
|
|
2219
|
+
|
|
2220
|
+
|
|
2221
|
+
|
|
2222
|
+
|
|
2223
|
+
|
|
2224
|
+
|
|
2225
|
+
|
|
2226
|
+
|
|
2227
|
+
|
|
2228
|
+
|
|
2229
|
+
|
|
2230
|
+
|
|
2231
|
+
|
|
2232
|
+
|
|
2233
|
+
|
|
2234
|
+
|
|
2235
|
+
|
|
2236
|
+
|
|
2237
|
+
|
|
2238
|
+
|
|
2239
|
+
|
|
2240
|
+
|
|
2241
|
+
|
|
2242
|
+
|
|
2243
|
+
|
|
2244
|
+
|
|
2245
|
+
|
|
2246
|
+
|
|
2247
|
+
|
|
2248
|
+
|
|
2249
|
+
|
|
2250
|
+
|
|
2251
|
+
|
|
2252
|
+
|
|
2253
|
+
|
|
2254
|
+
|
|
2255
|
+
|
|
2256
|
+
|
|
2257
|
+
|
|
2258
|
+
|
|
2259
|
+
|
|
2260
|
+
|
|
2261
|
+
|
|
2262
|
+
|
|
2263
|
+
|
|
2264
|
+
|
|
2265
|
+
|
|
2266
|
+
|
|
2267
|
+
|
|
2268
|
+
|
|
2269
|
+
|
|
2270
|
+
|
|
2271
|
+
|
|
2272
|
+
|
|
2273
|
+
exports.Modal = Modal; exports.WalletIcon = WalletIcon; exports.ExternalLinkIcon = ExternalLinkIcon; exports.CheckIcon = CheckIcon; exports.TransferCryptoIcon = TransferCryptoIcon; exports.ChevronRightIcon = ChevronRightIcon; exports.ChevronLeftIcon = ChevronLeftIcon; exports.ChevronDownIcon = ChevronDownIcon; exports.CloseIcon = CloseIcon; exports.HandCoinsIcon = HandCoinsIcon; exports.CoinsIcon = CoinsIcon; exports.HistoryIcon = HistoryIcon; exports.InfoIcon = InfoIcon; exports.CopyIcon = CopyIcon; exports.ArrowUpRightIcon = ArrowUpRightIcon; exports.AlertTriangleIcon = AlertTriangleIcon; exports.PercentIcon = PercentIcon; exports.ClockIcon = ClockIcon; exports.PlusCircleIcon = PlusCircleIcon; exports.CircleArrowOutUpLeftIcon = CircleArrowOutUpLeftIcon; exports.CardIcon = CardIcon; exports.BankIcon = BankIcon; exports.UnplugIcon = UnplugIcon; exports.MigrateAssetsIcon = MigrateAssetsIcon; exports.AppleIcon = AppleIcon; exports.BodyHeader = BodyHeader; exports.CdnIcon = CdnIcon; exports.PoweredBy = PoweredBy; exports.Spinner = Spinner; exports.useLatestRef = useLatestRef; exports.Button = Button; exports.Callout = Callout; exports.TokenIcon = TokenIcon; exports.debugLog = debugLog; exports.debugError = debugError; exports.getAssetId = getAssetId; exports.chainIdsByValue = chainIdsByValue; exports.portfolioToAssets = portfolioToAssets; exports.isNativeAsset = isNativeAsset; exports.formatFeeUsd = formatFeeUsd; exports.quoteFeeRow = quoteFeeRow; exports.quoteFeeGroups = quoteFeeGroups; exports.SwappedConnectFeeChangedError = SwappedConnectFeeChangedError; exports.resolveAppFeeBps = resolveAppFeeBps; exports.createDepositService = createDepositService; exports.currencyFormatter = currencyFormatter; exports.tokenFormatter = tokenFormatter; exports.isUnsupportedChainSwitchError = isUnsupportedChainSwitchError; exports.formatUserError = formatUserError; exports.resolveTokenDisplay = resolveTokenDisplay; exports.formatTokenAmount = formatTokenAmount; exports.tokenAmountToNumber = tokenAmountToNumber; exports.formatRawTokenAmount = formatRawTokenAmount; exports.isDisplayStablecoinSymbol = isDisplayStablecoinSymbol; exports.isRecognizedToken = isRecognizedToken; exports.estimateReceiveAmount = estimateReceiveAmount; exports.formatQuotedReceive = formatQuotedReceive; exports.formatReceiveEstimate = formatReceiveEstimate; exports.rpcUrlFor = rpcUrlFor; exports.RpcUrlsProvider = RpcUrlsProvider; exports.useRpcUrls = useRpcUrls; exports.useStableRpcUrls = useStableRpcUrls; exports.applyTheme = applyTheme; exports.checkBackendUrl = checkBackendUrl;
|