@rhinestone/deposit-modal 0.9.1 → 0.11.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/dist/{DepositModalReown-JUJI7UHE.mjs → DepositModalReown-6RVLEM3B.mjs} +96 -26
- package/dist/{DepositModalReown-YQSO4SVY.cjs → DepositModalReown-TXTLVZIQ.cjs} +97 -27
- package/dist/caip-D8aRWdEY.d.cts +40 -0
- package/dist/caip-D8aRWdEY.d.ts +40 -0
- package/dist/{chunk-A223BLVC.mjs → chunk-53IFZGSF.mjs} +177 -21
- package/dist/{chunk-VQJHYWAE.cjs → chunk-7RNEYPI4.cjs} +836 -579
- package/dist/{chunk-ITFRTPGF.cjs → chunk-BLJMYCBF.cjs} +92 -90
- package/dist/{chunk-AYWEWI47.mjs → chunk-DYTRG4C7.mjs} +1 -1
- package/dist/{chunk-QGXAAFHU.mjs → chunk-G4FVZQOM.mjs} +23 -21
- package/dist/{chunk-SQOEHQNT.cjs → chunk-GWA6GFTI.cjs} +66 -63
- package/dist/{chunk-EEEQZOTJ.cjs → chunk-HCQWFL3A.cjs} +84 -101
- package/dist/{chunk-WUQZYQRK.mjs → chunk-ITAYM7SB.mjs} +784 -167
- package/dist/{chunk-YEBXUUH3.cjs → chunk-JPRV36DT.cjs} +2 -2
- package/dist/{chunk-EAUF7SGM.cjs → chunk-JYKMR6QI.cjs} +3 -3
- package/dist/{chunk-ILT2PITN.mjs → chunk-MZ53PDIX.mjs} +1 -1
- package/dist/{chunk-6U2H3R3T.cjs → chunk-NPSC5R22.cjs} +862 -245
- package/dist/{chunk-QLZ5RZTA.mjs → chunk-QRR3Y7EK.mjs} +1 -1
- package/dist/{chunk-H577RJN5.cjs → chunk-TENL4H64.cjs} +186 -30
- package/dist/{chunk-N3OHR3T2.mjs → chunk-TRD2FCAR.mjs} +363 -106
- package/dist/{chunk-7OQO6JDC.mjs → chunk-VRNRRN2U.mjs} +12 -9
- package/dist/{chunk-GYEUZSQP.mjs → chunk-WLDTBKRA.mjs} +14 -31
- package/dist/{chunk-XJE5MRY4.cjs → chunk-XVKBCDZI.cjs} +1 -1
- package/dist/claim.cjs +6 -6
- package/dist/claim.d.cts +3 -2
- package/dist/claim.d.ts +3 -2
- package/dist/claim.mjs +5 -5
- package/dist/{caip-523Zrc3r.d.cts → constants-FuzG3h4m.d.cts} +1 -18
- package/dist/{caip-523Zrc3r.d.ts → constants-FuzG3h4m.d.ts} +1 -18
- package/dist/constants.cjs +5 -3
- package/dist/constants.d.cts +3 -2
- package/dist/constants.d.ts +3 -2
- package/dist/constants.mjs +4 -2
- package/dist/deposit.cjs +8 -8
- package/dist/deposit.d.cts +3 -2
- package/dist/deposit.d.ts +3 -2
- package/dist/deposit.mjs +7 -7
- package/dist/index.cjs +12 -10
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.mjs +11 -9
- package/dist/polymarket.cjs +5 -5
- package/dist/polymarket.mjs +2 -2
- package/dist/styles.css +14 -0
- package/dist/{types-C0SGf-21.d.cts → types-C7wag_iL.d.cts} +4 -3
- package/dist/{types-C0SGf-21.d.ts → types-D4b6Cjox.d.ts} +4 -3
- package/dist/withdraw.cjs +6 -6
- package/dist/withdraw.d.cts +3 -2
- package/dist/withdraw.d.ts +3 -2
- package/dist/withdraw.mjs +5 -5
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
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; }
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } 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
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkXVKBCDZIcjs = require('./chunk-XVKBCDZI.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
@@ -17,7 +17,20 @@ var _chunkXJE5MRY4cjs = require('./chunk-XJE5MRY4.cjs');
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
var _chunkTENL4H64cjs = require('./chunk-TENL4H64.cjs');
|
|
21
34
|
|
|
22
35
|
// src/components/ui/Modal.tsx
|
|
23
36
|
|
|
@@ -323,7 +336,7 @@ function preconnectIconCdn() {
|
|
|
323
336
|
const link = document.createElement("link");
|
|
324
337
|
link.id = "rs-icon-cdn-preconnect";
|
|
325
338
|
link.rel = "preconnect";
|
|
326
|
-
link.href =
|
|
339
|
+
link.href = _chunkTENL4H64cjs.ICON_CDN;
|
|
327
340
|
link.crossOrigin = "anonymous";
|
|
328
341
|
document.head.appendChild(link);
|
|
329
342
|
}
|
|
@@ -433,140 +446,6 @@ function PoweredBy() {
|
|
|
433
446
|
}
|
|
434
447
|
PoweredBy.displayName = "PoweredBy";
|
|
435
448
|
|
|
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
449
|
// src/core/deposit-service.ts
|
|
571
450
|
var _viem = require('viem');
|
|
572
451
|
|
|
@@ -623,6 +502,101 @@ function debugError(enabled, scope, message, error, data) {
|
|
|
623
502
|
console.error(`[deposit-modal:${scope}] ${message}`, payload);
|
|
624
503
|
}
|
|
625
504
|
|
|
505
|
+
// src/core/chain-catalog.ts
|
|
506
|
+
function parseToken(value) {
|
|
507
|
+
if (typeof value !== "object" || value === null) return null;
|
|
508
|
+
const { symbol, address, decimals } = value;
|
|
509
|
+
if (typeof symbol !== "string" || typeof address !== "string" || typeof decimals !== "number") {
|
|
510
|
+
return null;
|
|
511
|
+
}
|
|
512
|
+
return { symbol, address, decimals };
|
|
513
|
+
}
|
|
514
|
+
function parseExplorer(value) {
|
|
515
|
+
if (typeof value !== "object" || value === null) return null;
|
|
516
|
+
const { url, addressPath, txPath } = value;
|
|
517
|
+
if (typeof url !== "string" || typeof addressPath !== "string" || typeof txPath !== "string") {
|
|
518
|
+
return null;
|
|
519
|
+
}
|
|
520
|
+
return { url, addressPath, txPath };
|
|
521
|
+
}
|
|
522
|
+
function parseVmType(value) {
|
|
523
|
+
return value === "evm" || value === "svm" || value === "tvm" ? value : null;
|
|
524
|
+
}
|
|
525
|
+
function parseOptionalString(value) {
|
|
526
|
+
return typeof value === "string" && value.trim() !== "" ? value.trim() : null;
|
|
527
|
+
}
|
|
528
|
+
function parseChain(caip2, value) {
|
|
529
|
+
if (typeof value !== "object" || value === null) return null;
|
|
530
|
+
const raw = value;
|
|
531
|
+
const { name, testnet, deposit, destination, refund } = raw;
|
|
532
|
+
if (typeof name !== "string" || typeof testnet !== "boolean" || typeof deposit !== "boolean" || typeof destination !== "boolean" || typeof refund !== "boolean") {
|
|
533
|
+
return null;
|
|
534
|
+
}
|
|
535
|
+
const vmType = parseVmType(raw.vmType);
|
|
536
|
+
const nativeToken = parseToken(raw.nativeToken);
|
|
537
|
+
if (!vmType || !nativeToken) return null;
|
|
538
|
+
let supportedTokens;
|
|
539
|
+
if (raw.supportedTokens === "all") {
|
|
540
|
+
supportedTokens = "all";
|
|
541
|
+
} else if (Array.isArray(raw.supportedTokens)) {
|
|
542
|
+
const tokens = [];
|
|
543
|
+
for (const entry of raw.supportedTokens) {
|
|
544
|
+
const token = parseToken(entry);
|
|
545
|
+
if (!token) return null;
|
|
546
|
+
tokens.push(token);
|
|
547
|
+
}
|
|
548
|
+
supportedTokens = tokens;
|
|
549
|
+
} else {
|
|
550
|
+
return null;
|
|
551
|
+
}
|
|
552
|
+
return {
|
|
553
|
+
caip2,
|
|
554
|
+
// `parseEvmChainId` returns null for `solana:`/`tron:`/`hypercore:` keys,
|
|
555
|
+
// which is the intended answer — those chains have no numeric id, and the
|
|
556
|
+
// modal addresses them by their CAIP-2 string or a sentinel.
|
|
557
|
+
chainId: _chunkTENL4H64cjs.parseEvmChainId.call(void 0, caip2),
|
|
558
|
+
name,
|
|
559
|
+
testnet,
|
|
560
|
+
deposit,
|
|
561
|
+
destination,
|
|
562
|
+
refund,
|
|
563
|
+
vmType,
|
|
564
|
+
nativeToken,
|
|
565
|
+
explorer: parseExplorer(raw.explorer),
|
|
566
|
+
supportedTokens,
|
|
567
|
+
publicRpcUrl: parseOptionalString(raw.publicRpcUrl),
|
|
568
|
+
iconUrl: parseOptionalString(raw.iconUrl)
|
|
569
|
+
};
|
|
570
|
+
}
|
|
571
|
+
function parseChainCatalog(body) {
|
|
572
|
+
if (typeof body !== "object" || body === null || Array.isArray(body)) {
|
|
573
|
+
return null;
|
|
574
|
+
}
|
|
575
|
+
const all = [];
|
|
576
|
+
const byCaip2 = /* @__PURE__ */ new Map();
|
|
577
|
+
const byChainId = /* @__PURE__ */ new Map();
|
|
578
|
+
for (const [caip2, value] of Object.entries(body)) {
|
|
579
|
+
const chain = parseChain(caip2, value);
|
|
580
|
+
if (!chain) continue;
|
|
581
|
+
all.push(chain);
|
|
582
|
+
byCaip2.set(chain.caip2, chain);
|
|
583
|
+
if (chain.chainId !== null) byChainId.set(chain.chainId, chain);
|
|
584
|
+
}
|
|
585
|
+
if (all.length === 0) return null;
|
|
586
|
+
return { all, byCaip2, byChainId };
|
|
587
|
+
}
|
|
588
|
+
function catalogKeyForChain(chainId) {
|
|
589
|
+
if (chainId === "solana") return _chunkTENL4H64cjs.SOLANA_MAINNET_CAIP2;
|
|
590
|
+
if (chainId === "hypercore" || chainId === _chunkTENL4H64cjs.HYPERCORE_CHAIN_ID) {
|
|
591
|
+
return _chunkTENL4H64cjs.HYPERCORE_MAINNET_CAIP2;
|
|
592
|
+
}
|
|
593
|
+
return chainId;
|
|
594
|
+
}
|
|
595
|
+
function catalogExplorerTxUrl(chain, txHash) {
|
|
596
|
+
if (!_optionalChain([chain, 'optionalAccess', _2 => _2.explorer])) return void 0;
|
|
597
|
+
return `${chain.explorer.url}${chain.explorer.txPath}${txHash}`;
|
|
598
|
+
}
|
|
599
|
+
|
|
626
600
|
// src/core/deposit-asset-helpers.ts
|
|
627
601
|
function getAssetId(asset) {
|
|
628
602
|
return `${asset.chainId}:${asset.token.toLowerCase()}`;
|
|
@@ -767,7 +741,7 @@ function quoteFeeGroups(breakdown) {
|
|
|
767
741
|
const groups = /* @__PURE__ */ new Map();
|
|
768
742
|
for (const [category, line] of Object.entries(breakdown)) {
|
|
769
743
|
if (line.internal || !Number.isFinite(line.usd) || line.usd < 0) continue;
|
|
770
|
-
const label = _optionalChain([line, 'access',
|
|
744
|
+
const label = _optionalChain([line, 'access', _3 => _3.label, 'optionalAccess', _4 => _4.trim, 'call', _5 => _5()]) || titleCaseFeeCategory(category);
|
|
771
745
|
const group = _nullishCoalesce(groups.get(label), () => ( {
|
|
772
746
|
label,
|
|
773
747
|
chargedUsd: 0,
|
|
@@ -870,14 +844,14 @@ function parseExchangeFeeBps(value) {
|
|
|
870
844
|
return typeof value === "number" && Number.isInteger(value) && value >= 0 && value <= 1e4 ? value : void 0;
|
|
871
845
|
}
|
|
872
846
|
function resolveAppFeeBps(appFees, sourceChainCaip2, sourceToken) {
|
|
873
|
-
const override = _optionalChain([appFees, 'optionalAccess',
|
|
874
|
-
const bps = _nullishCoalesce(_nullishCoalesce(override, () => ( _optionalChain([appFees, 'optionalAccess',
|
|
847
|
+
const override = _optionalChain([appFees, 'optionalAccess', _6 => _6.tokens, 'optionalAccess', _7 => _7[sourceChainCaip2], 'optionalAccess', _8 => _8[sourceToken.toLowerCase()]]);
|
|
848
|
+
const bps = _nullishCoalesce(_nullishCoalesce(override, () => ( _optionalChain([appFees, 'optionalAccess', _9 => _9.feeBps]))), () => ( 0));
|
|
875
849
|
return bps > 0 ? bps : 0;
|
|
876
850
|
}
|
|
877
851
|
function createDepositService(baseUrl, options) {
|
|
878
852
|
const normalizedBaseUrl = baseUrl.replace(/\/$/, "");
|
|
879
|
-
const debug = _optionalChain([options, 'optionalAccess',
|
|
880
|
-
const scope = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
853
|
+
const debug = _optionalChain([options, 'optionalAccess', _10 => _10.debug]) === true;
|
|
854
|
+
const scope = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _11 => _11.debugScope]), () => ( "service"));
|
|
881
855
|
function apiUrl(path) {
|
|
882
856
|
const normalizedPath = path.startsWith("/") ? path : `/${path}`;
|
|
883
857
|
return `${normalizedBaseUrl}${normalizedPath}`;
|
|
@@ -889,6 +863,7 @@ function createDepositService(baseUrl, options) {
|
|
|
889
863
|
const PORTFOLIO_CACHE_TTL_MS = 3e4;
|
|
890
864
|
const portfolioCache = /* @__PURE__ */ new Map();
|
|
891
865
|
let topTokensPromise = null;
|
|
866
|
+
let chainsPromise = null;
|
|
892
867
|
function parseTopTokens(value) {
|
|
893
868
|
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
894
869
|
return null;
|
|
@@ -913,7 +888,7 @@ function createDepositService(baseUrl, options) {
|
|
|
913
888
|
try {
|
|
914
889
|
const response = await fetch(apiUrl("/qr/tokens"), {
|
|
915
890
|
method: "GET",
|
|
916
|
-
headers:
|
|
891
|
+
headers: _chunkXVKBCDZIcjs.SERVICE_HEADERS
|
|
917
892
|
});
|
|
918
893
|
if (!response.ok) {
|
|
919
894
|
debugLog(debug, scope, "getTopTokens:unavailable", {
|
|
@@ -936,6 +911,32 @@ function createDepositService(baseUrl, options) {
|
|
|
936
911
|
return null;
|
|
937
912
|
}
|
|
938
913
|
}
|
|
914
|
+
async function requestChains() {
|
|
915
|
+
try {
|
|
916
|
+
const response = await fetch(apiUrl("/chains"), {
|
|
917
|
+
method: "GET",
|
|
918
|
+
headers: _chunkXVKBCDZIcjs.SERVICE_HEADERS
|
|
919
|
+
});
|
|
920
|
+
if (!response.ok) {
|
|
921
|
+
debugLog(debug, scope, "getChains:unavailable", {
|
|
922
|
+
status: response.status
|
|
923
|
+
});
|
|
924
|
+
return null;
|
|
925
|
+
}
|
|
926
|
+
const catalog = parseChainCatalog(await response.json());
|
|
927
|
+
if (!catalog) {
|
|
928
|
+
debugLog(debug, scope, "getChains:malformed");
|
|
929
|
+
return null;
|
|
930
|
+
}
|
|
931
|
+
debugLog(debug, scope, "getChains:success", {
|
|
932
|
+
chains: catalog.all.length
|
|
933
|
+
});
|
|
934
|
+
return catalog;
|
|
935
|
+
} catch (error) {
|
|
936
|
+
debugError(debug, scope, "getChains:error", error);
|
|
937
|
+
return null;
|
|
938
|
+
}
|
|
939
|
+
}
|
|
939
940
|
function cachedPortfolio(key, fetcher, forceRefresh = false) {
|
|
940
941
|
const now = Date.now();
|
|
941
942
|
const entry = portfolioCache.get(key);
|
|
@@ -945,7 +946,7 @@ function createDepositService(baseUrl, options) {
|
|
|
945
946
|
}
|
|
946
947
|
let promise;
|
|
947
948
|
promise = fetcher().catch((err) => {
|
|
948
|
-
if (_optionalChain([portfolioCache, 'access',
|
|
949
|
+
if (_optionalChain([portfolioCache, 'access', _12 => _12.get, 'call', _13 => _13(key), 'optionalAccess', _14 => _14.promise]) === promise) {
|
|
949
950
|
portfolioCache.delete(key);
|
|
950
951
|
}
|
|
951
952
|
throw err;
|
|
@@ -968,7 +969,7 @@ function createDepositService(baseUrl, options) {
|
|
|
968
969
|
});
|
|
969
970
|
const response = await fetch(url, {
|
|
970
971
|
method: "POST",
|
|
971
|
-
headers:
|
|
972
|
+
headers: _chunkXVKBCDZIcjs.SERVICE_HEADERS,
|
|
972
973
|
body: JSON.stringify({ account: params })
|
|
973
974
|
});
|
|
974
975
|
if (!response.ok) {
|
|
@@ -980,19 +981,19 @@ function createDepositService(baseUrl, options) {
|
|
|
980
981
|
error,
|
|
981
982
|
{ status: response.status, salt: params.salt }
|
|
982
983
|
);
|
|
983
|
-
const detail = Array.isArray(error.details) ? error.details.map((d) => _optionalChain([d, 'optionalAccess',
|
|
984
|
+
const detail = Array.isArray(error.details) ? error.details.map((d) => _optionalChain([d, 'optionalAccess', _15 => _15.message])).filter(Boolean).join("; ") : void 0;
|
|
984
985
|
const base = error.error || `Account registration failed: ${response.status}`;
|
|
985
986
|
throw new Error(detail ? `${base}: ${detail}` : base);
|
|
986
987
|
}
|
|
987
988
|
const result = await response.json();
|
|
988
989
|
debugLog(debug, scope, "registerManagedAccount:success", {
|
|
989
|
-
evmDepositAddress: _optionalChain([result, 'optionalAccess',
|
|
990
|
-
hasSolanaDepositAddress: Boolean(_optionalChain([result, 'optionalAccess',
|
|
991
|
-
hasTronDepositAddress: Boolean(_optionalChain([result, 'optionalAccess',
|
|
990
|
+
evmDepositAddress: _optionalChain([result, 'optionalAccess', _16 => _16.evmDepositAddress]),
|
|
991
|
+
hasSolanaDepositAddress: Boolean(_optionalChain([result, 'optionalAccess', _17 => _17.solanaDepositAddress])),
|
|
992
|
+
hasTronDepositAddress: Boolean(_optionalChain([result, 'optionalAccess', _18 => _18.tronDepositAddress]))
|
|
992
993
|
});
|
|
993
994
|
return {
|
|
994
995
|
...result,
|
|
995
|
-
evmDepositAddress: normalizeEvmAddress(_optionalChain([result, 'optionalAccess',
|
|
996
|
+
evmDepositAddress: normalizeEvmAddress(_optionalChain([result, 'optionalAccess', _19 => _19.evmDepositAddress]))
|
|
996
997
|
};
|
|
997
998
|
},
|
|
998
999
|
async fetchPortfolio(address, options2) {
|
|
@@ -1001,7 +1002,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1001
1002
|
debugLog(debug, scope, "fetchPortfolio:request", { url, address });
|
|
1002
1003
|
const response = await fetch(url, {
|
|
1003
1004
|
method: "GET",
|
|
1004
|
-
headers:
|
|
1005
|
+
headers: _chunkXVKBCDZIcjs.SERVICE_HEADERS
|
|
1005
1006
|
});
|
|
1006
1007
|
if (!response.ok) {
|
|
1007
1008
|
const error = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
@@ -1040,7 +1041,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1040
1041
|
}
|
|
1041
1042
|
debugLog(debug, scope, "fetchPortfolio:empty", { address });
|
|
1042
1043
|
return { tokens: [], totalUsd: 0 };
|
|
1043
|
-
}, _optionalChain([options2, 'optionalAccess',
|
|
1044
|
+
}, _optionalChain([options2, 'optionalAccess', _20 => _20.forceRefresh]));
|
|
1044
1045
|
},
|
|
1045
1046
|
async fetchSolanaPortfolio(address, options2) {
|
|
1046
1047
|
return cachedPortfolio(`sol:${address}`, async () => {
|
|
@@ -1048,7 +1049,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1048
1049
|
debugLog(debug, scope, "fetchSolanaPortfolio:request", { url, address });
|
|
1049
1050
|
const response = await fetch(url, {
|
|
1050
1051
|
method: "GET",
|
|
1051
|
-
headers:
|
|
1052
|
+
headers: _chunkXVKBCDZIcjs.SERVICE_HEADERS
|
|
1052
1053
|
});
|
|
1053
1054
|
if (!response.ok) {
|
|
1054
1055
|
const error = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
@@ -1071,14 +1072,14 @@ function createDepositService(baseUrl, options) {
|
|
|
1071
1072
|
totalUsd: normalized.totalUsd
|
|
1072
1073
|
});
|
|
1073
1074
|
return normalized;
|
|
1074
|
-
}, _optionalChain([options2, 'optionalAccess',
|
|
1075
|
+
}, _optionalChain([options2, 'optionalAccess', _21 => _21.forceRefresh]));
|
|
1075
1076
|
},
|
|
1076
1077
|
async checkAccount(address) {
|
|
1077
1078
|
const url = apiUrl(`/check/${address}`);
|
|
1078
1079
|
debugLog(debug, scope, "checkAccount:request", { url, address });
|
|
1079
1080
|
const response = await fetch(url, {
|
|
1080
1081
|
method: "GET",
|
|
1081
|
-
headers:
|
|
1082
|
+
headers: _chunkXVKBCDZIcjs.SERVICE_HEADERS
|
|
1082
1083
|
});
|
|
1083
1084
|
if (!response.ok) {
|
|
1084
1085
|
const error = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
@@ -1093,9 +1094,9 @@ function createDepositService(baseUrl, options) {
|
|
|
1093
1094
|
}
|
|
1094
1095
|
const data = await response.json();
|
|
1095
1096
|
const result = {
|
|
1096
|
-
isRegistered: _optionalChain([data, 'optionalAccess',
|
|
1097
|
-
targetChain: _optionalChain([data, 'optionalAccess',
|
|
1098
|
-
targetToken: _optionalChain([data, 'optionalAccess',
|
|
1097
|
+
isRegistered: _optionalChain([data, 'optionalAccess', _22 => _22.isRegistered]) === true,
|
|
1098
|
+
targetChain: _optionalChain([data, 'optionalAccess', _23 => _23.targetChain]),
|
|
1099
|
+
targetToken: _optionalChain([data, 'optionalAccess', _24 => _24.targetToken])
|
|
1099
1100
|
};
|
|
1100
1101
|
debugLog(debug, scope, "checkAccount:success", {
|
|
1101
1102
|
address,
|
|
@@ -1113,7 +1114,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1113
1114
|
);
|
|
1114
1115
|
const response = await fetch(url, {
|
|
1115
1116
|
method: "GET",
|
|
1116
|
-
headers:
|
|
1117
|
+
headers: _chunkXVKBCDZIcjs.SERVICE_HEADERS,
|
|
1117
1118
|
cache: "no-store"
|
|
1118
1119
|
});
|
|
1119
1120
|
if (!response.ok) {
|
|
@@ -1125,12 +1126,12 @@ function createDepositService(baseUrl, options) {
|
|
|
1125
1126
|
return { lastEvent: void 0 };
|
|
1126
1127
|
}
|
|
1127
1128
|
const body = await response.json();
|
|
1128
|
-
const row = _optionalChain([body, 'access',
|
|
1129
|
+
const row = _optionalChain([body, 'access', _25 => _25.deposits, 'optionalAccess', _26 => _26[0]]);
|
|
1129
1130
|
const lastEvent = row ? depositRowToEvent(row) : void 0;
|
|
1130
1131
|
debugLog(debug, scope, "fetchStatus:success", {
|
|
1131
1132
|
address,
|
|
1132
1133
|
txHash: shortRef(normalized),
|
|
1133
|
-
eventType: _optionalChain([lastEvent, 'optionalAccess',
|
|
1134
|
+
eventType: _optionalChain([lastEvent, 'optionalAccess', _27 => _27.type])
|
|
1134
1135
|
});
|
|
1135
1136
|
return { lastEvent };
|
|
1136
1137
|
},
|
|
@@ -1141,7 +1142,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1141
1142
|
);
|
|
1142
1143
|
const response = await fetch(url, {
|
|
1143
1144
|
method: "GET",
|
|
1144
|
-
headers:
|
|
1145
|
+
headers: _chunkXVKBCDZIcjs.SERVICE_HEADERS,
|
|
1145
1146
|
cache: "no-store"
|
|
1146
1147
|
});
|
|
1147
1148
|
if (!response.ok) {
|
|
@@ -1165,7 +1166,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1165
1166
|
);
|
|
1166
1167
|
const response = await fetch(url, {
|
|
1167
1168
|
method: "GET",
|
|
1168
|
-
headers:
|
|
1169
|
+
headers: _chunkXVKBCDZIcjs.SERVICE_HEADERS,
|
|
1169
1170
|
cache: "no-store"
|
|
1170
1171
|
});
|
|
1171
1172
|
if (!response.ok) {
|
|
@@ -1176,14 +1177,75 @@ function createDepositService(baseUrl, options) {
|
|
|
1176
1177
|
return { lastEvent: void 0 };
|
|
1177
1178
|
}
|
|
1178
1179
|
const body = await response.json();
|
|
1179
|
-
const row = _optionalChain([body, 'access',
|
|
1180
|
+
const row = _optionalChain([body, 'access', _28 => _28.deposits, 'optionalAccess', _29 => _29[0]]);
|
|
1180
1181
|
const lastEvent = row ? depositRowToEvent(row) : void 0;
|
|
1181
1182
|
debugLog(debug, scope, "fetchLatestStatus:success", {
|
|
1182
1183
|
address,
|
|
1183
|
-
eventType: _optionalChain([lastEvent, 'optionalAccess',
|
|
1184
|
+
eventType: _optionalChain([lastEvent, 'optionalAccess', _30 => _30.type])
|
|
1184
1185
|
});
|
|
1185
1186
|
return { lastEvent };
|
|
1186
1187
|
},
|
|
1188
|
+
async getPositions(address) {
|
|
1189
|
+
const url = apiUrl(`/positions/${address}`);
|
|
1190
|
+
debugLog(debug, scope, "getPositions:request", { url, address });
|
|
1191
|
+
const response = await fetch(url, { headers: _chunkXVKBCDZIcjs.SERVICE_HEADERS });
|
|
1192
|
+
if (!response.ok) {
|
|
1193
|
+
const error = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
1194
|
+
debugError(debug, scope, "getPositions:failed", error, {
|
|
1195
|
+
status: response.status,
|
|
1196
|
+
address
|
|
1197
|
+
});
|
|
1198
|
+
throw new Error(
|
|
1199
|
+
error.error || `Position lookup failed: ${response.status}`
|
|
1200
|
+
);
|
|
1201
|
+
}
|
|
1202
|
+
const result = await response.json();
|
|
1203
|
+
debugLog(debug, scope, "getPositions:success", {
|
|
1204
|
+
address,
|
|
1205
|
+
count: _nullishCoalesce(_optionalChain([result, 'access', _31 => _31.positions, 'optionalAccess', _32 => _32.length]), () => ( 0)),
|
|
1206
|
+
totalUsd: result.totalUsd,
|
|
1207
|
+
failures: _optionalChain([result, 'access', _33 => _33.failures, 'optionalAccess', _34 => _34.map, 'call', _35 => _35((f) => f.venue)])
|
|
1208
|
+
});
|
|
1209
|
+
return result;
|
|
1210
|
+
},
|
|
1211
|
+
async prepareUnwind(params) {
|
|
1212
|
+
const { address, account, market, chainId, asset, amount } = params;
|
|
1213
|
+
const url = apiUrl(`/positions/${address}/unwind`);
|
|
1214
|
+
debugLog(debug, scope, "prepareUnwind:request", {
|
|
1215
|
+
url,
|
|
1216
|
+
address,
|
|
1217
|
+
account,
|
|
1218
|
+
market,
|
|
1219
|
+
chainId,
|
|
1220
|
+
asset,
|
|
1221
|
+
amount
|
|
1222
|
+
});
|
|
1223
|
+
const response = await fetch(url, {
|
|
1224
|
+
method: "POST",
|
|
1225
|
+
headers: _chunkXVKBCDZIcjs.SERVICE_HEADERS,
|
|
1226
|
+
body: JSON.stringify({ account, market, chainId, asset, amount })
|
|
1227
|
+
});
|
|
1228
|
+
if (!response.ok) {
|
|
1229
|
+
const error = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
1230
|
+
debugError(debug, scope, "prepareUnwind:failed", error, {
|
|
1231
|
+
status: response.status,
|
|
1232
|
+
address,
|
|
1233
|
+
market,
|
|
1234
|
+
asset
|
|
1235
|
+
});
|
|
1236
|
+
throw new Error(
|
|
1237
|
+
error.error || `Unwind preparation failed: ${response.status}`
|
|
1238
|
+
);
|
|
1239
|
+
}
|
|
1240
|
+
const result = await response.json();
|
|
1241
|
+
debugLog(debug, scope, "prepareUnwind:success", {
|
|
1242
|
+
address,
|
|
1243
|
+
amount: result.amount,
|
|
1244
|
+
isFullExit: result.isFullExit,
|
|
1245
|
+
recipient: result.recipient
|
|
1246
|
+
});
|
|
1247
|
+
return result;
|
|
1248
|
+
},
|
|
1187
1249
|
async submitPolymarketWithdraw(params) {
|
|
1188
1250
|
const { depositWallet, owner, nonce, deadline, calls, signature } = params;
|
|
1189
1251
|
const url = apiUrl(`/polymarket/withdraw`);
|
|
@@ -1196,7 +1258,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1196
1258
|
});
|
|
1197
1259
|
const response = await fetch(url, {
|
|
1198
1260
|
method: "POST",
|
|
1199
|
-
headers:
|
|
1261
|
+
headers: _chunkXVKBCDZIcjs.SERVICE_HEADERS,
|
|
1200
1262
|
body: JSON.stringify({
|
|
1201
1263
|
depositWallet,
|
|
1202
1264
|
owner,
|
|
@@ -1220,7 +1282,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1220
1282
|
const result = await response.json();
|
|
1221
1283
|
debugLog(debug, scope, "submitPolymarketWithdraw:success", {
|
|
1222
1284
|
depositWallet,
|
|
1223
|
-
txHash: _optionalChain([result, 'optionalAccess',
|
|
1285
|
+
txHash: _optionalChain([result, 'optionalAccess', _36 => _36.txHash]) ? shortRef(result.txHash) : void 0
|
|
1224
1286
|
});
|
|
1225
1287
|
return result;
|
|
1226
1288
|
},
|
|
@@ -1238,7 +1300,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1238
1300
|
});
|
|
1239
1301
|
const response = await fetch(url, {
|
|
1240
1302
|
method: "GET",
|
|
1241
|
-
headers:
|
|
1303
|
+
headers: _chunkXVKBCDZIcjs.SERVICE_HEADERS,
|
|
1242
1304
|
cache: "no-store"
|
|
1243
1305
|
});
|
|
1244
1306
|
if (!response.ok) {
|
|
@@ -1255,8 +1317,8 @@ function createDepositService(baseUrl, options) {
|
|
|
1255
1317
|
);
|
|
1256
1318
|
}
|
|
1257
1319
|
const data = await response.json();
|
|
1258
|
-
const deposits = Array.isArray(_optionalChain([data, 'optionalAccess',
|
|
1259
|
-
const nextCursor = _nullishCoalesce(_nullishCoalesce(_optionalChain([data, 'optionalAccess',
|
|
1320
|
+
const deposits = Array.isArray(_optionalChain([data, 'optionalAccess', _37 => _37.deposits])) ? data.deposits : [];
|
|
1321
|
+
const nextCursor = _nullishCoalesce(_nullishCoalesce(_optionalChain([data, 'optionalAccess', _38 => _38.nextCursor]), () => ( _optionalChain([data, 'optionalAccess', _39 => _39.next_cursor]))), () => ( null));
|
|
1260
1322
|
debugLog(debug, scope, "fetchDepositHistory:success", {
|
|
1261
1323
|
recipient: shortRef(params.recipient),
|
|
1262
1324
|
count: deposits.length,
|
|
@@ -1265,20 +1327,20 @@ function createDepositService(baseUrl, options) {
|
|
|
1265
1327
|
return { deposits, nextCursor };
|
|
1266
1328
|
},
|
|
1267
1329
|
async checkLiquidity(params) {
|
|
1268
|
-
if (params.destinationChainId === "solana") {
|
|
1269
|
-
const token =
|
|
1330
|
+
if (_chunkTENL4H64cjs.isSolanaCaip2.call(void 0, params.destinationChainId) || params.destinationChainId === "solana") {
|
|
1331
|
+
const token = _chunkTENL4H64cjs.getSolanaTokenByMint.call(void 0, params.destinationToken);
|
|
1270
1332
|
return {
|
|
1271
1333
|
hasLiquidity: true,
|
|
1272
|
-
symbol: _nullishCoalesce(_optionalChain([token, 'optionalAccess',
|
|
1273
|
-
decimals: _nullishCoalesce(_optionalChain([token, 'optionalAccess',
|
|
1334
|
+
symbol: _nullishCoalesce(_optionalChain([token, 'optionalAccess', _40 => _40.symbol]), () => ( "Token")),
|
|
1335
|
+
decimals: _nullishCoalesce(_optionalChain([token, 'optionalAccess', _41 => _41.decimals]), () => ( 9)),
|
|
1274
1336
|
unlimited: true,
|
|
1275
1337
|
maxAmount: null
|
|
1276
1338
|
};
|
|
1277
1339
|
}
|
|
1278
1340
|
const searchParams = new URLSearchParams({
|
|
1279
|
-
sourceChainId:
|
|
1341
|
+
sourceChainId: _chunkTENL4H64cjs.toEvmCaip2.call(void 0, params.sourceChainId),
|
|
1280
1342
|
sourceToken: params.sourceToken,
|
|
1281
|
-
destinationChainId:
|
|
1343
|
+
destinationChainId: params.destinationChainId,
|
|
1282
1344
|
destinationToken: params.destinationToken,
|
|
1283
1345
|
amount: params.amount
|
|
1284
1346
|
});
|
|
@@ -1291,7 +1353,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1291
1353
|
});
|
|
1292
1354
|
const response = await fetch(url, {
|
|
1293
1355
|
method: "GET",
|
|
1294
|
-
headers:
|
|
1356
|
+
headers: _chunkXVKBCDZIcjs.SERVICE_HEADERS,
|
|
1295
1357
|
cache: "no-store"
|
|
1296
1358
|
});
|
|
1297
1359
|
if (!response.ok) {
|
|
@@ -1323,7 +1385,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1323
1385
|
const body = {
|
|
1324
1386
|
account: params.account,
|
|
1325
1387
|
// HyperCore has its own CAIP-2 namespace — never the eip155 placeholder.
|
|
1326
|
-
sourceChainId: params.sourceChainId === "hypercore" ?
|
|
1388
|
+
sourceChainId: params.sourceChainId === "hypercore" ? _chunkTENL4H64cjs.HYPERCORE_MAINNET_CAIP2 : `eip155:${params.sourceChainId}`,
|
|
1327
1389
|
sourceToken: params.sourceToken,
|
|
1328
1390
|
amount: params.amount
|
|
1329
1391
|
};
|
|
@@ -1336,7 +1398,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1336
1398
|
try {
|
|
1337
1399
|
const response = await fetch(url, {
|
|
1338
1400
|
method: "POST",
|
|
1339
|
-
headers:
|
|
1401
|
+
headers: _chunkXVKBCDZIcjs.SERVICE_HEADERS,
|
|
1340
1402
|
body: JSON.stringify(body),
|
|
1341
1403
|
cache: "no-store"
|
|
1342
1404
|
});
|
|
@@ -1373,7 +1435,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1373
1435
|
try {
|
|
1374
1436
|
const response = await fetch(url, {
|
|
1375
1437
|
method: "GET",
|
|
1376
|
-
headers:
|
|
1438
|
+
headers: _chunkXVKBCDZIcjs.SERVICE_HEADERS,
|
|
1377
1439
|
cache: "no-store"
|
|
1378
1440
|
});
|
|
1379
1441
|
if (!response.ok) {
|
|
@@ -1403,7 +1465,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1403
1465
|
try {
|
|
1404
1466
|
const response = await fetch(url, {
|
|
1405
1467
|
method: "GET",
|
|
1406
|
-
headers:
|
|
1468
|
+
headers: _chunkXVKBCDZIcjs.SERVICE_HEADERS,
|
|
1407
1469
|
cache: "no-store"
|
|
1408
1470
|
});
|
|
1409
1471
|
if (!response.ok) {
|
|
@@ -1428,7 +1490,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1428
1490
|
});
|
|
1429
1491
|
const response = await fetch(url, {
|
|
1430
1492
|
method: "POST",
|
|
1431
|
-
headers:
|
|
1493
|
+
headers: _chunkXVKBCDZIcjs.SERVICE_HEADERS,
|
|
1432
1494
|
body: JSON.stringify(params)
|
|
1433
1495
|
});
|
|
1434
1496
|
if (!response.ok) {
|
|
@@ -1460,7 +1522,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1460
1522
|
});
|
|
1461
1523
|
const response = await fetch(url, {
|
|
1462
1524
|
method: "POST",
|
|
1463
|
-
headers:
|
|
1525
|
+
headers: _chunkXVKBCDZIcjs.SERVICE_HEADERS,
|
|
1464
1526
|
body: JSON.stringify(params)
|
|
1465
1527
|
});
|
|
1466
1528
|
if (!response.ok) {
|
|
@@ -1497,7 +1559,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1497
1559
|
debugLog(debug, scope, "getSwappedConnectExchanges:request");
|
|
1498
1560
|
const response = await fetch(url, {
|
|
1499
1561
|
method: "GET",
|
|
1500
|
-
headers:
|
|
1562
|
+
headers: _chunkXVKBCDZIcjs.SERVICE_HEADERS,
|
|
1501
1563
|
cache: "no-store"
|
|
1502
1564
|
});
|
|
1503
1565
|
if (!response.ok) {
|
|
@@ -1550,7 +1612,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1550
1612
|
try {
|
|
1551
1613
|
const response = await fetch(url, {
|
|
1552
1614
|
method: "GET",
|
|
1553
|
-
headers:
|
|
1615
|
+
headers: _chunkXVKBCDZIcjs.SERVICE_HEADERS,
|
|
1554
1616
|
cache: "no-store"
|
|
1555
1617
|
});
|
|
1556
1618
|
if (!response.ok) {
|
|
@@ -1621,12 +1683,22 @@ function createDepositService(baseUrl, options) {
|
|
|
1621
1683
|
}
|
|
1622
1684
|
return topTokensPromise;
|
|
1623
1685
|
},
|
|
1686
|
+
getChains() {
|
|
1687
|
+
if (!chainsPromise) {
|
|
1688
|
+
const attempt = requestChains().then((catalog) => {
|
|
1689
|
+
if (!catalog && chainsPromise === attempt) chainsPromise = null;
|
|
1690
|
+
return catalog;
|
|
1691
|
+
});
|
|
1692
|
+
chainsPromise = attempt;
|
|
1693
|
+
}
|
|
1694
|
+
return chainsPromise;
|
|
1695
|
+
},
|
|
1624
1696
|
async getSetup() {
|
|
1625
1697
|
const url = apiUrl("/setup");
|
|
1626
1698
|
try {
|
|
1627
1699
|
const response = await fetch(url, {
|
|
1628
1700
|
method: "GET",
|
|
1629
|
-
headers:
|
|
1701
|
+
headers: _chunkXVKBCDZIcjs.SERVICE_HEADERS,
|
|
1630
1702
|
cache: "no-store"
|
|
1631
1703
|
});
|
|
1632
1704
|
if (!response.ok) {
|
|
@@ -1653,7 +1725,7 @@ function createDepositService(baseUrl, options) {
|
|
|
1653
1725
|
);
|
|
1654
1726
|
const response = await fetch(url, {
|
|
1655
1727
|
method: "GET",
|
|
1656
|
-
headers:
|
|
1728
|
+
headers: _chunkXVKBCDZIcjs.SERVICE_HEADERS,
|
|
1657
1729
|
cache: "no-store"
|
|
1658
1730
|
});
|
|
1659
1731
|
if (!response.ok) return null;
|
|
@@ -1694,16 +1766,16 @@ function createDepositService(baseUrl, options) {
|
|
|
1694
1766
|
}
|
|
1695
1767
|
function normalizeDirectPortfolio(data) {
|
|
1696
1768
|
const rawTokens = _nullishCoalesce(_nullishCoalesce(extractArray(data, "tokens"), () => ( extractArray(
|
|
1697
|
-
_optionalChain([data, 'optionalAccess',
|
|
1769
|
+
_optionalChain([data, 'optionalAccess', _42 => _42.data]),
|
|
1698
1770
|
"tokens"
|
|
1699
1771
|
))), () => ( []));
|
|
1700
|
-
const totalUsd = _nullishCoalesce(_nullishCoalesce(extractNumber(data, "totalUsd"), () => ( extractNumber(_optionalChain([data, 'optionalAccess',
|
|
1772
|
+
const totalUsd = _nullishCoalesce(_nullishCoalesce(extractNumber(data, "totalUsd"), () => ( extractNumber(_optionalChain([data, 'optionalAccess', _43 => _43.data]), "totalUsd"))), () => ( 0));
|
|
1701
1773
|
const tokens = rawTokens.map((token) => normalizeDirectToken(token)).filter((token) => Boolean(token));
|
|
1702
1774
|
return { tokens, totalUsd };
|
|
1703
1775
|
}
|
|
1704
1776
|
function extractOrchestratorPortfolio(data) {
|
|
1705
1777
|
const portfolio = _nullishCoalesce(extractArray(data, "portfolio"), () => ( extractArray(
|
|
1706
|
-
_optionalChain([data, 'optionalAccess',
|
|
1778
|
+
_optionalChain([data, 'optionalAccess', _44 => _44.data]),
|
|
1707
1779
|
"portfolio"
|
|
1708
1780
|
)));
|
|
1709
1781
|
if (!portfolio || !Array.isArray(portfolio)) return null;
|
|
@@ -1714,17 +1786,17 @@ function normalizeOrchestratorPortfolio(data) {
|
|
|
1714
1786
|
for (const tokenData of data.portfolio || []) {
|
|
1715
1787
|
const chainBalances = _nullishCoalesce(_nullishCoalesce(tokenData.tokenChainBalance, () => ( tokenData.chainBalances)), () => ( []));
|
|
1716
1788
|
for (const chainBalance of chainBalances) {
|
|
1717
|
-
const unlocked = _nullishCoalesce(_optionalChain([chainBalance, 'access',
|
|
1789
|
+
const unlocked = _nullishCoalesce(_optionalChain([chainBalance, 'access', _45 => _45.balance, 'optionalAccess', _46 => _46.unlocked]), () => ( "0"));
|
|
1718
1790
|
const normalizedName = tokenData.tokenName.trim();
|
|
1719
1791
|
const isNativeSymbol = normalizedName.toUpperCase() === "ETH" || normalizedName.toUpperCase() === "ETHER";
|
|
1720
|
-
const tokenAddress = _nullishCoalesce(_nullishCoalesce(chainBalance.tokenAddress, () => ( extractTokenAddress(tokenData, chainBalance.chainId))), () => (
|
|
1721
|
-
const resolvedTokenAddress = isNativeSymbol ?
|
|
1792
|
+
const tokenAddress = _nullishCoalesce(_nullishCoalesce(chainBalance.tokenAddress, () => ( extractTokenAddress(tokenData, chainBalance.chainId))), () => ( _chunkTENL4H64cjs.getTokenAddress.call(void 0, tokenData.tokenName, chainBalance.chainId)));
|
|
1793
|
+
const resolvedTokenAddress = isNativeSymbol ? _chunkTENL4H64cjs.NATIVE_TOKEN_ADDRESS : tokenAddress;
|
|
1722
1794
|
if (!resolvedTokenAddress) {
|
|
1723
1795
|
continue;
|
|
1724
1796
|
}
|
|
1725
|
-
const registrySymbol =
|
|
1797
|
+
const registrySymbol = _chunkTENL4H64cjs.getTokenSymbol.call(void 0, resolvedTokenAddress, chainBalance.chainId);
|
|
1726
1798
|
const symbol = registrySymbol !== "Token" ? registrySymbol : normalizedName || "Token";
|
|
1727
|
-
const decimals = registrySymbol !== "Token" ?
|
|
1799
|
+
const decimals = registrySymbol !== "Token" ? _chunkTENL4H64cjs.getTokenDecimalsByAddress.call(void 0, resolvedTokenAddress, chainBalance.chainId) : _nullishCoalesce(tokenData.tokenDecimals, () => ( 18));
|
|
1728
1800
|
tokens.push({
|
|
1729
1801
|
chainId: chainBalance.chainId,
|
|
1730
1802
|
address: resolvedTokenAddress,
|
|
@@ -1744,28 +1816,28 @@ function normalizeOrchestratorPortfolio(data) {
|
|
|
1744
1816
|
function normalizeDirectToken(token) {
|
|
1745
1817
|
const rawChainId = _nullishCoalesce(extractNumber(token, "chainId"), () => ( extractNumber(token.chain, "id")));
|
|
1746
1818
|
const rawChainString = _nullishCoalesce(extractString(token, "chainId"), () => ( extractString(token.chain, "id")));
|
|
1747
|
-
const chainId = _nullishCoalesce(rawChainId, () => ( (rawChainString ?
|
|
1819
|
+
const chainId = _nullishCoalesce(rawChainId, () => ( (rawChainString ? _chunkTENL4H64cjs.isSolanaCaip2.call(void 0, rawChainString) || rawChainString.toLowerCase() === "solana" ? "solana" : (
|
|
1748
1820
|
// HyperCore (`hypercore:mainnet`) is a non-EVM source; keep its USDC
|
|
1749
1821
|
// instead of dropping it as an unparseable chain string.
|
|
1750
|
-
|
|
1822
|
+
_chunkTENL4H64cjs.isHyperCoreCaip2.call(void 0, rawChainString) || rawChainString.toLowerCase() === "hypercore" ? "hypercore" : _chunkTENL4H64cjs.parseEvmChainId.call(void 0, rawChainString)
|
|
1751
1823
|
) : null)));
|
|
1752
1824
|
if (chainId === null) return null;
|
|
1753
|
-
const registryChainId = typeof chainId === "number" ? chainId : chainId === "hypercore" ?
|
|
1825
|
+
const registryChainId = typeof chainId === "number" ? chainId : chainId === "hypercore" ? _chunkTENL4H64cjs.HYPERCORE_CHAIN_ID : void 0;
|
|
1754
1826
|
const symbol = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(extractString(token, "symbol"), () => ( extractString(token, "tokenSymbol"))), () => ( extractString(token, "tokenName"))), () => ( extractString(token, "name")));
|
|
1755
1827
|
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',
|
|
1828
|
+
const balanceValue = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(extractString(token, "balance"), () => ( extractString(token, "amount"))), () => ( extractString(token, "value"))), () => ( extractString(token, "rawBalance"))), () => ( _optionalChain([extractNumber, 'call', _47 => _47(token, "balance"), 'optionalAccess', _48 => _48.toString, 'call', _49 => _49()]))), () => ( _optionalChain([extractNumber, 'call', _50 => _50(token, "amount"), 'optionalAccess', _51 => _51.toString, 'call', _52 => _52()]))), () => ( _optionalChain([extractNumber, 'call', _53 => _53(token, "value"), 'optionalAccess', _54 => _54.toString, 'call', _55 => _55()]))), () => ( _optionalChain([extractNumber, 'call', _56 => _56(token, "rawBalance"), 'optionalAccess', _57 => _57.toString, 'call', _58 => _58()])));
|
|
1757
1829
|
if (!balanceValue) return null;
|
|
1758
1830
|
const address = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(extractString(token, "address"), () => ( extractString(token, "tokenAddress"))), () => ( extractString(
|
|
1759
1831
|
token.token,
|
|
1760
1832
|
"address"
|
|
1761
|
-
))), () => ( (registryChainId !== void 0 ?
|
|
1833
|
+
))), () => ( (registryChainId !== void 0 ? _chunkTENL4H64cjs.getTokenAddress.call(void 0, symbol, registryChainId) : void 0)));
|
|
1762
1834
|
if (!address) return null;
|
|
1763
1835
|
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
1836
|
const isSolanaToken = chainId === "solana";
|
|
1765
|
-
const registrySymbol = isSolanaToken ? "Token" :
|
|
1837
|
+
const registrySymbol = isSolanaToken ? "Token" : _chunkTENL4H64cjs.getTokenSymbol.call(void 0, address, registryChainId);
|
|
1766
1838
|
const resolvedSymbol = isSolanaToken ? symbol : registrySymbol !== "Token" ? registrySymbol : symbol;
|
|
1767
1839
|
const backendDecimals = _nullishCoalesce(extractNumber(token, "decimals"), () => ( extractNumber(token, "tokenDecimals")));
|
|
1768
|
-
const resolvedDecimals = !isSolanaToken && registrySymbol !== "Token" ?
|
|
1840
|
+
const resolvedDecimals = !isSolanaToken && registrySymbol !== "Token" ? _chunkTENL4H64cjs.getTokenDecimalsByAddress.call(void 0, address, registryChainId) : _nullishCoalesce(backendDecimals, () => ( 18));
|
|
1769
1841
|
return {
|
|
1770
1842
|
chainId,
|
|
1771
1843
|
address,
|
|
@@ -1778,7 +1850,7 @@ function normalizeDirectToken(token) {
|
|
|
1778
1850
|
}
|
|
1779
1851
|
function extractTokenAddress(tokenData, chainId) {
|
|
1780
1852
|
const token = tokenData;
|
|
1781
|
-
return _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(token.tokenAddress, () => ( token.address)), () => ( _optionalChain([token, 'access',
|
|
1853
|
+
return _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(token.tokenAddress, () => ( token.address)), () => ( _optionalChain([token, 'access', _59 => _59.addresses, 'optionalAccess', _60 => _60[chainId]]))), () => ( _optionalChain([token, 'access', _61 => _61.token, 'optionalAccess', _62 => _62.address]))), () => ( _optionalChain([token, 'access', _63 => _63.token, 'optionalAccess', _64 => _64.addresses, 'optionalAccess', _65 => _65[chainId]])));
|
|
1782
1854
|
}
|
|
1783
1855
|
function extractArray(data, key) {
|
|
1784
1856
|
if (!data || typeof data !== "object") return null;
|
|
@@ -1805,6 +1877,558 @@ function extractNumericString(data, key) {
|
|
|
1805
1877
|
return Number.isFinite(parsed) ? parsed : null;
|
|
1806
1878
|
}
|
|
1807
1879
|
|
|
1880
|
+
// src/core/rpc.ts
|
|
1881
|
+
|
|
1882
|
+
function rpcUrlFor(rpcUrls, chain) {
|
|
1883
|
+
const url = _optionalChain([rpcUrls, 'optionalAccess', _66 => _66[chain], 'optionalAccess', _67 => _67.trim, 'call', _68 => _68()]);
|
|
1884
|
+
return url ? url : void 0;
|
|
1885
|
+
}
|
|
1886
|
+
var RpcUrlsContext = _react.createContext.call(void 0, void 0);
|
|
1887
|
+
var RpcUrlsProvider = RpcUrlsContext.Provider;
|
|
1888
|
+
function useRpcUrls() {
|
|
1889
|
+
return _react.useContext.call(void 0, RpcUrlsContext);
|
|
1890
|
+
}
|
|
1891
|
+
function rpcUrlsKey(rpcUrls) {
|
|
1892
|
+
if (!rpcUrls) return "";
|
|
1893
|
+
return Object.entries(rpcUrls).map(([chain, url]) => [chain, _nullishCoalesce(_optionalChain([url, 'optionalAccess', _69 => _69.trim, 'call', _70 => _70()]), () => ( ""))]).filter(([, url]) => url !== "").map(([chain, url]) => `${chain}=${url}`).sort().join("|");
|
|
1894
|
+
}
|
|
1895
|
+
function useStableRpcUrls(rpcUrls) {
|
|
1896
|
+
const key = rpcUrlsKey(rpcUrls);
|
|
1897
|
+
return _react.useMemo.call(void 0, () => rpcUrls, [key]);
|
|
1898
|
+
}
|
|
1899
|
+
|
|
1900
|
+
// src/core/chain-catalog-context.tsx
|
|
1901
|
+
|
|
1902
|
+
|
|
1903
|
+
|
|
1904
|
+
|
|
1905
|
+
|
|
1906
|
+
|
|
1907
|
+
|
|
1908
|
+
|
|
1909
|
+
// src/core/public-client.ts
|
|
1910
|
+
|
|
1911
|
+
var clientCache = /* @__PURE__ */ new Map();
|
|
1912
|
+
var runtimeChainById = /* @__PURE__ */ new Map();
|
|
1913
|
+
function setRuntimeChains(chains) {
|
|
1914
|
+
for (const chain of chains) {
|
|
1915
|
+
const known = runtimeChainById.get(chain.id);
|
|
1916
|
+
if (known === chain) continue;
|
|
1917
|
+
runtimeChainById.set(chain.id, chain);
|
|
1918
|
+
for (const key of clientCache.keys()) {
|
|
1919
|
+
if (key.startsWith(`${chain.id}|`)) clientCache.delete(key);
|
|
1920
|
+
}
|
|
1921
|
+
}
|
|
1922
|
+
}
|
|
1923
|
+
function getPublicClient(chainId, rpcUrls) {
|
|
1924
|
+
const url = rpcUrlFor(rpcUrls, chainId);
|
|
1925
|
+
const cacheKey = `${chainId}|${_nullishCoalesce(url, () => ( ""))}`;
|
|
1926
|
+
let client = clientCache.get(cacheKey);
|
|
1927
|
+
if (!client) {
|
|
1928
|
+
const chain = _nullishCoalesce(_chunkTENL4H64cjs.CHAIN_BY_ID[chainId], () => ( runtimeChainById.get(chainId)));
|
|
1929
|
+
client = _viem.createPublicClient.call(void 0, {
|
|
1930
|
+
chain,
|
|
1931
|
+
transport: _viem.http.call(void 0, url)
|
|
1932
|
+
});
|
|
1933
|
+
clientCache.set(cacheKey, client);
|
|
1934
|
+
}
|
|
1935
|
+
return client;
|
|
1936
|
+
}
|
|
1937
|
+
|
|
1938
|
+
// src/core/chain-objects.ts
|
|
1939
|
+
|
|
1940
|
+
var viemChainsById = null;
|
|
1941
|
+
var viemChainsPromise = null;
|
|
1942
|
+
async function loadViemChains() {
|
|
1943
|
+
if (viemChainsById) return viemChainsById;
|
|
1944
|
+
if (!viemChainsPromise) {
|
|
1945
|
+
viemChainsPromise = Promise.resolve().then(() => _interopRequireWildcard(require("viem/chains"))).then((module) => {
|
|
1946
|
+
const map = /* @__PURE__ */ new Map();
|
|
1947
|
+
for (const value of Object.values(module)) {
|
|
1948
|
+
if (value && typeof value === "object" && typeof value.id === "number" && _optionalChain([value, 'access', _71 => _71.rpcUrls, 'optionalAccess', _72 => _72.default, 'optionalAccess', _73 => _73.http, 'optionalAccess', _74 => _74.length])) {
|
|
1949
|
+
const chain = value;
|
|
1950
|
+
const existing = map.get(chain.id);
|
|
1951
|
+
if (existing) existing.push(chain);
|
|
1952
|
+
else map.set(chain.id, [chain]);
|
|
1953
|
+
}
|
|
1954
|
+
}
|
|
1955
|
+
viemChainsById = map;
|
|
1956
|
+
return map;
|
|
1957
|
+
});
|
|
1958
|
+
}
|
|
1959
|
+
return viemChainsPromise;
|
|
1960
|
+
}
|
|
1961
|
+
function pickViemChain(candidates, chain) {
|
|
1962
|
+
if (!_optionalChain([candidates, 'optionalAccess', _75 => _75.length])) return void 0;
|
|
1963
|
+
if (candidates.length === 1) return candidates[0];
|
|
1964
|
+
const sameNetworkClass = candidates.filter(
|
|
1965
|
+
(candidate) => Boolean(candidate.testnet) === chain.testnet
|
|
1966
|
+
);
|
|
1967
|
+
if (sameNetworkClass.length === 1) return sameNetworkClass[0];
|
|
1968
|
+
const pool = sameNetworkClass.length > 0 ? sameNetworkClass : candidates;
|
|
1969
|
+
const normalized = chain.name.toLowerCase().replace(/\s+/g, "");
|
|
1970
|
+
const byName = pool.find(
|
|
1971
|
+
(candidate) => candidate.name.toLowerCase().replace(/\s+/g, "") === normalized
|
|
1972
|
+
);
|
|
1973
|
+
if (byName) return byName;
|
|
1974
|
+
return void 0;
|
|
1975
|
+
}
|
|
1976
|
+
function resolveRpcUrls(chain, override, viemChains) {
|
|
1977
|
+
const urls = [];
|
|
1978
|
+
if (_optionalChain([override, 'optionalAccess', _76 => _76.trim, 'call', _77 => _77()])) urls.push(override.trim());
|
|
1979
|
+
if (chain.publicRpcUrl) urls.push(chain.publicRpcUrl);
|
|
1980
|
+
if (chain.chainId !== null && chain.vmType === "evm") {
|
|
1981
|
+
const http2 = _optionalChain([pickViemChain, 'call', _78 => _78(_optionalChain([viemChains, 'optionalAccess', _79 => _79.get, 'call', _80 => _80(chain.chainId)]), chain), 'optionalAccess', _81 => _81.rpcUrls, 'optionalAccess', _82 => _82.default, 'optionalAccess', _83 => _83.http]);
|
|
1982
|
+
if (http2) urls.push(...http2);
|
|
1983
|
+
}
|
|
1984
|
+
return [...new Set(urls)];
|
|
1985
|
+
}
|
|
1986
|
+
function toViemChain(chain, override, viemChains) {
|
|
1987
|
+
if (chain.vmType !== "evm" || chain.chainId === null) return null;
|
|
1988
|
+
const rpcUrls = resolveRpcUrls(chain, override, viemChains);
|
|
1989
|
+
if (rpcUrls.length === 0) return null;
|
|
1990
|
+
const bundled = pickViemChain(_optionalChain([viemChains, 'optionalAccess', _84 => _84.get, 'call', _85 => _85(chain.chainId)]), chain);
|
|
1991
|
+
if (bundled) {
|
|
1992
|
+
if (rpcUrls[0] === bundled.rpcUrls.default.http[0]) return bundled;
|
|
1993
|
+
return _viem.defineChain.call(void 0, {
|
|
1994
|
+
...bundled,
|
|
1995
|
+
rpcUrls: { ...bundled.rpcUrls, default: { http: rpcUrls } }
|
|
1996
|
+
});
|
|
1997
|
+
}
|
|
1998
|
+
return _viem.defineChain.call(void 0, {
|
|
1999
|
+
id: chain.chainId,
|
|
2000
|
+
name: chain.name,
|
|
2001
|
+
nativeCurrency: {
|
|
2002
|
+
name: chain.nativeToken.symbol,
|
|
2003
|
+
symbol: chain.nativeToken.symbol,
|
|
2004
|
+
decimals: chain.nativeToken.decimals
|
|
2005
|
+
},
|
|
2006
|
+
rpcUrls: { default: { http: rpcUrls } },
|
|
2007
|
+
blockExplorers: chain.explorer ? {
|
|
2008
|
+
default: {
|
|
2009
|
+
name: "Explorer",
|
|
2010
|
+
url: chain.explorer.url
|
|
2011
|
+
}
|
|
2012
|
+
} : void 0,
|
|
2013
|
+
testnet: chain.testnet
|
|
2014
|
+
});
|
|
2015
|
+
}
|
|
2016
|
+
function toViemChains(catalog, overrides, viemChains) {
|
|
2017
|
+
const chains = [];
|
|
2018
|
+
for (const entry of catalog.all) {
|
|
2019
|
+
const chain = toViemChain(
|
|
2020
|
+
entry,
|
|
2021
|
+
entry.chainId === null ? void 0 : _optionalChain([overrides, 'optionalAccess', _86 => _86[entry.chainId]]),
|
|
2022
|
+
viemChains
|
|
2023
|
+
);
|
|
2024
|
+
if (chain) chains.push(chain);
|
|
2025
|
+
}
|
|
2026
|
+
return chains;
|
|
2027
|
+
}
|
|
2028
|
+
function needsViemChains(catalog, overrides) {
|
|
2029
|
+
return catalog.all.some(
|
|
2030
|
+
(chain) => chain.vmType === "evm" && chain.chainId !== null && !chain.publicRpcUrl && !_optionalChain([overrides, 'optionalAccess', _87 => _87[chain.chainId], 'optionalAccess', _88 => _88.trim, 'call', _89 => _89()])
|
|
2031
|
+
);
|
|
2032
|
+
}
|
|
2033
|
+
|
|
2034
|
+
// src/core/chain-catalog-context.tsx
|
|
2035
|
+
|
|
2036
|
+
var EMPTY = {
|
|
2037
|
+
catalog: null,
|
|
2038
|
+
viemChains: null,
|
|
2039
|
+
isLoading: true,
|
|
2040
|
+
shortlist: null,
|
|
2041
|
+
clientCapableChainIds: null
|
|
2042
|
+
};
|
|
2043
|
+
var ChainCatalogContext = _react.createContext.call(void 0, EMPTY);
|
|
2044
|
+
var resolvedChainsByKey = /* @__PURE__ */ new Map();
|
|
2045
|
+
function overridesKey(overrides) {
|
|
2046
|
+
return Object.entries(_nullishCoalesce(overrides, () => ( {}))).map(([id, override]) => `${id}=${_nullishCoalesce(override, () => ( ""))}`).sort().join("|");
|
|
2047
|
+
}
|
|
2048
|
+
function runtimeChainsKey(backendUrl, overrides) {
|
|
2049
|
+
return [backendUrl.replace(/\/$/, ""), overridesKey(overrides)].join("#");
|
|
2050
|
+
}
|
|
2051
|
+
var catalogByBackend = /* @__PURE__ */ new Map();
|
|
2052
|
+
function primeChainCatalog(backendUrl, debug = false) {
|
|
2053
|
+
const key = backendUrl.replace(/\/$/, "");
|
|
2054
|
+
let promise = catalogByBackend.get(key);
|
|
2055
|
+
if (!promise) {
|
|
2056
|
+
promise = createDepositService(key, {
|
|
2057
|
+
debug,
|
|
2058
|
+
debugScope: "service:chains"
|
|
2059
|
+
}).getChains();
|
|
2060
|
+
catalogByBackend.set(key, promise);
|
|
2061
|
+
promise.then((catalog) => {
|
|
2062
|
+
if (!catalog) catalogByBackend.delete(key);
|
|
2063
|
+
});
|
|
2064
|
+
}
|
|
2065
|
+
return promise;
|
|
2066
|
+
}
|
|
2067
|
+
function peekRuntimeChains(backendUrl, overrides) {
|
|
2068
|
+
return _nullishCoalesce(resolvedChainsByKey.get(runtimeChainsKey(backendUrl, overrides)), () => ( null));
|
|
2069
|
+
}
|
|
2070
|
+
function publishCatalogTokens(catalog) {
|
|
2071
|
+
_chunkTENL4H64cjs.setRuntimeTokens.call(void 0,
|
|
2072
|
+
catalog.all.flatMap(
|
|
2073
|
+
(chain) => chain.chainId === null || !Array.isArray(chain.supportedTokens) ? [] : chain.supportedTokens.map((token) => ({
|
|
2074
|
+
chainId: chain.chainId,
|
|
2075
|
+
symbol: token.symbol,
|
|
2076
|
+
address: token.address,
|
|
2077
|
+
decimals: token.decimals
|
|
2078
|
+
}))
|
|
2079
|
+
)
|
|
2080
|
+
);
|
|
2081
|
+
}
|
|
2082
|
+
function publishRuntimeChainMeta(catalog) {
|
|
2083
|
+
_chunkTENL4H64cjs.setRuntimeChainMeta.call(void 0,
|
|
2084
|
+
catalog.all.flatMap((chain) => {
|
|
2085
|
+
const ids = [];
|
|
2086
|
+
if (chain.chainId !== null) ids.push(chain.chainId);
|
|
2087
|
+
if (chain.caip2 === _chunkTENL4H64cjs.HYPERCORE_MAINNET_CAIP2) ids.push(_chunkTENL4H64cjs.HYPERCORE_CHAIN_ID);
|
|
2088
|
+
return ids.map((chainId) => ({
|
|
2089
|
+
chainId,
|
|
2090
|
+
name: chain.name,
|
|
2091
|
+
iconUrl: _nullishCoalesce(chain.iconUrl, () => ( void 0)),
|
|
2092
|
+
nativeSymbol: chain.nativeToken.symbol
|
|
2093
|
+
}));
|
|
2094
|
+
})
|
|
2095
|
+
);
|
|
2096
|
+
}
|
|
2097
|
+
var runtimeChainsByBackend = /* @__PURE__ */ new Map();
|
|
2098
|
+
function primeRuntimeChains(backendUrl, overrides, debug = false) {
|
|
2099
|
+
const url = backendUrl.replace(/\/$/, "");
|
|
2100
|
+
const key = runtimeChainsKey(url, overrides);
|
|
2101
|
+
let promise = runtimeChainsByBackend.get(key);
|
|
2102
|
+
if (!promise) {
|
|
2103
|
+
promise = primeChainCatalog(url, debug).then(async (catalog) => {
|
|
2104
|
+
if (!catalog) return [];
|
|
2105
|
+
publishRuntimeChainMeta(catalog);
|
|
2106
|
+
publishCatalogTokens(catalog);
|
|
2107
|
+
const viemChains = needsViemChains(catalog, overrides) ? await loadViemChains() : null;
|
|
2108
|
+
const chains = toViemChains(catalog, overrides, viemChains);
|
|
2109
|
+
if (chains.length > 0) {
|
|
2110
|
+
setRuntimeChains(chains);
|
|
2111
|
+
resolvedChainsByKey.set(key, chains);
|
|
2112
|
+
}
|
|
2113
|
+
return chains;
|
|
2114
|
+
}).catch(() => []);
|
|
2115
|
+
runtimeChainsByBackend.set(key, promise);
|
|
2116
|
+
promise.then((chains) => {
|
|
2117
|
+
if (chains.length === 0) runtimeChainsByBackend.delete(key);
|
|
2118
|
+
});
|
|
2119
|
+
}
|
|
2120
|
+
return promise;
|
|
2121
|
+
}
|
|
2122
|
+
function useChainCatalog() {
|
|
2123
|
+
return _react.useContext.call(void 0, ChainCatalogContext);
|
|
2124
|
+
}
|
|
2125
|
+
function useCatalogChain(chainId) {
|
|
2126
|
+
const { catalog } = useChainCatalog();
|
|
2127
|
+
if (!catalog || chainId == null) return void 0;
|
|
2128
|
+
return typeof chainId === "number" ? catalog.byChainId.get(chainId) : catalog.byCaip2.get(chainId);
|
|
2129
|
+
}
|
|
2130
|
+
function useDepositChainIds() {
|
|
2131
|
+
const { catalog } = useChainCatalog();
|
|
2132
|
+
return _react.useMemo.call(void 0, () => {
|
|
2133
|
+
if (!catalog) return _chunkTENL4H64cjs.getSupportedChainIds.call(void 0, );
|
|
2134
|
+
const ids = catalog.all.filter(
|
|
2135
|
+
(c) => c.deposit && c.vmType === "evm" && c.chainId !== null && // `/chains` enumerates testnets; the bundled list never did, and a
|
|
2136
|
+
// production picker offering Sepolia next to Ethereum is a way to
|
|
2137
|
+
// lose funds. Reading the set at runtime must not quietly widen it
|
|
2138
|
+
// to a different KIND of chain.
|
|
2139
|
+
!c.testnet
|
|
2140
|
+
).map((c) => c.chainId);
|
|
2141
|
+
const rank = (id) => {
|
|
2142
|
+
const i = _chunkTENL4H64cjs.CHAIN_DISPLAY_ORDER.indexOf(id);
|
|
2143
|
+
return i === -1 ? _chunkTENL4H64cjs.CHAIN_DISPLAY_ORDER.length : i;
|
|
2144
|
+
};
|
|
2145
|
+
return ids.map((id, i) => ({ id, i })).sort((a, b) => rank(a.id) - rank(b.id) || a.i - b.i).map(({ id }) => id);
|
|
2146
|
+
}, [catalog]);
|
|
2147
|
+
}
|
|
2148
|
+
function useDestinationChains() {
|
|
2149
|
+
const { catalog } = useChainCatalog();
|
|
2150
|
+
return _react.useMemo.call(void 0, () => {
|
|
2151
|
+
if (!catalog) {
|
|
2152
|
+
return _chunkTENL4H64cjs.SOURCE_CHAINS.filter(
|
|
2153
|
+
(chain) => _chunkTENL4H64cjs.getSupportedTargetTokens.call(void 0, chain.id).length > 0
|
|
2154
|
+
).map((chain) => ({ id: chain.id, name: chain.name }));
|
|
2155
|
+
}
|
|
2156
|
+
const rank = (id) => {
|
|
2157
|
+
const i = _chunkTENL4H64cjs.CHAIN_DISPLAY_ORDER.indexOf(id);
|
|
2158
|
+
return i === -1 ? _chunkTENL4H64cjs.CHAIN_DISPLAY_ORDER.length : i;
|
|
2159
|
+
};
|
|
2160
|
+
return catalog.all.filter(
|
|
2161
|
+
(c) => c.destination && c.vmType === "evm" && c.chainId !== null && !c.testnet
|
|
2162
|
+
).map((c, i) => ({ id: c.chainId, name: c.name, i })).sort((a, b) => rank(a.id) - rank(b.id) || a.i - b.i).map(({ id, name }) => ({ id, name }));
|
|
2163
|
+
}, [catalog]);
|
|
2164
|
+
}
|
|
2165
|
+
function useTargetTokens() {
|
|
2166
|
+
const { catalog, shortlist } = useChainCatalog();
|
|
2167
|
+
return _react.useMemo.call(void 0, () => {
|
|
2168
|
+
return (chainId) => {
|
|
2169
|
+
const bundled = _chunkTENL4H64cjs.getBundledTargetTokens.call(void 0, chainId);
|
|
2170
|
+
if (bundled.length > 0) return bundled;
|
|
2171
|
+
const fromShortlist = _optionalChain([shortlist, 'optionalAccess', _90 => _90[String(chainId)]]);
|
|
2172
|
+
if (_optionalChain([fromShortlist, 'optionalAccess', _91 => _91.length])) {
|
|
2173
|
+
return fromShortlist.map((token) => ({
|
|
2174
|
+
symbol: token.symbol,
|
|
2175
|
+
address: token.address,
|
|
2176
|
+
decimals: token.decimals
|
|
2177
|
+
}));
|
|
2178
|
+
}
|
|
2179
|
+
const entry = _optionalChain([catalog, 'optionalAccess', _92 => _92.byChainId, 'access', _93 => _93.get, 'call', _94 => _94(chainId)]);
|
|
2180
|
+
return Array.isArray(_optionalChain([entry, 'optionalAccess', _95 => _95.supportedTokens])) ? entry.supportedTokens.map((token) => ({
|
|
2181
|
+
symbol: token.symbol,
|
|
2182
|
+
address: token.address,
|
|
2183
|
+
decimals: token.decimals
|
|
2184
|
+
})) : [];
|
|
2185
|
+
};
|
|
2186
|
+
}, [catalog, shortlist]);
|
|
2187
|
+
}
|
|
2188
|
+
function useIsDepositChain() {
|
|
2189
|
+
const ids = useDepositChainIds();
|
|
2190
|
+
const { clientCapableChainIds } = useChainCatalog();
|
|
2191
|
+
return _react.useMemo.call(void 0, () => {
|
|
2192
|
+
const set = new Set(ids);
|
|
2193
|
+
return (chainId) => set.has(chainId) && (clientCapableChainIds === null || clientCapableChainIds.has(chainId));
|
|
2194
|
+
}, [ids, clientCapableChainIds]);
|
|
2195
|
+
}
|
|
2196
|
+
function useChainName() {
|
|
2197
|
+
const { catalog } = useChainCatalog();
|
|
2198
|
+
return _react.useMemo.call(void 0, () => {
|
|
2199
|
+
return (chainId) => {
|
|
2200
|
+
if (!catalog) return _chunkTENL4H64cjs.getChainName.call(void 0, chainId);
|
|
2201
|
+
const key = catalogKeyForChain(chainId);
|
|
2202
|
+
const entry = typeof key === "number" ? catalog.byChainId.get(key) : catalog.byCaip2.get(key);
|
|
2203
|
+
return _nullishCoalesce(_optionalChain([entry, 'optionalAccess', _96 => _96.name]), () => ( _chunkTENL4H64cjs.getChainName.call(void 0, chainId)));
|
|
2204
|
+
};
|
|
2205
|
+
}, [catalog]);
|
|
2206
|
+
}
|
|
2207
|
+
function useExplorerTxUrl() {
|
|
2208
|
+
const { catalog } = useChainCatalog();
|
|
2209
|
+
return _react.useMemo.call(void 0, () => {
|
|
2210
|
+
return (chainId, txHash) => {
|
|
2211
|
+
if (chainId === "hypercore") return _chunkTENL4H64cjs.getExplorerTxUrl.call(void 0, chainId, txHash);
|
|
2212
|
+
const key = catalog ? catalogKeyForChain(chainId) : void 0;
|
|
2213
|
+
const entry = key === void 0 ? void 0 : typeof key === "number" ? _optionalChain([catalog, 'optionalAccess', _97 => _97.byChainId, 'access', _98 => _98.get, 'call', _99 => _99(key)]) : _optionalChain([catalog, 'optionalAccess', _100 => _100.byCaip2, 'access', _101 => _101.get, 'call', _102 => _102(key)]);
|
|
2214
|
+
return _nullishCoalesce(catalogExplorerTxUrl(entry, txHash), () => ( _chunkTENL4H64cjs.getExplorerTxUrl.call(void 0, chainId, txHash)));
|
|
2215
|
+
};
|
|
2216
|
+
}, [catalog]);
|
|
2217
|
+
}
|
|
2218
|
+
function ChainCatalogProvider({
|
|
2219
|
+
service,
|
|
2220
|
+
rpcUrls,
|
|
2221
|
+
children
|
|
2222
|
+
}) {
|
|
2223
|
+
const [catalog, setCatalog] = _react.useState.call(void 0, null);
|
|
2224
|
+
const [viemChains, setViemChains] = _react.useState.call(void 0, null);
|
|
2225
|
+
const [isLoading, setIsLoading] = _react.useState.call(void 0, true);
|
|
2226
|
+
_react.useEffect.call(void 0, () => {
|
|
2227
|
+
let active = true;
|
|
2228
|
+
setIsLoading(true);
|
|
2229
|
+
service.getChains().then((next) => {
|
|
2230
|
+
if (!active) return;
|
|
2231
|
+
setCatalog(next);
|
|
2232
|
+
setIsLoading(false);
|
|
2233
|
+
});
|
|
2234
|
+
return () => {
|
|
2235
|
+
active = false;
|
|
2236
|
+
};
|
|
2237
|
+
}, [service]);
|
|
2238
|
+
const overrides = _react.useMemo.call(void 0, () => {
|
|
2239
|
+
if (!rpcUrls) return void 0;
|
|
2240
|
+
const out = {};
|
|
2241
|
+
for (const [key, url] of Object.entries(rpcUrls)) {
|
|
2242
|
+
const id = Number(key);
|
|
2243
|
+
if (Number.isFinite(id) && typeof url === "string") out[id] = url;
|
|
2244
|
+
}
|
|
2245
|
+
return out;
|
|
2246
|
+
}, [rpcUrls]);
|
|
2247
|
+
const overrideKey = overridesKey(overrides);
|
|
2248
|
+
_react.useEffect.call(void 0, () => {
|
|
2249
|
+
if (!catalog || viemChains) return;
|
|
2250
|
+
if (!needsViemChains(catalog, overrides)) return;
|
|
2251
|
+
let active = true;
|
|
2252
|
+
loadViemChains().then((chains) => {
|
|
2253
|
+
if (active) setViemChains(chains);
|
|
2254
|
+
});
|
|
2255
|
+
return () => {
|
|
2256
|
+
active = false;
|
|
2257
|
+
};
|
|
2258
|
+
}, [catalog, viemChains, overrideKey]);
|
|
2259
|
+
_react.useEffect.call(void 0, () => {
|
|
2260
|
+
if (!catalog) return;
|
|
2261
|
+
publishRuntimeChainMeta(catalog);
|
|
2262
|
+
publishCatalogTokens(catalog);
|
|
2263
|
+
const chains = toViemChains(catalog, overrides, viemChains);
|
|
2264
|
+
if (chains.length > 0) setRuntimeChains(chains);
|
|
2265
|
+
}, [catalog, viemChains, overrides]);
|
|
2266
|
+
const [shortlist, setShortlist] = _react.useState.call(void 0, null);
|
|
2267
|
+
_react.useEffect.call(void 0, () => {
|
|
2268
|
+
let active = true;
|
|
2269
|
+
setShortlist(null);
|
|
2270
|
+
service.getTopTokens().then((tokens) => {
|
|
2271
|
+
if (!active || !tokens) return;
|
|
2272
|
+
_chunkTENL4H64cjs.publishShortlistTokens.call(void 0, tokens);
|
|
2273
|
+
setShortlist(tokens);
|
|
2274
|
+
});
|
|
2275
|
+
return () => {
|
|
2276
|
+
active = false;
|
|
2277
|
+
};
|
|
2278
|
+
}, [service]);
|
|
2279
|
+
const clientCapableChainIds = _react.useMemo.call(void 0, () => {
|
|
2280
|
+
if (!catalog) return null;
|
|
2281
|
+
return new Set(
|
|
2282
|
+
toViemChains(catalog, overrides, viemChains).map((c) => c.id)
|
|
2283
|
+
);
|
|
2284
|
+
}, [catalog, viemChains, overrideKey]);
|
|
2285
|
+
const value = _react.useMemo.call(void 0,
|
|
2286
|
+
() => ({
|
|
2287
|
+
catalog,
|
|
2288
|
+
viemChains,
|
|
2289
|
+
isLoading,
|
|
2290
|
+
shortlist,
|
|
2291
|
+
clientCapableChainIds
|
|
2292
|
+
}),
|
|
2293
|
+
[catalog, viemChains, isLoading, shortlist, clientCapableChainIds]
|
|
2294
|
+
);
|
|
2295
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ChainCatalogContext.Provider, { value, children });
|
|
2296
|
+
}
|
|
2297
|
+
|
|
2298
|
+
// src/core/useLatestRef.ts
|
|
2299
|
+
|
|
2300
|
+
function useLatestRef(value) {
|
|
2301
|
+
const ref = _react.useRef.call(void 0, value);
|
|
2302
|
+
_react.useEffect.call(void 0, () => {
|
|
2303
|
+
ref.current = value;
|
|
2304
|
+
}, [value]);
|
|
2305
|
+
return ref;
|
|
2306
|
+
}
|
|
2307
|
+
|
|
2308
|
+
// src/components/ui/Spinner.tsx
|
|
2309
|
+
|
|
2310
|
+
function Spinner({ className }) {
|
|
2311
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2312
|
+
"svg",
|
|
2313
|
+
{
|
|
2314
|
+
className: `rs-spinner ${className || ""}`,
|
|
2315
|
+
fill: "none",
|
|
2316
|
+
viewBox: "0 0 20 21",
|
|
2317
|
+
children: [
|
|
2318
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2319
|
+
"path",
|
|
2320
|
+
{
|
|
2321
|
+
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",
|
|
2322
|
+
fill: "currentColor",
|
|
2323
|
+
opacity: 0.3
|
|
2324
|
+
}
|
|
2325
|
+
),
|
|
2326
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2327
|
+
"path",
|
|
2328
|
+
{
|
|
2329
|
+
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",
|
|
2330
|
+
fill: "currentColor"
|
|
2331
|
+
}
|
|
2332
|
+
)
|
|
2333
|
+
]
|
|
2334
|
+
}
|
|
2335
|
+
);
|
|
2336
|
+
}
|
|
2337
|
+
|
|
2338
|
+
// src/components/ui/Button.tsx
|
|
2339
|
+
|
|
2340
|
+
function Button({
|
|
2341
|
+
children,
|
|
2342
|
+
variant = "accent",
|
|
2343
|
+
size = "default",
|
|
2344
|
+
loading = false,
|
|
2345
|
+
loadingText,
|
|
2346
|
+
fullWidth = false,
|
|
2347
|
+
disabled,
|
|
2348
|
+
className = "",
|
|
2349
|
+
...props
|
|
2350
|
+
}) {
|
|
2351
|
+
const classes = [
|
|
2352
|
+
"rs-button",
|
|
2353
|
+
`rs-button--${variant}`,
|
|
2354
|
+
`rs-button--size-${size}`,
|
|
2355
|
+
fullWidth ? "rs-button--full-width" : "",
|
|
2356
|
+
className
|
|
2357
|
+
].filter(Boolean).join(" ");
|
|
2358
|
+
const showInlineLoadingText = loading && loadingText !== void 0;
|
|
2359
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2360
|
+
"button",
|
|
2361
|
+
{
|
|
2362
|
+
className: classes,
|
|
2363
|
+
disabled: disabled || loading,
|
|
2364
|
+
"aria-busy": loading || void 0,
|
|
2365
|
+
...props,
|
|
2366
|
+
children: showInlineLoadingText ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "rs-button__loading-row", children: [
|
|
2367
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Spinner, { className: "rs-spinner--sm" }),
|
|
2368
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: loadingText })
|
|
2369
|
+
] }) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
2370
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: loading ? "rs-button__content--hidden" : "", children }),
|
|
2371
|
+
loading && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-button__spinner", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Spinner, { className: "rs-spinner--sm" }) })
|
|
2372
|
+
] })
|
|
2373
|
+
}
|
|
2374
|
+
);
|
|
2375
|
+
}
|
|
2376
|
+
Button.displayName = "Button";
|
|
2377
|
+
|
|
2378
|
+
// src/components/ui/Callout.tsx
|
|
2379
|
+
|
|
2380
|
+
function CircleAlertIcon() {
|
|
2381
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2382
|
+
"svg",
|
|
2383
|
+
{
|
|
2384
|
+
width: "16",
|
|
2385
|
+
height: "16",
|
|
2386
|
+
viewBox: "0 0 16 16",
|
|
2387
|
+
fill: "none",
|
|
2388
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2389
|
+
"aria-hidden": "true",
|
|
2390
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2391
|
+
"path",
|
|
2392
|
+
{
|
|
2393
|
+
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",
|
|
2394
|
+
stroke: "currentColor",
|
|
2395
|
+
strokeWidth: "1.33",
|
|
2396
|
+
strokeLinecap: "round",
|
|
2397
|
+
strokeLinejoin: "round"
|
|
2398
|
+
}
|
|
2399
|
+
)
|
|
2400
|
+
}
|
|
2401
|
+
);
|
|
2402
|
+
}
|
|
2403
|
+
function Callout({ variant = "error", children, role }) {
|
|
2404
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2405
|
+
"div",
|
|
2406
|
+
{
|
|
2407
|
+
className: `rs-callout rs-callout--${variant}`,
|
|
2408
|
+
role: _nullishCoalesce(role, () => ( (variant === "error" ? "alert" : "status"))),
|
|
2409
|
+
children: [
|
|
2410
|
+
/* @__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, {}) }),
|
|
2411
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-callout-text", children })
|
|
2412
|
+
]
|
|
2413
|
+
}
|
|
2414
|
+
);
|
|
2415
|
+
}
|
|
2416
|
+
Callout.displayName = "Callout";
|
|
2417
|
+
|
|
2418
|
+
// src/components/ui/TokenIcon.tsx
|
|
2419
|
+
|
|
2420
|
+
function TokenIcon({ symbol, className, fallback }) {
|
|
2421
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2422
|
+
CdnIcon,
|
|
2423
|
+
{
|
|
2424
|
+
src: _chunkTENL4H64cjs.tokenIconUrl.call(void 0, symbol),
|
|
2425
|
+
className: `rs-token-icon ${_nullishCoalesce(className, () => ( ""))}`.trimEnd(),
|
|
2426
|
+
fallback
|
|
2427
|
+
}
|
|
2428
|
+
);
|
|
2429
|
+
}
|
|
2430
|
+
TokenIcon.displayName = "TokenIcon";
|
|
2431
|
+
|
|
1808
2432
|
// src/core/formatters.ts
|
|
1809
2433
|
var currencyFormatter = new Intl.NumberFormat("en-US", {
|
|
1810
2434
|
style: "currency",
|
|
@@ -1898,29 +2522,29 @@ var EVM_ADDRESS_RE = /^0x[a-fA-F0-9]{40}$/;
|
|
|
1898
2522
|
function resolveTokenDisplay(token, chain, fallback) {
|
|
1899
2523
|
if (token !== void 0) {
|
|
1900
2524
|
if (chain === "solana") {
|
|
1901
|
-
const solanaToken =
|
|
2525
|
+
const solanaToken = _chunkTENL4H64cjs.getSolanaTokenByMint.call(void 0, token);
|
|
1902
2526
|
if (solanaToken) {
|
|
1903
2527
|
return { symbol: solanaToken.symbol, decimals: solanaToken.decimals };
|
|
1904
2528
|
}
|
|
1905
2529
|
} else if (chain === "hypercore") {
|
|
1906
|
-
const t =
|
|
2530
|
+
const t = _chunkTENL4H64cjs.HYPERCORE_SOURCE_TOKENS.find(
|
|
1907
2531
|
(x) => x.address.toLowerCase() === token.toLowerCase()
|
|
1908
2532
|
);
|
|
1909
2533
|
if (t) return { symbol: t.symbol, decimals: t.decimals };
|
|
1910
2534
|
} else if (EVM_ADDRESS_RE.test(token)) {
|
|
1911
|
-
const symbol =
|
|
1912
|
-
const decimals =
|
|
2535
|
+
const symbol = _chunkTENL4H64cjs.getTokenSymbol.call(void 0, token, chain);
|
|
2536
|
+
const decimals = _chunkTENL4H64cjs.findTokenDecimals.call(void 0, token, chain);
|
|
1913
2537
|
if (symbol !== "Token" || decimals !== void 0) {
|
|
1914
2538
|
return {
|
|
1915
|
-
symbol: symbol !== "Token" ? symbol : _nullishCoalesce(_optionalChain([fallback, 'optionalAccess',
|
|
1916
|
-
decimals: _nullishCoalesce(decimals, () => ( _optionalChain([fallback, 'optionalAccess',
|
|
2539
|
+
symbol: symbol !== "Token" ? symbol : _nullishCoalesce(_optionalChain([fallback, 'optionalAccess', _103 => _103.symbol]), () => ( symbol)),
|
|
2540
|
+
decimals: _nullishCoalesce(decimals, () => ( _optionalChain([fallback, 'optionalAccess', _104 => _104.decimals])))
|
|
1917
2541
|
};
|
|
1918
2542
|
}
|
|
1919
2543
|
}
|
|
1920
2544
|
}
|
|
1921
2545
|
return {
|
|
1922
|
-
symbol: _nullishCoalesce(_optionalChain([fallback, 'optionalAccess',
|
|
1923
|
-
decimals: _optionalChain([fallback, 'optionalAccess',
|
|
2546
|
+
symbol: _nullishCoalesce(_optionalChain([fallback, 'optionalAccess', _105 => _105.symbol]), () => ( "Token")),
|
|
2547
|
+
decimals: _optionalChain([fallback, 'optionalAccess', _106 => _106.decimals])
|
|
1924
2548
|
};
|
|
1925
2549
|
}
|
|
1926
2550
|
function maxFractionDigitsFor(symbol) {
|
|
@@ -1958,13 +2582,13 @@ function priceUsdFor(symbol, prices) {
|
|
|
1958
2582
|
}
|
|
1959
2583
|
function isRecognizedToken(address, chain) {
|
|
1960
2584
|
if (address === void 0 || chain === void 0) return false;
|
|
1961
|
-
if (chain === "solana") return
|
|
2585
|
+
if (chain === "solana") return _chunkTENL4H64cjs.getSolanaTokenByMint.call(void 0, address) !== void 0;
|
|
1962
2586
|
if (chain === "hypercore") {
|
|
1963
|
-
return
|
|
2587
|
+
return _chunkTENL4H64cjs.HYPERCORE_SOURCE_TOKENS.some(
|
|
1964
2588
|
(t) => t.address.toLowerCase() === address.toLowerCase()
|
|
1965
2589
|
);
|
|
1966
2590
|
}
|
|
1967
|
-
return EVM_ADDRESS_RE.test(address) &&
|
|
2591
|
+
return EVM_ADDRESS_RE.test(address) && _chunkTENL4H64cjs.isRegistryTokenOnChain.call(void 0, address, chain);
|
|
1968
2592
|
}
|
|
1969
2593
|
function estimateReceiveAmount(params) {
|
|
1970
2594
|
const {
|
|
@@ -2015,26 +2639,6 @@ function formatReceiveEstimate(params) {
|
|
|
2015
2639
|
return sameSymbol ? `${formatted} ${params.targetSymbol}` : `~${formatted} ${params.targetSymbol}`;
|
|
2016
2640
|
}
|
|
2017
2641
|
|
|
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
2642
|
// src/core/theme.ts
|
|
2039
2643
|
var RADIUS_SCALE = {
|
|
2040
2644
|
none: { sm: "0", md: "0", lg: "0" },
|
|
@@ -2137,19 +2741,19 @@ var CUSTOM_PRIMARY_VARS = [
|
|
|
2137
2741
|
function applyTheme(element, theme) {
|
|
2138
2742
|
if (!element) return;
|
|
2139
2743
|
const parent = element.parentElement;
|
|
2140
|
-
const targets = _optionalChain([parent, 'optionalAccess',
|
|
2141
|
-
if (_optionalChain([theme, 'optionalAccess',
|
|
2744
|
+
const targets = _optionalChain([parent, 'optionalAccess', _107 => _107.classList, 'access', _108 => _108.contains, 'call', _109 => _109("rs-modal-content")]) ? [element, parent] : [element];
|
|
2745
|
+
if (_optionalChain([theme, 'optionalAccess', _110 => _110.mode])) {
|
|
2142
2746
|
for (const t of targets) t.setAttribute("data-theme", theme.mode);
|
|
2143
2747
|
} else {
|
|
2144
2748
|
for (const t of targets) t.removeAttribute("data-theme");
|
|
2145
2749
|
}
|
|
2146
|
-
if (_optionalChain([theme, 'optionalAccess',
|
|
2750
|
+
if (_optionalChain([theme, 'optionalAccess', _111 => _111.fontColor])) {
|
|
2147
2751
|
setVar(targets, "--rs-foreground", theme.fontColor);
|
|
2148
2752
|
}
|
|
2149
|
-
if (_optionalChain([theme, 'optionalAccess',
|
|
2753
|
+
if (_optionalChain([theme, 'optionalAccess', _112 => _112.iconColor])) {
|
|
2150
2754
|
setVar(targets, "--rs-icon", theme.iconColor);
|
|
2151
2755
|
}
|
|
2152
|
-
if (_optionalChain([theme, 'optionalAccess',
|
|
2756
|
+
if (_optionalChain([theme, 'optionalAccess', _113 => _113.ctaColor])) {
|
|
2153
2757
|
const derived = deriveCustomPrimary(theme.ctaColor);
|
|
2154
2758
|
if (derived) {
|
|
2155
2759
|
setVar(targets, "--rs-primary", derived.base);
|
|
@@ -2174,18 +2778,18 @@ function applyTheme(element, theme) {
|
|
|
2174
2778
|
}
|
|
2175
2779
|
} else {
|
|
2176
2780
|
for (const v of CUSTOM_PRIMARY_VARS) clearVar(targets, v);
|
|
2177
|
-
if (_optionalChain([theme, 'optionalAccess',
|
|
2781
|
+
if (_optionalChain([theme, 'optionalAccess', _114 => _114.ctaHoverColor])) {
|
|
2178
2782
|
setVar(targets, "--rs-primary-hover", theme.ctaHoverColor);
|
|
2179
2783
|
}
|
|
2180
2784
|
}
|
|
2181
|
-
if (_optionalChain([theme, 'optionalAccess',
|
|
2785
|
+
if (_optionalChain([theme, 'optionalAccess', _115 => _115.borderColor])) {
|
|
2182
2786
|
setVar(targets, "--rs-border", theme.borderColor);
|
|
2183
2787
|
setVar(targets, "--rs-border-surface", theme.borderColor);
|
|
2184
2788
|
}
|
|
2185
|
-
if (_optionalChain([theme, 'optionalAccess',
|
|
2789
|
+
if (_optionalChain([theme, 'optionalAccess', _116 => _116.backgroundColor])) {
|
|
2186
2790
|
setVar(targets, "--rs-background", theme.backgroundColor);
|
|
2187
2791
|
}
|
|
2188
|
-
if (_optionalChain([theme, 'optionalAccess',
|
|
2792
|
+
if (_optionalChain([theme, 'optionalAccess', _117 => _117.radius])) {
|
|
2189
2793
|
const scale = RADIUS_SCALE[theme.radius];
|
|
2190
2794
|
setVar(targets, "--rs-radius-sm", scale.sm);
|
|
2191
2795
|
setVar(targets, "--rs-radius-md", scale.md);
|
|
@@ -2270,4 +2874,17 @@ function checkBackendUrl(component, backendUrl) {
|
|
|
2270
2874
|
|
|
2271
2875
|
|
|
2272
2876
|
|
|
2273
|
-
|
|
2877
|
+
|
|
2878
|
+
|
|
2879
|
+
|
|
2880
|
+
|
|
2881
|
+
|
|
2882
|
+
|
|
2883
|
+
|
|
2884
|
+
|
|
2885
|
+
|
|
2886
|
+
|
|
2887
|
+
|
|
2888
|
+
|
|
2889
|
+
|
|
2890
|
+
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.catalogKeyForChain = catalogKeyForChain; 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.rpcUrlFor = rpcUrlFor; exports.RpcUrlsProvider = RpcUrlsProvider; exports.useRpcUrls = useRpcUrls; exports.useStableRpcUrls = useStableRpcUrls; exports.getPublicClient = getPublicClient; exports.peekRuntimeChains = peekRuntimeChains; exports.primeRuntimeChains = primeRuntimeChains; exports.useChainCatalog = useChainCatalog; exports.useCatalogChain = useCatalogChain; exports.useDepositChainIds = useDepositChainIds; exports.useDestinationChains = useDestinationChains; exports.useTargetTokens = useTargetTokens; exports.useIsDepositChain = useIsDepositChain; exports.useChainName = useChainName; exports.useExplorerTxUrl = useExplorerTxUrl; exports.ChainCatalogProvider = ChainCatalogProvider; exports.useLatestRef = useLatestRef; exports.Button = Button; exports.Callout = Callout; exports.TokenIcon = TokenIcon; 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.applyTheme = applyTheme; exports.checkBackendUrl = checkBackendUrl;
|