@glacislabs/stablegenie-zerodelta 4.20.1 → 4.22.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-4WBNXYOV.js → chunk-UBSZA63S.js} +504 -50
- package/dist/{chunk-RUHREVDT.js → chunk-UIIH5O6G.js} +439 -40
- package/dist/core/index.cjs +454 -39
- package/dist/core/index.d.cts +196 -3
- package/dist/core/index.d.ts +196 -3
- package/dist/core/index.js +1 -1
- package/dist/index.cjs +970 -117
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/{mount-D2tDkHea.d.cts → mount-DC_JT0cE.d.cts} +1 -1
- package/dist/{mount-DuTF5CQV.d.ts → mount-GOYY_jNr.d.ts} +1 -1
- package/dist/mount.cjs +970 -117
- 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 +15 -8
- package/dist/{verify-UqDjAVxa.d.cts → verify-mpglrU7n.d.cts} +21 -2
- package/dist/{verify-UqDjAVxa.d.ts → verify-mpglrU7n.d.ts} +21 -2
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CHAIN_DISPLAY_NAMES, EXECUTABLE_STABLE_ASSETS, STABLE_ASSETS, SUPPORTED_ASSETS, complianceView, complianceTagOf, symbolKey, normalizeDecimalText, findToken, laneLimitFor, laneLimitSymbol, tokenTicker, exceedsLaneLimit, assetDecimals, parseUnitsDecimal, counterpartTokens, assetClassOf, brokenLaneFor, brokenLaneReason, destinationAvailability, laneLimitHint, tickerOn, laneLimitError, routeNativeValue, formatNative, nativeSymbol, isSolanaChainId, isSellableRwa, formatUnits, amountFieldError, solanaQuoteCompliance, directComplianceFromScreens, SUPPORTED_CHAIN_IDS, complianceChecks, DIRECT_CHECK_IDS, isSolanaAddress, createEngine, isAddress, checkNativeFee, nativeFeeShortLabel, nativeFeeShortMessage, zdHeavyExpected, preflightZdHeavyPlan, allowanceCovers, validatePlannedTransaction, priceCompareOptions, parity, pickForWait, cornerTags, extraVsFastest, proposedWait, visibleOptions, promotionFor, estimateBonus, pairPromotionsInto, promotedAssets, TRACKING, mergeHistory, hasValidChecksum, solanaPlanNeedsPreparation, SOLANA_CHAIN_ID, clampWait, waitScaleFor, waitFraction, waitLabel, WAIT_POSITIONS, snapWait, WAIT_STEP_SEC, waitFromFraction, compareDuration, compareAmount, unattributedComplianceReasons, distinctScreenedWallets, formatJurisdiction, humanizeComplianceReason, DIRECT_SCOPE_NOTE, categoryLabel, SCREENING_BUCKETS, BUNDLED_RPC, foldTicker } from './chunk-
|
|
1
|
+
import { CHAIN_DISPLAY_NAMES, EXECUTABLE_STABLE_ASSETS, STABLE_ASSETS, SUPPORTED_ASSETS, complianceView, complianceTagOf, symbolKey, normalizeDecimalText, findToken, laneLimitFor, laneLimitSymbol, tokenTicker, exceedsLaneLimit, assetDecimals, parseUnitsDecimal, counterpartTokens, assetClassOf, brokenLaneFor, brokenLaneReason, destinationAvailability, laneLimitHint, tickerOn, laneLimitError, routeNativeValue, formatNative, nativeSymbol, isSolanaChainId, isSellableRwa, formatUnits, amountFieldError, solanaQuoteCompliance, directComplianceFromScreens, SUPPORTED_CHAIN_IDS, complianceChecks, DIRECT_CHECK_IDS, isSolanaAddress, createEngine, isAddress, checkNativeFee, nativeFeeShortLabel, ZdHeavyQuoteExpiredError, assertZdHeavyQuoteFresh, nativeFeeShortMessage, zdHeavyExpected, preflightZdHeavyPlan, allowanceCovers, validatePlannedTransaction, priceCompareOptions, parity, pickForWait, cornerTags, extraVsFastest, proposedWait, visibleOptions, promotionFor, estimateBonus, pairPromotionsInto, promotedAssets, TRACKING, mergeHistory, hasValidChecksum, solanaPlanNeedsPreparation, SOLANA_CHAIN_ID, clampWait, waitScaleFor, waitFraction, waitLabel, WAIT_POSITIONS, snapWait, WAIT_STEP_SEC, waitFromFraction, compareDuration, compareAmount, unattributedComplianceReasons, distinctScreenedWallets, formatJurisdiction, humanizeComplianceReason, DIRECT_SCOPE_NOTE, categoryLabel, SCREENING_BUCKETS, BUNDLED_RPC, isZdHeavyOrderId, zdHeavyRecovery, foldTicker, checkZdHeavyCancelTx, checkZdHeavyClaimTx, decodeZdHeavyCancel, decodeZdHeavyClaim } from './chunk-UIIH5O6G.js';
|
|
2
2
|
import { createContext, useState, useRef, useMemo, useEffect, useCallback, useId, useLayoutEffect, createElement, useContext, useSyncExternalStore, useReducer } from 'react';
|
|
3
3
|
import { createRoot } from 'react-dom/client';
|
|
4
4
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
@@ -23,7 +23,7 @@ function useDelivery(engine, hash) {
|
|
|
23
23
|
let unanswered = 0;
|
|
24
24
|
const started2 = Date.now();
|
|
25
25
|
setState({ hash, value: TRACKING });
|
|
26
|
-
const
|
|
26
|
+
const schedule2 = () => {
|
|
27
27
|
if (Date.now() - started2 > DELIVERY_GIVE_UP_MS) {
|
|
28
28
|
if (waitsOnOwner) return;
|
|
29
29
|
return setState({ hash, value: UNAVAILABLE });
|
|
@@ -32,18 +32,18 @@ function useDelivery(engine, hash) {
|
|
|
32
32
|
};
|
|
33
33
|
const tick = async () => {
|
|
34
34
|
timer2 = void 0;
|
|
35
|
-
if (hidden()) return
|
|
35
|
+
if (hidden()) return schedule2();
|
|
36
36
|
const next = await engine.trackDelivery(hash);
|
|
37
37
|
if (!alive) return;
|
|
38
38
|
if (next.phase === "tracking") {
|
|
39
39
|
if (!answered && ++unanswered >= UNANSWERED_LIMIT) return setState({ hash, value: UNAVAILABLE });
|
|
40
|
-
return
|
|
40
|
+
return schedule2();
|
|
41
41
|
}
|
|
42
42
|
answered = true;
|
|
43
43
|
waitsOnOwner = next.phase === "attention";
|
|
44
44
|
setState({ hash, value: next });
|
|
45
45
|
if (next.phase === "delivered" || next.phase === "failed") return;
|
|
46
|
-
|
|
46
|
+
schedule2();
|
|
47
47
|
};
|
|
48
48
|
const onVisible2 = () => {
|
|
49
49
|
if (!alive || hidden() || !timer2) return;
|
|
@@ -82,8 +82,8 @@ function deliveryHeadline(delivery, sourceConfirmed, direct = false) {
|
|
|
82
82
|
case "delivered":
|
|
83
83
|
return "Delivered";
|
|
84
84
|
case "failed":
|
|
85
|
-
if (delivery.status === "cancelled" && delivery.refunded) return "
|
|
86
|
-
return delivery.status === "cancelled" ? "
|
|
85
|
+
if (delivery.status === "cancelled" && delivery.refunded) return "Cancellation and refund reported by ZeroDelta";
|
|
86
|
+
return delivery.status === "cancelled" ? "Cancellation reported \u2014 not delivered" : `Not delivered (${delivery.status.replace(/_/g, " ")}) \u2014 open the transaction for details`;
|
|
87
87
|
case "attention":
|
|
88
88
|
return delivery.status === "cancel_pending" ? "Being cancelled \u2014 not delivered" : "Waiting to be claimed \u2014 open the transaction";
|
|
89
89
|
case "in-progress": {
|
|
@@ -241,7 +241,9 @@ function normalizeWalletError(err, fallback = "Transaction failed.") {
|
|
|
241
241
|
async function sendTransaction(provider, tx) {
|
|
242
242
|
const hash = await provider.request({
|
|
243
243
|
method: "eth_sendTransaction",
|
|
244
|
-
|
|
244
|
+
// `chainId` only when the caller names one (ZD Heavy recovery writes): the wallet then refuses to
|
|
245
|
+
// sign on any other chain. The order submit path names none, so its request is unchanged.
|
|
246
|
+
params: [{ from: tx.from, to: tx.to, data: tx.data, value: tx.value || "0x0", ...tx.chainId ? { chainId: chainHex(tx.chainId) } : {} }]
|
|
245
247
|
});
|
|
246
248
|
return hash;
|
|
247
249
|
}
|
|
@@ -472,6 +474,8 @@ function useUserPresence() {
|
|
|
472
474
|
}
|
|
473
475
|
|
|
474
476
|
// src/react/hooks/useFlow.ts
|
|
477
|
+
var REFRESH_LEAD_SECONDS = 20;
|
|
478
|
+
var SIGN_MIN_SECONDS = 15;
|
|
475
479
|
function reportQuietly(engine, report, stage) {
|
|
476
480
|
try {
|
|
477
481
|
void engine.reportSubmission?.({ ...report, stage })?.catch?.(() => {
|
|
@@ -495,6 +499,7 @@ function useFlow(args) {
|
|
|
495
499
|
const [nonce, setNonce] = useState(0);
|
|
496
500
|
const reqId = useRef(0);
|
|
497
501
|
const busyRef = useRef(false);
|
|
502
|
+
const keepExpiryError = useRef(false);
|
|
498
503
|
const [planAt, setPlanAt] = useState(0);
|
|
499
504
|
const planAtRef = useRef(0);
|
|
500
505
|
const statusRef = useRef("idle");
|
|
@@ -524,7 +529,8 @@ function useFlow(args) {
|
|
|
524
529
|
}
|
|
525
530
|
const id = ++reqId.current;
|
|
526
531
|
setStatus("loading");
|
|
527
|
-
setError(null);
|
|
532
|
+
if (!keepExpiryError.current) setError(null);
|
|
533
|
+
keepExpiryError.current = false;
|
|
528
534
|
setVerdict(null);
|
|
529
535
|
setTxHash(null);
|
|
530
536
|
setLastTxEntry(null);
|
|
@@ -590,8 +596,8 @@ function useFlow(args) {
|
|
|
590
596
|
engine.fetchChains().catch(() => [])
|
|
591
597
|
]);
|
|
592
598
|
if (!alive) return;
|
|
593
|
-
const
|
|
594
|
-
setNativeShortfall(nativeFeeShortLabel(
|
|
599
|
+
const check3 = checkNativeFee(selected, balance);
|
|
600
|
+
setNativeShortfall(nativeFeeShortLabel(check3, nativeSymbol(Number(src.chainId), chains)));
|
|
595
601
|
} catch {
|
|
596
602
|
}
|
|
597
603
|
})();
|
|
@@ -617,6 +623,10 @@ function useFlow(args) {
|
|
|
617
623
|
setVerdict(null);
|
|
618
624
|
const patch = (id, s, hash) => setSteps((prev) => prev.map((st) => st.id === id ? { ...st, state: s, ...hash ? { hash } : {} } : st));
|
|
619
625
|
try {
|
|
626
|
+
if (route.zdHeavy) {
|
|
627
|
+
if (route.zdHeavy.order.expiresAt - Date.now() / 1e3 < SIGN_MIN_SECONDS) throw new ZdHeavyQuoteExpiredError();
|
|
628
|
+
assertZdHeavyQuoteFresh(route.zdHeavy.order, Math.floor(Date.now() / 1e3));
|
|
629
|
+
}
|
|
620
630
|
const current = await getChainId(provider);
|
|
621
631
|
if (current !== Number(sourceChainId)) {
|
|
622
632
|
await switchChain(provider, Number(sourceChainId));
|
|
@@ -624,10 +634,10 @@ function useFlow(args) {
|
|
|
624
634
|
if (after !== Number(sourceChainId)) throw new Error("Wallet did not switch to the source chain.");
|
|
625
635
|
}
|
|
626
636
|
if (routeNativeValue(route) > 0n) {
|
|
627
|
-
const
|
|
628
|
-
if (
|
|
637
|
+
const check3 = checkNativeFee(route, await nativeBalance(provider, account));
|
|
638
|
+
if (check3.short) {
|
|
629
639
|
const chains = await engine.fetchChains().catch(() => []);
|
|
630
|
-
throw new Error(nativeFeeShortMessage(
|
|
640
|
+
throw new Error(nativeFeeShortMessage(check3, nativeSymbol(Number(sourceChainId), chains), route.source.chainName));
|
|
631
641
|
}
|
|
632
642
|
}
|
|
633
643
|
const heavyExpected = route.zdHeavy ? zdHeavyExpected(route, account, recipient, ...await Promise.all([engine.fetchTokens(), engine.fetchRoutes()])) : void 0;
|
|
@@ -647,6 +657,7 @@ function useFlow(args) {
|
|
|
647
657
|
patch(tx.id, "done");
|
|
648
658
|
continue;
|
|
649
659
|
}
|
|
660
|
+
if (route.zdHeavy && tx.kind === "submitOrder") assertZdHeavyQuoteFresh(route.zdHeavy.order, Math.floor(Date.now() / 1e3));
|
|
650
661
|
if (!validatePlannedTransaction(tx, route, recipient, heavyExpected ? { ...heavyExpected, nowSec: Math.floor(Date.now() / 1e3) } : void 0)) {
|
|
651
662
|
throw new Error(`Refusing to sign a ${tx.kind} that does not match the reviewed plan.`);
|
|
652
663
|
}
|
|
@@ -711,13 +722,17 @@ function useFlow(args) {
|
|
|
711
722
|
}
|
|
712
723
|
} catch (e) {
|
|
713
724
|
setStatus("error");
|
|
714
|
-
setError(normalizeWalletError(e));
|
|
725
|
+
setError(e instanceof ZdHeavyQuoteExpiredError ? e.message : normalizeWalletError(e));
|
|
726
|
+
if (e instanceof ZdHeavyQuoteExpiredError) {
|
|
727
|
+
keepExpiryError.current = true;
|
|
728
|
+
reload();
|
|
729
|
+
}
|
|
715
730
|
setSteps((prev) => prev.map((st) => st.state === "active" ? { ...st, state: "error" } : st));
|
|
716
731
|
onError?.(e instanceof Error ? e : new Error(String(e)));
|
|
717
732
|
} finally {
|
|
718
733
|
busyRef.current = false;
|
|
719
734
|
}
|
|
720
|
-
}, [selected, wallet.provider, wallet.account, engine, kind, recipientFor, onSuccess, onError]);
|
|
735
|
+
}, [selected, wallet.provider, wallet.account, engine, kind, recipientFor, onSuccess, onError, reload]);
|
|
721
736
|
const [prices, setPrices] = useState(null);
|
|
722
737
|
const priceKey = baseSelected?.options?.length ? `${baseSelected.source.asset}|${baseSelected.receive.asset}` : "";
|
|
723
738
|
useEffect(() => {
|
|
@@ -813,6 +828,24 @@ function useFlow(args) {
|
|
|
813
828
|
const quoteReady = status === "ready" && !!plan;
|
|
814
829
|
const quotePaused = quoteReady && idle2;
|
|
815
830
|
const quoteStale = quoteReady && (idle2 || planAt < returnedAt2);
|
|
831
|
+
useEffect(() => {
|
|
832
|
+
if (!enabled || !selected?.zdHeavy || !quoteReady || quotePaused || busyRef.current) return;
|
|
833
|
+
let timer2;
|
|
834
|
+
const schedule2 = () => {
|
|
835
|
+
clearTimeout(timer2);
|
|
836
|
+
if (document.visibilityState !== "visible" || busyRef.current) return;
|
|
837
|
+
const delay = Math.max(3e3, (selected.zdHeavy.order.expiresAt - REFRESH_LEAD_SECONDS) * 1e3 - Date.now());
|
|
838
|
+
timer2 = setTimeout(() => {
|
|
839
|
+
if (!busyRef.current && statusRef.current === "ready" && !isUserIdle() && document.visibilityState === "visible") reload();
|
|
840
|
+
}, delay);
|
|
841
|
+
};
|
|
842
|
+
schedule2();
|
|
843
|
+
document.addEventListener("visibilitychange", schedule2);
|
|
844
|
+
return () => {
|
|
845
|
+
clearTimeout(timer2);
|
|
846
|
+
document.removeEventListener("visibilitychange", schedule2);
|
|
847
|
+
};
|
|
848
|
+
}, [enabled, selected, quoteReady, quotePaused, reload]);
|
|
816
849
|
return {
|
|
817
850
|
status,
|
|
818
851
|
plan,
|
|
@@ -1393,6 +1426,13 @@ img.sg-tok-badge{width:16px;padding:0;object-fit:cover;background:var(--sg-bg)}
|
|
|
1393
1426
|
/* transaction detail: copyable hash row (no external links \u2014 everything stays in-widget) */
|
|
1394
1427
|
.sg-txd-hash{display:flex;align-items:center;gap:8px;margin-top:12px;font-size:13px}
|
|
1395
1428
|
.sg-txd-hash .sg-mono{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
1429
|
+
.sg-zdh{margin-top:14px;padding:12px;border:1px solid var(--sg-border);border-radius:var(--sg-radius-control);background:var(--sg-surface)}
|
|
1430
|
+
.sg-zdh-title{font-size:14px;font-weight:600;line-height:1.25}
|
|
1431
|
+
.sg-zdh-body{margin:4px 0 10px;font-size:12px;line-height:1.45;color:var(--sg-text-muted)}
|
|
1432
|
+
.sg-zdh-actions{display:flex;flex-direction:column;gap:10px}
|
|
1433
|
+
.sg-zdh-action{display:flex;flex-direction:column;gap:6px}
|
|
1434
|
+
.sg-zdh-action .sg-txd-hash{margin-top:0}
|
|
1435
|
+
.sg-zdh-status{margin-top:14px}
|
|
1396
1436
|
.sg-copy{display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;width:26px;height:26px;border:1px solid var(--sg-border);border-radius:var(--sg-radius-control);background:transparent;color:var(--sg-text-muted);cursor:pointer;transition:color 120ms ease,border-color 120ms ease}
|
|
1397
1437
|
.sg-copy:hover{color:var(--sg-accent);border-color:var(--sg-accent)}
|
|
1398
1438
|
|
|
@@ -2713,10 +2753,10 @@ var CHAIN_ALIASES = {
|
|
|
2713
2753
|
43114: ["avax"]
|
|
2714
2754
|
};
|
|
2715
2755
|
function labelForms(label2) {
|
|
2716
|
-
const
|
|
2717
|
-
if (!
|
|
2718
|
-
const compact =
|
|
2719
|
-
return compact && compact !==
|
|
2756
|
+
const lower3 = label2.trim().toLowerCase();
|
|
2757
|
+
if (!lower3) return [];
|
|
2758
|
+
const compact = lower3.replace(/[^a-z0-9]/g, "");
|
|
2759
|
+
return compact && compact !== lower3 ? [lower3, compact] : [lower3];
|
|
2720
2760
|
}
|
|
2721
2761
|
function buildChainSearchTerms(chains) {
|
|
2722
2762
|
const byId = /* @__PURE__ */ new Map();
|
|
@@ -3439,22 +3479,22 @@ function TriggerGlyph({ cv }) {
|
|
|
3439
3479
|
if (cv.tone === "blocked" || cv.tone === "warn") return /* @__PURE__ */ jsx(CloseCircle, {});
|
|
3440
3480
|
return /* @__PURE__ */ jsx(ShieldTick, {});
|
|
3441
3481
|
}
|
|
3442
|
-
function CheckRow({ check:
|
|
3443
|
-
const label2 =
|
|
3444
|
-
return /* @__PURE__ */ jsxs("li", { className: "sg-cp-check", "data-ok":
|
|
3482
|
+
function CheckRow({ check: check3, onViewPolicy }) {
|
|
3483
|
+
const label2 = check3.id === "risk" ? check3.ok ? "Risk screening passed" : "Risk screening failed" : check3.label;
|
|
3484
|
+
return /* @__PURE__ */ jsxs("li", { className: "sg-cp-check", "data-ok": check3.ok, children: [
|
|
3445
3485
|
/* @__PURE__ */ jsxs("div", { className: "sg-cp-check-head", children: [
|
|
3446
3486
|
/* @__PURE__ */ jsxs("span", { className: "sg-cp-check-label", children: [
|
|
3447
|
-
/* @__PURE__ */ jsx("span", { className: "sg-cp-check-mark", "data-ok":
|
|
3487
|
+
/* @__PURE__ */ jsx("span", { className: "sg-cp-check-mark", "data-ok": check3.ok, children: check3.ok ? /* @__PURE__ */ jsx(Tick, {}) : /* @__PURE__ */ jsx(Cross, {}) }),
|
|
3448
3488
|
/* @__PURE__ */ jsx("span", { children: label2 }),
|
|
3449
|
-
/* @__PURE__ */ jsx("span", { className: "sg-sr-only", children:
|
|
3489
|
+
/* @__PURE__ */ jsx("span", { className: "sg-sr-only", children: check3.ok ? " \u2014 passed" : " \u2014 failed" })
|
|
3450
3490
|
] }),
|
|
3451
|
-
|
|
3491
|
+
check3.id === "risk" ? /* @__PURE__ */ jsxs("button", { type: "button", className: "sg-cp-link", onClick: onViewPolicy, children: [
|
|
3452
3492
|
"View policy",
|
|
3453
3493
|
/* @__PURE__ */ jsx(CornerArrow, {})
|
|
3454
3494
|
] }) : null
|
|
3455
3495
|
] }),
|
|
3456
|
-
|
|
3457
|
-
|
|
3496
|
+
check3.note ? /* @__PURE__ */ jsx("span", { className: "sg-cp-check-note", children: check3.note }) : null,
|
|
3497
|
+
check3.reasons.map((reason) => /* @__PURE__ */ jsx("span", { className: "sg-cp-check-reason", children: humanizeComplianceReason(reason) }, reason))
|
|
3458
3498
|
] });
|
|
3459
3499
|
}
|
|
3460
3500
|
function QuoteChecks({
|
|
@@ -3488,7 +3528,7 @@ function QuoteChecks({
|
|
|
3488
3528
|
/* @__PURE__ */ jsx("p", { className: "sg-cp-summary-sub", children: "The gateway returned no compliance decision for this quote, so there is nothing to show. It is not a failed check." })
|
|
3489
3529
|
)
|
|
3490
3530
|
] }),
|
|
3491
|
-
checks.length > 0 ? /* @__PURE__ */ jsx("ul", { className: "sg-cp-checks", children: checks.map((
|
|
3531
|
+
checks.length > 0 ? /* @__PURE__ */ jsx("ul", { className: "sg-cp-checks", children: checks.map((check3) => /* @__PURE__ */ jsx(CheckRow, { check: check3, onViewPolicy }, check3.id)) }) : null,
|
|
3492
3532
|
orphans.length > 0 ? /* @__PURE__ */ jsx("ul", { className: "sg-cp-orphans", children: orphans.map((reason) => /* @__PURE__ */ jsx("li", { children: humanizeComplianceReason(reason) }, reason)) }) : null,
|
|
3493
3533
|
direct && checks.length > 0 ? /* @__PURE__ */ jsx("p", { className: "sg-cp-scope", children: DIRECT_SCOPE_NOTE }) : null
|
|
3494
3534
|
] }),
|
|
@@ -3682,6 +3722,398 @@ function useWalletHistory(engine, wallets) {
|
|
|
3682
3722
|
}, [engine, key]);
|
|
3683
3723
|
return entries;
|
|
3684
3724
|
}
|
|
3725
|
+
var lower = (s) => (s ?? "").toLowerCase();
|
|
3726
|
+
var ZDH_RECHECK_MS = 15e3;
|
|
3727
|
+
var ZDH_RECHECK_FOR_MS = 30 * 6e4;
|
|
3728
|
+
var inFlight = /* @__PURE__ */ new Set();
|
|
3729
|
+
var writes = /* @__PURE__ */ new Map();
|
|
3730
|
+
var listeners = /* @__PURE__ */ new Set();
|
|
3731
|
+
var notify = () => {
|
|
3732
|
+
for (const listener of listeners) listener();
|
|
3733
|
+
};
|
|
3734
|
+
var hidden3 = () => typeof document !== "undefined" && document.visibilityState === "hidden";
|
|
3735
|
+
var unresolved = (w) => !!w && (w.status === "checking" || w.status === "stalled");
|
|
3736
|
+
var lockKey = (account, orderId, chainId, kind, asset) => `${lower(account)}:${lower(orderId)}:${chainId}:${kind}:${kind === "claim" ? lower(asset) : ""}`;
|
|
3737
|
+
function cancelScope(keys) {
|
|
3738
|
+
const norm = keys.map((k) => {
|
|
3739
|
+
try {
|
|
3740
|
+
return BigInt(k).toString();
|
|
3741
|
+
} catch {
|
|
3742
|
+
return k;
|
|
3743
|
+
}
|
|
3744
|
+
});
|
|
3745
|
+
return `cancel:${[...new Set(norm)].sort().join(",")}`;
|
|
3746
|
+
}
|
|
3747
|
+
var claimScope = (asset, amount) => `claim:${lower(asset)}:${amount ?? ""}`;
|
|
3748
|
+
async function check2(key) {
|
|
3749
|
+
const w = writes.get(key);
|
|
3750
|
+
if (!w || w.checking || !unresolved(w)) return;
|
|
3751
|
+
w.checking = true;
|
|
3752
|
+
let status;
|
|
3753
|
+
try {
|
|
3754
|
+
status = (await w.engine.verifySubmittedTx({ chainId: w.chainId, hash: w.hash, ...w.tx, minNonce: w.minNonce ?? 0 })).status;
|
|
3755
|
+
} catch {
|
|
3756
|
+
status = "unconfirmed";
|
|
3757
|
+
}
|
|
3758
|
+
w.checking = false;
|
|
3759
|
+
if (writes.get(key) !== w) return;
|
|
3760
|
+
if (status === "confirmed" || status === "reverted") {
|
|
3761
|
+
if (w.timer) clearTimeout(w.timer);
|
|
3762
|
+
w.timer = void 0;
|
|
3763
|
+
w.status = status;
|
|
3764
|
+
notify();
|
|
3765
|
+
if (status === "confirmed") {
|
|
3766
|
+
try {
|
|
3767
|
+
window.dispatchEvent(new CustomEvent(TX_HISTORY_EVENT, { detail: { account: lower(w.tx.from) } }));
|
|
3768
|
+
} catch {
|
|
3769
|
+
}
|
|
3770
|
+
}
|
|
3771
|
+
}
|
|
3772
|
+
}
|
|
3773
|
+
function schedule(key) {
|
|
3774
|
+
const w = writes.get(key);
|
|
3775
|
+
if (!w) return;
|
|
3776
|
+
if (w.timer) clearTimeout(w.timer);
|
|
3777
|
+
w.timer = void 0;
|
|
3778
|
+
if (w.status !== "checking") return;
|
|
3779
|
+
if (Date.now() - w.since >= ZDH_RECHECK_FOR_MS) {
|
|
3780
|
+
w.status = "stalled";
|
|
3781
|
+
notify();
|
|
3782
|
+
return;
|
|
3783
|
+
}
|
|
3784
|
+
w.timer = setTimeout(async () => {
|
|
3785
|
+
w.timer = void 0;
|
|
3786
|
+
if (!hidden3()) await check2(key);
|
|
3787
|
+
schedule(key);
|
|
3788
|
+
}, ZDH_RECHECK_MS);
|
|
3789
|
+
}
|
|
3790
|
+
function useZdHeavyAction(a) {
|
|
3791
|
+
const [phase, setPhase] = useState("idle");
|
|
3792
|
+
const [error, setError] = useState(null);
|
|
3793
|
+
const [switching, setSwitching] = useState(false);
|
|
3794
|
+
const alive = useRef(true);
|
|
3795
|
+
const [, rerender] = useReducer((n) => n + 1, 0);
|
|
3796
|
+
useEffect(() => {
|
|
3797
|
+
alive.current = true;
|
|
3798
|
+
listeners.add(rerender);
|
|
3799
|
+
return () => {
|
|
3800
|
+
alive.current = false;
|
|
3801
|
+
listeners.delete(rerender);
|
|
3802
|
+
};
|
|
3803
|
+
}, []);
|
|
3804
|
+
const walletEpoch = useRef(0);
|
|
3805
|
+
const walletKey = `${lower(a.account)}:${a.walletChainId ?? ""}`;
|
|
3806
|
+
const lastWalletKey = useRef(walletKey);
|
|
3807
|
+
if (lastWalletKey.current !== walletKey) {
|
|
3808
|
+
lastWalletKey.current = walletKey;
|
|
3809
|
+
walletEpoch.current += 1;
|
|
3810
|
+
}
|
|
3811
|
+
const key = a.account ? lockKey(a.account, a.orderId, a.chainId, a.kind, a.asset) : "";
|
|
3812
|
+
const write = key ? writes.get(key) : void 0;
|
|
3813
|
+
const scope = a.kind === "cancel" ? cancelScope(a.lotKeys ?? []) : claimScope(a.asset, a.amount);
|
|
3814
|
+
useEffect(() => {
|
|
3815
|
+
if (!key || !unresolved(writes.get(key))) return;
|
|
3816
|
+
void check2(key).then(() => schedule(key));
|
|
3817
|
+
}, [key]);
|
|
3818
|
+
const firedFor = useRef(null);
|
|
3819
|
+
const onConfirmed = a.onConfirmed;
|
|
3820
|
+
useEffect(() => {
|
|
3821
|
+
if (write?.status === "confirmed" && firedFor.current !== write.hash) {
|
|
3822
|
+
firedFor.current = write.hash;
|
|
3823
|
+
onConfirmed?.(write.hash);
|
|
3824
|
+
}
|
|
3825
|
+
});
|
|
3826
|
+
const supported = SUPPORTED_CHAIN_IDS.has(a.chainId);
|
|
3827
|
+
const connected2 = !!a.account && !!a.provider;
|
|
3828
|
+
const isOwner = !!a.account && lower(a.account) === lower(a.owner);
|
|
3829
|
+
const onChain = supported && a.walletChainId === a.chainId;
|
|
3830
|
+
const busy = phase === "preparing" || phase === "signing";
|
|
3831
|
+
const done = write?.status === "confirmed" && write.scope === scope;
|
|
3832
|
+
async function run() {
|
|
3833
|
+
const { engine, provider, account } = a;
|
|
3834
|
+
if (!engine || !provider || !account || !supported) return;
|
|
3835
|
+
const key2 = lockKey(account, a.orderId, a.chainId, a.kind, a.asset);
|
|
3836
|
+
const prior = writes.get(key2);
|
|
3837
|
+
if (unresolved(prior) || prior?.status === "confirmed" && prior.scope === scope) {
|
|
3838
|
+
setError(`This ${a.kind} was already sent. Wait for it to confirm.`);
|
|
3839
|
+
return;
|
|
3840
|
+
}
|
|
3841
|
+
if (inFlight.has(key2)) {
|
|
3842
|
+
setError(`This ${a.kind} is already in progress. Wait for it to finish.`);
|
|
3843
|
+
return;
|
|
3844
|
+
}
|
|
3845
|
+
if (prior) writes.delete(key2);
|
|
3846
|
+
inFlight.add(key2);
|
|
3847
|
+
const epoch = walletEpoch.current;
|
|
3848
|
+
const signer = account;
|
|
3849
|
+
const stale = () => !alive.current || walletEpoch.current !== epoch;
|
|
3850
|
+
setError(null);
|
|
3851
|
+
setPhase("preparing");
|
|
3852
|
+
try {
|
|
3853
|
+
const unsigned = a.kind === "cancel" ? await engine.buildZdHeavyCancelTx(a.orderId, a.chainId) : await engine.buildZdHeavyClaimTx(a.orderId, a.chainId, a.asset ?? "");
|
|
3854
|
+
const checked = a.kind === "cancel" ? checkZdHeavyCancelTx(unsigned, { orderId: a.orderId, owner: signer, chainId: a.chainId, lotKeys: a.lotKeys }) : checkZdHeavyClaimTx(unsigned, { owner: signer, chainId: a.chainId, token: a.asset ?? "" });
|
|
3855
|
+
if (!checked.ok) {
|
|
3856
|
+
if (alive.current) {
|
|
3857
|
+
setError(checked.reason);
|
|
3858
|
+
setPhase("idle");
|
|
3859
|
+
}
|
|
3860
|
+
return;
|
|
3861
|
+
}
|
|
3862
|
+
const minNonce = await engine.payerNonceBaseline(checked.chainId, signer);
|
|
3863
|
+
if (stale()) throw new Error(`The wallet changed while the ${a.kind} was prepared. Try again.`);
|
|
3864
|
+
const [walletChain, accounts] = await Promise.all([getChainId(provider), getAccounts(provider)]);
|
|
3865
|
+
if (stale()) throw new Error(`The wallet changed while the ${a.kind} was prepared. Try again.`);
|
|
3866
|
+
if (walletChain !== checked.chainId) throw new Error(`Switch your wallet to ${a.chainName} and try again.`);
|
|
3867
|
+
if (!accounts.some((x) => lower(x) === lower(signer))) throw new Error("The connected wallet changed. Try again.");
|
|
3868
|
+
setPhase("signing");
|
|
3869
|
+
const sentScope = a.kind === "cancel" ? cancelScope(decodeZdHeavyCancel(checked.tx.data).keys.map(String)) : claimScope(decodeZdHeavyClaim(checked.tx.data).token, a.amount);
|
|
3870
|
+
const hash = await sendTransaction(provider, { ...checked.tx, chainId: checked.chainId });
|
|
3871
|
+
writes.set(key2, {
|
|
3872
|
+
hash,
|
|
3873
|
+
chainId: checked.chainId,
|
|
3874
|
+
tx: checked.tx,
|
|
3875
|
+
minNonce,
|
|
3876
|
+
engine,
|
|
3877
|
+
scope: sentScope,
|
|
3878
|
+
since: Date.now(),
|
|
3879
|
+
status: "checking",
|
|
3880
|
+
checking: false
|
|
3881
|
+
});
|
|
3882
|
+
notify();
|
|
3883
|
+
if (alive.current) setPhase("idle");
|
|
3884
|
+
await check2(key2);
|
|
3885
|
+
schedule(key2);
|
|
3886
|
+
} catch (e) {
|
|
3887
|
+
if (!alive.current) return;
|
|
3888
|
+
const msg = normalizeWalletError(e, "");
|
|
3889
|
+
setError(msg ? `Could not ${a.kind === "claim" ? "claim" : "cancel"}: ${msg}` : `Could not prepare the ${a.kind}.`);
|
|
3890
|
+
setPhase("idle");
|
|
3891
|
+
} finally {
|
|
3892
|
+
inFlight.delete(key2);
|
|
3893
|
+
}
|
|
3894
|
+
}
|
|
3895
|
+
function retryCheck() {
|
|
3896
|
+
const w = key ? writes.get(key) : void 0;
|
|
3897
|
+
if (!w || !unresolved(w)) return;
|
|
3898
|
+
w.since = Date.now();
|
|
3899
|
+
w.status = "checking";
|
|
3900
|
+
notify();
|
|
3901
|
+
void check2(key).then(() => schedule(key));
|
|
3902
|
+
}
|
|
3903
|
+
const text = !connected2 ? "Connect wallet" : !supported ? `Unsupported network ${a.chainId}` : !isOwner ? a.kind === "claim" ? "Connected wallet is not the refund address" : "Connected wallet is not the order owner" : !onChain ? switching ? "Switching\u2026" : `Switch to ${a.chainName}` : done ? a.kind === "claim" ? "Claimed" : `Cancelled on ${a.chainName}` : phase === "preparing" ? "Preparing\u2026" : phase === "signing" ? "Signing\u2026" : a.label;
|
|
3904
|
+
const disabled = !connected2 ? !a.onConnect : !supported || !isOwner || (!onChain ? switching : busy || done || unresolved(write));
|
|
3905
|
+
function onClick() {
|
|
3906
|
+
if (busy || switching) return;
|
|
3907
|
+
if (!connected2) return a.onConnect?.();
|
|
3908
|
+
if (!onChain && supported && a.provider) {
|
|
3909
|
+
setSwitching(true);
|
|
3910
|
+
setError(null);
|
|
3911
|
+
switchChain(a.provider, a.chainId).catch((e) => alive.current && setError(normalizeWalletError(e, `Could not switch to ${a.chainName}.`))).finally(() => alive.current && setSwitching(false));
|
|
3912
|
+
return;
|
|
3913
|
+
}
|
|
3914
|
+
void run();
|
|
3915
|
+
}
|
|
3916
|
+
const reverted = write?.status === "reverted" ? `The ${a.kind} reverted on-chain. Nothing changed.` : null;
|
|
3917
|
+
return {
|
|
3918
|
+
text,
|
|
3919
|
+
disabled,
|
|
3920
|
+
onClick,
|
|
3921
|
+
retryCheck,
|
|
3922
|
+
sentHash: write?.hash ?? null,
|
|
3923
|
+
done,
|
|
3924
|
+
busy,
|
|
3925
|
+
error: error ?? reverted,
|
|
3926
|
+
pending: write?.status === "checking",
|
|
3927
|
+
stalled: write?.status === "stalled"
|
|
3928
|
+
};
|
|
3929
|
+
}
|
|
3930
|
+
var ZDH_PLAN_REFRESH_MS = 1e4;
|
|
3931
|
+
var hidden4 = () => typeof document !== "undefined" && document.visibilityState === "hidden";
|
|
3932
|
+
var settled = (plan) => plan.complete && (plan.finished === true || plan.state === "refund_complete");
|
|
3933
|
+
function useZdHeavyRecovery(engine, orderId) {
|
|
3934
|
+
const [state, setState] = useState({ orderId, value: { status: "loading" } });
|
|
3935
|
+
const readRef = useRef(() => {
|
|
3936
|
+
});
|
|
3937
|
+
useEffect(() => {
|
|
3938
|
+
setState({ orderId, value: { status: "loading" } });
|
|
3939
|
+
if (!engine || !isZdHeavyOrderId(orderId)) return;
|
|
3940
|
+
let alive = true;
|
|
3941
|
+
let timer2;
|
|
3942
|
+
let shown = false;
|
|
3943
|
+
let started2 = Date.now();
|
|
3944
|
+
const read = async () => {
|
|
3945
|
+
if (timer2) clearTimeout(timer2);
|
|
3946
|
+
timer2 = void 0;
|
|
3947
|
+
if (!hidden4()) {
|
|
3948
|
+
const plan = await engine.fetchZdHeavyCancellation(orderId);
|
|
3949
|
+
if (!alive) return;
|
|
3950
|
+
if (plan) {
|
|
3951
|
+
shown = true;
|
|
3952
|
+
setState({ orderId, value: { status: "ready", plan } });
|
|
3953
|
+
if (settled(plan)) return;
|
|
3954
|
+
} else if (!shown) {
|
|
3955
|
+
setState({ orderId, value: { status: "unavailable" } });
|
|
3956
|
+
}
|
|
3957
|
+
}
|
|
3958
|
+
if (Date.now() - started2 > DELIVERY_GIVE_UP_MS) return;
|
|
3959
|
+
timer2 = setTimeout(read, ZDH_PLAN_REFRESH_MS);
|
|
3960
|
+
};
|
|
3961
|
+
readRef.current = () => {
|
|
3962
|
+
started2 = Date.now();
|
|
3963
|
+
void read();
|
|
3964
|
+
};
|
|
3965
|
+
void read();
|
|
3966
|
+
return () => {
|
|
3967
|
+
alive = false;
|
|
3968
|
+
readRef.current = () => {
|
|
3969
|
+
};
|
|
3970
|
+
if (timer2) clearTimeout(timer2);
|
|
3971
|
+
};
|
|
3972
|
+
}, [engine, orderId]);
|
|
3973
|
+
const refresh = useCallback(() => readRef.current(), []);
|
|
3974
|
+
return { state: state.orderId === orderId ? state.value : { status: "loading" }, refresh };
|
|
3975
|
+
}
|
|
3976
|
+
function useZdHeavySourceBinding(engine, chainId, hash, orderId) {
|
|
3977
|
+
const key = `${chainId ?? ""}:${hash}:${orderId ?? ""}`;
|
|
3978
|
+
const [state, setState] = useState({ key, value: "checking" });
|
|
3979
|
+
useEffect(() => {
|
|
3980
|
+
setState({ key, value: "checking" });
|
|
3981
|
+
if (!engine || typeof chainId !== "number" || !isZdHeavyOrderId(orderId)) {
|
|
3982
|
+
setState({ key, value: "unbound" });
|
|
3983
|
+
return;
|
|
3984
|
+
}
|
|
3985
|
+
let alive = true;
|
|
3986
|
+
engine.verifyZdHeavySourceOrder(chainId, hash, orderId).then((r) => alive && setState({ key, value: r.ok ? "bound" : "unbound" })).catch(() => alive && setState({ key, value: "unbound" }));
|
|
3987
|
+
return () => {
|
|
3988
|
+
alive = false;
|
|
3989
|
+
};
|
|
3990
|
+
}, [engine, chainId, hash, orderId, key]);
|
|
3991
|
+
return state.key === key ? state.value : "checking";
|
|
3992
|
+
}
|
|
3993
|
+
var lower2 = (s) => (s ?? "").toLowerCase();
|
|
3994
|
+
var shortHash = (h) => `${h.slice(0, 10)}\u2026${h.slice(-8)}`;
|
|
3995
|
+
function showsZdHeavyRecovery(entry) {
|
|
3996
|
+
if (entry.protocol !== "zdheavy" || !isZdHeavyOrderId(entry.orderId)) return false;
|
|
3997
|
+
return !(entry.delivery === "delivered" && !entry.claimable);
|
|
3998
|
+
}
|
|
3999
|
+
function ZdHeavyRecovery(props) {
|
|
4000
|
+
const orderId = isZdHeavyOrderId(props.entry.orderId) ? props.entry.orderId : void 0;
|
|
4001
|
+
const binding = useZdHeavySourceBinding(props.engine, props.entry.chainId, props.entry.hash, orderId);
|
|
4002
|
+
const { state, refresh } = useZdHeavyRecovery(props.engine, binding === "bound" ? orderId : void 0);
|
|
4003
|
+
const view = state.status === "ready" ? zdHeavyRecovery(state.plan, props.account) : null;
|
|
4004
|
+
if (!orderId) return null;
|
|
4005
|
+
if (binding === "unbound") {
|
|
4006
|
+
return /* @__PURE__ */ jsx("p", { className: "sg-note sg-zdh-status", role: "status", "data-testid": "zdh-recovery-unbound", children: "This order could not be matched to its transaction on-chain, so it cannot be cancelled or claimed from here." });
|
|
4007
|
+
}
|
|
4008
|
+
if (state.status === "unavailable") {
|
|
4009
|
+
return /* @__PURE__ */ jsx("p", { className: "sg-note sg-zdh-status", role: "status", "aria-live": "polite", "data-testid": "zdh-recovery-unavailable", children: "Cancellation status is unavailable right now. It is checked again in a moment." });
|
|
4010
|
+
}
|
|
4011
|
+
if (binding === "checking" || state.status === "loading" || !view) {
|
|
4012
|
+
return /* @__PURE__ */ jsx("p", { className: "sg-note sg-zdh-status", role: "status", "aria-live": "polite", children: "Checking whether this order can be cancelled\u2026" });
|
|
4013
|
+
}
|
|
4014
|
+
const plan = state.plan;
|
|
4015
|
+
if (view.kind === "delivered" || view.kind === "not-owner") return null;
|
|
4016
|
+
const chainName3 = (id) => CHAIN_LABELS[id] || `Chain ${id}`;
|
|
4017
|
+
const listNames = (ids) => {
|
|
4018
|
+
const names = ids.map(chainName3);
|
|
4019
|
+
return names.length <= 1 ? names[0] ?? "" : `${names.slice(0, -1).join(", ")} and ${names[names.length - 1]}`;
|
|
4020
|
+
};
|
|
4021
|
+
const amountLabel = (chainId, asset, amount) => {
|
|
4022
|
+
const t = (props.tokens ?? []).find((x) => Number(x.chainId) === chainId && lower2(String(x.address)) === lower2(asset));
|
|
4023
|
+
if (!t) return "your funds";
|
|
4024
|
+
try {
|
|
4025
|
+
return `${formatUnits(amount, Number(t.decimals))} ${t.symbol}`;
|
|
4026
|
+
} catch {
|
|
4027
|
+
return t.symbol;
|
|
4028
|
+
}
|
|
4029
|
+
};
|
|
4030
|
+
const bid = props.entry.fromTicker || props.entry.fromAsset || "funds";
|
|
4031
|
+
let headline;
|
|
4032
|
+
let body;
|
|
4033
|
+
let actions = [];
|
|
4034
|
+
let refunds = [];
|
|
4035
|
+
if (view.kind === "claim") {
|
|
4036
|
+
headline = "Ready to claim";
|
|
4037
|
+
body = `The refund could not be sent to your wallet automatically, so it is waiting for you on ${listNames([...new Set(view.claims.map((c) => c.chainId))])}. Confirm the claim in your wallet to receive it.`;
|
|
4038
|
+
actions = view.claims.map((c) => ({
|
|
4039
|
+
// The signer is part of the key: another wallet's claim is another button, not this one's state.
|
|
4040
|
+
key: `claim:${c.chainId}:${c.token}:${props.account ?? ""}`,
|
|
4041
|
+
kind: "claim",
|
|
4042
|
+
chainId: c.chainId,
|
|
4043
|
+
asset: c.token,
|
|
4044
|
+
amount: c.amount,
|
|
4045
|
+
label: `Claim ${amountLabel(c.chainId, c.token, c.amount)}`,
|
|
4046
|
+
// The payee: the claim reads claimable[msg.sender], so only it can send this.
|
|
4047
|
+
owner: props.account ?? ""
|
|
4048
|
+
}));
|
|
4049
|
+
} else if (view.kind === "cancel") {
|
|
4050
|
+
const holding = plan.places.some((p) => p.lots.length > 0);
|
|
4051
|
+
headline = view.requested ? "Finish the cancellation" : "You can cancel this order and reclaim your funds";
|
|
4052
|
+
body = view.requested ? `Part of your ${bid} is still held by the order router on ${listNames(view.chains)}. Cancel there too to have it refunded.` : holding ? view.chains.length > 1 ? `Your ${bid} is held by the order router on ${listNames(view.chains)}. Cancel on each network to have it refunded, one signature per network.` : `Your ${bid} is held by the order router on ${listNames(view.chains)}. Cancel it and the router refunds what it holds in the same transaction.` : `Your ${bid} is on its way between networks. If you cancel, the order stops and the funds are refunded when they land; you may be asked to cancel once more on the network they reach.`;
|
|
4053
|
+
actions = view.chains.map((chainId) => {
|
|
4054
|
+
const lots = plan.places.find((p) => p.kind === "router" && p.chainId === chainId)?.lots ?? [];
|
|
4055
|
+
return {
|
|
4056
|
+
key: `cancel:${chainId}:${props.account ?? ""}`,
|
|
4057
|
+
kind: "cancel",
|
|
4058
|
+
chainId,
|
|
4059
|
+
label: view.chains.length > 1 || view.requested ? `Cancel on ${chainName3(chainId)}` : "Cancel order",
|
|
4060
|
+
owner: plan.owner,
|
|
4061
|
+
lotKeys: lots.length ? lots.map((l) => l.key) : void 0
|
|
4062
|
+
};
|
|
4063
|
+
});
|
|
4064
|
+
} else if (view.kind === "refunded") {
|
|
4065
|
+
headline = "Cancellation reported by ZeroDelta";
|
|
4066
|
+
body = `ZeroDelta reports your ${bid} as refunded. This widget has not checked the refund on-chain.`;
|
|
4067
|
+
refunds = view.refunds.map((r) => r.txHash);
|
|
4068
|
+
} else {
|
|
4069
|
+
headline = "What happens next";
|
|
4070
|
+
body = "Your cancellation is in. Funds still travelling between networks are refunded when they land; this page updates by itself.";
|
|
4071
|
+
}
|
|
4072
|
+
return /* @__PURE__ */ jsxs("div", { className: "sg-zdh", "data-testid": "zdh-recovery", "data-zdh-recovery": view.kind, children: [
|
|
4073
|
+
/* @__PURE__ */ jsx("div", { className: "sg-zdh-title", children: headline }),
|
|
4074
|
+
/* @__PURE__ */ jsx("p", { className: "sg-zdh-body", children: body }),
|
|
4075
|
+
actions.length > 0 ? /* @__PURE__ */ jsx("div", { className: "sg-zdh-actions", children: actions.map(({ key, ...a }) => /* @__PURE__ */ jsx(
|
|
4076
|
+
ZdHeavyActionButton,
|
|
4077
|
+
{
|
|
4078
|
+
...a,
|
|
4079
|
+
engine: props.engine,
|
|
4080
|
+
provider: props.provider,
|
|
4081
|
+
account: props.account,
|
|
4082
|
+
walletChainId: props.walletChainId,
|
|
4083
|
+
onConnect: props.onConnect,
|
|
4084
|
+
orderId,
|
|
4085
|
+
chainName: chainName3(a.chainId),
|
|
4086
|
+
onConfirmed: refresh
|
|
4087
|
+
},
|
|
4088
|
+
key
|
|
4089
|
+
)) }) : null,
|
|
4090
|
+
refunds.map((hash) => /* @__PURE__ */ jsxs("div", { className: "sg-txd-hash", children: [
|
|
4091
|
+
/* @__PURE__ */ jsx("span", { className: "sg-meta-label", children: "Reported refund tx" }),
|
|
4092
|
+
/* @__PURE__ */ jsx("span", { className: "sg-mono", children: shortHash(hash) })
|
|
4093
|
+
] }, hash))
|
|
4094
|
+
] });
|
|
4095
|
+
}
|
|
4096
|
+
function ZdHeavyActionButton(args) {
|
|
4097
|
+
const a = useZdHeavyAction(args);
|
|
4098
|
+
return /* @__PURE__ */ jsxs("div", { className: "sg-zdh-action", children: [
|
|
4099
|
+
a.pending ? (
|
|
4100
|
+
// A write of this wallet for this order is broadcast and its receipt has not decided: no button,
|
|
4101
|
+
// on this mount or any later one, until it does (re-review 2026-12-01, finding 4).
|
|
4102
|
+
/* @__PURE__ */ jsx("p", { className: "sg-note", role: "status", "aria-live": "polite", "data-testid": "zdh-action-pending", children: "Sent \u2014 confirming" })
|
|
4103
|
+
) : a.stalled ? (
|
|
4104
|
+
// Still undecided after the bounded recheck: say so, and offer another CHECK — never a new send.
|
|
4105
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4106
|
+
/* @__PURE__ */ jsx("p", { className: "sg-note", role: "status", "data-testid": "zdh-action-stalled", children: "Not confirmed yet \u2014 check the transaction" }),
|
|
4107
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "sg-btn sg-btn-ghost", onClick: a.retryCheck, children: "Retry check" })
|
|
4108
|
+
] })
|
|
4109
|
+
) : /* @__PURE__ */ jsx("button", { type: "button", className: "sg-btn sg-btn-ghost", onClick: a.onClick, disabled: a.disabled, "data-zdh-action": args.kind, children: a.text }),
|
|
4110
|
+
a.error ? /* @__PURE__ */ jsx("p", { className: "sg-ws-error", role: "alert", "data-testid": "zdh-action-error", children: a.error }) : null,
|
|
4111
|
+
a.sentHash ? /* @__PURE__ */ jsxs("div", { className: "sg-txd-hash", children: [
|
|
4112
|
+
/* @__PURE__ */ jsx("span", { className: "sg-meta-label", children: args.kind === "claim" ? "Claim tx" : "Cancel tx" }),
|
|
4113
|
+
/* @__PURE__ */ jsx("span", { className: "sg-mono", children: shortHash(a.sentHash) })
|
|
4114
|
+
] }) : null
|
|
4115
|
+
] });
|
|
4116
|
+
}
|
|
3685
4117
|
function BackGlyph() {
|
|
3686
4118
|
return /* @__PURE__ */ jsxs("svg", { width: "17", height: "17", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.4", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
|
|
3687
4119
|
/* @__PURE__ */ jsx("path", { d: "M19 12H5" }),
|
|
@@ -3768,6 +4200,7 @@ function TxLegs(props) {
|
|
|
3768
4200
|
function statusBadge(entry) {
|
|
3769
4201
|
if (entry.delivery === "delivered")
|
|
3770
4202
|
return /* @__PURE__ */ jsx("span", { className: "sg-badge", "data-tone": "ok", children: "Delivered" });
|
|
4203
|
+
if (entry.delivery === "failed" && entry.deliveryStatus === "cancelled") return /* @__PURE__ */ jsx("span", { className: "sg-badge", children: "Cancellation reported" });
|
|
3771
4204
|
if (entry.delivery === "failed")
|
|
3772
4205
|
return /* @__PURE__ */ jsx("span", { className: "sg-badge", "data-tone": "warn", children: "Not delivered" });
|
|
3773
4206
|
if (entry.delivery === "attention")
|
|
@@ -3912,7 +4345,20 @@ function TxDetail(props) {
|
|
|
3912
4345
|
/* @__PURE__ */ jsx("span", { className: "sg-meta-label", children: "Tx hash" }),
|
|
3913
4346
|
/* @__PURE__ */ jsx("span", { className: "sg-mono", children: `${e.hash.slice(0, 10)}\u2026${e.hash.slice(-8)}` }),
|
|
3914
4347
|
/* @__PURE__ */ jsx("button", { type: "button", className: "sg-copy", onClick: copyHash, "aria-label": copied ? "Copied" : "Copy transaction hash", "aria-live": "polite", title: "Copy transaction hash", children: copied ? /* @__PURE__ */ jsx(CheckGlyph, {}) : /* @__PURE__ */ jsx(CopyGlyph, {}) })
|
|
3915
|
-
] })
|
|
4348
|
+
] }),
|
|
4349
|
+
props.recovery?.engine && showsZdHeavyRecovery(e) ? /* @__PURE__ */ jsx(
|
|
4350
|
+
ZdHeavyRecovery,
|
|
4351
|
+
{
|
|
4352
|
+
entry: e,
|
|
4353
|
+
engine: props.recovery.engine,
|
|
4354
|
+
provider: props.recovery.provider,
|
|
4355
|
+
account: props.recovery.account,
|
|
4356
|
+
walletChainId: props.recovery.walletChainId,
|
|
4357
|
+
onConnect: props.recovery.onConnect,
|
|
4358
|
+
tokens: props.tokens
|
|
4359
|
+
},
|
|
4360
|
+
e.orderId
|
|
4361
|
+
) : null
|
|
3916
4362
|
] });
|
|
3917
4363
|
}
|
|
3918
4364
|
function displayableHistory(entries, account) {
|
|
@@ -3941,7 +4387,15 @@ function TxHistoryPanel(props) {
|
|
|
3941
4387
|
account ? /* @__PURE__ */ jsx("span", { className: "sg-sel-sub sg-mono", children: shortAddress(account) }) : null
|
|
3942
4388
|
] })
|
|
3943
4389
|
] }),
|
|
3944
|
-
selected ? /* @__PURE__ */ jsx(
|
|
4390
|
+
selected ? /* @__PURE__ */ jsx(
|
|
4391
|
+
TxDetail,
|
|
4392
|
+
{
|
|
4393
|
+
entry: selected,
|
|
4394
|
+
tokens: props.tokens,
|
|
4395
|
+
vaultIcons: props.vaultIcons,
|
|
4396
|
+
recovery: { engine: props.engine, provider: props.provider, account, walletChainId: props.walletChainId, onConnect: props.onConnect }
|
|
4397
|
+
}
|
|
4398
|
+
) : /* @__PURE__ */ jsx(TxHistoryList, { entries, tokens: props.tokens, vaultIcons: props.vaultIcons, onPick: pick })
|
|
3945
4399
|
] });
|
|
3946
4400
|
}
|
|
3947
4401
|
|
|
@@ -3973,7 +4427,7 @@ function registry(win) {
|
|
|
3973
4427
|
const existing = registries.get(win);
|
|
3974
4428
|
if (existing) return existing;
|
|
3975
4429
|
const standard = /* @__PURE__ */ new Set();
|
|
3976
|
-
const
|
|
4430
|
+
const listeners2 = /* @__PURE__ */ new Set();
|
|
3977
4431
|
let snapshot = EMPTY;
|
|
3978
4432
|
const read = () => {
|
|
3979
4433
|
const candidates = [...standard].map(solanaWalletInfo);
|
|
@@ -4004,7 +4458,7 @@ function registry(win) {
|
|
|
4004
4458
|
const refresh = () => {
|
|
4005
4459
|
const previous = snapshot;
|
|
4006
4460
|
read();
|
|
4007
|
-
if (previous !== snapshot) for (const cb of
|
|
4461
|
+
if (previous !== snapshot) for (const cb of listeners2) cb();
|
|
4008
4462
|
};
|
|
4009
4463
|
const api = {
|
|
4010
4464
|
register(...wallets) {
|
|
@@ -4018,9 +4472,9 @@ function registry(win) {
|
|
|
4018
4472
|
}
|
|
4019
4473
|
};
|
|
4020
4474
|
const result = { read, watch: (cb) => {
|
|
4021
|
-
|
|
4475
|
+
listeners2.add(cb);
|
|
4022
4476
|
return () => {
|
|
4023
|
-
|
|
4477
|
+
listeners2.delete(cb);
|
|
4024
4478
|
};
|
|
4025
4479
|
} };
|
|
4026
4480
|
registries.set(win, result);
|
|
@@ -5477,7 +5931,7 @@ function PaymentIsland(props) {
|
|
|
5477
5931
|
] });
|
|
5478
5932
|
let body;
|
|
5479
5933
|
if (hist && wallet.account) {
|
|
5480
|
-
body = /* @__PURE__ */ jsx(TxHistoryPanel, { account: wallet.account, engine, tokens: registryTokens, vaultIcons: catalogue?.vaultIcons, initialEntry: hist.entry ?? null, onBack: closeHistory });
|
|
5934
|
+
body = /* @__PURE__ */ jsx(TxHistoryPanel, { account: wallet.account, engine, provider: wallet.provider, walletChainId: wallet.chainId, onConnect: wallet.connect, tokens: registryTokens, vaultIcons: catalogue?.vaultIcons, initialEntry: hist.entry ?? null, onBack: closeHistory });
|
|
5481
5935
|
} else if (isPay && view === "select" && wallet.account) {
|
|
5482
5936
|
body = /* @__PURE__ */ jsx(
|
|
5483
5937
|
TokenSelect,
|
|
@@ -6075,7 +6529,7 @@ function PayCard(props) {
|
|
|
6075
6529
|
...durationLabel(sel.quote.estimatedDuration) ? [{ label: "Estimated time", value: durationLabel(sel.quote.estimatedDuration) }] : []
|
|
6076
6530
|
] : [];
|
|
6077
6531
|
const loadingPlan = flow.status === "loading" || holdings.loading && !sel || pricing !== null;
|
|
6078
|
-
return /* @__PURE__ */ jsx(WidgetShell, { title: config.title || "Complete payment", theme: config.theme, heightPx: props.heightPx, walletSlot, onClose: props.onClose, children: hist && wallet.account ? /* @__PURE__ */ jsx(TxHistoryPanel, { account: wallet.account, engine, tokens: registryTokens, vaultIcons: catalogue?.vaultIcons, initialEntry: hist.entry ?? null, onBack: closeHistory }) : view === "select" && wallet.account ? /* @__PURE__ */ jsx(
|
|
6532
|
+
return /* @__PURE__ */ jsx(WidgetShell, { title: config.title || "Complete payment", theme: config.theme, heightPx: props.heightPx, walletSlot, onClose: props.onClose, children: hist && wallet.account ? /* @__PURE__ */ jsx(TxHistoryPanel, { account: wallet.account, engine, provider: wallet.provider, walletChainId: wallet.chainId, onConnect: wallet.connect, tokens: registryTokens, vaultIcons: catalogue?.vaultIcons, initialEntry: hist.entry ?? null, onBack: closeHistory }) : view === "select" && wallet.account ? /* @__PURE__ */ jsx(
|
|
6079
6533
|
TokenSelect,
|
|
6080
6534
|
{
|
|
6081
6535
|
title: "Pay with",
|
|
@@ -6260,7 +6714,7 @@ function StableGenieSwap(props) {
|
|
|
6260
6714
|
/* @__PURE__ */ jsx("div", { className: "sg-brand", children: "ZeroDelta" })
|
|
6261
6715
|
] }) : void 0;
|
|
6262
6716
|
if (hist && wallet.account) {
|
|
6263
|
-
return /* @__PURE__ */ jsx(WidgetShell, { title: config.title || "Swap", theme: config.theme, walletSlot, children: /* @__PURE__ */ jsx(TxHistoryPanel, { account: wallet.account, engine, tokens: registryTokens, vaultIcons: catalogue?.vaultIcons, initialEntry: hist.entry ?? null, onBack: closeHistory }) });
|
|
6717
|
+
return /* @__PURE__ */ jsx(WidgetShell, { title: config.title || "Swap", theme: config.theme, walletSlot, children: /* @__PURE__ */ jsx(TxHistoryPanel, { account: wallet.account, engine, provider: wallet.provider, walletChainId: wallet.chainId, onConnect: wallet.connect, tokens: registryTokens, vaultIcons: catalogue?.vaultIcons, initialEntry: hist.entry ?? null, onBack: closeHistory }) });
|
|
6264
6718
|
}
|
|
6265
6719
|
if (recipientState.open) return /* @__PURE__ */ jsx(WidgetShell, { title: config.title || "Swap", theme: config.theme, walletSlot, children: /* @__PURE__ */ jsx(RecipientSheet, { state: recipientState, symbol: toAsset }) });
|
|
6266
6720
|
if (flow.status === "success" || flow.status === "pending") {
|
|
@@ -6550,16 +7004,16 @@ function Hint({ id, label: label2, text, hint }) {
|
|
|
6550
7004
|
open ? /* @__PURE__ */ jsx("span", { role: "tooltip", id: tipId, className: "sg-cd-tip", children: text }) : null
|
|
6551
7005
|
] });
|
|
6552
7006
|
}
|
|
6553
|
-
function CheckRow2({ check:
|
|
6554
|
-
const label2 =
|
|
6555
|
-
return /* @__PURE__ */ jsxs("li", { className: "sg-cd-check", "data-ok":
|
|
7007
|
+
function CheckRow2({ check: check3, hideNote }) {
|
|
7008
|
+
const label2 = check3.id === "risk" ? check3.ok ? "Risk screening passed" : "Risk screening failed" : check3.label;
|
|
7009
|
+
return /* @__PURE__ */ jsxs("li", { className: "sg-cd-check", "data-ok": check3.ok, children: [
|
|
6556
7010
|
/* @__PURE__ */ jsxs("span", { className: "sg-cd-check-line", children: [
|
|
6557
|
-
/* @__PURE__ */ jsx("span", { className: "sg-cd-check-mark", "data-ok":
|
|
7011
|
+
/* @__PURE__ */ jsx("span", { className: "sg-cd-check-mark", "data-ok": check3.ok, children: check3.ok ? /* @__PURE__ */ jsx(Tick, { size: 12 }) : /* @__PURE__ */ jsx(Cross, { size: 12 }) }),
|
|
6558
7012
|
/* @__PURE__ */ jsx("span", { className: "sg-cd-check-label", children: label2 }),
|
|
6559
|
-
/* @__PURE__ */ jsx("span", { className: "sg-sr-only", children:
|
|
7013
|
+
/* @__PURE__ */ jsx("span", { className: "sg-sr-only", children: check3.ok ? " \u2014 passed" : " \u2014 failed" })
|
|
6560
7014
|
] }),
|
|
6561
|
-
|
|
6562
|
-
|
|
7015
|
+
check3.note && !hideNote ? /* @__PURE__ */ jsx("span", { className: "sg-cd-check-note", children: check3.note }) : null,
|
|
7016
|
+
check3.reasons.map((reason) => /* @__PURE__ */ jsx("span", { className: "sg-cd-check-reason", children: humanizeComplianceReason(reason) }, reason))
|
|
6563
7017
|
] });
|
|
6564
7018
|
}
|
|
6565
7019
|
function Fact2({ label: label2, value, title, mono = false }) {
|
|
@@ -6594,10 +7048,10 @@ function QuoteChecks2(props) {
|
|
|
6594
7048
|
/* @__PURE__ */ jsx("p", { className: "sg-cd-summary-sub", children: "The gateway returned no compliance decision for this quote, so there is nothing to show. It is not a failed check." })
|
|
6595
7049
|
)
|
|
6596
7050
|
] }),
|
|
6597
|
-
checks.length > 0 ? /* @__PURE__ */ jsx("ul", { className: "sg-cd-checks", children: checks.map((
|
|
7051
|
+
checks.length > 0 ? /* @__PURE__ */ jsx("ul", { className: "sg-cd-checks", children: checks.map((check3) => (
|
|
6598
7052
|
// The Figma row carries no sub-line: with ONE screened wallet the note would repeat the
|
|
6599
7053
|
// address Quote details names two cards down. Any other note (a count of wallets) stays.
|
|
6600
|
-
/* @__PURE__ */ jsx(CheckRow2, { check:
|
|
7054
|
+
/* @__PURE__ */ jsx(CheckRow2, { check: check3, hideNote: check3.id === "screening" && wallets.length === 1 && hasDetails }, check3.id)
|
|
6601
7055
|
)) }) : null,
|
|
6602
7056
|
orphans.length > 0 ? /* @__PURE__ */ jsx("ul", { className: "sg-cd-orphans", children: orphans.map((reason) => /* @__PURE__ */ jsx("li", { children: humanizeComplianceReason(reason) }, reason)) }) : null,
|
|
6603
7057
|
props.direct && checks.length > 0 ? /* @__PURE__ */ jsx("p", { className: "sg-cd-scope", children: DIRECT_SCOPE_NOTE }) : null
|
|
@@ -7052,10 +7506,10 @@ function QuoteCard(props) {
|
|
|
7052
7506
|
const hops = option.hops;
|
|
7053
7507
|
const collapsed = side && hops.length > 3;
|
|
7054
7508
|
const inline = collapsed ? [hops[0], hops[1], "gap", hops[hops.length - 1]] : hops;
|
|
7055
|
-
const
|
|
7509
|
+
const hidden5 = collapsed ? hops.slice(2, -1) : [];
|
|
7056
7510
|
const routeIcons = /* @__PURE__ */ jsx("span", { className: "sg-cq-route-icons", "data-testid": "compare-route-inline", children: inline.map((hop, i) => /* @__PURE__ */ jsxs("span", { className: "sg-cq-hop-inline", children: [
|
|
7057
7511
|
i > 0 ? /* @__PURE__ */ jsx(ArrowGlyph2, {}) : null,
|
|
7058
|
-
hop === "gap" ? /* @__PURE__ */ jsx("button", { type: "button", className: "sg-cq-gap", title:
|
|
7512
|
+
hop === "gap" ? /* @__PURE__ */ jsx("button", { type: "button", className: "sg-cq-gap", title: hidden5.map((h) => `${h.ticker} on ${props.chainName(h.chainId)}`).join(" \u2192 "), "aria-label": `Also via ${hidden5.map((h) => `${h.ticker} on ${props.chainName(h.chainId)}`).join(", ")}`, children: "\u2026" }) : /* @__PURE__ */ jsx("span", { title: `${hop.ticker} on ${props.chainName(hop.chainId)}`, children: /* @__PURE__ */ jsx(HopMark, { hop, tokens: props.tokens, size: "xxs" }) })
|
|
7059
7513
|
] }, hop === "gap" ? "gap" : `${hop.chainId}-${hop.address}-${i}`)) });
|
|
7060
7514
|
const fee = compareFeeLabel(option.feeUsd);
|
|
7061
7515
|
const tagEl = tags.length > 0 ? /* @__PURE__ */ jsx("span", { ref: tagRef, className: "sg-cq-tag", "data-kind": nettingTag ? "netting" : purple ? "purple" : "brand", children: tags.map((tag, i) => /* @__PURE__ */ jsxs("span", { className: "sg-cq-tag-item", children: [
|
|
@@ -7778,7 +8232,7 @@ function ExchangeCard(props) {
|
|
|
7778
8232
|
let body;
|
|
7779
8233
|
let takeover = false;
|
|
7780
8234
|
if (hist && connected2) {
|
|
7781
|
-
body = /* @__PURE__ */ jsx(TxHistoryPanel, { account: wallet.account, engine, solanaAccount: solanaWallet.address, tokens, vaultIcons: catalogue?.vaultIcons, initialEntry: hist.entry ?? null, onBack: closeHistory });
|
|
8235
|
+
body = /* @__PURE__ */ jsx(TxHistoryPanel, { account: wallet.account, engine, provider: wallet.provider, walletChainId: wallet.chainId, onConnect: wallet.connect, solanaAccount: solanaWallet.address, tokens, vaultIcons: catalogue?.vaultIcons, initialEntry: hist.entry ?? null, onBack: closeHistory });
|
|
7782
8236
|
} else if (view === "from" || view === "to") {
|
|
7783
8237
|
const isFrom = view === "from";
|
|
7784
8238
|
body = /* @__PURE__ */ jsx(
|