@glacislabs/stablegenie-zerodelta 4.20.0 → 4.21.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/index.cjs CHANGED
@@ -1839,6 +1839,7 @@ function hubDeliverableSymbols(tokens, execution) {
1839
1839
  function isSourceToken(token, ctx) {
1840
1840
  const chainId = Number(token.chainId);
1841
1841
  if (!ctx.sourceChains.has(chainId)) return false;
1842
+ if (ctx.zdHeavySources?.has(tokenKey(chainId, token.address))) return true;
1842
1843
  return ctx.execution.has(chainId) || !isKnownUnbridgeable(token.bridge) && ctx.source.has(tokenKey(chainId, token.address));
1843
1844
  }
1844
1845
  function directLaneOK(token, source2, lanes) {
@@ -1857,6 +1858,7 @@ function laneLimitFor(token, source2, limitedLanes2) {
1857
1858
  }
1858
1859
  function destinationAvailability(token, ctx, source2) {
1859
1860
  if (brokenLaneFor(token, source2 ?? void 0, ctx.brokenLanes)) return "unreachable";
1861
+ if (source2 && ctx.zdHeavyLanes?.has(laneKey(source2.chainId, source2.address, token.chainId, token.address))) return "available";
1860
1862
  if (directLaneOK(token, source2 ?? void 0, ctx.lanes)) {
1861
1863
  if (ctx.execution.has(Number(token.chainId))) return "available";
1862
1864
  if (token.isChainedDestination === true) return "available";
@@ -1875,6 +1877,7 @@ function hasReachableDestination(source2, catalogue, ctx) {
1875
1877
  }
1876
1878
  function buildCatalogue(input) {
1877
1879
  const { chains, tokens, routes, supportedChainIds, brokenLanes } = input;
1880
+ const zdHeavy = (input.zdHeavyRoutes ?? []).filter((r) => !!r && typeof r === "object" && !Array.isArray(r) && r.isEnabled !== false && r.isQuotable === true);
1878
1881
  const product = input.product ?? "stable";
1879
1882
  const universe = productAssets(product);
1880
1883
  const allowedAssets = input.allowedAssets ? new Set([...input.allowedAssets].filter((a) => universe.has(a))) : universe;
@@ -1882,7 +1885,10 @@ function buildCatalogue(input) {
1882
1885
  const registryChainIds = new Set(enabledChains.map((c) => Number(c.chainId)));
1883
1886
  const sourceChains = new Set([...registryChainIds].filter((id) => supportedChainIds.has(id)));
1884
1887
  const execution = executionChainIds(enabledChains);
1885
- const projected = product === "rwa" ? routes.filter((route) => route.isEnabled !== false) : executableRoutes(routes);
1888
+ const projected = [...product === "rwa" ? routes.filter((route) => route.isEnabled !== false) : executableRoutes(routes), ...zdHeavy];
1889
+ const zdHeavyLanes = laneKeys(zdHeavy);
1890
+ const zdHeavySources = sourceKeys(zdHeavy);
1891
+ const zdHeavyKeys = /* @__PURE__ */ new Set([...zdHeavySources, ...destinationKeys(zdHeavy)]);
1886
1892
  const source2 = sourceKeys(projected);
1887
1893
  const destination = destinationKeys(projected);
1888
1894
  const lanes = laneKeys(projected);
@@ -1897,14 +1903,15 @@ function buildCatalogue(input) {
1897
1903
  if (!chainIds.has(chainId)) return false;
1898
1904
  if (product === "rwa") return true;
1899
1905
  if (execution.has(chainId) || token.isChainedDestination === true) return true;
1900
- if (!isExecutableBridge(token)) return false;
1901
1906
  const key2 = tokenKey(token.chainId, token.address);
1907
+ if (zdHeavyKeys.has(key2)) return true;
1908
+ if (!isExecutableBridge(token)) return false;
1902
1909
  return source2.has(key2) || destination.has(key2);
1903
1910
  });
1904
1911
  const ready = chains.length > 0 && routes.length > 0 && projectedCatalogue.length > 0;
1905
1912
  const catalogue = ready ? projectedCatalogue : allowed;
1906
1913
  const hubSymbols = hubDeliverableSymbols(catalogue, execution);
1907
- const ctx = { source: source2, destination, lanes, execution, sourceChains, hubSymbols, ...brokenLanes ? { brokenLanes } : {} };
1914
+ const ctx = { source: source2, destination, lanes, execution, sourceChains, hubSymbols, ...zdHeavy.length ? { zdHeavyLanes, zdHeavySources } : {}, ...brokenLanes ? { brokenLanes } : {} };
1908
1915
  const sellable = (token) => product !== "rwa" || isSellableRwa(token);
1909
1916
  const sources2 = ready ? catalogue.filter((token) => sellable(token) && isSourceToken(token, ctx) && hasReachableDestination(token, catalogue, ctx)) : (
1910
1917
  // Unprojected: the only rule we can still apply with confidence is the escrow-chain bound,
@@ -3222,6 +3229,15 @@ function zdHeavyRouterPinned(chainId, router) {
3222
3229
  }
3223
3230
 
3224
3231
  // src/core/quote-option.ts
3232
+ function gateZdHeavyOptions(response, request, quotableRoutes) {
3233
+ if (!Array.isArray(response?.options)) return response;
3234
+ const matchesToken = (chainId, token, address, symbol) => typeof address === "string" && !!address && chainAddressKey(chainId, token) === chainAddressKey(chainId, address) || typeof symbol === "string" && !!symbolKey(symbol) && symbolKey(token) === symbolKey(symbol);
3235
+ const matchesLane = quotableRoutes.some(
3236
+ (r) => !!r && typeof r === "object" && !Array.isArray(r) && r.isEnabled !== false && r.isQuotable === true && Number(r.fromChainId) === Number(request.inputChain) && Number(r.toChainId) === Number(request.outputChain) && matchesToken(request.inputChain, request.inputToken, r.fromAddress, r.fromSymbol) && matchesToken(request.outputChain, request.outputToken, r.toAddress, r.toSymbol)
3237
+ );
3238
+ if (matchesLane) return response;
3239
+ return { ...response, options: response.options.filter((option) => option?.protocol !== "zdheavy") };
3240
+ }
3225
3241
  function zdHeavyExecutable(q) {
3226
3242
  const order = q.execution?.order;
3227
3243
  const chainId = typeof q.fromChainId === "number" ? q.fromChainId : Number(order?.chainNumber);
@@ -3439,6 +3455,7 @@ function resultForOption(result, option, mode, destinationChainId) {
3439
3455
  var DEFAULT_DEADLINE_SECONDS = 1800;
3440
3456
  var MAX_DEADLINE_SECONDS = 60 * 60;
3441
3457
  var ABSOLUTE_MAX_DEADLINE_SECONDS = 24 * 60 * 60;
3458
+ var DEADLINE_CLOCK_SKEW_SECONDS = 120;
3442
3459
  function recommendedDeadlineSeconds(quote) {
3443
3460
  const recommended = Number(quote?.recommendedDeadlineSeconds);
3444
3461
  if (!Number.isFinite(recommended) || recommended <= 0) return DEFAULT_DEADLINE_SECONDS;
@@ -3534,7 +3551,7 @@ function assertQuoteMatchesSelection({ quote, order, orders, option, destination
3534
3551
  throw new Error("ZeroDelta order guarantees less than the displayed receive amount.");
3535
3552
  }
3536
3553
  const maxDeadline = maxDeadlineSeconds(quote);
3537
- if (!Number.isFinite(deadline) || deadline <= now || deadline > now + maxDeadline) {
3554
+ if (!Number.isFinite(deadline) || deadline <= now || deadline > now + maxDeadline + DEADLINE_CLOCK_SKEW_SECONDS) {
3538
3555
  throw new Error("ZeroDelta quote deadline is invalid or too far in the future.");
3539
3556
  }
3540
3557
  for (let index = 1; index < list.length; index += 1) {
@@ -4152,6 +4169,16 @@ async function allowanceCovers(tx, account, ethCall2) {
4152
4169
  }
4153
4170
 
4154
4171
  // src/core/zdheavy-route.ts
4172
+ var ZdHeavyQuoteExpiredError = class extends Error {
4173
+ code = "zdheavy_quote_expired";
4174
+ constructor() {
4175
+ super("This ZD Heavy quote expired before it was signed. A fresh quote is loading \u2014 review it and press Exchange again.");
4176
+ this.name = "ZdHeavyQuoteExpiredError";
4177
+ }
4178
+ };
4179
+ function assertZdHeavyQuoteFresh(order, nowSec) {
4180
+ if (order && (order.expiresAt <= nowSec || order.expiryDate <= nowSec)) throw new ZdHeavyQuoteExpiredError();
4181
+ }
4155
4182
  function zdHeavyExpected(route, owner, receiver, tokens, routes) {
4156
4183
  const heavy = route.zdHeavy;
4157
4184
  if (!heavy) throw new Error("Missing ZD Heavy order.");
@@ -4177,6 +4204,7 @@ function zdHeavyExpected(route, owner, receiver, tokens, routes) {
4177
4204
  };
4178
4205
  }
4179
4206
  function validateZdHeavyPlan(route, expected) {
4207
+ assertZdHeavyQuoteFresh(expected.order, expected.nowSec);
4180
4208
  if (route.transactions.length !== 2 || route.transactions[0].kind !== "approve" || route.transactions[1].kind !== "submitOrder") {
4181
4209
  throw new Error("ZD Heavy requires exactly approve then submitOrder; refusing to sign.");
4182
4210
  }
@@ -4981,7 +5009,7 @@ var CHANNEL_HEADER = "x-zd-channel";
4981
5009
  var CHANNEL_VERSION_HEADER = "x-zd-channel-version";
4982
5010
  var CHANNEL_ORIGIN_HEADER = "x-zd-channel-origin";
4983
5011
  var WIDGET_CHANNEL = "widget";
4984
- var WIDGET_VERSION = "4.20.0" ;
5012
+ var WIDGET_VERSION = "4.21.0" ;
4985
5013
  var MAX_CHANNEL_VERSION_LEN = 32;
4986
5014
  function sanitizeVersion(raw2) {
4987
5015
  const v = String(raw2).trim();
@@ -5105,7 +5133,7 @@ function wait(ms) {
5105
5133
  }
5106
5134
  var PAGE_LIMIT = 500;
5107
5135
  var MAX_PAGES = 10;
5108
- var newRegistryCache = () => ({ chains: null, tokens: null, routes: null, health: null, vaults: null, promotions: null, inflight: /* @__PURE__ */ new Map() });
5136
+ var newRegistryCache = () => ({ chains: null, tokens: null, routes: null, zdHeavy: null, health: null, vaults: null, promotions: null, inflight: /* @__PURE__ */ new Map() });
5109
5137
  var SHARED_REGISTRY = /* @__PURE__ */ new WeakMap();
5110
5138
  function registryCacheFor(scope) {
5111
5139
  if (!scope) return newRegistryCache();
@@ -5182,13 +5210,14 @@ function createApiClient(cfg) {
5182
5210
  const json = await requestJson(path, init);
5183
5211
  return json?.data ?? json;
5184
5212
  }
5185
- async function requestAllPages(path) {
5213
+ async function requestAllPages(path, params = {}) {
5186
5214
  const rows = [];
5187
5215
  let firstRow = "";
5188
5216
  for (let page = 0; page < MAX_PAGES; page += 1) {
5189
- const json = await requestJson(`${path}${toQuery({ limit: PAGE_LIMIT, offset: rows.length || void 0 })}`);
5217
+ const json = await requestJson(`${path}${toQuery({ ...params, limit: PAGE_LIMIT, offset: rows.length || void 0 })}`);
5190
5218
  const envelope = json && !Array.isArray(json) ? json : {};
5191
5219
  const data = Array.isArray(json) ? json : envelope.data;
5220
+ if (params.protocol === "zdheavy" && !Array.isArray(data)) throw apiError(`ZeroDelta returned an unusable list (${path}).`, { code: "bad_response" });
5192
5221
  const pageRows = Array.isArray(data) ? data : [];
5193
5222
  const head = pageRows.length ? JSON.stringify(pageRows[0]) : "";
5194
5223
  if (page === 0) firstRow = head;
@@ -5234,6 +5263,20 @@ function createApiClient(cfg) {
5234
5263
  }
5235
5264
  });
5236
5265
  }
5266
+ function fetchZdHeavyRoutes() {
5267
+ if (nowFresh(cache.zdHeavy)) return Promise.resolve(cache.zdHeavy.value);
5268
+ return once("zdHeavy", async () => {
5269
+ let value = [];
5270
+ try {
5271
+ const rows = await requestAllPages("/routes", { protocol: "zdheavy", isEnabled: true });
5272
+ value = rows.filter((r) => !!r && typeof r === "object" && !Array.isArray(r) && r.isEnabled !== false && r.isQuotable === true);
5273
+ } catch {
5274
+ value = [];
5275
+ }
5276
+ cache.zdHeavy = { at: Date.now(), value };
5277
+ return value;
5278
+ });
5279
+ }
5237
5280
  function fetchRouteHealth() {
5238
5281
  if (nowFresh(cache.health)) return Promise.resolve(cache.health.value);
5239
5282
  return once("health", async () => {
@@ -5312,7 +5355,8 @@ function createApiClient(cfg) {
5312
5355
  for (let attempt = 0; attempt <= retries; attempt += 1) {
5313
5356
  try {
5314
5357
  const quote = await apiRequest("/quote", { method: "POST", headers: { "X-ZD-Shape": "native" }, body: JSON.stringify(request), timeoutMs: 18e3 });
5315
- return normalizeQuoteResponse(quote, request);
5358
+ const gated = Array.isArray(quote?.options) && quote.options.some((option) => option?.protocol === "zdheavy") ? gateZdHeavyOptions(quote, request, await fetchZdHeavyRoutes()) : quote;
5359
+ return normalizeQuoteResponse(gated, request);
5316
5360
  } catch (error) {
5317
5361
  lastError = error;
5318
5362
  if (attempt >= retries || !isTransientQuoteError(error)) throw error;
@@ -5368,7 +5412,7 @@ function createApiClient(cfg) {
5368
5412
  return false;
5369
5413
  }
5370
5414
  }
5371
- return { apiRequest, fetchChains, fetchTokens, fetchRoutes, fetchRouteHealth, fetchRwaVaults, fetchPrices, fetchPromotions, fetchQuote, screenWallet, reportSubmission, apiBase };
5415
+ return { apiRequest, fetchChains, fetchTokens, fetchRoutes, fetchZdHeavyRoutes, fetchRouteHealth, fetchRwaVaults, fetchPrices, fetchPromotions, fetchQuote, screenWallet, reportSubmission, apiBase };
5372
5416
  }
5373
5417
 
5374
5418
  // src/core/plan.ts
@@ -5999,10 +6043,11 @@ function createEngine(config = {}) {
5999
6043
  fetchPrices: (symbols) => api.fetchPrices ? api.fetchPrices(symbols) : Promise.resolve({}),
6000
6044
  fetchPromotions: () => api.fetchPromotions ? api.fetchPromotions() : Promise.resolve([]),
6001
6045
  fetchCatalogue: async (allowedAssets, product, options) => {
6002
- const [chains, registryTokens, routes, health, vaults] = await Promise.all([
6046
+ const [chains, registryTokens, routes, zdHeavyRoutes, health, vaults] = await Promise.all([
6003
6047
  api.fetchChains().catch(() => []),
6004
6048
  api.fetchTokens().catch(() => []),
6005
6049
  api.fetchRoutes().catch(() => []),
6050
+ api.fetchZdHeavyRoutes(),
6006
6051
  api.fetchRouteHealth(),
6007
6052
  api.fetchRwaVaults()
6008
6053
  ]);
@@ -6013,6 +6058,7 @@ function createEngine(config = {}) {
6013
6058
  chains,
6014
6059
  tokens,
6015
6060
  routes,
6061
+ zdHeavyRoutes,
6016
6062
  product,
6017
6063
  ...allowed ? { allowedAssets: allowed } : {},
6018
6064
  // Solana is a SOURCE only for a surface that can pay from it (the exchange card, through the
@@ -6412,6 +6458,8 @@ function useUserPresence() {
6412
6458
  }
6413
6459
 
6414
6460
  // src/react/hooks/useFlow.ts
6461
+ var REFRESH_LEAD_SECONDS = 20;
6462
+ var SIGN_MIN_SECONDS = 15;
6415
6463
  function reportQuietly(engine, report, stage) {
6416
6464
  try {
6417
6465
  void engine.reportSubmission?.({ ...report, stage })?.catch?.(() => {
@@ -6435,6 +6483,7 @@ function useFlow(args) {
6435
6483
  const [nonce, setNonce] = react.useState(0);
6436
6484
  const reqId = react.useRef(0);
6437
6485
  const busyRef = react.useRef(false);
6486
+ const keepExpiryError = react.useRef(false);
6438
6487
  const [planAt, setPlanAt] = react.useState(0);
6439
6488
  const planAtRef = react.useRef(0);
6440
6489
  const statusRef = react.useRef("idle");
@@ -6464,7 +6513,8 @@ function useFlow(args) {
6464
6513
  }
6465
6514
  const id = ++reqId.current;
6466
6515
  setStatus("loading");
6467
- setError(null);
6516
+ if (!keepExpiryError.current) setError(null);
6517
+ keepExpiryError.current = false;
6468
6518
  setVerdict(null);
6469
6519
  setTxHash(null);
6470
6520
  setLastTxEntry(null);
@@ -6557,6 +6607,10 @@ function useFlow(args) {
6557
6607
  setVerdict(null);
6558
6608
  const patch = (id, s, hash2) => setSteps((prev) => prev.map((st) => st.id === id ? { ...st, state: s, ...hash2 ? { hash: hash2 } : {} } : st));
6559
6609
  try {
6610
+ if (route.zdHeavy) {
6611
+ if (route.zdHeavy.order.expiresAt - Date.now() / 1e3 < SIGN_MIN_SECONDS) throw new ZdHeavyQuoteExpiredError();
6612
+ assertZdHeavyQuoteFresh(route.zdHeavy.order, Math.floor(Date.now() / 1e3));
6613
+ }
6560
6614
  const current = await getChainId(provider);
6561
6615
  if (current !== Number(sourceChainId)) {
6562
6616
  await switchChain(provider, Number(sourceChainId));
@@ -6587,6 +6641,7 @@ function useFlow(args) {
6587
6641
  patch(tx.id, "done");
6588
6642
  continue;
6589
6643
  }
6644
+ if (route.zdHeavy && tx.kind === "submitOrder") assertZdHeavyQuoteFresh(route.zdHeavy.order, Math.floor(Date.now() / 1e3));
6590
6645
  if (!validatePlannedTransaction(tx, route, recipient2, heavyExpected ? { ...heavyExpected, nowSec: Math.floor(Date.now() / 1e3) } : void 0)) {
6591
6646
  throw new Error(`Refusing to sign a ${tx.kind} that does not match the reviewed plan.`);
6592
6647
  }
@@ -6651,13 +6706,17 @@ function useFlow(args) {
6651
6706
  }
6652
6707
  } catch (e) {
6653
6708
  setStatus("error");
6654
- setError(normalizeWalletError(e));
6709
+ setError(e instanceof ZdHeavyQuoteExpiredError ? e.message : normalizeWalletError(e));
6710
+ if (e instanceof ZdHeavyQuoteExpiredError) {
6711
+ keepExpiryError.current = true;
6712
+ reload();
6713
+ }
6655
6714
  setSteps((prev) => prev.map((st) => st.state === "active" ? { ...st, state: "error" } : st));
6656
6715
  onError?.(e instanceof Error ? e : new Error(String(e)));
6657
6716
  } finally {
6658
6717
  busyRef.current = false;
6659
6718
  }
6660
- }, [selected, wallet.provider, wallet.account, engine, kind, recipientFor, onSuccess, onError]);
6719
+ }, [selected, wallet.provider, wallet.account, engine, kind, recipientFor, onSuccess, onError, reload]);
6661
6720
  const [prices, setPrices] = react.useState(null);
6662
6721
  const priceKey = baseSelected?.options?.length ? `${baseSelected.source.asset}|${baseSelected.receive.asset}` : "";
6663
6722
  react.useEffect(() => {
@@ -6753,6 +6812,24 @@ function useFlow(args) {
6753
6812
  const quoteReady = status === "ready" && !!plan;
6754
6813
  const quotePaused = quoteReady && idle2;
6755
6814
  const quoteStale = quoteReady && (idle2 || planAt < returnedAt2);
6815
+ react.useEffect(() => {
6816
+ if (!enabled || !selected?.zdHeavy || !quoteReady || quotePaused || busyRef.current) return;
6817
+ let timer2;
6818
+ const schedule = () => {
6819
+ clearTimeout(timer2);
6820
+ if (document.visibilityState !== "visible" || busyRef.current) return;
6821
+ const delay = Math.max(3e3, (selected.zdHeavy.order.expiresAt - REFRESH_LEAD_SECONDS) * 1e3 - Date.now());
6822
+ timer2 = setTimeout(() => {
6823
+ if (!busyRef.current && statusRef.current === "ready" && !isUserIdle() && document.visibilityState === "visible") reload();
6824
+ }, delay);
6825
+ };
6826
+ schedule();
6827
+ document.addEventListener("visibilitychange", schedule);
6828
+ return () => {
6829
+ clearTimeout(timer2);
6830
+ document.removeEventListener("visibilitychange", schedule);
6831
+ };
6832
+ }, [enabled, selected, quoteReady, quotePaused, reload]);
6756
6833
  return {
6757
6834
  status,
6758
6835
  plan,
package/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
- export { B as BankPayoutAccount, E as Eip1193Provider, a as ExchangeInput, b as ExchangeMode, L as LinkIdentity, M as MountConfig, P as PaymentIsland, c as PaymentIslandKind, d as PaymentIslandProps, e as PillOpenAs, S as SettlementMethod, f as StableGenieConfig, g as StableGenieExchange, h as StableGenieExchangeProps, i as StableGeniePay, j as StableGeniePayProps, k as StableGenieProvider, l as StableGenieRwaExchange, m as StableGenieSwap, n as StableGenieSwapProps, o as StableGenieTheme, p as SuccessInfo, q as SupportedAsset, r as darkTheme, s as lightTheme, t as mount, u as resolveTheme } from './mount-D2tDkHea.cjs';
1
+ export { B as BankPayoutAccount, E as Eip1193Provider, a as ExchangeInput, b as ExchangeMode, L as LinkIdentity, M as MountConfig, P as PaymentIsland, c as PaymentIslandKind, d as PaymentIslandProps, e as PillOpenAs, S as SettlementMethod, f as StableGenieConfig, g as StableGenieExchange, h as StableGenieExchangeProps, i as StableGeniePay, j as StableGeniePayProps, k as StableGenieProvider, l as StableGenieRwaExchange, m as StableGenieSwap, n as StableGenieSwapProps, o as StableGenieTheme, p as SuccessInfo, q as SupportedAsset, r as darkTheme, s as lightTheme, t as mount, u as resolveTheme } from './mount-C2GLFqgK.cjs';
2
2
  import * as react from 'react';
3
- import { C as Compliance } from './verify-UqDjAVxa.cjs';
4
- export { A as Availability, B as BrokenLane, a as Catalogue, b as Chain, c as ComplianceCheck, d as ComplianceTone, e as ComplianceView, E as EngineConfig, f as ExchangeProduct, L as LaneLimit, P as Plan, R as Route, g as RouteLeg, h as RouteResult, S as SanitizedTxEntry, T as Token, i as TxHistoryEntry, V as VerifyResult, W as WalletScreen, j as assetClassOf, k as brokenLaneReason, l as complianceChecks, m as complianceControlsLine, n as complianceView, o as counterpartTokens, p as destinationAvailability, q as formatJurisdiction, r as humanizeComplianceReason } from './verify-UqDjAVxa.cjs';
3
+ import { C as Compliance } from './verify-CeHRSKl2.cjs';
4
+ export { A as Availability, B as BrokenLane, a as Catalogue, b as Chain, c as ComplianceCheck, d as ComplianceTone, e as ComplianceView, E as EngineConfig, f as ExchangeProduct, L as LaneLimit, P as Plan, R as Route, g as RouteLeg, h as RouteResult, S as SanitizedTxEntry, T as Token, i as TxHistoryEntry, V as VerifyResult, W as WalletScreen, j as assetClassOf, k as brokenLaneReason, l as complianceChecks, m as complianceControlsLine, n as complianceView, o as counterpartTokens, p as destinationAvailability, q as formatJurisdiction, r as humanizeComplianceReason } from './verify-CeHRSKl2.cjs';
5
5
  export { EXECUTABLE_STABLE_ASSETS, Engine, STABLE_ASSETS, SUPPORTED_ASSETS, SUPPORTED_CHAIN_IDS, TRADEABLE_RWA_ASSETS, createEngine, symbolKey } from './core/index.cjs';
6
6
 
7
7
  interface SolanaWalletInfo {
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- export { B as BankPayoutAccount, E as Eip1193Provider, a as ExchangeInput, b as ExchangeMode, L as LinkIdentity, M as MountConfig, P as PaymentIsland, c as PaymentIslandKind, d as PaymentIslandProps, e as PillOpenAs, S as SettlementMethod, f as StableGenieConfig, g as StableGenieExchange, h as StableGenieExchangeProps, i as StableGeniePay, j as StableGeniePayProps, k as StableGenieProvider, l as StableGenieRwaExchange, m as StableGenieSwap, n as StableGenieSwapProps, o as StableGenieTheme, p as SuccessInfo, q as SupportedAsset, r as darkTheme, s as lightTheme, t as mount, u as resolveTheme } from './mount-DuTF5CQV.js';
1
+ export { B as BankPayoutAccount, E as Eip1193Provider, a as ExchangeInput, b as ExchangeMode, L as LinkIdentity, M as MountConfig, P as PaymentIsland, c as PaymentIslandKind, d as PaymentIslandProps, e as PillOpenAs, S as SettlementMethod, f as StableGenieConfig, g as StableGenieExchange, h as StableGenieExchangeProps, i as StableGeniePay, j as StableGeniePayProps, k as StableGenieProvider, l as StableGenieRwaExchange, m as StableGenieSwap, n as StableGenieSwapProps, o as StableGenieTheme, p as SuccessInfo, q as SupportedAsset, r as darkTheme, s as lightTheme, t as mount, u as resolveTheme } from './mount-867H-JSe.js';
2
2
  import * as react from 'react';
3
- import { C as Compliance } from './verify-UqDjAVxa.js';
4
- export { A as Availability, B as BrokenLane, a as Catalogue, b as Chain, c as ComplianceCheck, d as ComplianceTone, e as ComplianceView, E as EngineConfig, f as ExchangeProduct, L as LaneLimit, P as Plan, R as Route, g as RouteLeg, h as RouteResult, S as SanitizedTxEntry, T as Token, i as TxHistoryEntry, V as VerifyResult, W as WalletScreen, j as assetClassOf, k as brokenLaneReason, l as complianceChecks, m as complianceControlsLine, n as complianceView, o as counterpartTokens, p as destinationAvailability, q as formatJurisdiction, r as humanizeComplianceReason } from './verify-UqDjAVxa.js';
3
+ import { C as Compliance } from './verify-CeHRSKl2.js';
4
+ export { A as Availability, B as BrokenLane, a as Catalogue, b as Chain, c as ComplianceCheck, d as ComplianceTone, e as ComplianceView, E as EngineConfig, f as ExchangeProduct, L as LaneLimit, P as Plan, R as Route, g as RouteLeg, h as RouteResult, S as SanitizedTxEntry, T as Token, i as TxHistoryEntry, V as VerifyResult, W as WalletScreen, j as assetClassOf, k as brokenLaneReason, l as complianceChecks, m as complianceControlsLine, n as complianceView, o as counterpartTokens, p as destinationAvailability, q as formatJurisdiction, r as humanizeComplianceReason } from './verify-CeHRSKl2.js';
5
5
  export { EXECUTABLE_STABLE_ASSETS, Engine, STABLE_ASSETS, SUPPORTED_ASSETS, SUPPORTED_CHAIN_IDS, TRADEABLE_RWA_ASSETS, createEngine, symbolKey } from './core/index.js';
6
6
 
7
7
  interface SolanaWalletInfo {
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export { CompliancePanel, PaymentIsland, StableGenieExchange, StableGeniePay, StableGenieProvider, StableGenieRwaExchange, StableGenieSwap, connectSolanaWallet, darkTheme, disconnectSolanaWallet, discoverSolanaWallets, lightTheme, mount, onSolanaAccountChange, resolveTheme, solanaWalletSigner, useSolanaWallet, watchSolanaWallets } from './chunk-FXH7TCJ5.js';
2
- export { EXECUTABLE_STABLE_ASSETS, STABLE_ASSETS, SUPPORTED_ASSETS, SUPPORTED_CHAIN_IDS, TRADEABLE_RWA_ASSETS, assetClassOf, brokenLaneReason, complianceChecks, complianceControlsLine, complianceView, counterpartTokens, createEngine, destinationAvailability, formatJurisdiction, humanizeComplianceReason, symbolKey } from './chunk-JIQRTR3C.js';
1
+ export { CompliancePanel, PaymentIsland, StableGenieExchange, StableGeniePay, StableGenieProvider, StableGenieRwaExchange, StableGenieSwap, connectSolanaWallet, darkTheme, disconnectSolanaWallet, discoverSolanaWallets, lightTheme, mount, onSolanaAccountChange, resolveTheme, solanaWalletSigner, useSolanaWallet, watchSolanaWallets } from './chunk-3E554IZO.js';
2
+ export { EXECUTABLE_STABLE_ASSETS, STABLE_ASSETS, SUPPORTED_ASSETS, SUPPORTED_CHAIN_IDS, TRADEABLE_RWA_ASSETS, assetClassOf, brokenLaneReason, complianceChecks, complianceControlsLine, complianceView, counterpartTokens, createEngine, destinationAvailability, formatJurisdiction, humanizeComplianceReason, symbolKey } from './chunk-KOFREX5L.js';
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode } from 'react';
3
- import { P as Plan, V as VerifyResult, h as RouteResult, S as SanitizedTxEntry, f as ExchangeProduct } from './verify-UqDjAVxa.js';
3
+ import { P as Plan, V as VerifyResult, h as RouteResult, S as SanitizedTxEntry, f as ExchangeProduct } from './verify-CeHRSKl2.js';
4
4
 
5
5
  interface Eip1193Provider {
6
6
  request(args: {
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode } from 'react';
3
- import { P as Plan, V as VerifyResult, h as RouteResult, S as SanitizedTxEntry, f as ExchangeProduct } from './verify-UqDjAVxa.cjs';
3
+ import { P as Plan, V as VerifyResult, h as RouteResult, S as SanitizedTxEntry, f as ExchangeProduct } from './verify-CeHRSKl2.cjs';
4
4
 
5
5
  interface Eip1193Provider {
6
6
  request(args: {
package/dist/mount.cjs CHANGED
@@ -1836,6 +1836,7 @@ function hubDeliverableSymbols(tokens, execution) {
1836
1836
  function isSourceToken(token, ctx) {
1837
1837
  const chainId = Number(token.chainId);
1838
1838
  if (!ctx.sourceChains.has(chainId)) return false;
1839
+ if (ctx.zdHeavySources?.has(tokenKey(chainId, token.address))) return true;
1839
1840
  return ctx.execution.has(chainId) || !isKnownUnbridgeable(token.bridge) && ctx.source.has(tokenKey(chainId, token.address));
1840
1841
  }
1841
1842
  function directLaneOK(token, source2, lanes) {
@@ -1854,6 +1855,7 @@ function laneLimitFor(token, source2, limitedLanes2) {
1854
1855
  }
1855
1856
  function destinationAvailability(token, ctx, source2) {
1856
1857
  if (brokenLaneFor(token, source2 ?? void 0, ctx.brokenLanes)) return "unreachable";
1858
+ if (source2 && ctx.zdHeavyLanes?.has(laneKey(source2.chainId, source2.address, token.chainId, token.address))) return "available";
1857
1859
  if (directLaneOK(token, source2 ?? void 0, ctx.lanes)) {
1858
1860
  if (ctx.execution.has(Number(token.chainId))) return "available";
1859
1861
  if (token.isChainedDestination === true) return "available";
@@ -1872,6 +1874,7 @@ function hasReachableDestination(source2, catalogue, ctx) {
1872
1874
  }
1873
1875
  function buildCatalogue(input) {
1874
1876
  const { chains, tokens, routes, supportedChainIds, brokenLanes } = input;
1877
+ const zdHeavy = (input.zdHeavyRoutes ?? []).filter((r) => !!r && typeof r === "object" && !Array.isArray(r) && r.isEnabled !== false && r.isQuotable === true);
1875
1878
  const product = input.product ?? "stable";
1876
1879
  const universe = productAssets(product);
1877
1880
  const allowedAssets = input.allowedAssets ? new Set([...input.allowedAssets].filter((a) => universe.has(a))) : universe;
@@ -1879,7 +1882,10 @@ function buildCatalogue(input) {
1879
1882
  const registryChainIds = new Set(enabledChains.map((c) => Number(c.chainId)));
1880
1883
  const sourceChains = new Set([...registryChainIds].filter((id) => supportedChainIds.has(id)));
1881
1884
  const execution = executionChainIds(enabledChains);
1882
- const projected = product === "rwa" ? routes.filter((route) => route.isEnabled !== false) : executableRoutes(routes);
1885
+ const projected = [...product === "rwa" ? routes.filter((route) => route.isEnabled !== false) : executableRoutes(routes), ...zdHeavy];
1886
+ const zdHeavyLanes = laneKeys(zdHeavy);
1887
+ const zdHeavySources = sourceKeys(zdHeavy);
1888
+ const zdHeavyKeys = /* @__PURE__ */ new Set([...zdHeavySources, ...destinationKeys(zdHeavy)]);
1883
1889
  const source2 = sourceKeys(projected);
1884
1890
  const destination = destinationKeys(projected);
1885
1891
  const lanes = laneKeys(projected);
@@ -1894,14 +1900,15 @@ function buildCatalogue(input) {
1894
1900
  if (!chainIds.has(chainId)) return false;
1895
1901
  if (product === "rwa") return true;
1896
1902
  if (execution.has(chainId) || token.isChainedDestination === true) return true;
1897
- if (!isExecutableBridge(token)) return false;
1898
1903
  const key2 = tokenKey(token.chainId, token.address);
1904
+ if (zdHeavyKeys.has(key2)) return true;
1905
+ if (!isExecutableBridge(token)) return false;
1899
1906
  return source2.has(key2) || destination.has(key2);
1900
1907
  });
1901
1908
  const ready = chains.length > 0 && routes.length > 0 && projectedCatalogue.length > 0;
1902
1909
  const catalogue = ready ? projectedCatalogue : allowed;
1903
1910
  const hubSymbols = hubDeliverableSymbols(catalogue, execution);
1904
- const ctx = { source: source2, destination, lanes, execution, sourceChains, hubSymbols, ...brokenLanes ? { brokenLanes } : {} };
1911
+ const ctx = { source: source2, destination, lanes, execution, sourceChains, hubSymbols, ...zdHeavy.length ? { zdHeavyLanes, zdHeavySources } : {}, ...brokenLanes ? { brokenLanes } : {} };
1905
1912
  const sellable = (token) => product !== "rwa" || isSellableRwa(token);
1906
1913
  const sources2 = ready ? catalogue.filter((token) => sellable(token) && isSourceToken(token, ctx) && hasReachableDestination(token, catalogue, ctx)) : (
1907
1914
  // Unprojected: the only rule we can still apply with confidence is the escrow-chain bound,
@@ -3203,6 +3210,15 @@ function zdHeavyRouterPinned(chainId, router) {
3203
3210
  }
3204
3211
 
3205
3212
  // src/core/quote-option.ts
3213
+ function gateZdHeavyOptions(response, request, quotableRoutes) {
3214
+ if (!Array.isArray(response?.options)) return response;
3215
+ const matchesToken = (chainId, token, address, symbol) => typeof address === "string" && !!address && chainAddressKey(chainId, token) === chainAddressKey(chainId, address) || typeof symbol === "string" && !!symbolKey(symbol) && symbolKey(token) === symbolKey(symbol);
3216
+ const matchesLane = quotableRoutes.some(
3217
+ (r) => !!r && typeof r === "object" && !Array.isArray(r) && r.isEnabled !== false && r.isQuotable === true && Number(r.fromChainId) === Number(request.inputChain) && Number(r.toChainId) === Number(request.outputChain) && matchesToken(request.inputChain, request.inputToken, r.fromAddress, r.fromSymbol) && matchesToken(request.outputChain, request.outputToken, r.toAddress, r.toSymbol)
3218
+ );
3219
+ if (matchesLane) return response;
3220
+ return { ...response, options: response.options.filter((option) => option?.protocol !== "zdheavy") };
3221
+ }
3206
3222
  function zdHeavyExecutable(q) {
3207
3223
  const order = q.execution?.order;
3208
3224
  const chainId = typeof q.fromChainId === "number" ? q.fromChainId : Number(order?.chainNumber);
@@ -3420,6 +3436,7 @@ function resultForOption(result, option, mode, destinationChainId) {
3420
3436
  var DEFAULT_DEADLINE_SECONDS = 1800;
3421
3437
  var MAX_DEADLINE_SECONDS = 60 * 60;
3422
3438
  var ABSOLUTE_MAX_DEADLINE_SECONDS = 24 * 60 * 60;
3439
+ var DEADLINE_CLOCK_SKEW_SECONDS = 120;
3423
3440
  function recommendedDeadlineSeconds(quote) {
3424
3441
  const recommended = Number(quote?.recommendedDeadlineSeconds);
3425
3442
  if (!Number.isFinite(recommended) || recommended <= 0) return DEFAULT_DEADLINE_SECONDS;
@@ -3515,7 +3532,7 @@ function assertQuoteMatchesSelection({ quote, order, orders, option, destination
3515
3532
  throw new Error("ZeroDelta order guarantees less than the displayed receive amount.");
3516
3533
  }
3517
3534
  const maxDeadline = maxDeadlineSeconds(quote);
3518
- if (!Number.isFinite(deadline) || deadline <= now || deadline > now + maxDeadline) {
3535
+ if (!Number.isFinite(deadline) || deadline <= now || deadline > now + maxDeadline + DEADLINE_CLOCK_SKEW_SECONDS) {
3519
3536
  throw new Error("ZeroDelta quote deadline is invalid or too far in the future.");
3520
3537
  }
3521
3538
  for (let index = 1; index < list.length; index += 1) {
@@ -4133,6 +4150,16 @@ async function allowanceCovers(tx, account, ethCall2) {
4133
4150
  }
4134
4151
 
4135
4152
  // src/core/zdheavy-route.ts
4153
+ var ZdHeavyQuoteExpiredError = class extends Error {
4154
+ code = "zdheavy_quote_expired";
4155
+ constructor() {
4156
+ super("This ZD Heavy quote expired before it was signed. A fresh quote is loading \u2014 review it and press Exchange again.");
4157
+ this.name = "ZdHeavyQuoteExpiredError";
4158
+ }
4159
+ };
4160
+ function assertZdHeavyQuoteFresh(order, nowSec) {
4161
+ if (order && (order.expiresAt <= nowSec || order.expiryDate <= nowSec)) throw new ZdHeavyQuoteExpiredError();
4162
+ }
4136
4163
  function zdHeavyExpected(route, owner, receiver, tokens, routes) {
4137
4164
  const heavy = route.zdHeavy;
4138
4165
  if (!heavy) throw new Error("Missing ZD Heavy order.");
@@ -4158,6 +4185,7 @@ function zdHeavyExpected(route, owner, receiver, tokens, routes) {
4158
4185
  };
4159
4186
  }
4160
4187
  function validateZdHeavyPlan(route, expected) {
4188
+ assertZdHeavyQuoteFresh(expected.order, expected.nowSec);
4161
4189
  if (route.transactions.length !== 2 || route.transactions[0].kind !== "approve" || route.transactions[1].kind !== "submitOrder") {
4162
4190
  throw new Error("ZD Heavy requires exactly approve then submitOrder; refusing to sign.");
4163
4191
  }
@@ -4962,7 +4990,7 @@ var CHANNEL_HEADER = "x-zd-channel";
4962
4990
  var CHANNEL_VERSION_HEADER = "x-zd-channel-version";
4963
4991
  var CHANNEL_ORIGIN_HEADER = "x-zd-channel-origin";
4964
4992
  var WIDGET_CHANNEL = "widget";
4965
- var WIDGET_VERSION = "4.20.0" ;
4993
+ var WIDGET_VERSION = "4.21.0" ;
4966
4994
  var MAX_CHANNEL_VERSION_LEN = 32;
4967
4995
  function sanitizeVersion(raw2) {
4968
4996
  const v = String(raw2).trim();
@@ -5086,7 +5114,7 @@ function wait(ms) {
5086
5114
  }
5087
5115
  var PAGE_LIMIT = 500;
5088
5116
  var MAX_PAGES = 10;
5089
- var newRegistryCache = () => ({ chains: null, tokens: null, routes: null, health: null, vaults: null, promotions: null, inflight: /* @__PURE__ */ new Map() });
5117
+ var newRegistryCache = () => ({ chains: null, tokens: null, routes: null, zdHeavy: null, health: null, vaults: null, promotions: null, inflight: /* @__PURE__ */ new Map() });
5090
5118
  var SHARED_REGISTRY = /* @__PURE__ */ new WeakMap();
5091
5119
  function registryCacheFor(scope) {
5092
5120
  if (!scope) return newRegistryCache();
@@ -5163,13 +5191,14 @@ function createApiClient(cfg) {
5163
5191
  const json = await requestJson(path, init);
5164
5192
  return json?.data ?? json;
5165
5193
  }
5166
- async function requestAllPages(path) {
5194
+ async function requestAllPages(path, params = {}) {
5167
5195
  const rows = [];
5168
5196
  let firstRow = "";
5169
5197
  for (let page = 0; page < MAX_PAGES; page += 1) {
5170
- const json = await requestJson(`${path}${toQuery({ limit: PAGE_LIMIT, offset: rows.length || void 0 })}`);
5198
+ const json = await requestJson(`${path}${toQuery({ ...params, limit: PAGE_LIMIT, offset: rows.length || void 0 })}`);
5171
5199
  const envelope = json && !Array.isArray(json) ? json : {};
5172
5200
  const data = Array.isArray(json) ? json : envelope.data;
5201
+ if (params.protocol === "zdheavy" && !Array.isArray(data)) throw apiError(`ZeroDelta returned an unusable list (${path}).`, { code: "bad_response" });
5173
5202
  const pageRows = Array.isArray(data) ? data : [];
5174
5203
  const head = pageRows.length ? JSON.stringify(pageRows[0]) : "";
5175
5204
  if (page === 0) firstRow = head;
@@ -5215,6 +5244,20 @@ function createApiClient(cfg) {
5215
5244
  }
5216
5245
  });
5217
5246
  }
5247
+ function fetchZdHeavyRoutes() {
5248
+ if (nowFresh(cache.zdHeavy)) return Promise.resolve(cache.zdHeavy.value);
5249
+ return once("zdHeavy", async () => {
5250
+ let value = [];
5251
+ try {
5252
+ const rows = await requestAllPages("/routes", { protocol: "zdheavy", isEnabled: true });
5253
+ value = rows.filter((r) => !!r && typeof r === "object" && !Array.isArray(r) && r.isEnabled !== false && r.isQuotable === true);
5254
+ } catch {
5255
+ value = [];
5256
+ }
5257
+ cache.zdHeavy = { at: Date.now(), value };
5258
+ return value;
5259
+ });
5260
+ }
5218
5261
  function fetchRouteHealth() {
5219
5262
  if (nowFresh(cache.health)) return Promise.resolve(cache.health.value);
5220
5263
  return once("health", async () => {
@@ -5293,7 +5336,8 @@ function createApiClient(cfg) {
5293
5336
  for (let attempt = 0; attempt <= retries; attempt += 1) {
5294
5337
  try {
5295
5338
  const quote = await apiRequest("/quote", { method: "POST", headers: { "X-ZD-Shape": "native" }, body: JSON.stringify(request), timeoutMs: 18e3 });
5296
- return normalizeQuoteResponse(quote, request);
5339
+ const gated = Array.isArray(quote?.options) && quote.options.some((option) => option?.protocol === "zdheavy") ? gateZdHeavyOptions(quote, request, await fetchZdHeavyRoutes()) : quote;
5340
+ return normalizeQuoteResponse(gated, request);
5297
5341
  } catch (error) {
5298
5342
  lastError = error;
5299
5343
  if (attempt >= retries || !isTransientQuoteError(error)) throw error;
@@ -5349,7 +5393,7 @@ function createApiClient(cfg) {
5349
5393
  return false;
5350
5394
  }
5351
5395
  }
5352
- return { apiRequest, fetchChains, fetchTokens, fetchRoutes, fetchRouteHealth, fetchRwaVaults, fetchPrices, fetchPromotions, fetchQuote, screenWallet, reportSubmission, apiBase };
5396
+ return { apiRequest, fetchChains, fetchTokens, fetchRoutes, fetchZdHeavyRoutes, fetchRouteHealth, fetchRwaVaults, fetchPrices, fetchPromotions, fetchQuote, screenWallet, reportSubmission, apiBase };
5353
5397
  }
5354
5398
 
5355
5399
  // src/core/plan.ts
@@ -5980,10 +6024,11 @@ function createEngine(config = {}) {
5980
6024
  fetchPrices: (symbols) => api.fetchPrices ? api.fetchPrices(symbols) : Promise.resolve({}),
5981
6025
  fetchPromotions: () => api.fetchPromotions ? api.fetchPromotions() : Promise.resolve([]),
5982
6026
  fetchCatalogue: async (allowedAssets, product, options) => {
5983
- const [chains, registryTokens, routes, health, vaults] = await Promise.all([
6027
+ const [chains, registryTokens, routes, zdHeavyRoutes, health, vaults] = await Promise.all([
5984
6028
  api.fetchChains().catch(() => []),
5985
6029
  api.fetchTokens().catch(() => []),
5986
6030
  api.fetchRoutes().catch(() => []),
6031
+ api.fetchZdHeavyRoutes(),
5987
6032
  api.fetchRouteHealth(),
5988
6033
  api.fetchRwaVaults()
5989
6034
  ]);
@@ -5994,6 +6039,7 @@ function createEngine(config = {}) {
5994
6039
  chains,
5995
6040
  tokens,
5996
6041
  routes,
6042
+ zdHeavyRoutes,
5997
6043
  product,
5998
6044
  ...allowed ? { allowedAssets: allowed } : {},
5999
6045
  // Solana is a SOURCE only for a surface that can pay from it (the exchange card, through the
@@ -6393,6 +6439,8 @@ function useUserPresence() {
6393
6439
  }
6394
6440
 
6395
6441
  // src/react/hooks/useFlow.ts
6442
+ var REFRESH_LEAD_SECONDS = 20;
6443
+ var SIGN_MIN_SECONDS = 15;
6396
6444
  function reportQuietly(engine, report, stage) {
6397
6445
  try {
6398
6446
  void engine.reportSubmission?.({ ...report, stage })?.catch?.(() => {
@@ -6416,6 +6464,7 @@ function useFlow(args) {
6416
6464
  const [nonce, setNonce] = react.useState(0);
6417
6465
  const reqId = react.useRef(0);
6418
6466
  const busyRef = react.useRef(false);
6467
+ const keepExpiryError = react.useRef(false);
6419
6468
  const [planAt, setPlanAt] = react.useState(0);
6420
6469
  const planAtRef = react.useRef(0);
6421
6470
  const statusRef = react.useRef("idle");
@@ -6445,7 +6494,8 @@ function useFlow(args) {
6445
6494
  }
6446
6495
  const id = ++reqId.current;
6447
6496
  setStatus("loading");
6448
- setError(null);
6497
+ if (!keepExpiryError.current) setError(null);
6498
+ keepExpiryError.current = false;
6449
6499
  setVerdict(null);
6450
6500
  setTxHash(null);
6451
6501
  setLastTxEntry(null);
@@ -6538,6 +6588,10 @@ function useFlow(args) {
6538
6588
  setVerdict(null);
6539
6589
  const patch = (id, s, hash2) => setSteps((prev) => prev.map((st) => st.id === id ? { ...st, state: s, ...hash2 ? { hash: hash2 } : {} } : st));
6540
6590
  try {
6591
+ if (route.zdHeavy) {
6592
+ if (route.zdHeavy.order.expiresAt - Date.now() / 1e3 < SIGN_MIN_SECONDS) throw new ZdHeavyQuoteExpiredError();
6593
+ assertZdHeavyQuoteFresh(route.zdHeavy.order, Math.floor(Date.now() / 1e3));
6594
+ }
6541
6595
  const current = await getChainId(provider);
6542
6596
  if (current !== Number(sourceChainId)) {
6543
6597
  await switchChain(provider, Number(sourceChainId));
@@ -6568,6 +6622,7 @@ function useFlow(args) {
6568
6622
  patch(tx.id, "done");
6569
6623
  continue;
6570
6624
  }
6625
+ if (route.zdHeavy && tx.kind === "submitOrder") assertZdHeavyQuoteFresh(route.zdHeavy.order, Math.floor(Date.now() / 1e3));
6571
6626
  if (!validatePlannedTransaction(tx, route, recipient2, heavyExpected ? { ...heavyExpected, nowSec: Math.floor(Date.now() / 1e3) } : void 0)) {
6572
6627
  throw new Error(`Refusing to sign a ${tx.kind} that does not match the reviewed plan.`);
6573
6628
  }
@@ -6632,13 +6687,17 @@ function useFlow(args) {
6632
6687
  }
6633
6688
  } catch (e) {
6634
6689
  setStatus("error");
6635
- setError(normalizeWalletError(e));
6690
+ setError(e instanceof ZdHeavyQuoteExpiredError ? e.message : normalizeWalletError(e));
6691
+ if (e instanceof ZdHeavyQuoteExpiredError) {
6692
+ keepExpiryError.current = true;
6693
+ reload();
6694
+ }
6636
6695
  setSteps((prev) => prev.map((st) => st.state === "active" ? { ...st, state: "error" } : st));
6637
6696
  onError?.(e instanceof Error ? e : new Error(String(e)));
6638
6697
  } finally {
6639
6698
  busyRef.current = false;
6640
6699
  }
6641
- }, [selected, wallet.provider, wallet.account, engine, kind, recipientFor, onSuccess, onError]);
6700
+ }, [selected, wallet.provider, wallet.account, engine, kind, recipientFor, onSuccess, onError, reload]);
6642
6701
  const [prices, setPrices] = react.useState(null);
6643
6702
  const priceKey = baseSelected?.options?.length ? `${baseSelected.source.asset}|${baseSelected.receive.asset}` : "";
6644
6703
  react.useEffect(() => {
@@ -6734,6 +6793,24 @@ function useFlow(args) {
6734
6793
  const quoteReady = status === "ready" && !!plan;
6735
6794
  const quotePaused = quoteReady && idle2;
6736
6795
  const quoteStale = quoteReady && (idle2 || planAt < returnedAt2);
6796
+ react.useEffect(() => {
6797
+ if (!enabled || !selected?.zdHeavy || !quoteReady || quotePaused || busyRef.current) return;
6798
+ let timer2;
6799
+ const schedule = () => {
6800
+ clearTimeout(timer2);
6801
+ if (document.visibilityState !== "visible" || busyRef.current) return;
6802
+ const delay = Math.max(3e3, (selected.zdHeavy.order.expiresAt - REFRESH_LEAD_SECONDS) * 1e3 - Date.now());
6803
+ timer2 = setTimeout(() => {
6804
+ if (!busyRef.current && statusRef.current === "ready" && !isUserIdle() && document.visibilityState === "visible") reload();
6805
+ }, delay);
6806
+ };
6807
+ schedule();
6808
+ document.addEventListener("visibilitychange", schedule);
6809
+ return () => {
6810
+ clearTimeout(timer2);
6811
+ document.removeEventListener("visibilitychange", schedule);
6812
+ };
6813
+ }, [enabled, selected, quoteReady, quotePaused, reload]);
6737
6814
  return {
6738
6815
  status,
6739
6816
  plan,
package/dist/mount.d.cts CHANGED
@@ -1,3 +1,3 @@
1
- export { M as MountConfig, t as mount } from './mount-D2tDkHea.cjs';
1
+ export { M as MountConfig, t as mount } from './mount-C2GLFqgK.cjs';
2
2
  import 'react';
3
- import './verify-UqDjAVxa.cjs';
3
+ import './verify-CeHRSKl2.cjs';