@glacislabs/stablegenie-zerodelta 4.15.1 → 4.17.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 +5 -2
- package/dist/{chunk-SKVRYU3E.js → chunk-5GVQQIGQ.js} +99 -19
- package/dist/{chunk-Z3W6DRWG.js → chunk-TIMSRHXC.js} +176 -59
- package/dist/core/index.cjs +101 -18
- package/dist/core/index.d.cts +23 -4
- package/dist/core/index.d.ts +23 -4
- package/dist/core/index.js +1 -1
- package/dist/index.cjs +279 -82
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/{mount-DRCSjQp0.d.cts → mount-BSXfSSP2.d.cts} +1 -1
- package/dist/{mount-CMsgFE6g.d.ts → mount-BdxMZC70.d.ts} +1 -1
- package/dist/mount.cjs +279 -82
- package/dist/mount.d.cts +2 -2
- package/dist/mount.d.ts +2 -2
- package/dist/mount.js +2 -2
- package/dist/standalone.global.js +10 -8
- package/dist/{verify-CoPaE02j.d.cts → verify-BBREdvIM.d.cts} +3 -0
- package/dist/{verify-CoPaE02j.d.ts → verify-BBREdvIM.d.ts} +3 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CHAIN_DISPLAY_NAMES, EXECUTABLE_STABLE_ASSETS, STABLE_ASSETS, SUPPORTED_ASSETS, complianceView, complianceTagOf, symbolKey, normalizeDecimalText, findToken, laneLimitFor, laneLimitSymbol, tokenTicker, exceedsLaneLimit, assetDecimals, parseUnitsDecimal, counterpartTokens, assetClassOf, brokenLaneFor, brokenLaneReason, destinationAvailability, laneLimitHint, tickerOn, laneLimitError, routeNativeValue, formatNative, nativeSymbol, isSolanaChainId, isSellableRwa, formatUnits, amountFieldError, solanaQuoteCompliance, directComplianceFromScreens, SUPPORTED_CHAIN_IDS, complianceChecks, DIRECT_CHECK_IDS, isSolanaAddress, createEngine, isAddress, checkNativeFee, nativeFeeShortLabel, nativeFeeShortMessage, allowanceCovers, validatePlannedTransaction, TRACKING, mergeHistory, solanaPlanNeedsPreparation, SOLANA_CHAIN_ID, unattributedComplianceReasons, distinctScreenedWallets, formatJurisdiction, humanizeComplianceReason, DIRECT_SCOPE_NOTE, categoryLabel, SCREENING_BUCKETS, BUNDLED_RPC, foldTicker } from './chunk-
|
|
1
|
+
import { CHAIN_DISPLAY_NAMES, EXECUTABLE_STABLE_ASSETS, STABLE_ASSETS, SUPPORTED_ASSETS, complianceView, complianceTagOf, symbolKey, normalizeDecimalText, findToken, laneLimitFor, laneLimitSymbol, tokenTicker, exceedsLaneLimit, assetDecimals, parseUnitsDecimal, counterpartTokens, assetClassOf, brokenLaneFor, brokenLaneReason, destinationAvailability, laneLimitHint, tickerOn, laneLimitError, routeNativeValue, formatNative, nativeSymbol, isSolanaChainId, isSellableRwa, formatUnits, amountFieldError, solanaQuoteCompliance, directComplianceFromScreens, SUPPORTED_CHAIN_IDS, complianceChecks, DIRECT_CHECK_IDS, isSolanaAddress, createEngine, isAddress, checkNativeFee, nativeFeeShortLabel, nativeFeeShortMessage, allowanceCovers, validatePlannedTransaction, TRACKING, mergeHistory, solanaPlanNeedsPreparation, SOLANA_CHAIN_ID, unattributedComplianceReasons, distinctScreenedWallets, formatJurisdiction, humanizeComplianceReason, DIRECT_SCOPE_NOTE, categoryLabel, SCREENING_BUCKETS, BUNDLED_RPC, foldTicker } from './chunk-5GVQQIGQ.js';
|
|
2
2
|
import { createContext, useState, useRef, useMemo, useEffect, useCallback, useId, useLayoutEffect, createElement, useContext, useSyncExternalStore, useReducer } from 'react';
|
|
3
3
|
import { createRoot } from 'react-dom/client';
|
|
4
4
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
@@ -496,6 +496,7 @@ function useFlow(args) {
|
|
|
496
496
|
if (busyRef.current) return;
|
|
497
497
|
setFieldError(null);
|
|
498
498
|
if (!enabled || !wallet.account) {
|
|
499
|
+
reqId.current++;
|
|
499
500
|
setStatus("idle");
|
|
500
501
|
setPlan(null);
|
|
501
502
|
return;
|
|
@@ -1089,6 +1090,8 @@ img.sg-tok-badge{width:16px;padding:0;object-fit:cover;background:var(--sg-bg)}
|
|
|
1089
1090
|
.sg-pk-body{display:flex;flex-direction:column;gap:8px}
|
|
1090
1091
|
.sg-pk-selected{display:flex;flex-direction:column;gap:8px;margin-bottom:8px}
|
|
1091
1092
|
.sg-pk-cap{margin:0;font-size:12px;line-height:1.2;color:var(--sg-text-muted)}
|
|
1093
|
+
.sg-pk-cap--section{margin-top:8px}
|
|
1094
|
+
.sg-pk-bal-missing{flex:0 0 auto;font-size:13px;line-height:1.4;color:var(--sg-text-muted);text-align:right}
|
|
1092
1095
|
.sg-pk-list{display:flex;flex-direction:column;gap:4px;max-height:320px;overflow-y:auto;margin:-1px;padding:1px;scrollbar-width:thin}
|
|
1093
1096
|
.sg-pk-row{display:flex;align-items:center;justify-content:space-between;gap:12px;width:100%;padding:16px;border:none;border-radius:24px;background:color-mix(in srgb,var(--sg-accent) 4%,transparent);color:var(--sg-text);font:inherit;text-align:left;cursor:pointer;transition:background 120ms ease}
|
|
1094
1097
|
.sg-pk-row:hover{background:color-mix(in srgb,var(--sg-accent) 8%,transparent)}
|
|
@@ -1884,6 +1887,12 @@ var SOURCE_CHAIN_LABELS = {
|
|
|
1884
1887
|
98866: "Plume"
|
|
1885
1888
|
};
|
|
1886
1889
|
var CHAIN_LABELS = { ...CHAIN_DISPLAY_NAMES, ...SOURCE_CHAIN_LABELS };
|
|
1890
|
+
function chainLabel(chainId, chain) {
|
|
1891
|
+
const pinned = SOURCE_CHAIN_LABELS[chainId];
|
|
1892
|
+
if (pinned) return pinned;
|
|
1893
|
+
const fromRegistry = typeof chain?.displayName === "string" ? chain.displayName.trim() : "";
|
|
1894
|
+
return fromRegistry || CHAIN_DISPLAY_NAMES[chainId] || `Chain ${chainId}`;
|
|
1895
|
+
}
|
|
1887
1896
|
var SUPPORTED_CHAINS = [1, 10, 42161, 8453, 57073, 130, 9745, 146, 98866];
|
|
1888
1897
|
var SUPPORTED_ASSETS2 = [
|
|
1889
1898
|
...EXECUTABLE_STABLE_ASSETS,
|
|
@@ -2419,7 +2428,7 @@ function TokenTile(props) {
|
|
|
2419
2428
|
/* @__PURE__ */ jsx(TokenGlyph, { symbol: props.pick.symbol, logoUrl: props.token?.logoUrl, chainId: props.pick.chainId, size: "tile" }),
|
|
2420
2429
|
/* @__PURE__ */ jsxs("span", { className: "sg-tile-text", children: [
|
|
2421
2430
|
/* @__PURE__ */ jsx("span", { className: "sg-tile-sym", children: shown }),
|
|
2422
|
-
/* @__PURE__ */ jsx("span", { className: "sg-tile-chain", children: CHAIN_LABELS[props.pick.chainId] || `Chain ${props.pick.chainId}` })
|
|
2431
|
+
/* @__PURE__ */ jsx("span", { className: "sg-tile-chain", children: props.chainName || CHAIN_LABELS[props.pick.chainId] || `Chain ${props.pick.chainId}` })
|
|
2423
2432
|
] })
|
|
2424
2433
|
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2425
2434
|
/* @__PURE__ */ jsx("span", { className: "sg-tok", children: /* @__PURE__ */ jsx("span", { className: "sg-tok-fb", children: "?" }) }),
|
|
@@ -2498,7 +2507,9 @@ function TickBadge() {
|
|
|
2498
2507
|
] }) });
|
|
2499
2508
|
}
|
|
2500
2509
|
function BalanceColumn(props) {
|
|
2501
|
-
if (props.amount == null)
|
|
2510
|
+
if (props.amount == null) {
|
|
2511
|
+
return props.walletMissing ? /* @__PURE__ */ jsx("span", { className: "sg-pk-bal-missing", "data-testid": "balance-wallet-missing", children: "Wallet not connected" }) : null;
|
|
2512
|
+
}
|
|
2502
2513
|
if (props.amount === 0) return /* @__PURE__ */ jsx("span", { className: "sg-pk-bal-zero", children: "0.00" });
|
|
2503
2514
|
return /* @__PURE__ */ jsxs("span", { className: "sg-pk-bal", children: [
|
|
2504
2515
|
/* @__PURE__ */ jsx("span", { className: "sg-pk-bal-usd sg-mono", children: props.usd == null ? "\u2014" : formatBalanceUsd(props.usd) }),
|
|
@@ -2551,7 +2562,7 @@ function TokenSelect(props) {
|
|
|
2551
2562
|
const listRef = useRef(null);
|
|
2552
2563
|
const savedScroll = useRef(0);
|
|
2553
2564
|
const chainById = useMemo(() => new Map(props.chains.map((c) => [Number(c.chainId), c])), [props.chains]);
|
|
2554
|
-
const chainName3 = (chainId) =>
|
|
2565
|
+
const chainName3 = (chainId) => chainLabel(chainId, chainById.get(chainId));
|
|
2555
2566
|
const showBalances = side === "from" && !!props.balances && Object.keys(props.balances).length > 0;
|
|
2556
2567
|
const [prices, setPrices] = useState({});
|
|
2557
2568
|
const symbolKey2 = useMemo(() => [...new Set(props.tokens.map((t) => String(t.symbol).toUpperCase()))].sort().join(","), [props.tokens]);
|
|
@@ -2597,6 +2608,15 @@ function TokenSelect(props) {
|
|
|
2597
2608
|
}, [props.tokens, props.balances, props.optionStates, showBalances, prices]);
|
|
2598
2609
|
const chainTerms = useMemo(() => buildChainSearchTerms(props.chains), [props.chains]);
|
|
2599
2610
|
const visible = useMemo(() => searchGroups(groups, query, chainTerms, prices), [groups, query, chainTerms, prices]);
|
|
2611
|
+
const { listed, other } = useMemo(() => {
|
|
2612
|
+
const held = [];
|
|
2613
|
+
const none = [];
|
|
2614
|
+
for (const g of visible) {
|
|
2615
|
+
const readZero = showBalances && !g.unavailable && g.deployments.length > 0 && g.deployments.every((d) => d.balance === 0);
|
|
2616
|
+
(readZero ? none : held).push(g);
|
|
2617
|
+
}
|
|
2618
|
+
return { listed: held, other: none };
|
|
2619
|
+
}, [visible, showBalances]);
|
|
2600
2620
|
const openGroup = openKey ? visible.find((g) => g.key === openKey) ?? null : null;
|
|
2601
2621
|
useEffect(() => {
|
|
2602
2622
|
if (openKey && !openGroup) setOpenKey(null);
|
|
@@ -2653,7 +2673,7 @@ function TokenSelect(props) {
|
|
|
2653
2673
|
d.hint ? /* @__PURE__ */ jsx("span", { className: "sg-pk-note", "data-testid": "lane-limit", children: d.hint }) : null
|
|
2654
2674
|
] })
|
|
2655
2675
|
] }),
|
|
2656
|
-
showBalances ? /* @__PURE__ */ jsx(BalanceColumn, { amount: d.balance, usd: usdOf(d.balance, prices, d.token.symbol), symbol: ticker }) : null
|
|
2676
|
+
showBalances ? /* @__PURE__ */ jsx(BalanceColumn, { amount: d.balance, usd: usdOf(d.balance, prices, d.token.symbol), symbol: ticker, walletMissing: props.walletMissing?.(d.token) }) : null
|
|
2657
2677
|
] }, d.key);
|
|
2658
2678
|
}) })
|
|
2659
2679
|
] });
|
|
@@ -2692,52 +2712,58 @@ function TokenSelect(props) {
|
|
|
2692
2712
|
) : null
|
|
2693
2713
|
] })
|
|
2694
2714
|
] }) : null,
|
|
2695
|
-
/* @__PURE__ */ jsx("p", { className: "sg-pk-cap", children: side === "from" ? "Your tokens \xB7 All networks" : "Popular tokens \xB7 All networks" }),
|
|
2696
|
-
/* @__PURE__ */ jsx("div", { className: "sg-pk-list", ref: listRef, role: "group", "aria-label": props.title, children: visible.length === 0 ? /* @__PURE__ */ jsx("p", { className: "sg-pk-empty", children: props.loading ? "Loading the token list\u2026" : "No tokens found." }) :
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
const blocked = !!g.unavailable;
|
|
2702
|
-
const opensNetworks = multi || blocked;
|
|
2703
|
-
const zero = showBalances && g.amount === 0 || blocked;
|
|
2704
|
-
return /* @__PURE__ */ jsxs(
|
|
2705
|
-
"button",
|
|
2706
|
-
{
|
|
2707
|
-
type: "button",
|
|
2708
|
-
className: "sg-pk-row",
|
|
2709
|
-
"data-testid": "token-row",
|
|
2710
|
-
"data-symbol": g.symbol,
|
|
2711
|
-
"data-networks": members.length,
|
|
2712
|
-
"data-zero": zero || void 0,
|
|
2713
|
-
"data-unavailable": blocked || void 0,
|
|
2714
|
-
onClick: () => {
|
|
2715
|
-
if (opensNetworks) {
|
|
2716
|
-
savedScroll.current = listRef.current?.scrollTop ?? 0;
|
|
2717
|
-
setOpenKey(g.key);
|
|
2718
|
-
} else pick(single.token);
|
|
2719
|
-
},
|
|
2720
|
-
children: [
|
|
2721
|
-
/* @__PURE__ */ jsxs("span", { className: "sg-pk-left", children: [
|
|
2722
|
-
/* @__PURE__ */ jsx(TokenPlate, { symbol: g.symbol, logoUrl: g.logoUrl }),
|
|
2723
|
-
/* @__PURE__ */ jsxs("span", { className: "sg-pk-text", children: [
|
|
2724
|
-
/* @__PURE__ */ jsx("span", { className: "sg-pk-label", children: label2 }),
|
|
2725
|
-
/* @__PURE__ */ jsxs("span", { className: "sg-pk-line", children: [
|
|
2726
|
-
/* @__PURE__ */ jsx("span", { className: "sg-pk-sub", children: multi ? showBalances ? "Total across" : "Available on" : `On ${chainName3(Number(single.token.chainId))}` }),
|
|
2727
|
-
/* @__PURE__ */ jsx(ChainMarks, { chainIds: members.map((m) => Number(m.token.chainId)), chainById, decorative: !multi }),
|
|
2728
|
-
opensNetworks && showBalances ? /* @__PURE__ */ jsx("span", { className: "sg-pk-chev sg-pk-chev--sm", "aria-hidden": "true", children: /* @__PURE__ */ jsx(ChevronGlyph, {}) }) : null
|
|
2729
|
-
] }),
|
|
2730
|
-
!multi && single.hint ? /* @__PURE__ */ jsx("span", { className: "sg-pk-note", "data-testid": "lane-limit", children: single.hint }) : null
|
|
2731
|
-
] })
|
|
2732
|
-
] }),
|
|
2733
|
-
showBalances ? /* @__PURE__ */ jsx(BalanceColumn, { amount: g.amount, usd: g.usd, symbol: label2 }) : opensNetworks ? /* @__PURE__ */ jsx("span", { className: "sg-pk-chev", "aria-hidden": "true", children: /* @__PURE__ */ jsx(ChevronGlyph, {}) }) : null
|
|
2734
|
-
]
|
|
2735
|
-
},
|
|
2736
|
-
g.key
|
|
2737
|
-
);
|
|
2738
|
-
}) })
|
|
2715
|
+
listed.length > 0 || visible.length === 0 ? /* @__PURE__ */ jsx("p", { className: "sg-pk-cap", children: side === "from" ? "Your tokens \xB7 All networks" : "Popular tokens \xB7 All networks" }) : null,
|
|
2716
|
+
/* @__PURE__ */ jsx("div", { className: "sg-pk-list", ref: listRef, role: "group", "aria-label": props.title, children: visible.length === 0 ? /* @__PURE__ */ jsx("p", { className: "sg-pk-empty", children: props.loading ? "Loading the token list\u2026" : "No tokens found." }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2717
|
+
listed.map((g) => renderRow(g, false)),
|
|
2718
|
+
other.length > 0 ? /* @__PURE__ */ jsx("p", { className: "sg-pk-cap sg-pk-cap--section", "data-testid": "other-tokens-cap", children: "Other supported tokens" }) : null,
|
|
2719
|
+
other.map((g) => renderRow(g, true))
|
|
2720
|
+
] }) })
|
|
2739
2721
|
] })
|
|
2740
2722
|
] });
|
|
2723
|
+
function renderRow(g, discovery) {
|
|
2724
|
+
const members = g.deployments;
|
|
2725
|
+
const multi = members.length > 1;
|
|
2726
|
+
const single = members[0];
|
|
2727
|
+
const label2 = multi ? g.symbol : tokenTicker(single.token);
|
|
2728
|
+
const blocked = !!g.unavailable;
|
|
2729
|
+
const opensNetworks = multi || blocked;
|
|
2730
|
+
const zero = showBalances && g.amount === 0 || blocked;
|
|
2731
|
+
return /* @__PURE__ */ jsxs(
|
|
2732
|
+
"button",
|
|
2733
|
+
{
|
|
2734
|
+
type: "button",
|
|
2735
|
+
className: "sg-pk-row",
|
|
2736
|
+
"data-testid": "token-row",
|
|
2737
|
+
"data-symbol": g.symbol,
|
|
2738
|
+
"data-networks": members.length,
|
|
2739
|
+
"data-zero": zero || void 0,
|
|
2740
|
+
"data-discovery": discovery || void 0,
|
|
2741
|
+
"data-unavailable": blocked || void 0,
|
|
2742
|
+
onClick: () => {
|
|
2743
|
+
if (opensNetworks) {
|
|
2744
|
+
savedScroll.current = listRef.current?.scrollTop ?? 0;
|
|
2745
|
+
setOpenKey(g.key);
|
|
2746
|
+
} else pick(single.token);
|
|
2747
|
+
},
|
|
2748
|
+
children: [
|
|
2749
|
+
/* @__PURE__ */ jsxs("span", { className: "sg-pk-left", children: [
|
|
2750
|
+
/* @__PURE__ */ jsx(TokenPlate, { symbol: g.symbol, logoUrl: g.logoUrl }),
|
|
2751
|
+
/* @__PURE__ */ jsxs("span", { className: "sg-pk-text", children: [
|
|
2752
|
+
/* @__PURE__ */ jsx("span", { className: "sg-pk-label", children: label2 }),
|
|
2753
|
+
/* @__PURE__ */ jsxs("span", { className: "sg-pk-line", children: [
|
|
2754
|
+
/* @__PURE__ */ jsx("span", { className: "sg-pk-sub", children: discovery ? "Available on" : multi ? showBalances ? "Total across" : "Available on" : `On ${chainName3(Number(single.token.chainId))}` }),
|
|
2755
|
+
/* @__PURE__ */ jsx(ChainMarks, { chainIds: members.map((m) => Number(m.token.chainId)), chainById, decorative: !multi && !discovery }),
|
|
2756
|
+
opensNetworks && showBalances ? /* @__PURE__ */ jsx("span", { className: "sg-pk-chev sg-pk-chev--sm", "aria-hidden": "true", children: /* @__PURE__ */ jsx(ChevronGlyph, {}) }) : null
|
|
2757
|
+
] }),
|
|
2758
|
+
!multi && single.hint ? /* @__PURE__ */ jsx("span", { className: "sg-pk-note", "data-testid": "lane-limit", children: single.hint }) : null
|
|
2759
|
+
] })
|
|
2760
|
+
] }),
|
|
2761
|
+
showBalances ? /* @__PURE__ */ jsx(BalanceColumn, { amount: g.amount, usd: g.usd, symbol: label2, walletMissing: !multi && props.walletMissing?.(single.token) }) : opensNetworks ? /* @__PURE__ */ jsx("span", { className: "sg-pk-chev", "aria-hidden": "true", children: /* @__PURE__ */ jsx(ChevronGlyph, {}) }) : null
|
|
2762
|
+
]
|
|
2763
|
+
},
|
|
2764
|
+
g.key
|
|
2765
|
+
);
|
|
2766
|
+
}
|
|
2741
2767
|
}
|
|
2742
2768
|
function ChevronRight({ size = 16 }) {
|
|
2743
2769
|
return /* @__PURE__ */ jsx("svg", { width: size, height: size, viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M6 4l4 4-4 4", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round" }) });
|
|
@@ -2814,7 +2840,7 @@ function durationLabel(seconds) {
|
|
|
2814
2840
|
}
|
|
2815
2841
|
function TokenButton(props) {
|
|
2816
2842
|
const shown = props.token ? tokenTicker(props.token) : props.symbol ?? "";
|
|
2817
|
-
const chain = props.chainId ? CHAIN_LABELS[props.chainId] || `Chain ${props.chainId}` : "";
|
|
2843
|
+
const chain = props.chainId ? props.chainName || CHAIN_LABELS[props.chainId] || `Chain ${props.chainId}` : "";
|
|
2818
2844
|
return /* @__PURE__ */ jsxs(
|
|
2819
2845
|
"button",
|
|
2820
2846
|
{
|
|
@@ -3279,7 +3305,7 @@ function CheckGlyph() {
|
|
|
3279
3305
|
function HistoryButton(props) {
|
|
3280
3306
|
return /* @__PURE__ */ jsx("button", { type: "button", ref: props.btnRef, className: "sg-hist", disabled: props.disabled, onClick: props.onClick, "aria-label": "Transaction history", title: "Transaction history", children: /* @__PURE__ */ jsx(HistoryGlyph, {}) });
|
|
3281
3307
|
}
|
|
3282
|
-
function
|
|
3308
|
+
function chainLabel2(entry) {
|
|
3283
3309
|
return entry.chainId != null && CHAIN_LABELS[entry.chainId] || entry.chainName || (entry.chainId != null ? `Chain ${entry.chainId}` : "Unknown chain");
|
|
3284
3310
|
}
|
|
3285
3311
|
function chainName(chainId, fallback) {
|
|
@@ -3412,7 +3438,7 @@ function TxHistoryList(props) {
|
|
|
3412
3438
|
/* @__PURE__ */ jsxs("span", { className: "sg-txrow-when", children: [
|
|
3413
3439
|
/* @__PURE__ */ jsxs("span", { className: "sg-txrow-what", children: [
|
|
3414
3440
|
/* @__PURE__ */ jsx("span", { children: e.kind === "payment" ? "Payment" : "Swap" }),
|
|
3415
|
-
/* @__PURE__ */ jsx("span", { children:
|
|
3441
|
+
/* @__PURE__ */ jsx("span", { children: chainLabel2(e) }),
|
|
3416
3442
|
(e.legs?.length ?? 1) > 1 ? /* @__PURE__ */ jsx("span", { children: ordersLabel(e.legs.length) }) : null
|
|
3417
3443
|
] }),
|
|
3418
3444
|
whenLabel(e.at) ? /* @__PURE__ */ jsx("span", { className: "sg-txrow-time", children: whenLabel(e.at) }) : null
|
|
@@ -3469,7 +3495,7 @@ function TxDetail(props) {
|
|
|
3469
3495
|
] }),
|
|
3470
3496
|
/* @__PURE__ */ jsxs("div", { className: "sg-meta-row", children: [
|
|
3471
3497
|
/* @__PURE__ */ jsx("span", { className: "sg-meta-label", children: "Signed on" }),
|
|
3472
|
-
/* @__PURE__ */ jsx("b", { children:
|
|
3498
|
+
/* @__PURE__ */ jsx("b", { children: chainLabel2(e) })
|
|
3473
3499
|
] }),
|
|
3474
3500
|
e.recipient ? /* @__PURE__ */ jsxs("div", { className: "sg-meta-row", children: [
|
|
3475
3501
|
/* @__PURE__ */ jsx("span", { className: "sg-meta-label", children: "Recipient" }),
|
|
@@ -6125,6 +6151,86 @@ function QuoteSheet(props) {
|
|
|
6125
6151
|
] })
|
|
6126
6152
|
] });
|
|
6127
6153
|
}
|
|
6154
|
+
|
|
6155
|
+
// src/react/ui/cost.ts
|
|
6156
|
+
function tenPow(d) {
|
|
6157
|
+
let x = 1n;
|
|
6158
|
+
for (let i = 0; i < d; i++) x *= 10n;
|
|
6159
|
+
return x;
|
|
6160
|
+
}
|
|
6161
|
+
function divRoundNearest(n, d) {
|
|
6162
|
+
if (d === 0n) return 0n;
|
|
6163
|
+
const sign = n < 0n !== d < 0n ? -1n : 1n;
|
|
6164
|
+
const an = n < 0n ? -n : n;
|
|
6165
|
+
const ad = d < 0n ? -d : d;
|
|
6166
|
+
let q = an / ad;
|
|
6167
|
+
const r = an - q * ad;
|
|
6168
|
+
if (r * 2n >= ad) q += 1n;
|
|
6169
|
+
return sign * q;
|
|
6170
|
+
}
|
|
6171
|
+
function parSpreadBps(fromAmountRaw, fromDecimals, toAmountRaw, toDecimals) {
|
|
6172
|
+
try {
|
|
6173
|
+
const from = BigInt(fromAmountRaw);
|
|
6174
|
+
const to = BigInt(toAmountRaw);
|
|
6175
|
+
if (from <= 0n) return null;
|
|
6176
|
+
const pFrom = tenPow(fromDecimals);
|
|
6177
|
+
const pTo = tenPow(toDecimals);
|
|
6178
|
+
const den = from * pTo;
|
|
6179
|
+
if (den === 0n) return null;
|
|
6180
|
+
return Number(divRoundNearest((den - to * pFrom) * 100000n, den)) / 10;
|
|
6181
|
+
} catch {
|
|
6182
|
+
return null;
|
|
6183
|
+
}
|
|
6184
|
+
}
|
|
6185
|
+
function totalCostBps(fromUsd, toUsd) {
|
|
6186
|
+
if (fromUsd == null || toUsd == null) return null;
|
|
6187
|
+
if (!Number.isFinite(fromUsd) || !Number.isFinite(toUsd) || fromUsd <= 0) return null;
|
|
6188
|
+
return (fromUsd - toUsd) / fromUsd * 1e4;
|
|
6189
|
+
}
|
|
6190
|
+
function costBasisFor(fromSymbol, toSymbol) {
|
|
6191
|
+
return assetClassOf(fromSymbol) === "stable" && assetClassOf(toSymbol) === "stable" ? "tokens" : "value";
|
|
6192
|
+
}
|
|
6193
|
+
function quoteCostBps(input) {
|
|
6194
|
+
if (!input.fromSymbol || !input.toSymbol) return null;
|
|
6195
|
+
if (costBasisFor(input.fromSymbol, input.toSymbol) === "value") {
|
|
6196
|
+
const usd = (amount, price) => price === void 0 || !amount ? null : Number(amount) * price;
|
|
6197
|
+
return totalCostBps(usd(input.send, input.fromPrice), usd(input.receive, input.toPrice));
|
|
6198
|
+
}
|
|
6199
|
+
try {
|
|
6200
|
+
if (!input.send || !input.receive) return null;
|
|
6201
|
+
return parSpreadBps(parseUnitsDecimal(input.send, 18).toString(), 18, parseUnitsDecimal(input.receive, 18).toString(), 18);
|
|
6202
|
+
} catch {
|
|
6203
|
+
return null;
|
|
6204
|
+
}
|
|
6205
|
+
}
|
|
6206
|
+
function statedCentibips(fee) {
|
|
6207
|
+
const c = fee?.zeroDeltaFeeCentibips;
|
|
6208
|
+
return typeof c === "number" && Number.isSafeInteger(c) && c >= 0 ? c : null;
|
|
6209
|
+
}
|
|
6210
|
+
function centibipsPct(centibips) {
|
|
6211
|
+
if (centibips === 0) return "0%";
|
|
6212
|
+
const whole = Math.floor(centibips / 1e4);
|
|
6213
|
+
const frac = String(centibips % 1e4).padStart(4, "0").replace(/0+$/, "").padEnd(2, "0");
|
|
6214
|
+
return `${whole}.${frac}%`;
|
|
6215
|
+
}
|
|
6216
|
+
function zeroDeltaFeeLabel(fee, native) {
|
|
6217
|
+
const centibips = statedCentibips(fee);
|
|
6218
|
+
if (centibips === null) return "--";
|
|
6219
|
+
const pct = centibipsPct(centibips);
|
|
6220
|
+
const raw = fee?.zeroDeltaFeeNative;
|
|
6221
|
+
if (typeof raw !== "string" || !/^\d+$/.test(raw) || BigInt(raw) === 0n) return pct;
|
|
6222
|
+
return `${pct} + ${formatUnits(raw, native.decimals, 8)} ${native.symbol}`;
|
|
6223
|
+
}
|
|
6224
|
+
function formatCostBps(bps) {
|
|
6225
|
+
const rounded = Number(bps.toFixed(1));
|
|
6226
|
+
const sign = rounded < 0 ? "\u2212" : "+";
|
|
6227
|
+
return `${sign}${Math.abs(rounded).toFixed(1)} bps`;
|
|
6228
|
+
}
|
|
6229
|
+
function rateImpactLabel(totalBps, fee) {
|
|
6230
|
+
if (totalBps === null) return "--";
|
|
6231
|
+
const centibips = statedCentibips(fee);
|
|
6232
|
+
return formatCostBps(totalBps - (centibips === null ? 0 : centibips / 100));
|
|
6233
|
+
}
|
|
6128
6234
|
var FIAT = [
|
|
6129
6235
|
{ code: "USD", glyph: "$", label: "US Dollar" },
|
|
6130
6236
|
{ code: "EUR", glyph: "\u20AC", label: "Euro" },
|
|
@@ -6192,6 +6298,8 @@ function ExchangeCard(props) {
|
|
|
6192
6298
|
const order = new Map(SUPPORTED_CHAINS.map((id, i) => [id, i]));
|
|
6193
6299
|
return [...catalogue?.chains ?? []].sort((a, b) => (order.get(Number(a.chainId)) ?? 99) - (order.get(Number(b.chainId)) ?? 99) || Number(a.chainId) - Number(b.chainId));
|
|
6194
6300
|
}, [catalogue]);
|
|
6301
|
+
const chainRow = useMemo(() => new Map(chains.map((c) => [Number(c.chainId), c])), [chains]);
|
|
6302
|
+
const nameOf = (id) => id ? chainLabel(id, chainRow.get(id)) : void 0;
|
|
6195
6303
|
const tokens = useMemo(() => catalogue?.tokens ?? [], [catalogue]);
|
|
6196
6304
|
const sourceTokens = useMemo(() => catalogue?.sources ?? [], [catalogue]);
|
|
6197
6305
|
const [view, setView] = useState("main");
|
|
@@ -6482,6 +6590,13 @@ function ExchangeCard(props) {
|
|
|
6482
6590
|
const complianceHasQuote = solActive ? Boolean(solFlow.plan && solFlow.status !== "quoting") : Boolean(selected && flow.status !== "loading");
|
|
6483
6591
|
const fromUsd = usdOf2(normalizedAmount, prices[from?.symbol ?? ""]);
|
|
6484
6592
|
const toUsd = usdOf2(receive, prices[to?.symbol ?? ""]);
|
|
6593
|
+
const statedFee = solActive ? solFlow.preview : addressed ? selected?.quote : preview.data;
|
|
6594
|
+
const feeNative = solActive ? { symbol: "SOL", decimals: 9 } : { symbol: nativeSymbol(from?.chainId ?? 1, chains), decimals: 18 };
|
|
6595
|
+
const feeLabel = hasQuote ? zeroDeltaFeeLabel(statedFee, feeNative) : "--";
|
|
6596
|
+
const rateImpact = hasQuote ? rateImpactLabel(
|
|
6597
|
+
quoteCostBps({ send: normalizedAmount, receive, fromSymbol: from?.symbol, toSymbol: to?.symbol, fromPrice: prices[from?.symbol ?? ""], toPrice: prices[to?.symbol ?? ""] }),
|
|
6598
|
+
statedFee
|
|
6599
|
+
) : "--";
|
|
6485
6600
|
const flippable = !rampMode && !submitting && Boolean(to && sourceTokens.some((t) => Number(t.chainId) === to.chainId && symbolKey(t.symbol) === to.symbol));
|
|
6486
6601
|
const flip = () => {
|
|
6487
6602
|
if (!flippable) return;
|
|
@@ -6572,7 +6687,8 @@ function ExchangeCard(props) {
|
|
|
6572
6687
|
{ label: "You send", value: `${normalizedAmount} ${fromTicker}` },
|
|
6573
6688
|
{ label: "You receive", value: `${receive} ${toTicker}` },
|
|
6574
6689
|
...rate ? [{ label: "Rate", value: `1 ${fromTicker} = ${rate} ${toTicker}` }] : [],
|
|
6575
|
-
{ label: "
|
|
6690
|
+
{ label: "Rate impact", value: rateImpact },
|
|
6691
|
+
{ label: "Fee", value: feeLabel },
|
|
6576
6692
|
{ label: "Network fee", value: networkFee },
|
|
6577
6693
|
...eta ? [{ label: "Estimated time", value: eta }] : []
|
|
6578
6694
|
],
|
|
@@ -6629,6 +6745,7 @@ function ExchangeCard(props) {
|
|
|
6629
6745
|
balances,
|
|
6630
6746
|
optionStates: isFrom ? void 0 : destinationStates,
|
|
6631
6747
|
loading: !catalogue?.ready,
|
|
6748
|
+
walletMissing: (t) => isSolanaChainId(t.chainId) && !solanaWallet.address,
|
|
6632
6749
|
onBack: () => closeSelector(isFrom),
|
|
6633
6750
|
onPick: (pick) => {
|
|
6634
6751
|
(isFrom ? setFrom : setTo)({ chainId: pick.chainId, symbol: symbolKey(pick.symbol) });
|
|
@@ -6681,8 +6798,8 @@ function ExchangeCard(props) {
|
|
|
6681
6798
|
] })
|
|
6682
6799
|
] });
|
|
6683
6800
|
} else {
|
|
6684
|
-
const payToken = mode === "onramp" ? /* @__PURE__ */ jsx(FiatButton, { fiat, onCurrency: setFiatCurrency, disabled: submitting }) : /* @__PURE__ */ jsx(TokenButton, { label: "You pay", symbol: from?.symbol ?? null, chainId: from?.chainId ?? null, token: fromToken, disabled: submitting, btnRef: fromTileRef, onClick: () => setView("from") });
|
|
6685
|
-
const receiveToken = mode === "offramp" ? /* @__PURE__ */ jsx(FiatButton, { fiat, onCurrency: setFiatCurrency, disabled: submitting }) : /* @__PURE__ */ jsx(TokenButton, { label: "You receive", symbol: to?.symbol ?? null, chainId: to?.chainId ?? null, token: toToken, disabled: submitting, btnRef: toTileRef, onClick: () => setView("to") });
|
|
6801
|
+
const payToken = mode === "onramp" ? /* @__PURE__ */ jsx(FiatButton, { fiat, onCurrency: setFiatCurrency, disabled: submitting }) : /* @__PURE__ */ jsx(TokenButton, { label: "You pay", symbol: from?.symbol ?? null, chainId: from?.chainId ?? null, chainName: nameOf(from?.chainId), token: fromToken, disabled: submitting, btnRef: fromTileRef, onClick: () => setView("from") });
|
|
6802
|
+
const receiveToken = mode === "offramp" ? /* @__PURE__ */ jsx(FiatButton, { fiat, onCurrency: setFiatCurrency, disabled: submitting }) : /* @__PURE__ */ jsx(TokenButton, { label: "You receive", symbol: to?.symbol ?? null, chainId: to?.chainId ?? null, chainName: nameOf(to?.chainId), token: toToken, disabled: submitting, btnRef: toTileRef, onClick: () => setView("to") });
|
|
6686
6803
|
const cta = solActive ? /* @__PURE__ */ jsxs("div", { className: "sg-cta-wrap", children: [
|
|
6687
6804
|
solanaSteps,
|
|
6688
6805
|
solanaCta,
|
|
@@ -6703,9 +6820,9 @@ function ExchangeCard(props) {
|
|
|
6703
6820
|
body = wide ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6704
6821
|
/* @__PURE__ */ jsxs("div", { className: "sg-stack", children: [
|
|
6705
6822
|
/* @__PURE__ */ jsxs("div", { className: "sg-ft", children: [
|
|
6706
|
-
mode === "onramp" ? /* @__PURE__ */ jsx(FiatTile, { label: "From", currency: fiatCurrency, onCurrency: setFiatCurrency }) : /* @__PURE__ */ jsx(TokenTile, { label: "From", pick: from, token: fromToken, disabled: submitting, btnRef: fromTileRef, onClick: () => setView("from") }),
|
|
6823
|
+
mode === "onramp" ? /* @__PURE__ */ jsx(FiatTile, { label: "From", currency: fiatCurrency, onCurrency: setFiatCurrency }) : /* @__PURE__ */ jsx(TokenTile, { label: "From", pick: from, chainName: nameOf(from?.chainId), token: fromToken, disabled: submitting, btnRef: fromTileRef, onClick: () => setView("from") }),
|
|
6707
6824
|
/* @__PURE__ */ jsx(FlipButton, { small: true, onClick: flip, disabled: !flippable }),
|
|
6708
|
-
mode === "offramp" ? /* @__PURE__ */ jsx(FiatTile, { label: "To", currency: fiatCurrency, onCurrency: setFiatCurrency }) : /* @__PURE__ */ jsx(TokenTile, { label: "To", pick: to, token: toToken, disabled: submitting, btnRef: toTileRef, onClick: () => setView("to") })
|
|
6825
|
+
mode === "offramp" ? /* @__PURE__ */ jsx(FiatTile, { label: "To", currency: fiatCurrency, onCurrency: setFiatCurrency }) : /* @__PURE__ */ jsx(TokenTile, { label: "To", pick: to, chainName: nameOf(to?.chainId), token: toToken, disabled: submitting, btnRef: toTileRef, onClick: () => setView("to") })
|
|
6709
6826
|
] }),
|
|
6710
6827
|
/* @__PURE__ */ jsxs("div", { className: "sg-pane", "data-kind": "send", children: [
|
|
6711
6828
|
/* @__PURE__ */ jsxs("div", { className: "sg-pane-top", children: [
|
|
@@ -6804,7 +6921,7 @@ function ExchangeCard(props) {
|
|
|
6804
6921
|
] }),
|
|
6805
6922
|
/* @__PURE__ */ jsxs("div", { className: "sg-recv-sub", children: [
|
|
6806
6923
|
"On ",
|
|
6807
|
-
|
|
6924
|
+
nameOf(to?.chainId) ?? `Chain ${to?.chainId}`
|
|
6808
6925
|
] })
|
|
6809
6926
|
] }),
|
|
6810
6927
|
/* @__PURE__ */ jsxs("div", { className: "sg-stack", children: [
|
package/dist/core/index.cjs
CHANGED
|
@@ -730,6 +730,7 @@ var BUNDLED_RPC = {
|
|
|
730
730
|
42161: "https://arb1.arbitrum.io/rpc",
|
|
731
731
|
98866: "https://rpc.plume.org"
|
|
732
732
|
};
|
|
733
|
+
var BUNDLED_SOLANA_RPC = ["https://solana-rpc.publicnode.com", "https://api.mainnet-beta.solana.com"];
|
|
733
734
|
var CHAIN_DISPLAY_NAMES = Object.freeze({
|
|
734
735
|
1: "Ethereum",
|
|
735
736
|
10: "Optimism",
|
|
@@ -769,7 +770,9 @@ var CHAIN_DISPLAY_NAMES = Object.freeze({
|
|
|
769
770
|
9745: "Plasma",
|
|
770
771
|
34443: "Mode",
|
|
771
772
|
42161: "Arbitrum One",
|
|
772
|
-
|
|
773
|
+
// "Avalanche", as the dApp prints it since zd-dapp#582 (from ZD Heavy's /chains). The widget's
|
|
774
|
+
// registry read lists no row for a payout-only chain, so this table is what names it here.
|
|
775
|
+
43114: "Avalanche",
|
|
773
776
|
48900: "Zircuit",
|
|
774
777
|
57073: "Ink",
|
|
775
778
|
59144: "Linea",
|
|
@@ -1776,7 +1779,7 @@ function buildPayOptions({ invoiceAsset, invoiceChainId, tokens, routes, chains,
|
|
|
1776
1779
|
if (refusal(token)) continue;
|
|
1777
1780
|
seen.add(key);
|
|
1778
1781
|
const payKey = symbolKey(token.symbol);
|
|
1779
|
-
const
|
|
1782
|
+
const direct2 = chainId === invoiceChain && payKey === invoiceKey;
|
|
1780
1783
|
options.push({
|
|
1781
1784
|
symbol: token.symbol,
|
|
1782
1785
|
symbolKey: payKey,
|
|
@@ -1789,7 +1792,7 @@ function buildPayOptions({ invoiceAsset, invoiceChainId, tokens, routes, chains,
|
|
|
1789
1792
|
logoUrl: token.logoUrl,
|
|
1790
1793
|
bridge: routeBridge.get(`${payKey}:${chainId}`) || token.bridge,
|
|
1791
1794
|
sameChain: chainId === invoiceChain,
|
|
1792
|
-
direct
|
|
1795
|
+
direct: direct2
|
|
1793
1796
|
});
|
|
1794
1797
|
}
|
|
1795
1798
|
options.sort((a, b) => {
|
|
@@ -1810,6 +1813,56 @@ function buildPayOptions({ invoiceAsset, invoiceChainId, tokens, routes, chains,
|
|
|
1810
1813
|
return options;
|
|
1811
1814
|
}
|
|
1812
1815
|
|
|
1816
|
+
// src/core/solana-rpc.ts
|
|
1817
|
+
var ATTEMPT_TIMEOUT_MS = 12e3;
|
|
1818
|
+
var REFUSAL_CODES = /* @__PURE__ */ new Set([-32005, -32029, -32052, 403, 429]);
|
|
1819
|
+
function refusesService(body) {
|
|
1820
|
+
const error = body.error;
|
|
1821
|
+
if (!error) return false;
|
|
1822
|
+
if (REFUSAL_CODES.has(error.code)) return true;
|
|
1823
|
+
return error.code === -32602 && /personal token/i.test(String(error.message ?? ""));
|
|
1824
|
+
}
|
|
1825
|
+
function unwrap(body) {
|
|
1826
|
+
if (body.error && solanaLamportShortfall(body.error.data?.logs) !== null) throw new Error(SOL_SHORTFALL_MESSAGE);
|
|
1827
|
+
if (body.error || body.result === void 0) throw new Error(String(body.error?.message || "Invalid Solana RPC response."));
|
|
1828
|
+
return body.result;
|
|
1829
|
+
}
|
|
1830
|
+
async function direct(fetchImpl, url, payload) {
|
|
1831
|
+
const controller = new AbortController();
|
|
1832
|
+
const timer = setTimeout(() => controller.abort(), ATTEMPT_TIMEOUT_MS);
|
|
1833
|
+
try {
|
|
1834
|
+
const response = await fetchImpl(url, { method: "POST", headers: { "Content-Type": "application/json" }, body: payload, signal: controller.signal });
|
|
1835
|
+
if (!response.ok) return { refused: `HTTP ${response.status}` };
|
|
1836
|
+
const body = await response.json().catch(() => null);
|
|
1837
|
+
if (!body || typeof body !== "object" || Array.isArray(body)) return { refused: "not a JSON-RPC body" };
|
|
1838
|
+
if (refusesService(body)) return { refused: `refused (${String(body.error?.code)})` };
|
|
1839
|
+
return { body };
|
|
1840
|
+
} catch (error) {
|
|
1841
|
+
return { refused: controller.signal.aborted ? "timed out" : error instanceof Error ? error.message : String(error) };
|
|
1842
|
+
} finally {
|
|
1843
|
+
clearTimeout(timer);
|
|
1844
|
+
}
|
|
1845
|
+
}
|
|
1846
|
+
function createSolanaRpc(api, fetchImpl = globalThis.fetch?.bind(globalThis), urls = BUNDLED_SOLANA_RPC) {
|
|
1847
|
+
return async (method, params) => {
|
|
1848
|
+
const payload = JSON.stringify({ jsonrpc: "2.0", id: 1, method, params });
|
|
1849
|
+
const refused = [];
|
|
1850
|
+
for (const url of urls) {
|
|
1851
|
+
const attempt = await direct(fetchImpl, url, payload);
|
|
1852
|
+
if ("body" in attempt) return unwrap(attempt.body);
|
|
1853
|
+
refused.push(`${new URL(url).host}: ${attempt.refused}`);
|
|
1854
|
+
}
|
|
1855
|
+
let relayed;
|
|
1856
|
+
try {
|
|
1857
|
+
relayed = await api.apiRequest("/solana-rpc", { method: "POST", body: payload, timeoutMs: 15e3 });
|
|
1858
|
+
} catch (error) {
|
|
1859
|
+
refused.push(`proxy: ${error instanceof Error ? error.message : String(error)}`);
|
|
1860
|
+
throw new Error(`No Solana RPC answered ${method} (${refused.join("; ")}).`);
|
|
1861
|
+
}
|
|
1862
|
+
return unwrap(relayed);
|
|
1863
|
+
};
|
|
1864
|
+
}
|
|
1865
|
+
|
|
1813
1866
|
// src/core/solana-source.ts
|
|
1814
1867
|
var CANONICAL_SOLANA_PROGRAM = "zd1E5feCJLNYaPPsBAYkCPMKGVnipYf8God9h917W33";
|
|
1815
1868
|
var MAX_ASK_OVER_FINAL_BPS = 200n;
|
|
@@ -1899,6 +1952,8 @@ function normalizePreview(request, quote, to, amount) {
|
|
|
1899
1952
|
estimatedDuration: Number(option.estimatedTimeSec || 0),
|
|
1900
1953
|
via: null,
|
|
1901
1954
|
nativeFeeRaw: String(option.gasCostSource || "0"),
|
|
1955
|
+
zeroDeltaFeeCentibips: option.zeroDeltaFeeCentibips,
|
|
1956
|
+
zeroDeltaFeeNative: option.zeroDeltaFeeNative,
|
|
1902
1957
|
quote,
|
|
1903
1958
|
option,
|
|
1904
1959
|
txData: option.txData,
|
|
@@ -1936,7 +1991,9 @@ async function previewSolanaSource(api, input) {
|
|
|
1936
1991
|
feeBps: Number(option.feeBps || 0),
|
|
1937
1992
|
estimatedDuration: Number(option.estimatedTimeSec || 0),
|
|
1938
1993
|
via: null,
|
|
1939
|
-
nativeFeeRaw: "0"
|
|
1994
|
+
nativeFeeRaw: "0",
|
|
1995
|
+
zeroDeltaFeeCentibips: option.zeroDeltaFeeCentibips,
|
|
1996
|
+
zeroDeltaFeeNative: option.zeroDeltaFeeNative
|
|
1940
1997
|
};
|
|
1941
1998
|
}
|
|
1942
1999
|
function solanaQuoteCompliance(quote) {
|
|
@@ -2055,18 +2112,6 @@ async function buildSolanaSourcePlan(api, input, quoted) {
|
|
|
2055
2112
|
});
|
|
2056
2113
|
return plan;
|
|
2057
2114
|
}
|
|
2058
|
-
function createSolanaRpc(api) {
|
|
2059
|
-
return async (method, params) => {
|
|
2060
|
-
const body = await api.apiRequest("/solana-rpc", {
|
|
2061
|
-
method: "POST",
|
|
2062
|
-
body: JSON.stringify({ jsonrpc: "2.0", id: 1, method, params }),
|
|
2063
|
-
timeoutMs: 15e3
|
|
2064
|
-
});
|
|
2065
|
-
if (body.error && solanaLamportShortfall(body.error.data?.logs) !== null) throw new Error(SOL_SHORTFALL_MESSAGE);
|
|
2066
|
-
if (body.error || body.result === void 0) throw new Error(body.error?.message || "Invalid Solana RPC response.");
|
|
2067
|
-
return body.result;
|
|
2068
|
-
};
|
|
2069
|
-
}
|
|
2070
2115
|
var SolanaSendError = class extends Error {
|
|
2071
2116
|
constructor(message, signature, sentAt) {
|
|
2072
2117
|
super(message);
|
|
@@ -2213,6 +2258,10 @@ async function readSolanaBalance(rpc, owner, mint) {
|
|
|
2213
2258
|
try {
|
|
2214
2259
|
solanaKeyBytes(owner);
|
|
2215
2260
|
solanaKeyBytes(mint);
|
|
2261
|
+
} catch {
|
|
2262
|
+
return void 0;
|
|
2263
|
+
}
|
|
2264
|
+
try {
|
|
2216
2265
|
const result = await rpc("getTokenAccountsByOwner", [owner, { mint }, { encoding: "jsonParsed", commitment: "confirmed" }]);
|
|
2217
2266
|
if (!Array.isArray(result.value)) throw new Error("Invalid token accounts.");
|
|
2218
2267
|
let total = 0n, decimals;
|
|
@@ -2223,10 +2272,30 @@ async function readSolanaBalance(rpc, owner, mint) {
|
|
|
2223
2272
|
total += BigInt(raw(amount.amount, "token balance"));
|
|
2224
2273
|
}
|
|
2225
2274
|
return total;
|
|
2275
|
+
} catch {
|
|
2276
|
+
}
|
|
2277
|
+
try {
|
|
2278
|
+
return await associatedBalance(rpc, owner, mint);
|
|
2226
2279
|
} catch {
|
|
2227
2280
|
return void 0;
|
|
2228
2281
|
}
|
|
2229
2282
|
}
|
|
2283
|
+
async function associatedBalance(rpc, owner, mint) {
|
|
2284
|
+
const programs = [TOKEN_PROGRAM, TOKEN_2022_PROGRAM];
|
|
2285
|
+
const keys = [...programs.map((p) => associatedTokenAddress(owner, mint, p)), mint];
|
|
2286
|
+
const result = await rpc("getMultipleAccounts", [keys, { encoding: "jsonParsed", commitment: "confirmed" }]);
|
|
2287
|
+
const accounts = result?.value;
|
|
2288
|
+
if (!Array.isArray(accounts) || accounts.length !== keys.length) throw new Error("Invalid token accounts.");
|
|
2289
|
+
if (!accounts[2] || !programs.includes(accounts[2].owner)) throw new Error("Not a token mint.");
|
|
2290
|
+
let total = 0n;
|
|
2291
|
+
for (const [i, account] of accounts.slice(0, 2).entries()) {
|
|
2292
|
+
if (!account) continue;
|
|
2293
|
+
const info = account.data?.parsed?.info;
|
|
2294
|
+
if (account.owner !== programs[i] || info?.mint !== mint) throw new Error("Invalid token account.");
|
|
2295
|
+
total += BigInt(raw(info?.tokenAmount?.amount, "token balance"));
|
|
2296
|
+
}
|
|
2297
|
+
return total;
|
|
2298
|
+
}
|
|
2230
2299
|
function solanaLamportShortfall(logs) {
|
|
2231
2300
|
if (!Array.isArray(logs)) return null;
|
|
2232
2301
|
for (const line of logs) {
|
|
@@ -2761,6 +2830,12 @@ function humanizeComplianceReason(raw2) {
|
|
|
2761
2830
|
}
|
|
2762
2831
|
case "blocked_jurisdiction":
|
|
2763
2832
|
return `Your region (${cleanJurisdiction(detail)}) isn't supported.`;
|
|
2833
|
+
// zd-dapp src/lib/complianceReason.ts (#588): ZD Heavy's account-country and wallet-origin rules.
|
|
2834
|
+
// Without these two the payer read the raw code ("account blocked country — IR").
|
|
2835
|
+
case "account_blocked_country":
|
|
2836
|
+
return `Your account doesn't support this region (${cleanJurisdiction(detail)}).`;
|
|
2837
|
+
case "blocked_origin_jurisdiction":
|
|
2838
|
+
return `The wallet's attributed region (${cleanJurisdiction(detail)}) isn't supported.`;
|
|
2764
2839
|
case "blocked_destination_jurisdiction":
|
|
2765
2840
|
return `The destination region (${cleanJurisdiction(detail)}) isn't supported.`;
|
|
2766
2841
|
case "jurisdiction_out_of_scope":
|
|
@@ -3455,6 +3530,8 @@ async function buildRoute({
|
|
|
3455
3530
|
quote: {
|
|
3456
3531
|
bridge: quote.bridge,
|
|
3457
3532
|
feeBps: quote.feeBps,
|
|
3533
|
+
zeroDeltaFeeCentibips: quote.zeroDeltaFeeCentibips,
|
|
3534
|
+
zeroDeltaFeeNative: quote.zeroDeltaFeeNative,
|
|
3458
3535
|
estimatedDuration: quote.estimatedDuration,
|
|
3459
3536
|
gasCostSource: quote.gasCostSource,
|
|
3460
3537
|
msgValue: valueRaw.toString(),
|
|
@@ -3475,7 +3552,7 @@ var CHANNEL_HEADER = "x-zd-channel";
|
|
|
3475
3552
|
var CHANNEL_VERSION_HEADER = "x-zd-channel-version";
|
|
3476
3553
|
var CHANNEL_ORIGIN_HEADER = "x-zd-channel-origin";
|
|
3477
3554
|
var WIDGET_CHANNEL = "widget";
|
|
3478
|
-
var WIDGET_VERSION = "4.
|
|
3555
|
+
var WIDGET_VERSION = "4.17.0" ;
|
|
3479
3556
|
var MAX_CHANNEL_VERSION_LEN = 32;
|
|
3480
3557
|
function sanitizeVersion(raw2) {
|
|
3481
3558
|
const v = String(raw2).trim();
|
|
@@ -4065,6 +4142,8 @@ async function quoteSwapPreview(api, swap, owner) {
|
|
|
4065
4142
|
return {
|
|
4066
4143
|
receive: formatUnits(final, assetDecimals(destToken)),
|
|
4067
4144
|
receiveRaw: final.toString(),
|
|
4145
|
+
zeroDeltaFeeCentibips: quote.zeroDeltaFeeCentibips,
|
|
4146
|
+
zeroDeltaFeeNative: quote.zeroDeltaFeeNative,
|
|
4068
4147
|
fromAmount: v.amountIn,
|
|
4069
4148
|
fromToken: sourceToken.symbol,
|
|
4070
4149
|
toToken: destToken.symbol,
|
|
@@ -4575,7 +4654,8 @@ function createEngine(config = {}) {
|
|
|
4575
4654
|
const resolved = resolveConfig(config);
|
|
4576
4655
|
const api = createApiClient(resolved);
|
|
4577
4656
|
const verifier = createVerifier(api, resolved.fetchImpl, resolved.rpcOverrides);
|
|
4578
|
-
const
|
|
4657
|
+
const solanaOverride = resolved.rpcOverrides[SOLANA_CHAIN_ID];
|
|
4658
|
+
const solanaRpc = createSolanaRpc(api, resolved.fetchImpl, solanaOverride && /^https?:\/\//i.test(solanaOverride) ? [solanaOverride] : BUNDLED_SOLANA_RPC);
|
|
4579
4659
|
return {
|
|
4580
4660
|
api,
|
|
4581
4661
|
verifier,
|
|
@@ -4650,6 +4730,7 @@ exports.API_CACHE_TTL_MS = API_CACHE_TTL_MS;
|
|
|
4650
4730
|
exports.BLOCK_LABEL_DEFAULT = BLOCK_LABEL_DEFAULT;
|
|
4651
4731
|
exports.BUNDLED_NATIVE_SYMBOL = BUNDLED_NATIVE_SYMBOL;
|
|
4652
4732
|
exports.BUNDLED_RPC = BUNDLED_RPC;
|
|
4733
|
+
exports.BUNDLED_SOLANA_RPC = BUNDLED_SOLANA_RPC;
|
|
4653
4734
|
exports.CANONICAL_DECIMALS = CANONICAL_DECIMALS;
|
|
4654
4735
|
exports.CANONICAL_ESCROW = CANONICAL_ESCROW;
|
|
4655
4736
|
exports.CANONICAL_INBOUND_BRIDGE = CANONICAL_INBOUND_BRIDGE;
|
|
@@ -4691,6 +4772,8 @@ exports.SUBMIT_ORDER_SELECTOR = SUBMIT_ORDER_SELECTOR;
|
|
|
4691
4772
|
exports.SUPPORTED_ASSETS = SUPPORTED_ASSETS;
|
|
4692
4773
|
exports.SUPPORTED_CHAIN_IDS = SUPPORTED_CHAIN_IDS;
|
|
4693
4774
|
exports.SolanaSendError = SolanaSendError;
|
|
4775
|
+
exports.TOKEN_2022_PROGRAM = TOKEN_2022_PROGRAM;
|
|
4776
|
+
exports.TOKEN_PROGRAM = TOKEN_PROGRAM;
|
|
4694
4777
|
exports.TRACKING = TRACKING;
|
|
4695
4778
|
exports.TRADEABLE_RWA_ASSETS = TRADEABLE_RWA_ASSETS;
|
|
4696
4779
|
exports.TUNABLE_CATEGORIES = TUNABLE_CATEGORIES;
|