@glacislabs/stablegenie-zerodelta 4.20.1 → 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/{chunk-4WBNXYOV.js → chunk-3E554IZO.js} +35 -4
- package/dist/{chunk-RUHREVDT.js → chunk-KOFREX5L.js} +56 -11
- package/dist/core/index.cjs +55 -10
- package/dist/core/index.d.cts +2 -2
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.js +1 -1
- package/dist/index.cjs +89 -13
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/{mount-DuTF5CQV.d.ts → mount-867H-JSe.d.ts} +1 -1
- package/dist/{mount-D2tDkHea.d.cts → mount-C2GLFqgK.d.cts} +1 -1
- package/dist/mount.cjs +89 -13
- package/dist/mount.d.cts +2 -2
- package/dist/mount.d.ts +2 -2
- package/dist/mount.js +2 -2
- package/dist/standalone.global.js +8 -8
- package/dist/{verify-UqDjAVxa.d.cts → verify-CeHRSKl2.d.cts} +10 -1
- package/dist/{verify-UqDjAVxa.d.ts → verify-CeHRSKl2.d.ts} +10 -1
- package/package.json +1 -1
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);
|
|
@@ -4153,6 +4169,16 @@ async function allowanceCovers(tx, account, ethCall2) {
|
|
|
4153
4169
|
}
|
|
4154
4170
|
|
|
4155
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
|
+
}
|
|
4156
4182
|
function zdHeavyExpected(route, owner, receiver, tokens, routes) {
|
|
4157
4183
|
const heavy = route.zdHeavy;
|
|
4158
4184
|
if (!heavy) throw new Error("Missing ZD Heavy order.");
|
|
@@ -4178,6 +4204,7 @@ function zdHeavyExpected(route, owner, receiver, tokens, routes) {
|
|
|
4178
4204
|
};
|
|
4179
4205
|
}
|
|
4180
4206
|
function validateZdHeavyPlan(route, expected) {
|
|
4207
|
+
assertZdHeavyQuoteFresh(expected.order, expected.nowSec);
|
|
4181
4208
|
if (route.transactions.length !== 2 || route.transactions[0].kind !== "approve" || route.transactions[1].kind !== "submitOrder") {
|
|
4182
4209
|
throw new Error("ZD Heavy requires exactly approve then submitOrder; refusing to sign.");
|
|
4183
4210
|
}
|
|
@@ -4982,7 +5009,7 @@ var CHANNEL_HEADER = "x-zd-channel";
|
|
|
4982
5009
|
var CHANNEL_VERSION_HEADER = "x-zd-channel-version";
|
|
4983
5010
|
var CHANNEL_ORIGIN_HEADER = "x-zd-channel-origin";
|
|
4984
5011
|
var WIDGET_CHANNEL = "widget";
|
|
4985
|
-
var WIDGET_VERSION = "4.
|
|
5012
|
+
var WIDGET_VERSION = "4.21.0" ;
|
|
4986
5013
|
var MAX_CHANNEL_VERSION_LEN = 32;
|
|
4987
5014
|
function sanitizeVersion(raw2) {
|
|
4988
5015
|
const v = String(raw2).trim();
|
|
@@ -5106,7 +5133,7 @@ function wait(ms) {
|
|
|
5106
5133
|
}
|
|
5107
5134
|
var PAGE_LIMIT = 500;
|
|
5108
5135
|
var MAX_PAGES = 10;
|
|
5109
|
-
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() });
|
|
5110
5137
|
var SHARED_REGISTRY = /* @__PURE__ */ new WeakMap();
|
|
5111
5138
|
function registryCacheFor(scope) {
|
|
5112
5139
|
if (!scope) return newRegistryCache();
|
|
@@ -5183,13 +5210,14 @@ function createApiClient(cfg) {
|
|
|
5183
5210
|
const json = await requestJson(path, init);
|
|
5184
5211
|
return json?.data ?? json;
|
|
5185
5212
|
}
|
|
5186
|
-
async function requestAllPages(path) {
|
|
5213
|
+
async function requestAllPages(path, params = {}) {
|
|
5187
5214
|
const rows = [];
|
|
5188
5215
|
let firstRow = "";
|
|
5189
5216
|
for (let page = 0; page < MAX_PAGES; page += 1) {
|
|
5190
|
-
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 })}`);
|
|
5191
5218
|
const envelope = json && !Array.isArray(json) ? json : {};
|
|
5192
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" });
|
|
5193
5221
|
const pageRows = Array.isArray(data) ? data : [];
|
|
5194
5222
|
const head = pageRows.length ? JSON.stringify(pageRows[0]) : "";
|
|
5195
5223
|
if (page === 0) firstRow = head;
|
|
@@ -5235,6 +5263,20 @@ function createApiClient(cfg) {
|
|
|
5235
5263
|
}
|
|
5236
5264
|
});
|
|
5237
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
|
+
}
|
|
5238
5280
|
function fetchRouteHealth() {
|
|
5239
5281
|
if (nowFresh(cache.health)) return Promise.resolve(cache.health.value);
|
|
5240
5282
|
return once("health", async () => {
|
|
@@ -5313,7 +5355,8 @@ function createApiClient(cfg) {
|
|
|
5313
5355
|
for (let attempt = 0; attempt <= retries; attempt += 1) {
|
|
5314
5356
|
try {
|
|
5315
5357
|
const quote = await apiRequest("/quote", { method: "POST", headers: { "X-ZD-Shape": "native" }, body: JSON.stringify(request), timeoutMs: 18e3 });
|
|
5316
|
-
|
|
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);
|
|
5317
5360
|
} catch (error) {
|
|
5318
5361
|
lastError = error;
|
|
5319
5362
|
if (attempt >= retries || !isTransientQuoteError(error)) throw error;
|
|
@@ -5369,7 +5412,7 @@ function createApiClient(cfg) {
|
|
|
5369
5412
|
return false;
|
|
5370
5413
|
}
|
|
5371
5414
|
}
|
|
5372
|
-
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 };
|
|
5373
5416
|
}
|
|
5374
5417
|
|
|
5375
5418
|
// src/core/plan.ts
|
|
@@ -6000,10 +6043,11 @@ function createEngine(config = {}) {
|
|
|
6000
6043
|
fetchPrices: (symbols) => api.fetchPrices ? api.fetchPrices(symbols) : Promise.resolve({}),
|
|
6001
6044
|
fetchPromotions: () => api.fetchPromotions ? api.fetchPromotions() : Promise.resolve([]),
|
|
6002
6045
|
fetchCatalogue: async (allowedAssets, product, options) => {
|
|
6003
|
-
const [chains, registryTokens, routes, health, vaults] = await Promise.all([
|
|
6046
|
+
const [chains, registryTokens, routes, zdHeavyRoutes, health, vaults] = await Promise.all([
|
|
6004
6047
|
api.fetchChains().catch(() => []),
|
|
6005
6048
|
api.fetchTokens().catch(() => []),
|
|
6006
6049
|
api.fetchRoutes().catch(() => []),
|
|
6050
|
+
api.fetchZdHeavyRoutes(),
|
|
6007
6051
|
api.fetchRouteHealth(),
|
|
6008
6052
|
api.fetchRwaVaults()
|
|
6009
6053
|
]);
|
|
@@ -6014,6 +6058,7 @@ function createEngine(config = {}) {
|
|
|
6014
6058
|
chains,
|
|
6015
6059
|
tokens,
|
|
6016
6060
|
routes,
|
|
6061
|
+
zdHeavyRoutes,
|
|
6017
6062
|
product,
|
|
6018
6063
|
...allowed ? { allowedAssets: allowed } : {},
|
|
6019
6064
|
// Solana is a SOURCE only for a surface that can pay from it (the exchange card, through the
|
|
@@ -6413,6 +6458,8 @@ function useUserPresence() {
|
|
|
6413
6458
|
}
|
|
6414
6459
|
|
|
6415
6460
|
// src/react/hooks/useFlow.ts
|
|
6461
|
+
var REFRESH_LEAD_SECONDS = 20;
|
|
6462
|
+
var SIGN_MIN_SECONDS = 15;
|
|
6416
6463
|
function reportQuietly(engine, report, stage) {
|
|
6417
6464
|
try {
|
|
6418
6465
|
void engine.reportSubmission?.({ ...report, stage })?.catch?.(() => {
|
|
@@ -6436,6 +6483,7 @@ function useFlow(args) {
|
|
|
6436
6483
|
const [nonce, setNonce] = react.useState(0);
|
|
6437
6484
|
const reqId = react.useRef(0);
|
|
6438
6485
|
const busyRef = react.useRef(false);
|
|
6486
|
+
const keepExpiryError = react.useRef(false);
|
|
6439
6487
|
const [planAt, setPlanAt] = react.useState(0);
|
|
6440
6488
|
const planAtRef = react.useRef(0);
|
|
6441
6489
|
const statusRef = react.useRef("idle");
|
|
@@ -6465,7 +6513,8 @@ function useFlow(args) {
|
|
|
6465
6513
|
}
|
|
6466
6514
|
const id = ++reqId.current;
|
|
6467
6515
|
setStatus("loading");
|
|
6468
|
-
setError(null);
|
|
6516
|
+
if (!keepExpiryError.current) setError(null);
|
|
6517
|
+
keepExpiryError.current = false;
|
|
6469
6518
|
setVerdict(null);
|
|
6470
6519
|
setTxHash(null);
|
|
6471
6520
|
setLastTxEntry(null);
|
|
@@ -6558,6 +6607,10 @@ function useFlow(args) {
|
|
|
6558
6607
|
setVerdict(null);
|
|
6559
6608
|
const patch = (id, s, hash2) => setSteps((prev) => prev.map((st) => st.id === id ? { ...st, state: s, ...hash2 ? { hash: hash2 } : {} } : st));
|
|
6560
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
|
+
}
|
|
6561
6614
|
const current = await getChainId(provider);
|
|
6562
6615
|
if (current !== Number(sourceChainId)) {
|
|
6563
6616
|
await switchChain(provider, Number(sourceChainId));
|
|
@@ -6588,6 +6641,7 @@ function useFlow(args) {
|
|
|
6588
6641
|
patch(tx.id, "done");
|
|
6589
6642
|
continue;
|
|
6590
6643
|
}
|
|
6644
|
+
if (route.zdHeavy && tx.kind === "submitOrder") assertZdHeavyQuoteFresh(route.zdHeavy.order, Math.floor(Date.now() / 1e3));
|
|
6591
6645
|
if (!validatePlannedTransaction(tx, route, recipient2, heavyExpected ? { ...heavyExpected, nowSec: Math.floor(Date.now() / 1e3) } : void 0)) {
|
|
6592
6646
|
throw new Error(`Refusing to sign a ${tx.kind} that does not match the reviewed plan.`);
|
|
6593
6647
|
}
|
|
@@ -6652,13 +6706,17 @@ function useFlow(args) {
|
|
|
6652
6706
|
}
|
|
6653
6707
|
} catch (e) {
|
|
6654
6708
|
setStatus("error");
|
|
6655
|
-
setError(normalizeWalletError(e));
|
|
6709
|
+
setError(e instanceof ZdHeavyQuoteExpiredError ? e.message : normalizeWalletError(e));
|
|
6710
|
+
if (e instanceof ZdHeavyQuoteExpiredError) {
|
|
6711
|
+
keepExpiryError.current = true;
|
|
6712
|
+
reload();
|
|
6713
|
+
}
|
|
6656
6714
|
setSteps((prev) => prev.map((st) => st.state === "active" ? { ...st, state: "error" } : st));
|
|
6657
6715
|
onError?.(e instanceof Error ? e : new Error(String(e)));
|
|
6658
6716
|
} finally {
|
|
6659
6717
|
busyRef.current = false;
|
|
6660
6718
|
}
|
|
6661
|
-
}, [selected, wallet.provider, wallet.account, engine, kind, recipientFor, onSuccess, onError]);
|
|
6719
|
+
}, [selected, wallet.provider, wallet.account, engine, kind, recipientFor, onSuccess, onError, reload]);
|
|
6662
6720
|
const [prices, setPrices] = react.useState(null);
|
|
6663
6721
|
const priceKey = baseSelected?.options?.length ? `${baseSelected.source.asset}|${baseSelected.receive.asset}` : "";
|
|
6664
6722
|
react.useEffect(() => {
|
|
@@ -6754,6 +6812,24 @@ function useFlow(args) {
|
|
|
6754
6812
|
const quoteReady = status === "ready" && !!plan;
|
|
6755
6813
|
const quotePaused = quoteReady && idle2;
|
|
6756
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]);
|
|
6757
6833
|
return {
|
|
6758
6834
|
status,
|
|
6759
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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);
|
|
@@ -4134,6 +4150,16 @@ async function allowanceCovers(tx, account, ethCall2) {
|
|
|
4134
4150
|
}
|
|
4135
4151
|
|
|
4136
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
|
+
}
|
|
4137
4163
|
function zdHeavyExpected(route, owner, receiver, tokens, routes) {
|
|
4138
4164
|
const heavy = route.zdHeavy;
|
|
4139
4165
|
if (!heavy) throw new Error("Missing ZD Heavy order.");
|
|
@@ -4159,6 +4185,7 @@ function zdHeavyExpected(route, owner, receiver, tokens, routes) {
|
|
|
4159
4185
|
};
|
|
4160
4186
|
}
|
|
4161
4187
|
function validateZdHeavyPlan(route, expected) {
|
|
4188
|
+
assertZdHeavyQuoteFresh(expected.order, expected.nowSec);
|
|
4162
4189
|
if (route.transactions.length !== 2 || route.transactions[0].kind !== "approve" || route.transactions[1].kind !== "submitOrder") {
|
|
4163
4190
|
throw new Error("ZD Heavy requires exactly approve then submitOrder; refusing to sign.");
|
|
4164
4191
|
}
|
|
@@ -4963,7 +4990,7 @@ var CHANNEL_HEADER = "x-zd-channel";
|
|
|
4963
4990
|
var CHANNEL_VERSION_HEADER = "x-zd-channel-version";
|
|
4964
4991
|
var CHANNEL_ORIGIN_HEADER = "x-zd-channel-origin";
|
|
4965
4992
|
var WIDGET_CHANNEL = "widget";
|
|
4966
|
-
var WIDGET_VERSION = "4.
|
|
4993
|
+
var WIDGET_VERSION = "4.21.0" ;
|
|
4967
4994
|
var MAX_CHANNEL_VERSION_LEN = 32;
|
|
4968
4995
|
function sanitizeVersion(raw2) {
|
|
4969
4996
|
const v = String(raw2).trim();
|
|
@@ -5087,7 +5114,7 @@ function wait(ms) {
|
|
|
5087
5114
|
}
|
|
5088
5115
|
var PAGE_LIMIT = 500;
|
|
5089
5116
|
var MAX_PAGES = 10;
|
|
5090
|
-
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() });
|
|
5091
5118
|
var SHARED_REGISTRY = /* @__PURE__ */ new WeakMap();
|
|
5092
5119
|
function registryCacheFor(scope) {
|
|
5093
5120
|
if (!scope) return newRegistryCache();
|
|
@@ -5164,13 +5191,14 @@ function createApiClient(cfg) {
|
|
|
5164
5191
|
const json = await requestJson(path, init);
|
|
5165
5192
|
return json?.data ?? json;
|
|
5166
5193
|
}
|
|
5167
|
-
async function requestAllPages(path) {
|
|
5194
|
+
async function requestAllPages(path, params = {}) {
|
|
5168
5195
|
const rows = [];
|
|
5169
5196
|
let firstRow = "";
|
|
5170
5197
|
for (let page = 0; page < MAX_PAGES; page += 1) {
|
|
5171
|
-
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 })}`);
|
|
5172
5199
|
const envelope = json && !Array.isArray(json) ? json : {};
|
|
5173
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" });
|
|
5174
5202
|
const pageRows = Array.isArray(data) ? data : [];
|
|
5175
5203
|
const head = pageRows.length ? JSON.stringify(pageRows[0]) : "";
|
|
5176
5204
|
if (page === 0) firstRow = head;
|
|
@@ -5216,6 +5244,20 @@ function createApiClient(cfg) {
|
|
|
5216
5244
|
}
|
|
5217
5245
|
});
|
|
5218
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
|
+
}
|
|
5219
5261
|
function fetchRouteHealth() {
|
|
5220
5262
|
if (nowFresh(cache.health)) return Promise.resolve(cache.health.value);
|
|
5221
5263
|
return once("health", async () => {
|
|
@@ -5294,7 +5336,8 @@ function createApiClient(cfg) {
|
|
|
5294
5336
|
for (let attempt = 0; attempt <= retries; attempt += 1) {
|
|
5295
5337
|
try {
|
|
5296
5338
|
const quote = await apiRequest("/quote", { method: "POST", headers: { "X-ZD-Shape": "native" }, body: JSON.stringify(request), timeoutMs: 18e3 });
|
|
5297
|
-
|
|
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);
|
|
5298
5341
|
} catch (error) {
|
|
5299
5342
|
lastError = error;
|
|
5300
5343
|
if (attempt >= retries || !isTransientQuoteError(error)) throw error;
|
|
@@ -5350,7 +5393,7 @@ function createApiClient(cfg) {
|
|
|
5350
5393
|
return false;
|
|
5351
5394
|
}
|
|
5352
5395
|
}
|
|
5353
|
-
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 };
|
|
5354
5397
|
}
|
|
5355
5398
|
|
|
5356
5399
|
// src/core/plan.ts
|
|
@@ -5981,10 +6024,11 @@ function createEngine(config = {}) {
|
|
|
5981
6024
|
fetchPrices: (symbols) => api.fetchPrices ? api.fetchPrices(symbols) : Promise.resolve({}),
|
|
5982
6025
|
fetchPromotions: () => api.fetchPromotions ? api.fetchPromotions() : Promise.resolve([]),
|
|
5983
6026
|
fetchCatalogue: async (allowedAssets, product, options) => {
|
|
5984
|
-
const [chains, registryTokens, routes, health, vaults] = await Promise.all([
|
|
6027
|
+
const [chains, registryTokens, routes, zdHeavyRoutes, health, vaults] = await Promise.all([
|
|
5985
6028
|
api.fetchChains().catch(() => []),
|
|
5986
6029
|
api.fetchTokens().catch(() => []),
|
|
5987
6030
|
api.fetchRoutes().catch(() => []),
|
|
6031
|
+
api.fetchZdHeavyRoutes(),
|
|
5988
6032
|
api.fetchRouteHealth(),
|
|
5989
6033
|
api.fetchRwaVaults()
|
|
5990
6034
|
]);
|
|
@@ -5995,6 +6039,7 @@ function createEngine(config = {}) {
|
|
|
5995
6039
|
chains,
|
|
5996
6040
|
tokens,
|
|
5997
6041
|
routes,
|
|
6042
|
+
zdHeavyRoutes,
|
|
5998
6043
|
product,
|
|
5999
6044
|
...allowed ? { allowedAssets: allowed } : {},
|
|
6000
6045
|
// Solana is a SOURCE only for a surface that can pay from it (the exchange card, through the
|
|
@@ -6394,6 +6439,8 @@ function useUserPresence() {
|
|
|
6394
6439
|
}
|
|
6395
6440
|
|
|
6396
6441
|
// src/react/hooks/useFlow.ts
|
|
6442
|
+
var REFRESH_LEAD_SECONDS = 20;
|
|
6443
|
+
var SIGN_MIN_SECONDS = 15;
|
|
6397
6444
|
function reportQuietly(engine, report, stage) {
|
|
6398
6445
|
try {
|
|
6399
6446
|
void engine.reportSubmission?.({ ...report, stage })?.catch?.(() => {
|
|
@@ -6417,6 +6464,7 @@ function useFlow(args) {
|
|
|
6417
6464
|
const [nonce, setNonce] = react.useState(0);
|
|
6418
6465
|
const reqId = react.useRef(0);
|
|
6419
6466
|
const busyRef = react.useRef(false);
|
|
6467
|
+
const keepExpiryError = react.useRef(false);
|
|
6420
6468
|
const [planAt, setPlanAt] = react.useState(0);
|
|
6421
6469
|
const planAtRef = react.useRef(0);
|
|
6422
6470
|
const statusRef = react.useRef("idle");
|
|
@@ -6446,7 +6494,8 @@ function useFlow(args) {
|
|
|
6446
6494
|
}
|
|
6447
6495
|
const id = ++reqId.current;
|
|
6448
6496
|
setStatus("loading");
|
|
6449
|
-
setError(null);
|
|
6497
|
+
if (!keepExpiryError.current) setError(null);
|
|
6498
|
+
keepExpiryError.current = false;
|
|
6450
6499
|
setVerdict(null);
|
|
6451
6500
|
setTxHash(null);
|
|
6452
6501
|
setLastTxEntry(null);
|
|
@@ -6539,6 +6588,10 @@ function useFlow(args) {
|
|
|
6539
6588
|
setVerdict(null);
|
|
6540
6589
|
const patch = (id, s, hash2) => setSteps((prev) => prev.map((st) => st.id === id ? { ...st, state: s, ...hash2 ? { hash: hash2 } : {} } : st));
|
|
6541
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
|
+
}
|
|
6542
6595
|
const current = await getChainId(provider);
|
|
6543
6596
|
if (current !== Number(sourceChainId)) {
|
|
6544
6597
|
await switchChain(provider, Number(sourceChainId));
|
|
@@ -6569,6 +6622,7 @@ function useFlow(args) {
|
|
|
6569
6622
|
patch(tx.id, "done");
|
|
6570
6623
|
continue;
|
|
6571
6624
|
}
|
|
6625
|
+
if (route.zdHeavy && tx.kind === "submitOrder") assertZdHeavyQuoteFresh(route.zdHeavy.order, Math.floor(Date.now() / 1e3));
|
|
6572
6626
|
if (!validatePlannedTransaction(tx, route, recipient2, heavyExpected ? { ...heavyExpected, nowSec: Math.floor(Date.now() / 1e3) } : void 0)) {
|
|
6573
6627
|
throw new Error(`Refusing to sign a ${tx.kind} that does not match the reviewed plan.`);
|
|
6574
6628
|
}
|
|
@@ -6633,13 +6687,17 @@ function useFlow(args) {
|
|
|
6633
6687
|
}
|
|
6634
6688
|
} catch (e) {
|
|
6635
6689
|
setStatus("error");
|
|
6636
|
-
setError(normalizeWalletError(e));
|
|
6690
|
+
setError(e instanceof ZdHeavyQuoteExpiredError ? e.message : normalizeWalletError(e));
|
|
6691
|
+
if (e instanceof ZdHeavyQuoteExpiredError) {
|
|
6692
|
+
keepExpiryError.current = true;
|
|
6693
|
+
reload();
|
|
6694
|
+
}
|
|
6637
6695
|
setSteps((prev) => prev.map((st) => st.state === "active" ? { ...st, state: "error" } : st));
|
|
6638
6696
|
onError?.(e instanceof Error ? e : new Error(String(e)));
|
|
6639
6697
|
} finally {
|
|
6640
6698
|
busyRef.current = false;
|
|
6641
6699
|
}
|
|
6642
|
-
}, [selected, wallet.provider, wallet.account, engine, kind, recipientFor, onSuccess, onError]);
|
|
6700
|
+
}, [selected, wallet.provider, wallet.account, engine, kind, recipientFor, onSuccess, onError, reload]);
|
|
6643
6701
|
const [prices, setPrices] = react.useState(null);
|
|
6644
6702
|
const priceKey = baseSelected?.options?.length ? `${baseSelected.source.asset}|${baseSelected.receive.asset}` : "";
|
|
6645
6703
|
react.useEffect(() => {
|
|
@@ -6735,6 +6793,24 @@ function useFlow(args) {
|
|
|
6735
6793
|
const quoteReady = status === "ready" && !!plan;
|
|
6736
6794
|
const quotePaused = quoteReady && idle2;
|
|
6737
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]);
|
|
6738
6814
|
return {
|
|
6739
6815
|
status,
|
|
6740
6816
|
plan,
|
package/dist/mount.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { M as MountConfig, t as mount } from './mount-
|
|
1
|
+
export { M as MountConfig, t as mount } from './mount-C2GLFqgK.cjs';
|
|
2
2
|
import 'react';
|
|
3
|
-
import './verify-
|
|
3
|
+
import './verify-CeHRSKl2.cjs';
|
package/dist/mount.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { M as MountConfig, t as mount } from './mount-
|
|
1
|
+
export { M as MountConfig, t as mount } from './mount-867H-JSe.js';
|
|
2
2
|
import 'react';
|
|
3
|
-
import './verify-
|
|
3
|
+
import './verify-CeHRSKl2.js';
|
package/dist/mount.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { mount } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
export { mount } from './chunk-3E554IZO.js';
|
|
2
|
+
import './chunk-KOFREX5L.js';
|