@glacislabs/stablegenie-zerodelta 4.21.0 → 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/mount.cjs CHANGED
@@ -593,13 +593,22 @@ var MAX_STEPS = 8;
593
593
  function isZdHeavy(r, steps) {
594
594
  return r.protocol === "zdheavy" || steps.some((s) => Number(s.stepNumber ?? 0) >= ZDH_FIRST_STEP);
595
595
  }
596
+ var FILL_EVIDENCE = /* @__PURE__ */ new Set(["filled", "consumed", "step_executed", "paid_out", "delivered"]);
597
+ function ownerCancelServedAsDeliveryFailure(steps) {
598
+ const txHash = (s) => typeof s.txHash === "string" && /^0x[0-9a-fA-F]{64}$/.test(s.txHash);
599
+ const anyTx = (s) => typeof s.txHash === "string" && s.txHash.length > 0;
600
+ const cancelTx = steps.some((s) => s.stepName === "cancelled" && txHash(s));
601
+ const refunded = steps.some((s) => s.stepName === "refunded" && word(s.stepStatus) === "recovered" && txHash(s));
602
+ const filled = steps.some((s) => FILL_EVIDENCE.has(String(s.stepName)) && word(s.stepStatus) === "completed" && anyTx(s));
603
+ return cancelTx && refunded && !filled;
604
+ }
596
605
  function zdHeavyDelivery(own, rawSteps) {
597
606
  const named = rawSteps.filter((s) => s && typeof s === "object" && typeof s.stepName === "string");
598
607
  const lite = (name) => named.some((s) => Number(s.stepNumber ?? 0) < ZDH_FIRST_STEP && s.stepName === name && s.stepStatus === "completed");
599
608
  const events = named.map((s, i) => ({ s, i })).filter(({ s }) => Number(s.stepNumber ?? 0) >= ZDH_FIRST_STEP).sort((a, b) => (Date.parse(String(a.s.blockTimestamp ?? "")) || 0) - (Date.parse(String(b.s.blockTimestamp ?? "")) || 0) || a.i - b.i).map(({ s }) => s);
600
609
  const has = (name) => events.some((e) => e.stepName === name);
601
610
  const cancelled = has("cancelled");
602
- const status = PROGRESS.has(own) && has("paid_out") && !cancelled ? "delivered" : own;
611
+ const status = own === "delivery_failed" && ownerCancelServedAsDeliveryFailure(named) ? "cancelled" : PROGRESS.has(own) && has("paid_out") && !cancelled ? "delivered" : own;
603
612
  const steps = [];
604
613
  const push = (name, done) => {
605
614
  const last = steps[steps.length - 1];
@@ -690,7 +699,7 @@ function useDelivery(engine, hash2) {
690
699
  let unanswered = 0;
691
700
  const started2 = Date.now();
692
701
  setState({ hash: hash2, value: TRACKING });
693
- const schedule = () => {
702
+ const schedule2 = () => {
694
703
  if (Date.now() - started2 > DELIVERY_GIVE_UP_MS) {
695
704
  if (waitsOnOwner) return;
696
705
  return setState({ hash: hash2, value: UNAVAILABLE });
@@ -699,18 +708,18 @@ function useDelivery(engine, hash2) {
699
708
  };
700
709
  const tick = async () => {
701
710
  timer2 = void 0;
702
- if (hidden()) return schedule();
711
+ if (hidden()) return schedule2();
703
712
  const next = await engine.trackDelivery(hash2);
704
713
  if (!alive) return;
705
714
  if (next.phase === "tracking") {
706
715
  if (!answered && ++unanswered >= UNANSWERED_LIMIT) return setState({ hash: hash2, value: UNAVAILABLE });
707
- return schedule();
716
+ return schedule2();
708
717
  }
709
718
  answered = true;
710
719
  waitsOnOwner = next.phase === "attention";
711
720
  setState({ hash: hash2, value: next });
712
721
  if (next.phase === "delivered" || next.phase === "failed") return;
713
- schedule();
722
+ schedule2();
714
723
  };
715
724
  const onVisible2 = () => {
716
725
  if (!alive || hidden() || !timer2) return;
@@ -749,8 +758,8 @@ function deliveryHeadline(delivery, sourceConfirmed, direct2 = false) {
749
758
  case "delivered":
750
759
  return "Delivered";
751
760
  case "failed":
752
- if (delivery.status === "cancelled" && delivery.refunded) return "Cancelled \u2014 refunded to the owner";
753
- return delivery.status === "cancelled" ? "Cancelled \u2014 not delivered" : `Not delivered (${delivery.status.replace(/_/g, " ")}) \u2014 open the transaction for details`;
761
+ if (delivery.status === "cancelled" && delivery.refunded) return "Cancellation and refund reported by ZeroDelta";
762
+ return delivery.status === "cancelled" ? "Cancellation reported \u2014 not delivered" : `Not delivered (${delivery.status.replace(/_/g, " ")}) \u2014 open the transaction for details`;
754
763
  case "attention":
755
764
  return delivery.status === "cancel_pending" ? "Being cancelled \u2014 not delivered" : "Waiting to be claimed \u2014 open the transaction";
756
765
  case "in-progress": {
@@ -2564,7 +2573,10 @@ function historyEntryFromOrder(raw2, tokens) {
2564
2573
  const toAsset = (to?.symbol ?? (str(r.finalToTokenSymbol) || str(r.toTokenSymbol))).slice(0, 10);
2565
2574
  const payAmount = amountOf(str(r.fromTokenRawAmount), from, r.fromTokenDecimals, str(r.fromTokenAmount));
2566
2575
  const receiveAmount = str(r.finalToTokenRawAmount) ? amountOf(str(r.finalToTokenRawAmount), to, r.finalToTokenDecimals, str(r.finalToTokenAmount)) : amountOf(str(r.toTokenRawAmount), to, r.toTokenDecimals, str(r.toTokenAmount));
2567
- const delivery = normalizeDelivery(r).phase;
2576
+ const tracked = normalizeDelivery(r);
2577
+ const delivery = tracked.phase;
2578
+ const protocol = str(r.protocol);
2579
+ const orderId = str(r.orderId);
2568
2580
  const wallet = str(r.wallet);
2569
2581
  const receiver = str(r.destinationReceiver);
2570
2582
  const at = str(r.createdAt) || str(r.submittedAt);
@@ -2586,6 +2598,11 @@ function historyEntryFromOrder(raw2, tokens) {
2586
2598
  status: "submitted",
2587
2599
  at: Number.isNaN(Date.parse(at)) ? (/* @__PURE__ */ new Date(0)).toISOString() : new Date(at).toISOString(),
2588
2600
  delivery: delivery === "tracking" || delivery === "unavailable" ? void 0 : delivery,
2601
+ ...tracked.status && delivery !== "tracking" && delivery !== "unavailable" ? { deliveryStatus: tracked.status.slice(0, 32) } : {},
2602
+ .../^[a-z]{1,16}$/.test(protocol) ? { protocol } : {},
2603
+ // Only a router order id (bytes32) is carried: it is the one thing a recovery call puts in a URL.
2604
+ .../^0x[0-9a-fA-F]{64}$/.test(orderId) ? { orderId } : {},
2605
+ ...r.claimable === true ? { claimable: true } : {},
2589
2606
  legs: [
2590
2607
  {
2591
2608
  index: 1,
@@ -2633,7 +2650,17 @@ function mergeHistory(local, remote, limit = WALLET_HISTORY_LIMIT) {
2633
2650
  if (seen.has(key2)) continue;
2634
2651
  seen.add(key2);
2635
2652
  const known = byHash.get(key2);
2636
- out.push(known ? { ...entry, delivery: known.delivery, legs: entry.legs ?? known.legs } : entry);
2653
+ out.push(
2654
+ known ? {
2655
+ ...entry,
2656
+ delivery: known.delivery,
2657
+ legs: entry.legs ?? known.legs,
2658
+ deliveryStatus: known.deliveryStatus,
2659
+ protocol: known.protocol,
2660
+ orderId: known.orderId,
2661
+ claimable: known.claimable
2662
+ } : entry
2663
+ );
2637
2664
  }
2638
2665
  for (const [key2, entry] of byHash) if (!seen.has(key2)) out.push(entry);
2639
2666
  return out.sort((a, b) => Date.parse(b.at) - Date.parse(a.at)).slice(0, limit);
@@ -2710,13 +2737,13 @@ function checkNativeFee(route, balance) {
2710
2737
  const shortfall = required > balance ? required - balance : 0n;
2711
2738
  return { required, balance, short: shortfall > 0n, shortfall };
2712
2739
  }
2713
- function nativeFeeShortLabel(check2, symbol) {
2714
- if (!check2.short) return null;
2715
- return `Need ${formatNative(check2.required)} ${symbol} for the bridge fee`;
2740
+ function nativeFeeShortLabel(check3, symbol) {
2741
+ if (!check3.short) return null;
2742
+ return `Need ${formatNative(check3.required)} ${symbol} for the bridge fee`;
2716
2743
  }
2717
- function nativeFeeShortMessage(check2, symbol, chainName3) {
2718
- const need = formatNative(check2.required);
2719
- const have = formatNative(check2.balance ?? 0n);
2744
+ function nativeFeeShortMessage(check3, symbol, chainName3) {
2745
+ const need = formatNative(check3.required);
2746
+ const have = formatNative(check3.balance ?? 0n);
2720
2747
  const where = chainName3 ? ` on ${chainName3}` : "";
2721
2748
  return `This route bridges via LayerZero, which charges a ${need} ${symbol} network fee paid as part of the transaction. Your wallet holds ${have} ${symbol}${where}. Add ${symbol}${where} and try again \u2014 gas is owed on top of this fee.`;
2722
2749
  }
@@ -3475,16 +3502,16 @@ function normalizeOrderRequests(requests, payer, destination, fallbackExecutionC
3475
3502
  );
3476
3503
  }
3477
3504
  function assertQuoteMatchesSelection({ quote, order, orders, option, destinationToken, destination, payer, result, tokens = [] }) {
3478
- const list = orders?.length ? orders : [order];
3479
- const sourceOrder = list[0];
3480
- const finalOrder = list[list.length - 1];
3505
+ const list2 = orders?.length ? orders : [order];
3506
+ const sourceOrder = list2[0];
3507
+ const finalOrder = list2[list2.length - 1];
3481
3508
  const now = Math.floor(Date.now() / 1e3);
3482
3509
  const deadline = Number(sourceOrder.deadline || 0);
3483
3510
  const solana = isSolanaChainId(destination.chainId);
3484
3511
  if (solana && solanaDestinationAsset(destinationToken.address)?.symbol !== symbolKey(destinationToken.symbol)) {
3485
3512
  throw new Error("This Solana token is not supported for delivery; refusing to sign.");
3486
3513
  }
3487
- for (const current of list) {
3514
+ for (const current of list2) {
3488
3515
  if (normalizeAddress(current.owner) !== normalizeAddress(payer)) {
3489
3516
  throw new Error("ZeroDelta quote returned an owner that does not match the connected wallet.");
3490
3517
  }
@@ -3535,9 +3562,9 @@ function assertQuoteMatchesSelection({ quote, order, orders, option, destination
3535
3562
  if (!Number.isFinite(deadline) || deadline <= now || deadline > now + maxDeadline + DEADLINE_CLOCK_SKEW_SECONDS) {
3536
3563
  throw new Error("ZeroDelta quote deadline is invalid or too far in the future.");
3537
3564
  }
3538
- for (let index = 1; index < list.length; index += 1) {
3539
- const previous = list[index - 1];
3540
- const current = list[index];
3565
+ for (let index = 1; index < list2.length; index += 1) {
3566
+ const previous = list2[index - 1];
3567
+ const current = list2[index];
3541
3568
  if (normalizeAddress(previous.askToken) !== normalizeAddress(current.bidToken)) {
3542
3569
  throw new Error("ZeroDelta chained quote returned disconnected order tokens.");
3543
3570
  }
@@ -3614,10 +3641,10 @@ function keccak256Hex(bytes) {
3614
3641
  return out;
3615
3642
  }
3616
3643
  function toChecksumAddress(address) {
3617
- const lower3 = address.slice(2).toLowerCase();
3618
- const hash2 = keccak256Hex(new TextEncoder().encode(lower3));
3644
+ const lower6 = address.slice(2).toLowerCase();
3645
+ const hash2 = keccak256Hex(new TextEncoder().encode(lower6));
3619
3646
  let out = "0x";
3620
- for (let i = 0; i < 40; i++) out += Number.parseInt(hash2[i], 16) >= 8 ? lower3[i].toUpperCase() : lower3[i];
3647
+ for (let i = 0; i < 40; i++) out += Number.parseInt(hash2[i], 16) >= 8 ? lower6[i].toUpperCase() : lower6[i];
3621
3648
  return out;
3622
3649
  }
3623
3650
  function hasValidChecksum(address) {
@@ -3635,6 +3662,7 @@ var toHex = (v, opts) => "0x" + (typeof v === "bigint" ? v.toString(16).padStart
3635
3662
  var keccak256 = (h2) => "0x" + keccak256Hex(hexToBytes2(h2));
3636
3663
  var STEP_VERSION = 5;
3637
3664
  var MAX_STEPS2 = 8;
3665
+ var ORDER_HEADER_LEN = 76;
3638
3666
  var StepKind = {
3639
3667
  LOCAL_PAYOUT: 1,
3640
3668
  REMOTE_PAYOUT: 2,
@@ -3775,11 +3803,11 @@ function decodeStep(step) {
3775
3803
  r.end();
3776
3804
  return result;
3777
3805
  }
3778
- function routerWord(addr) {
3779
- return concat([toHex(new Uint8Array(12)), checkedHex(addr, 20)]);
3806
+ function routerWord(addr2) {
3807
+ return concat([toHex(new Uint8Array(12)), checkedHex(addr2, 20)]);
3780
3808
  }
3781
- function ownerWord(addr) {
3782
- return routerWord(addr);
3809
+ function ownerWord(addr2) {
3810
+ return routerWord(addr2);
3783
3811
  }
3784
3812
  function encodeOrderHeader(serial, router, ownerType, owner) {
3785
3813
  if (!Number.isInteger(ownerType) || ownerType < 0 || ownerType > 255) throw new ZdHeavyCodecError("Invalid ownerType");
@@ -4990,7 +5018,7 @@ var CHANNEL_HEADER = "x-zd-channel";
4990
5018
  var CHANNEL_VERSION_HEADER = "x-zd-channel-version";
4991
5019
  var CHANNEL_ORIGIN_HEADER = "x-zd-channel-origin";
4992
5020
  var WIDGET_CHANNEL = "widget";
4993
- var WIDGET_VERSION = "4.21.0" ;
5021
+ var WIDGET_VERSION = "4.22.0" ;
4994
5022
  var MAX_CHANNEL_VERSION_LEN = 32;
4995
5023
  function sanitizeVersion(raw2) {
4996
5024
  const v = String(raw2).trim();
@@ -5347,24 +5375,24 @@ function createApiClient(cfg) {
5347
5375
  throw lastError;
5348
5376
  }
5349
5377
  async function screenWallet(address, chainId) {
5350
- const addr = String(address || "").trim();
5351
- if (!addr) throw apiError("An address is required to screen a wallet.", { code: "bad_request" });
5352
- const solana = isSolanaChainId(chainId) || isSolanaAddress(addr);
5353
- if (solana && !isSolanaAddress(addr)) throw apiError("Not a valid Solana address.", { code: "bad_request" });
5354
- const key2 = solana ? "solana|" + addr : (/^0x[0-9a-fA-F]+$/.test(addr) ? addr.toLowerCase() : addr) + "|" + (chainId ?? "");
5378
+ const addr2 = String(address || "").trim();
5379
+ if (!addr2) throw apiError("An address is required to screen a wallet.", { code: "bad_request" });
5380
+ const solana = isSolanaChainId(chainId) || isSolanaAddress(addr2);
5381
+ if (solana && !isSolanaAddress(addr2)) throw apiError("Not a valid Solana address.", { code: "bad_request" });
5382
+ const key2 = solana ? "solana|" + addr2 : (/^0x[0-9a-fA-F]+$/.test(addr2) ? addr2.toLowerCase() : addr2) + "|" + (chainId ?? "");
5355
5383
  const hit = screenCache.get(key2);
5356
5384
  if (hit && Date.now() - hit.at < SCREEN_CACHE_TTL_MS) return hit.value;
5357
5385
  const inflight = screenInflight.get(key2);
5358
5386
  if (inflight) return inflight;
5359
5387
  const request = apiRequest("/screen/wallet", {
5360
5388
  method: "POST",
5361
- body: JSON.stringify(solana ? { address: addr, network: "solana" } : chainId == null ? { address: addr } : { address: addr, chainId }),
5389
+ body: JSON.stringify(solana ? { address: addr2, network: "solana" } : chainId == null ? { address: addr2 } : { address: addr2, chainId }),
5362
5390
  timeoutMs: 12e3
5363
5391
  }).then((screen) => {
5364
5392
  if (!screen || typeof screen !== "object" || typeof screen.blocked !== "boolean") {
5365
5393
  throw apiError("Compliance screening returned an unusable result.", { code: "bad_response" });
5366
5394
  }
5367
- const value = { ...screen, address: screen.address || addr };
5395
+ const value = { ...screen, address: screen.address || addr2 };
5368
5396
  screenCache.set(key2, { at: Date.now(), value });
5369
5397
  return value;
5370
5398
  }).finally(() => {
@@ -5468,12 +5496,12 @@ async function fetchPaymentPlan(api, request, payer, wallet = {}, readBalances)
5468
5496
  const parties = [];
5469
5497
  const seenParty = /* @__PURE__ */ new Set();
5470
5498
  for (const raw2 of [payer, destination.address]) {
5471
- const addr = String(raw2 || "").trim();
5472
- if (!addr) continue;
5473
- const key2 = /^0x[0-9a-fA-F]+$/.test(addr) ? addr.toLowerCase() : addr;
5499
+ const addr2 = String(raw2 || "").trim();
5500
+ if (!addr2) continue;
5501
+ const key2 = /^0x[0-9a-fA-F]+$/.test(addr2) ? addr2.toLowerCase() : addr2;
5474
5502
  if (seenParty.has(key2)) continue;
5475
5503
  seenParty.add(key2);
5476
- parties.push(addr);
5504
+ parties.push(addr2);
5477
5505
  }
5478
5506
  try {
5479
5507
  const screens = await Promise.all(parties.map((address) => api.screenWallet(address, destination.chainId)));
@@ -5688,6 +5716,322 @@ async function buildSwapPlan(api, swap, payer, wallet = {}) {
5688
5716
  };
5689
5717
  }
5690
5718
 
5719
+ // src/core/zdheavy-cancel.ts
5720
+ var lower3 = (s) => (typeof s === "string" ? s : "").toLowerCase();
5721
+ var ORDER_ID = /^0x[0-9a-fA-F]{64}$/;
5722
+ var EVM_ADDRESS = /^0x[0-9a-fA-F]{40}$/;
5723
+ function isZdHeavyOrderId(v) {
5724
+ return typeof v === "string" && ORDER_ID.test(v);
5725
+ }
5726
+ function zdHeavyRecovery(plan, wallet) {
5727
+ const claims = wallet ? plan.places.flatMap(
5728
+ (p) => p.kind === "router" && p.chainId !== void 0 && p.contract ? p.claimable.filter((c) => lower3(c.payee) === lower3(wallet)).map((c) => ({ chainId: p.chainId, token: c.token, amount: c.amount })) : []
5729
+ ) : [];
5730
+ if (claims.length) return { kind: "claim", claims };
5731
+ if (plan.finished) return { kind: "delivered" };
5732
+ if (plan.state === "refund_complete" && plan.complete) {
5733
+ return { kind: "refunded", refunds: plan.places.flatMap((p) => p.refunds.map((r) => ({ ...r, chainId: p.chainId }))) };
5734
+ }
5735
+ if (plan.ownerType !== "evm") return { kind: "not-owner" };
5736
+ const holding = plan.places.filter(
5737
+ (p) => p.kind === "router" && p.chainId !== void 0 && !!p.contract && p.canCancelInPerson && !p.complete && p.lots.length > 0
5738
+ );
5739
+ if (holding.length) return { kind: "cancel", chains: holding.map((p) => p.chainId), requested: plan.state === "cancel_requested" };
5740
+ if (plan.state === "open" && !plan.complete) return { kind: "cancel", chains: [plan.originChainId], requested: false };
5741
+ return { kind: "waiting" };
5742
+ }
5743
+ var MAX_PLACES = 32;
5744
+ var MAX_ROWS = 64;
5745
+ var DIGITS = /^\d{1,78}$/;
5746
+ var LOT_KEY = /^(?:\d{1,78}|0x[0-9a-fA-F]{1,64})$/;
5747
+ var TX_HASH = /^0x[0-9a-fA-F]{64}$/;
5748
+ var posInt = (v) => typeof v === "number" && Number.isSafeInteger(v) && v > 0 ? v : void 0;
5749
+ var nonNegInt = (v) => typeof v === "number" && Number.isSafeInteger(v) && v >= 0;
5750
+ var addr = (v) => typeof v === "string" && EVM_ADDRESS.test(v);
5751
+ var list = (v) => v === void 0 || v === null ? [] : Array.isArray(v) && v.length <= MAX_ROWS ? v : null;
5752
+ var obj = (v) => v && typeof v === "object" && !Array.isArray(v) ? v : null;
5753
+ function normalizeCancellationPlan(raw2, orderId) {
5754
+ const r = obj(raw2);
5755
+ if (!r || !isZdHeavyOrderId(orderId) || lower3(r.orderId) !== lower3(orderId)) return null;
5756
+ const ownerType = r.ownerType === "evm" || r.ownerType === "solana" ? r.ownerType : null;
5757
+ const state = r.state === "open" || r.state === "cancel_requested" || r.state === "refund_complete" ? r.state : null;
5758
+ const originChainId = posInt(r.originChainId);
5759
+ if (!ownerType || !state || originChainId === void 0 || typeof r.complete !== "boolean" || typeof r.owner !== "string" || r.owner.length > 64) return null;
5760
+ if (r.finished !== void 0 && typeof r.finished !== "boolean") return null;
5761
+ if (!Array.isArray(r.places) || r.places.length > MAX_PLACES) return null;
5762
+ const places = [];
5763
+ for (const rawPlace of r.places) {
5764
+ const p = obj(rawPlace);
5765
+ if (!p || p.kind !== "router" && p.kind !== "hub" || typeof p.canCancelInPerson !== "boolean" || typeof p.complete !== "boolean") return null;
5766
+ const chainId = p.chainId === void 0 ? void 0 : posInt(p.chainId);
5767
+ if (p.chainId !== void 0 && chainId === void 0) return null;
5768
+ const contract = typeof p.contract === "string" ? p.contract : "";
5769
+ if (contract && !addr(contract)) return null;
5770
+ const lots = list(p.lots);
5771
+ const refunds = list(p.refunds);
5772
+ const claimable = list(p.claimable);
5773
+ if (!lots || !refunds || !claimable) return null;
5774
+ const place = {
5775
+ kind: p.kind,
5776
+ chainId,
5777
+ contract,
5778
+ canCancelInPerson: p.canCancelInPerson,
5779
+ complete: p.complete,
5780
+ lots: [],
5781
+ refunds: [],
5782
+ claimable: []
5783
+ };
5784
+ for (const rawLot of lots) {
5785
+ const l = obj(rawLot);
5786
+ if (!l || !nonNegInt(l.step) || !addr(l.token) || typeof l.amount !== "string" || !DIGITS.test(l.amount) || typeof l.key !== "string" || !LOT_KEY.test(l.key))
5787
+ return null;
5788
+ place.lots.push({ step: l.step, token: l.token, amount: l.amount, key: l.key });
5789
+ }
5790
+ for (const rawRefund of refunds) {
5791
+ const f = obj(rawRefund);
5792
+ if (!f || typeof f.txHash !== "string" || !TX_HASH.test(f.txHash) || !nonNegInt(f.step) || !addr(f.token) || typeof f.amount !== "string" || !DIGITS.test(f.amount) || !addr(f.to))
5793
+ return null;
5794
+ place.refunds.push({ txHash: f.txHash, step: f.step, token: f.token, amount: f.amount, to: f.to });
5795
+ }
5796
+ for (const rawClaim of claimable) {
5797
+ const c = obj(rawClaim);
5798
+ if (!c || !addr(c.payee) || !addr(c.token) || typeof c.amount !== "string" || !DIGITS.test(c.amount)) return null;
5799
+ place.claimable.push({ payee: c.payee, token: c.token, amount: c.amount });
5800
+ }
5801
+ places.push(place);
5802
+ }
5803
+ return {
5804
+ orderId: r.orderId,
5805
+ ownerType,
5806
+ owner: r.owner,
5807
+ originChainId,
5808
+ state,
5809
+ complete: r.complete,
5810
+ ...r.finished !== void 0 ? { finished: r.finished } : {},
5811
+ places
5812
+ };
5813
+ }
5814
+ function zdHeavyOrderPath(orderId, tail) {
5815
+ if (!isZdHeavyOrderId(orderId)) throw new ZdHeavyCodecError("Not a ZD Heavy order id.");
5816
+ return `/orders/${orderId.toLowerCase()}/${tail}`;
5817
+ }
5818
+ async function fetchZdHeavyCancellation(api, orderId) {
5819
+ if (!isZdHeavyOrderId(orderId)) return null;
5820
+ try {
5821
+ return normalizeCancellationPlan(await api.apiRequest(zdHeavyOrderPath(orderId, "cancellation"), { timeoutMs: 1e4 }), orderId);
5822
+ } catch {
5823
+ return null;
5824
+ }
5825
+ }
5826
+ function unsigned(raw2) {
5827
+ const r = obj(raw2);
5828
+ const s = (v) => typeof v === "string" ? v : typeof v === "number" ? String(v) : "";
5829
+ if (!r) return { purpose: "", chainId: "", from: "", to: "", data: "" };
5830
+ return {
5831
+ purpose: s(r.purpose),
5832
+ chainId: s(r.chainId),
5833
+ from: s(r.from),
5834
+ to: s(r.to),
5835
+ data: s(r.data),
5836
+ ...r.value !== void 0 ? { value: s(r.value) } : {}
5837
+ };
5838
+ }
5839
+ async function buildZdHeavyCancelTx(api, orderId, chainId) {
5840
+ return unsigned(
5841
+ await api.apiRequest(zdHeavyOrderPath(orderId, "cancel-tx"), {
5842
+ method: "POST",
5843
+ body: JSON.stringify(chainId === void 0 ? {} : { chainId }),
5844
+ timeoutMs: 15e3
5845
+ })
5846
+ );
5847
+ }
5848
+ async function buildZdHeavyClaimTx(api, orderId, chainId, token) {
5849
+ return unsigned(
5850
+ await api.apiRequest(zdHeavyOrderPath(orderId, "claim-tx"), {
5851
+ method: "POST",
5852
+ body: JSON.stringify({ chainId, token }),
5853
+ timeoutMs: 15e3
5854
+ })
5855
+ );
5856
+ }
5857
+ var ZDHEAVY_CANCEL_SELECTOR = "0xf26bce2c";
5858
+ var ZDHEAVY_CLAIM_SELECTOR = "0x1e83409a";
5859
+ var ZDHEAVY_CLAIM_TO_SELECTOR = "0x21c0b342";
5860
+ var MAX_CANCEL_KEYS = 32;
5861
+ function reader(data, selector) {
5862
+ if (typeof data !== "string" || !/^0x(?:[0-9a-fA-F]{2})*$/.test(data) || data.slice(0, 10).toLowerCase() !== selector) {
5863
+ throw new ZdHeavyCodecError("Unexpected call");
5864
+ }
5865
+ const body = data.slice(10).toLowerCase();
5866
+ const size = body.length / 2;
5867
+ const fail = () => {
5868
+ throw new ZdHeavyCodecError("Invalid calldata");
5869
+ };
5870
+ const word2 = (at, bits = 256) => {
5871
+ if (!Number.isSafeInteger(at) || at < 0 || at + 32 > size) return fail();
5872
+ const n = BigInt(`0x${body.slice(at * 2, (at + 32) * 2)}`);
5873
+ if (bits < 256 && n >= 1n << BigInt(bits)) return fail();
5874
+ return n;
5875
+ };
5876
+ const fixed = (at) => {
5877
+ word2(at);
5878
+ return `0x${body.slice(at * 2, (at + 32) * 2)}`;
5879
+ };
5880
+ const address = (at) => `0x${word2(at, 160).toString(16).padStart(40, "0")}`;
5881
+ const offset = (at, expected) => {
5882
+ if (word2(at) !== BigInt(expected)) fail();
5883
+ };
5884
+ const count = (at, each) => {
5885
+ const n = word2(at);
5886
+ if (n > BigInt(Math.floor((size - at - 32) / each))) return fail();
5887
+ return Number(n);
5888
+ };
5889
+ const bytes = (at) => {
5890
+ const n = word2(at);
5891
+ if (n > BigInt(size - at - 32)) return fail();
5892
+ const length = Number(n);
5893
+ const end = at + 32 + Math.ceil(length / 32) * 32;
5894
+ if (end > size || /[^0]/.test(body.slice((at + 32 + length) * 2, end * 2))) return fail();
5895
+ return { value: `0x${body.slice((at + 32) * 2, (at + 32 + length) * 2)}`, end };
5896
+ };
5897
+ return { size, fail, word: word2, fixed, address, offset, count, bytes };
5898
+ }
5899
+ function decodeZdHeavyCancel(data) {
5900
+ const r = reader(data, ZDHEAVY_CANCEL_SELECTOR);
5901
+ const orderId = r.fixed(0);
5902
+ const P3 = 96;
5903
+ r.offset(32, P3);
5904
+ const expiryDate = r.word(P3, 64);
5905
+ r.offset(P3 + 32, 96);
5906
+ const header = r.bytes(P3 + 96);
5907
+ r.offset(P3 + 64, header.end - P3);
5908
+ const hashesAt = header.end;
5909
+ const n = r.count(hashesAt, 32);
5910
+ const stepHashes = [];
5911
+ for (let i = 0; i < n; i++) stepHashes.push(r.fixed(hashesAt + 32 + i * 32));
5912
+ const keysAt = hashesAt + 32 + n * 32;
5913
+ r.offset(64, keysAt);
5914
+ const k = r.count(keysAt, 32);
5915
+ const keys = [];
5916
+ for (let i = 0; i < k; i++) keys.push(r.word(keysAt + 32 + i * 32));
5917
+ if (keysAt + 32 + k * 32 !== r.size) r.fail();
5918
+ return { orderId, proof: { expiryDate, orderHeader: header.value, stepHashes }, keys };
5919
+ }
5920
+ function decodeZdHeavyClaim(data) {
5921
+ const selector = typeof data === "string" ? data.slice(0, 10).toLowerCase() : "";
5922
+ if (selector === ZDHEAVY_CLAIM_SELECTOR) {
5923
+ const r2 = reader(data, ZDHEAVY_CLAIM_SELECTOR);
5924
+ if (r2.size !== 32) r2.fail();
5925
+ return { token: r2.address(0) };
5926
+ }
5927
+ const r = reader(data, ZDHEAVY_CLAIM_TO_SELECTOR);
5928
+ if (r.size !== 64) r.fail();
5929
+ return { token: r.address(0), to: r.address(32) };
5930
+ }
5931
+ var hexBytes2 = (h2) => Uint8Array.from(h2.slice(2).match(/../g) ?? [], (b) => Number.parseInt(b, 16));
5932
+ var keccak = (h2) => `0x${keccak256Hex(hexBytes2(h2))}`;
5933
+ function orderIdFromProof(expiryDate, header, stepHashes) {
5934
+ const tag = Array.from(new TextEncoder().encode("ZD/ORDER"), (b) => b.toString(16).padStart(2, "0")).join("");
5935
+ return keccak(`0x${tag}${expiryDate.toString(16).padStart(16, "0")}${keccak(header).slice(2)}${stepHashes.map((h2) => h2.slice(2)).join("")}`);
5936
+ }
5937
+ var TX = /^0x[0-9a-fA-F]{64}$/;
5938
+ var succeeded = (receipt) => {
5939
+ const status = obj(receipt)?.status;
5940
+ return typeof status === "string" && /^0x0*1$/.test(status);
5941
+ };
5942
+ async function verifyZdHeavySourceOrder(rpc, chainId, hash2, orderId) {
5943
+ const no = (reason) => ({ ok: false, reason });
5944
+ if (!SUPPORTED_CHAIN_IDS.has(chainId) || typeof hash2 !== "string" || !TX.test(hash2) || !isZdHeavyOrderId(orderId)) return no("not checkable");
5945
+ try {
5946
+ const [tx, receipt] = await Promise.all([rpc(chainId, "eth_getTransactionByHash", [hash2]), rpc(chainId, "eth_getTransactionReceipt", [hash2])]);
5947
+ const t = obj(tx);
5948
+ if (!t || lower3(t.hash) !== lower3(hash2)) return no("source transaction not found");
5949
+ if (!succeeded(receipt) || lower3(obj(receipt)?.transactionHash) !== lower3(hash2)) return no("source transaction not confirmed");
5950
+ const router = checkZdHeavyRouter(chainId, typeof t.to === "string" ? t.to : "");
5951
+ if (!router.ok) return no("source transaction is not to a pinned router");
5952
+ const input = typeof t.input === "string" ? t.input : typeof t.data === "string" ? t.data : "";
5953
+ const { submission } = decodeZdHeavySubmit(input);
5954
+ const id = orderIdOf(submission.expiryDate, encodeOrderHeader(submission.serial, router.address, submission.ownerType, submission.owner), submission.steps);
5955
+ return lower3(id) === lower3(orderId) ? { ok: true } : no("source transaction submitted another order");
5956
+ } catch {
5957
+ return no("source transaction could not be read");
5958
+ }
5959
+ }
5960
+ var refuse2 = (what) => ({ ok: false, reason: `The ${what} does not match this order. Refusing to sign.` });
5961
+ function commonChecks(tx, owner, purpose, chainId) {
5962
+ if (!tx || tx.purpose !== purpose) return refuse2("transaction kind");
5963
+ const chain2 = typeof tx.chainId === "string" && /^\d{1,12}$/.test(tx.chainId) ? Number(tx.chainId) : NaN;
5964
+ if (!Number.isSafeInteger(chain2) || chain2 <= 0) return refuse2("chain");
5965
+ if (chainId !== void 0 && chain2 !== chainId) return refuse2("chain");
5966
+ const router = checkZdHeavyRouter(chain2, tx.to);
5967
+ if (!router.ok) return { ok: false, reason: router.reason };
5968
+ if (!addr(owner) || !addr(tx.from) || lower3(tx.from) !== lower3(owner)) return refuse2("sender");
5969
+ try {
5970
+ if (tx.value !== void 0 && tx.value !== "" && BigInt(tx.value) !== 0n) return refuse2("value");
5971
+ } catch {
5972
+ return refuse2("value");
5973
+ }
5974
+ return { ok: true, chainId: chain2, router: router.address };
5975
+ }
5976
+ var accepted = (chainId, owner, router, data) => ({
5977
+ ok: true,
5978
+ chainId,
5979
+ tx: { from: owner, to: router, data: data.toLowerCase(), value: "0x0" }
5980
+ });
5981
+ function checkZdHeavyCancelTx(tx, e) {
5982
+ const base = commonChecks(tx, e.owner, "cancel", e.chainId);
5983
+ if (!base.ok) return base;
5984
+ let decoded;
5985
+ try {
5986
+ decoded = decodeZdHeavyCancel(tx.data);
5987
+ } catch {
5988
+ return refuse2("call");
5989
+ }
5990
+ const { orderId, proof, keys } = decoded;
5991
+ if (!isZdHeavyOrderId(e.orderId) || lower3(orderId) !== lower3(e.orderId)) return refuse2("order id");
5992
+ if (keys.length > MAX_CANCEL_KEYS) return refuse2("lot keys");
5993
+ const listed = e.lotKeys ? new Set(
5994
+ e.lotKeys.map((k) => {
5995
+ try {
5996
+ return BigInt(k).toString();
5997
+ } catch {
5998
+ return "";
5999
+ }
6000
+ })
6001
+ ) : void 0;
6002
+ const seen = /* @__PURE__ */ new Set();
6003
+ for (const k of keys) {
6004
+ if (listed && !listed.has(k.toString())) return refuse2("lot keys");
6005
+ const step = k >> 160n;
6006
+ const tokenBits = k & (1n << 160n) - 1n;
6007
+ if (step >= BigInt(proof.stepHashes.length) || tokenBits === 0n || seen.has(k.toString())) return refuse2("lot keys");
6008
+ seen.add(k.toString());
6009
+ }
6010
+ if (proof.stepHashes.length < 1 || proof.stepHashes.length > 8) return refuse2("order proof");
6011
+ if (lower3(orderIdFromProof(proof.expiryDate, proof.orderHeader, proof.stepHashes)) !== lower3(orderId)) return refuse2("order proof");
6012
+ const h2 = proof.orderHeader;
6013
+ if (h2.length !== 2 + ORDER_HEADER_LEN * 2) return refuse2("order proof");
6014
+ const routerWordHex = `0x${h2.slice(2 + 11 * 2, 2 + 43 * 2)}`;
6015
+ const ownerType = Number.parseInt(h2.slice(2 + 43 * 2, 2 + 44 * 2), 16);
6016
+ const ownerWordHex = `0x${h2.slice(2 + 44 * 2)}`;
6017
+ if (lower3(routerWordHex) !== lower3(ownerWord(base.router))) return refuse2("router");
6018
+ if (ownerType !== 1 || lower3(ownerWordHex) !== lower3(ownerWord(e.owner))) return refuse2("owner");
6019
+ return accepted(base.chainId, e.owner, base.router, tx.data);
6020
+ }
6021
+ function checkZdHeavyClaimTx(tx, e) {
6022
+ const base = commonChecks(tx, e.owner, "claim", e.chainId);
6023
+ if (!base.ok) return base;
6024
+ let decoded;
6025
+ try {
6026
+ decoded = decodeZdHeavyClaim(tx.data);
6027
+ } catch {
6028
+ return refuse2("call");
6029
+ }
6030
+ if (!addr(e.token) || lower3(decoded.token) !== lower3(e.token)) return refuse2("token");
6031
+ if (decoded.to !== void 0 && lower3(decoded.to) !== lower3(e.owner)) return refuse2("recipient");
6032
+ return accepted(base.chainId, e.owner, base.router, tx.data);
6033
+ }
6034
+
5691
6035
  // src/core/verify.ts
5692
6036
  var TX_VERIFY_ATTEMPTS = 5;
5693
6037
  var TX_VERIFY_INTERVAL_MS = 2500;
@@ -5901,7 +6245,13 @@ function createVerifier(api, fetchImpl, rpcOverrides = {}) {
5901
6245
  return void 0;
5902
6246
  }
5903
6247
  }
5904
- return { payerNonceBaseline, verifySubmittedTx, readBalances, readNativeBalance, readZdHeavySubmitFee };
6248
+ async function bundledRpc(chainId, method, params) {
6249
+ const override = rpcOverrides[Number(chainId)];
6250
+ const rpc = override && /^https?:\/\//i.test(override) ? override : BUNDLED_RPC[Number(chainId)];
6251
+ if (!rpc) throw new Error("No bundled RPC for this chain");
6252
+ return rpcCall(rpc, method, params);
6253
+ }
6254
+ return { payerNonceBaseline, verifySubmittedTx, readBalances, readNativeBalance, readZdHeavySubmitFee, bundledRpc };
5905
6255
  }
5906
6256
 
5907
6257
  // src/core/config.ts
@@ -6061,6 +6411,10 @@ function createEngine(config = {}) {
6061
6411
  executeSolanaPlanStaged: (input) => executeSolanaPlanStaged({ ...input, rpc: input.rpc ?? solanaRpc }),
6062
6412
  previewSolanaSource: (input) => previewSolanaSource(api, input),
6063
6413
  trackDelivery: (hash2) => fetchDelivery(api, hash2),
6414
+ fetchZdHeavyCancellation: (orderId) => fetchZdHeavyCancellation(api, orderId),
6415
+ buildZdHeavyCancelTx: (orderId, chainId) => buildZdHeavyCancelTx(api, orderId, chainId),
6416
+ buildZdHeavyClaimTx: (orderId, chainId, tokenAddress) => buildZdHeavyClaimTx(api, orderId, chainId, tokenAddress),
6417
+ verifyZdHeavySourceOrder: (chainId, hash2, orderId) => verifyZdHeavySourceOrder(verifier.bundledRpc, chainId, hash2, orderId),
6064
6418
  fetchWalletHistory: (wallets) => fetchWalletHistory(api, wallets),
6065
6419
  readSolanaBalance: (owner, mint) => readSolanaBalance(solanaRpc, owner, mint),
6066
6420
  simulateSolanaCost: (plan) => simulateSolanaCost(solanaRpc, plan),
@@ -6208,7 +6562,9 @@ function normalizeWalletError(err2, fallback = "Transaction failed.") {
6208
6562
  async function sendTransaction(provider, tx) {
6209
6563
  const hash2 = await provider.request({
6210
6564
  method: "eth_sendTransaction",
6211
- params: [{ from: tx.from, to: tx.to, data: tx.data, value: tx.value || "0x0" }]
6565
+ // `chainId` only when the caller names one (ZD Heavy recovery writes): the wallet then refuses to
6566
+ // sign on any other chain. The order submit path names none, so its request is unchanged.
6567
+ params: [{ from: tx.from, to: tx.to, data: tx.data, value: tx.value || "0x0", ...tx.chainId ? { chainId: chainHex(tx.chainId) } : {} }]
6212
6568
  });
6213
6569
  return hash2;
6214
6570
  }
@@ -6561,8 +6917,8 @@ function useFlow(args) {
6561
6917
  engine.fetchChains().catch(() => [])
6562
6918
  ]);
6563
6919
  if (!alive) return;
6564
- const check2 = checkNativeFee(selected, balance);
6565
- setNativeShortfall(nativeFeeShortLabel(check2, nativeSymbol(Number(src.chainId), chains)));
6920
+ const check3 = checkNativeFee(selected, balance);
6921
+ setNativeShortfall(nativeFeeShortLabel(check3, nativeSymbol(Number(src.chainId), chains)));
6566
6922
  } catch {
6567
6923
  }
6568
6924
  })();
@@ -6599,10 +6955,10 @@ function useFlow(args) {
6599
6955
  if (after !== Number(sourceChainId)) throw new Error("Wallet did not switch to the source chain.");
6600
6956
  }
6601
6957
  if (routeNativeValue(route) > 0n) {
6602
- const check2 = checkNativeFee(route, await nativeBalance(provider, account));
6603
- if (check2.short) {
6958
+ const check3 = checkNativeFee(route, await nativeBalance(provider, account));
6959
+ if (check3.short) {
6604
6960
  const chains = await engine.fetchChains().catch(() => []);
6605
- throw new Error(nativeFeeShortMessage(check2, nativeSymbol(Number(sourceChainId), chains), route.source.chainName));
6961
+ throw new Error(nativeFeeShortMessage(check3, nativeSymbol(Number(sourceChainId), chains), route.source.chainName));
6606
6962
  }
6607
6963
  }
6608
6964
  const heavyExpected = route.zdHeavy ? zdHeavyExpected(route, account, recipient2, ...await Promise.all([engine.fetchTokens(), engine.fetchRoutes()])) : void 0;
@@ -6754,8 +7110,8 @@ function useFlow(args) {
6754
7110
  try {
6755
7111
  if (typeof engine.fetchPromotions !== "function") return;
6756
7112
  const read = await engine.fetchPromotions();
6757
- const list = Array.isArray(read) ? read : [];
6758
- if (alive) setPromotionList((prev) => JSON.stringify(prev) === JSON.stringify(list) ? prev : list);
7113
+ const list2 = Array.isArray(read) ? read : [];
7114
+ if (alive) setPromotionList((prev) => JSON.stringify(prev) === JSON.stringify(list2) ? prev : list2);
6759
7115
  } catch {
6760
7116
  }
6761
7117
  })();
@@ -6796,7 +7152,7 @@ function useFlow(args) {
6796
7152
  react.useEffect(() => {
6797
7153
  if (!enabled || !selected?.zdHeavy || !quoteReady || quotePaused || busyRef.current) return;
6798
7154
  let timer2;
6799
- const schedule = () => {
7155
+ const schedule2 = () => {
6800
7156
  clearTimeout(timer2);
6801
7157
  if (document.visibilityState !== "visible" || busyRef.current) return;
6802
7158
  const delay = Math.max(3e3, (selected.zdHeavy.order.expiresAt - REFRESH_LEAD_SECONDS) * 1e3 - Date.now());
@@ -6804,11 +7160,11 @@ function useFlow(args) {
6804
7160
  if (!busyRef.current && statusRef.current === "ready" && !isUserIdle() && document.visibilityState === "visible") reload();
6805
7161
  }, delay);
6806
7162
  };
6807
- schedule();
6808
- document.addEventListener("visibilitychange", schedule);
7163
+ schedule2();
7164
+ document.addEventListener("visibilitychange", schedule2);
6809
7165
  return () => {
6810
7166
  clearTimeout(timer2);
6811
- document.removeEventListener("visibilitychange", schedule);
7167
+ document.removeEventListener("visibilitychange", schedule2);
6812
7168
  };
6813
7169
  }, [enabled, selected, quoteReady, quotePaused, reload]);
6814
7170
  return {
@@ -6838,7 +7194,7 @@ function useFlow(args) {
6838
7194
  var RETRY_DELAYS_MS = [800, 2400, 6e3];
6839
7195
  var CATALOGUE_REFRESH_MS = 6e4 + 250;
6840
7196
  function catalogueSignature(c) {
6841
- const ids = (list) => list.map((t) => `${Number(t.chainId)}:${String(t.address).toLowerCase()}`).join(",");
7197
+ const ids = (list2) => list2.map((t) => `${Number(t.chainId)}:${String(t.address).toLowerCase()}`).join(",");
6842
7198
  return [ids(c.tokens), ids(c.sources), [...c.source].sort().join(","), [...c.destination].sort().join(","), [...c.lanes ?? []].sort().join(","), [...c.brokenLanes?.keys() ?? []].sort().join(","), [...c.limitedLanes.keys()].sort().join(",")].join("|");
6843
7199
  }
6844
7200
  function useCatalogue(engine, options = {}) {
@@ -6903,16 +7259,16 @@ function useHoldings(engine, account, routes, initialBalances) {
6903
7259
  const reqId = react.useRef(0);
6904
7260
  const targets = react.useMemo(() => {
6905
7261
  const seen = /* @__PURE__ */ new Set();
6906
- const list = [];
7262
+ const list2 = [];
6907
7263
  for (const r of routes) {
6908
7264
  const s = r.source;
6909
7265
  if (!s?.tokenAddress || s.decimals == null) continue;
6910
7266
  const k = balanceKey(s.chainId, s.tokenAddress);
6911
7267
  if (seen.has(k)) continue;
6912
7268
  seen.add(k);
6913
- list.push({ chainId: s.chainId, tokenAddress: s.tokenAddress, decimals: s.decimals });
7269
+ list2.push({ chainId: s.chainId, tokenAddress: s.tokenAddress, decimals: s.decimals });
6914
7270
  }
6915
- return list;
7271
+ return list2;
6916
7272
  }, [routes]);
6917
7273
  const targetsKey = react.useMemo(() => targets.map((t) => balanceKey(t.chainId, t.tokenAddress)).join("|"), [targets]);
6918
7274
  react.useEffect(() => {
@@ -7391,6 +7747,13 @@ img.sg-tok-badge{width:16px;padding:0;object-fit:cover;background:var(--sg-bg)}
7391
7747
  /* transaction detail: copyable hash row (no external links \u2014 everything stays in-widget) */
7392
7748
  .sg-txd-hash{display:flex;align-items:center;gap:8px;margin-top:12px;font-size:13px}
7393
7749
  .sg-txd-hash .sg-mono{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
7750
+ .sg-zdh{margin-top:14px;padding:12px;border:1px solid var(--sg-border);border-radius:var(--sg-radius-control);background:var(--sg-surface)}
7751
+ .sg-zdh-title{font-size:14px;font-weight:600;line-height:1.25}
7752
+ .sg-zdh-body{margin:4px 0 10px;font-size:12px;line-height:1.45;color:var(--sg-text-muted)}
7753
+ .sg-zdh-actions{display:flex;flex-direction:column;gap:10px}
7754
+ .sg-zdh-action{display:flex;flex-direction:column;gap:6px}
7755
+ .sg-zdh-action .sg-txd-hash{margin-top:0}
7756
+ .sg-zdh-status{margin-top:14px}
7394
7757
  .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}
7395
7758
  .sg-copy:hover{color:var(--sg-accent);border-color:var(--sg-accent)}
7396
7759
 
@@ -8696,8 +9059,8 @@ function groupDeployments(deployments, prices) {
8696
9059
  const members = /* @__PURE__ */ new Map();
8697
9060
  for (const d of [...deployments].sort(byDeployment)) {
8698
9061
  const key2 = String(d.token.symbol).toUpperCase();
8699
- const list = members.get(key2);
8700
- if (list) list.push(d);
9062
+ const list2 = members.get(key2);
9063
+ if (list2) list2.push(d);
8701
9064
  else {
8702
9065
  members.set(key2, [d]);
8703
9066
  order.push(key2);
@@ -8711,10 +9074,10 @@ var CHAIN_ALIASES = {
8711
9074
  43114: ["avax"]
8712
9075
  };
8713
9076
  function labelForms(label2) {
8714
- const lower3 = label2.trim().toLowerCase();
8715
- if (!lower3) return [];
8716
- const compact = lower3.replace(/[^a-z0-9]/g, "");
8717
- return compact && compact !== lower3 ? [lower3, compact] : [lower3];
9077
+ const lower6 = label2.trim().toLowerCase();
9078
+ if (!lower6) return [];
9079
+ const compact = lower6.replace(/[^a-z0-9]/g, "");
9080
+ return compact && compact !== lower6 ? [lower6, compact] : [lower6];
8718
9081
  }
8719
9082
  function buildChainSearchTerms(chains) {
8720
9083
  const byId = /* @__PURE__ */ new Map();
@@ -9437,22 +9800,22 @@ function TriggerGlyph({ cv }) {
9437
9800
  if (cv.tone === "blocked" || cv.tone === "warn") return /* @__PURE__ */ jsxRuntime.jsx(CloseCircle, {});
9438
9801
  return /* @__PURE__ */ jsxRuntime.jsx(ShieldTick, {});
9439
9802
  }
9440
- function CheckRow({ check: check2, onViewPolicy }) {
9441
- const label2 = check2.id === "risk" ? check2.ok ? "Risk screening passed" : "Risk screening failed" : check2.label;
9442
- return /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "sg-cp-check", "data-ok": check2.ok, children: [
9803
+ function CheckRow({ check: check3, onViewPolicy }) {
9804
+ const label2 = check3.id === "risk" ? check3.ok ? "Risk screening passed" : "Risk screening failed" : check3.label;
9805
+ return /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "sg-cp-check", "data-ok": check3.ok, children: [
9443
9806
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cp-check-head", children: [
9444
9807
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cp-check-label", children: [
9445
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cp-check-mark", "data-ok": check2.ok, children: check2.ok ? /* @__PURE__ */ jsxRuntime.jsx(Tick, {}) : /* @__PURE__ */ jsxRuntime.jsx(Cross, {}) }),
9808
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cp-check-mark", "data-ok": check3.ok, children: check3.ok ? /* @__PURE__ */ jsxRuntime.jsx(Tick, {}) : /* @__PURE__ */ jsxRuntime.jsx(Cross, {}) }),
9446
9809
  /* @__PURE__ */ jsxRuntime.jsx("span", { children: label2 }),
9447
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-sr-only", children: check2.ok ? " \u2014 passed" : " \u2014 failed" })
9810
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-sr-only", children: check3.ok ? " \u2014 passed" : " \u2014 failed" })
9448
9811
  ] }),
9449
- check2.id === "risk" ? /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "sg-cp-link", onClick: onViewPolicy, children: [
9812
+ check3.id === "risk" ? /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "sg-cp-link", onClick: onViewPolicy, children: [
9450
9813
  "View policy",
9451
9814
  /* @__PURE__ */ jsxRuntime.jsx(CornerArrow, {})
9452
9815
  ] }) : null
9453
9816
  ] }),
9454
- check2.note ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cp-check-note", children: check2.note }) : null,
9455
- check2.reasons.map((reason) => /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cp-check-reason", children: humanizeComplianceReason(reason) }, reason))
9817
+ check3.note ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cp-check-note", children: check3.note }) : null,
9818
+ check3.reasons.map((reason) => /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cp-check-reason", children: humanizeComplianceReason(reason) }, reason))
9456
9819
  ] });
9457
9820
  }
9458
9821
  function QuoteChecks({
@@ -9486,7 +9849,7 @@ function QuoteChecks({
9486
9849
  /* @__PURE__ */ jsxRuntime.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." })
9487
9850
  )
9488
9851
  ] }),
9489
- checks.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "sg-cp-checks", children: checks.map((check2) => /* @__PURE__ */ jsxRuntime.jsx(CheckRow, { check: check2, onViewPolicy }, check2.id)) }) : null,
9852
+ checks.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "sg-cp-checks", children: checks.map((check3) => /* @__PURE__ */ jsxRuntime.jsx(CheckRow, { check: check3, onViewPolicy }, check3.id)) }) : null,
9490
9853
  orphans.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "sg-cp-orphans", children: orphans.map((reason) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: humanizeComplianceReason(reason) }, reason)) }) : null,
9491
9854
  direct2 && checks.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "sg-cp-scope", children: DIRECT_SCOPE_NOTE }) : null
9492
9855
  ] }),
@@ -9680,6 +10043,398 @@ function useWalletHistory(engine, wallets) {
9680
10043
  }, [engine, key2]);
9681
10044
  return entries;
9682
10045
  }
10046
+ var lower4 = (s) => (s ?? "").toLowerCase();
10047
+ var ZDH_RECHECK_MS = 15e3;
10048
+ var ZDH_RECHECK_FOR_MS = 30 * 6e4;
10049
+ var inFlight2 = /* @__PURE__ */ new Set();
10050
+ var writes = /* @__PURE__ */ new Map();
10051
+ var listeners = /* @__PURE__ */ new Set();
10052
+ var notify = () => {
10053
+ for (const listener of listeners) listener();
10054
+ };
10055
+ var hidden3 = () => typeof document !== "undefined" && document.visibilityState === "hidden";
10056
+ var unresolved = (w) => !!w && (w.status === "checking" || w.status === "stalled");
10057
+ var lockKey = (account, orderId, chainId, kind, asset) => `${lower4(account)}:${lower4(orderId)}:${chainId}:${kind}:${kind === "claim" ? lower4(asset) : ""}`;
10058
+ function cancelScope(keys) {
10059
+ const norm = keys.map((k) => {
10060
+ try {
10061
+ return BigInt(k).toString();
10062
+ } catch {
10063
+ return k;
10064
+ }
10065
+ });
10066
+ return `cancel:${[...new Set(norm)].sort().join(",")}`;
10067
+ }
10068
+ var claimScope = (asset, amount) => `claim:${lower4(asset)}:${amount ?? ""}`;
10069
+ async function check2(key2) {
10070
+ const w = writes.get(key2);
10071
+ if (!w || w.checking || !unresolved(w)) return;
10072
+ w.checking = true;
10073
+ let status;
10074
+ try {
10075
+ status = (await w.engine.verifySubmittedTx({ chainId: w.chainId, hash: w.hash, ...w.tx, minNonce: w.minNonce ?? 0 })).status;
10076
+ } catch {
10077
+ status = "unconfirmed";
10078
+ }
10079
+ w.checking = false;
10080
+ if (writes.get(key2) !== w) return;
10081
+ if (status === "confirmed" || status === "reverted") {
10082
+ if (w.timer) clearTimeout(w.timer);
10083
+ w.timer = void 0;
10084
+ w.status = status;
10085
+ notify();
10086
+ if (status === "confirmed") {
10087
+ try {
10088
+ window.dispatchEvent(new CustomEvent(TX_HISTORY_EVENT, { detail: { account: lower4(w.tx.from) } }));
10089
+ } catch {
10090
+ }
10091
+ }
10092
+ }
10093
+ }
10094
+ function schedule(key2) {
10095
+ const w = writes.get(key2);
10096
+ if (!w) return;
10097
+ if (w.timer) clearTimeout(w.timer);
10098
+ w.timer = void 0;
10099
+ if (w.status !== "checking") return;
10100
+ if (Date.now() - w.since >= ZDH_RECHECK_FOR_MS) {
10101
+ w.status = "stalled";
10102
+ notify();
10103
+ return;
10104
+ }
10105
+ w.timer = setTimeout(async () => {
10106
+ w.timer = void 0;
10107
+ if (!hidden3()) await check2(key2);
10108
+ schedule(key2);
10109
+ }, ZDH_RECHECK_MS);
10110
+ }
10111
+ function useZdHeavyAction(a) {
10112
+ const [phase, setPhase] = react.useState("idle");
10113
+ const [error, setError] = react.useState(null);
10114
+ const [switching, setSwitching] = react.useState(false);
10115
+ const alive = react.useRef(true);
10116
+ const [, rerender] = react.useReducer((n) => n + 1, 0);
10117
+ react.useEffect(() => {
10118
+ alive.current = true;
10119
+ listeners.add(rerender);
10120
+ return () => {
10121
+ alive.current = false;
10122
+ listeners.delete(rerender);
10123
+ };
10124
+ }, []);
10125
+ const walletEpoch = react.useRef(0);
10126
+ const walletKey = `${lower4(a.account)}:${a.walletChainId ?? ""}`;
10127
+ const lastWalletKey = react.useRef(walletKey);
10128
+ if (lastWalletKey.current !== walletKey) {
10129
+ lastWalletKey.current = walletKey;
10130
+ walletEpoch.current += 1;
10131
+ }
10132
+ const key2 = a.account ? lockKey(a.account, a.orderId, a.chainId, a.kind, a.asset) : "";
10133
+ const write = key2 ? writes.get(key2) : void 0;
10134
+ const scope = a.kind === "cancel" ? cancelScope(a.lotKeys ?? []) : claimScope(a.asset, a.amount);
10135
+ react.useEffect(() => {
10136
+ if (!key2 || !unresolved(writes.get(key2))) return;
10137
+ void check2(key2).then(() => schedule(key2));
10138
+ }, [key2]);
10139
+ const firedFor = react.useRef(null);
10140
+ const onConfirmed = a.onConfirmed;
10141
+ react.useEffect(() => {
10142
+ if (write?.status === "confirmed" && firedFor.current !== write.hash) {
10143
+ firedFor.current = write.hash;
10144
+ onConfirmed?.(write.hash);
10145
+ }
10146
+ });
10147
+ const supported = SUPPORTED_CHAIN_IDS.has(a.chainId);
10148
+ const connected2 = !!a.account && !!a.provider;
10149
+ const isOwner = !!a.account && lower4(a.account) === lower4(a.owner);
10150
+ const onChain = supported && a.walletChainId === a.chainId;
10151
+ const busy = phase === "preparing" || phase === "signing";
10152
+ const done = write?.status === "confirmed" && write.scope === scope;
10153
+ async function run() {
10154
+ const { engine, provider, account } = a;
10155
+ if (!engine || !provider || !account || !supported) return;
10156
+ const key3 = lockKey(account, a.orderId, a.chainId, a.kind, a.asset);
10157
+ const prior = writes.get(key3);
10158
+ if (unresolved(prior) || prior?.status === "confirmed" && prior.scope === scope) {
10159
+ setError(`This ${a.kind} was already sent. Wait for it to confirm.`);
10160
+ return;
10161
+ }
10162
+ if (inFlight2.has(key3)) {
10163
+ setError(`This ${a.kind} is already in progress. Wait for it to finish.`);
10164
+ return;
10165
+ }
10166
+ if (prior) writes.delete(key3);
10167
+ inFlight2.add(key3);
10168
+ const epoch = walletEpoch.current;
10169
+ const signer = account;
10170
+ const stale = () => !alive.current || walletEpoch.current !== epoch;
10171
+ setError(null);
10172
+ setPhase("preparing");
10173
+ try {
10174
+ const unsigned2 = a.kind === "cancel" ? await engine.buildZdHeavyCancelTx(a.orderId, a.chainId) : await engine.buildZdHeavyClaimTx(a.orderId, a.chainId, a.asset ?? "");
10175
+ const checked = a.kind === "cancel" ? checkZdHeavyCancelTx(unsigned2, { orderId: a.orderId, owner: signer, chainId: a.chainId, lotKeys: a.lotKeys }) : checkZdHeavyClaimTx(unsigned2, { owner: signer, chainId: a.chainId, token: a.asset ?? "" });
10176
+ if (!checked.ok) {
10177
+ if (alive.current) {
10178
+ setError(checked.reason);
10179
+ setPhase("idle");
10180
+ }
10181
+ return;
10182
+ }
10183
+ const minNonce = await engine.payerNonceBaseline(checked.chainId, signer);
10184
+ if (stale()) throw new Error(`The wallet changed while the ${a.kind} was prepared. Try again.`);
10185
+ const [walletChain, accounts] = await Promise.all([getChainId(provider), getAccounts(provider)]);
10186
+ if (stale()) throw new Error(`The wallet changed while the ${a.kind} was prepared. Try again.`);
10187
+ if (walletChain !== checked.chainId) throw new Error(`Switch your wallet to ${a.chainName} and try again.`);
10188
+ if (!accounts.some((x) => lower4(x) === lower4(signer))) throw new Error("The connected wallet changed. Try again.");
10189
+ setPhase("signing");
10190
+ const sentScope = a.kind === "cancel" ? cancelScope(decodeZdHeavyCancel(checked.tx.data).keys.map(String)) : claimScope(decodeZdHeavyClaim(checked.tx.data).token, a.amount);
10191
+ const hash2 = await sendTransaction(provider, { ...checked.tx, chainId: checked.chainId });
10192
+ writes.set(key3, {
10193
+ hash: hash2,
10194
+ chainId: checked.chainId,
10195
+ tx: checked.tx,
10196
+ minNonce,
10197
+ engine,
10198
+ scope: sentScope,
10199
+ since: Date.now(),
10200
+ status: "checking",
10201
+ checking: false
10202
+ });
10203
+ notify();
10204
+ if (alive.current) setPhase("idle");
10205
+ await check2(key3);
10206
+ schedule(key3);
10207
+ } catch (e) {
10208
+ if (!alive.current) return;
10209
+ const msg = normalizeWalletError(e, "");
10210
+ setError(msg ? `Could not ${a.kind === "claim" ? "claim" : "cancel"}: ${msg}` : `Could not prepare the ${a.kind}.`);
10211
+ setPhase("idle");
10212
+ } finally {
10213
+ inFlight2.delete(key3);
10214
+ }
10215
+ }
10216
+ function retryCheck() {
10217
+ const w = key2 ? writes.get(key2) : void 0;
10218
+ if (!w || !unresolved(w)) return;
10219
+ w.since = Date.now();
10220
+ w.status = "checking";
10221
+ notify();
10222
+ void check2(key2).then(() => schedule(key2));
10223
+ }
10224
+ 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;
10225
+ const disabled = !connected2 ? !a.onConnect : !supported || !isOwner || (!onChain ? switching : busy || done || unresolved(write));
10226
+ function onClick() {
10227
+ if (busy || switching) return;
10228
+ if (!connected2) return a.onConnect?.();
10229
+ if (!onChain && supported && a.provider) {
10230
+ setSwitching(true);
10231
+ setError(null);
10232
+ switchChain(a.provider, a.chainId).catch((e) => alive.current && setError(normalizeWalletError(e, `Could not switch to ${a.chainName}.`))).finally(() => alive.current && setSwitching(false));
10233
+ return;
10234
+ }
10235
+ void run();
10236
+ }
10237
+ const reverted = write?.status === "reverted" ? `The ${a.kind} reverted on-chain. Nothing changed.` : null;
10238
+ return {
10239
+ text,
10240
+ disabled,
10241
+ onClick,
10242
+ retryCheck,
10243
+ sentHash: write?.hash ?? null,
10244
+ done,
10245
+ busy,
10246
+ error: error ?? reverted,
10247
+ pending: write?.status === "checking",
10248
+ stalled: write?.status === "stalled"
10249
+ };
10250
+ }
10251
+ var ZDH_PLAN_REFRESH_MS = 1e4;
10252
+ var hidden4 = () => typeof document !== "undefined" && document.visibilityState === "hidden";
10253
+ var settled = (plan) => plan.complete && (plan.finished === true || plan.state === "refund_complete");
10254
+ function useZdHeavyRecovery(engine, orderId) {
10255
+ const [state, setState] = react.useState({ orderId, value: { status: "loading" } });
10256
+ const readRef = react.useRef(() => {
10257
+ });
10258
+ react.useEffect(() => {
10259
+ setState({ orderId, value: { status: "loading" } });
10260
+ if (!engine || !isZdHeavyOrderId(orderId)) return;
10261
+ let alive = true;
10262
+ let timer2;
10263
+ let shown = false;
10264
+ let started2 = Date.now();
10265
+ const read = async () => {
10266
+ if (timer2) clearTimeout(timer2);
10267
+ timer2 = void 0;
10268
+ if (!hidden4()) {
10269
+ const plan = await engine.fetchZdHeavyCancellation(orderId);
10270
+ if (!alive) return;
10271
+ if (plan) {
10272
+ shown = true;
10273
+ setState({ orderId, value: { status: "ready", plan } });
10274
+ if (settled(plan)) return;
10275
+ } else if (!shown) {
10276
+ setState({ orderId, value: { status: "unavailable" } });
10277
+ }
10278
+ }
10279
+ if (Date.now() - started2 > DELIVERY_GIVE_UP_MS) return;
10280
+ timer2 = setTimeout(read, ZDH_PLAN_REFRESH_MS);
10281
+ };
10282
+ readRef.current = () => {
10283
+ started2 = Date.now();
10284
+ void read();
10285
+ };
10286
+ void read();
10287
+ return () => {
10288
+ alive = false;
10289
+ readRef.current = () => {
10290
+ };
10291
+ if (timer2) clearTimeout(timer2);
10292
+ };
10293
+ }, [engine, orderId]);
10294
+ const refresh = react.useCallback(() => readRef.current(), []);
10295
+ return { state: state.orderId === orderId ? state.value : { status: "loading" }, refresh };
10296
+ }
10297
+ function useZdHeavySourceBinding(engine, chainId, hash2, orderId) {
10298
+ const key2 = `${chainId ?? ""}:${hash2}:${orderId ?? ""}`;
10299
+ const [state, setState] = react.useState({ key: key2, value: "checking" });
10300
+ react.useEffect(() => {
10301
+ setState({ key: key2, value: "checking" });
10302
+ if (!engine || typeof chainId !== "number" || !isZdHeavyOrderId(orderId)) {
10303
+ setState({ key: key2, value: "unbound" });
10304
+ return;
10305
+ }
10306
+ let alive = true;
10307
+ engine.verifyZdHeavySourceOrder(chainId, hash2, orderId).then((r) => alive && setState({ key: key2, value: r.ok ? "bound" : "unbound" })).catch(() => alive && setState({ key: key2, value: "unbound" }));
10308
+ return () => {
10309
+ alive = false;
10310
+ };
10311
+ }, [engine, chainId, hash2, orderId, key2]);
10312
+ return state.key === key2 ? state.value : "checking";
10313
+ }
10314
+ var lower5 = (s) => (s ?? "").toLowerCase();
10315
+ var shortHash = (h2) => `${h2.slice(0, 10)}\u2026${h2.slice(-8)}`;
10316
+ function showsZdHeavyRecovery(entry) {
10317
+ if (entry.protocol !== "zdheavy" || !isZdHeavyOrderId(entry.orderId)) return false;
10318
+ return !(entry.delivery === "delivered" && !entry.claimable);
10319
+ }
10320
+ function ZdHeavyRecovery(props) {
10321
+ const orderId = isZdHeavyOrderId(props.entry.orderId) ? props.entry.orderId : void 0;
10322
+ const binding = useZdHeavySourceBinding(props.engine, props.entry.chainId, props.entry.hash, orderId);
10323
+ const { state, refresh } = useZdHeavyRecovery(props.engine, binding === "bound" ? orderId : void 0);
10324
+ const view = state.status === "ready" ? zdHeavyRecovery(state.plan, props.account) : null;
10325
+ if (!orderId) return null;
10326
+ if (binding === "unbound") {
10327
+ return /* @__PURE__ */ jsxRuntime.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." });
10328
+ }
10329
+ if (state.status === "unavailable") {
10330
+ return /* @__PURE__ */ jsxRuntime.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." });
10331
+ }
10332
+ if (binding === "checking" || state.status === "loading" || !view) {
10333
+ return /* @__PURE__ */ jsxRuntime.jsx("p", { className: "sg-note sg-zdh-status", role: "status", "aria-live": "polite", children: "Checking whether this order can be cancelled\u2026" });
10334
+ }
10335
+ const plan = state.plan;
10336
+ if (view.kind === "delivered" || view.kind === "not-owner") return null;
10337
+ const chainName3 = (id) => CHAIN_LABELS[id] || `Chain ${id}`;
10338
+ const listNames = (ids) => {
10339
+ const names = ids.map(chainName3);
10340
+ return names.length <= 1 ? names[0] ?? "" : `${names.slice(0, -1).join(", ")} and ${names[names.length - 1]}`;
10341
+ };
10342
+ const amountLabel = (chainId, asset, amount) => {
10343
+ const t = (props.tokens ?? []).find((x) => Number(x.chainId) === chainId && lower5(String(x.address)) === lower5(asset));
10344
+ if (!t) return "your funds";
10345
+ try {
10346
+ return `${formatUnits(amount, Number(t.decimals))} ${t.symbol}`;
10347
+ } catch {
10348
+ return t.symbol;
10349
+ }
10350
+ };
10351
+ const bid = props.entry.fromTicker || props.entry.fromAsset || "funds";
10352
+ let headline;
10353
+ let body;
10354
+ let actions = [];
10355
+ let refunds = [];
10356
+ if (view.kind === "claim") {
10357
+ headline = "Ready to claim";
10358
+ 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.`;
10359
+ actions = view.claims.map((c) => ({
10360
+ // The signer is part of the key: another wallet's claim is another button, not this one's state.
10361
+ key: `claim:${c.chainId}:${c.token}:${props.account ?? ""}`,
10362
+ kind: "claim",
10363
+ chainId: c.chainId,
10364
+ asset: c.token,
10365
+ amount: c.amount,
10366
+ label: `Claim ${amountLabel(c.chainId, c.token, c.amount)}`,
10367
+ // The payee: the claim reads claimable[msg.sender], so only it can send this.
10368
+ owner: props.account ?? ""
10369
+ }));
10370
+ } else if (view.kind === "cancel") {
10371
+ const holding = plan.places.some((p) => p.lots.length > 0);
10372
+ headline = view.requested ? "Finish the cancellation" : "You can cancel this order and reclaim your funds";
10373
+ 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.`;
10374
+ actions = view.chains.map((chainId) => {
10375
+ const lots = plan.places.find((p) => p.kind === "router" && p.chainId === chainId)?.lots ?? [];
10376
+ return {
10377
+ key: `cancel:${chainId}:${props.account ?? ""}`,
10378
+ kind: "cancel",
10379
+ chainId,
10380
+ label: view.chains.length > 1 || view.requested ? `Cancel on ${chainName3(chainId)}` : "Cancel order",
10381
+ owner: plan.owner,
10382
+ lotKeys: lots.length ? lots.map((l) => l.key) : void 0
10383
+ };
10384
+ });
10385
+ } else if (view.kind === "refunded") {
10386
+ headline = "Cancellation reported by ZeroDelta";
10387
+ body = `ZeroDelta reports your ${bid} as refunded. This widget has not checked the refund on-chain.`;
10388
+ refunds = view.refunds.map((r) => r.txHash);
10389
+ } else {
10390
+ headline = "What happens next";
10391
+ body = "Your cancellation is in. Funds still travelling between networks are refunded when they land; this page updates by itself.";
10392
+ }
10393
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-zdh", "data-testid": "zdh-recovery", "data-zdh-recovery": view.kind, children: [
10394
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-zdh-title", children: headline }),
10395
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "sg-zdh-body", children: body }),
10396
+ actions.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-zdh-actions", children: actions.map(({ key: key2, ...a }) => /* @__PURE__ */ jsxRuntime.jsx(
10397
+ ZdHeavyActionButton,
10398
+ {
10399
+ ...a,
10400
+ engine: props.engine,
10401
+ provider: props.provider,
10402
+ account: props.account,
10403
+ walletChainId: props.walletChainId,
10404
+ onConnect: props.onConnect,
10405
+ orderId,
10406
+ chainName: chainName3(a.chainId),
10407
+ onConfirmed: refresh
10408
+ },
10409
+ key2
10410
+ )) }) : null,
10411
+ refunds.map((hash2) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-txd-hash", children: [
10412
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-meta-label", children: "Reported refund tx" }),
10413
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-mono", children: shortHash(hash2) })
10414
+ ] }, hash2))
10415
+ ] });
10416
+ }
10417
+ function ZdHeavyActionButton(args) {
10418
+ const a = useZdHeavyAction(args);
10419
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-zdh-action", children: [
10420
+ a.pending ? (
10421
+ // A write of this wallet for this order is broadcast and its receipt has not decided: no button,
10422
+ // on this mount or any later one, until it does (re-review 2026-12-01, finding 4).
10423
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "sg-note", role: "status", "aria-live": "polite", "data-testid": "zdh-action-pending", children: "Sent \u2014 confirming" })
10424
+ ) : a.stalled ? (
10425
+ // Still undecided after the bounded recheck: say so, and offer another CHECK — never a new send.
10426
+ /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
10427
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "sg-note", role: "status", "data-testid": "zdh-action-stalled", children: "Not confirmed yet \u2014 check the transaction" }),
10428
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "sg-btn sg-btn-ghost", onClick: a.retryCheck, children: "Retry check" })
10429
+ ] })
10430
+ ) : /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "sg-btn sg-btn-ghost", onClick: a.onClick, disabled: a.disabled, "data-zdh-action": args.kind, children: a.text }),
10431
+ a.error ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "sg-ws-error", role: "alert", "data-testid": "zdh-action-error", children: a.error }) : null,
10432
+ a.sentHash ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-txd-hash", children: [
10433
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-meta-label", children: args.kind === "claim" ? "Claim tx" : "Cancel tx" }),
10434
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-mono", children: shortHash(a.sentHash) })
10435
+ ] }) : null
10436
+ ] });
10437
+ }
9683
10438
  function BackGlyph() {
9684
10439
  return /* @__PURE__ */ jsxRuntime.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: [
9685
10440
  /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M19 12H5" }),
@@ -9766,6 +10521,7 @@ function TxLegs(props) {
9766
10521
  function statusBadge(entry) {
9767
10522
  if (entry.delivery === "delivered")
9768
10523
  return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-badge", "data-tone": "ok", children: "Delivered" });
10524
+ if (entry.delivery === "failed" && entry.deliveryStatus === "cancelled") return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-badge", children: "Cancellation reported" });
9769
10525
  if (entry.delivery === "failed")
9770
10526
  return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-badge", "data-tone": "warn", children: "Not delivered" });
9771
10527
  if (entry.delivery === "attention")
@@ -9910,7 +10666,20 @@ function TxDetail(props) {
9910
10666
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-meta-label", children: "Tx hash" }),
9911
10667
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-mono", children: `${e.hash.slice(0, 10)}\u2026${e.hash.slice(-8)}` }),
9912
10668
  /* @__PURE__ */ jsxRuntime.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__ */ jsxRuntime.jsx(CheckGlyph, {}) : /* @__PURE__ */ jsxRuntime.jsx(CopyGlyph, {}) })
9913
- ] })
10669
+ ] }),
10670
+ props.recovery?.engine && showsZdHeavyRecovery(e) ? /* @__PURE__ */ jsxRuntime.jsx(
10671
+ ZdHeavyRecovery,
10672
+ {
10673
+ entry: e,
10674
+ engine: props.recovery.engine,
10675
+ provider: props.recovery.provider,
10676
+ account: props.recovery.account,
10677
+ walletChainId: props.recovery.walletChainId,
10678
+ onConnect: props.recovery.onConnect,
10679
+ tokens: props.tokens
10680
+ },
10681
+ e.orderId
10682
+ ) : null
9914
10683
  ] });
