@glacislabs/stablegenie-zerodelta 3.0.0 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-VL5MWEY2.js → chunk-AZPTL3KD.js} +92 -22
- package/dist/{chunk-6FPSGLRR.js → chunk-TR2XMP7X.js} +310 -56
- package/dist/core/index.cjs +92 -22
- package/dist/core/index.d.cts +11 -9
- package/dist/core/index.d.ts +11 -9
- package/dist/core/index.js +1 -1
- package/dist/index.cjs +401 -77
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/{mount-yTJi4VdA.d.ts → mount-8nchcNbL.d.ts} +1 -1
- package/dist/{mount-yqXrDBLc.d.cts → mount-BC5gY1X6.d.cts} +1 -1
- package/dist/mount.cjs +401 -77
- 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 +12 -8
- package/dist/{verify-CaO0OD4Z.d.cts → verify-DFTuQ2g3.d.cts} +9 -1
- package/dist/{verify-CaO0OD4Z.d.ts → verify-DFTuQ2g3.d.ts} +9 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { symbolKey, normalizeDecimalText, parseUnitsDecimal, SUPPORTED_CHAIN_IDS, tokenEnabled, isDeliverable, assetDecimals, findToken, formatUnits, createEngine, routeNativeValue, checkNativeFee, nativeFeeShortLabel, nativeSymbol, nativeFeeShortMessage, allowanceCovers, validatePlannedTransaction, SUPPORTED_ASSETS, BUNDLED_RPC } from './chunk-
|
|
1
|
+
import { symbolKey, normalizeDecimalText, parseUnitsDecimal, SUPPORTED_CHAIN_IDS, tokenEnabled, isDeliverable, assetDecimals, findToken, formatUnits, createEngine, routeNativeValue, checkNativeFee, nativeFeeShortLabel, nativeSymbol, nativeFeeShortMessage, allowanceCovers, validatePlannedTransaction, SUPPORTED_ASSETS, BUNDLED_RPC } from './chunk-AZPTL3KD.js';
|
|
2
2
|
import { createContext, useMemo, useState, useEffect, useRef, useCallback, useId, createElement, useContext } from 'react';
|
|
3
3
|
import { createRoot } from 'react-dom/client';
|
|
4
4
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
@@ -501,7 +501,7 @@ function useFlow(args) {
|
|
|
501
501
|
function balanceKey(chainId, tokenAddress) {
|
|
502
502
|
return `${Number(chainId)}:${String(tokenAddress || "").toLowerCase()}`;
|
|
503
503
|
}
|
|
504
|
-
function useHoldings(engine, account, routes) {
|
|
504
|
+
function useHoldings(engine, account, routes, initialBalances) {
|
|
505
505
|
const [balances, setBalances] = useState({});
|
|
506
506
|
const [loading, setLoading] = useState(false);
|
|
507
507
|
const reqId = useRef(0);
|
|
@@ -526,19 +526,32 @@ function useHoldings(engine, account, routes) {
|
|
|
526
526
|
return;
|
|
527
527
|
}
|
|
528
528
|
const id = ++reqId.current;
|
|
529
|
+
const seeded = {};
|
|
530
|
+
const missing = [];
|
|
531
|
+
for (const target of targets) {
|
|
532
|
+
const key = balanceKey(target.chainId, target.tokenAddress);
|
|
533
|
+
const balance = initialBalances?.[key];
|
|
534
|
+
if (balance) seeded[key] = balance;
|
|
535
|
+
else missing.push(target);
|
|
536
|
+
}
|
|
537
|
+
setBalances(seeded);
|
|
538
|
+
if (!missing.length) {
|
|
539
|
+
setLoading(false);
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
529
542
|
setLoading(true);
|
|
530
543
|
(async () => {
|
|
531
544
|
try {
|
|
532
|
-
const res = await engine.readBalances(account,
|
|
545
|
+
const res = await engine.readBalances(account, missing);
|
|
533
546
|
if (id !== reqId.current) return;
|
|
534
|
-
setBalances(res);
|
|
547
|
+
setBalances({ ...seeded, ...res });
|
|
535
548
|
} catch {
|
|
536
|
-
if (id === reqId.current) setBalances(
|
|
549
|
+
if (id === reqId.current) setBalances(seeded);
|
|
537
550
|
} finally {
|
|
538
551
|
if (id === reqId.current) setLoading(false);
|
|
539
552
|
}
|
|
540
553
|
})();
|
|
541
|
-
}, [engine, account, targetsKey]);
|
|
554
|
+
}, [engine, account, targetsKey, initialBalances]);
|
|
542
555
|
return { balances, loading };
|
|
543
556
|
}
|
|
544
557
|
|
|
@@ -683,6 +696,10 @@ var WIDGET_CSS = `
|
|
|
683
696
|
.sg-tile-sym{font-size:16px;font-weight:700;line-height:1.15;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
684
697
|
.sg-tile-chain{font-size:11px;color:var(--sg-text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
685
698
|
.sg-tile-empty{color:var(--sg-text-muted);font-size:15px;font-weight:600}
|
|
699
|
+
.sg-funding-glyphs{display:flex;align-items:center;flex:0 0 auto;padding-right:2px}
|
|
700
|
+
.sg-funding-glyphs .sg-tok{box-shadow:0 0 0 2px var(--sg-surface);border-radius:999px}
|
|
701
|
+
.sg-funding-glyphs .sg-tok+.sg-tok{margin-left:-8px}
|
|
702
|
+
.sg-funding-copy{display:flex;flex-direction:column;min-width:0}
|
|
686
703
|
.sg-ft-arrow{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:30px;height:30px;border-radius:999px;background:var(--sg-bg);border:1px solid var(--sg-border);display:flex;align-items:center;justify-content:center;color:var(--sg-text-muted);z-index:1;pointer-events:none}
|
|
687
704
|
|
|
688
705
|
/* token identity: logo circle + tiny chain badge, with a letters fallback */
|
|
@@ -1319,6 +1336,31 @@ function TokenTile(props) {
|
|
|
1319
1336
|
/* @__PURE__ */ jsx("span", { className: "sg-tile-main", children: glyph })
|
|
1320
1337
|
] });
|
|
1321
1338
|
}
|
|
1339
|
+
function FundingTile(props) {
|
|
1340
|
+
const symbols = props.assets.map((asset) => asset.symbol);
|
|
1341
|
+
const summary = props.loading ? "Checking wallet assets\u2026" : symbols.length ? symbols.join(", ") : "No payable balance";
|
|
1342
|
+
const detail = props.loading ? "Finding what you can pay with" : symbols.length ? `${symbols.length} wallet asset${symbols.length === 1 ? "" : "s"} available` : "Open to review funding options";
|
|
1343
|
+
const ariaLabel = `${props.label}: ${props.loading ? "checking wallet assets" : symbols.length ? symbols.join(", ") : "no payable balance"}`;
|
|
1344
|
+
const glyphs = props.loading ? /* @__PURE__ */ jsx("span", { className: "sg-tok", children: /* @__PURE__ */ jsx("span", { className: "sg-tok-fb", children: "\u2026" }) }) : symbols.length ? /* @__PURE__ */ jsx("span", { className: "sg-funding-glyphs", "aria-hidden": "true", children: props.assets.slice(0, 3).map((asset) => /* @__PURE__ */ jsx(TokenGlyph, { symbol: asset.symbol, logoUrl: asset.logoUrl, size: "sm" }, asset.symbol)) }) : /* @__PURE__ */ jsx("span", { className: "sg-tok", children: /* @__PURE__ */ jsx("span", { className: "sg-tok-fb", children: "?" }) });
|
|
1345
|
+
const main = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1346
|
+
glyphs,
|
|
1347
|
+
/* @__PURE__ */ jsxs("span", { className: "sg-funding-copy", children: [
|
|
1348
|
+
/* @__PURE__ */ jsx("span", { className: "sg-tile-sym", children: summary }),
|
|
1349
|
+
/* @__PURE__ */ jsx("span", { className: "sg-tile-chain", children: detail })
|
|
1350
|
+
] })
|
|
1351
|
+
] });
|
|
1352
|
+
if (props.row) {
|
|
1353
|
+
return /* @__PURE__ */ jsxs("button", { type: "button", ref: props.btnRef, className: "sg-tile sg-tile--row", disabled: props.disabled, onClick: props.onClick, "aria-label": ariaLabel, children: [
|
|
1354
|
+
/* @__PURE__ */ jsx("span", { className: "sg-tile-label", children: props.label }),
|
|
1355
|
+
/* @__PURE__ */ jsx("span", { className: "sg-tile-rowmain", children: main }),
|
|
1356
|
+
/* @__PURE__ */ jsx("span", { className: "sg-tile-chev", children: /* @__PURE__ */ jsx(ChevronGlyph, {}) })
|
|
1357
|
+
] });
|
|
1358
|
+
}
|
|
1359
|
+
return /* @__PURE__ */ jsxs("button", { type: "button", ref: props.btnRef, className: "sg-tile", disabled: props.disabled, onClick: props.onClick, "aria-label": ariaLabel, children: [
|
|
1360
|
+
/* @__PURE__ */ jsx("span", { className: "sg-tile-label", children: props.label }),
|
|
1361
|
+
/* @__PURE__ */ jsx("span", { className: "sg-tile-main", children: main })
|
|
1362
|
+
] });
|
|
1363
|
+
}
|
|
1322
1364
|
function ChainChip(props) {
|
|
1323
1365
|
const [broken, setBroken] = useState(false);
|
|
1324
1366
|
const logo = props.chain?.logoUrl;
|
|
@@ -1648,7 +1690,21 @@ var addrEq = (a, b) => String(a || "").toLowerCase() === String(b || "").toLower
|
|
|
1648
1690
|
var chainName = (id) => id != null ? CHAIN_LABELS[id] || `Chain ${id}` : "";
|
|
1649
1691
|
var STABLES = /* @__PURE__ */ new Set(["USDC", "USDT", "USDE"]);
|
|
1650
1692
|
function BankGlyph() {
|
|
1651
|
-
return /* @__PURE__ */ jsx(
|
|
1693
|
+
return /* @__PURE__ */ jsx(
|
|
1694
|
+
"svg",
|
|
1695
|
+
{
|
|
1696
|
+
width: "18",
|
|
1697
|
+
height: "18",
|
|
1698
|
+
viewBox: "0 0 24 24",
|
|
1699
|
+
fill: "none",
|
|
1700
|
+
stroke: "currentColor",
|
|
1701
|
+
strokeWidth: "2",
|
|
1702
|
+
strokeLinecap: "round",
|
|
1703
|
+
strokeLinejoin: "round",
|
|
1704
|
+
"aria-hidden": "true",
|
|
1705
|
+
children: /* @__PURE__ */ jsx("path", { d: "M3 10h18M5 10v8M10 10v8M14 10v8M19 10v8M3 19h18M12 3 3 8h18Z" })
|
|
1706
|
+
}
|
|
1707
|
+
);
|
|
1652
1708
|
}
|
|
1653
1709
|
function MerchantBankPayout(props) {
|
|
1654
1710
|
const bankName = props.account?.bankName?.trim() || "Bank account";
|
|
@@ -1675,25 +1731,81 @@ function MerchantBankPayout(props) {
|
|
|
1675
1731
|
] }) }) });
|
|
1676
1732
|
}
|
|
1677
1733
|
function CheckGlyph2() {
|
|
1678
|
-
return /* @__PURE__ */ jsx(
|
|
1734
|
+
return /* @__PURE__ */ jsx(
|
|
1735
|
+
"svg",
|
|
1736
|
+
{
|
|
1737
|
+
width: "20",
|
|
1738
|
+
height: "20",
|
|
1739
|
+
viewBox: "0 0 24 24",
|
|
1740
|
+
fill: "none",
|
|
1741
|
+
stroke: "currentColor",
|
|
1742
|
+
strokeWidth: "3",
|
|
1743
|
+
strokeLinecap: "round",
|
|
1744
|
+
strokeLinejoin: "round",
|
|
1745
|
+
"aria-hidden": "true",
|
|
1746
|
+
children: /* @__PURE__ */ jsx("path", { d: "M20 6 9 17l-5-5" })
|
|
1747
|
+
}
|
|
1748
|
+
);
|
|
1679
1749
|
}
|
|
1680
1750
|
function ArrowGlyph() {
|
|
1681
|
-
return /* @__PURE__ */ jsxs(
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1751
|
+
return /* @__PURE__ */ jsxs(
|
|
1752
|
+
"svg",
|
|
1753
|
+
{
|
|
1754
|
+
width: "14",
|
|
1755
|
+
height: "14",
|
|
1756
|
+
viewBox: "0 0 24 24",
|
|
1757
|
+
fill: "none",
|
|
1758
|
+
stroke: "currentColor",
|
|
1759
|
+
strokeWidth: "2.4",
|
|
1760
|
+
strokeLinecap: "round",
|
|
1761
|
+
strokeLinejoin: "round",
|
|
1762
|
+
"aria-hidden": "true",
|
|
1763
|
+
children: [
|
|
1764
|
+
/* @__PURE__ */ jsx("path", { d: "M5 12h14" }),
|
|
1765
|
+
/* @__PURE__ */ jsx("path", { d: "m13 6 6 6-6 6" })
|
|
1766
|
+
]
|
|
1767
|
+
}
|
|
1768
|
+
);
|
|
1685
1769
|
}
|
|
1686
1770
|
function ClockGlyph() {
|
|
1687
|
-
return /* @__PURE__ */ jsxs(
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1771
|
+
return /* @__PURE__ */ jsxs(
|
|
1772
|
+
"svg",
|
|
1773
|
+
{
|
|
1774
|
+
width: "20",
|
|
1775
|
+
height: "20",
|
|
1776
|
+
viewBox: "0 0 24 24",
|
|
1777
|
+
fill: "none",
|
|
1778
|
+
stroke: "currentColor",
|
|
1779
|
+
strokeWidth: "2.2",
|
|
1780
|
+
strokeLinecap: "round",
|
|
1781
|
+
strokeLinejoin: "round",
|
|
1782
|
+
"aria-hidden": "true",
|
|
1783
|
+
children: [
|
|
1784
|
+
/* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "9" }),
|
|
1785
|
+
/* @__PURE__ */ jsx("path", { d: "M12 7v5l3 2" })
|
|
1786
|
+
]
|
|
1787
|
+
}
|
|
1788
|
+
);
|
|
1691
1789
|
}
|
|
1692
1790
|
function WalletGlyph() {
|
|
1693
|
-
return /* @__PURE__ */ jsxs(
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1791
|
+
return /* @__PURE__ */ jsxs(
|
|
1792
|
+
"svg",
|
|
1793
|
+
{
|
|
1794
|
+
width: "16",
|
|
1795
|
+
height: "16",
|
|
1796
|
+
viewBox: "0 0 24 24",
|
|
1797
|
+
fill: "none",
|
|
1798
|
+
stroke: "currentColor",
|
|
1799
|
+
strokeWidth: "2",
|
|
1800
|
+
strokeLinecap: "round",
|
|
1801
|
+
strokeLinejoin: "round",
|
|
1802
|
+
"aria-hidden": "true",
|
|
1803
|
+
children: [
|
|
1804
|
+
/* @__PURE__ */ jsx("rect", { x: "3", y: "6", width: "18", height: "13", rx: "2" }),
|
|
1805
|
+
/* @__PURE__ */ jsx("path", { d: "M16 12h.01M3 9h18" })
|
|
1806
|
+
]
|
|
1807
|
+
}
|
|
1808
|
+
);
|
|
1697
1809
|
}
|
|
1698
1810
|
function LinkMenu(props) {
|
|
1699
1811
|
const [open, setOpen] = useState(false);
|
|
@@ -1804,7 +1916,13 @@ function IdentityLine(props) {
|
|
|
1804
1916
|
function PaymentIsland(props) {
|
|
1805
1917
|
injectStyles();
|
|
1806
1918
|
const config = useMergedConfig(props);
|
|
1807
|
-
const engine = useEngine({
|
|
1919
|
+
const engine = useEngine({
|
|
1920
|
+
apiBase: config.apiBase,
|
|
1921
|
+
apiKey: config.apiKey,
|
|
1922
|
+
trustedApiOrigin: config.trustedApiOrigin,
|
|
1923
|
+
rpcOverrides: config.rpcOverrides,
|
|
1924
|
+
onTransaction: config.onTransaction
|
|
1925
|
+
});
|
|
1808
1926
|
const wallet = useWallet(config.provider);
|
|
1809
1927
|
const kind = props.kind;
|
|
1810
1928
|
const isPay = kind === "pay";
|
|
@@ -1833,7 +1951,8 @@ function PaymentIsland(props) {
|
|
|
1833
1951
|
const normEx = normalizeDecimalText(exAmount);
|
|
1834
1952
|
const exAmountValid = /^\d+(\.\d+)?$/.test(normEx) && Number(normEx) > 0 && Number(normEx) <= 1e9;
|
|
1835
1953
|
const exQuotable = !rampMode && exAmountValid && Boolean(exFromChainId && exFromAsset && exToChainId && exToAsset);
|
|
1836
|
-
const
|
|
1954
|
+
const payFundingAssets = props.fundingAssets?.length ? props.fundingAssets : ["USDC", "USDT", "USDE"];
|
|
1955
|
+
const payParamsKey = `pay|${props.recipient}|${props.toChainId}|${props.toAsset}|${props.amount}|${payFundingAssets.join(",")}`;
|
|
1837
1956
|
const exParamsKey = `${kind}|${mode}|${exFromChainId}|${exFromAsset}|${exToChainId}|${exToAsset}|${normEx}|${props.recipient ?? ""}`;
|
|
1838
1957
|
const flow = useFlow({
|
|
1839
1958
|
engine,
|
|
@@ -1843,7 +1962,20 @@ function PaymentIsland(props) {
|
|
|
1843
1962
|
// quote (and fire onQuote) for a payment whose CTA it never shows.
|
|
1844
1963
|
enabled: isPay ? Boolean(props.recipient && props.amount) && !bankSettlement : exQuotable,
|
|
1845
1964
|
paramsKey: isPay ? payParamsKey : exParamsKey,
|
|
1846
|
-
loadPlan: isPay ? (e, payer, chainId) => e.fetchPaymentPlan({ address: props.recipient, chainId: props.toChainId, asset: props.toAsset, amount: props.amount }, payer, {
|
|
1965
|
+
loadPlan: isPay ? (e, payer, chainId) => e.fetchPaymentPlan({ address: props.recipient, chainId: props.toChainId, asset: props.toAsset, amount: props.amount }, payer, {
|
|
1966
|
+
chainId,
|
|
1967
|
+
fundingAssets: payFundingAssets
|
|
1968
|
+
}) : (e, payer) => e.buildSwapPlan(
|
|
1969
|
+
{
|
|
1970
|
+
fromChainId: exFromChainId,
|
|
1971
|
+
toChainId: exToChainId,
|
|
1972
|
+
fromToken: exFromAsset,
|
|
1973
|
+
toToken: exToAsset,
|
|
1974
|
+
amountIn: normEx,
|
|
1975
|
+
recipient: props.recipient
|
|
1976
|
+
},
|
|
1977
|
+
payer
|
|
1978
|
+
),
|
|
1847
1979
|
recipientFor: (account) => isPay ? props.recipient : props.recipient || account,
|
|
1848
1980
|
onQuote: config.onQuote,
|
|
1849
1981
|
onSuccess: config.onSuccess,
|
|
@@ -1851,15 +1983,14 @@ function PaymentIsland(props) {
|
|
|
1851
1983
|
});
|
|
1852
1984
|
const [method, setMethod] = useState("stablecoin");
|
|
1853
1985
|
const parked = isPay && !isLiveMethod(method);
|
|
1854
|
-
const fundingSet = useMemo(
|
|
1855
|
-
() => props.fundingAssets?.length ? new Set(props.fundingAssets.map((a) => a.toUpperCase())) : null,
|
|
1856
|
-
[props.fundingAssets]
|
|
1857
|
-
);
|
|
1986
|
+
const fundingSet = useMemo(() => props.fundingAssets?.length ? new Set(props.fundingAssets.map((a) => a.toUpperCase())) : null, [props.fundingAssets]);
|
|
1858
1987
|
const visibleRoutes = useMemo(() => {
|
|
1859
1988
|
const base = fundingSet ? flow.routes.filter((r) => fundingSet.has(r.source.asset.toUpperCase()) || r.state === "DIRECT") : flow.routes;
|
|
1860
|
-
return isPay && method === "stablecoin" ? base.filter((r) => STABLES.has(r.source.asset)) : base;
|
|
1989
|
+
return isPay && method === "stablecoin" ? base.filter((r) => STABLES.has(symbolKey(r.source.asset))) : base;
|
|
1861
1990
|
}, [flow.routes, fundingSet, isPay, method]);
|
|
1862
|
-
const
|
|
1991
|
+
const paymentPlan = flow.plan;
|
|
1992
|
+
const prefetchedBalances = paymentPlan && paymentPlan.fundingAccount === wallet.account?.toLowerCase() ? paymentPlan.fundingBalances : void 0;
|
|
1993
|
+
const holdings = useHoldings(engine, wallet.account, flow.routes, prefetchedBalances);
|
|
1863
1994
|
const annotated = useMemo(
|
|
1864
1995
|
() => visibleRoutes.map((r) => {
|
|
1865
1996
|
const balance = holdings.balances[balanceKey(r.source.chainId, r.source.tokenAddress)];
|
|
@@ -1954,7 +2085,15 @@ function PaymentIsland(props) {
|
|
|
1954
2085
|
if (seen.has(key)) continue;
|
|
1955
2086
|
seen.add(key);
|
|
1956
2087
|
const reg = registryTokens.find((t) => Number(t.chainId) === r.source.chainId && addrEq(t.address, r.source.tokenAddress));
|
|
1957
|
-
list.push(
|
|
2088
|
+
list.push(
|
|
2089
|
+
reg ?? {
|
|
2090
|
+
symbol: r.source.asset,
|
|
2091
|
+
name: r.source.asset,
|
|
2092
|
+
chainId: r.source.chainId,
|
|
2093
|
+
address: r.source.tokenAddress ?? "",
|
|
2094
|
+
decimals: r.source.decimals ?? 18
|
|
2095
|
+
}
|
|
2096
|
+
);
|
|
1958
2097
|
}
|
|
1959
2098
|
return list;
|
|
1960
2099
|
}, [visibleRoutes, registryTokens]);
|
|
@@ -1962,6 +2101,18 @@ function PaymentIsland(props) {
|
|
|
1962
2101
|
const ids = new Set(fundingTokens.map((t) => Number(t.chainId)));
|
|
1963
2102
|
return chains.filter((c) => ids.has(Number(c.chainId)));
|
|
1964
2103
|
}, [chains, fundingTokens]);
|
|
2104
|
+
const payableAssets = useMemo(() => {
|
|
2105
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2106
|
+
const list = [];
|
|
2107
|
+
for (const { route } of held) {
|
|
2108
|
+
const symbol = symbolKey(route.source.asset);
|
|
2109
|
+
if (seen.has(symbol)) continue;
|
|
2110
|
+
seen.add(symbol);
|
|
2111
|
+
const token = registryTokens.find((t) => Number(t.chainId) === route.source.chainId && addrEq(t.address, route.source.tokenAddress));
|
|
2112
|
+
list.push({ symbol: route.source.asset, logoUrl: token?.logoUrl });
|
|
2113
|
+
}
|
|
2114
|
+
return list;
|
|
2115
|
+
}, [held, registryTokens]);
|
|
1965
2116
|
const userPicked = useRef(false);
|
|
1966
2117
|
const selectRoute = useCallback(
|
|
1967
2118
|
(id) => {
|
|
@@ -2064,8 +2215,6 @@ function PaymentIsland(props) {
|
|
|
2064
2215
|
const submitting = flow.status === "submitting";
|
|
2065
2216
|
const sel = flow.selected;
|
|
2066
2217
|
const selectedVisible = Boolean(sel && visibleRoutes.some((r) => r.id === sel.id));
|
|
2067
|
-
const selPick = sel && selectedVisible ? { chainId: sel.source.chainId, symbol: sel.source.asset } : null;
|
|
2068
|
-
const selToken = sel ? registryTokens.find((t) => Number(t.chainId) === sel.source.chainId && addrEq(t.address, sel.source.tokenAddress)) ?? null : null;
|
|
2069
2218
|
const selBal = sel ? holdings.balances[balanceKey(sel.source.chainId, sel.source.tokenAddress)] : void 0;
|
|
2070
2219
|
const lastTxOwned = Boolean(flow.lastTxEntry?.hash && wallet.account && flow.lastTxEntry.account === wallet.account.toLowerCase());
|
|
2071
2220
|
const mismatch = flow.status === "error" && flow.verdict?.status === "mismatch";
|
|
@@ -2154,7 +2303,18 @@ function PaymentIsland(props) {
|
|
|
2154
2303
|
if (hist && wallet.account) {
|
|
2155
2304
|
body = /* @__PURE__ */ jsx(TxHistoryPanel, { account: wallet.account, tokens: registryTokens, initialEntry: hist.entry ?? null, onBack: closeHistory });
|
|
2156
2305
|
} else if (isPay && view === "select" && wallet.account) {
|
|
2157
|
-
body = /* @__PURE__ */ jsx(
|
|
2306
|
+
body = /* @__PURE__ */ jsx(
|
|
2307
|
+
TokenSelect,
|
|
2308
|
+
{
|
|
2309
|
+
title: "Pay with",
|
|
2310
|
+
chains: fundingChains,
|
|
2311
|
+
tokens: fundingTokens,
|
|
2312
|
+
balances: holdings.balances,
|
|
2313
|
+
optionStates,
|
|
2314
|
+
onBack: () => closeSelector(),
|
|
2315
|
+
onPick: pickFunding
|
|
2316
|
+
}
|
|
2317
|
+
);
|
|
2158
2318
|
} else if (!isPay && (view === "from" || view === "to")) {
|
|
2159
2319
|
const isFrom = view === "from";
|
|
2160
2320
|
const openerRef = isFrom ? exFromTileRef : exToTileRef;
|
|
@@ -2289,7 +2449,18 @@ function PaymentIsland(props) {
|
|
|
2289
2449
|
/* @__PURE__ */ jsx("div", { className: "sg-cta-wrap", children: /* @__PURE__ */ jsx(Button, { disabled: true, children: method === "card" ? "Card \u2014 coming soon" : "Bank \u2014 coming soon" }) })
|
|
2290
2450
|
] })
|
|
2291
2451
|
) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2292
|
-
isPay ? /* @__PURE__ */ jsx("div", { style: { marginTop: 12 }, children: /* @__PURE__ */ jsx(
|
|
2452
|
+
isPay ? /* @__PURE__ */ jsx("div", { style: { marginTop: 12 }, children: /* @__PURE__ */ jsx(
|
|
2453
|
+
FundingTile,
|
|
2454
|
+
{
|
|
2455
|
+
row: true,
|
|
2456
|
+
label: "Pay with",
|
|
2457
|
+
assets: payableAssets,
|
|
2458
|
+
loading: flow.status === "loading" || holdings.loading,
|
|
2459
|
+
disabled: submitting || !visibleRoutes.length,
|
|
2460
|
+
btnRef: methodRowRef,
|
|
2461
|
+
onClick: () => setView("select")
|
|
2462
|
+
}
|
|
2463
|
+
) }) : null,
|
|
2293
2464
|
loading ? /* @__PURE__ */ jsxs("div", { className: "sg-panel", style: { marginTop: 12 }, children: [
|
|
2294
2465
|
/* @__PURE__ */ jsx("div", { className: "sg-skel" }),
|
|
2295
2466
|
/* @__PURE__ */ jsxs("div", { className: "sg-muted", style: { fontSize: 13 }, children: [
|
|
@@ -2343,22 +2514,66 @@ function PaymentIsland(props) {
|
|
|
2343
2514
|
const islandVars = themeToVars(resolved);
|
|
2344
2515
|
return /* @__PURE__ */ jsx("div", { className: "sg-island-wrap", children: /* @__PURE__ */ jsxs("div", { className: "sg-island", "data-sg-mode": resolved.mode, "data-expanded": expanded, "data-status": flow.status, style: islandVars, children: [
|
|
2345
2516
|
pillFace,
|
|
2346
|
-
/* @__PURE__ */ jsx("div", { className: "sg-island-reveal", children: /* @__PURE__ */ jsx("div", { className: "sg-island-reveal-inner", children: /* @__PURE__ */ jsx(
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2517
|
+
/* @__PURE__ */ jsx("div", { className: "sg-island-reveal", children: /* @__PURE__ */ jsx("div", { className: "sg-island-reveal-inner", children: /* @__PURE__ */ jsx(
|
|
2518
|
+
"div",
|
|
2519
|
+
{
|
|
2520
|
+
className: "sg-island-body",
|
|
2521
|
+
id: panelId,
|
|
2522
|
+
ref: regionRef,
|
|
2523
|
+
role: "region",
|
|
2524
|
+
"aria-label": isPay ? "ZeroDelta Link checkout" : `ZeroDelta Link ${verb.present.toLowerCase()}`,
|
|
2525
|
+
tabIndex: -1,
|
|
2526
|
+
children: expanded ? /* @__PURE__ */ jsxs(
|
|
2527
|
+
WidgetShell,
|
|
2528
|
+
{
|
|
2529
|
+
variant: "express",
|
|
2530
|
+
title: "ZeroDelta Link",
|
|
2531
|
+
theme: config.theme,
|
|
2532
|
+
heightPx: props.heightPx,
|
|
2533
|
+
brandSlot,
|
|
2534
|
+
walletSlot,
|
|
2535
|
+
children: [
|
|
2536
|
+
/* @__PURE__ */ jsx("span", { className: "sg-sr-only", role: "status", "aria-live": "polite", children: liveMsg }),
|
|
2537
|
+
body
|
|
2538
|
+
]
|
|
2539
|
+
}
|
|
2540
|
+
) : null
|
|
2541
|
+
}
|
|
2542
|
+
) }) })
|
|
2350
2543
|
] }) });
|
|
2351
2544
|
}
|
|
2352
2545
|
var STABLES2 = /* @__PURE__ */ new Set(["USDC", "USDT", "USDE"]);
|
|
2546
|
+
var DEFAULT_FUNDING_ASSETS = ["USDC", "USDT", "USDE"];
|
|
2353
2547
|
function CheckGlyph3() {
|
|
2354
|
-
return /* @__PURE__ */ jsx(
|
|
2548
|
+
return /* @__PURE__ */ jsx(
|
|
2549
|
+
"svg",
|
|
2550
|
+
{
|
|
2551
|
+
width: "20",
|
|
2552
|
+
height: "20",
|
|
2553
|
+
viewBox: "0 0 24 24",
|
|
2554
|
+
fill: "none",
|
|
2555
|
+
stroke: "currentColor",
|
|
2556
|
+
strokeWidth: "3",
|
|
2557
|
+
strokeLinecap: "round",
|
|
2558
|
+
strokeLinejoin: "round",
|
|
2559
|
+
"aria-hidden": "true",
|
|
2560
|
+
children: /* @__PURE__ */ jsx("path", { d: "M20 6 9 17l-5-5" })
|
|
2561
|
+
}
|
|
2562
|
+
);
|
|
2355
2563
|
}
|
|
2356
2564
|
var addrEq2 = (a, b) => String(a || "").toLowerCase() === String(b || "").toLowerCase();
|
|
2357
2565
|
function StableGeniePay(props) {
|
|
2358
2566
|
const config = useMergedConfig(props);
|
|
2359
|
-
const engine = useEngine({
|
|
2567
|
+
const engine = useEngine({
|
|
2568
|
+
apiBase: config.apiBase,
|
|
2569
|
+
apiKey: config.apiKey,
|
|
2570
|
+
trustedApiOrigin: config.trustedApiOrigin,
|
|
2571
|
+
rpcOverrides: config.rpcOverrides,
|
|
2572
|
+
onTransaction: config.onTransaction
|
|
2573
|
+
});
|
|
2360
2574
|
const wallet = useWallet(config.provider);
|
|
2361
|
-
const
|
|
2575
|
+
const planFundingAssets = props.fundingAssets?.length ? props.fundingAssets : DEFAULT_FUNDING_ASSETS;
|
|
2576
|
+
const paramsKey = `${props.recipient}|${props.toChainId}|${props.toAsset}|${props.amount}|${planFundingAssets.join(",")}`;
|
|
2362
2577
|
const flow = useFlow({
|
|
2363
2578
|
engine,
|
|
2364
2579
|
wallet,
|
|
@@ -2367,22 +2582,24 @@ function StableGeniePay(props) {
|
|
|
2367
2582
|
// network work here, or every quote / balance read fires twice and onQuote/onError double-fire.
|
|
2368
2583
|
enabled: Boolean(props.recipient && props.amount) && props.variant !== "pill",
|
|
2369
2584
|
paramsKey,
|
|
2370
|
-
loadPlan: (e, payer, chainId) => e.fetchPaymentPlan({ address: props.recipient, chainId: props.toChainId, asset: props.toAsset, amount: props.amount }, payer, {
|
|
2585
|
+
loadPlan: (e, payer, chainId) => e.fetchPaymentPlan({ address: props.recipient, chainId: props.toChainId, asset: props.toAsset, amount: props.amount }, payer, {
|
|
2586
|
+
chainId,
|
|
2587
|
+
fundingAssets: planFundingAssets
|
|
2588
|
+
}),
|
|
2371
2589
|
recipientFor: () => props.recipient,
|
|
2372
2590
|
onQuote: config.onQuote,
|
|
2373
2591
|
onSuccess: config.onSuccess,
|
|
2374
2592
|
onError: config.onError
|
|
2375
2593
|
});
|
|
2376
2594
|
const [method, setMethod] = useState("stablecoin");
|
|
2377
|
-
const fundingSet = useMemo(
|
|
2378
|
-
() => props.fundingAssets?.length ? new Set(props.fundingAssets.map((a) => a.toUpperCase())) : null,
|
|
2379
|
-
[props.fundingAssets]
|
|
2380
|
-
);
|
|
2595
|
+
const fundingSet = useMemo(() => props.fundingAssets?.length ? new Set(props.fundingAssets.map((a) => a.toUpperCase())) : null, [props.fundingAssets]);
|
|
2381
2596
|
const visibleRoutes = useMemo(() => {
|
|
2382
2597
|
const base = fundingSet ? flow.routes.filter((r) => fundingSet.has(r.source.asset.toUpperCase()) || r.state === "DIRECT") : flow.routes;
|
|
2383
|
-
return method === "stablecoin" ? base.filter((r) => STABLES2.has(r.source.asset)) : base;
|
|
2598
|
+
return method === "stablecoin" ? base.filter((r) => STABLES2.has(symbolKey(r.source.asset))) : base;
|
|
2384
2599
|
}, [flow.routes, method, fundingSet]);
|
|
2385
|
-
const
|
|
2600
|
+
const paymentPlan = flow.plan;
|
|
2601
|
+
const prefetchedBalances = paymentPlan && paymentPlan.fundingAccount === wallet.account?.toLowerCase() ? paymentPlan.fundingBalances : void 0;
|
|
2602
|
+
const holdings = useHoldings(engine, wallet.account, flow.routes, prefetchedBalances);
|
|
2386
2603
|
const annotated = useMemo(
|
|
2387
2604
|
() => visibleRoutes.map((r) => {
|
|
2388
2605
|
const balance = holdings.balances[balanceKey(r.source.chainId, r.source.tokenAddress)];
|
|
@@ -2456,7 +2673,15 @@ function StableGeniePay(props) {
|
|
|
2456
2673
|
if (seen.has(key)) continue;
|
|
2457
2674
|
seen.add(key);
|
|
2458
2675
|
const reg = registryTokens.find((t) => Number(t.chainId) === r.source.chainId && addrEq2(t.address, r.source.tokenAddress));
|
|
2459
|
-
list.push(
|
|
2676
|
+
list.push(
|
|
2677
|
+
reg ?? {
|
|
2678
|
+
symbol: r.source.asset,
|
|
2679
|
+
name: r.source.asset,
|
|
2680
|
+
chainId: r.source.chainId,
|
|
2681
|
+
address: r.source.tokenAddress ?? "",
|
|
2682
|
+
decimals: r.source.decimals ?? 18
|
|
2683
|
+
}
|
|
2684
|
+
);
|
|
2460
2685
|
}
|
|
2461
2686
|
return list;
|
|
2462
2687
|
}, [visibleRoutes, registryTokens]);
|
|
@@ -2464,6 +2689,18 @@ function StableGeniePay(props) {
|
|
|
2464
2689
|
const ids = new Set(fundingTokens.map((t) => Number(t.chainId)));
|
|
2465
2690
|
return chains.filter((c) => ids.has(Number(c.chainId)));
|
|
2466
2691
|
}, [chains, fundingTokens]);
|
|
2692
|
+
const payableAssets = useMemo(() => {
|
|
2693
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2694
|
+
const list = [];
|
|
2695
|
+
for (const { route } of held) {
|
|
2696
|
+
const symbol = symbolKey(route.source.asset);
|
|
2697
|
+
if (seen.has(symbol)) continue;
|
|
2698
|
+
seen.add(symbol);
|
|
2699
|
+
const token = registryTokens.find((t) => Number(t.chainId) === route.source.chainId && addrEq2(t.address, route.source.tokenAddress));
|
|
2700
|
+
list.push({ symbol: route.source.asset, logoUrl: token?.logoUrl });
|
|
2701
|
+
}
|
|
2702
|
+
return list;
|
|
2703
|
+
}, [held, registryTokens]);
|
|
2467
2704
|
const userPicked = useRef(false);
|
|
2468
2705
|
const selectRoute = useCallback(
|
|
2469
2706
|
(id) => {
|
|
@@ -2511,8 +2748,6 @@ function StableGeniePay(props) {
|
|
|
2511
2748
|
const submitting = flow.status === "submitting";
|
|
2512
2749
|
const sel = flow.selected;
|
|
2513
2750
|
const selectedVisible = Boolean(sel && visibleRoutes.some((r) => r.id === sel.id));
|
|
2514
|
-
const selPick = sel && selectedVisible ? { chainId: sel.source.chainId, symbol: sel.source.asset } : null;
|
|
2515
|
-
const selToken = sel ? registryTokens.find((t) => Number(t.chainId) === sel.source.chainId && addrEq2(t.address, sel.source.tokenAddress)) ?? null : null;
|
|
2516
2751
|
const selBal = sel ? holdings.balances[balanceKey(sel.source.chainId, sel.source.tokenAddress)] : void 0;
|
|
2517
2752
|
const why = parked ? "" : sel && selectedVisible ? sel.state === "DIRECT" ? `Direct ${sel.source.asset} transfer on ${CHAIN_LABELS[sel.source.chainId] || sel.source.chainName} \xB7 lowest cost` : (
|
|
2518
2753
|
// Deliberately does NOT restate the destination amount — that is merchant config, not a payer fact.
|
|
@@ -2528,7 +2763,18 @@ function StableGeniePay(props) {
|
|
|
2528
2763
|
] })
|
|
2529
2764
|
] }) : void 0;
|
|
2530
2765
|
if (props.variant === "pill") return /* @__PURE__ */ jsx(PaymentIsland, { kind: "pay", ...props });
|
|
2531
|
-
return /* @__PURE__ */ jsx(WidgetShell, { title: config.title || "Complete payment", theme: config.theme, heightPx: props.heightPx, walletSlot, children: hist && wallet.account ? /* @__PURE__ */ jsx(TxHistoryPanel, { account: wallet.account, tokens: registryTokens, initialEntry: hist.entry ?? null, onBack: closeHistory }) : view === "select" && wallet.account ? /* @__PURE__ */ jsx(
|
|
2766
|
+
return /* @__PURE__ */ jsx(WidgetShell, { title: config.title || "Complete payment", theme: config.theme, heightPx: props.heightPx, walletSlot, children: hist && wallet.account ? /* @__PURE__ */ jsx(TxHistoryPanel, { account: wallet.account, tokens: registryTokens, initialEntry: hist.entry ?? null, onBack: closeHistory }) : view === "select" && wallet.account ? /* @__PURE__ */ jsx(
|
|
2767
|
+
TokenSelect,
|
|
2768
|
+
{
|
|
2769
|
+
title: "Pay with",
|
|
2770
|
+
chains: fundingChains,
|
|
2771
|
+
tokens: fundingTokens,
|
|
2772
|
+
balances: holdings.balances,
|
|
2773
|
+
optionStates,
|
|
2774
|
+
onBack: closeSelector,
|
|
2775
|
+
onPick: pickFunding
|
|
2776
|
+
}
|
|
2777
|
+
) : /* @__PURE__ */ jsx(Fragment, { children: !wallet.account ? /* @__PURE__ */ jsxs("div", { className: "sg-cta-wrap", children: [
|
|
2532
2778
|
/* @__PURE__ */ jsx(Button, { onClick: wallet.connect, busy: wallet.connecting, children: "Connect wallet" }),
|
|
2533
2779
|
wallet.error ? /* @__PURE__ */ jsx(StatusPanel, { tone: "error", children: wallet.error }) : null
|
|
2534
2780
|
] }) : flow.status === "success" || flow.status === "pending" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -2550,11 +2796,11 @@ function StableGeniePay(props) {
|
|
|
2550
2796
|
/* @__PURE__ */ jsx(MethodTabs, { value: method, onChange: setMethod }),
|
|
2551
2797
|
parked ? /* @__PURE__ */ jsx(StatusPanel, { children: comingSoon }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2552
2798
|
/* @__PURE__ */ jsx("div", { style: { marginTop: 12 }, children: /* @__PURE__ */ jsx(
|
|
2553
|
-
|
|
2799
|
+
FundingTile,
|
|
2554
2800
|
{
|
|
2555
2801
|
label: "Pay with",
|
|
2556
|
-
|
|
2557
|
-
|
|
2802
|
+
assets: payableAssets,
|
|
2803
|
+
loading: flow.status === "loading" || holdings.loading,
|
|
2558
2804
|
disabled: submitting || !visibleRoutes.length,
|
|
2559
2805
|
btnRef: payTileRef,
|
|
2560
2806
|
onClick: () => setView("select")
|
|
@@ -2586,7 +2832,15 @@ function StableGeniePay(props) {
|
|
|
2586
2832
|
flow.status === "ready" && !visibleRoutes.length ? /* @__PURE__ */ jsx(StatusPanel, { children: "No funding route matches the accepted assets for this payment." }) : null
|
|
2587
2833
|
] }),
|
|
2588
2834
|
submitting ? /* @__PURE__ */ jsx(StepList, { steps: flow.steps }) : null,
|
|
2589
|
-
/* @__PURE__ */ jsx("div", { className: "sg-cta-wrap", children: /* @__PURE__ */ jsx(
|
|
2835
|
+
/* @__PURE__ */ jsx("div", { className: "sg-cta-wrap", children: /* @__PURE__ */ jsx(
|
|
2836
|
+
Button,
|
|
2837
|
+
{
|
|
2838
|
+
onClick: parked || !selectedVisible ? void 0 : flow.submit,
|
|
2839
|
+
busy: submitting,
|
|
2840
|
+
disabled: parked || !selectedVisible || flow.insufficient || !!flow.nativeShortfall || flow.status === "loading",
|
|
2841
|
+
children: payLabel
|
|
2842
|
+
}
|
|
2843
|
+
) })
|
|
2590
2844
|
] }) }) });
|
|
2591
2845
|
}
|
|
2592
2846
|
var chainOptions = SUPPORTED_CHAINS.map((c) => ({ value: c, label: CHAIN_LABELS[c] || `Chain ${c}` }));
|