@glacislabs/stablegenie-zerodelta 4.2.1 → 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-FDCSZ3OY.js → chunk-PMVF6A2D.js} +97 -6
- package/dist/{chunk-OOESQYM3.js → chunk-RFBNRCFB.js} +115 -31
- package/dist/core/index.cjs +105 -5
- 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 +210 -35
- 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 +210 -35
- 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,10 +1730,18 @@ 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) {
|
|
@@ -1705,6 +1793,7 @@ function createApiClient(cfg) {
|
|
|
1705
1793
|
status: response.status,
|
|
1706
1794
|
code: json?.error?.code || json?.code || (response.status >= 502 ? "gateway_timeout" : "api_error"),
|
|
1707
1795
|
fieldErrors: json?.error?.fieldErrors || json?.fieldErrors,
|
|
1796
|
+
limits: json?.error?.limits || json?.limits,
|
|
1708
1797
|
reasons: json?.error?.reasons || json?.reasons
|
|
1709
1798
|
});
|
|
1710
1799
|
}
|
|
@@ -2493,6 +2582,8 @@ function createEngine(config = {}) {
|
|
|
2493
2582
|
...allowed ? { allowedAssets: allowed } : {},
|
|
2494
2583
|
supportedChainIds: SUPPORTED_CHAIN_IDS,
|
|
2495
2584
|
brokenLanes: suppressedLanes(health),
|
|
2585
|
+
// Same read, same degraded mode: a null health response limits nothing.
|
|
2586
|
+
limitedLanes: limitedLanes(health),
|
|
2496
2587
|
vaultIcons
|
|
2497
2588
|
});
|
|
2498
2589
|
},
|
|
@@ -2794,6 +2885,7 @@ function useFlow(args) {
|
|
|
2794
2885
|
const [plan, setPlan] = react.useState(null);
|
|
2795
2886
|
const [selectedId, setSelectedId] = react.useState(null);
|
|
2796
2887
|
const [error, setError] = react.useState(null);
|
|
2888
|
+
const [fieldError, setFieldError] = react.useState(null);
|
|
2797
2889
|
const [insufficient, setInsufficient] = react.useState(false);
|
|
2798
2890
|
const [nativeShortfall, setNativeShortfall] = react.useState(null);
|
|
2799
2891
|
const [steps, setSteps] = react.useState([]);
|
|
@@ -2808,6 +2900,7 @@ function useFlow(args) {
|
|
|
2808
2900
|
const reload = react.useCallback(() => setNonce((n) => n + 1), []);
|
|
2809
2901
|
react.useEffect(() => {
|
|
2810
2902
|
if (busyRef.current) return;
|
|
2903
|
+
setFieldError(null);
|
|
2811
2904
|
if (!enabled || !wallet.account) {
|
|
2812
2905
|
setStatus("idle");
|
|
2813
2906
|
setPlan(null);
|
|
@@ -2831,6 +2924,7 @@ function useFlow(args) {
|
|
|
2831
2924
|
if (id !== reqId.current) return;
|
|
2832
2925
|
setPlan(null);
|
|
2833
2926
|
setError(e?.message || "Could not price this right now.");
|
|
2927
|
+
setFieldError(amountFieldError(e));
|
|
2834
2928
|
setStatus("error");
|
|
2835
2929
|
onError?.(e instanceof Error ? e : new Error(String(e)));
|
|
2836
2930
|
}
|
|
@@ -2997,6 +3091,7 @@ function useFlow(args) {
|
|
|
2997
3091
|
selected,
|
|
2998
3092
|
selectRoute: setSelectedId,
|
|
2999
3093
|
error,
|
|
3094
|
+
fieldError,
|
|
3000
3095
|
insufficient,
|
|
3001
3096
|
nativeShortfall,
|
|
3002
3097
|
steps,
|
|
@@ -3234,6 +3329,10 @@ img.sg-tok-badge{width:16px;padding:0;object-fit:cover;background:var(--sg-bg)}
|
|
|
3234
3329
|
.sg-send-row{display:flex;align-items:center;gap:12px}
|
|
3235
3330
|
.sg-send-row .sg-amount{flex:1 1 auto;min-width:0}
|
|
3236
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)}
|
|
3237
3336
|
.sg-pct-row{display:flex;gap:8px;margin-top:12px}
|
|
3238
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}
|
|
3239
3338
|
.sg-pct:hover:not(:disabled){color:var(--sg-accent);border-color:var(--sg-accent)}
|
|
@@ -3275,6 +3374,8 @@ img.sg-tok-badge{width:16px;padding:0;object-fit:cover;background:var(--sg-bg)}
|
|
|
3275
3374
|
.sg-tokrow--off:hover,.sg-tokrow[disabled]:hover{background:transparent}
|
|
3276
3375
|
.sg-tokrow--off .sg-tokrow-sym,.sg-tokrow--off .sg-tokrow-name,.sg-tokrow--off .sg-tokrow-bal{color:var(--sg-text-muted)}
|
|
3277
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)}
|
|
3278
3379
|
.sg-sel-empty{padding:26px 10px;text-align:center;font-size:13px;color:var(--sg-text-muted)}
|
|
3279
3380
|
|
|
3280
3381
|
/* wide (duo) layout: main card + receive/routes side card. The collapse is keyed to the WIDGET'S
|
|
@@ -3811,10 +3912,16 @@ function AmountInput(props) {
|
|
|
3811
3912
|
placeholder: props.placeholder ?? "0.0",
|
|
3812
3913
|
value: props.value,
|
|
3813
3914
|
disabled: props.disabled,
|
|
3915
|
+
"aria-invalid": props.invalid || void 0,
|
|
3916
|
+
"aria-describedby": props.describedBy,
|
|
3814
3917
|
onChange: (e) => props.onChange(e.target.value.replace(/[^0-9.,]/g, ""))
|
|
3815
3918
|
}
|
|
3816
3919
|
);
|
|
3817
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
|
+
}
|
|
3818
3925
|
function StatusPanel(props) {
|
|
3819
3926
|
const tone = props.tone ?? "neutral";
|
|
3820
3927
|
return (
|
|
@@ -4423,7 +4530,7 @@ function TokenSelect(props) {
|
|
|
4423
4530
|
] }),
|
|
4424
4531
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-tokrow-end", children: [
|
|
4425
4532
|
bal ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tokrow-bal sg-mono", children: bal.formatted }) : null,
|
|
4426
|
-
|
|
4533
|
+
st?.hint ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tokrow-hint", "data-tone": disabled ? void 0 : "note", children: st.hint }) : null,
|
|
4427
4534
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tokrow-chain", children: CHAIN_LABELS[chainId] || `Chain ${chainId}` })
|
|
4428
4535
|
] })
|
|
4429
4536
|
]
|
|
@@ -5027,7 +5134,40 @@ function PaymentIsland(props) {
|
|
|
5027
5134
|
const exToAsset = exTo?.symbol;
|
|
5028
5135
|
const normEx = normalizeDecimalText(exAmount);
|
|
5029
5136
|
const exAmountValid = /^\d+(\.\d+)?$/.test(normEx) && Number(normEx) > 0 && Number(normEx) <= 1e9;
|
|
5030
|
-
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);
|
|
5031
5171
|
const payFundingAssets = props.fundingAssets?.length ? props.fundingAssets : ["USDC", "USDT", "USDE"];
|
|
5032
5172
|
const payParamsKey = `pay|${props.recipient}|${props.toChainId}|${props.toAsset}|${props.amount}|${payFundingAssets.join(",")}`;
|
|
5033
5173
|
const exParamsKey = `${kind}|${mode}|${exFromChainId}|${exFromAsset}|${exToChainId}|${exToAsset}|${normEx}|${props.recipient ?? ""}`;
|
|
@@ -5111,24 +5251,6 @@ function PaymentIsland(props) {
|
|
|
5111
5251
|
}
|
|
5112
5252
|
return map;
|
|
5113
5253
|
}, [annotated, holdings.loading]);
|
|
5114
|
-
const [catalogue, setCatalogue] = react.useState(null);
|
|
5115
|
-
react.useEffect(() => {
|
|
5116
|
-
if (bankSettlement || !isPay && rampMode) return;
|
|
5117
|
-
let alive = true;
|
|
5118
|
-
engine.fetchCatalogue(isPay ? void 0 : exAllowed, isPay ? "stable" : exProduct).then((next) => {
|
|
5119
|
-
if (alive) setCatalogue(next);
|
|
5120
|
-
});
|
|
5121
|
-
return () => {
|
|
5122
|
-
alive = false;
|
|
5123
|
-
};
|
|
5124
|
-
}, [engine, isPay, rampMode, bankSettlement, exAllowed, exProduct]);
|
|
5125
|
-
const chains = react.useMemo(() => {
|
|
5126
|
-
const order = new Map(SUPPORTED_CHAINS.map((id, i) => [id, i]));
|
|
5127
|
-
return [...catalogue?.chains ?? []].sort((a, b) => (order.get(Number(a.chainId)) ?? 99) - (order.get(Number(b.chainId)) ?? 99) || Number(a.chainId) - Number(b.chainId));
|
|
5128
|
-
}, [catalogue]);
|
|
5129
|
-
const registryTokens = react.useMemo(() => catalogue?.tokens ?? [], [catalogue]);
|
|
5130
|
-
const exchangeTokens = react.useMemo(() => isPay ? [] : registryTokens, [isPay, registryTokens]);
|
|
5131
|
-
const exSourceTokens = react.useMemo(() => isPay ? [] : catalogue?.sources ?? [], [isPay, catalogue]);
|
|
5132
5254
|
const [exBalances, setExBalances] = react.useState({});
|
|
5133
5255
|
const exBalReq = react.useRef(0);
|
|
5134
5256
|
react.useEffect(() => {
|
|
@@ -5148,8 +5270,6 @@ function PaymentIsland(props) {
|
|
|
5148
5270
|
if (id === exBalReq.current) setExBalances(res);
|
|
5149
5271
|
});
|
|
5150
5272
|
}, [engine, isPay, wallet.account, exchangeTokens]);
|
|
5151
|
-
const exFromToken = react.useMemo(() => exFrom ? findToken(exchangeTokens, exFrom.chainId, exFrom.symbol) : null, [exchangeTokens, exFrom]);
|
|
5152
|
-
const exToToken = react.useMemo(() => exTo ? findToken(exchangeTokens, exTo.chainId, exTo.symbol) : null, [exchangeTokens, exTo]);
|
|
5153
5273
|
const exFromPicker = react.useMemo(() => exProduct === "rwa" ? counterpartTokens(exSourceTokens, exToToken) : exSourceTokens, [exProduct, exSourceTokens, exToToken]);
|
|
5154
5274
|
const exToPicker = react.useMemo(() => exProduct === "rwa" ? counterpartTokens(exchangeTokens, exFromToken) : exchangeTokens, [exProduct, exchangeTokens, exFromToken]);
|
|
5155
5275
|
const exRwaSeeded = react.useRef(false);
|
|
@@ -5174,7 +5294,11 @@ function PaymentIsland(props) {
|
|
|
5174
5294
|
continue;
|
|
5175
5295
|
}
|
|
5176
5296
|
const verdict = destinationAvailability(token, catalogue, exFromToken);
|
|
5177
|
-
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
|
+
}
|
|
5178
5302
|
states[key] = {
|
|
5179
5303
|
disabled: true,
|
|
5180
5304
|
reason: verdict === "hub-only" ? `${tokenTicker(token)} cannot be delivered on this chain.` : "ZeroDelta cannot deliver this asset here.",
|
|
@@ -5290,6 +5414,7 @@ function PaymentIsland(props) {
|
|
|
5290
5414
|
const exToTileRef = react.useRef(null);
|
|
5291
5415
|
const regionRef = react.useRef(null);
|
|
5292
5416
|
const panelId = react.useId();
|
|
5417
|
+
const exAmountNoteId = react.useId();
|
|
5293
5418
|
react.useEffect(() => setView("main"), [wallet.account, payParamsKey]);
|
|
5294
5419
|
react.useEffect(() => setHist(null), [wallet.account]);
|
|
5295
5420
|
const firstRender = react.useRef(true);
|
|
@@ -5393,6 +5518,9 @@ function PaymentIsland(props) {
|
|
|
5393
5518
|
const raw = BigInt(exFromBal.raw);
|
|
5394
5519
|
setExAmount(formatUnits(p === 100 ? raw : raw * BigInt(p) / 100n, assetDecimals(exFromToken)));
|
|
5395
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);
|
|
5396
5524
|
const exchangeControls = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
5397
5525
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-ft", style: { marginTop: 12 }, children: [
|
|
5398
5526
|
/* @__PURE__ */ jsxRuntime.jsx(TokenTile, { label: "From", pick: exFrom, token: exFromToken, disabled: submitting, btnRef: exFromTileRef, onClick: () => setView("from") }),
|
|
@@ -5403,8 +5531,18 @@ function PaymentIsland(props) {
|
|
|
5403
5531
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-label", children: "Send" }),
|
|
5404
5532
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-send-row", children: [
|
|
5405
5533
|
exFrom ? /* @__PURE__ */ jsxRuntime.jsx(TokenGlyph, { symbol: exFrom.symbol, logoUrl: exFromToken?.logoUrl, chainId: exFrom.chainId, size: "sm" }) : null,
|
|
5406
|
-
/* @__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
|
+
)
|
|
5407
5544
|
] }),
|
|
5545
|
+
exAmountNote ? /* @__PURE__ */ jsxRuntime.jsx(AmountNote, { id: exAmountNoteId, tone: exAmountError ? "error" : "neutral", children: exAmountNote }) : null,
|
|
5408
5546
|
exFromBal ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-send-bal sg-mono", children: [
|
|
5409
5547
|
"Balance: ",
|
|
5410
5548
|
exFromBal.formatted,
|
|
@@ -5536,7 +5674,7 @@ function PaymentIsland(props) {
|
|
|
5536
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
|
|
5537
5675
|
] });
|
|
5538
5676
|
} else {
|
|
5539
|
-
const quoteError = flow.status === "error" && flow.steps.length === 0;
|
|
5677
|
+
const quoteError = flow.status === "error" && flow.steps.length === 0 && !exGatewayAmountError;
|
|
5540
5678
|
const walletError = flow.status === "error" && flow.steps.length > 0;
|
|
5541
5679
|
body = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
5542
5680
|
/* @__PURE__ */ jsxRuntime.jsx(IdentityLine, { account: wallet.account, email: identity?.email }),
|
|
@@ -6207,7 +6345,11 @@ function StableGenieExchange(props) {
|
|
|
6207
6345
|
continue;
|
|
6208
6346
|
}
|
|
6209
6347
|
const verdict = destinationAvailability(token, catalogue, fromToken);
|
|
6210
|
-
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
|
+
}
|
|
6211
6353
|
states[key] = {
|
|
6212
6354
|
disabled: true,
|
|
6213
6355
|
reason: verdict === "hub-only" ? `${tokenTicker(token)} cannot be delivered on this chain \u2014 choose an execution chain.` : "ZeroDelta cannot deliver this asset here.",
|
|
@@ -6219,9 +6361,23 @@ function StableGenieExchange(props) {
|
|
|
6219
6361
|
const normalizedAmount = normalizeDecimalText(amount);
|
|
6220
6362
|
const amountValid = /^\d+(\.\d+)?$/.test(normalizedAmount) && Number(normalizedAmount) > 0 && Number(normalizedAmount) <= 1e9;
|
|
6221
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();
|
|
6222
6378
|
const inUniverse = (p) => Boolean(p && tokens.some((t) => Number(t.chainId) === p.chainId && symbolKey(t.symbol) === p.symbol));
|
|
6223
6379
|
const cryptoReady = rampMode ? inUniverse(mode === "onramp" ? to : from) : inUniverse(from) && inUniverse(to);
|
|
6224
|
-
const quotable = mode === "exchange" && inUniverse(from) && inUniverse(to) && amountValid;
|
|
6380
|
+
const quotable = mode === "exchange" && inUniverse(from) && inUniverse(to) && amountValid && !overLimit;
|
|
6225
6381
|
const [balances, setBalances] = react.useState({});
|
|
6226
6382
|
const balReq = react.useRef(0);
|
|
6227
6383
|
react.useEffect(() => {
|
|
@@ -6269,7 +6425,7 @@ function StableGenieExchange(props) {
|
|
|
6269
6425
|
engine.quoteSwapPreview({ fromChainId: from.chainId, toChainId: to.chainId, fromToken: from.symbol, toToken: to.symbol, amountIn: normalizedAmount, recipient: props.recipient }).then((data) => {
|
|
6270
6426
|
if (id === prevReq.current) setPreview({ status: "ready", data });
|
|
6271
6427
|
}).catch((e) => {
|
|
6272
|
-
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) });
|
|
6273
6429
|
});
|
|
6274
6430
|
}, 350);
|
|
6275
6431
|
return () => clearTimeout(timer);
|
|
@@ -6279,6 +6435,9 @@ function StableGenieExchange(props) {
|
|
|
6279
6435
|
const lastTxOwned = Boolean(flow.lastTxEntry?.hash && wallet.account && flow.lastTxEntry.account === wallet.account.toLowerCase());
|
|
6280
6436
|
const quoting = connected ? flow.status === "loading" : preview.status === "loading";
|
|
6281
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;
|
|
6282
6441
|
const receive = connected ? flow.selected?.receive.amount : preview.data?.receive;
|
|
6283
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;
|
|
6284
6443
|
const pct = (p) => {
|
|
@@ -6355,8 +6514,18 @@ function StableGenieExchange(props) {
|
|
|
6355
6514
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-label", children: mode === "onramp" ? `You pay (${fiatCurrency})` : "Send" }),
|
|
6356
6515
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-send-row", children: [
|
|
6357
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,
|
|
6358
|
-
/* @__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
|
+
)
|
|
6359
6527
|
] }),
|
|
6528
|
+
amountNote ? /* @__PURE__ */ jsxRuntime.jsx(AmountNote, { id: amountNoteId, tone: amountError ? "error" : "neutral", children: amountNote }) : null,
|
|
6360
6529
|
mode !== "onramp" && fromBal ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-send-bal sg-mono", children: [
|
|
6361
6530
|
"Balance: ",
|
|
6362
6531
|
fromBal.formatted,
|
|
@@ -6370,7 +6539,7 @@ function StableGenieExchange(props) {
|
|
|
6370
6539
|
) : null
|
|
6371
6540
|
] }),
|
|
6372
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,
|
|
6373
|
-
!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,
|
|
6374
6543
|
!rampMode && !wide && quotable && !quoteError ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-panel", style: { marginTop: 12 }, children: [
|
|
6375
6544
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-label", children: "You receive (estimated)" }),
|
|
6376
6545
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-anchor sg-mono", children: quoting ? "\u2026" : receive ? `${receive} ${toTicker}` : "\u2014" }),
|
|
@@ -6402,6 +6571,12 @@ function StableGenieExchange(props) {
|
|
|
6402
6571
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-noroutes-title", children: soonLabel }),
|
|
6403
6572
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-noroutes-sub", children: "Fiat rails are on the roadmap. Crypto-to-crypto exchange is live today." })
|
|
6404
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
|
+
] });
|
|
6405
6580
|
} else if (quoting) {
|
|
6406
6581
|
side = /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
6407
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';
|