9915
10684
  }
9916
10685
  function displayableHistory(entries, account) {
@@ -9939,7 +10708,15 @@ function TxHistoryPanel(props) {
9939
10708
  account ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-sel-sub sg-mono", children: shortAddress3(account) }) : null
9940
10709
  ] })
9941
10710
  ] }),
9942
- selected ? /* @__PURE__ */ jsxRuntime.jsx(TxDetail, { entry: selected, tokens: props.tokens, vaultIcons: props.vaultIcons }) : /* @__PURE__ */ jsxRuntime.jsx(TxHistoryList, { entries, tokens: props.tokens, vaultIcons: props.vaultIcons, onPick: pick })
10711
+ selected ? /* @__PURE__ */ jsxRuntime.jsx(
10712
+ TxDetail,
10713
+ {
10714
+ entry: selected,
10715
+ tokens: props.tokens,
10716
+ vaultIcons: props.vaultIcons,
10717
+ recovery: { engine: props.engine, provider: props.provider, account, walletChainId: props.walletChainId, onConnect: props.onConnect }
10718
+ }
10719
+ ) : /* @__PURE__ */ jsxRuntime.jsx(TxHistoryList, { entries, tokens: props.tokens, vaultIcons: props.vaultIcons, onPick: pick })
9943
10720
  ] });
