@glacislabs/stablegenie-zerodelta 4.18.2 → 4.19.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/README.md +2 -0
- package/dist/{chunk-OIJN6SHV.js → chunk-NLXQVXZ5.js} +1511 -180
- package/dist/{chunk-LMK5C6VA.js → chunk-NS444RZM.js} +118 -81
- package/dist/core/index.cjs +1545 -179
- package/dist/core/index.d.cts +26 -5
- package/dist/core/index.d.ts +26 -5
- package/dist/core/index.js +1 -1
- package/dist/index.cjs +1584 -349
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/{mount-BdxMZC70.d.ts → mount-A24qHOI0.d.ts} +1 -1
- package/dist/{mount-BSXfSSP2.d.cts → mount-BsoZvwCl.d.cts} +1 -1
- package/dist/mount.cjs +1584 -349
- 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 +9 -9
- package/dist/{verify-BBREdvIM.d.cts → verify-BzTQQMc8.d.cts} +466 -2
- package/dist/{verify-BBREdvIM.d.ts → verify-BzTQQMc8.d.ts} +466 -2
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CHAIN_DISPLAY_NAMES, EXECUTABLE_STABLE_ASSETS, STABLE_ASSETS, SUPPORTED_ASSETS, complianceView, complianceTagOf, symbolKey, normalizeDecimalText, findToken, laneLimitFor, laneLimitSymbol, tokenTicker, exceedsLaneLimit, assetDecimals, parseUnitsDecimal, counterpartTokens, assetClassOf, brokenLaneFor, brokenLaneReason, destinationAvailability, laneLimitHint, tickerOn, laneLimitError, routeNativeValue, formatNative, nativeSymbol, isSolanaChainId, isSellableRwa, formatUnits, amountFieldError, solanaQuoteCompliance, directComplianceFromScreens, SUPPORTED_CHAIN_IDS, complianceChecks, DIRECT_CHECK_IDS, isSolanaAddress, createEngine, isAddress, checkNativeFee, nativeFeeShortLabel, nativeFeeShortMessage, allowanceCovers, validatePlannedTransaction, TRACKING, mergeHistory, solanaPlanNeedsPreparation, SOLANA_CHAIN_ID, unattributedComplianceReasons, distinctScreenedWallets, formatJurisdiction, humanizeComplianceReason, DIRECT_SCOPE_NOTE, categoryLabel, SCREENING_BUCKETS, BUNDLED_RPC, foldTicker } from './chunk-
|
|
1
|
+
import { CHAIN_DISPLAY_NAMES, EXECUTABLE_STABLE_ASSETS, STABLE_ASSETS, SUPPORTED_ASSETS, complianceView, complianceTagOf, symbolKey, normalizeDecimalText, findToken, laneLimitFor, laneLimitSymbol, tokenTicker, exceedsLaneLimit, assetDecimals, parseUnitsDecimal, counterpartTokens, assetClassOf, brokenLaneFor, brokenLaneReason, destinationAvailability, laneLimitHint, tickerOn, laneLimitError, routeNativeValue, formatNative, nativeSymbol, isSolanaChainId, isSellableRwa, formatUnits, amountFieldError, solanaQuoteCompliance, directComplianceFromScreens, SUPPORTED_CHAIN_IDS, complianceChecks, DIRECT_CHECK_IDS, isSolanaAddress, createEngine, isAddress, checkNativeFee, nativeFeeShortLabel, nativeFeeShortMessage, zdHeavyExpected, preflightZdHeavyPlan, allowanceCovers, validatePlannedTransaction, priceCompareOptions, parity, pickForWait, cornerTags, extraVsFastest, proposedWait, visibleOptions, promotionFor, estimateBonus, pairPromotionsInto, promotedAssets, TRACKING, mergeHistory, hasValidChecksum, solanaPlanNeedsPreparation, SOLANA_CHAIN_ID, unattributedComplianceReasons, distinctScreenedWallets, formatJurisdiction, humanizeComplianceReason, DIRECT_SCOPE_NOTE, categoryLabel, SCREENING_BUCKETS, BUNDLED_RPC, foldTicker } from './chunk-NLXQVXZ5.js';
|
|
2
2
|
import { createContext, useState, useRef, useMemo, useEffect, useCallback, useId, useLayoutEffect, createElement, useContext, useSyncExternalStore, useReducer } from 'react';
|
|
3
3
|
import { createRoot } from 'react-dom/client';
|
|
4
4
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
@@ -65,7 +65,15 @@ var STEP_LABEL = {
|
|
|
65
65
|
arrived: "Arrived",
|
|
66
66
|
filled: "Filled",
|
|
67
67
|
outbound_bridging: "Bridging",
|
|
68
|
-
delivered: "Delivered"
|
|
68
|
+
delivered: "Delivered",
|
|
69
|
+
// ZD Heavy (core/delivery.ts; mirrors zd-dapp src/lib/zdHeavyTimeline.ts). How the order was filled
|
|
70
|
+
// (netted, partly netted, swapped) is the protocol's business, so the holder reads one "Filled".
|
|
71
|
+
route_completed: "Filled",
|
|
72
|
+
route: "Filled",
|
|
73
|
+
cancellation_requested: "Cancellation requested",
|
|
74
|
+
refunded: "Refunded",
|
|
75
|
+
ready_to_claim: "Ready to claim",
|
|
76
|
+
claimed: "Claimed"
|
|
69
77
|
};
|
|
70
78
|
var label = (name) => STEP_LABEL[name] ?? name.replace(/_/g, " ");
|
|
71
79
|
function deliveryHeadline(delivery, sourceConfirmed, direct = false) {
|
|
@@ -74,12 +82,14 @@ function deliveryHeadline(delivery, sourceConfirmed, direct = false) {
|
|
|
74
82
|
case "delivered":
|
|
75
83
|
return "Delivered";
|
|
76
84
|
case "failed":
|
|
85
|
+
if (delivery.status === "cancelled" && delivery.refunded) return "Cancelled \u2014 refunded to the owner";
|
|
77
86
|
return delivery.status === "cancelled" ? "Cancelled \u2014 not delivered" : `Not delivered (${delivery.status.replace(/_/g, " ")}) \u2014 open the transaction for details`;
|
|
78
87
|
case "attention":
|
|
79
88
|
return delivery.status === "cancel_pending" ? "Being cancelled \u2014 not delivered" : "Waiting to be claimed \u2014 open the transaction";
|
|
80
89
|
case "in-progress": {
|
|
81
90
|
if (delivery.status === "continuing") return "On its way \u2014 final leg next";
|
|
82
91
|
const next = delivery.steps.find((s) => !s.done);
|
|
92
|
+
if (next?.name === "route") return "On its way";
|
|
83
93
|
return next ? `On its way \u2014 ${label(next.name).toLowerCase()} next` : "On its way";
|
|
84
94
|
}
|
|
85
95
|
case "unavailable":
|
|
@@ -491,7 +501,13 @@ function useFlow(args) {
|
|
|
491
501
|
statusRef.current = status;
|
|
492
502
|
const { idle: idle2, returnedAt: returnedAt2 } = useUserPresence();
|
|
493
503
|
const routes = plan?.routes ?? [];
|
|
494
|
-
const
|
|
504
|
+
const baseSelected = useMemo(() => routes.find((r) => r.id === selectedId) ?? routes.find((r) => r.recommended) ?? routes[0] ?? null, [routes, selectedId]);
|
|
505
|
+
const [pickedOptionId, setPickedOptionId] = useState(null);
|
|
506
|
+
const selected = useMemo(() => {
|
|
507
|
+
if (!baseSelected || !pickedOptionId || pickedOptionId === baseSelected.selectedOptionId) return baseSelected;
|
|
508
|
+
const alt = baseSelected.alternatives?.find((r) => r.selectedOptionId === pickedOptionId);
|
|
509
|
+
return alt ? { ...alt, recommended: baseSelected.recommended } : baseSelected;
|
|
510
|
+
}, [baseSelected, pickedOptionId]);
|
|
495
511
|
const reload = useCallback(() => setNonce((n) => n + 1), []);
|
|
496
512
|
const addRoute = useCallback((route) => {
|
|
497
513
|
setPlan((p) => p ? { ...p, routes: [...p.routes.filter((r) => r.id !== route.id), route] } : p);
|
|
@@ -614,6 +630,8 @@ function useFlow(args) {
|
|
|
614
630
|
throw new Error(nativeFeeShortMessage(check2, nativeSymbol(Number(sourceChainId), chains), route.source.chainName));
|
|
615
631
|
}
|
|
616
632
|
}
|
|
633
|
+
const heavyExpected = route.zdHeavy ? zdHeavyExpected(route, account, recipient, ...await Promise.all([engine.fetchTokens(), engine.fetchRoutes()])) : void 0;
|
|
634
|
+
if (heavyExpected) await preflightZdHeavyPlan(route, heavyExpected, engine.verifier.readZdHeavySubmitFee);
|
|
617
635
|
const minNonce = await engine.payerNonceBaseline(Number(sourceChainId), account);
|
|
618
636
|
const txs = route.transactions;
|
|
619
637
|
let settleHash = "";
|
|
@@ -629,7 +647,7 @@ function useFlow(args) {
|
|
|
629
647
|
patch(tx.id, "done");
|
|
630
648
|
continue;
|
|
631
649
|
}
|
|
632
|
-
if (!validatePlannedTransaction(tx, route, recipient)) {
|
|
650
|
+
if (!validatePlannedTransaction(tx, route, recipient, heavyExpected ? { ...heavyExpected, nowSec: Math.floor(Date.now() / 1e3) } : void 0)) {
|
|
633
651
|
throw new Error(`Refusing to sign a ${tx.kind} that does not match the reviewed plan.`);
|
|
634
652
|
}
|
|
635
653
|
patch(tx.id, "active");
|
|
@@ -700,6 +718,98 @@ function useFlow(args) {
|
|
|
700
718
|
busyRef.current = false;
|
|
701
719
|
}
|
|
702
720
|
}, [selected, wallet.provider, wallet.account, engine, kind, recipientFor, onSuccess, onError]);
|
|
721
|
+
const [prices, setPrices] = useState(null);
|
|
722
|
+
const priceKey = baseSelected?.options?.length ? `${baseSelected.source.asset}|${baseSelected.receive.asset}` : "";
|
|
723
|
+
useEffect(() => {
|
|
724
|
+
if (!priceKey || typeof engine.fetchPrices !== "function") return;
|
|
725
|
+
let alive = true;
|
|
726
|
+
const [from, to] = priceKey.split("|");
|
|
727
|
+
(async () => {
|
|
728
|
+
try {
|
|
729
|
+
const p = await engine.fetchPrices([from, to]);
|
|
730
|
+
const next = { key: priceKey, from: p[from.toUpperCase()], to: p[to.toUpperCase()] };
|
|
731
|
+
if (alive) setPrices((prev) => prev && prev.key === next.key && prev.from === next.from && prev.to === next.to ? prev : next);
|
|
732
|
+
} catch {
|
|
733
|
+
}
|
|
734
|
+
})();
|
|
735
|
+
return () => {
|
|
736
|
+
alive = false;
|
|
737
|
+
};
|
|
738
|
+
}, [engine, priceKey]);
|
|
739
|
+
const compare = useMemo(() => {
|
|
740
|
+
const base = baseSelected;
|
|
741
|
+
if (!base?.options?.length) return null;
|
|
742
|
+
const priced = prices?.key === priceKey ? prices : null;
|
|
743
|
+
const inputAmount = Number(base.source.payAmount || base.source.amount);
|
|
744
|
+
const fromUsd = priced?.from && Number.isFinite(inputAmount) ? inputAmount * priced.from : null;
|
|
745
|
+
const options = priceCompareOptions(base.options, fromUsd);
|
|
746
|
+
const selectedOptionId = selected?.selectedOptionId ?? null;
|
|
747
|
+
const parityState = parity(options, fromUsd, priced?.to ?? null);
|
|
748
|
+
return {
|
|
749
|
+
options,
|
|
750
|
+
visibleOptions: visibleOptions(options, proposedWait(options), selectedOptionId),
|
|
751
|
+
selectedId: selectedOptionId,
|
|
752
|
+
proposedWait: proposedWait(options),
|
|
753
|
+
parity: parityState,
|
|
754
|
+
extraVsFastest: extraVsFastest(options, selectedOptionId),
|
|
755
|
+
tags: Object.fromEntries(options.map((o) => [o.id, cornerTags(options, o, parityState)])),
|
|
756
|
+
pickForWait: (waitSec) => pickForWait(options, waitSec)
|
|
757
|
+
};
|
|
758
|
+
}, [baseSelected, selected, prices, priceKey]);
|
|
759
|
+
const selectOption = useCallback(
|
|
760
|
+
(optionId) => {
|
|
761
|
+
if (busyRef.current || !baseSelected) return false;
|
|
762
|
+
const signable = optionId === baseSelected.selectedOptionId || !!baseSelected.alternatives?.some((r) => r.selectedOptionId === optionId);
|
|
763
|
+
if (!signable) return false;
|
|
764
|
+
setPickedOptionId(optionId === baseSelected.selectedOptionId ? null : optionId);
|
|
765
|
+
return true;
|
|
766
|
+
},
|
|
767
|
+
[baseSelected]
|
|
768
|
+
);
|
|
769
|
+
const [promotionList, setPromotionList] = useState([]);
|
|
770
|
+
useEffect(() => {
|
|
771
|
+
if (!enabled) return;
|
|
772
|
+
let alive = true;
|
|
773
|
+
(async () => {
|
|
774
|
+
try {
|
|
775
|
+
if (typeof engine.fetchPromotions !== "function") return;
|
|
776
|
+
const read = await engine.fetchPromotions();
|
|
777
|
+
const list = Array.isArray(read) ? read : [];
|
|
778
|
+
if (alive) setPromotionList((prev) => JSON.stringify(prev) === JSON.stringify(list) ? prev : list);
|
|
779
|
+
} catch {
|
|
780
|
+
}
|
|
781
|
+
})();
|
|
782
|
+
return () => {
|
|
783
|
+
alive = false;
|
|
784
|
+
};
|
|
785
|
+
}, [engine, enabled]);
|
|
786
|
+
const promotions = useMemo(() => {
|
|
787
|
+
const route = selected;
|
|
788
|
+
const toAddress = route?.receive.tokenAddress;
|
|
789
|
+
const forSelection = route && toAddress ? promotionFor(promotionList, {
|
|
790
|
+
fromChainId: Number(route.source.chainId),
|
|
791
|
+
...route.source.tokenAddress ? { fromAddress: route.source.tokenAddress } : {},
|
|
792
|
+
toChainId: Number(route.receive.chainId),
|
|
793
|
+
toAddress
|
|
794
|
+
}) : void 0;
|
|
795
|
+
let bonusEstimateRaw = null;
|
|
796
|
+
if (forSelection && route) {
|
|
797
|
+
const pickedRow = route.options?.find((o) => o.id === route.selectedOptionId);
|
|
798
|
+
try {
|
|
799
|
+
const delivered = pickedRow ? BigInt(pickedRow.amountRaw) : parseUnitsDecimal(route.receive.amount, Number(route.receive.decimals));
|
|
800
|
+
bonusEstimateRaw = estimateBonus(delivered, forSelection).toString();
|
|
801
|
+
} catch {
|
|
802
|
+
bonusEstimateRaw = null;
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
return {
|
|
806
|
+
all: promotionList,
|
|
807
|
+
promotedAssets: promotedAssets(promotionList),
|
|
808
|
+
forSelection,
|
|
809
|
+
pairsInto: route && toAddress ? pairPromotionsInto(promotionList, Number(route.receive.chainId), toAddress) : [],
|
|
810
|
+
bonusEstimateRaw
|
|
811
|
+
};
|
|
812
|
+
}, [promotionList, selected]);
|
|
703
813
|
const quoteReady = status === "ready" && !!plan;
|
|
704
814
|
const quotePaused = quoteReady && idle2;
|
|
705
815
|
const quoteStale = quoteReady && (idle2 || planAt < returnedAt2);
|
|
@@ -721,7 +831,10 @@ function useFlow(args) {
|
|
|
721
831
|
quoteStale,
|
|
722
832
|
submit,
|
|
723
833
|
reload,
|
|
724
|
-
addRoute
|
|
834
|
+
addRoute,
|
|
835
|
+
compare,
|
|
836
|
+
selectOption,
|
|
837
|
+
promotions
|
|
725
838
|
};
|
|
726
839
|
}
|
|
727
840
|
var RETRY_DELAYS_MS = [800, 2400, 6e3];
|
|
@@ -3944,82 +4057,6 @@ function useRecipient(destinationChainId, hostRecipient, opts = {}) {
|
|
|
3944
4057
|
const recipientFor = (account) => required ? recipient || "" : hostRecipient || custom.evm || account;
|
|
3945
4058
|
return { recipientFamily, recipientChainId: destinationChainId, recipient, shown, typed, recipientFor, managed, missing, error, wallet, familyWallet, wallets, open: open && managed, show: () => setOpen(true), close, selectAddress, connect, triggerRef };
|
|
3946
4059
|
}
|
|
3947
|
-
|
|
3948
|
-
// src/core/checksum.ts
|
|
3949
|
-
var RC = [
|
|
3950
|
-
0x0000000000000001n,
|
|
3951
|
-
0x0000000000008082n,
|
|
3952
|
-
0x800000000000808an,
|
|
3953
|
-
0x8000000080008000n,
|
|
3954
|
-
0x000000000000808bn,
|
|
3955
|
-
0x0000000080000001n,
|
|
3956
|
-
0x8000000080008081n,
|
|
3957
|
-
0x8000000000008009n,
|
|
3958
|
-
0x000000000000008an,
|
|
3959
|
-
0x0000000000000088n,
|
|
3960
|
-
0x0000000080008009n,
|
|
3961
|
-
0x000000008000000an,
|
|
3962
|
-
0x000000008000808bn,
|
|
3963
|
-
0x800000000000008bn,
|
|
3964
|
-
0x8000000000008089n,
|
|
3965
|
-
0x8000000000008003n,
|
|
3966
|
-
0x8000000000008002n,
|
|
3967
|
-
0x8000000000000080n,
|
|
3968
|
-
0x000000000000800an,
|
|
3969
|
-
0x800000008000000an,
|
|
3970
|
-
0x8000000080008081n,
|
|
3971
|
-
0x8000000000008080n,
|
|
3972
|
-
0x0000000080000001n,
|
|
3973
|
-
0x8000000080008008n
|
|
3974
|
-
];
|
|
3975
|
-
var ROT = [0, 1, 62, 28, 27, 36, 44, 6, 55, 20, 3, 10, 43, 25, 39, 41, 45, 15, 21, 8, 18, 2, 61, 56, 14];
|
|
3976
|
-
var MASK = (1n << 64n) - 1n;
|
|
3977
|
-
var rotl = (x, n) => n === 0 ? x : (x << BigInt(n) | x >> BigInt(64 - n)) & MASK;
|
|
3978
|
-
function keccakF(s) {
|
|
3979
|
-
for (let round = 0; round < 24; round++) {
|
|
3980
|
-
const c = [0, 1, 2, 3, 4].map((x) => s[x] ^ s[x + 5] ^ s[x + 10] ^ s[x + 15] ^ s[x + 20]);
|
|
3981
|
-
for (let x = 0; x < 5; x++) {
|
|
3982
|
-
const d = c[(x + 4) % 5] ^ rotl(c[(x + 1) % 5], 1);
|
|
3983
|
-
for (let y = 0; y < 25; y += 5) s[y + x] = s[y + x] ^ d;
|
|
3984
|
-
}
|
|
3985
|
-
const b = new Array(25);
|
|
3986
|
-
for (let x = 0; x < 5; x++) for (let y = 0; y < 5; y++) b[y + 5 * ((2 * x + 3 * y) % 5)] = rotl(s[x + 5 * y], ROT[x + 5 * y]);
|
|
3987
|
-
for (let x = 0; x < 5; x++) for (let y = 0; y < 25; y += 5) s[y + x] = b[y + x] ^ ~b[y + (x + 1) % 5] & MASK & b[y + (x + 2) % 5];
|
|
3988
|
-
s[0] = s[0] ^ RC[round];
|
|
3989
|
-
}
|
|
3990
|
-
}
|
|
3991
|
-
function keccak256Hex(bytes) {
|
|
3992
|
-
const rate = 136;
|
|
3993
|
-
const padded = new Uint8Array(Math.ceil((bytes.length + 1) / rate) * rate);
|
|
3994
|
-
padded.set(bytes);
|
|
3995
|
-
padded[bytes.length] = padded[bytes.length] ^ 1;
|
|
3996
|
-
padded[padded.length - 1] = padded[padded.length - 1] ^ 128;
|
|
3997
|
-
const s = new Array(25).fill(0n);
|
|
3998
|
-
for (let off = 0; off < padded.length; off += rate) {
|
|
3999
|
-
for (let i = 0; i < rate / 8; i++) {
|
|
4000
|
-
let lane = 0n;
|
|
4001
|
-
for (let j = 7; j >= 0; j--) lane = lane << 8n | BigInt(padded[off + i * 8 + j]);
|
|
4002
|
-
s[i] = s[i] ^ lane;
|
|
4003
|
-
}
|
|
4004
|
-
keccakF(s);
|
|
4005
|
-
}
|
|
4006
|
-
let out = "";
|
|
4007
|
-
for (let i = 0; i < 4; i++) for (let j = 0; j < 8; j++) out += Number(s[i] >> BigInt(8 * j) & 0xffn).toString(16).padStart(2, "0");
|
|
4008
|
-
return out;
|
|
4009
|
-
}
|
|
4010
|
-
function toChecksumAddress(address) {
|
|
4011
|
-
const lower = address.slice(2).toLowerCase();
|
|
4012
|
-
const hash = keccak256Hex(new TextEncoder().encode(lower));
|
|
4013
|
-
let out = "0x";
|
|
4014
|
-
for (let i = 0; i < 40; i++) out += Number.parseInt(hash[i], 16) >= 8 ? lower[i].toUpperCase() : lower[i];
|
|
4015
|
-
return out;
|
|
4016
|
-
}
|
|
4017
|
-
function hasValidChecksum(address) {
|
|
4018
|
-
if (!/^0x[0-9a-fA-F]{40}$/.test(address)) return false;
|
|
4019
|
-
const body = address.slice(2);
|
|
4020
|
-
if (body === body.toLowerCase() || body === body.toUpperCase()) return true;
|
|
4021
|
-
return toChecksumAddress(address) === address;
|
|
4022
|
-
}
|
|
4023
4060
|
function ArrowLeft() {
|
|
4024
4061
|
return /* @__PURE__ */ jsxs("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: [
|
|
4025
4062
|
/* @__PURE__ */ jsx("path", { d: "M6.38 3.95312L2.33333 7.99979L6.38 12.0465", stroke: "currentColor", strokeWidth: "1.2", strokeMiterlimit: "10", strokeLinecap: "round", strokeLinejoin: "round" }),
|