@glacislabs/stablegenie-zerodelta 4.7.0 → 4.8.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/{chunk-L7ZEFAZ4.js → chunk-2TCYBOYW.js} +161 -11
- package/dist/{chunk-MZCS5TL2.js → chunk-F46VMTTL.js} +1 -1
- package/dist/core/index.cjs +1 -1
- package/dist/core/index.js +1 -1
- package/dist/index.cjs +160 -10
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/{mount-D4mbJwdc.d.cts → mount-Dxsc7-Fb.d.cts} +20 -1
- package/dist/{mount-D5TIOkMe.d.ts → mount-LkKQjoZU.d.ts} +20 -1
- package/dist/mount.cjs +160 -10
- package/dist/mount.d.cts +1 -1
- package/dist/mount.d.ts +1 -1
- package/dist/mount.js +2 -2
- package/dist/standalone.global.js +6 -6
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
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, amountFieldError, SUPPORTED_CHAIN_IDS, formatUnits, complianceChecks, DIRECT_CHECK_IDS, createEngine, checkNativeFee, nativeFeeShortLabel, nativeFeeShortMessage, allowanceCovers, validatePlannedTransaction, foldTicker, unattributedComplianceReasons, distinctScreenedWallets, humanizeComplianceReason, DIRECT_SCOPE_NOTE, categoryLabel, SCREENING_BUCKETS, BUNDLED_RPC } from './chunk-
|
|
2
|
-
import { createContext, useState, useRef, useMemo, useEffect, useCallback, useId, createElement, useContext } from 'react';
|
|
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, amountFieldError, SUPPORTED_CHAIN_IDS, formatUnits, complianceChecks, DIRECT_CHECK_IDS, createEngine, checkNativeFee, nativeFeeShortLabel, nativeFeeShortMessage, allowanceCovers, validatePlannedTransaction, foldTicker, unattributedComplianceReasons, distinctScreenedWallets, humanizeComplianceReason, DIRECT_SCOPE_NOTE, categoryLabel, SCREENING_BUCKETS, BUNDLED_RPC } from './chunk-F46VMTTL.js';
|
|
2
|
+
import { createContext, useState, useRef, useMemo, useEffect, useCallback, useId, createElement, useContext, useLayoutEffect, useReducer } from 'react';
|
|
3
3
|
import { createRoot } from 'react-dom/client';
|
|
4
4
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
5
5
|
|
|
@@ -577,6 +577,83 @@ function useHoldings(engine, account, routes, initialBalances) {
|
|
|
577
577
|
return { balances, loading };
|
|
578
578
|
}
|
|
579
579
|
|
|
580
|
+
// src/react/ui/amount.ts
|
|
581
|
+
var MAX_FRACTION_DIGITS = 8;
|
|
582
|
+
function trimFraction(fixed) {
|
|
583
|
+
return fixed.includes(".") ? fixed.replace(/\.?0+$/, "") : fixed;
|
|
584
|
+
}
|
|
585
|
+
function groupDecimal(value) {
|
|
586
|
+
const match = value.match(/^([+-]?)(\d+)(\.\d+)?$/);
|
|
587
|
+
if (!match) return value;
|
|
588
|
+
const integer = match[2].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
589
|
+
return `${match[1]}${integer}${match[3] ?? ""}`;
|
|
590
|
+
}
|
|
591
|
+
var SIGNIFICANT_DIGITS = 7;
|
|
592
|
+
var MIN_FRACTION_DIGITS = 4;
|
|
593
|
+
function formatCalculatedAmount(value, decimals) {
|
|
594
|
+
let raw = typeof value === "number" ? String(value) : value.trim();
|
|
595
|
+
if (typeof value === "number") {
|
|
596
|
+
if (!Number.isFinite(value)) return raw;
|
|
597
|
+
if (/e/i.test(raw)) {
|
|
598
|
+
raw = value.toLocaleString("en-US", {
|
|
599
|
+
useGrouping: false,
|
|
600
|
+
maximumFractionDigits: 20
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
const match = raw.match(/^([+-]?)(\d*)(?:\.(\d*))?$/);
|
|
605
|
+
if (!match) return raw;
|
|
606
|
+
const negative = match[1] === "-";
|
|
607
|
+
const integer = (match[2] || "0").replace(/^0+(?=\d)/, "");
|
|
608
|
+
const fraction = match[3] ?? "";
|
|
609
|
+
const firstNonZero = fraction.search(/[1-9]/);
|
|
610
|
+
const isZero = integer === "0" && firstNonZero === -1;
|
|
611
|
+
if (isZero) return "0";
|
|
612
|
+
if (integer === "0" && firstNonZero >= 6) return `${negative ? "-" : ""}<0.000001`;
|
|
613
|
+
const cap = decimals === void 0 || !Number.isFinite(decimals) ? MAX_FRACTION_DIGITS : Math.min(MAX_FRACTION_DIGITS, Math.max(0, Math.trunc(decimals)));
|
|
614
|
+
const places = integer !== "0" ? Math.min(cap, Math.max(MIN_FRACTION_DIGITS, SIGNIFICANT_DIGITS - integer.length)) : (
|
|
615
|
+
// Below one the leading zeros are not significant, so the count starts
|
|
616
|
+
// at the first digit that is.
|
|
617
|
+
Math.min(cap, firstNonZero + SIGNIFICANT_DIGITS)
|
|
618
|
+
);
|
|
619
|
+
const scale = 10n ** BigInt(places);
|
|
620
|
+
const padded = fraction.padEnd(places + 1, "0");
|
|
621
|
+
const kept = padded.slice(0, places);
|
|
622
|
+
let rounded = BigInt(integer) * scale + BigInt(kept || "0");
|
|
623
|
+
if ((padded[places] ?? "0") >= "5") rounded += 1n;
|
|
624
|
+
const whole = rounded / scale;
|
|
625
|
+
const remainder = rounded % scale;
|
|
626
|
+
const fixed = places === 0 ? whole.toString() : `${whole}.${remainder.toString().padStart(places, "0")}`;
|
|
627
|
+
const out = groupDecimal(trimFraction(fixed));
|
|
628
|
+
return negative && out !== "0" ? `-${out}` : out;
|
|
629
|
+
}
|
|
630
|
+
function exactAmountTitle(raw, shown) {
|
|
631
|
+
const full = typeof raw === "number" ? String(raw) : raw.trim();
|
|
632
|
+
if (!full || /e/i.test(full)) return void 0;
|
|
633
|
+
const normalized = full.includes(".") ? trimFraction(full) : full;
|
|
634
|
+
const grouped = groupDecimal(normalized);
|
|
635
|
+
return grouped === shown ? void 0 : grouped;
|
|
636
|
+
}
|
|
637
|
+
function sanitizeAmount(raw) {
|
|
638
|
+
const cleaned = raw.replace(/[^0-9.]/g, "");
|
|
639
|
+
const first = cleaned.indexOf(".");
|
|
640
|
+
if (first === -1) return cleaned;
|
|
641
|
+
return cleaned.slice(0, first + 1) + cleaned.slice(first + 1).replace(/\./g, "");
|
|
642
|
+
}
|
|
643
|
+
function groupAmountInput(value) {
|
|
644
|
+
const point = value.indexOf(".");
|
|
645
|
+
const whole = point === -1 ? value : value.slice(0, point);
|
|
646
|
+
return whole.replace(/\B(?=(\d{3})+(?!\d))/g, ",") + (point === -1 ? "" : value.slice(point));
|
|
647
|
+
}
|
|
648
|
+
function groupedAmountCaret(grouped, kept) {
|
|
649
|
+
if (kept <= 0) return 0;
|
|
650
|
+
let seen = 0;
|
|
651
|
+
for (let i = 0; i < grouped.length; i++) {
|
|
652
|
+
if (grouped[i] !== "," && ++seen === kept) return i + 1;
|
|
653
|
+
}
|
|
654
|
+
return grouped.length;
|
|
655
|
+
}
|
|
656
|
+
|
|
580
657
|
// src/react/styles.ts
|
|
581
658
|
var WIDGET_CSS = `
|
|
582
659
|
/* The card as the ZeroDelta widget design draws it (Figma "Widget Playground", 2026-09-30): no
|
|
@@ -1398,6 +1475,53 @@ function BrandMark({ size = 18, mono = false, className, style, title }) {
|
|
|
1398
1475
|
}
|
|
1399
1476
|
);
|
|
1400
1477
|
}
|
|
1478
|
+
var MIN_FONT_PX = 10;
|
|
1479
|
+
function useFitText(ref, text) {
|
|
1480
|
+
useLayoutEffect(() => {
|
|
1481
|
+
const el = ref.current;
|
|
1482
|
+
if (!el) return;
|
|
1483
|
+
const fit = () => {
|
|
1484
|
+
el.style.fontSize = "";
|
|
1485
|
+
const room = el.clientWidth;
|
|
1486
|
+
const needed = el.scrollWidth;
|
|
1487
|
+
if (!room || needed <= room) return;
|
|
1488
|
+
const base = Number.parseFloat(getComputedStyle(el).fontSize);
|
|
1489
|
+
if (!Number.isFinite(base) || base <= 0) return;
|
|
1490
|
+
el.style.fontSize = `${Math.max(MIN_FONT_PX, Math.floor(base * room / needed))}px`;
|
|
1491
|
+
};
|
|
1492
|
+
fit();
|
|
1493
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
1494
|
+
const observer = new ResizeObserver(fit);
|
|
1495
|
+
if (el.parentElement) observer.observe(el.parentElement);
|
|
1496
|
+
return () => observer.disconnect();
|
|
1497
|
+
}, [ref, text]);
|
|
1498
|
+
}
|
|
1499
|
+
function useGroupedAmountInput(amount, onAmount) {
|
|
1500
|
+
const caret = useRef(null);
|
|
1501
|
+
const [, rerender] = useReducer((n) => n + 1, 0);
|
|
1502
|
+
useLayoutEffect(() => {
|
|
1503
|
+
const pending = caret.current;
|
|
1504
|
+
caret.current = null;
|
|
1505
|
+
if (pending === null || pending.input !== document.activeElement) return;
|
|
1506
|
+
const at = groupedAmountCaret(pending.input.value, pending.kept);
|
|
1507
|
+
pending.input.setSelectionRange(at, at);
|
|
1508
|
+
});
|
|
1509
|
+
const onChange = (e) => {
|
|
1510
|
+
const input = e.target;
|
|
1511
|
+
const raw = input.value;
|
|
1512
|
+
caret.current = { input, kept: sanitizeAmount(raw.slice(0, input.selectionEnd ?? raw.length)).length };
|
|
1513
|
+
onAmount(sanitizeAmount(raw));
|
|
1514
|
+
rerender();
|
|
1515
|
+
};
|
|
1516
|
+
const onKeyDown = (e) => {
|
|
1517
|
+
const input = e.currentTarget;
|
|
1518
|
+
const at = input.selectionStart;
|
|
1519
|
+
if (at === null || at !== input.selectionEnd) return;
|
|
1520
|
+
if (e.key === "Backspace" && input.value[at - 1] === ",") input.setSelectionRange(at - 1, at - 1);
|
|
1521
|
+
else if (e.key === "Delete" && input.value[at] === ",") input.setSelectionRange(at + 1, at + 1);
|
|
1522
|
+
};
|
|
1523
|
+
return { value: groupAmountInput(amount), onChange, onKeyDown };
|
|
1524
|
+
}
|
|
1401
1525
|
var SOURCE_CHAIN_LABELS = {
|
|
1402
1526
|
1: "Ethereum",
|
|
1403
1527
|
10: "Optimism",
|
|
@@ -1451,17 +1575,22 @@ function Select(props) {
|
|
|
1451
1575
|
] }) });
|
|
1452
1576
|
}
|
|
1453
1577
|
function AmountInput(props) {
|
|
1578
|
+
const grouped = useGroupedAmountInput(props.value, props.onChange);
|
|
1579
|
+
const field = useRef(null);
|
|
1580
|
+
useFitText(field, grouped.value);
|
|
1454
1581
|
return /* @__PURE__ */ jsx(
|
|
1455
1582
|
"input",
|
|
1456
1583
|
{
|
|
1584
|
+
ref: field,
|
|
1457
1585
|
className: "sg-input sg-amount sg-mono",
|
|
1458
1586
|
inputMode: "decimal",
|
|
1459
1587
|
placeholder: props.placeholder ?? "0.0",
|
|
1460
|
-
value:
|
|
1588
|
+
value: grouped.value,
|
|
1461
1589
|
disabled: props.disabled,
|
|
1462
1590
|
"aria-invalid": props.invalid || void 0,
|
|
1463
1591
|
"aria-describedby": props.describedBy,
|
|
1464
|
-
onChange:
|
|
1592
|
+
onChange: grouped.onChange,
|
|
1593
|
+
onKeyDown: grouped.onKeyDown
|
|
1465
1594
|
}
|
|
1466
1595
|
);
|
|
1467
1596
|
}
|
|
@@ -1887,11 +2016,11 @@ function QuoteGlyph({ size = 16 }) {
|
|
|
1887
2016
|
)
|
|
1888
2017
|
] });
|
|
1889
2018
|
}
|
|
1890
|
-
function AmountText({ value, suffix }) {
|
|
1891
|
-
const dot = value.indexOf(".");
|
|
2019
|
+
function AmountText({ value, suffix, exact }) {
|
|
2020
|
+
const dot = value.startsWith("<") ? -1 : value.indexOf(".");
|
|
1892
2021
|
const whole = dot < 0 ? value : value.slice(0, dot + 1);
|
|
1893
2022
|
const decimals = dot < 0 ? "" : value.slice(dot + 1);
|
|
1894
|
-
return /* @__PURE__ */ jsxs("span", { className: "sg-amt", children: [
|
|
2023
|
+
return /* @__PURE__ */ jsxs("span", { className: "sg-amt", title: exact === void 0 ? void 0 : exactAmountTitle(exact, value), children: [
|
|
1895
2024
|
whole,
|
|
1896
2025
|
decimals ? /* @__PURE__ */ jsx("span", { className: "sg-amt-dec", children: decimals }) : null,
|
|
1897
2026
|
suffix ? ` ${suffix}` : null
|
|
@@ -3817,7 +3946,7 @@ function PayCard(props) {
|
|
|
3817
3946
|
setSheet(false);
|
|
3818
3947
|
requestAnimationFrame(() => complianceBtnRef.current?.focus());
|
|
3819
3948
|
};
|
|
3820
|
-
const payLabel = parked ? "Coming soon" : submitting ? "Paying\u2026" : flow.insufficient ? "Insufficient balance" : flow.nativeShortfall ? flow.nativeShortfall : sel && selectedVisible ? `Pay ${atLeastCents(sel.source.payAmount)} ${sel.source.ticker || sel.source.asset}` : "Pay";
|
|
3949
|
+
const payLabel = parked ? "Coming soon" : submitting ? "Paying\u2026" : flow.insufficient ? "Insufficient balance" : flow.nativeShortfall ? flow.nativeShortfall : sel && selectedVisible ? `Pay ${groupDecimal(atLeastCents(sel.source.payAmount))} ${sel.source.ticker || sel.source.asset}` : "Pay";
|
|
3821
3950
|
const walletSlot = wallet.account ? /* @__PURE__ */ jsxs("div", { className: "sg-head-tools", children: [
|
|
3822
3951
|
/* @__PURE__ */ jsx(HistoryButton, { btnRef: histBtnRef, disabled: submitting, onClick: () => setHist({}) }),
|
|
3823
3952
|
/* @__PURE__ */ jsxs("span", { className: "sg-wallet", "data-connected": "true", children: [
|
|
@@ -3869,7 +3998,7 @@ function PayCard(props) {
|
|
|
3869
3998
|
/* @__PURE__ */ jsxs("div", { className: "sg-pane", "data-kind": "pay", children: [
|
|
3870
3999
|
/* @__PURE__ */ jsx("span", { className: "sg-pane-label", children: "You pay" }),
|
|
3871
4000
|
/* @__PURE__ */ jsxs("div", { className: "sg-pane-mid", children: [
|
|
3872
|
-
/* @__PURE__ */ jsx("span", { className: "sg-amt-out", "aria-live": "polite", children: loadingPlan ? /* @__PURE__ */ jsx("span", { className: "sg-amt-empty", children: "\u2026" }) : sel && selectedVisible ? /* @__PURE__ */ jsx(AmountText, { value: atLeastCents(sel.source.payAmount) }) : /* @__PURE__ */ jsx("span", { className: "sg-amt-empty", children: "\u2014" }) }),
|
|
4001
|
+
/* @__PURE__ */ jsx("span", { className: "sg-amt-out", "aria-live": "polite", children: loadingPlan ? /* @__PURE__ */ jsx("span", { className: "sg-amt-empty", children: "\u2026" }) : sel && selectedVisible ? /* @__PURE__ */ jsx(AmountText, { value: groupDecimal(atLeastCents(sel.source.payAmount)) }) : /* @__PURE__ */ jsx("span", { className: "sg-amt-empty", children: "\u2014" }) }),
|
|
3873
4002
|
/* @__PURE__ */ jsx(
|
|
3874
4003
|
TokenButton,
|
|
3875
4004
|
{
|
|
@@ -4194,6 +4323,15 @@ function ExchangeCard(props) {
|
|
|
4194
4323
|
() => props.defaultToChainId && props.defaultToAsset ? { chainId: props.defaultToChainId, symbol: symbolKey(props.defaultToAsset) } : null
|
|
4195
4324
|
);
|
|
4196
4325
|
const [amount, setAmount] = useState(props.defaultAmount ?? "");
|
|
4326
|
+
const onInputChange = useRef(props.onInputChange);
|
|
4327
|
+
onInputChange.current = props.onInputChange;
|
|
4328
|
+
const fromChainId = from?.chainId ?? null;
|
|
4329
|
+
const fromSymbol = from?.symbol ?? null;
|
|
4330
|
+
const toChainId = to?.chainId ?? null;
|
|
4331
|
+
const toSymbolKey = to?.symbol ?? null;
|
|
4332
|
+
useEffect(() => {
|
|
4333
|
+
onInputChange.current?.({ fromChainId, fromAsset: fromSymbol, toChainId, toAsset: toSymbolKey, amount });
|
|
4334
|
+
}, [fromChainId, fromSymbol, toChainId, toSymbolKey, amount]);
|
|
4197
4335
|
const [fiatCurrency, setFiatCurrency] = useState(props.fiatCurrency ?? "EUR");
|
|
4198
4336
|
const fromToken = useMemo(() => from ? findToken(tokens, from.chainId, from.symbol) : null, [tokens, from]);
|
|
4199
4337
|
const toToken = useMemo(() => to ? findToken(tokens, to.chainId, to.symbol) : null, [tokens, to]);
|
|
@@ -4331,6 +4469,18 @@ function ExchangeCard(props) {
|
|
|
4331
4469
|
const amountError = overLimit && laneLimit ? laneLimitError(laneLimit, limitSymbol) : gatewayAmountError;
|
|
4332
4470
|
const amountNote = mode === "exchange" ? amountError || (laneLimit ? laneLimitHint(laneLimit, limitSymbol) : null) : null;
|
|
4333
4471
|
const receive = connected ? flow.selected?.receive.amount : preview.data?.receive;
|
|
4472
|
+
const receiveOutRef = useRef(null);
|
|
4473
|
+
const receiveSideRef = useRef(null);
|
|
4474
|
+
const receiveShown = `${receive ?? ""}|${quoting}|${toTicker}`;
|
|
4475
|
+
useFitText(receiveOutRef, receiveShown);
|
|
4476
|
+
useFitText(receiveSideRef, receiveShown);
|
|
4477
|
+
const toDecimals = useMemo(() => {
|
|
4478
|
+
try {
|
|
4479
|
+
return toToken ? assetDecimals(toToken) : void 0;
|
|
4480
|
+
} catch {
|
|
4481
|
+
return void 0;
|
|
4482
|
+
}
|
|
4483
|
+
}, [toToken]);
|
|
4334
4484
|
const meta = connected ? flow.selected ? { bridge: flow.selected.quote.bridge || "ZeroDelta", feeBps: Number(flow.selected.quote.feeBps || 0), duration: Number(flow.selected.quote.estimatedDuration || 0) } : null : preview.data ? { bridge: preview.data.bridge || "ZeroDelta", feeBps: preview.data.feeBps, duration: preview.data.estimatedDuration } : null;
|
|
4335
4485
|
const pct = (p) => {
|
|
4336
4486
|
if (!fromBal || !fromToken) return;
|
|
@@ -4524,7 +4674,7 @@ function ExchangeCard(props) {
|
|
|
4524
4674
|
/* @__PURE__ */ jsxs("div", { className: "sg-pane", "data-kind": "receive", children: [
|
|
4525
4675
|
/* @__PURE__ */ jsx("span", { className: "sg-pane-label", children: product === "rwa" ? "You receive (estimated)" : "You receive" }),
|
|
4526
4676
|
/* @__PURE__ */ jsxs("div", { className: "sg-pane-mid", children: [
|
|
4527
|
-
/* @__PURE__ */ jsx("span", { className: "sg-amt-out", "aria-live": "polite", children: rampMode ? /* @__PURE__ */ jsx("span", { className: "sg-amt-empty", children: "\u2014" }) : quoting ? /* @__PURE__ */ jsx("span", { className: "sg-amt-empty", children: "\u2026" }) : receive && quotable && !quoteError ? /* @__PURE__ */ jsx(AmountText, { value: receive }) : /* @__PURE__ */ jsx("span", { className: "sg-amt-empty", children: "0" }) }),
|
|
4677
|
+
/* @__PURE__ */ jsx("span", { className: "sg-amt-out", "aria-live": "polite", ref: receiveOutRef, children: rampMode ? /* @__PURE__ */ jsx("span", { className: "sg-amt-empty", children: "\u2014" }) : quoting ? /* @__PURE__ */ jsx("span", { className: "sg-amt-empty", children: "\u2026" }) : receive && quotable && !quoteError ? /* @__PURE__ */ jsx(AmountText, { value: formatCalculatedAmount(receive, toDecimals), exact: receive }) : /* @__PURE__ */ jsx("span", { className: "sg-amt-empty", children: "0" }) }),
|
|
4528
4678
|
receiveToken
|
|
4529
4679
|
] }),
|
|
4530
4680
|
/* @__PURE__ */ jsx(PaneFoot, { usd: hasQuote ? toUsd : null })
|
|
@@ -4585,7 +4735,7 @@ function ExchangeCard(props) {
|
|
|
4585
4735
|
/* @__PURE__ */ jsxs("div", { className: "sg-recv", children: [
|
|
4586
4736
|
/* @__PURE__ */ jsxs("div", { className: "sg-recv-line", children: [
|
|
4587
4737
|
/* @__PURE__ */ jsx(TokenGlyph, { symbol: to?.symbol ?? "", logoUrl: toToken?.logoUrl, chainId: to?.chainId, size: "xs" }),
|
|
4588
|
-
/* @__PURE__ */ jsx("span", { className: "sg-recv-amt", children: /* @__PURE__ */ jsx(AmountText, { value: receive, suffix: toTicker }) })
|
|
4738
|
+
/* @__PURE__ */ jsx("span", { className: "sg-recv-amt", ref: receiveSideRef, children: /* @__PURE__ */ jsx(AmountText, { value: formatCalculatedAmount(receive, toDecimals), exact: receive, suffix: toTicker }) })
|
|
4589
4739
|
] }),
|
|
4590
4740
|
/* @__PURE__ */ jsxs("div", { className: "sg-recv-sub", children: [
|
|
4591
4741
|
"On ",
|
|
@@ -1706,7 +1706,7 @@ var CHANNEL_HEADER = "x-zd-channel";
|
|
|
1706
1706
|
var CHANNEL_VERSION_HEADER = "x-zd-channel-version";
|
|
1707
1707
|
var CHANNEL_ORIGIN_HEADER = "x-zd-channel-origin";
|
|
1708
1708
|
var WIDGET_CHANNEL = "widget";
|
|
1709
|
-
var WIDGET_VERSION = "4.
|
|
1709
|
+
var WIDGET_VERSION = "4.8.0" ;
|
|
1710
1710
|
var MAX_CHANNEL_VERSION_LEN = 32;
|
|
1711
1711
|
function sanitizeVersion(raw) {
|
|
1712
1712
|
const v = String(raw).trim();
|
package/dist/core/index.cjs
CHANGED
|
@@ -1708,7 +1708,7 @@ var CHANNEL_HEADER = "x-zd-channel";
|
|
|
1708
1708
|
var CHANNEL_VERSION_HEADER = "x-zd-channel-version";
|
|
1709
1709
|
var CHANNEL_ORIGIN_HEADER = "x-zd-channel-origin";
|
|
1710
1710
|
var WIDGET_CHANNEL = "widget";
|
|
1711
|
-
var WIDGET_VERSION = "4.
|
|
1711
|
+
var WIDGET_VERSION = "4.8.0" ;
|
|
1712
1712
|
var MAX_CHANNEL_VERSION_LEN = 32;
|
|
1713
1713
|
function sanitizeVersion(raw) {
|
|
1714
1714
|
const v = String(raw).trim();
|
package/dist/core/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { API_CACHE_TTL_MS, BLOCK_LABEL_DEFAULT, BUNDLED_NATIVE_SYMBOL, BUNDLED_RPC, CANONICAL_DECIMALS, CANONICAL_ESCROW, CANONICAL_INBOUND_BRIDGE, CHAIN_DISPLAY_NAMES, COMPLIANCE_CHECK_ORDER, COMPLIANCE_DENY_LABEL, DEFAULT_WIDGET_API_BASE, DIRECT_CHECK_IDS, DIRECT_SCOPE_NOTE, ERC20_ALLOWANCE_SELECTOR, ERC20_APPROVE_SELECTOR, ERC20_BALANCEOF_SELECTOR, ERC20_TRANSFER_SELECTOR, EXECUTABLE_STABLE_ASSETS, FLOOR_CATEGORIES, LZ_FEE_BUFFER_BPS, MAX_LZ_MSG_VALUE_WEI, MAX_LZ_MSG_VALUE_WEI_BY_CHAIN, MAX_QUOTE_CANDIDATES, MAX_SAME_CLASS_PAY_BPS, MAX_UINT64, NO_PARTNER_ID, PREVIEW_OWNER, QUOTE_BUFFER_BPS, SAME_CLASS_STABLE, SCREENING_BUCKETS, SCREEN_CACHE_TTL_MS, STABLEGENIE_INTENT_TTL_MS, STABLEGENIE_INTENT_VERSION, STABLEGENIE_SUPPORTED_ASSETS, STABLEGENIE_SUPPORTED_CHAIN_IDS, STABLE_ASSETS, SUBMIT_ORDER_SELECTOR, SUPPORTED_ASSETS, SUPPORTED_CHAIN_IDS, TRADEABLE_RWA_ASSETS, TUNABLE_CATEGORIES, ZERO_ADDRESS, addressWord, allowanceCovers, amountFieldError, apiError, applyLayerZeroBuffer, assertAddress, assertQuoteMatchesSelection, assetClassOf, assetDecimals, blockLabelFor, brokenLaneFor, brokenLaneReason, buildCatalogue, buildPayOptions, buildRoute, buildSwapPlan, bytes32Word, bytesPayload, canAttachApiKey, categoryLabel, chainById, chainNameOf, chainSelectable, checkEscrow, checkNativeFee, classifyQuoteError, complianceChecks, complianceControlsEvaluated, complianceControlsLine, complianceReasonHead, complianceReasonTag, complianceTagOf, complianceView, counterpartTokens, createApiClient, createEngine, createVerifier, decodeSubmitOrderCalldata, destinationAvailability, destinationKeys, directComplianceFromScreens, distinctScreenedWallets, encodeAllowance, encodeApprove, encodeBalanceOf, encodeSubmitOrder, encodeTransfer, exceedsLaneLimit, executableRoutes, executionChainIds, fetchPaymentPlan, finalOf, findToken, foldTicker, formatNative, formatUnits, hasReachableDestination, hubDeliverableSymbols, humanizeComplianceReason, isAddress, isDeliverable, isExecutableBridge, isHexAddress, isHexData, isHexQuantity, isKnownUnbridgeable, isLayerZeroRoute, isSourceToken, laneAvailabilityState, laneKey, laneKeys, laneLimitAmount, laneLimitError, laneLimitFor, laneLimitHint, laneLimitSymbol, limitedLanes, maxDeadlineSeconds, maxNativeFeeWei, nativeFeeShortLabel, nativeFeeShortMessage, nativeSymbol, normalizeAddress, normalizeDecimalText, normalizeOrderRequest, normalizeOrderRequests, parseAllowedApiBase, parseUnitsDecimal, planErrorSummary, planMsgValueHex, productAssets, quotePartnerId, quoteSwapPreview, recommendedDeadlineSeconds, registryRpc, requiresNativeBridgeFee, resolveApiBase, resolveConfig, resolveSwapReceiver, resolveVaultIcon, routeNativeValue, safeTicker, scaleDecimals, screeningOutcomeOf, solveExactIn, solveExactOut, sourceKeys, stableGenieIntentSchema, strip0x, suppressedLanes, symbolKey, tickerOn, toHexQuantity, tokenEnabled, tokenKey, tokenTicker, txMatchesPlan, uint64Word, uintWord, unattributedComplianceReasons, validateDestination, validatePlannedTransaction, validateSwap, vaultIconsBySymbol, withVaultArtwork } from '../chunk-
|
|
1
|
+
export { API_CACHE_TTL_MS, BLOCK_LABEL_DEFAULT, BUNDLED_NATIVE_SYMBOL, BUNDLED_RPC, CANONICAL_DECIMALS, CANONICAL_ESCROW, CANONICAL_INBOUND_BRIDGE, CHAIN_DISPLAY_NAMES, COMPLIANCE_CHECK_ORDER, COMPLIANCE_DENY_LABEL, DEFAULT_WIDGET_API_BASE, DIRECT_CHECK_IDS, DIRECT_SCOPE_NOTE, ERC20_ALLOWANCE_SELECTOR, ERC20_APPROVE_SELECTOR, ERC20_BALANCEOF_SELECTOR, ERC20_TRANSFER_SELECTOR, EXECUTABLE_STABLE_ASSETS, FLOOR_CATEGORIES, LZ_FEE_BUFFER_BPS, MAX_LZ_MSG_VALUE_WEI, MAX_LZ_MSG_VALUE_WEI_BY_CHAIN, MAX_QUOTE_CANDIDATES, MAX_SAME_CLASS_PAY_BPS, MAX_UINT64, NO_PARTNER_ID, PREVIEW_OWNER, QUOTE_BUFFER_BPS, SAME_CLASS_STABLE, SCREENING_BUCKETS, SCREEN_CACHE_TTL_MS, STABLEGENIE_INTENT_TTL_MS, STABLEGENIE_INTENT_VERSION, STABLEGENIE_SUPPORTED_ASSETS, STABLEGENIE_SUPPORTED_CHAIN_IDS, STABLE_ASSETS, SUBMIT_ORDER_SELECTOR, SUPPORTED_ASSETS, SUPPORTED_CHAIN_IDS, TRADEABLE_RWA_ASSETS, TUNABLE_CATEGORIES, ZERO_ADDRESS, addressWord, allowanceCovers, amountFieldError, apiError, applyLayerZeroBuffer, assertAddress, assertQuoteMatchesSelection, assetClassOf, assetDecimals, blockLabelFor, brokenLaneFor, brokenLaneReason, buildCatalogue, buildPayOptions, buildRoute, buildSwapPlan, bytes32Word, bytesPayload, canAttachApiKey, categoryLabel, chainById, chainNameOf, chainSelectable, checkEscrow, checkNativeFee, classifyQuoteError, complianceChecks, complianceControlsEvaluated, complianceControlsLine, complianceReasonHead, complianceReasonTag, complianceTagOf, complianceView, counterpartTokens, createApiClient, createEngine, createVerifier, decodeSubmitOrderCalldata, destinationAvailability, destinationKeys, directComplianceFromScreens, distinctScreenedWallets, encodeAllowance, encodeApprove, encodeBalanceOf, encodeSubmitOrder, encodeTransfer, exceedsLaneLimit, executableRoutes, executionChainIds, fetchPaymentPlan, finalOf, findToken, foldTicker, formatNative, formatUnits, hasReachableDestination, hubDeliverableSymbols, humanizeComplianceReason, isAddress, isDeliverable, isExecutableBridge, isHexAddress, isHexData, isHexQuantity, isKnownUnbridgeable, isLayerZeroRoute, isSourceToken, laneAvailabilityState, laneKey, laneKeys, laneLimitAmount, laneLimitError, laneLimitFor, laneLimitHint, laneLimitSymbol, limitedLanes, maxDeadlineSeconds, maxNativeFeeWei, nativeFeeShortLabel, nativeFeeShortMessage, nativeSymbol, normalizeAddress, normalizeDecimalText, normalizeOrderRequest, normalizeOrderRequests, parseAllowedApiBase, parseUnitsDecimal, planErrorSummary, planMsgValueHex, productAssets, quotePartnerId, quoteSwapPreview, recommendedDeadlineSeconds, registryRpc, requiresNativeBridgeFee, resolveApiBase, resolveConfig, resolveSwapReceiver, resolveVaultIcon, routeNativeValue, safeTicker, scaleDecimals, screeningOutcomeOf, solveExactIn, solveExactOut, sourceKeys, stableGenieIntentSchema, strip0x, suppressedLanes, symbolKey, tickerOn, toHexQuantity, tokenEnabled, tokenKey, tokenTicker, txMatchesPlan, uint64Word, uintWord, unattributedComplianceReasons, validateDestination, validatePlannedTransaction, validateSwap, vaultIconsBySymbol, withVaultArtwork } from '../chunk-F46VMTTL.js';
|
package/dist/index.cjs
CHANGED
|
@@ -1718,7 +1718,7 @@ var CHANNEL_HEADER = "x-zd-channel";
|
|
|
1718
1718
|
var CHANNEL_VERSION_HEADER = "x-zd-channel-version";
|
|
1719
1719
|
var CHANNEL_ORIGIN_HEADER = "x-zd-channel-origin";
|
|
1720
1720
|
var WIDGET_CHANNEL = "widget";
|
|
1721
|
-
var WIDGET_VERSION = "4.
|
|
1721
|
+
var WIDGET_VERSION = "4.8.0" ;
|
|
1722
1722
|
var MAX_CHANNEL_VERSION_LEN = 32;
|
|
1723
1723
|
function sanitizeVersion(raw) {
|
|
1724
1724
|
const v = String(raw).trim();
|
|
@@ -3313,6 +3313,83 @@ function useHoldings(engine, account, routes, initialBalances) {
|
|
|
3313
3313
|
return { balances, loading };
|
|
3314
3314
|
}
|
|
3315
3315
|
|
|
3316
|
+
// src/react/ui/amount.ts
|
|
3317
|
+
var MAX_FRACTION_DIGITS = 8;
|
|
3318
|
+
function trimFraction(fixed) {
|
|
3319
|
+
return fixed.includes(".") ? fixed.replace(/\.?0+$/, "") : fixed;
|
|
3320
|
+
}
|
|
3321
|
+
function groupDecimal(value) {
|
|
3322
|
+
const match = value.match(/^([+-]?)(\d+)(\.\d+)?$/);
|
|
3323
|
+
if (!match) return value;
|
|
3324
|
+
const integer = match[2].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
3325
|
+
return `${match[1]}${integer}${match[3] ?? ""}`;
|
|
3326
|
+
}
|
|
3327
|
+
var SIGNIFICANT_DIGITS = 7;
|
|
3328
|
+
var MIN_FRACTION_DIGITS = 4;
|
|
3329
|
+
function formatCalculatedAmount(value, decimals) {
|
|
3330
|
+
let raw = typeof value === "number" ? String(value) : value.trim();
|
|
3331
|
+
if (typeof value === "number") {
|
|
3332
|
+
if (!Number.isFinite(value)) return raw;
|
|
3333
|
+
if (/e/i.test(raw)) {
|
|
3334
|
+
raw = value.toLocaleString("en-US", {
|
|
3335
|
+
useGrouping: false,
|
|
3336
|
+
maximumFractionDigits: 20
|
|
3337
|
+
});
|
|
3338
|
+
}
|
|
3339
|
+
}
|
|
3340
|
+
const match = raw.match(/^([+-]?)(\d*)(?:\.(\d*))?$/);
|
|
3341
|
+
if (!match) return raw;
|
|
3342
|
+
const negative = match[1] === "-";
|
|
3343
|
+
const integer = (match[2] || "0").replace(/^0+(?=\d)/, "");
|
|
3344
|
+
const fraction = match[3] ?? "";
|
|
3345
|
+
const firstNonZero = fraction.search(/[1-9]/);
|
|
3346
|
+
const isZero = integer === "0" && firstNonZero === -1;
|
|
3347
|
+
if (isZero) return "0";
|
|
3348
|
+
if (integer === "0" && firstNonZero >= 6) return `${negative ? "-" : ""}<0.000001`;
|
|
3349
|
+
const cap = decimals === void 0 || !Number.isFinite(decimals) ? MAX_FRACTION_DIGITS : Math.min(MAX_FRACTION_DIGITS, Math.max(0, Math.trunc(decimals)));
|
|
3350
|
+
const places = integer !== "0" ? Math.min(cap, Math.max(MIN_FRACTION_DIGITS, SIGNIFICANT_DIGITS - integer.length)) : (
|
|
3351
|
+
// Below one the leading zeros are not significant, so the count starts
|
|
3352
|
+
// at the first digit that is.
|
|
3353
|
+
Math.min(cap, firstNonZero + SIGNIFICANT_DIGITS)
|
|
3354
|
+
);
|
|
3355
|
+
const scale = 10n ** BigInt(places);
|
|
3356
|
+
const padded = fraction.padEnd(places + 1, "0");
|
|
3357
|
+
const kept = padded.slice(0, places);
|
|
3358
|
+
let rounded = BigInt(integer) * scale + BigInt(kept || "0");
|
|
3359
|
+
if ((padded[places] ?? "0") >= "5") rounded += 1n;
|
|
3360
|
+
const whole = rounded / scale;
|
|
3361
|
+
const remainder = rounded % scale;
|
|
3362
|
+
const fixed = places === 0 ? whole.toString() : `${whole}.${remainder.toString().padStart(places, "0")}`;
|
|
3363
|
+
const out = groupDecimal(trimFraction(fixed));
|
|
3364
|
+
return negative && out !== "0" ? `-${out}` : out;
|
|
3365
|
+
}
|
|
3366
|
+
function exactAmountTitle(raw, shown) {
|
|
3367
|
+
const full = typeof raw === "number" ? String(raw) : raw.trim();
|
|
3368
|
+
if (!full || /e/i.test(full)) return void 0;
|
|
3369
|
+
const normalized = full.includes(".") ? trimFraction(full) : full;
|
|
3370
|
+
const grouped = groupDecimal(normalized);
|
|
3371
|
+
return grouped === shown ? void 0 : grouped;
|
|
3372
|
+
}
|
|
3373
|
+
function sanitizeAmount(raw) {
|
|
3374
|
+
const cleaned = raw.replace(/[^0-9.]/g, "");
|
|
3375
|
+
const first = cleaned.indexOf(".");
|
|
3376
|
+
if (first === -1) return cleaned;
|
|
3377
|
+
return cleaned.slice(0, first + 1) + cleaned.slice(first + 1).replace(/\./g, "");
|
|
3378
|
+
}
|
|
3379
|
+
function groupAmountInput(value) {
|
|
3380
|
+
const point = value.indexOf(".");
|
|
3381
|
+
const whole = point === -1 ? value : value.slice(0, point);
|
|
3382
|
+
return whole.replace(/\B(?=(\d{3})+(?!\d))/g, ",") + (point === -1 ? "" : value.slice(point));
|
|
3383
|
+
}
|
|
3384
|
+
function groupedAmountCaret(grouped, kept) {
|
|
3385
|
+
if (kept <= 0) return 0;
|
|
3386
|
+
let seen = 0;
|
|
3387
|
+
for (let i = 0; i < grouped.length; i++) {
|
|
3388
|
+
if (grouped[i] !== "," && ++seen === kept) return i + 1;
|
|
3389
|
+
}
|
|
3390
|
+
return grouped.length;
|
|
3391
|
+
}
|
|
3392
|
+
|
|
3316
3393
|
// src/react/styles.ts
|
|
3317
3394
|
var WIDGET_CSS = `
|
|
3318
3395
|
/* The card as the ZeroDelta widget design draws it (Figma "Widget Playground", 2026-09-30): no
|
|
@@ -4134,6 +4211,53 @@ function BrandMark({ size = 18, mono = false, className, style, title }) {
|
|
|
4134
4211
|
}
|
|
4135
4212
|
);
|
|
4136
4213
|
}
|
|
4214
|
+
var MIN_FONT_PX = 10;
|
|
4215
|
+
function useFitText(ref, text) {
|
|
4216
|
+
react.useLayoutEffect(() => {
|
|
4217
|
+
const el = ref.current;
|
|
4218
|
+
if (!el) return;
|
|
4219
|
+
const fit = () => {
|
|
4220
|
+
el.style.fontSize = "";
|
|
4221
|
+
const room = el.clientWidth;
|
|
4222
|
+
const needed = el.scrollWidth;
|
|
4223
|
+
if (!room || needed <= room) return;
|
|
4224
|
+
const base = Number.parseFloat(getComputedStyle(el).fontSize);
|
|
4225
|
+
if (!Number.isFinite(base) || base <= 0) return;
|
|
4226
|
+
el.style.fontSize = `${Math.max(MIN_FONT_PX, Math.floor(base * room / needed))}px`;
|
|
4227
|
+
};
|
|
4228
|
+
fit();
|
|
4229
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
4230
|
+
const observer = new ResizeObserver(fit);
|
|
4231
|
+
if (el.parentElement) observer.observe(el.parentElement);
|
|
4232
|
+
return () => observer.disconnect();
|
|
4233
|
+
}, [ref, text]);
|
|
4234
|
+
}
|
|
4235
|
+
function useGroupedAmountInput(amount, onAmount) {
|
|
4236
|
+
const caret = react.useRef(null);
|
|
4237
|
+
const [, rerender] = react.useReducer((n) => n + 1, 0);
|
|
4238
|
+
react.useLayoutEffect(() => {
|
|
4239
|
+
const pending = caret.current;
|
|
4240
|
+
caret.current = null;
|
|
4241
|
+
if (pending === null || pending.input !== document.activeElement) return;
|
|
4242
|
+
const at = groupedAmountCaret(pending.input.value, pending.kept);
|
|
4243
|
+
pending.input.setSelectionRange(at, at);
|
|
4244
|
+
});
|
|
4245
|
+
const onChange = (e) => {
|
|
4246
|
+
const input = e.target;
|
|
4247
|
+
const raw = input.value;
|
|
4248
|
+
caret.current = { input, kept: sanitizeAmount(raw.slice(0, input.selectionEnd ?? raw.length)).length };
|
|
4249
|
+
onAmount(sanitizeAmount(raw));
|
|
4250
|
+
rerender();
|
|
4251
|
+
};
|
|
4252
|
+
const onKeyDown = (e) => {
|
|
4253
|
+
const input = e.currentTarget;
|
|
4254
|
+
const at = input.selectionStart;
|
|
4255
|
+
if (at === null || at !== input.selectionEnd) return;
|
|
4256
|
+
if (e.key === "Backspace" && input.value[at - 1] === ",") input.setSelectionRange(at - 1, at - 1);
|
|
4257
|
+
else if (e.key === "Delete" && input.value[at] === ",") input.setSelectionRange(at + 1, at + 1);
|
|
4258
|
+
};
|
|
4259
|
+
return { value: groupAmountInput(amount), onChange, onKeyDown };
|
|
4260
|
+
}
|
|
4137
4261
|
var SOURCE_CHAIN_LABELS = {
|
|
4138
4262
|
1: "Ethereum",
|
|
4139
4263
|
10: "Optimism",
|
|
@@ -4187,17 +4311,22 @@ function Select(props) {
|
|
|
4187
4311
|
] }) });
|
|
4188
4312
|
}
|
|
4189
4313
|
function AmountInput(props) {
|
|
4314
|
+
const grouped = useGroupedAmountInput(props.value, props.onChange);
|
|
4315
|
+
const field = react.useRef(null);
|
|
4316
|
+
useFitText(field, grouped.value);
|
|
4190
4317
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4191
4318
|
"input",
|
|
4192
4319
|
{
|
|
4320
|
+
ref: field,
|
|
4193
4321
|
className: "sg-input sg-amount sg-mono",
|
|
4194
4322
|
inputMode: "decimal",
|
|
4195
4323
|
placeholder: props.placeholder ?? "0.0",
|
|
4196
|
-
value:
|
|
4324
|
+
value: grouped.value,
|
|
4197
4325
|
disabled: props.disabled,
|
|
4198
4326
|
"aria-invalid": props.invalid || void 0,
|
|
4199
4327
|
"aria-describedby": props.describedBy,
|
|
4200
|
-
onChange:
|
|
4328
|
+
onChange: grouped.onChange,
|
|
4329
|
+
onKeyDown: grouped.onKeyDown
|
|
4201
4330
|
}
|
|
4202
4331
|
);
|
|
4203
4332
|
}
|
|
@@ -4623,11 +4752,11 @@ function QuoteGlyph({ size = 16 }) {
|
|
|
4623
4752
|
)
|
|
4624
4753
|
] });
|
|
4625
4754
|
}
|
|
4626
|
-
function AmountText({ value, suffix }) {
|
|
4627
|
-
const dot = value.indexOf(".");
|
|
4755
|
+
function AmountText({ value, suffix, exact }) {
|
|
4756
|
+
const dot = value.startsWith("<") ? -1 : value.indexOf(".");
|
|
4628
4757
|
const whole = dot < 0 ? value : value.slice(0, dot + 1);
|
|
4629
4758
|
const decimals = dot < 0 ? "" : value.slice(dot + 1);
|
|
4630
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-amt", children: [
|
|
4759
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-amt", title: exact === void 0 ? void 0 : exactAmountTitle(exact, value), children: [
|
|
4631
4760
|
whole,
|
|
4632
4761
|
decimals ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-amt-dec", children: decimals }) : null,
|
|
4633
4762
|
suffix ? ` ${suffix}` : null
|
|
@@ -6553,7 +6682,7 @@ function PayCard(props) {
|
|
|
6553
6682
|
setSheet(false);
|
|
6554
6683
|
requestAnimationFrame(() => complianceBtnRef.current?.focus());
|
|
6555
6684
|
};
|
|
6556
|
-
const payLabel = parked ? "Coming soon" : submitting ? "Paying\u2026" : flow.insufficient ? "Insufficient balance" : flow.nativeShortfall ? flow.nativeShortfall : sel && selectedVisible ? `Pay ${atLeastCents(sel.source.payAmount)} ${sel.source.ticker || sel.source.asset}` : "Pay";
|
|
6685
|
+
const payLabel = parked ? "Coming soon" : submitting ? "Paying\u2026" : flow.insufficient ? "Insufficient balance" : flow.nativeShortfall ? flow.nativeShortfall : sel && selectedVisible ? `Pay ${groupDecimal(atLeastCents(sel.source.payAmount))} ${sel.source.ticker || sel.source.asset}` : "Pay";
|
|
6557
6686
|
const walletSlot = wallet.account ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-head-tools", children: [
|
|
6558
6687
|
/* @__PURE__ */ jsxRuntime.jsx(HistoryButton, { btnRef: histBtnRef, disabled: submitting, onClick: () => setHist({}) }),
|
|
6559
6688
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-wallet", "data-connected": "true", children: [
|
|
@@ -6605,7 +6734,7 @@ function PayCard(props) {
|
|
|
6605
6734
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-pane", "data-kind": "pay", children: [
|
|
6606
6735
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pane-label", children: "You pay" }),
|
|
6607
6736
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-pane-mid", children: [
|
|
6608
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-amt-out", "aria-live": "polite", children: loadingPlan ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-amt-empty", children: "\u2026" }) : sel && selectedVisible ? /* @__PURE__ */ jsxRuntime.jsx(AmountText, { value: atLeastCents(sel.source.payAmount) }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-amt-empty", children: "\u2014" }) }),
|
|
6737
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-amt-out", "aria-live": "polite", children: loadingPlan ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-amt-empty", children: "\u2026" }) : sel && selectedVisible ? /* @__PURE__ */ jsxRuntime.jsx(AmountText, { value: groupDecimal(atLeastCents(sel.source.payAmount)) }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-amt-empty", children: "\u2014" }) }),
|
|
6609
6738
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6610
6739
|
TokenButton,
|
|
6611
6740
|
{
|
|
@@ -6930,6 +7059,15 @@ function ExchangeCard(props) {
|
|
|
6930
7059
|
() => props.defaultToChainId && props.defaultToAsset ? { chainId: props.defaultToChainId, symbol: symbolKey(props.defaultToAsset) } : null
|
|
6931
7060
|
);
|
|
6932
7061
|
const [amount, setAmount] = react.useState(props.defaultAmount ?? "");
|
|
7062
|
+
const onInputChange = react.useRef(props.onInputChange);
|
|
7063
|
+
onInputChange.current = props.onInputChange;
|
|
7064
|
+
const fromChainId = from?.chainId ?? null;
|
|
7065
|
+
const fromSymbol = from?.symbol ?? null;
|
|
7066
|
+
const toChainId = to?.chainId ?? null;
|
|
7067
|
+
const toSymbolKey = to?.symbol ?? null;
|
|
7068
|
+
react.useEffect(() => {
|
|
7069
|
+
onInputChange.current?.({ fromChainId, fromAsset: fromSymbol, toChainId, toAsset: toSymbolKey, amount });
|
|
7070
|
+
}, [fromChainId, fromSymbol, toChainId, toSymbolKey, amount]);
|
|
6933
7071
|
const [fiatCurrency, setFiatCurrency] = react.useState(props.fiatCurrency ?? "EUR");
|
|
6934
7072
|
const fromToken = react.useMemo(() => from ? findToken(tokens, from.chainId, from.symbol) : null, [tokens, from]);
|
|
6935
7073
|
const toToken = react.useMemo(() => to ? findToken(tokens, to.chainId, to.symbol) : null, [tokens, to]);
|
|
@@ -7067,6 +7205,18 @@ function ExchangeCard(props) {
|
|
|
7067
7205
|
const amountError = overLimit && laneLimit ? laneLimitError(laneLimit, limitSymbol) : gatewayAmountError;
|
|
7068
7206
|
const amountNote = mode === "exchange" ? amountError || (laneLimit ? laneLimitHint(laneLimit, limitSymbol) : null) : null;
|
|
7069
7207
|
const receive = connected ? flow.selected?.receive.amount : preview.data?.receive;
|
|
7208
|
+
const receiveOutRef = react.useRef(null);
|
|
7209
|
+
const receiveSideRef = react.useRef(null);
|
|
7210
|
+
const receiveShown = `${receive ?? ""}|${quoting}|${toTicker}`;
|
|
7211
|
+
useFitText(receiveOutRef, receiveShown);
|
|
7212
|
+
useFitText(receiveSideRef, receiveShown);
|
|
7213
|
+
const toDecimals = react.useMemo(() => {
|
|
7214
|
+
try {
|
|
7215
|
+
return toToken ? assetDecimals(toToken) : void 0;
|
|
7216
|
+
} catch {
|
|
7217
|
+
return void 0;
|
|
7218
|
+
}
|
|
7219
|
+
}, [toToken]);
|
|
7070
7220
|
const meta = connected ? flow.selected ? { bridge: flow.selected.quote.bridge || "ZeroDelta", feeBps: Number(flow.selected.quote.feeBps || 0), duration: Number(flow.selected.quote.estimatedDuration || 0) } : null : preview.data ? { bridge: preview.data.bridge || "ZeroDelta", feeBps: preview.data.feeBps, duration: preview.data.estimatedDuration } : null;
|
|
7071
7221
|
const pct = (p) => {
|
|
7072
7222
|
if (!fromBal || !fromToken) return;
|
|
@@ -7260,7 +7410,7 @@ function ExchangeCard(props) {
|
|
|
7260
7410
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-pane", "data-kind": "receive", children: [
|
|
7261
7411
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pane-label", children: product === "rwa" ? "You receive (estimated)" : "You receive" }),
|
|
7262
7412
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-pane-mid", children: [
|
|
7263
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-amt-out", "aria-live": "polite", children: rampMode ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-amt-empty", children: "\u2014" }) : quoting ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-amt-empty", children: "\u2026" }) : receive && quotable && !quoteError ? /* @__PURE__ */ jsxRuntime.jsx(AmountText, { value: receive }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-amt-empty", children: "0" }) }),
|
|
7413
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-amt-out", "aria-live": "polite", ref: receiveOutRef, children: rampMode ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-amt-empty", children: "\u2014" }) : quoting ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-amt-empty", children: "\u2026" }) : receive && quotable && !quoteError ? /* @__PURE__ */ jsxRuntime.jsx(AmountText, { value: formatCalculatedAmount(receive, toDecimals), exact: receive }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-amt-empty", children: "0" }) }),
|
|
7264
7414
|
receiveToken
|
|
7265
7415
|
] }),
|
|
7266
7416
|
/* @__PURE__ */ jsxRuntime.jsx(PaneFoot, { usd: hasQuote ? toUsd : null })
|
|
@@ -7321,7 +7471,7 @@ function ExchangeCard(props) {
|
|
|
7321
7471
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-recv", children: [
|
|
7322
7472
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-recv-line", children: [
|
|
7323
7473
|
/* @__PURE__ */ jsxRuntime.jsx(TokenGlyph, { symbol: to?.symbol ?? "", logoUrl: toToken?.logoUrl, chainId: to?.chainId, size: "xs" }),
|
|
7324
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-recv-amt", children: /* @__PURE__ */ jsxRuntime.jsx(AmountText, { value: receive, suffix: toTicker }) })
|
|
7474
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-recv-amt", ref: receiveSideRef, children: /* @__PURE__ */ jsxRuntime.jsx(AmountText, { value: formatCalculatedAmount(receive, toDecimals), exact: receive, suffix: toTicker }) })
|
|
7325
7475
|
] }),
|
|
7326
7476
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-recv-sub", children: [
|
|
7327
7477
|
"On ",
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { B as BankPayoutAccount, E as Eip1193Provider, a as ExchangeMode, L as LinkIdentity, M as MountConfig, P as PaymentIsland,
|
|
1
|
+
export { B as BankPayoutAccount, E as Eip1193Provider, a as ExchangeInput, b as ExchangeMode, L as LinkIdentity, M as MountConfig, P as PaymentIsland, c as PaymentIslandKind, d as PaymentIslandProps, e as PillOpenAs, S as SettlementMethod, f as StableGenieConfig, g as StableGenieExchange, h as StableGenieExchangeProps, i as StableGeniePay, j as StableGeniePayProps, k as StableGenieProvider, l as StableGenieRwaExchange, m as StableGenieSwap, n as StableGenieSwapProps, o as StableGenieTheme, p as SuccessInfo, q as SupportedAsset, r as darkTheme, s as lightTheme, t as mount, u as resolveTheme } from './mount-Dxsc7-Fb.cjs';
|
|
2
2
|
import * as react from 'react';
|
|
3
3
|
import { C as Compliance } from './verify-BEQ8DMvJ.cjs';
|
|
4
4
|
export { A as Availability, B as BrokenLane, a as Catalogue, b as Chain, c as ComplianceCheck, d as ComplianceTone, e as ComplianceView, E as EngineConfig, f as ExchangeProduct, L as LaneLimit, P as Plan, R as Route, g as RouteLeg, h as RouteResult, S as SanitizedTxEntry, T as Token, i as TxHistoryEntry, V as VerifyResult, W as WalletScreen, j as assetClassOf, k as brokenLaneReason, l as complianceChecks, m as complianceControlsLine, n as complianceView, o as counterpartTokens, p as destinationAvailability, q as humanizeComplianceReason } from './verify-BEQ8DMvJ.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { B as BankPayoutAccount, E as Eip1193Provider, a as ExchangeMode, L as LinkIdentity, M as MountConfig, P as PaymentIsland,
|
|
1
|
+
export { B as BankPayoutAccount, E as Eip1193Provider, a as ExchangeInput, b as ExchangeMode, L as LinkIdentity, M as MountConfig, P as PaymentIsland, c as PaymentIslandKind, d as PaymentIslandProps, e as PillOpenAs, S as SettlementMethod, f as StableGenieConfig, g as StableGenieExchange, h as StableGenieExchangeProps, i as StableGeniePay, j as StableGeniePayProps, k as StableGenieProvider, l as StableGenieRwaExchange, m as StableGenieSwap, n as StableGenieSwapProps, o as StableGenieTheme, p as SuccessInfo, q as SupportedAsset, r as darkTheme, s as lightTheme, t as mount, u as resolveTheme } from './mount-LkKQjoZU.js';
|
|
2
2
|
import * as react from 'react';
|
|
3
3
|
import { C as Compliance } from './verify-BEQ8DMvJ.js';
|
|
4
4
|
export { A as Availability, B as BrokenLane, a as Catalogue, b as Chain, c as ComplianceCheck, d as ComplianceTone, e as ComplianceView, E as EngineConfig, f as ExchangeProduct, L as LaneLimit, P as Plan, R as Route, g as RouteLeg, h as RouteResult, S as SanitizedTxEntry, T as Token, i as TxHistoryEntry, V as VerifyResult, W as WalletScreen, j as assetClassOf, k as brokenLaneReason, l as complianceChecks, m as complianceControlsLine, n as complianceView, o as counterpartTokens, p as destinationAvailability, q as humanizeComplianceReason } from './verify-BEQ8DMvJ.js';
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { CompliancePanel, PaymentIsland, StableGenieExchange, StableGeniePay, StableGenieProvider, StableGenieRwaExchange, StableGenieSwap, darkTheme, lightTheme, mount, resolveTheme } from './chunk-
|
|
2
|
-
export { EXECUTABLE_STABLE_ASSETS, STABLE_ASSETS, SUPPORTED_ASSETS, SUPPORTED_CHAIN_IDS, TRADEABLE_RWA_ASSETS, assetClassOf, brokenLaneReason, complianceChecks, complianceControlsLine, complianceView, counterpartTokens, createEngine, destinationAvailability, humanizeComplianceReason, symbolKey } from './chunk-
|
|
1
|
+
export { CompliancePanel, PaymentIsland, StableGenieExchange, StableGeniePay, StableGenieProvider, StableGenieRwaExchange, StableGenieSwap, darkTheme, lightTheme, mount, resolveTheme } from './chunk-2TCYBOYW.js';
|
|
2
|
+
export { EXECUTABLE_STABLE_ASSETS, STABLE_ASSETS, SUPPORTED_ASSETS, SUPPORTED_CHAIN_IDS, TRADEABLE_RWA_ASSETS, assetClassOf, brokenLaneReason, complianceChecks, complianceControlsLine, complianceView, counterpartTokens, createEngine, destinationAvailability, humanizeComplianceReason, symbolKey } from './chunk-F46VMTTL.js';
|
|
@@ -81,6 +81,15 @@ declare function StableGenieProvider({ children, ...config }: StableGenieConfig
|
|
|
81
81
|
type PillOpenAs = "modal" | "drawer";
|
|
82
82
|
|
|
83
83
|
type ExchangeMode = "exchange" | "onramp" | "offramp";
|
|
84
|
+
/** What the exchange card currently holds — see `onInputChange`. */
|
|
85
|
+
interface ExchangeInput {
|
|
86
|
+
fromChainId: number | null;
|
|
87
|
+
/** The asset's upper-cased symbol key (`"USDC"`, `"USDE"`), as `defaultFromAsset` takes it. */
|
|
88
|
+
fromAsset: string | null;
|
|
89
|
+
toChainId: number | null;
|
|
90
|
+
toAsset: string | null;
|
|
91
|
+
amount: string;
|
|
92
|
+
}
|
|
84
93
|
interface StableGenieExchangeProps extends StableGenieConfig {
|
|
85
94
|
mode?: ExchangeMode;
|
|
86
95
|
/**
|
|
@@ -111,6 +120,16 @@ interface StableGenieExchangeProps extends StableGenieConfig {
|
|
|
111
120
|
defaultToChainId?: number;
|
|
112
121
|
defaultToAsset?: SupportedAsset;
|
|
113
122
|
defaultAmount?: string;
|
|
123
|
+
/**
|
|
124
|
+
* Called with the pair and amount on the card whenever any of them changes — a token picked, the
|
|
125
|
+
* direction flipped, the amount typed — and once on mount with what the card started on.
|
|
126
|
+
*
|
|
127
|
+
* The `default*` props only SEED the card; after that the card owns its state. A host that shows
|
|
128
|
+
* the same pair somewhere else (a configurator, a summary, a URL) needs this to follow the card,
|
|
129
|
+
* or the two drift apart the first time the user touches it. `amount` is the bare number as typed
|
|
130
|
+
* (`"1234.5"`), never the grouped text on screen. A leg is `null` until the card has one.
|
|
131
|
+
*/
|
|
132
|
+
onInputChange?: (input: ExchangeInput) => void;
|
|
114
133
|
/** Optional explicit receiver (defaults to the payer). */
|
|
115
134
|
recipient?: string;
|
|
116
135
|
/** Default fiat currency for the on/off-ramp modes. */
|
|
@@ -260,4 +279,4 @@ type MountConfig = ({
|
|
|
260
279
|
/** Imperatively mount a widget into an element (for non-JSX / vanilla React hosts). Returns unmount. */
|
|
261
280
|
declare function mount(el: HTMLElement, config: MountConfig): () => void;
|
|
262
281
|
|
|
263
|
-
export { type BankPayoutAccount as B, type Eip1193Provider as E, type LinkIdentity as L, type MountConfig as M, PaymentIsland as P, type SettlementMethod as S, type
|
|
282
|
+
export { type BankPayoutAccount as B, type Eip1193Provider as E, type LinkIdentity as L, type MountConfig as M, PaymentIsland as P, type SettlementMethod as S, type ExchangeInput as a, type ExchangeMode as b, type PaymentIslandKind as c, type PaymentIslandProps as d, type PillOpenAs as e, type StableGenieConfig as f, StableGenieExchange as g, type StableGenieExchangeProps as h, StableGeniePay as i, type StableGeniePayProps as j, StableGenieProvider as k, StableGenieRwaExchange as l, StableGenieSwap as m, type StableGenieSwapProps as n, type StableGenieTheme as o, type SuccessInfo as p, type SupportedAsset as q, darkTheme as r, lightTheme as s, mount as t, resolveTheme as u };
|