@glacislabs/stablegenie-zerodelta 4.13.0 → 4.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +223 -223
- package/dist/{chunk-52MY5D3D.js → chunk-6WFIFKZ4.js} +198 -28
- package/dist/{chunk-BYAKXZ5E.js → chunk-M55J3P64.js} +211 -49
- package/dist/core/index.cjs +208 -27
- package/dist/core/index.d.cts +85 -3
- package/dist/core/index.d.ts +85 -3
- package/dist/core/index.js +1 -1
- package/dist/index.cjs +421 -87
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/{mount-bKSKIGmW.d.ts → mount-B6soKC-9.d.ts} +1 -1
- package/dist/{mount-BR3wWmjt.d.cts → mount-CEy4Nqky.d.cts} +1 -1
- package/dist/mount.cjs +421 -87
- 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 +10 -9
- package/dist/{verify-DdSA23GJ.d.cts → verify-Y9jZ83T5.d.cts} +3 -0
- package/dist/{verify-DdSA23GJ.d.ts → verify-Y9jZ83T5.d.ts} +3 -0
- package/package.json +134 -134
package/dist/mount.cjs
CHANGED
|
@@ -573,6 +573,134 @@ var init_ed255192 = __esm({
|
|
|
573
573
|
"src/core/ed25519.ts"() {
|
|
574
574
|
}
|
|
575
575
|
});
|
|
576
|
+
|
|
577
|
+
// src/core/delivery.ts
|
|
578
|
+
var FAILED = /* @__PURE__ */ new Set(["cancelled", "fill_failed", "delivery_failed", "expired", "failed"]);
|
|
579
|
+
var ATTENTION = /* @__PURE__ */ new Set(["cancel_pending", "awaiting_claim"]);
|
|
580
|
+
var TRACKING = Object.freeze({ phase: "tracking", status: "", steps: [] });
|
|
581
|
+
var word = (v) => typeof v === "string" ? v.trim().toLowerCase() : "";
|
|
582
|
+
function normalizeDelivery(raw2) {
|
|
583
|
+
const row = raw2 && typeof raw2 === "object" && !Array.isArray(raw2) ? raw2.data ?? raw2 : null;
|
|
584
|
+
if (!row || typeof row !== "object" || Array.isArray(row)) return TRACKING;
|
|
585
|
+
const r = row;
|
|
586
|
+
const chained = r.isChained === true || Array.isArray(r.legs) && r.legs.length > 1;
|
|
587
|
+
const journey = word(r.journeyStatus);
|
|
588
|
+
const own = word(r.status);
|
|
589
|
+
const status = journey || own;
|
|
590
|
+
const rawSteps = Array.isArray(r.steps) ? r.steps : [];
|
|
591
|
+
const steps = rawSteps.filter((s) => s && typeof s === "object" && typeof s.stepName === "string").sort((a, b) => Number(a.stepNumber ?? 0) - Number(b.stepNumber ?? 0)).slice(0, 8).map((s) => ({ name: String(s.stepName).slice(0, 32), done: s.stepStatus === "completed" }));
|
|
592
|
+
if (!status) return TRACKING;
|
|
593
|
+
if (FAILED.has(status)) return { phase: "failed", status, steps };
|
|
594
|
+
if (ATTENTION.has(status)) return { phase: "attention", status, steps };
|
|
595
|
+
if (status === "delivered" && !(chained && !journey)) return { phase: "delivered", status, steps: steps.map((s) => ({ ...s, done: true })) };
|
|
596
|
+
return { phase: "in-progress", status: status === "delivered" ? "continuing" : status, steps };
|
|
597
|
+
}
|
|
598
|
+
var HASH = /^(?:0x[0-9a-fA-F]{64}|[1-9A-HJ-NP-Za-km-z]{64,88})$/;
|
|
599
|
+
function sameOrder(raw2, hash2) {
|
|
600
|
+
const row = raw2 && typeof raw2 === "object" ? raw2.data ?? raw2 : null;
|
|
601
|
+
const got = row && typeof row === "object" ? row.txHash : void 0;
|
|
602
|
+
if (typeof got !== "string" || !got) return false;
|
|
603
|
+
return hash2.startsWith("0x") ? got.toLowerCase() === hash2.toLowerCase() : got === hash2;
|
|
604
|
+
}
|
|
605
|
+
async function fetchDelivery(api, hash2) {
|
|
606
|
+
if (typeof hash2 !== "string" || !HASH.test(hash2)) return TRACKING;
|
|
607
|
+
try {
|
|
608
|
+
const raw2 = await api.apiRequest(`/transactions/${hash2}`, { timeoutMs: 8e3 });
|
|
609
|
+
return sameOrder(raw2, hash2) ? normalizeDelivery(raw2) : TRACKING;
|
|
610
|
+
} catch {
|
|
611
|
+
return TRACKING;
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
// src/react/hooks/useDelivery.ts
|
|
616
|
+
function deliveryPollDelay(elapsedMs) {
|
|
617
|
+
if (elapsedMs < 6e4) return 5e3;
|
|
618
|
+
if (elapsedMs < 11 * 6e4) return 15e3;
|
|
619
|
+
return 3e4;
|
|
620
|
+
}
|
|
621
|
+
var DELIVERY_GIVE_UP_MS = 2 * 60 * 60 * 1e3;
|
|
622
|
+
var UNANSWERED_LIMIT = 20;
|
|
623
|
+
var UNAVAILABLE = Object.freeze({ phase: "unavailable", status: "", steps: [] });
|
|
624
|
+
var hidden = () => typeof document !== "undefined" && document.visibilityState === "hidden";
|
|
625
|
+
function useDelivery(engine, hash2) {
|
|
626
|
+
const [state, setState] = react.useState({ hash: null, value: TRACKING });
|
|
627
|
+
react.useEffect(() => {
|
|
628
|
+
if (!hash2) return;
|
|
629
|
+
let alive = true;
|
|
630
|
+
let timer2;
|
|
631
|
+
let answered = false;
|
|
632
|
+
let unanswered = 0;
|
|
633
|
+
const started2 = Date.now();
|
|
634
|
+
setState({ hash: hash2, value: TRACKING });
|
|
635
|
+
const schedule = () => {
|
|
636
|
+
if (Date.now() - started2 > DELIVERY_GIVE_UP_MS) return setState({ hash: hash2, value: UNAVAILABLE });
|
|
637
|
+
timer2 = setTimeout(tick, deliveryPollDelay(Date.now() - started2));
|
|
638
|
+
};
|
|
639
|
+
const tick = async () => {
|
|
640
|
+
timer2 = void 0;
|
|
641
|
+
if (hidden()) return schedule();
|
|
642
|
+
const next = await engine.trackDelivery(hash2);
|
|
643
|
+
if (!alive) return;
|
|
644
|
+
if (next.phase === "tracking") {
|
|
645
|
+
if (!answered && ++unanswered >= UNANSWERED_LIMIT) return setState({ hash: hash2, value: UNAVAILABLE });
|
|
646
|
+
return schedule();
|
|
647
|
+
}
|
|
648
|
+
answered = true;
|
|
649
|
+
setState({ hash: hash2, value: next });
|
|
650
|
+
if (next.phase === "delivered" || next.phase === "failed") return;
|
|
651
|
+
schedule();
|
|
652
|
+
};
|
|
653
|
+
const onVisible2 = () => {
|
|
654
|
+
if (!alive || hidden() || !timer2) return;
|
|
655
|
+
clearTimeout(timer2);
|
|
656
|
+
void tick();
|
|
657
|
+
};
|
|
658
|
+
void tick();
|
|
659
|
+
if (typeof document !== "undefined") document.addEventListener("visibilitychange", onVisible2);
|
|
660
|
+
return () => {
|
|
661
|
+
alive = false;
|
|
662
|
+
if (timer2) clearTimeout(timer2);
|
|
663
|
+
if (typeof document !== "undefined") document.removeEventListener("visibilitychange", onVisible2);
|
|
664
|
+
};
|
|
665
|
+
}, [engine, hash2]);
|
|
666
|
+
return state.hash === hash2 ? state.value : TRACKING;
|
|
667
|
+
}
|
|
668
|
+
var STEP_LABEL = {
|
|
669
|
+
submitted: "Submitted",
|
|
670
|
+
arrived: "Arrived",
|
|
671
|
+
filled: "Filled",
|
|
672
|
+
outbound_bridging: "Bridging",
|
|
673
|
+
delivered: "Delivered"
|
|
674
|
+
};
|
|
675
|
+
var label = (name) => STEP_LABEL[name] ?? name.replace(/_/g, " ");
|
|
676
|
+
function deliveryHeadline(delivery, sourceConfirmed, direct = false) {
|
|
677
|
+
if (direct) return sourceConfirmed ? "Delivered" : "Submitted \u2014 awaiting confirmation";
|
|
678
|
+
switch (delivery.phase) {
|
|
679
|
+
case "delivered":
|
|
680
|
+
return "Delivered";
|
|
681
|
+
case "failed":
|
|
682
|
+
return delivery.status === "cancelled" ? "Cancelled \u2014 not delivered" : `Not delivered (${delivery.status.replace(/_/g, " ")}) \u2014 open the transaction for details`;
|
|
683
|
+
case "attention":
|
|
684
|
+
return delivery.status === "cancel_pending" ? "Being cancelled \u2014 not delivered" : "Waiting to be claimed \u2014 open the transaction";
|
|
685
|
+
case "in-progress": {
|
|
686
|
+
if (delivery.status === "continuing") return "On its way \u2014 final leg next";
|
|
687
|
+
const next = delivery.steps.find((s) => !s.done);
|
|
688
|
+
return next ? `On its way \u2014 ${label(next.name).toLowerCase()} next` : "On its way";
|
|
689
|
+
}
|
|
690
|
+
case "unavailable":
|
|
691
|
+
return sourceConfirmed ? "Sent \u2014 open the transaction to follow delivery" : "Submitted \u2014 awaiting confirmation";
|
|
692
|
+
default:
|
|
693
|
+
return sourceConfirmed ? "Sent \u2014 tracking delivery" : "Submitted \u2014 awaiting confirmation";
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
function isDelivered(delivery, sourceConfirmed, direct = false) {
|
|
697
|
+
return direct ? sourceConfirmed : delivery.phase === "delivered";
|
|
698
|
+
}
|
|
699
|
+
function DeliverySteps(props) {
|
|
700
|
+
const { steps, phase } = props.delivery;
|
|
701
|
+
if (!steps.length || phase === "failed") return null;
|
|
702
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-success-steps", "data-testid": "delivery-steps", "data-phase": phase, children: steps.map((s) => `${label(s.name)}${s.done ? " \u2713" : ""}`).join(" \xB7 ") });
|
|
703
|
+
}
|
|
576
704
|
var ConfigContext = react.createContext({});
|
|
577
705
|
function useMergedConfig(local) {
|
|
578
706
|
const ctx = react.useContext(ConfigContext);
|
|
@@ -1045,9 +1173,9 @@ function normalizeAddress(value) {
|
|
|
1045
1173
|
if (!isAddress(value)) return null;
|
|
1046
1174
|
return String(value).toLowerCase();
|
|
1047
1175
|
}
|
|
1048
|
-
function assertAddress(value,
|
|
1176
|
+
function assertAddress(value, label2) {
|
|
1049
1177
|
const normalized = normalizeAddress(value);
|
|
1050
|
-
if (!normalized || normalized === ZERO_ADDRESS) throw new Error(`${
|
|
1178
|
+
if (!normalized || normalized === ZERO_ADDRESS) throw new Error(`${label2} is not a valid EVM address.`);
|
|
1051
1179
|
return normalized;
|
|
1052
1180
|
}
|
|
1053
1181
|
function resolveSwapReceiver(recipient2, payer, destinationChainId) {
|
|
@@ -1065,8 +1193,8 @@ function chainAddressKey(chainId, value) {
|
|
|
1065
1193
|
const text = String(value || "");
|
|
1066
1194
|
return isSolanaChainId(chainId) ? text.trim() : text.toLowerCase();
|
|
1067
1195
|
}
|
|
1068
|
-
function assertChainAddress(chainId, value,
|
|
1069
|
-
if (!isSolanaChainId(chainId)) return assertAddress(value,
|
|
1196
|
+
function assertChainAddress(chainId, value, label2) {
|
|
1197
|
+
if (!isSolanaChainId(chainId)) return assertAddress(value, label2);
|
|
1070
1198
|
if (!String(value || "").trim()) throw new Error("Connect a Solana wallet or enter a Solana recipient address.");
|
|
1071
1199
|
if (!isSolanaAddress(value)) throw new Error("Not a valid Solana address.");
|
|
1072
1200
|
return String(value).trim();
|
|
@@ -1142,9 +1270,9 @@ function encodeSubmitOrder(orders, partnerId = NO_PARTNER_ID) {
|
|
|
1142
1270
|
const tuples = orders.map(encodeOrderTuple);
|
|
1143
1271
|
let offset = 32n * BigInt(tuples.length);
|
|
1144
1272
|
const offsets = tuples.map((tuple) => {
|
|
1145
|
-
const
|
|
1273
|
+
const word2 = uintWord(offset);
|
|
1146
1274
|
offset += BigInt(tuple.length / 2);
|
|
1147
|
-
return
|
|
1275
|
+
return word2;
|
|
1148
1276
|
}).join("");
|
|
1149
1277
|
return `0x${SUBMIT_ORDER_SELECTOR.slice(2)}${uintWord(64)}${bytes32Word(partnerId)}${uintWord(tuples.length)}${offsets}${tuples.join("")}`;
|
|
1150
1278
|
}
|
|
@@ -1155,21 +1283,21 @@ function decodeSubmitOrderCalldata(data) {
|
|
|
1155
1283
|
if (`0x${hex.slice(0, 8)}` !== SUBMIT_ORDER_SELECTOR) return null;
|
|
1156
1284
|
const body = hex.slice(8);
|
|
1157
1285
|
const totalBytes = body.length / 2;
|
|
1158
|
-
const
|
|
1286
|
+
const word2 = (byteOffset) => {
|
|
1159
1287
|
if (!Number.isSafeInteger(byteOffset) || byteOffset < 0 || byteOffset + 32 > totalBytes) return null;
|
|
1160
1288
|
return BigInt(`0x${body.slice(byteOffset * 2, byteOffset * 2 + 64)}`);
|
|
1161
1289
|
};
|
|
1162
1290
|
const addressAt = (byteOffset) => {
|
|
1163
|
-
const w =
|
|
1291
|
+
const w = word2(byteOffset);
|
|
1164
1292
|
if (w === null || w >= 1n << 160n) return null;
|
|
1165
1293
|
return `0x${w.toString(16).padStart(40, "0")}`;
|
|
1166
1294
|
};
|
|
1167
1295
|
const uint64At = (byteOffset) => {
|
|
1168
|
-
const w =
|
|
1296
|
+
const w = word2(byteOffset);
|
|
1169
1297
|
return w === null || w > MAX_UINT64 ? null : w;
|
|
1170
1298
|
};
|
|
1171
1299
|
const keyBytesAt = (byteOffset) => {
|
|
1172
|
-
const len =
|
|
1300
|
+
const len = word2(byteOffset);
|
|
1173
1301
|
if (len !== 20n && len !== 32n) return null;
|
|
1174
1302
|
const length = Number(len);
|
|
1175
1303
|
const padded = Math.ceil(length / 32) * 32;
|
|
@@ -1177,25 +1305,25 @@ function decodeSubmitOrderCalldata(data) {
|
|
|
1177
1305
|
if (content.length !== padded * 2 || content.slice(length * 2) !== "0".repeat((padded - length) * 2)) return null;
|
|
1178
1306
|
return { value: `0x${content.slice(0, length * 2)}`, size: 32 + padded };
|
|
1179
1307
|
};
|
|
1180
|
-
if (
|
|
1181
|
-
if (
|
|
1308
|
+
if (word2(0) !== 64n) return null;
|
|
1309
|
+
if (word2(32) === null) return null;
|
|
1182
1310
|
const partnerId = `0x${body.slice(64, 128)}`;
|
|
1183
|
-
const count =
|
|
1311
|
+
const count = word2(64);
|
|
1184
1312
|
if (count === null || count < 1n || count > BigInt(MAX_DECODED_ORDERS)) return null;
|
|
1185
1313
|
const n = Number(count);
|
|
1186
1314
|
const arrayBase = 96;
|
|
1187
1315
|
let next = arrayBase + 32 * n;
|
|
1188
1316
|
const orders = [];
|
|
1189
1317
|
for (let i = 0; i < n; i += 1) {
|
|
1190
|
-
const rel =
|
|
1318
|
+
const rel = word2(arrayBase + i * 32);
|
|
1191
1319
|
if (rel === null || rel !== BigInt(next - arrayBase)) return null;
|
|
1192
1320
|
const base = next;
|
|
1193
1321
|
const owner = addressAt(base);
|
|
1194
1322
|
const bidToken = addressAt(base + 32);
|
|
1195
|
-
const bidTokenAmount =
|
|
1196
|
-
const askOffset =
|
|
1197
|
-
const askTokenAmount =
|
|
1198
|
-
const receiverOffset =
|
|
1323
|
+
const bidTokenAmount = word2(base + 64);
|
|
1324
|
+
const askOffset = word2(base + 96);
|
|
1325
|
+
const askTokenAmount = word2(base + 128);
|
|
1326
|
+
const receiverOffset = word2(base + 160);
|
|
1199
1327
|
const destinationChainId = uint64At(base + 192);
|
|
1200
1328
|
const executionChainId = uint64At(base + 224);
|
|
1201
1329
|
const deadline = uint64At(base + 256);
|
|
@@ -1818,8 +1946,8 @@ function freeze(value) {
|
|
|
1818
1946
|
}
|
|
1819
1947
|
return value;
|
|
1820
1948
|
}
|
|
1821
|
-
function raw(value,
|
|
1822
|
-
if (typeof value !== "string" || !/^\d+$/.test(value) || positive && BigInt(value) <= 0n || BigInt(value) >= 1n << 256n) throw new Error(`Invalid ${
|
|
1949
|
+
function raw(value, label2, positive = false) {
|
|
1950
|
+
if (typeof value !== "string" || !/^\d+$/.test(value) || positive && BigInt(value) <= 0n || BigInt(value) >= 1n << 256n) throw new Error(`Invalid ${label2}.`);
|
|
1823
1951
|
return value;
|
|
1824
1952
|
}
|
|
1825
1953
|
function chain(value) {
|
|
@@ -1932,6 +2060,12 @@ async function previewSolanaSource(api, input) {
|
|
|
1932
2060
|
nativeFeeRaw: "0"
|
|
1933
2061
|
};
|
|
1934
2062
|
}
|
|
2063
|
+
function solanaQuoteCompliance(quote) {
|
|
2064
|
+
for (const value of [quote?.complianceDecision, quote?.compliance]) {
|
|
2065
|
+
if (value && typeof value === "object" && !Array.isArray(value)) return value;
|
|
2066
|
+
}
|
|
2067
|
+
return void 0;
|
|
2068
|
+
}
|
|
1935
2069
|
function denied(value) {
|
|
1936
2070
|
return typeof value === "string" ? value.toUpperCase() === "DENY" : !!value && typeof value === "object" && denied(value.decision);
|
|
1937
2071
|
}
|
|
@@ -2049,6 +2183,7 @@ function createSolanaRpc(api) {
|
|
|
2049
2183
|
body: JSON.stringify({ jsonrpc: "2.0", id: 1, method, params }),
|
|
2050
2184
|
timeoutMs: 15e3
|
|
2051
2185
|
});
|
|
2186
|
+
if (body.error && solanaLamportShortfall(body.error.data?.logs) !== null) throw new Error(SOL_SHORTFALL_MESSAGE);
|
|
2052
2187
|
if (body.error || body.result === void 0) throw new Error(body.error?.message || "Invalid Solana RPC response.");
|
|
2053
2188
|
return body.result;
|
|
2054
2189
|
};
|
|
@@ -2213,18 +2348,141 @@ async function readSolanaBalance(rpc, owner, mint) {
|
|
|
2213
2348
|
return void 0;
|
|
2214
2349
|
}
|
|
2215
2350
|
}
|
|
2351
|
+
function solanaLamportShortfall(logs) {
|
|
2352
|
+
if (!Array.isArray(logs)) return null;
|
|
2353
|
+
for (const line of logs) {
|
|
2354
|
+
const m = /insufficient lamports (\d+), need (\d+)/.exec(String(line));
|
|
2355
|
+
if (m) {
|
|
2356
|
+
const need = Number(m[2]);
|
|
2357
|
+
return Number.isSafeInteger(need) && need > 0 ? need : null;
|
|
2358
|
+
}
|
|
2359
|
+
}
|
|
2360
|
+
return null;
|
|
2361
|
+
}
|
|
2362
|
+
var SOL_SHORTFALL_MESSAGE = "Not enough SOL in this wallet for the Solana network fee and account rent. Add a little SOL and try again.";
|
|
2216
2363
|
async function simulateSolanaCost(rpc, plan) {
|
|
2217
2364
|
checkSolanaPlan(plan.txData);
|
|
2218
2365
|
const signer = plan.expected.signer;
|
|
2219
2366
|
const before = await rpc("getAccountInfo", [signer, { encoding: "base64", commitment: "confirmed" }]);
|
|
2220
2367
|
const sim = await rpc("simulateTransaction", [plan.txData[0].transaction, { encoding: "base64", sigVerify: false, replaceRecentBlockhash: true, accounts: { addresses: [signer], encoding: "base64" } }]);
|
|
2221
|
-
if (sim.value?.err) throw new Error(`Simulation failed: ${JSON.stringify(sim.value.err)}`);
|
|
2222
2368
|
const balanceLamports = before.value?.lamports ?? 0, post = sim.value?.accounts?.[0]?.lamports;
|
|
2369
|
+
if (sim.value?.err) {
|
|
2370
|
+
const need = solanaLamportShortfall(sim.value.logs);
|
|
2371
|
+
if (need !== null && Number.isSafeInteger(balanceLamports)) return { lamports: need, balanceLamports, sufficient: false };
|
|
2372
|
+
throw new Error(`Simulation failed: ${JSON.stringify(sim.value.err)}`);
|
|
2373
|
+
}
|
|
2223
2374
|
if (!Number.isSafeInteger(balanceLamports) || balanceLamports < 0 || post !== void 0 && (!Number.isSafeInteger(post) || post < 0)) throw new Error("Invalid simulation lamports.");
|
|
2224
2375
|
const lamports = typeof post === "number" ? Math.max(0, balanceLamports - post) : 0;
|
|
2225
2376
|
return { lamports, balanceLamports, sufficient: balanceLamports >= lamports };
|
|
2226
2377
|
}
|
|
2227
2378
|
|
|
2379
|
+
// src/core/history.ts
|
|
2380
|
+
var WALLET_HISTORY_LIMIT = 50;
|
|
2381
|
+
var HASH2 = /^(?:0x[0-9a-fA-F]{64}|[1-9A-HJ-NP-Za-km-z]{64,88})$/;
|
|
2382
|
+
var WALLET = /^(?:0x[0-9a-fA-F]{40}|[1-9A-HJ-NP-Za-km-z]{32,44})$/;
|
|
2383
|
+
function historyKey(value) {
|
|
2384
|
+
return value.startsWith("0x") ? value.toLowerCase() : value;
|
|
2385
|
+
}
|
|
2386
|
+
var str = (v) => typeof v === "string" ? v : typeof v === "number" ? String(v) : "";
|
|
2387
|
+
function tokenAt(tokens, chainId, address) {
|
|
2388
|
+
if (!address) return void 0;
|
|
2389
|
+
const key = historyKey(address);
|
|
2390
|
+
return tokens.find((t) => Number(t.chainId) === chainId && historyKey(String(t.address)) === key);
|
|
2391
|
+
}
|
|
2392
|
+
function amountOf(raw2, token, rowDecimals, rowAmount) {
|
|
2393
|
+
const decimals = token ? Number(token.decimals) : Number(rowDecimals);
|
|
2394
|
+
if (/^\d{1,78}$/.test(raw2) && Number.isInteger(decimals) && decimals > 0 && decimals <= 36) return formatUnits(raw2, decimals);
|
|
2395
|
+
return Number(rowDecimals) > 0 && /^\d+(?:\.\d+)?$/.test(rowAmount) ? rowAmount.slice(0, 40) : "";
|
|
2396
|
+
}
|
|
2397
|
+
function historyEntryFromOrder(raw2, tokens) {
|
|
2398
|
+
if (!raw2 || typeof raw2 !== "object" || Array.isArray(raw2)) return null;
|
|
2399
|
+
const r = raw2;
|
|
2400
|
+
const hash2 = str(r.txHash);
|
|
2401
|
+
if (!HASH2.test(hash2)) return null;
|
|
2402
|
+
const fromChainId = Number(r.sourceChainId) || 0;
|
|
2403
|
+
const toChainId = Number(r.finalDestChainId ?? r.destChainId) || 0;
|
|
2404
|
+
const from = tokenAt(tokens, fromChainId, str(r.fromTokenAddress));
|
|
2405
|
+
const toAddress = str(r.finalToTokenAddress) || str(r.toTokenAddress);
|
|
2406
|
+
const to = tokenAt(tokens, toChainId, toAddress);
|
|
2407
|
+
const fromAsset = (from?.symbol ?? str(r.fromTokenSymbol)).slice(0, 10);
|
|
2408
|
+
const toAsset = (to?.symbol ?? (str(r.finalToTokenSymbol) || str(r.toTokenSymbol))).slice(0, 10);
|
|
2409
|
+
const payAmount = amountOf(str(r.fromTokenRawAmount), from, r.fromTokenDecimals, str(r.fromTokenAmount));
|
|
2410
|
+
const receiveAmount = str(r.finalToTokenRawAmount) ? amountOf(str(r.finalToTokenRawAmount), to, r.finalToTokenDecimals, str(r.finalToTokenAmount)) : amountOf(str(r.toTokenRawAmount), to, r.toTokenDecimals, str(r.toTokenAmount));
|
|
2411
|
+
const delivery = normalizeDelivery(r).phase;
|
|
2412
|
+
const wallet = str(r.wallet);
|
|
2413
|
+
const receiver = str(r.destinationReceiver);
|
|
2414
|
+
const at = str(r.createdAt) || str(r.submittedAt);
|
|
2415
|
+
return {
|
|
2416
|
+
kind: "swap",
|
|
2417
|
+
hash: hash2,
|
|
2418
|
+
txKind: "submitOrder",
|
|
2419
|
+
chainId: fromChainId || null,
|
|
2420
|
+
chainName: "",
|
|
2421
|
+
fromAsset,
|
|
2422
|
+
toAsset,
|
|
2423
|
+
fromTicker: from ? tokenTicker(from).slice(0, 12) : void 0,
|
|
2424
|
+
toTicker: to ? tokenTicker(to).slice(0, 12) : void 0,
|
|
2425
|
+
payAmount,
|
|
2426
|
+
receiveAmount,
|
|
2427
|
+
account: WALLET.test(wallet) ? historyKey(wallet) : "",
|
|
2428
|
+
recipient: WALLET.test(receiver) ? receiver : "",
|
|
2429
|
+
settlement: "escrow",
|
|
2430
|
+
status: "submitted",
|
|
2431
|
+
at: Number.isNaN(Date.parse(at)) ? (/* @__PURE__ */ new Date(0)).toISOString() : new Date(at).toISOString(),
|
|
2432
|
+
delivery: delivery === "tracking" || delivery === "unavailable" ? void 0 : delivery,
|
|
2433
|
+
legs: [
|
|
2434
|
+
{
|
|
2435
|
+
index: 1,
|
|
2436
|
+
fromAsset,
|
|
2437
|
+
fromTicker: from ? tokenTicker(from).slice(0, 12) : void 0,
|
|
2438
|
+
fromChainId,
|
|
2439
|
+
fromChainName: "",
|
|
2440
|
+
fromAmount: payAmount,
|
|
2441
|
+
toAsset,
|
|
2442
|
+
toTicker: to ? tokenTicker(to).slice(0, 12) : void 0,
|
|
2443
|
+
toChainId,
|
|
2444
|
+
toChainName: "",
|
|
2445
|
+
toAmount: receiveAmount,
|
|
2446
|
+
executionChainId: Number(r.executionChainId) || 0,
|
|
2447
|
+
executionChainName: ""
|
|
2448
|
+
}
|
|
2449
|
+
]
|
|
2450
|
+
};
|
|
2451
|
+
}
|
|
2452
|
+
async function fetchWalletHistory(api, wallets) {
|
|
2453
|
+
const asked = [...new Set(wallets.filter((w) => WALLET.test(w)).map(historyKey))];
|
|
2454
|
+
if (!asked.length) return [];
|
|
2455
|
+
const tokens = await api.fetchTokens().catch(() => []);
|
|
2456
|
+
const reads = await Promise.all(
|
|
2457
|
+
asked.map(async (wallet) => {
|
|
2458
|
+
try {
|
|
2459
|
+
const rows = await api.apiRequest(`/transactions?wallet=${encodeURIComponent(wallet)}&limit=${WALLET_HISTORY_LIMIT}`, { timeoutMs: 1e4 });
|
|
2460
|
+
if (!Array.isArray(rows)) return null;
|
|
2461
|
+
return rows.filter((row) => historyKey(str(row?.wallet)) === wallet).map((row) => historyEntryFromOrder(row, tokens));
|
|
2462
|
+
} catch {
|
|
2463
|
+
return null;
|
|
2464
|
+
}
|
|
2465
|
+
})
|
|
2466
|
+
);
|
|
2467
|
+
if (reads.every((read) => read === null)) return null;
|
|
2468
|
+
return reads.flatMap((read) => read ?? []).filter((e) => e !== null);
|
|
2469
|
+
}
|
|
2470
|
+
function mergeHistory(local, remote, limit = WALLET_HISTORY_LIMIT) {
|
|
2471
|
+
const byHash = /* @__PURE__ */ new Map();
|
|
2472
|
+
for (const entry of remote ?? []) if (!byHash.has(historyKey(entry.hash))) byHash.set(historyKey(entry.hash), entry);
|
|
2473
|
+
const out = [];
|
|
2474
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2475
|
+
for (const entry of local) {
|
|
2476
|
+
const key = historyKey(entry.hash);
|
|
2477
|
+
if (seen.has(key)) continue;
|
|
2478
|
+
seen.add(key);
|
|
2479
|
+
const known = byHash.get(key);
|
|
2480
|
+
out.push(known ? { ...entry, delivery: known.delivery, legs: entry.legs ?? known.legs } : entry);
|
|
2481
|
+
}
|
|
2482
|
+
for (const [key, entry] of byHash) if (!seen.has(key)) out.push(entry);
|
|
2483
|
+
return out.sort((a, b) => Date.parse(b.at) - Date.parse(a.at)).slice(0, limit);
|
|
2484
|
+
}
|
|
2485
|
+
|
|
2228
2486
|
// src/core/escrow.ts
|
|
2229
2487
|
function checkEscrow(chainId, quoteEscrow, chainsEscrow) {
|
|
2230
2488
|
const fromQuote = normalizeAddress(quoteEscrow);
|
|
@@ -2479,11 +2737,11 @@ function complianceView(compliance, hasQuote = true) {
|
|
|
2479
2737
|
};
|
|
2480
2738
|
}
|
|
2481
2739
|
if (decision === "REVIEW" || decision === "REMEDIATE") {
|
|
2482
|
-
const
|
|
2740
|
+
const word2 = decision.toLowerCase();
|
|
2483
2741
|
return {
|
|
2484
2742
|
tone: "warn",
|
|
2485
|
-
label: `Compliance: ${
|
|
2486
|
-
headline: `Manual ${
|
|
2743
|
+
label: `Compliance: ${word2} required`,
|
|
2744
|
+
headline: `Manual ${word2} required`,
|
|
2487
2745
|
blocked: false,
|
|
2488
2746
|
needsAction: true,
|
|
2489
2747
|
screened
|
|
@@ -2717,8 +2975,8 @@ var BLOCK_CATEGORY_LABELS = {
|
|
|
2717
2975
|
var BLOCK_LABEL_DEFAULT = "flagged by compliance screening";
|
|
2718
2976
|
function blockLabelFor(categories) {
|
|
2719
2977
|
for (const raw2 of categories) {
|
|
2720
|
-
const
|
|
2721
|
-
if (
|
|
2978
|
+
const label2 = BLOCK_CATEGORY_LABELS[String(raw2 || "").trim().toUpperCase()];
|
|
2979
|
+
if (label2) return label2;
|
|
2722
2980
|
}
|
|
2723
2981
|
return BLOCK_LABEL_DEFAULT;
|
|
2724
2982
|
}
|
|
@@ -2918,8 +3176,8 @@ function normalizeOrderRequest(order, payer, destination, fallbackExecutionChain
|
|
|
2918
3176
|
const executionChainId = String(order.executionChainId || fallbackExecutionChainId || "0");
|
|
2919
3177
|
if (!/^\d+$/.test(executionChainId) || BigInt(executionChainId) <= 0n) throw new Error("ZeroDelta quote did not include an execution chain.");
|
|
2920
3178
|
const solana = isSolanaChainId(order.destinationChainId || destination.chainId);
|
|
2921
|
-
const keyBytes2 = (value,
|
|
2922
|
-
if (!/^0x[0-9a-fA-F]{64}$/.test(String(value || ""))) throw new Error(`${
|
|
3179
|
+
const keyBytes2 = (value, label2) => {
|
|
3180
|
+
if (!/^0x[0-9a-fA-F]{64}$/.test(String(value || ""))) throw new Error(`${label2} is not a valid 32-byte Solana key.`);
|
|
2923
3181
|
return String(value).toLowerCase();
|
|
2924
3182
|
};
|
|
2925
3183
|
return {
|
|
@@ -3038,7 +3296,7 @@ function routeLabelFor(option, destinationToken, result) {
|
|
|
3038
3296
|
const bridge = result.quote.bridge ? ` via ${result.quote.bridge}` : "";
|
|
3039
3297
|
return `Swap ${optionTicker(option)} to ${tokenTicker(destinationToken)} and settle on ZeroDelta${bridge}.`;
|
|
3040
3298
|
}
|
|
3041
|
-
function
|
|
3299
|
+
function tokenAt2(tokens, chainId, address) {
|
|
3042
3300
|
const key = isSolanaChainId(chainId) ? hexToSolanaKey(address) || address : address;
|
|
3043
3301
|
const wanted = isChainAddress(chainId, key) ? chainAddressKey(chainId, key) : null;
|
|
3044
3302
|
if (!wanted || !tokens?.length) return void 0;
|
|
@@ -3062,7 +3320,7 @@ function buildLegs(orders, ctx) {
|
|
|
3062
3320
|
const order = orders[index];
|
|
3063
3321
|
const isLast = index === orders.length - 1;
|
|
3064
3322
|
const toChainId = Number(order.destinationChainId);
|
|
3065
|
-
const askToken = isLast ? ctx.destinationToken :
|
|
3323
|
+
const askToken = isLast ? ctx.destinationToken : tokenAt2(ctx.tokens, toChainId, order.askToken);
|
|
3066
3324
|
const toAsset = isLast ? ctx.destinationToken.symbol : askToken?.symbol ?? "";
|
|
3067
3325
|
const toTicker = askToken ? tokenTicker(askToken) : "";
|
|
3068
3326
|
const toDecimals = askToken ? assetDecimals(askToken) : void 0;
|
|
@@ -3280,7 +3538,7 @@ var CHANNEL_HEADER = "x-zd-channel";
|
|
|
3280
3538
|
var CHANNEL_VERSION_HEADER = "x-zd-channel-version";
|
|
3281
3539
|
var CHANNEL_ORIGIN_HEADER = "x-zd-channel-origin";
|
|
3282
3540
|
var WIDGET_CHANNEL = "widget";
|
|
3283
|
-
var WIDGET_VERSION = "4.13.
|
|
3541
|
+
var WIDGET_VERSION = "4.13.1" ;
|
|
3284
3542
|
var MAX_CHANNEL_VERSION_LEN = 32;
|
|
3285
3543
|
function sanitizeVersion(raw2) {
|
|
3286
3544
|
const v = String(raw2).trim();
|
|
@@ -3361,12 +3619,12 @@ function classifyQuoteError(error) {
|
|
|
3361
3619
|
const isBlock = isStructuredComplianceBlock(error) || !!catMatch || error.code === "blocked" || error.code === "compliance_block" || /\b(stolen|sanction(?:s|ed|ing)?|block(?:ed|list)|screen(?:ed|ing)?|compliance|ofac|denylist|blacklist)\b/i.test(haystack);
|
|
3362
3620
|
if (!isBlock) return null;
|
|
3363
3621
|
const category = (catMatch?.[1] || "").toUpperCase() || "COMPLIANCE";
|
|
3364
|
-
const
|
|
3622
|
+
const label2 = blockLabelFor([category]);
|
|
3365
3623
|
return {
|
|
3366
3624
|
blocked: true,
|
|
3367
3625
|
category,
|
|
3368
3626
|
reason: reasons.join(", ") || error.message || "",
|
|
3369
|
-
message: `This payment was blocked by compliance screening \u2014 the recipient is ${
|
|
3627
|
+
message: `This payment was blocked by compliance screening \u2014 the recipient is ${label2}. Choose a different recipient or connect a different wallet.`
|
|
3370
3628
|
};
|
|
3371
3629
|
}
|
|
3372
3630
|
function amountFieldError(error) {
|
|
@@ -3939,16 +4197,16 @@ function isHexQuantity(value) {
|
|
|
3939
4197
|
return /^0x[0-9a-fA-F]+$/.test(String(value));
|
|
3940
4198
|
}
|
|
3941
4199
|
function dataWord(data, index) {
|
|
3942
|
-
const
|
|
3943
|
-
return /^[a-fA-F0-9]{64}$/.test(
|
|
4200
|
+
const word2 = String(data || "").slice(10 + index * 64, 10 + (index + 1) * 64);
|
|
4201
|
+
return /^[a-fA-F0-9]{64}$/.test(word2) ? word2 : "";
|
|
3944
4202
|
}
|
|
3945
4203
|
function dataAddress(data, index) {
|
|
3946
|
-
const
|
|
3947
|
-
return
|
|
4204
|
+
const word2 = dataWord(data, index);
|
|
4205
|
+
return word2 ? `0x${word2.slice(24)}` : "";
|
|
3948
4206
|
}
|
|
3949
4207
|
function dataUint(data, index) {
|
|
3950
|
-
const
|
|
3951
|
-
return
|
|
4208
|
+
const word2 = dataWord(data, index);
|
|
4209
|
+
return word2 ? BigInt(`0x${word2}`) : null;
|
|
3952
4210
|
}
|
|
3953
4211
|
function rawEquals(value, expected) {
|
|
3954
4212
|
try {
|
|
@@ -4366,6 +4624,8 @@ function createEngine(config = {}) {
|
|
|
4366
4624
|
executeSolanaPlan: (input) => executeSolanaPlan({ ...input, rpc: input.rpc ?? solanaRpc }),
|
|
4367
4625
|
executeSolanaPlanStaged: (input) => executeSolanaPlanStaged({ ...input, rpc: input.rpc ?? solanaRpc }),
|
|
4368
4626
|
previewSolanaSource: (input) => previewSolanaSource(api, input),
|
|
4627
|
+
trackDelivery: (hash2) => fetchDelivery(api, hash2),
|
|
4628
|
+
fetchWalletHistory: (wallets) => fetchWalletHistory(api, wallets),
|
|
4369
4629
|
readSolanaBalance: (owner, mint) => readSolanaBalance(solanaRpc, owner, mint),
|
|
4370
4630
|
simulateSolanaCost: (plan) => simulateSolanaCost(solanaRpc, plan),
|
|
4371
4631
|
payerNonceBaseline: verifier.payerNonceBaseline,
|
|
@@ -5239,6 +5499,7 @@ var WIDGET_CSS = `
|
|
|
5239
5499
|
.sg-success-check{width:40px;height:40px;border-radius:999px;background:var(--sg-accent);color:var(--sg-accent-text);display:inline-flex;align-items:center;justify-content:center;margin-bottom:8px}
|
|
5240
5500
|
/* Broadcast but not receipt-confirmed: mute the disc so a pending settlement never wears the
|
|
5241
5501
|
accent-coloured "paid" affordance. Mirrors .sg-settle-disc[data-pending] in the island. */
|
|
5502
|
+
.sg-success-steps{font-size:12px;color:var(--sg-text-muted);margin-top:6px;text-align:center}
|
|
5242
5503
|
.sg-success-check[data-pending="true"]{background:var(--sg-surface);color:var(--sg-text-muted);border:1px solid var(--sg-border)}
|
|
5243
5504
|
.sg-success-amt{font-size:20px;font-weight:700;font-variant-numeric:tabular-nums}
|
|
5244
5505
|
.sg-success-sub{font-size:12px;color:var(--sg-text-muted);margin-top:2px}
|
|
@@ -6129,7 +6390,7 @@ function StepList(props) {
|
|
|
6129
6390
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: s.state === "done" ? "sg-muted" : "", children: s.label }),
|
|
6130
6391
|
rich ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-sr-only", children: ` \u2014 ${STEP_STATE_WORD[s.state]}` }) : null
|
|
6131
6392
|
] }, s.id)) }),
|
|
6132
|
-
rich && props.verdict && verifyDone ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-step-verdict", children: props.verdict.status === "confirmed" ? "Confirmed on-chain \u2014
|
|
6393
|
+
rich && props.verdict && verifyDone ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-step-verdict", children: props.verdict.status === "confirmed" ? "Confirmed on-chain \u2014 on its way to the merchant." : props.verdict.status === "mismatch" ? "The submitted transaction did not match the reviewed plan." : "Payment sent \u2014 confirmation is still pending." }) : null
|
|
6133
6394
|
] });
|
|
6134
6395
|
}
|
|
6135
6396
|
var SHOW_ROADMAP_METHODS = true;
|
|
@@ -6469,8 +6730,8 @@ var CHAIN_ALIASES = {
|
|
|
6469
6730
|
137: ["matic"],
|
|
6470
6731
|
43114: ["avax"]
|
|
6471
6732
|
};
|
|
6472
|
-
function labelForms(
|
|
6473
|
-
const lower2 =
|
|
6733
|
+
function labelForms(label2) {
|
|
6734
|
+
const lower2 = label2.trim().toLowerCase();
|
|
6474
6735
|
if (!lower2) return [];
|
|
6475
6736
|
const compact = lower2.replace(/[^a-z0-9]/g, "");
|
|
6476
6737
|
return compact && compact !== lower2 ? [lower2, compact] : [lower2];
|
|
@@ -6481,8 +6742,8 @@ function buildChainSearchTerms(chains) {
|
|
|
6481
6742
|
for (const id of ids) {
|
|
6482
6743
|
const chain2 = chains.find((c) => Number(c.chainId) === id);
|
|
6483
6744
|
const terms = /* @__PURE__ */ new Set();
|
|
6484
|
-
for (const
|
|
6485
|
-
if (
|
|
6745
|
+
for (const label2 of [chain2?.displayName, chain2?.name, typeof chain2?.slug === "string" ? chain2.slug : void 0, CHAIN_LABELS[id]]) {
|
|
6746
|
+
if (label2) for (const form of labelForms(label2)) terms.add(form);
|
|
6486
6747
|
}
|
|
6487
6748
|
for (const alias of CHAIN_ALIASES[id] ?? []) terms.add(alias);
|
|
6488
6749
|
byId.set(id, [...terms]);
|
|
@@ -6854,7 +7115,7 @@ function TokenSelect(props) {
|
|
|
6854
7115
|
const members = g.deployments;
|
|
6855
7116
|
const multi = members.length > 1;
|
|
6856
7117
|
const single = members[0];
|
|
6857
|
-
const
|
|
7118
|
+
const label2 = multi ? g.symbol : tokenTicker(single.token);
|
|
6858
7119
|
const blocked = !!g.unavailable;
|
|
6859
7120
|
const opensNetworks = multi || blocked;
|
|
6860
7121
|
const zero = showBalances && g.amount === 0 || blocked;
|
|
@@ -6878,7 +7139,7 @@ function TokenSelect(props) {
|
|
|
6878
7139
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-left", children: [
|
|
6879
7140
|
/* @__PURE__ */ jsxRuntime.jsx(TokenPlate, { symbol: g.symbol, logoUrl: g.logoUrl }),
|
|
6880
7141
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-text", children: [
|
|
6881
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-label", children:
|
|
7142
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-label", children: label2 }),
|
|
6882
7143
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-line", children: [
|
|
6883
7144
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-sub", children: multi ? showBalances ? "Total across" : "Available on" : `On ${chainName3(Number(single.token.chainId))}` }),
|
|
6884
7145
|
/* @__PURE__ */ jsxRuntime.jsx(ChainMarks, { chainIds: members.map((m) => Number(m.token.chainId)), chainById: chainById2, decorative: !multi }),
|
|
@@ -6887,7 +7148,7 @@ function TokenSelect(props) {
|
|
|
6887
7148
|
!multi && single.hint ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-note", "data-testid": "lane-limit", children: single.hint }) : null
|
|
6888
7149
|
] })
|
|
6889
7150
|
] }),
|
|
6890
|
-
showBalances ? /* @__PURE__ */ jsxRuntime.jsx(BalanceColumn, { amount: g.amount, usd: g.usd, symbol:
|
|
7151
|
+
showBalances ? /* @__PURE__ */ jsxRuntime.jsx(BalanceColumn, { amount: g.amount, usd: g.usd, symbol: label2 }) : opensNetworks ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-chev", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx(ChevronGlyph, {}) }) : null
|
|
6891
7152
|
]
|
|
6892
7153
|
},
|
|
6893
7154
|
g.key
|
|
@@ -7173,12 +7434,12 @@ function TriggerGlyph({ cv }) {
|
|
|
7173
7434
|
return /* @__PURE__ */ jsxRuntime.jsx(ShieldTick, {});
|
|
7174
7435
|
}
|
|
7175
7436
|
function CheckRow({ check: check2, onViewPolicy }) {
|
|
7176
|
-
const
|
|
7437
|
+
const label2 = check2.id === "risk" ? check2.ok ? "Risk screening passed" : "Risk screening failed" : check2.label;
|
|
7177
7438
|
return /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "sg-cp-check", "data-ok": check2.ok, children: [
|
|
7178
7439
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cp-check-head", children: [
|
|
7179
7440
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cp-check-label", children: [
|
|
7180
7441
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cp-check-mark", "data-ok": check2.ok, children: check2.ok ? /* @__PURE__ */ jsxRuntime.jsx(Tick, {}) : /* @__PURE__ */ jsxRuntime.jsx(Cross, {}) }),
|
|
7181
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { children:
|
|
7442
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: label2 }),
|
|
7182
7443
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-sr-only", children: check2.ok ? " \u2014 passed" : " \u2014 failed" })
|
|
7183
7444
|
] }),
|
|
7184
7445
|
check2.id === "risk" ? /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "sg-cp-link", onClick: onViewPolicy, children: [
|
|
@@ -7246,9 +7507,9 @@ function QuoteChecks({
|
|
|
7246
7507
|
] }) : null
|
|
7247
7508
|
] });
|
|
7248
7509
|
}
|
|
7249
|
-
function Fact({ label, value, title, mono = false }) {
|
|
7510
|
+
function Fact({ label: label2, value, title, mono = false }) {
|
|
7250
7511
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cp-fact", children: [
|
|
7251
|
-
/* @__PURE__ */ jsxRuntime.jsx("dt", { children:
|
|
7512
|
+
/* @__PURE__ */ jsxRuntime.jsx("dt", { children: label2 }),
|
|
7252
7513
|
/* @__PURE__ */ jsxRuntime.jsx("dd", { title, className: mono ? "sg-mono" : void 0, children: value })
|
|
7253
7514
|
] });
|
|
7254
7515
|
}
|
|
@@ -7377,6 +7638,39 @@ function useTxHistory(account) {
|
|
|
7377
7638
|
}, [account]);
|
|
7378
7639
|
return entries;
|
|
7379
7640
|
}
|
|
7641
|
+
var WALLET_HISTORY_REFRESH_MS = 3e4;
|
|
7642
|
+
var hidden2 = () => typeof document !== "undefined" && document.visibilityState === "hidden";
|
|
7643
|
+
var travelling = (entries) => !!entries?.some((e) => e.delivery === "in-progress" || e.delivery === "attention");
|
|
7644
|
+
function useWalletHistory(engine, wallets) {
|
|
7645
|
+
const [entries, setEntries] = react.useState(null);
|
|
7646
|
+
const key = wallets.filter((w) => !!w).join("|");
|
|
7647
|
+
react.useEffect(() => {
|
|
7648
|
+
setEntries(null);
|
|
7649
|
+
if (!engine || !key) return;
|
|
7650
|
+
let alive = true;
|
|
7651
|
+
let timer2;
|
|
7652
|
+
const read = async () => {
|
|
7653
|
+
if (timer2) clearTimeout(timer2);
|
|
7654
|
+
timer2 = void 0;
|
|
7655
|
+
if (!hidden2()) {
|
|
7656
|
+
const next = await engine.fetchWalletHistory(key.split("|"));
|
|
7657
|
+
if (!alive) return;
|
|
7658
|
+
if (next) setEntries(next);
|
|
7659
|
+
if (!travelling(next)) return;
|
|
7660
|
+
}
|
|
7661
|
+
timer2 = setTimeout(read, WALLET_HISTORY_REFRESH_MS);
|
|
7662
|
+
};
|
|
7663
|
+
void read();
|
|
7664
|
+
const onRecorded = () => void read();
|
|
7665
|
+
if (typeof window !== "undefined") window.addEventListener(TX_HISTORY_EVENT, onRecorded);
|
|
7666
|
+
return () => {
|
|
7667
|
+
alive = false;
|
|
7668
|
+
if (timer2) clearTimeout(timer2);
|
|
7669
|
+
if (typeof window !== "undefined") window.removeEventListener(TX_HISTORY_EVENT, onRecorded);
|
|
7670
|
+
};
|
|
7671
|
+
}, [engine, key]);
|
|
7672
|
+
return entries;
|
|
7673
|
+
}
|
|
7380
7674
|
function BackGlyph() {
|
|
7381
7675
|
return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "17", height: "17", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.4", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
|
|
7382
7676
|
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M19 12H5" }),
|
|
@@ -7460,7 +7754,15 @@ function TxLegs(props) {
|
|
|
7460
7754
|
] }, `${leg.index}:${leg.fromChainId}:${leg.toChainId}`)) })
|
|
7461
7755
|
] });
|
|
7462
7756
|
}
|
|
7463
|
-
function statusBadge(
|
|
7757
|
+
function statusBadge(entry) {
|
|
7758
|
+
if (entry.delivery === "delivered")
|
|
7759
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-badge", "data-tone": "ok", children: "Delivered" });
|
|
7760
|
+
if (entry.delivery === "failed")
|
|
7761
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-badge", "data-tone": "warn", children: "Not delivered" });
|
|
7762
|
+
if (entry.delivery === "attention")
|
|
7763
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-badge", "data-tone": "warn", children: "Needs action" });
|
|
7764
|
+
if (entry.delivery === "in-progress") return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-badge", children: "On its way" });
|
|
7765
|
+
const status = entry.status;
|
|
7464
7766
|
if (status === "confirmed")
|
|
7465
7767
|
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-badge", "data-tone": "ok", children: "Confirmed" });
|
|
7466
7768
|
if (status === "error")
|
|
@@ -7532,7 +7834,7 @@ function TxHistoryList(props) {
|
|
|
7532
7834
|
] }),
|
|
7533
7835
|
whenLabel(e.at) ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-txrow-time", children: whenLabel(e.at) }) : null
|
|
7534
7836
|
] }),
|
|
7535
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-txrow-end", children: statusBadge(e
|
|
7837
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-txrow-end", children: statusBadge(e) })
|
|
7536
7838
|
] })
|
|
7537
7839
|
] }, `${e.hash}:${e.at}`)
|
|
7538
7840
|
)) });
|
|
@@ -7572,7 +7874,7 @@ function TxDetail(props) {
|
|
|
7572
7874
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-meta", children: [
|
|
7573
7875
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-meta-row", children: [
|
|
7574
7876
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-meta-label", children: "Status" }),
|
|
7575
|
-
statusBadge(e
|
|
7877
|
+
statusBadge(e)
|
|
7576
7878
|
] }),
|
|
7577
7879
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-meta-row", children: [
|
|
7578
7880
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-meta-label", children: "You sent" }),
|
|
@@ -7608,18 +7910,21 @@ function displayableHistory(entries, account) {
|
|
|
7608
7910
|
}
|
|
7609
7911
|
function TxHistoryPanel(props) {
|
|
7610
7912
|
const account = props.account;
|
|
7611
|
-
const
|
|
7612
|
-
const
|
|
7613
|
-
const
|
|
7913
|
+
const stored = useTxHistory(account);
|
|
7914
|
+
const remote = useWalletHistory(props.engine, [account, props.solanaAccount]);
|
|
7915
|
+
const entries = react.useMemo(() => mergeHistory(displayableHistory(stored, account), remote), [stored, account, remote]);
|
|
7916
|
+
const linked = props.initialEntry && displayableHistory([props.initialEntry], account).length ? props.initialEntry : null;
|
|
7917
|
+
const [selectedHash, setSelectedHash] = react.useState(linked?.hash ?? null);
|
|
7918
|
+
const selected = selectedHash ? entries.find((e) => e.hash === selectedHash) ?? (linked?.hash === selectedHash ? linked : null) : null;
|
|
7614
7919
|
const backRef = react.useRef(null);
|
|
7615
|
-
react.useEffect(() =>
|
|
7920
|
+
react.useEffect(() => setSelectedHash(linked?.hash ?? null), [linked?.hash]);
|
|
7616
7921
|
const pick = (entry) => {
|
|
7617
|
-
|
|
7922
|
+
setSelectedHash(entry.hash);
|
|
7618
7923
|
requestAnimationFrame(() => backRef.current?.focus());
|
|
7619
7924
|
};
|
|
7620
7925
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
7621
7926
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-sel-head", children: [
|
|
7622
|
-
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", autoFocus: true, ref: backRef, className: "sg-back", onClick: selected ? () =>
|
|
7927
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", autoFocus: true, ref: backRef, className: "sg-back", onClick: selected ? () => setSelectedHash(null) : props.onBack, "aria-label": "Back", children: /* @__PURE__ */ jsxRuntime.jsx(BackGlyph, {}) }),
|
|
7623
7928
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-sel-title", children: [
|
|
7624
7929
|
selected ? "Transaction" : "Transaction history",
|
|
7625
7930
|
account ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-sel-sub sg-mono", children: shortAddress2(account) }) : null
|
|
@@ -8708,6 +9013,9 @@ function PaymentIsland(props) {
|
|
|
8708
9013
|
const selectedVisible = Boolean(sel && visibleRoutes.some((r) => r.id === sel.id));
|
|
8709
9014
|
const selBal = sel ? holdings.balances[balanceKey(sel.source.chainId, sel.source.tokenAddress)] : void 0;
|
|
8710
9015
|
const lastTxOwned = Boolean(flow.lastTxEntry?.hash && wallet.account && flow.lastTxEntry.account === wallet.account.toLowerCase());
|
|
9016
|
+
const evmDirect = flow.lastTxEntry?.settlement === "direct";
|
|
9017
|
+
const evmConfirmed = flow.verdict?.status === "confirmed";
|
|
9018
|
+
const evmDelivery = useDelivery(engine, (flow.status === "success" || flow.status === "pending") && !evmDirect ? flow.txHash : null);
|
|
8711
9019
|
const mismatch = flow.status === "error" && flow.verdict?.status === "mismatch";
|
|
8712
9020
|
const destTicker = isPay ? tickerOn(registryTokens, props.toChainId, props.toAsset ?? "") : exToToken ? tokenTicker(exToToken) : exToAsset ?? "";
|
|
8713
9021
|
const exFromTicker = exFromToken ? tokenTicker(exFromToken) : exFromAsset ?? "";
|
|
@@ -8765,7 +9073,11 @@ function PaymentIsland(props) {
|
|
|
8765
9073
|
linkMenu
|
|
8766
9074
|
] }) : void 0;
|
|
8767
9075
|
const activeStep = flow.steps.find((s) => s.state === "active");
|
|
8768
|
-
const liveMsg = flow.status === "loading" ? isPay ? "Finding the best way to pay." : "Finding the best route." : flow.status === "submitting" ? `${activeStep?.label ?? (isPay ? "Processing your payment" : `Processing your ${verb.present.toLowerCase()}`)} \u2014 in progress.` : flow.status === "success" || flow.status === "pending" ?
|
|
9076
|
+
const liveMsg = flow.status === "loading" ? isPay ? "Finding the best way to pay." : "Finding the best route." : flow.status === "submitting" ? `${activeStep?.label ?? (isPay ? "Processing your payment" : `Processing your ${verb.present.toLowerCase()}`)} \u2014 in progress.` : flow.status === "success" || flow.status === "pending" ? (
|
|
9077
|
+
// Announces what the receipt shows: delivery from the tracker, never settlement on the
|
|
9078
|
+
// source receipt alone (review 2026-10-28).
|
|
9079
|
+
`${isPay ? "Payment" : verb.past}: ${deliveryHeadline(evmDelivery, evmConfirmed, evmDirect)}.`
|
|
9080
|
+
) : "";
|
|
8769
9081
|
const loading = flow.status === "loading";
|
|
8770
9082
|
const payReady = isPay ? Boolean(sel && selectedVisible) : Boolean(sel) && !needsRecipient;
|
|
8771
9083
|
const ctaLabel = submitting ? isPay ? "Paying\u2026" : kind === "swap" ? "Swapping\u2026" : "Exchanging\u2026" : flow.quoteStale ? flow.quotePaused ? "Refresh quote" : "Refreshing quote\u2026" : flow.insufficient ? "Insufficient balance" : flow.nativeShortfall ? flow.nativeShortfall : loading ? "Getting a price\u2026" : isPay ? sel && selectedVisible ? `Pay ${sel.source.payAmount} ${sel.source.ticker || sel.source.asset}` : "Pay" : kind === "swap" ? "Swap" : "Exchange";
|
|
@@ -8810,7 +9122,7 @@ function PaymentIsland(props) {
|
|
|
8810
9122
|
] });
|
|
8811
9123
|
let body;
|
|
8812
9124
|
if (hist && wallet.account) {
|
|
8813
|
-
body = /* @__PURE__ */ jsxRuntime.jsx(TxHistoryPanel, { account: wallet.account, tokens: registryTokens, vaultIcons: catalogue?.vaultIcons, initialEntry: hist.entry ?? null, onBack: closeHistory });
|
|
9125
|
+
body = /* @__PURE__ */ jsxRuntime.jsx(TxHistoryPanel, { account: wallet.account, engine, tokens: registryTokens, vaultIcons: catalogue?.vaultIcons, initialEntry: hist.entry ?? null, onBack: closeHistory });
|
|
8814
9126
|
} else if (isPay && view === "select" && wallet.account) {
|
|
8815
9127
|
body = /* @__PURE__ */ jsxRuntime.jsx(
|
|
8816
9128
|
TokenSelect,
|
|
@@ -8888,7 +9200,7 @@ function PaymentIsland(props) {
|
|
|
8888
9200
|
] })
|
|
8889
9201
|
] });
|
|
8890
9202
|
} else if (paid || settling) {
|
|
8891
|
-
const confirmed =
|
|
9203
|
+
const confirmed = isDelivered(evmDelivery, evmConfirmed, evmDirect);
|
|
8892
9204
|
body = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
8893
9205
|
/* @__PURE__ */ jsxRuntime.jsx(IdentityLine, { account: wallet.account, email: identity?.email }),
|
|
8894
9206
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-receipt", children: [
|
|
@@ -8900,9 +9212,10 @@ function PaymentIsland(props) {
|
|
|
8900
9212
|
destTicker
|
|
8901
9213
|
] }),
|
|
8902
9214
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-receipt-sub", children: [
|
|
8903
|
-
|
|
9215
|
+
deliveryHeadline(evmDelivery, evmConfirmed, evmDirect),
|
|
8904
9216
|
(flow.lastTxEntry?.recipient || recipient2) && (isPay || recipientState.recipientFamily === "solana") ? ` \xB7 ${shortAddress2(flow.lastTxEntry?.recipient || recipient2)}` : ""
|
|
8905
|
-
] })
|
|
9217
|
+
] }),
|
|
9218
|
+
evmDirect ? null : /* @__PURE__ */ jsxRuntime.jsx(DeliverySteps, { delivery: evmDelivery })
|
|
8906
9219
|
] }),
|
|
8907
9220
|
!identityMatchesWallet ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-remember", children: [
|
|
8908
9221
|
/* @__PURE__ */ jsxRuntime.jsxs("label", { className: "sg-remember-top", children: [
|
|
@@ -9327,6 +9640,9 @@ function PayCard(props) {
|
|
|
9327
9640
|
};
|
|
9328
9641
|
react.useEffect(() => setHist(null), [wallet.account]);
|
|
9329
9642
|
const lastTxOwned = Boolean(flow.lastTxEntry?.hash && wallet.account && flow.lastTxEntry.account === wallet.account.toLowerCase());
|
|
9643
|
+
const evmDirect = flow.lastTxEntry?.settlement === "direct";
|
|
9644
|
+
const evmConfirmed = flow.verdict?.status === "confirmed";
|
|
9645
|
+
const evmDelivery = useDelivery(engine, (flow.status === "success" || flow.status === "pending") && !evmDirect ? flow.txHash : null);
|
|
9330
9646
|
const pickFunding = (pick) => {
|
|
9331
9647
|
setPickError(null);
|
|
9332
9648
|
const r = visibleRoutes.find((x) => x.source.chainId === pick.chainId && symbolKey(x.source.asset) === symbolKey(pick.symbol));
|
|
@@ -9386,7 +9702,7 @@ function PayCard(props) {
|
|
|
9386
9702
|
...durationLabel(sel.quote.estimatedDuration) ? [{ label: "Estimated time", value: durationLabel(sel.quote.estimatedDuration) }] : []
|
|
9387
9703
|
] : [];
|
|
9388
9704
|
const loadingPlan = flow.status === "loading" || holdings.loading && !sel || pricing !== null;
|
|
9389
|
-
return /* @__PURE__ */ jsxRuntime.jsx(WidgetShell, { title: config.title || "Complete payment", theme: config.theme, heightPx: props.heightPx, walletSlot, onClose: props.onClose, children: hist && wallet.account ? /* @__PURE__ */ jsxRuntime.jsx(TxHistoryPanel, { account: wallet.account, tokens: registryTokens, vaultIcons: catalogue?.vaultIcons, initialEntry: hist.entry ?? null, onBack: closeHistory }) : view === "select" && wallet.account ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
9705
|
+
return /* @__PURE__ */ jsxRuntime.jsx(WidgetShell, { title: config.title || "Complete payment", theme: config.theme, heightPx: props.heightPx, walletSlot, onClose: props.onClose, children: hist && wallet.account ? /* @__PURE__ */ jsxRuntime.jsx(TxHistoryPanel, { account: wallet.account, engine, tokens: registryTokens, vaultIcons: catalogue?.vaultIcons, initialEntry: hist.entry ?? null, onBack: closeHistory }) : view === "select" && wallet.account ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
9390
9706
|
TokenSelect,
|
|
9391
9707
|
{
|
|
9392
9708
|
title: "Pay with",
|
|
@@ -9408,17 +9724,18 @@ function PayCard(props) {
|
|
|
9408
9724
|
] })
|
|
9409
9725
|
] }) : flow.status === "success" || flow.status === "pending" ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
9410
9726
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-success", children: [
|
|
9411
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-success-check", "data-pending":
|
|
9727
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-success-check", "data-pending": !isDelivered(evmDelivery, evmConfirmed, evmDirect), children: /* @__PURE__ */ jsxRuntime.jsx(CheckGlyph3, {}) }),
|
|
9412
9728
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-success-amt sg-mono", children: [
|
|
9413
9729
|
props.amount,
|
|
9414
9730
|
" ",
|
|
9415
9731
|
tickerOn(registryTokens, props.toChainId, props.toAsset)
|
|
9416
9732
|
] }),
|
|
9417
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-success-sub", children: [
|
|
9418
|
-
|
|
9733
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-success-sub", role: "status", "aria-live": "polite", children: [
|
|
9734
|
+
deliveryHeadline(evmDelivery, evmConfirmed, evmDirect),
|
|
9419
9735
|
" \xB7 ",
|
|
9420
9736
|
shortAddress2(props.recipient)
|
|
9421
|
-
] })
|
|
9737
|
+
] }),
|
|
9738
|
+
evmDirect ? null : /* @__PURE__ */ jsxRuntime.jsx(DeliverySteps, { delivery: evmDelivery })
|
|
9422
9739
|
] }),
|
|
9423
9740
|
lastTxOwned ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-cta-wrap", children: /* @__PURE__ */ jsxRuntime.jsx(Button, { variant: "ghost", onClick: () => setHist({ entry: flow.lastTxEntry }), children: "View transaction" }) }) : null
|
|
9424
9741
|
] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
@@ -9570,28 +9887,32 @@ function StableGenieSwap(props) {
|
|
|
9570
9887
|
};
|
|
9571
9888
|
}, [engine, props.variant, hist]);
|
|
9572
9889
|
const lastTxOwned = Boolean(flow.lastTxEntry?.hash && wallet.account && flow.lastTxEntry.account === wallet.account.toLowerCase());
|
|
9890
|
+
const evmDirect = flow.lastTxEntry?.settlement === "direct";
|
|
9891
|
+
const evmConfirmed = flow.verdict?.status === "confirmed";
|
|
9892
|
+
const evmDelivery = useDelivery(engine, (flow.status === "success" || flow.status === "pending") && !evmDirect ? flow.txHash : null);
|
|
9573
9893
|
if (props.variant === "pill") return /* @__PURE__ */ jsxRuntime.jsx(PaymentIsland, { kind: "swap", ...props });
|
|
9574
9894
|
const walletSlot = wallet.account ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-head-tools", children: [
|
|
9575
9895
|
/* @__PURE__ */ jsxRuntime.jsx(HistoryButton, { btnRef: histBtnRef, disabled: submitting, onClick: () => setHist({}) }),
|
|
9576
9896
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-brand", children: "ZeroDelta" })
|
|
9577
9897
|
] }) : void 0;
|
|
9578
9898
|
if (hist && wallet.account) {
|
|
9579
|
-
return /* @__PURE__ */ jsxRuntime.jsx(WidgetShell, { title: config.title || "Swap", theme: config.theme, walletSlot, children: /* @__PURE__ */ jsxRuntime.jsx(TxHistoryPanel, { account: wallet.account, tokens: registryTokens, vaultIcons: catalogue?.vaultIcons, initialEntry: hist.entry ?? null, onBack: closeHistory }) });
|
|
9899
|
+
return /* @__PURE__ */ jsxRuntime.jsx(WidgetShell, { title: config.title || "Swap", theme: config.theme, walletSlot, children: /* @__PURE__ */ jsxRuntime.jsx(TxHistoryPanel, { account: wallet.account, engine, tokens: registryTokens, vaultIcons: catalogue?.vaultIcons, initialEntry: hist.entry ?? null, onBack: closeHistory }) });
|
|
9580
9900
|
}
|
|
9581
9901
|
if (recipientState.open) return /* @__PURE__ */ jsxRuntime.jsx(WidgetShell, { title: config.title || "Swap", theme: config.theme, walletSlot, children: /* @__PURE__ */ jsxRuntime.jsx(RecipientSheet, { state: recipientState, symbol: toAsset }) });
|
|
9582
9902
|
if (flow.status === "success" || flow.status === "pending") {
|
|
9583
9903
|
return /* @__PURE__ */ jsxRuntime.jsxs(WidgetShell, { title: config.title || "Swap", theme: config.theme, walletSlot, children: [
|
|
9584
9904
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-success", children: [
|
|
9585
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-success-check", "data-pending":
|
|
9905
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-success-check", "data-pending": !isDelivered(evmDelivery, evmConfirmed, evmDirect), children: /* @__PURE__ */ jsxRuntime.jsx(CheckGlyph4, {}) }),
|
|
9586
9906
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-success-amt sg-mono", children: [
|
|
9587
9907
|
receive,
|
|
9588
9908
|
" ",
|
|
9589
9909
|
tickerOn(registryTokens, toChainId, toAsset)
|
|
9590
9910
|
] }),
|
|
9591
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-success-sub", children: [
|
|
9592
|
-
|
|
9911
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-success-sub", role: "status", "aria-live": "polite", children: [
|
|
9912
|
+
deliveryHeadline(evmDelivery, evmConfirmed, evmDirect),
|
|
9593
9913
|
recipientState.recipientFamily === "solana" ? ` \xB7 ${shortAddress2(flow.lastTxEntry?.recipient || recipient2)}` : props.recipient ? ` \xB7 ${shortAddress2(props.recipient)}` : ""
|
|
9594
|
-
] })
|
|
9914
|
+
] }),
|
|
9915
|
+
evmDirect ? null : /* @__PURE__ */ jsxRuntime.jsx(DeliverySteps, { delivery: evmDelivery })
|
|
9595
9916
|
] }),
|
|
9596
9917
|
lastTxOwned ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-cta-wrap", children: /* @__PURE__ */ jsxRuntime.jsx(Button, { variant: "ghost", onClick: () => setHist({ entry: flow.lastTxEntry }), children: "View transaction" }) }) : null
|
|
9597
9918
|
] });
|
|
@@ -10102,6 +10423,10 @@ function ExchangeCard(props) {
|
|
|
10102
10423
|
const addressed = connected2 && !needsRecipient;
|
|
10103
10424
|
const submitting = solActive ? solFlow.status === "preparing" || solFlow.status === "submitting" : flow.status === "submitting";
|
|
10104
10425
|
const lastTxOwned = Boolean(flow.lastTxEntry?.hash && wallet.account && flow.lastTxEntry.account === wallet.account.toLowerCase());
|
|
10426
|
+
const evmDirect = flow.lastTxEntry?.settlement === "direct";
|
|
10427
|
+
const evmConfirmed = flow.verdict?.status === "confirmed";
|
|
10428
|
+
const evmDelivery = useDelivery(engine, (flow.status === "success" || flow.status === "pending") && !evmDirect ? flow.txHash : null);
|
|
10429
|
+
const solDelivery = useDelivery(engine, solActive && solFlow.status === "sent" ? solFlow.signature : null);
|
|
10105
10430
|
const quoting = solActive ? solFlow.status === "quoting" : addressed ? flow.status === "loading" : preview.status === "loading";
|
|
10106
10431
|
const quoteError = !quotable ? null : solActive ? solFlow.status === "error" || solFlow.status === "failed" ? solFlow.error : null : addressed ? flow.status === "error" ? flow.error : null : preview.status === "error" ? preview.error ?? "No route." : null;
|
|
10107
10432
|
const gatewayAmountError = !quoteError || solActive ? null : addressed ? flow.fieldError : preview.fieldError ?? null;
|
|
@@ -10146,8 +10471,8 @@ function ExchangeCard(props) {
|
|
|
10146
10471
|
const rateRows = hasQuote ? [{ label: "Network fee", value: networkFee }, ...eta ? [{ label: "Estimated time", value: eta }] : []] : [];
|
|
10147
10472
|
const via = selected ? selected.legs.length > 1 ? selected.legs[0]?.toTicker || selected.legs[0]?.toAsset || "" : null : preview.data?.via ?? null;
|
|
10148
10473
|
const routeShape = via === null ? "Direct" : via ? `Via ${via}` : "Two steps";
|
|
10149
|
-
const compliance = selected?.quote.compliance;
|
|
10150
|
-
const complianceHasQuote = Boolean(selected && flow.status !== "loading");
|
|
10474
|
+
const compliance = solActive ? solanaQuoteCompliance(solFlow.plan?.preview.quote) : selected?.quote.compliance;
|
|
10475
|
+
const complianceHasQuote = solActive ? Boolean(solFlow.plan && solFlow.status !== "quoting") : Boolean(selected && flow.status !== "loading");
|
|
10151
10476
|
const fromUsd = usdOf2(normalizedAmount, prices[from?.symbol ?? ""]);
|
|
10152
10477
|
const toUsd = usdOf2(receive, prices[to?.symbol ?? ""]);
|
|
10153
10478
|
const flippable = !rampMode && !submitting && Boolean(to && sourceTokens.some((t) => Number(t.chainId) === to.chainId && symbolKey(t.symbol) === to.symbol));
|
|
@@ -10247,10 +10572,17 @@ function ExchangeCard(props) {
|
|
|
10247
10572
|
children: solFlow.status === "preparing" ? "Preparing order\u2026" : solFlow.status === "submitting" ? "Submitting\u2026" : solFlow.insufficient ? "Insufficient balance" : solFlow.solShort ? "Not enough SOL for network fees" : solFlow.status === "failed" ? "Try again" : !solFlow.plan ? "Exchange" : solFlow.needsPreparation ? "Continue in wallet" : "Submit"
|
|
10248
10573
|
}
|
|
10249
10574
|
);
|
|
10250
|
-
const solanaSteps = solActive && solFlow.plan && connected2 && solanaWallet.address ? /* @__PURE__ */ jsxRuntime.
|
|
10575
|
+
const solanaSteps = solActive && solFlow.plan && connected2 && solanaWallet.address && solFlow.solShort && solFlow.cost ? /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "sg-cp-summary-sub", style: { textAlign: "center", margin: "0 0 8px" }, "data-testid": "sol-shortfall", children: [
|
|
10576
|
+
"This order needs about ",
|
|
10577
|
+
(solFlow.cost.lamports / 1e9).toFixed(4),
|
|
10578
|
+
" SOL for network fees and rent; the wallet holds",
|
|
10579
|
+
" ",
|
|
10580
|
+
(solFlow.cost.balanceLamports / 1e9).toFixed(4),
|
|
10581
|
+
" SOL."
|
|
10582
|
+
] }) : null;
|
|
10251
10583
|
let body;
|
|
10252
10584
|
if (hist && connected2) {
|
|
10253
|
-
body = /* @__PURE__ */ jsxRuntime.jsx(TxHistoryPanel, { account: wallet.account, tokens, vaultIcons: catalogue?.vaultIcons, initialEntry: hist.entry ?? null, onBack: closeHistory });
|
|
10585
|
+
body = /* @__PURE__ */ jsxRuntime.jsx(TxHistoryPanel, { account: wallet.account, engine, solanaAccount: solanaWallet.address, tokens, vaultIcons: catalogue?.vaultIcons, initialEntry: hist.entry ?? null, onBack: closeHistory });
|
|
10254
10586
|
} else if (view === "from" || view === "to") {
|
|
10255
10587
|
const isFrom = view === "from";
|
|
10256
10588
|
body = /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -10277,16 +10609,17 @@ function ExchangeCard(props) {
|
|
|
10277
10609
|
} else if (solActive && solFlow.status === "sent") {
|
|
10278
10610
|
body = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
10279
10611
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-success", children: [
|
|
10280
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-success-check", "data-pending":
|
|
10612
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-success-check", "data-pending": !isDelivered(solDelivery, false), children: /* @__PURE__ */ jsxRuntime.jsx(CheckGlyph5, {}) }),
|
|
10281
10613
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-success-amt sg-mono", children: [
|
|
10282
10614
|
solFlow.sent?.receive ?? receive,
|
|
10283
10615
|
" ",
|
|
10284
10616
|
solFlow.sent?.toTicker ?? toTicker
|
|
10285
10617
|
] }),
|
|
10286
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-success-sub", children: [
|
|
10287
|
-
"Submitted on Solana \u2014
|
|
10618
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-success-sub", role: "status", "aria-live": "polite", children: [
|
|
10619
|
+
solDelivery.phase === "tracking" ? "Submitted on Solana \u2014 tracking delivery" : deliveryHeadline(solDelivery, true),
|
|
10288
10620
|
solFlow.sent?.recipient ? ` \xB7 ${shortAddress2(solFlow.sent.recipient)}` : ""
|
|
10289
|
-
] })
|
|
10621
|
+
] }),
|
|
10622
|
+
/* @__PURE__ */ jsxRuntime.jsx(DeliverySteps, { delivery: solDelivery })
|
|
10290
10623
|
] }),
|
|
10291
10624
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cta-wrap", children: [
|
|
10292
10625
|
solFlow.signature ? /* @__PURE__ */ jsxRuntime.jsx("a", { className: "sg-btn sg-btn-ghost", href: `https://solscan.io/tx/${solFlow.signature}`, target: "_blank", rel: "noopener noreferrer", children: "View on Solscan" }) : null,
|
|
@@ -10297,16 +10630,17 @@ function ExchangeCard(props) {
|
|
|
10297
10630
|
} else if (flow.status === "success" || flow.status === "pending") {
|
|
10298
10631
|
body = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
10299
10632
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-success", children: [
|
|
10300
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-success-check", "data-pending":
|
|
10633
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-success-check", "data-pending": !isDelivered(evmDelivery, evmConfirmed, evmDirect), children: /* @__PURE__ */ jsxRuntime.jsx(CheckGlyph5, {}) }),
|
|
10301
10634
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-success-amt sg-mono", children: [
|
|
10302
10635
|
receive,
|
|
10303
10636
|
" ",
|
|
10304
10637
|
toTicker
|
|
10305
10638
|
] }),
|
|
10306
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-success-sub", children: [
|
|
10307
|
-
|
|
10639
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-success-sub", role: "status", "aria-live": "polite", children: [
|
|
10640
|
+
deliveryHeadline(evmDelivery, evmConfirmed, evmDirect),
|
|
10308
10641
|
recipientState.recipientFamily === "solana" ? ` \xB7 ${shortAddress2(flow.lastTxEntry?.recipient || recipient2)}` : props.recipient ? ` \xB7 ${shortAddress2(props.recipient)}` : ""
|
|
10309
|
-
] })
|
|
10642
|
+
] }),
|
|
10643
|
+
evmDirect ? null : /* @__PURE__ */ jsxRuntime.jsx(DeliverySteps, { delivery: evmDelivery })
|
|
10310
10644
|
] }),
|
|
10311
10645
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cta-wrap", children: [
|
|
10312
10646
|
lastTxOwned ? /* @__PURE__ */ jsxRuntime.jsx(Button, { variant: "ghost", onClick: () => setHist({ entry: flow.lastTxEntry }), children: "View transaction" }) : null,
|