@glacislabs/stablegenie-zerodelta 4.2.0 → 4.3.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-ZBUK7ULN.js → chunk-PMVF6A2D.js} +125 -11
- package/dist/{chunk-KETGKV7Y.js → chunk-RFBNRCFB.js} +115 -31
- package/dist/core/index.cjs +133 -10
- package/dist/core/index.d.cts +2 -2
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.js +1 -1
- package/dist/index.cjs +238 -40
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/{mount-Bver3O2z.d.ts → mount-BX_B0fzO.d.ts} +1 -1
- package/dist/{mount-Dtbtdry1.d.cts → mount-Dw3LvQZi.d.cts} +1 -1
- package/dist/mount.cjs +238 -40
- 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 -6
- package/dist/{verify-57gjg_dM.d.cts → verify-CPaT8Upe.d.cts} +146 -9
- package/dist/{verify-57gjg_dM.d.ts → verify-CPaT8Upe.d.ts} +146 -9
- package/package.json +1 -1
package/dist/mount.cjs
CHANGED
|
@@ -565,6 +565,10 @@ function brokenLaneFor(token, source, brokenLanes) {
|
|
|
565
565
|
if (!source || !brokenLanes) return void 0;
|
|
566
566
|
return brokenLanes.get(laneKey(source.chainId, source.address, token.chainId, token.address));
|
|
567
567
|
}
|
|
568
|
+
function laneLimitFor(token, source, limitedLanes2) {
|
|
569
|
+
if (!source || !limitedLanes2) return void 0;
|
|
570
|
+
return limitedLanes2.get(laneKey(source.chainId, source.address, token.chainId, token.address));
|
|
571
|
+
}
|
|
568
572
|
function destinationAvailability(token, ctx, source) {
|
|
569
573
|
if (brokenLaneFor(token, source ?? void 0, ctx.brokenLanes)) return "unreachable";
|
|
570
574
|
if (directLaneOK(token, source ?? void 0, ctx.lanes)) {
|
|
@@ -620,7 +624,17 @@ function buildCatalogue(input) {
|
|
|
620
624
|
);
|
|
621
625
|
const byId = new Map(enabledChains.map((c) => [Number(c.chainId), c]));
|
|
622
626
|
for (const id of chainIds) if (!byId.has(id)) byId.set(id, { chainId: id, isEnabled: true });
|
|
623
|
-
return {
|
|
627
|
+
return {
|
|
628
|
+
...ctx,
|
|
629
|
+
product,
|
|
630
|
+
tokens: catalogue,
|
|
631
|
+
sources,
|
|
632
|
+
chainIds,
|
|
633
|
+
chains: [...byId.values()],
|
|
634
|
+
ready,
|
|
635
|
+
vaultIcons: input.vaultIcons ?? /* @__PURE__ */ new Map(),
|
|
636
|
+
limitedLanes: input.limitedLanes ?? /* @__PURE__ */ new Map()
|
|
637
|
+
};
|
|
624
638
|
}
|
|
625
639
|
|
|
626
640
|
// src/core/options.ts
|
|
@@ -755,23 +769,89 @@ function nativeFeeShortMessage(check, symbol, chainName3) {
|
|
|
755
769
|
|
|
756
770
|
// src/core/route-health.ts
|
|
757
771
|
var EMPTY = /* @__PURE__ */ new Map();
|
|
772
|
+
var NO_LIMITS = /* @__PURE__ */ new Map();
|
|
773
|
+
function laneAvailabilityState(lane) {
|
|
774
|
+
const availability = lane?.availability;
|
|
775
|
+
if (!availability || typeof availability !== "object") return null;
|
|
776
|
+
const state = availability.state;
|
|
777
|
+
return state === "available" || state === "limited" || state === "unavailable" ? state : null;
|
|
778
|
+
}
|
|
779
|
+
function isSuppressed(lane) {
|
|
780
|
+
const state = laneAvailabilityState(lane);
|
|
781
|
+
if (state) return state === "unavailable";
|
|
782
|
+
const firewalled = lane.status === "unknown" && lane.kind === "firewalled";
|
|
783
|
+
return lane.status === "broken" || firewalled;
|
|
784
|
+
}
|
|
758
785
|
function suppressedLanes(health) {
|
|
759
786
|
if (health?.mode !== "enforce" || !Array.isArray(health.lanes)) return EMPTY;
|
|
760
787
|
const out = /* @__PURE__ */ new Map();
|
|
761
788
|
for (const lane of health.lanes) {
|
|
762
|
-
|
|
763
|
-
if (lane?.status !== "broken" && !firewalled) continue;
|
|
789
|
+
if (!lane || typeof lane !== "object" || !isSuppressed(lane)) continue;
|
|
764
790
|
const key = typeof lane.laneKey === "string" ? lane.laneKey.toLowerCase() : "";
|
|
765
791
|
if (!key) continue;
|
|
792
|
+
const availability = laneAvailabilityState(lane) ? lane.availability : void 0;
|
|
793
|
+
const code = typeof availability?.code === "string" && availability.code ? availability.code : lane.code;
|
|
794
|
+
const message = typeof availability?.message === "string" && availability.message ? availability.message : lane.message;
|
|
766
795
|
out.set(key, {
|
|
767
796
|
route: typeof lane.route === "string" ? lane.route : "",
|
|
768
|
-
code: typeof
|
|
769
|
-
message: typeof
|
|
797
|
+
code: typeof code === "string" ? code : "",
|
|
798
|
+
message: typeof message === "string" ? message : "",
|
|
770
799
|
...typeof lane.kind === "string" ? { kind: lane.kind } : {}
|
|
771
800
|
});
|
|
772
801
|
}
|
|
773
802
|
return out;
|
|
774
803
|
}
|
|
804
|
+
var BASE_UNITS = /^\d{1,78}$/;
|
|
805
|
+
function limitedLanes(health) {
|
|
806
|
+
if (health?.mode !== "enforce" || !Array.isArray(health.lanes)) return NO_LIMITS;
|
|
807
|
+
const out = /* @__PURE__ */ new Map();
|
|
808
|
+
for (const lane of health.lanes) {
|
|
809
|
+
if (!lane || typeof lane !== "object" || laneAvailabilityState(lane) !== "limited") continue;
|
|
810
|
+
const key = typeof lane.laneKey === "string" ? lane.laneKey.toLowerCase() : "";
|
|
811
|
+
const limit = lane.availability?.limit;
|
|
812
|
+
if (!key || !limit || typeof limit !== "object") continue;
|
|
813
|
+
const side = limit.side === "bid" || limit.side === "ask" ? limit.side : null;
|
|
814
|
+
const maxAmount = typeof limit.maxAmount === "string" ? limit.maxAmount.trim() : "";
|
|
815
|
+
const decimals = limit.decimals;
|
|
816
|
+
if (!side || !BASE_UNITS.test(maxAmount) || typeof decimals !== "number" || !Number.isInteger(decimals) || decimals < 0 || decimals > 36) continue;
|
|
817
|
+
const code = lane.availability?.code;
|
|
818
|
+
out.set(key, {
|
|
819
|
+
side,
|
|
820
|
+
token: typeof limit.token === "string" ? limit.token : "",
|
|
821
|
+
fromChainId: Number(limit.fromChainId) || 0,
|
|
822
|
+
toChainId: Number(limit.toChainId) || 0,
|
|
823
|
+
maxAmount,
|
|
824
|
+
decimals,
|
|
825
|
+
code: typeof code === "string" ? code : "",
|
|
826
|
+
...typeof limit.measuredAt === "string" ? { measuredAt: limit.measuredAt } : {}
|
|
827
|
+
});
|
|
828
|
+
}
|
|
829
|
+
return out;
|
|
830
|
+
}
|
|
831
|
+
function exceedsLaneLimit(limit, amount, bidDecimals) {
|
|
832
|
+
if (limit?.side !== "bid" || !BASE_UNITS.test(limit.maxAmount)) return false;
|
|
833
|
+
let raw;
|
|
834
|
+
try {
|
|
835
|
+
raw = parseUnitsDecimal(amount, bidDecimals);
|
|
836
|
+
} catch {
|
|
837
|
+
return false;
|
|
838
|
+
}
|
|
839
|
+
const scale = Math.max(bidDecimals, limit.decimals);
|
|
840
|
+
return scaleDecimals(raw, bidDecimals, scale) > scaleDecimals(BigInt(limit.maxAmount), limit.decimals, scale);
|
|
841
|
+
}
|
|
842
|
+
function laneLimitAmount(limit) {
|
|
843
|
+
return formatUnits(limit.maxAmount, limit.decimals);
|
|
844
|
+
}
|
|
845
|
+
function laneLimitSymbol(limit, bidTicker) {
|
|
846
|
+
if (limit.side === "bid" && bidTicker) return bidTicker;
|
|
847
|
+
return safeTicker(limit.token, limit.token);
|
|
848
|
+
}
|
|
849
|
+
function laneLimitHint(limit, symbol) {
|
|
850
|
+
return `Max ${laneLimitAmount(limit)}${symbol ? ` ${symbol}` : ""} right now`;
|
|
851
|
+
}
|
|
852
|
+
function laneLimitError(limit, symbol) {
|
|
853
|
+
return `Maximum: ${laneLimitAmount(limit)}${symbol ? ` ${symbol}` : ""} right now`;
|
|
854
|
+
}
|
|
775
855
|
function brokenLaneReason(lane) {
|
|
776
856
|
if (!lane) return "";
|
|
777
857
|
switch (lane.kind) {
|
|
@@ -1650,15 +1730,25 @@ function classifyQuoteError(error) {
|
|
|
1650
1730
|
message: `This payment was blocked by compliance screening \u2014 the recipient is ${label}. Choose a different recipient or connect a different wallet.`
|
|
1651
1731
|
};
|
|
1652
1732
|
}
|
|
1733
|
+
function amountFieldError(error) {
|
|
1734
|
+
const fieldErrors = error?.fieldErrors;
|
|
1735
|
+
if (!Array.isArray(fieldErrors)) return null;
|
|
1736
|
+
const entry = fieldErrors.find((e) => e && typeof e === "object" && e.field === "fromAmount" && typeof e.message === "string");
|
|
1737
|
+
const message = entry ? sanitizeMessage(entry.message, "") : "";
|
|
1738
|
+
return message || null;
|
|
1739
|
+
}
|
|
1653
1740
|
function nowFresh(entry) {
|
|
1654
1741
|
return !!entry && Date.now() - entry.at < API_CACHE_TTL_MS;
|
|
1655
1742
|
}
|
|
1656
1743
|
function isTransientQuoteError(error) {
|
|
1744
|
+
if (error?.code === "BRIDGE_RATE_LIMITED" || Array.isArray(error?.fieldErrors) && error.fieldErrors.length > 0) return false;
|
|
1657
1745
|
return error?.code === "gateway_timeout" || error?.status === 502 || error?.status === 503 || error?.status === 504 || /failed to get swap quote|timeout|temporar/i.test(error?.message || "");
|
|
1658
1746
|
}
|
|
1659
1747
|
function wait(ms) {
|
|
1660
1748
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
1661
1749
|
}
|
|
1750
|
+
var PAGE_LIMIT = 500;
|
|
1751
|
+
var MAX_PAGES = 10;
|
|
1662
1752
|
function createApiClient(cfg) {
|
|
1663
1753
|
const cache = {
|
|
1664
1754
|
chains: null,
|
|
@@ -1670,7 +1760,7 @@ function createApiClient(cfg) {
|
|
|
1670
1760
|
const screenCache = /* @__PURE__ */ new Map();
|
|
1671
1761
|
const screenInflight = /* @__PURE__ */ new Map();
|
|
1672
1762
|
const apiBase = cfg.apiBase.replace(/\/$/, "");
|
|
1673
|
-
async function
|
|
1763
|
+
async function requestJson(path, init = {}) {
|
|
1674
1764
|
const apiKey = await cfg.getApiKey();
|
|
1675
1765
|
const headers = { "Content-Type": "application/json", ...init.headers || {} };
|
|
1676
1766
|
if (apiKey) headers["x-api-key"] = apiKey;
|
|
@@ -1703,11 +1793,34 @@ function createApiClient(cfg) {
|
|
|
1703
1793
|
status: response.status,
|
|
1704
1794
|
code: json?.error?.code || json?.code || (response.status >= 502 ? "gateway_timeout" : "api_error"),
|
|
1705
1795
|
fieldErrors: json?.error?.fieldErrors || json?.fieldErrors,
|
|
1796
|
+
limits: json?.error?.limits || json?.limits,
|
|
1706
1797
|
reasons: json?.error?.reasons || json?.reasons
|
|
1707
1798
|
});
|
|
1708
1799
|
}
|
|
1800
|
+
return json;
|
|
1801
|
+
}
|
|
1802
|
+
async function apiRequest(path, init = {}) {
|
|
1803
|
+
const json = await requestJson(path, init);
|
|
1709
1804
|
return json?.data ?? json;
|
|
1710
1805
|
}
|
|
1806
|
+
async function requestAllPages(path) {
|
|
1807
|
+
const rows = [];
|
|
1808
|
+
let firstRow = "";
|
|
1809
|
+
for (let page = 0; page < MAX_PAGES; page += 1) {
|
|
1810
|
+
const json = await requestJson(`${path}${toQuery({ limit: PAGE_LIMIT, offset: rows.length || void 0 })}`);
|
|
1811
|
+
const envelope = json && !Array.isArray(json) ? json : {};
|
|
1812
|
+
const data = Array.isArray(json) ? json : envelope.data;
|
|
1813
|
+
const pageRows = Array.isArray(data) ? data : [];
|
|
1814
|
+
const head = pageRows.length ? JSON.stringify(pageRows[0]) : "";
|
|
1815
|
+
if (page === 0) firstRow = head;
|
|
1816
|
+
else if (head && head === firstRow) throw apiError(`ZeroDelta paging ignored the offset (${path}, offset ${rows.length}).`, { code: "bad_response" });
|
|
1817
|
+
rows.push(...pageRows);
|
|
1818
|
+
const total = envelope.meta?.totalCount;
|
|
1819
|
+
if (!envelope.paging?.next || typeof total === "number" && rows.length >= total) return rows;
|
|
1820
|
+
if (!pageRows.length) throw apiError(`ZeroDelta paging did not advance (${path}, offset ${rows.length}).`, { code: "bad_response" });
|
|
1821
|
+
}
|
|
1822
|
+
throw apiError(`ZeroDelta still had rows after ${MAX_PAGES} pages (${path}).`, { code: "bad_response" });
|
|
1823
|
+
}
|
|
1711
1824
|
async function fetchChains() {
|
|
1712
1825
|
if (nowFresh(cache.chains)) return cache.chains.value;
|
|
1713
1826
|
const chains = await apiRequest(`/chains${toQuery({ enabledOnly: true, limit: 500 })}`);
|
|
@@ -1720,16 +1833,15 @@ function createApiClient(cfg) {
|
|
|
1720
1833
|
}
|
|
1721
1834
|
async function fetchTokens() {
|
|
1722
1835
|
if (nowFresh(cache.tokens)) return cache.tokens.value;
|
|
1723
|
-
const tokens = await
|
|
1724
|
-
const normalized =
|
|
1836
|
+
const tokens = await requestAllPages("/tokens");
|
|
1837
|
+
const normalized = tokens.map((token) => ({ ...token, chainId: Number(token.chainId) }));
|
|
1725
1838
|
cache.tokens = { at: Date.now(), value: normalized };
|
|
1726
1839
|
return normalized;
|
|
1727
1840
|
}
|
|
1728
1841
|
async function fetchRoutes() {
|
|
1729
1842
|
if (nowFresh(cache.routes)) return cache.routes.value;
|
|
1730
1843
|
try {
|
|
1731
|
-
const
|
|
1732
|
-
const normalized = Array.isArray(routes) ? routes : [];
|
|
1844
|
+
const normalized = await requestAllPages("/routes");
|
|
1733
1845
|
cache.routes = { at: Date.now(), value: normalized };
|
|
1734
1846
|
return normalized;
|
|
1735
1847
|
} catch {
|
|
@@ -2470,6 +2582,8 @@ function createEngine(config = {}) {
|
|
|
2470
2582
|
...allowed ? { allowedAssets: allowed } : {},
|
|
2471
2583
|
supportedChainIds: SUPPORTED_CHAIN_IDS,
|
|
2472
2584
|
brokenLanes: suppressedLanes(health),
|
|
2585
|
+
// Same read, same degraded mode: a null health response limits nothing.
|
|
2586
|
+
limitedLanes: limitedLanes(health),
|
|
2473
2587
|
vaultIcons
|
|
2474
2588
|
});
|
|
2475
2589
|
},
|
|
@@ -2771,6 +2885,7 @@ function useFlow(args) {
|
|
|
2771
2885
|
const [plan, setPlan] = react.useState(null);
|
|
2772
2886
|
const [selectedId, setSelectedId] = react.useState(null);
|
|
2773
2887
|
const [error, setError] = react.useState(null);
|
|
2888
|
+
const [fieldError, setFieldError] = react.useState(null);
|
|
2774
2889
|
const [insufficient, setInsufficient] = react.useState(false);
|
|
2775
2890
|
const [nativeShortfall, setNativeShortfall] = react.useState(null);
|
|
2776
2891
|
const [steps, setSteps] = react.useState([]);
|
|
@@ -2785,6 +2900,7 @@ function useFlow(args) {
|
|
|
2785
2900
|
const reload = react.useCallback(() => setNonce((n) => n + 1), []);
|
|
2786
2901
|
react.useEffect(() => {
|
|
2787
2902
|
if (busyRef.current) return;
|
|
2903
|
+
setFieldError(null);
|
|
2788
2904
|
if (!enabled || !wallet.account) {
|
|
2789
2905
|
setStatus("idle");
|
|
2790
2906
|
setPlan(null);
|
|
@@ -2808,6 +2924,7 @@ function useFlow(args) {
|
|
|
2808
2924
|
if (id !== reqId.current) return;
|
|
2809
2925
|
setPlan(null);
|
|
2810
2926
|
setError(e?.message || "Could not price this right now.");
|
|
2927
|
+
setFieldError(amountFieldError(e));
|
|
2811
2928
|
setStatus("error");
|
|
2812
2929
|
onError?.(e instanceof Error ? e : new Error(String(e)));
|
|
2813
2930
|
}
|
|
@@ -2974,6 +3091,7 @@ function useFlow(args) {
|
|
|
2974
3091
|
selected,
|
|
2975
3092
|
selectRoute: setSelectedId,
|
|
2976
3093
|
error,
|
|
3094
|
+
fieldError,
|
|
2977
3095
|
insufficient,
|
|
2978
3096
|
nativeShortfall,
|
|
2979
3097
|
steps,
|
|
@@ -3211,6 +3329,10 @@ img.sg-tok-badge{width:16px;padding:0;object-fit:cover;background:var(--sg-bg)}
|
|
|
3211
3329
|
.sg-send-row{display:flex;align-items:center;gap:12px}
|
|
3212
3330
|
.sg-send-row .sg-amount{flex:1 1 auto;min-width:0}
|
|
3213
3331
|
.sg-send-bal{font-size:11px;color:var(--sg-text-muted);margin-top:6px}
|
|
3332
|
+
/* the line under the amount: a lane's current size limit (muted), or why the amount is refused (danger) */
|
|
3333
|
+
.sg-amount-note{font-size:12px;font-weight:600;line-height:1.35;color:var(--sg-text-muted);margin-top:6px}
|
|
3334
|
+
.sg-amount-note[data-tone="error"]{color:var(--sg-danger)}
|
|
3335
|
+
.sg-amount[aria-invalid="true"]{color:var(--sg-danger)}
|
|
3214
3336
|
.sg-pct-row{display:flex;gap:8px;margin-top:12px}
|
|
3215
3337
|
.sg-pct{flex:1 1 0;padding:7px 0;border-radius:var(--sg-radius-cta);border:1px solid var(--sg-border);background:var(--sg-bg);color:var(--sg-text-muted);font:inherit;font-size:12px;font-weight:600;cursor:pointer;transition:color 120ms ease,border-color 120ms ease}
|
|
3216
3338
|
.sg-pct:hover:not(:disabled){color:var(--sg-accent);border-color:var(--sg-accent)}
|
|
@@ -3252,6 +3374,8 @@ img.sg-tok-badge{width:16px;padding:0;object-fit:cover;background:var(--sg-bg)}
|
|
|
3252
3374
|
.sg-tokrow--off:hover,.sg-tokrow[disabled]:hover{background:transparent}
|
|
3253
3375
|
.sg-tokrow--off .sg-tokrow-sym,.sg-tokrow--off .sg-tokrow-name,.sg-tokrow--off .sg-tokrow-bal{color:var(--sg-text-muted)}
|
|
3254
3376
|
.sg-tokrow-hint{display:block;font-size:11px;font-weight:600;color:var(--sg-danger)}
|
|
3377
|
+
/* on a row that stays selectable (a limited lane): a caveat, not a refusal */
|
|
3378
|
+
.sg-tokrow-hint[data-tone="note"]{color:var(--sg-text-muted)}
|
|
3255
3379
|
.sg-sel-empty{padding:26px 10px;text-align:center;font-size:13px;color:var(--sg-text-muted)}
|
|
3256
3380
|
|
|
3257
3381
|
/* wide (duo) layout: main card + receive/routes side card. The collapse is keyed to the WIDGET'S
|
|
@@ -3788,10 +3912,16 @@ function AmountInput(props) {
|
|
|
3788
3912
|
placeholder: props.placeholder ?? "0.0",
|
|
3789
3913
|
value: props.value,
|
|
3790
3914
|
disabled: props.disabled,
|
|
3915
|
+
"aria-invalid": props.invalid || void 0,
|
|
3916
|
+
"aria-describedby": props.describedBy,
|
|
3791
3917
|
onChange: (e) => props.onChange(e.target.value.replace(/[^0-9.,]/g, ""))
|
|
3792
3918
|
}
|
|
3793
3919
|
);
|
|
3794
3920
|
}
|
|
3921
|
+
function AmountNote(props) {
|
|
3922
|
+
const error = props.tone === "error";
|
|
3923
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { id: props.id, className: "sg-amount-note", "data-tone": error ? "error" : void 0, role: error ? "alert" : void 0, children: props.children });
|
|
3924
|
+
}
|
|
3795
3925
|
function StatusPanel(props) {
|
|
3796
3926
|
const tone = props.tone ?? "neutral";
|
|
3797
3927
|
return (
|
|
@@ -4400,7 +4530,7 @@ function TokenSelect(props) {
|
|
|
4400
4530
|
] }),
|
|
4401
4531
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-tokrow-end", children: [
|
|
4402
4532
|
bal ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tokrow-bal sg-mono", children: bal.formatted }) : null,
|
|
4403
|
-
|
|
4533
|
+
st?.hint ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tokrow-hint", "data-tone": disabled ? void 0 : "note", children: st.hint }) : null,
|
|
4404
4534
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tokrow-chain", children: CHAIN_LABELS[chainId] || `Chain ${chainId}` })
|
|
4405
4535
|
] })
|
|
4406
4536
|
]
|
|
@@ -5004,7 +5134,40 @@ function PaymentIsland(props) {
|
|
|
5004
5134
|
const exToAsset = exTo?.symbol;
|
|
5005
5135
|
const normEx = normalizeDecimalText(exAmount);
|
|
5006
5136
|
const exAmountValid = /^\d+(\.\d+)?$/.test(normEx) && Number(normEx) > 0 && Number(normEx) <= 1e9;
|
|
5007
|
-
const
|
|
5137
|
+
const [catalogue, setCatalogue] = react.useState(null);
|
|
5138
|
+
react.useEffect(() => {
|
|
5139
|
+
if (bankSettlement || !isPay && rampMode) return;
|
|
5140
|
+
let alive = true;
|
|
5141
|
+
engine.fetchCatalogue(isPay ? void 0 : exAllowed, isPay ? "stable" : exProduct).then((next) => {
|
|
5142
|
+
if (alive) setCatalogue(next);
|
|
5143
|
+
});
|
|
5144
|
+
return () => {
|
|
5145
|
+
alive = false;
|
|
5146
|
+
};
|
|
5147
|
+
}, [engine, isPay, rampMode, bankSettlement, exAllowed, exProduct]);
|
|
5148
|
+
const chains = react.useMemo(() => {
|
|
5149
|
+
const order = new Map(SUPPORTED_CHAINS.map((id, i) => [id, i]));
|
|
5150
|
+
return [...catalogue?.chains ?? []].sort((a, b) => (order.get(Number(a.chainId)) ?? 99) - (order.get(Number(b.chainId)) ?? 99) || Number(a.chainId) - Number(b.chainId));
|
|
5151
|
+
}, [catalogue]);
|
|
5152
|
+
const registryTokens = react.useMemo(() => catalogue?.tokens ?? [], [catalogue]);
|
|
5153
|
+
const exchangeTokens = react.useMemo(() => isPay ? [] : registryTokens, [isPay, registryTokens]);
|
|
5154
|
+
const exSourceTokens = react.useMemo(() => isPay ? [] : catalogue?.sources ?? [], [isPay, catalogue]);
|
|
5155
|
+
const exFromToken = react.useMemo(() => exFrom ? findToken(exchangeTokens, exFrom.chainId, exFrom.symbol) : null, [exchangeTokens, exFrom]);
|
|
5156
|
+
const exToToken = react.useMemo(() => exTo ? findToken(exchangeTokens, exTo.chainId, exTo.symbol) : null, [exchangeTokens, exTo]);
|
|
5157
|
+
const exLaneLimit = react.useMemo(
|
|
5158
|
+
() => !isPay && !rampMode && exFromToken && exToToken ? laneLimitFor(exToToken, exFromToken, catalogue?.limitedLanes) : void 0,
|
|
5159
|
+
[isPay, rampMode, catalogue, exFromToken, exToToken]
|
|
5160
|
+
);
|
|
5161
|
+
const exLimitSymbol = exLaneLimit ? laneLimitSymbol(exLaneLimit, exFromToken ? tokenTicker(exFromToken) : void 0) : "";
|
|
5162
|
+
const exOverLimit = react.useMemo(() => {
|
|
5163
|
+
if (!exLaneLimit || !exFromToken || !exAmountValid) return false;
|
|
5164
|
+
try {
|
|
5165
|
+
return exceedsLaneLimit(exLaneLimit, normEx, assetDecimals(exFromToken));
|
|
5166
|
+
} catch {
|
|
5167
|
+
return false;
|
|
5168
|
+
}
|
|
5169
|
+
}, [exLaneLimit, exFromToken, exAmountValid, normEx]);
|
|
5170
|
+
const exQuotable = !rampMode && exAmountValid && !exOverLimit && Boolean(exFromChainId && exFromAsset && exToChainId && exToAsset);
|
|
5008
5171
|
const payFundingAssets = props.fundingAssets?.length ? props.fundingAssets : ["USDC", "USDT", "USDE"];
|
|
5009
5172
|
const payParamsKey = `pay|${props.recipient}|${props.toChainId}|${props.toAsset}|${props.amount}|${payFundingAssets.join(",")}`;
|
|
5010
5173
|
const exParamsKey = `${kind}|${mode}|${exFromChainId}|${exFromAsset}|${exToChainId}|${exToAsset}|${normEx}|${props.recipient ?? ""}`;
|
|
@@ -5088,24 +5251,6 @@ function PaymentIsland(props) {
|
|
|
5088
5251
|
}
|
|
5089
5252
|
return map;
|
|
5090
5253
|
}, [annotated, holdings.loading]);
|
|
5091
|
-
const [catalogue, setCatalogue] = react.useState(null);
|
|
5092
|
-
react.useEffect(() => {
|
|
5093
|
-
if (bankSettlement || !isPay && rampMode) return;
|
|
5094
|
-
let alive = true;
|
|
5095
|
-
engine.fetchCatalogue(isPay ? void 0 : exAllowed, isPay ? "stable" : exProduct).then((next) => {
|
|
5096
|
-
if (alive) setCatalogue(next);
|
|
5097
|
-
});
|
|
5098
|
-
return () => {
|
|
5099
|
-
alive = false;
|
|
5100
|
-
};
|
|
5101
|
-
}, [engine, isPay, rampMode, bankSettlement, exAllowed, exProduct]);
|
|
5102
|
-
const chains = react.useMemo(() => {
|
|
5103
|
-
const order = new Map(SUPPORTED_CHAINS.map((id, i) => [id, i]));
|
|
5104
|
-
return [...catalogue?.chains ?? []].sort((a, b) => (order.get(Number(a.chainId)) ?? 99) - (order.get(Number(b.chainId)) ?? 99) || Number(a.chainId) - Number(b.chainId));
|
|
5105
|
-
}, [catalogue]);
|
|
5106
|
-
const registryTokens = react.useMemo(() => catalogue?.tokens ?? [], [catalogue]);
|
|
5107
|
-
const exchangeTokens = react.useMemo(() => isPay ? [] : registryTokens, [isPay, registryTokens]);
|
|
5108
|
-
const exSourceTokens = react.useMemo(() => isPay ? [] : catalogue?.sources ?? [], [isPay, catalogue]);
|
|
5109
5254
|
const [exBalances, setExBalances] = react.useState({});
|
|
5110
5255
|
const exBalReq = react.useRef(0);
|
|
5111
5256
|
react.useEffect(() => {
|
|
@@ -5125,8 +5270,6 @@ function PaymentIsland(props) {
|
|
|
5125
5270
|
if (id === exBalReq.current) setExBalances(res);
|
|
5126
5271
|
});
|
|
5127
5272
|
}, [engine, isPay, wallet.account, exchangeTokens]);
|
|
5128
|
-
const exFromToken = react.useMemo(() => exFrom ? findToken(exchangeTokens, exFrom.chainId, exFrom.symbol) : null, [exchangeTokens, exFrom]);
|
|
5129
|
-
const exToToken = react.useMemo(() => exTo ? findToken(exchangeTokens, exTo.chainId, exTo.symbol) : null, [exchangeTokens, exTo]);
|
|
5130
5273
|
const exFromPicker = react.useMemo(() => exProduct === "rwa" ? counterpartTokens(exSourceTokens, exToToken) : exSourceTokens, [exProduct, exSourceTokens, exToToken]);
|
|
5131
5274
|
const exToPicker = react.useMemo(() => exProduct === "rwa" ? counterpartTokens(exchangeTokens, exFromToken) : exchangeTokens, [exProduct, exchangeTokens, exFromToken]);
|
|
5132
5275
|
const exRwaSeeded = react.useRef(false);
|
|
@@ -5151,7 +5294,11 @@ function PaymentIsland(props) {
|
|
|
5151
5294
|
continue;
|
|
5152
5295
|
}
|
|
5153
5296
|
const verdict = destinationAvailability(token, catalogue, exFromToken);
|
|
5154
|
-
if (verdict === "available")
|
|
5297
|
+
if (verdict === "available") {
|
|
5298
|
+
const limit = laneLimitFor(token, exFromToken, catalogue.limitedLanes);
|
|
5299
|
+
if (limit) states[key] = { disabled: false, hint: laneLimitHint(limit, laneLimitSymbol(limit, exFromToken ? tokenTicker(exFromToken) : void 0)) };
|
|
5300
|
+
continue;
|
|
5301
|
+
}
|
|
5155
5302
|
states[key] = {
|
|
5156
5303
|
disabled: true,
|
|
5157
5304
|
reason: verdict === "hub-only" ? `${tokenTicker(token)} cannot be delivered on this chain.` : "ZeroDelta cannot deliver this asset here.",
|
|
@@ -5267,6 +5414,7 @@ function PaymentIsland(props) {
|
|
|
5267
5414
|
const exToTileRef = react.useRef(null);
|
|
5268
5415
|
const regionRef = react.useRef(null);
|
|
5269
5416
|
const panelId = react.useId();
|
|
5417
|
+
const exAmountNoteId = react.useId();
|
|
5270
5418
|
react.useEffect(() => setView("main"), [wallet.account, payParamsKey]);
|
|
5271
5419
|
react.useEffect(() => setHist(null), [wallet.account]);
|
|
5272
5420
|
const firstRender = react.useRef(true);
|
|
@@ -5370,6 +5518,9 @@ function PaymentIsland(props) {
|
|
|
5370
5518
|
const raw = BigInt(exFromBal.raw);
|
|
5371
5519
|
setExAmount(formatUnits(p === 100 ? raw : raw * BigInt(p) / 100n, assetDecimals(exFromToken)));
|
|
5372
5520
|
};
|
|
5521
|
+
const exGatewayAmountError = !isPay && exQuotable && flow.status === "error" && flow.steps.length === 0 ? flow.fieldError : null;
|
|
5522
|
+
const exAmountError = exOverLimit && exLaneLimit ? laneLimitError(exLaneLimit, exLimitSymbol) : exGatewayAmountError;
|
|
5523
|
+
const exAmountNote = exAmountError || (exLaneLimit ? laneLimitHint(exLaneLimit, exLimitSymbol) : null);
|
|
5373
5524
|
const exchangeControls = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
5374
5525
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-ft", style: { marginTop: 12 }, children: [
|
|
5375
5526
|
/* @__PURE__ */ jsxRuntime.jsx(TokenTile, { label: "From", pick: exFrom, token: exFromToken, disabled: submitting, btnRef: exFromTileRef, onClick: () => setView("from") }),
|
|
@@ -5380,8 +5531,18 @@ function PaymentIsland(props) {
|
|
|
5380
5531
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-label", children: "Send" }),
|
|
5381
5532
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-send-row", children: [
|
|
5382
5533
|
exFrom ? /* @__PURE__ */ jsxRuntime.jsx(TokenGlyph, { symbol: exFrom.symbol, logoUrl: exFromToken?.logoUrl, chainId: exFrom.chainId, size: "sm" }) : null,
|
|
5383
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5534
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5535
|
+
AmountInput,
|
|
5536
|
+
{
|
|
5537
|
+
value: exAmount,
|
|
5538
|
+
onChange: setExAmount,
|
|
5539
|
+
disabled: submitting,
|
|
5540
|
+
invalid: !!exAmountError,
|
|
5541
|
+
describedBy: exAmountNote ? exAmountNoteId : void 0
|
|
5542
|
+
}
|
|
5543
|
+
)
|
|
5384
5544
|
] }),
|
|
5545
|
+
exAmountNote ? /* @__PURE__ */ jsxRuntime.jsx(AmountNote, { id: exAmountNoteId, tone: exAmountError ? "error" : "neutral", children: exAmountNote }) : null,
|
|
5385
5546
|
exFromBal ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-send-bal sg-mono", children: [
|
|
5386
5547
|
"Balance: ",
|
|
5387
5548
|
exFromBal.formatted,
|
|
@@ -5513,7 +5674,7 @@ function PaymentIsland(props) {
|
|
|
5513
5674
|
lastTxOwned ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-cta-wrap", children: /* @__PURE__ */ jsxRuntime.jsx(Button, { variant: "ghost", onClick: () => setHist({ entry: flow.lastTxEntry }), children: "View transaction" }) }) : null
|
|
5514
5675
|
] });
|
|
5515
5676
|
} else {
|
|
5516
|
-
const quoteError = flow.status === "error" && flow.steps.length === 0;
|
|
5677
|
+
const quoteError = flow.status === "error" && flow.steps.length === 0 && !exGatewayAmountError;
|
|
5517
5678
|
const walletError = flow.status === "error" && flow.steps.length > 0;
|
|
5518
5679
|
body = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
5519
5680
|
/* @__PURE__ */ jsxRuntime.jsx(IdentityLine, { account: wallet.account, email: identity?.email }),
|
|
@@ -6184,7 +6345,11 @@ function StableGenieExchange(props) {
|
|
|
6184
6345
|
continue;
|
|
6185
6346
|
}
|
|
6186
6347
|
const verdict = destinationAvailability(token, catalogue, fromToken);
|
|
6187
|
-
if (verdict === "available")
|
|
6348
|
+
if (verdict === "available") {
|
|
6349
|
+
const limit = laneLimitFor(token, fromToken, catalogue.limitedLanes);
|
|
6350
|
+
if (limit) states[key] = { disabled: false, hint: laneLimitHint(limit, laneLimitSymbol(limit, fromToken ? tokenTicker(fromToken) : void 0)) };
|
|
6351
|
+
continue;
|
|
6352
|
+
}
|
|
6188
6353
|
states[key] = {
|
|
6189
6354
|
disabled: true,
|
|
6190
6355
|
reason: verdict === "hub-only" ? `${tokenTicker(token)} cannot be delivered on this chain \u2014 choose an execution chain.` : "ZeroDelta cannot deliver this asset here.",
|
|
@@ -6196,9 +6361,23 @@ function StableGenieExchange(props) {
|
|
|
6196
6361
|
const normalizedAmount = normalizeDecimalText(amount);
|
|
6197
6362
|
const amountValid = /^\d+(\.\d+)?$/.test(normalizedAmount) && Number(normalizedAmount) > 0 && Number(normalizedAmount) <= 1e9;
|
|
6198
6363
|
const rampMode = mode !== "exchange";
|
|
6364
|
+
const laneLimit = react.useMemo(
|
|
6365
|
+
() => mode === "exchange" && fromToken && toToken ? laneLimitFor(toToken, fromToken, catalogue?.limitedLanes) : void 0,
|
|
6366
|
+
[mode, catalogue, fromToken, toToken]
|
|
6367
|
+
);
|
|
6368
|
+
const limitSymbol = laneLimit ? laneLimitSymbol(laneLimit, fromTicker) : "";
|
|
6369
|
+
const overLimit = react.useMemo(() => {
|
|
6370
|
+
if (!laneLimit || !fromToken || !amountValid) return false;
|
|
6371
|
+
try {
|
|
6372
|
+
return exceedsLaneLimit(laneLimit, normalizedAmount, assetDecimals(fromToken));
|
|
6373
|
+
} catch {
|
|
6374
|
+
return false;
|
|
6375
|
+
}
|
|
6376
|
+
}, [laneLimit, fromToken, amountValid, normalizedAmount]);
|
|
6377
|
+
const amountNoteId = react.useId();
|
|
6199
6378
|
const inUniverse = (p) => Boolean(p && tokens.some((t) => Number(t.chainId) === p.chainId && symbolKey(t.symbol) === p.symbol));
|
|
6200
6379
|
const cryptoReady = rampMode ? inUniverse(mode === "onramp" ? to : from) : inUniverse(from) && inUniverse(to);
|
|
6201
|
-
const quotable = mode === "exchange" && inUniverse(from) && inUniverse(to) && amountValid;
|
|
6380
|
+
const quotable = mode === "exchange" && inUniverse(from) && inUniverse(to) && amountValid && !overLimit;
|
|
6202
6381
|
const [balances, setBalances] = react.useState({});
|
|
6203
6382
|
const balReq = react.useRef(0);
|
|
6204
6383
|
react.useEffect(() => {
|
|
@@ -6246,7 +6425,7 @@ function StableGenieExchange(props) {
|
|
|
6246
6425
|
engine.quoteSwapPreview({ fromChainId: from.chainId, toChainId: to.chainId, fromToken: from.symbol, toToken: to.symbol, amountIn: normalizedAmount, recipient: props.recipient }).then((data) => {
|
|
6247
6426
|
if (id === prevReq.current) setPreview({ status: "ready", data });
|
|
6248
6427
|
}).catch((e) => {
|
|
6249
|
-
if (id === prevReq.current) setPreview({ status: "error", error: e instanceof Error ? e.message : String(e) });
|
|
6428
|
+
if (id === prevReq.current) setPreview({ status: "error", error: e instanceof Error ? e.message : String(e), fieldError: amountFieldError(e) });
|
|
6250
6429
|
});
|
|
6251
6430
|
}, 350);
|
|
6252
6431
|
return () => clearTimeout(timer);
|
|
@@ -6256,6 +6435,9 @@ function StableGenieExchange(props) {
|
|
|
6256
6435
|
const lastTxOwned = Boolean(flow.lastTxEntry?.hash && wallet.account && flow.lastTxEntry.account === wallet.account.toLowerCase());
|
|
6257
6436
|
const quoting = connected ? flow.status === "loading" : preview.status === "loading";
|
|
6258
6437
|
const quoteError = !quotable ? null : connected ? flow.status === "error" ? flow.error : null : preview.status === "error" ? preview.error ?? "No route." : null;
|
|
6438
|
+
const gatewayAmountError = !quoteError ? null : connected ? flow.fieldError : preview.fieldError ?? null;
|
|
6439
|
+
const amountError = overLimit && laneLimit ? laneLimitError(laneLimit, limitSymbol) : gatewayAmountError;
|
|
6440
|
+
const amountNote = mode === "exchange" ? amountError || (laneLimit ? laneLimitHint(laneLimit, limitSymbol) : null) : null;
|
|
6259
6441
|
const receive = connected ? flow.selected?.receive.amount : preview.data?.receive;
|
|
6260
6442
|
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;
|
|
6261
6443
|
const pct = (p) => {
|
|
@@ -6332,8 +6514,18 @@ function StableGenieExchange(props) {
|
|
|
6332
6514
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-label", children: mode === "onramp" ? `You pay (${fiatCurrency})` : "Send" }),
|
|
6333
6515
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-send-row", children: [
|
|
6334
6516
|
mode === "onramp" ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-fiat", children: FIAT.find((f) => f.code === fiatCurrency)?.glyph ?? "$" }) : from ? /* @__PURE__ */ jsxRuntime.jsx(TokenGlyph, { symbol: from.symbol, logoUrl: fromToken?.logoUrl, chainId: from.chainId, size: "sm" }) : null,
|
|
6335
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6517
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6518
|
+
AmountInput,
|
|
6519
|
+
{
|
|
6520
|
+
value: amount,
|
|
6521
|
+
onChange: setAmount,
|
|
6522
|
+
disabled: submitting,
|
|
6523
|
+
invalid: !!amountError,
|
|
6524
|
+
describedBy: amountNote ? amountNoteId : void 0
|
|
6525
|
+
}
|
|
6526
|
+
)
|
|
6336
6527
|
] }),
|
|
6528
|
+
amountNote ? /* @__PURE__ */ jsxRuntime.jsx(AmountNote, { id: amountNoteId, tone: amountError ? "error" : "neutral", children: amountNote }) : null,
|
|
6337
6529
|
mode !== "onramp" && fromBal ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-send-bal sg-mono", children: [
|
|
6338
6530
|
"Balance: ",
|
|
6339
6531
|
fromBal.formatted,
|
|
@@ -6347,7 +6539,7 @@ function StableGenieExchange(props) {
|
|
|
6347
6539
|
) : null
|
|
6348
6540
|
] }),
|
|
6349
6541
|
rampMode ? /* @__PURE__ */ jsxRuntime.jsx(StatusPanel, { children: mode === "onramp" ? "Buy supported stablecoins with card or bank transfer \u2014 coming soon. Today the widget settles crypto-to-crypto." : "Cash out supported stablecoins to your bank \u2014 coming soon. Today the widget settles crypto-to-crypto." }) : null,
|
|
6350
|
-
!rampMode && quoteError && !wide ? /* @__PURE__ */ jsxRuntime.jsx(StatusPanel, { tone: "error", children: quoteError }) : null,
|
|
6542
|
+
!rampMode && quoteError && !gatewayAmountError && !wide ? /* @__PURE__ */ jsxRuntime.jsx(StatusPanel, { tone: "error", children: quoteError }) : null,
|
|
6351
6543
|
!rampMode && !wide && quotable && !quoteError ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-panel", style: { marginTop: 12 }, children: [
|
|
6352
6544
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-label", children: "You receive (estimated)" }),
|
|
6353
6545
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-anchor sg-mono", children: quoting ? "\u2026" : receive ? `${receive} ${toTicker}` : "\u2014" }),
|
|
@@ -6379,6 +6571,12 @@ function StableGenieExchange(props) {
|
|
|
6379
6571
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-noroutes-title", children: soonLabel }),
|
|
6380
6572
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-noroutes-sub", children: "Fiat rails are on the roadmap. Crypto-to-crypto exchange is live today." })
|
|
6381
6573
|
] });
|
|
6574
|
+
} else if (amountError) {
|
|
6575
|
+
side = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-noroutes", children: [
|
|
6576
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-noroutes-icon", children: /* @__PURE__ */ jsxRuntime.jsx(RouteGlyph, {}) }),
|
|
6577
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-noroutes-title", children: "Change the amount" }),
|
|
6578
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-noroutes-sub", children: amountError })
|
|
6579
|
+
] });
|
|
6382
6580
|
} else if (quoting) {
|
|
6383
6581
|
side = /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
6384
6582
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-skel" }),
|
package/dist/mount.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { M as MountConfig, r as mount } from './mount-
|
|
1
|
+
export { M as MountConfig, r as mount } from './mount-Dw3LvQZi.cjs';
|
|
2
2
|
import 'react';
|
|
3
|
-
import './verify-
|
|
3
|
+
import './verify-CPaT8Upe.cjs';
|
package/dist/mount.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { M as MountConfig, r as mount } from './mount-
|
|
1
|
+
export { M as MountConfig, r as mount } from './mount-BX_B0fzO.js';
|
|
2
2
|
import 'react';
|
|
3
|
-
import './verify-
|
|
3
|
+
import './verify-CPaT8Upe.js';
|
package/dist/mount.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { mount } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
export { mount } from './chunk-RFBNRCFB.js';
|
|
2
|
+
import './chunk-PMVF6A2D.js';
|