@glacislabs/stablegenie-zerodelta 4.21.0 → 4.22.1
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/CHANGELOG.md +424 -0
- package/dist/{chunk-KOFREX5L.js → chunk-6TCVZRNB.js} +385 -31
- package/dist/{chunk-3E554IZO.js → chunk-WVDRVGBA.js} +474 -51
- package/dist/core/index.cjs +400 -30
- 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 +886 -109
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/{mount-C2GLFqgK.d.cts → mount-DC_JT0cE.d.cts} +1 -1
- package/dist/{mount-867H-JSe.d.ts → mount-GOYY_jNr.d.ts} +1 -1
- package/dist/mount.cjs +886 -109
- 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-CeHRSKl2.d.cts → verify-mpglrU7n.d.cts} +11 -1
- package/dist/{verify-CeHRSKl2.d.ts → verify-mpglrU7n.d.ts} +11 -1
- package/package.json +3 -2
|
@@ -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, 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, 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-6TCVZRNB.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
|
}
|
|
@@ -594,8 +596,8 @@ function useFlow(args) {
|
|
|
594
596
|
engine.fetchChains().catch(() => [])
|
|
595
597
|
]);
|
|
596
598
|
if (!alive) return;
|
|
597
|
-
const
|
|
598
|
-
setNativeShortfall(nativeFeeShortLabel(
|
|
599
|
+
const check3 = checkNativeFee(selected, balance);
|
|
600
|
+
setNativeShortfall(nativeFeeShortLabel(check3, nativeSymbol(Number(src.chainId), chains)));
|
|
599
601
|
} catch {
|
|
600
602
|
}
|
|
601
603
|
})();
|
|
@@ -632,10 +634,10 @@ function useFlow(args) {
|
|
|
632
634
|
if (after !== Number(sourceChainId)) throw new Error("Wallet did not switch to the source chain.");
|
|
633
635
|
}
|
|
634
636
|
if (routeNativeValue(route) > 0n) {
|
|
635
|
-
const
|
|
636
|
-
if (
|
|
637
|
+
const check3 = checkNativeFee(route, await nativeBalance(provider, account));
|
|
638
|
+
if (check3.short) {
|
|
637
639
|
const chains = await engine.fetchChains().catch(() => []);
|
|
638
|
-
throw new Error(nativeFeeShortMessage(
|
|
640
|
+
throw new Error(nativeFeeShortMessage(check3, nativeSymbol(Number(sourceChainId), chains), route.source.chainName));
|
|
639
641
|
}
|
|
640
642
|
}
|
|
641
643
|
const heavyExpected = route.zdHeavy ? zdHeavyExpected(route, account, recipient, ...await Promise.all([engine.fetchTokens(), engine.fetchRoutes()])) : void 0;
|
|
@@ -829,7 +831,7 @@ function useFlow(args) {
|
|
|
829
831
|
useEffect(() => {
|
|
830
832
|
if (!enabled || !selected?.zdHeavy || !quoteReady || quotePaused || busyRef.current) return;
|
|
831
833
|
let timer2;
|
|
832
|
-
const
|
|
834
|
+
const schedule2 = () => {
|
|
833
835
|
clearTimeout(timer2);
|
|
834
836
|
if (document.visibilityState !== "visible" || busyRef.current) return;
|
|
835
837
|
const delay = Math.max(3e3, (selected.zdHeavy.order.expiresAt - REFRESH_LEAD_SECONDS) * 1e3 - Date.now());
|
|
@@ -837,11 +839,11 @@ function useFlow(args) {
|
|
|
837
839
|
if (!busyRef.current && statusRef.current === "ready" && !isUserIdle() && document.visibilityState === "visible") reload();
|
|
838
840
|
}, delay);
|
|
839
841
|
};
|
|
840
|
-
|
|
841
|
-
document.addEventListener("visibilitychange",
|
|
842
|
+
schedule2();
|
|
843
|
+
document.addEventListener("visibilitychange", schedule2);
|
|
842
844
|
return () => {
|
|
843
845
|
clearTimeout(timer2);
|
|
844
|
-
document.removeEventListener("visibilitychange",
|
|
846
|
+
document.removeEventListener("visibilitychange", schedule2);
|
|
845
847
|
};
|
|
846
848
|
}, [enabled, selected, quoteReady, quotePaused, reload]);
|
|
847
849
|
return {
|
|
@@ -1424,6 +1426,13 @@ img.sg-tok-badge{width:16px;padding:0;object-fit:cover;background:var(--sg-bg)}
|
|
|
1424
1426
|
/* transaction detail: copyable hash row (no external links \u2014 everything stays in-widget) */
|
|
1425
1427
|
.sg-txd-hash{display:flex;align-items:center;gap:8px;margin-top:12px;font-size:13px}
|
|
1426
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}
|
|
1427
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}
|
|
1428
1437
|
.sg-copy:hover{color:var(--sg-accent);border-color:var(--sg-accent)}
|
|
1429
1438
|
|
|
@@ -2744,10 +2753,10 @@ var CHAIN_ALIASES = {
|
|
|
2744
2753
|
43114: ["avax"]
|
|
2745
2754
|
};
|
|
2746
2755
|
function labelForms(label2) {
|
|
2747
|
-
const
|
|
2748
|
-
if (!
|
|
2749
|
-
const compact =
|
|
2750
|
-
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];
|
|
2751
2760
|
}
|
|
2752
2761
|
function buildChainSearchTerms(chains) {
|
|
2753
2762
|
const byId = /* @__PURE__ */ new Map();
|
|
@@ -3470,22 +3479,22 @@ function TriggerGlyph({ cv }) {
|
|
|
3470
3479
|
if (cv.tone === "blocked" || cv.tone === "warn") return /* @__PURE__ */ jsx(CloseCircle, {});
|
|
3471
3480
|
return /* @__PURE__ */ jsx(ShieldTick, {});
|
|
3472
3481
|
}
|
|
3473
|
-
function CheckRow({ check:
|
|
3474
|
-
const label2 =
|
|
3475
|
-
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: [
|
|
3476
3485
|
/* @__PURE__ */ jsxs("div", { className: "sg-cp-check-head", children: [
|
|
3477
3486
|
/* @__PURE__ */ jsxs("span", { className: "sg-cp-check-label", children: [
|
|
3478
|
-
/* @__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, {}) }),
|
|
3479
3488
|
/* @__PURE__ */ jsx("span", { children: label2 }),
|
|
3480
|
-
/* @__PURE__ */ jsx("span", { className: "sg-sr-only", children:
|
|
3489
|
+
/* @__PURE__ */ jsx("span", { className: "sg-sr-only", children: check3.ok ? " \u2014 passed" : " \u2014 failed" })
|
|
3481
3490
|
] }),
|
|
3482
|
-
|
|
3491
|
+
check3.id === "risk" ? /* @__PURE__ */ jsxs("button", { type: "button", className: "sg-cp-link", onClick: onViewPolicy, children: [
|
|
3483
3492
|
"View policy",
|
|
3484
3493
|
/* @__PURE__ */ jsx(CornerArrow, {})
|
|
3485
3494
|
] }) : null
|
|
3486
3495
|
] }),
|
|
3487
|
-
|
|
3488
|
-
|
|
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))
|
|
3489
3498
|
] });
|
|
3490
3499
|
}
|
|
3491
3500
|
function QuoteChecks({
|
|
@@ -3519,7 +3528,7 @@ function QuoteChecks({
|
|
|
3519
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." })
|
|
3520
3529
|
)
|
|
3521
3530
|
] }),
|
|
3522
|
-
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,
|
|
3523
3532
|
orphans.length > 0 ? /* @__PURE__ */ jsx("ul", { className: "sg-cp-orphans", children: orphans.map((reason) => /* @__PURE__ */ jsx("li", { children: humanizeComplianceReason(reason) }, reason)) }) : null,
|
|
3524
3533
|
direct && checks.length > 0 ? /* @__PURE__ */ jsx("p", { className: "sg-cp-scope", children: DIRECT_SCOPE_NOTE }) : null
|
|
3525
3534
|
] }),
|
|
@@ -3713,6 +3722,398 @@ function useWalletHistory(engine, wallets) {
|
|
|
3713
3722
|
}, [engine, key]);
|
|
3714
3723
|
return entries;
|
|
3715
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
|
+
}
|
|
3716
4117
|
function BackGlyph() {
|
|
3717
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: [
|
|
3718
4119
|
/* @__PURE__ */ jsx("path", { d: "M19 12H5" }),
|
|
@@ -3799,6 +4200,7 @@ function TxLegs(props) {
|
|
|
3799
4200
|
function statusBadge(entry) {
|
|
3800
4201
|
if (entry.delivery === "delivered")
|
|
3801
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" });
|
|
3802
4204
|
if (entry.delivery === "failed")
|
|
3803
4205
|
return /* @__PURE__ */ jsx("span", { className: "sg-badge", "data-tone": "warn", children: "Not delivered" });
|
|
3804
4206
|
if (entry.delivery === "attention")
|
|
@@ -3943,7 +4345,20 @@ function TxDetail(props) {
|
|
|
3943
4345
|
/* @__PURE__ */ jsx("span", { className: "sg-meta-label", children: "Tx hash" }),
|
|
3944
4346
|
/* @__PURE__ */ jsx("span", { className: "sg-mono", children: `${e.hash.slice(0, 10)}\u2026${e.hash.slice(-8)}` }),
|
|
3945
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, {}) })
|
|
3946
|
-
] })
|
|
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
|
|
3947
4362
|
] });
|
|
3948
4363
|
}
|
|
3949
4364
|
function displayableHistory(entries, account) {
|
|
@@ -3972,7 +4387,15 @@ function TxHistoryPanel(props) {
|
|
|
3972
4387
|
account ? /* @__PURE__ */ jsx("span", { className: "sg-sel-sub sg-mono", children: shortAddress(account) }) : null
|
|
3973
4388
|
] })
|
|
3974
4389
|
] }),
|
|
3975
|
-
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 })
|
|
3976
4399
|
] });
|
|
3977
4400
|
}
|
|
3978
4401
|
|
|
@@ -4004,7 +4427,7 @@ function registry(win) {
|
|
|
4004
4427
|
const existing = registries.get(win);
|
|
4005
4428
|
if (existing) return existing;
|
|
4006
4429
|
const standard = /* @__PURE__ */ new Set();
|
|
4007
|
-
const
|
|
4430
|
+
const listeners2 = /* @__PURE__ */ new Set();
|
|
4008
4431
|
let snapshot = EMPTY;
|
|
4009
4432
|
const read = () => {
|
|
4010
4433
|
const candidates = [...standard].map(solanaWalletInfo);
|
|
@@ -4035,7 +4458,7 @@ function registry(win) {
|
|
|
4035
4458
|
const refresh = () => {
|
|
4036
4459
|
const previous = snapshot;
|
|
4037
4460
|
read();
|
|
4038
|
-
if (previous !== snapshot) for (const cb of
|
|
4461
|
+
if (previous !== snapshot) for (const cb of listeners2) cb();
|
|
4039
4462
|
};
|
|
4040
4463
|
const api = {
|
|
4041
4464
|
register(...wallets) {
|
|
@@ -4049,9 +4472,9 @@ function registry(win) {
|
|
|
4049
4472
|
}
|
|
4050
4473
|
};
|
|
4051
4474
|
const result = { read, watch: (cb) => {
|
|
4052
|
-
|
|
4475
|
+
listeners2.add(cb);
|
|
4053
4476
|
return () => {
|
|
4054
|
-
|
|
4477
|
+
listeners2.delete(cb);
|
|
4055
4478
|
};
|
|
4056
4479
|
} };
|
|
4057
4480
|
registries.set(win, result);
|
|
@@ -5508,7 +5931,7 @@ function PaymentIsland(props) {
|
|
|
5508
5931
|
] });
|
|
5509
5932
|
let body;
|
|
5510
5933
|
if (hist && wallet.account) {
|
|
5511
|
-
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 });
|
|
5512
5935
|
} else if (isPay && view === "select" && wallet.account) {
|
|
5513
5936
|
body = /* @__PURE__ */ jsx(
|
|
5514
5937
|
TokenSelect,
|
|
@@ -6106,7 +6529,7 @@ function PayCard(props) {
|
|
|
6106
6529
|
...durationLabel(sel.quote.estimatedDuration) ? [{ label: "Estimated time", value: durationLabel(sel.quote.estimatedDuration) }] : []
|
|
6107
6530
|
] : [];
|
|
6108
6531
|
const loadingPlan = flow.status === "loading" || holdings.loading && !sel || pricing !== null;
|
|
6109
|
-
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(
|
|
6110
6533
|
TokenSelect,
|
|
6111
6534
|
{
|
|
6112
6535
|
title: "Pay with",
|
|
@@ -6291,7 +6714,7 @@ function StableGenieSwap(props) {
|
|
|
6291
6714
|
/* @__PURE__ */ jsx("div", { className: "sg-brand", children: "ZeroDelta" })
|
|
6292
6715
|
] }) : void 0;
|
|
6293
6716
|
if (hist && wallet.account) {
|
|
6294
|
-
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 }) });
|
|
6295
6718
|
}
|
|
6296
6719
|
if (recipientState.open) return /* @__PURE__ */ jsx(WidgetShell, { title: config.title || "Swap", theme: config.theme, walletSlot, children: /* @__PURE__ */ jsx(RecipientSheet, { state: recipientState, symbol: toAsset }) });
|
|
6297
6720
|
if (flow.status === "success" || flow.status === "pending") {
|
|
@@ -6581,16 +7004,16 @@ function Hint({ id, label: label2, text, hint }) {
|
|
|
6581
7004
|
open ? /* @__PURE__ */ jsx("span", { role: "tooltip", id: tipId, className: "sg-cd-tip", children: text }) : null
|
|
6582
7005
|
] });
|
|
6583
7006
|
}
|
|
6584
|
-
function CheckRow2({ check:
|
|
6585
|
-
const label2 =
|
|
6586
|
-
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: [
|
|
6587
7010
|
/* @__PURE__ */ jsxs("span", { className: "sg-cd-check-line", children: [
|
|
6588
|
-
/* @__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 }) }),
|
|
6589
7012
|
/* @__PURE__ */ jsx("span", { className: "sg-cd-check-label", children: label2 }),
|
|
6590
|
-
/* @__PURE__ */ jsx("span", { className: "sg-sr-only", children:
|
|
7013
|
+
/* @__PURE__ */ jsx("span", { className: "sg-sr-only", children: check3.ok ? " \u2014 passed" : " \u2014 failed" })
|
|
6591
7014
|
] }),
|
|
6592
|
-
|
|
6593
|
-
|
|
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))
|
|
6594
7017
|
] });
|
|
6595
7018
|
}
|
|
6596
7019
|
function Fact2({ label: label2, value, title, mono = false }) {
|
|
@@ -6625,10 +7048,10 @@ function QuoteChecks2(props) {
|
|
|
6625
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." })
|
|
6626
7049
|
)
|
|
6627
7050
|
] }),
|
|
6628
|
-
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) => (
|
|
6629
7052
|
// The Figma row carries no sub-line: with ONE screened wallet the note would repeat the
|
|
6630
7053
|
// address Quote details names two cards down. Any other note (a count of wallets) stays.
|
|
6631
|
-
/* @__PURE__ */ jsx(CheckRow2, { check:
|
|
7054
|
+
/* @__PURE__ */ jsx(CheckRow2, { check: check3, hideNote: check3.id === "screening" && wallets.length === 1 && hasDetails }, check3.id)
|
|
6632
7055
|
)) }) : null,
|
|
6633
7056
|
orphans.length > 0 ? /* @__PURE__ */ jsx("ul", { className: "sg-cd-orphans", children: orphans.map((reason) => /* @__PURE__ */ jsx("li", { children: humanizeComplianceReason(reason) }, reason)) }) : null,
|
|
6634
7057
|
props.direct && checks.length > 0 ? /* @__PURE__ */ jsx("p", { className: "sg-cd-scope", children: DIRECT_SCOPE_NOTE }) : null
|
|
@@ -7083,10 +7506,10 @@ function QuoteCard(props) {
|
|
|
7083
7506
|
const hops = option.hops;
|
|
7084
7507
|
const collapsed = side && hops.length > 3;
|
|
7085
7508
|
const inline = collapsed ? [hops[0], hops[1], "gap", hops[hops.length - 1]] : hops;
|
|
7086
|
-
const
|
|
7509
|
+
const hidden5 = collapsed ? hops.slice(2, -1) : [];
|
|
7087
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: [
|
|
7088
7511
|
i > 0 ? /* @__PURE__ */ jsx(ArrowGlyph2, {}) : null,
|
|
7089
|
-
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" }) })
|
|
7090
7513
|
] }, hop === "gap" ? "gap" : `${hop.chainId}-${hop.address}-${i}`)) });
|
|
7091
7514
|
const fee = compareFeeLabel(option.feeUsd);
|
|
7092
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: [
|
|
@@ -7809,7 +8232,7 @@ function ExchangeCard(props) {
|
|
|
7809
8232
|
let body;
|
|
7810
8233
|
let takeover = false;
|
|
7811
8234
|
if (hist && connected2) {
|
|
7812
|
-
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 });
|
|
7813
8236
|
} else if (view === "from" || view === "to") {
|
|
7814
8237
|
const isFrom = view === "from";
|
|
7815
8238
|
body = /* @__PURE__ */ jsx(
|