9944
10721
  }
9945
10722
 
@@ -9971,7 +10748,7 @@ function registry(win) {
9971
10748
  const existing = registries.get(win);
9972
10749
  if (existing) return existing;
9973
10750
  const standard = /* @__PURE__ */ new Set();
9974
- const listeners = /* @__PURE__ */ new Set();
10751
+ const listeners2 = /* @__PURE__ */ new Set();
9975
10752
  let snapshot = EMPTY2;
9976
10753
  const read = () => {
9977
10754
  const candidates = [...standard].map(solanaWalletInfo);
@@ -10002,7 +10779,7 @@ function registry(win) {
10002
10779
  const refresh = () => {
10003
10780
  const previous = snapshot;
10004
10781
  read();
10005
- if (previous !== snapshot) for (const cb of listeners) cb();
10782
+ if (previous !== snapshot) for (const cb of listeners2) cb();
10006
10783
  };
10007
10784
  const api = {
10008
10785
  register(...wallets) {
@@ -10016,9 +10793,9 @@ function registry(win) {
10016
10793
  }
10017
10794
  };
10018
10795
  const result = { read, watch: (cb) => {
10019
- listeners.add(cb);
10796
+ listeners2.add(cb);
10020
10797
  return () => {
10021
- listeners.delete(cb);
10798
+ listeners2.delete(cb);
10022
10799
  };
10023
10800
  } };
10024
10801
  registries.set(win, result);
@@ -11224,13 +12001,13 @@ function PaymentIsland(props) {
11224
12001
  const exFromBal = exFrom && exFromToken ? exBalances[balanceKey(exFrom.chainId, exFromToken.address)] : void 0;
11225
12002
  const fundingTokens = react.useMemo(() => {
11226
12003
  const seen = /* @__PURE__ */ new Set();
11227
- const list = [];
12004
+ const list2 = [];
11228
12005
  for (const r of visibleRoutes) {
11229
12006
  const key2 = balanceKey(r.source.chainId, r.source.tokenAddress);
11230
12007
  if (seen.has(key2)) continue;
11231
12008
  seen.add(key2);
11232
12009
  const reg = registryTokens.find((t) => Number(t.chainId) === r.source.chainId && addrEq(t.address, r.source.tokenAddress));
11233
- list.push(
12010
+ list2.push(
11234
12011
  reg ?? {
11235
12012
  symbol: r.source.asset,
11236
12013
  displaySymbol: r.source.ticker,
@@ -11241,7 +12018,7 @@ function PaymentIsland(props) {
11241
12018
  }
11242
12019
  );
11243
12020
  }
11244
- return list;
12021
+ return list2;
11245
12022
  }, [visibleRoutes, registryTokens]);
11246
12023
  const fundingChains = react.useMemo(() => {
11247
12024
  const ids = new Set(fundingTokens.map((t) => Number(t.chainId)));
@@ -11249,15 +12026,15 @@ function PaymentIsland(props) {
11249
12026
  }, [chains, fundingTokens]);
11250
12027
  const payableAssets = react.useMemo(() => {
11251
12028
  const seen = /* @__PURE__ */ new Set();
11252
- const list = [];
12029
+ const list2 = [];
11253
12030
  for (const { route } of held) {
11254
12031
  const symbol = symbolKey(route.source.asset);
11255
12032
  if (seen.has(symbol)) continue;
11256
12033
  seen.add(symbol);
11257
12034
  const token = registryTokens.find((t) => Number(t.chainId) === route.source.chainId && addrEq(t.address, route.source.tokenAddress));
11258
- list.push({ symbol: route.source.asset, logoUrl: token?.logoUrl });
12035
+ list2.push({ symbol: route.source.asset, logoUrl: token?.logoUrl });
11259
12036
  }
11260
- return list;
12037
+ return list2;
11261
12038
  }, [held, registryTokens]);
11262
12039
  const userPicked = react.useRef(false);
11263
12040
  const selectRoute = react.useCallback(
@@ -11475,7 +12252,7 @@ function PaymentIsland(props) {
11475
12252
  ] });
11476
12253
  let body;
11477
12254
  if (hist && wallet.account) {
11478
- body = /* @__PURE__ */ jsxRuntime.jsx(TxHistoryPanel, { account: wallet.account, engine, tokens: registryTokens, vaultIcons: catalogue?.vaultIcons, initialEntry: hist.entry ?? null, onBack: closeHistory });
12255
+ body = /* @__PURE__ */ jsxRuntime.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 });
11479
12256
  } else if (isPay && view === "select" && wallet.account) {
11480
12257
  body = /* @__PURE__ */ jsxRuntime.jsx(
11481
12258
  TokenSelect,
@@ -11759,22 +12536,22 @@ function PillLauncher(props) {
11759
12536
  if (e.key !== "Tab") return;
11760
12537
  const root = dialogRef.current;
11761
12538
  if (!root) return;
11762
- const list = Array.from(root.querySelectorAll("a[href],button,input,select,textarea,[tabindex]")).filter(
12539
+ const list2 = Array.from(root.querySelectorAll("a[href],button,input,select,textarea,[tabindex]")).filter(
11763
12540
  (el) => el.tabIndex >= 0 && !el.hasAttribute("disabled") && el.getClientRects().length > 0
11764
12541
  );
11765
- if (list.length === 0) {
12542
+ if (list2.length === 0) {
11766
12543
  e.preventDefault();
11767
12544
  return;
11768
12545
  }
11769
- const first = list[0];
11770
- const last = list[list.length - 1];
11771
- const idx = list.indexOf(document.activeElement);
12546
+ const first = list2[0];
12547
+ const last = list2[list2.length - 1];
12548
+ const idx = list2.indexOf(document.activeElement);
11772
12549
  if (e.shiftKey) {
11773
12550
  if (idx <= 0) {
11774
12551
  e.preventDefault();
11775
12552
  last.focus();
11776
12553
  }
11777
- } else if (idx === -1 || idx === list.length - 1) {
12554
+ } else if (idx === -1 || idx === list2.length - 1) {
11778
12555
  e.preventDefault();
11779
12556
  first.focus();
11780
12557
  }
@@ -11947,12 +12724,12 @@ function PayCard(props) {
11947
12724
  const registryTokens = react.useMemo(() => catalogue?.tokens ?? [], [catalogue]);
11948
12725
  const fundingTokens = react.useMemo(() => {
11949
12726
  const seen = /* @__PURE__ */ new Set();
11950
- const list = [];
12727
+ const list2 = [];
11951
12728
  const push = (chainId, address, fallback) => {
11952
12729
  const key2 = balanceKey(chainId, address);
11953
12730
  if (seen.has(key2)) return;
11954
12731
  seen.add(key2);
11955
- list.push(registryTokens.find((t) => Number(t.chainId) === chainId && addrEq2(t.address, address)) ?? fallback);
12732
+ list2.push(registryTokens.find((t) => Number(t.chainId) === chainId && addrEq2(t.address, address)) ?? fallback);
11956
12733
  };
11957
12734
  for (const r of visibleRoutes) {
11958
12735
  push(r.source.chainId, r.source.tokenAddress, {
@@ -11967,7 +12744,7 @@ function PayCard(props) {
11967
12744
  for (const o of unquoted) {
11968
12745
  push(o.chainId, o.address, { symbol: o.symbol, displaySymbol: o.ticker, name: o.name, chainId: o.chainId, address: o.address, decimals: o.decimals, logoUrl: o.logoUrl });
11969
12746
  }
11970
- return list;
12747
+ return list2;
11971
12748
  }, [visibleRoutes, unquoted, registryTokens]);
11972
12749
  const fundingChains = react.useMemo(() => {
11973
12750
  const ids = new Set(fundingTokens.map((t) => Number(t.chainId)));
@@ -12073,7 +12850,7 @@ function PayCard(props) {
12073
12850
  ...durationLabel(sel.quote.estimatedDuration) ? [{ label: "Estimated time", value: durationLabel(sel.quote.estimatedDuration) }] : []
12074
12851
  ] : [];
12075
12852
  const loadingPlan = flow.status === "loading" || holdings.loading && !sel || pricing !== null;
12076
- return /* @__PURE__ */ jsxRuntime.jsx(WidgetShell, { title: config.title || "Complete payment", theme: config.theme, heightPx: props.heightPx, walletSlot, onClose: props.onClose, children: hist && wallet.account ? /* @__PURE__ */ jsxRuntime.jsx(TxHistoryPanel, { account: wallet.account, engine, tokens: registryTokens, vaultIcons: catalogue?.vaultIcons, initialEntry: hist.entry ?? null, onBack: closeHistory }) : view === "select" && wallet.account ? /* @__PURE__ */ jsxRuntime.jsx(
12853
+ return /* @__PURE__ */ jsxRuntime.jsx(WidgetShell, { title: config.title || "Complete payment", theme: config.theme, heightPx: props.heightPx, walletSlot, onClose: props.onClose, children: hist && wallet.account ? /* @__PURE__ */ jsxRuntime.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__ */ jsxRuntime.jsx(
12077
12854
  TokenSelect,
12078
12855
  {
12079
12856
  title: "Pay with",
@@ -12258,7 +13035,7 @@ function StableGenieSwap(props) {
12258
13035
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-brand", children: "ZeroDelta" })
12259
13036
  ] }) : void 0;
12260
13037
  if (hist && wallet.account) {
12261
- return /* @__PURE__ */ jsxRuntime.jsx(WidgetShell, { title: config.title || "Swap", theme: config.theme, walletSlot, children: /* @__PURE__ */ jsxRuntime.jsx(TxHistoryPanel, { account: wallet.account, engine, tokens: registryTokens, vaultIcons: catalogue?.vaultIcons, initialEntry: hist.entry ?? null, onBack: closeHistory }) });
13038
+ return /* @__PURE__ */ jsxRuntime.jsx(WidgetShell, { title: config.title || "Swap", theme: config.theme, walletSlot, children: /* @__PURE__ */ jsxRuntime.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 }) });
12262
13039
  }
12263
13040
  if (recipientState.open) return /* @__PURE__ */ jsxRuntime.jsx(WidgetShell, { title: config.title || "Swap", theme: config.theme, walletSlot, children: /* @__PURE__ */ jsxRuntime.jsx(RecipientSheet, { state: recipientState, symbol: toAsset }) });
12264
13041
  if (flow.status === "success" || flow.status === "pending") {
@@ -12548,16 +13325,16 @@ function Hint({ id, label: label2, text, hint }) {
12548
13325
  open ? /* @__PURE__ */ jsxRuntime.jsx("span", { role: "tooltip", id: tipId, className: "sg-cd-tip", children: text }) : null
12549
13326
  ] });
12550
13327
  }
12551
- function CheckRow2({ check: check2, hideNote }) {
12552
- const label2 = check2.id === "risk" ? check2.ok ? "Risk screening passed" : "Risk screening failed" : check2.label;
12553
- return /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "sg-cd-check", "data-ok": check2.ok, children: [
13328
+ function CheckRow2({ check: check3, hideNote }) {
13329
+ const label2 = check3.id === "risk" ? check3.ok ? "Risk screening passed" : "Risk screening failed" : check3.label;
13330
+ return /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "sg-cd-check", "data-ok": check3.ok, children: [
12554
13331
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cd-check-line", children: [
12555
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-check-mark", "data-ok": check2.ok, children: check2.ok ? /* @__PURE__ */ jsxRuntime.jsx(Tick, { size: 12 }) : /* @__PURE__ */ jsxRuntime.jsx(Cross, { size: 12 }) }),
13332
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-check-mark", "data-ok": check3.ok, children: check3.ok ? /* @__PURE__ */ jsxRuntime.jsx(Tick, { size: 12 }) : /* @__PURE__ */ jsxRuntime.jsx(Cross, { size: 12 }) }),
12556
13333
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-check-label", children: label2 }),
12557
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-sr-only", children: check2.ok ? " \u2014 passed" : " \u2014 failed" })
13334
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-sr-only", children: check3.ok ? " \u2014 passed" : " \u2014 failed" })
12558
13335
  ] }),
12559
- check2.note && !hideNote ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-check-note", children: check2.note }) : null,
12560
- check2.reasons.map((reason) => /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-check-reason", children: humanizeComplianceReason(reason) }, reason))
13336
+ check3.note && !hideNote ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-check-note", children: check3.note }) : null,
13337
+ check3.reasons.map((reason) => /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-check-reason", children: humanizeComplianceReason(reason) }, reason))
12561
13338
  ] });
12562
13339
  }
12563
13340
  function Fact2({ label: label2, value, title, mono = false }) {
@@ -12592,10 +13369,10 @@ function QuoteChecks2(props) {
12592
13369
  /* @__PURE__ */ jsxRuntime.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." })
12593
13370
  )
12594
13371
  ] }),
12595
- checks.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "sg-cd-checks", children: checks.map((check2) => (
13372
+ checks.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "sg-cd-checks", children: checks.map((check3) => (
12596
13373
  // The Figma row carries no sub-line: with ONE screened wallet the note would repeat the
12597
13374
  // address Quote details names two cards down. Any other note (a count of wallets) stays.
12598
- /* @__PURE__ */ jsxRuntime.jsx(CheckRow2, { check: check2, hideNote: check2.id === "screening" && wallets.length === 1 && hasDetails }, check2.id)
13375
+ /* @__PURE__ */ jsxRuntime.jsx(CheckRow2, { check: check3, hideNote: check3.id === "screening" && wallets.length === 1 && hasDetails }, check3.id)
12599
13376
  )) }) : null,
12600
13377
  orphans.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "sg-cd-orphans", children: orphans.map((reason) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: humanizeComplianceReason(reason) }, reason)) }) : null,
12601
13378
  props.direct && checks.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "sg-cd-scope", children: DIRECT_SCOPE_NOTE }) : null
@@ -13050,10 +13827,10 @@ function QuoteCard(props) {
13050
13827
  const hops = option.hops;
13051
13828
  const collapsed = side && hops.length > 3;
13052
13829
  const inline = collapsed ? [hops[0], hops[1], "gap", hops[hops.length - 1]] : hops;
13053
- const hidden3 = collapsed ? hops.slice(2, -1) : [];
13830
+ const hidden5 = collapsed ? hops.slice(2, -1) : [];
13054
13831
  const routeIcons = /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cq-route-icons", "data-testid": "compare-route-inline", children: inline.map((hop, i) => /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-hop-inline", children: [
13055
13832
  i > 0 ? /* @__PURE__ */ jsxRuntime.jsx(ArrowGlyph2, {}) : null,
13056
- hop === "gap" ? /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "sg-cq-gap", title: hidden3.map((h2) => `${h2.ticker} on ${props.chainName(h2.chainId)}`).join(" \u2192 "), "aria-label": `Also via ${hidden3.map((h2) => `${h2.ticker} on ${props.chainName(h2.chainId)}`).join(", ")}`, children: "\u2026" }) : /* @__PURE__ */ jsxRuntime.jsx("span", { title: `${hop.ticker} on ${props.chainName(hop.chainId)}`, children: /* @__PURE__ */ jsxRuntime.jsx(HopMark, { hop, tokens: props.tokens, size: "xxs" }) })
13833
+ hop === "gap" ? /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "sg-cq-gap", title: hidden5.map((h2) => `${h2.ticker} on ${props.chainName(h2.chainId)}`).join(" \u2192 "), "aria-label": `Also via ${hidden5.map((h2) => `${h2.ticker} on ${props.chainName(h2.chainId)}`).join(", ")}`, children: "\u2026" }) : /* @__PURE__ */ jsxRuntime.jsx("span", { title: `${hop.ticker} on ${props.chainName(hop.chainId)}`, children: /* @__PURE__ */ jsxRuntime.jsx(HopMark, { hop, tokens: props.tokens, size: "xxs" }) })
13057
13834
  ] }, hop === "gap" ? "gap" : `${hop.chainId}-${hop.address}-${i}`)) });
13058
13835
  const fee = compareFeeLabel(option.feeUsd);
13059
13836
  const tagEl = tags.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("span", { ref: tagRef, className: "sg-cq-tag", "data-kind": nettingTag ? "netting" : purple ? "purple" : "brand", children: tags.map((tag, i) => /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-tag-item", children: [
@@ -13776,7 +14553,7 @@ function ExchangeCard(props) {
13776
14553
  let body;
13777
14554
  let takeover = false;
13778
14555
  if (hist && connected2) {
13779
- body = /* @__PURE__ */ jsxRuntime.jsx(TxHistoryPanel, { account: wallet.account, engine, solanaAccount: solanaWallet.address, tokens, vaultIcons: catalogue?.vaultIcons, initialEntry: hist.entry ?? null, onBack: closeHistory });
14556
+ body = /* @__PURE__ */ jsxRuntime.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 });
13780
14557
  } else if (view === "from" || view === "to") {
13781
14558
  const isFrom = view === "from";
13782
14559
  body = /* @__PURE__ */ jsxRuntime.jsx(