@glacislabs/stablegenie-zerodelta 4.12.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/dist/{chunk-A7ADZJXA.js → chunk-6WFIFKZ4.js} +1427 -227
- package/dist/{chunk-MA2VYFG3.js → chunk-M55J3P64.js} +961 -97
- package/dist/core/index.cjs +2086 -239
- package/dist/core/index.d.cts +449 -40
- package/dist/core/index.d.ts +449 -40
- package/dist/core/index.js +1 -1
- package/dist/ed25519-FZW4JEOV.js +526 -0
- package/dist/ed25519-GAMEXARB.js +11 -0
- package/dist/index.cjs +3085 -450
- package/dist/index.d.cts +96 -4
- package/dist/index.d.ts +96 -4
- package/dist/index.js +2 -2
- package/dist/{mount-hxb3zioQ.d.ts → mount-B6soKC-9.d.ts} +1 -1
- package/dist/{mount-xruGixNZ.d.cts → mount-CEy4Nqky.d.cts} +1 -1
- package/dist/mount.cjs +3076 -448
- 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 +13 -9
- package/dist/{verify-D8tr1yY1.d.cts → verify-Y9jZ83T5.d.cts} +81 -68
- package/dist/{verify-D8tr1yY1.d.ts → verify-Y9jZ83T5.d.ts} +81 -68
- package/package.json +4 -3
|
@@ -1,8 +1,96 @@
|
|
|
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, amountFieldError,
|
|
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, formatUnits, amountFieldError, solanaQuoteCompliance, 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-6WFIFKZ4.js';
|
|
2
2
|
import { createContext, useState, useRef, useMemo, useEffect, useCallback, useId, createElement, useContext, useLayoutEffect, useSyncExternalStore, useReducer } from 'react';
|
|
3
3
|
import { createRoot } from 'react-dom/client';
|
|
4
4
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
5
5
|
|
|
6
|
+
function deliveryPollDelay(elapsedMs) {
|
|
7
|
+
if (elapsedMs < 6e4) return 5e3;
|
|
8
|
+
if (elapsedMs < 11 * 6e4) return 15e3;
|
|
9
|
+
return 3e4;
|
|
10
|
+
}
|
|
11
|
+
var DELIVERY_GIVE_UP_MS = 2 * 60 * 60 * 1e3;
|
|
12
|
+
var UNANSWERED_LIMIT = 20;
|
|
13
|
+
var UNAVAILABLE = Object.freeze({ phase: "unavailable", status: "", steps: [] });
|
|
14
|
+
var hidden = () => typeof document !== "undefined" && document.visibilityState === "hidden";
|
|
15
|
+
function useDelivery(engine, hash) {
|
|
16
|
+
const [state, setState] = useState({ hash: null, value: TRACKING });
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (!hash) return;
|
|
19
|
+
let alive = true;
|
|
20
|
+
let timer2;
|
|
21
|
+
let answered = false;
|
|
22
|
+
let unanswered = 0;
|
|
23
|
+
const started2 = Date.now();
|
|
24
|
+
setState({ hash, value: TRACKING });
|
|
25
|
+
const schedule = () => {
|
|
26
|
+
if (Date.now() - started2 > DELIVERY_GIVE_UP_MS) return setState({ hash, value: UNAVAILABLE });
|
|
27
|
+
timer2 = setTimeout(tick, deliveryPollDelay(Date.now() - started2));
|
|
28
|
+
};
|
|
29
|
+
const tick = async () => {
|
|
30
|
+
timer2 = void 0;
|
|
31
|
+
if (hidden()) return schedule();
|
|
32
|
+
const next = await engine.trackDelivery(hash);
|
|
33
|
+
if (!alive) return;
|
|
34
|
+
if (next.phase === "tracking") {
|
|
35
|
+
if (!answered && ++unanswered >= UNANSWERED_LIMIT) return setState({ hash, value: UNAVAILABLE });
|
|
36
|
+
return schedule();
|
|
37
|
+
}
|
|
38
|
+
answered = true;
|
|
39
|
+
setState({ hash, value: next });
|
|
40
|
+
if (next.phase === "delivered" || next.phase === "failed") return;
|
|
41
|
+
schedule();
|
|
42
|
+
};
|
|
43
|
+
const onVisible2 = () => {
|
|
44
|
+
if (!alive || hidden() || !timer2) return;
|
|
45
|
+
clearTimeout(timer2);
|
|
46
|
+
void tick();
|
|
47
|
+
};
|
|
48
|
+
void tick();
|
|
49
|
+
if (typeof document !== "undefined") document.addEventListener("visibilitychange", onVisible2);
|
|
50
|
+
return () => {
|
|
51
|
+
alive = false;
|
|
52
|
+
if (timer2) clearTimeout(timer2);
|
|
53
|
+
if (typeof document !== "undefined") document.removeEventListener("visibilitychange", onVisible2);
|
|
54
|
+
};
|
|
55
|
+
}, [engine, hash]);
|
|
56
|
+
return state.hash === hash ? state.value : TRACKING;
|
|
57
|
+
}
|
|
58
|
+
var STEP_LABEL = {
|
|
59
|
+
submitted: "Submitted",
|
|
60
|
+
arrived: "Arrived",
|
|
61
|
+
filled: "Filled",
|
|
62
|
+
outbound_bridging: "Bridging",
|
|
63
|
+
delivered: "Delivered"
|
|
64
|
+
};
|
|
65
|
+
var label = (name) => STEP_LABEL[name] ?? name.replace(/_/g, " ");
|
|
66
|
+
function deliveryHeadline(delivery, sourceConfirmed, direct = false) {
|
|
67
|
+
if (direct) return sourceConfirmed ? "Delivered" : "Submitted \u2014 awaiting confirmation";
|
|
68
|
+
switch (delivery.phase) {
|
|
69
|
+
case "delivered":
|
|
70
|
+
return "Delivered";
|
|
71
|
+
case "failed":
|
|
72
|
+
return delivery.status === "cancelled" ? "Cancelled \u2014 not delivered" : `Not delivered (${delivery.status.replace(/_/g, " ")}) \u2014 open the transaction for details`;
|
|
73
|
+
case "attention":
|
|
74
|
+
return delivery.status === "cancel_pending" ? "Being cancelled \u2014 not delivered" : "Waiting to be claimed \u2014 open the transaction";
|
|
75
|
+
case "in-progress": {
|
|
76
|
+
if (delivery.status === "continuing") return "On its way \u2014 final leg next";
|
|
77
|
+
const next = delivery.steps.find((s) => !s.done);
|
|
78
|
+
return next ? `On its way \u2014 ${label(next.name).toLowerCase()} next` : "On its way";
|
|
79
|
+
}
|
|
80
|
+
case "unavailable":
|
|
81
|
+
return sourceConfirmed ? "Sent \u2014 open the transaction to follow delivery" : "Submitted \u2014 awaiting confirmation";
|
|
82
|
+
default:
|
|
83
|
+
return sourceConfirmed ? "Sent \u2014 tracking delivery" : "Submitted \u2014 awaiting confirmation";
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function isDelivered(delivery, sourceConfirmed, direct = false) {
|
|
87
|
+
return direct ? sourceConfirmed : delivery.phase === "delivered";
|
|
88
|
+
}
|
|
89
|
+
function DeliverySteps(props) {
|
|
90
|
+
const { steps, phase } = props.delivery;
|
|
91
|
+
if (!steps.length || phase === "failed") return null;
|
|
92
|
+
return /* @__PURE__ */ 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 ") });
|
|
93
|
+
}
|
|
6
94
|
var ConfigContext = createContext({});
|
|
7
95
|
function StableGenieProvider({ children, ...config }) {
|
|
8
96
|
return /* @__PURE__ */ jsx(ConfigContext.Provider, { value: config, children });
|
|
@@ -865,6 +953,7 @@ var WIDGET_CSS = `
|
|
|
865
953
|
.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}
|
|
866
954
|
/* Broadcast but not receipt-confirmed: mute the disc so a pending settlement never wears the
|
|
867
955
|
accent-coloured "paid" affordance. Mirrors .sg-settle-disc[data-pending] in the island. */
|
|
956
|
+
.sg-success-steps{font-size:12px;color:var(--sg-text-muted);margin-top:6px;text-align:center}
|
|
868
957
|
.sg-success-check[data-pending="true"]{background:var(--sg-surface);color:var(--sg-text-muted);border:1px solid var(--sg-border)}
|
|
869
958
|
.sg-success-amt{font-size:20px;font-weight:700;font-variant-numeric:tabular-nums}
|
|
870
959
|
.sg-success-sub{font-size:12px;color:var(--sg-text-muted);margin-top:2px}
|
|
@@ -1755,7 +1844,7 @@ function StepList(props) {
|
|
|
1755
1844
|
/* @__PURE__ */ jsx("span", { className: s.state === "done" ? "sg-muted" : "", children: s.label }),
|
|
1756
1845
|
rich ? /* @__PURE__ */ jsx("span", { className: "sg-sr-only", children: ` \u2014 ${STEP_STATE_WORD[s.state]}` }) : null
|
|
1757
1846
|
] }, s.id)) }),
|
|
1758
|
-
rich && props.verdict && verifyDone ? /* @__PURE__ */ jsx("div", { className: "sg-step-verdict", children: props.verdict.status === "confirmed" ? "Confirmed on-chain \u2014
|
|
1847
|
+
rich && props.verdict && verifyDone ? /* @__PURE__ */ 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
|
|
1759
1848
|
] });
|
|
1760
1849
|
}
|
|
1761
1850
|
var SHOW_ROADMAP_METHODS = true;
|
|
@@ -1811,7 +1900,7 @@ function RouteList(props) {
|
|
|
1811
1900
|
visible.map((r) => {
|
|
1812
1901
|
const selected = props.selectedId === r.id;
|
|
1813
1902
|
const bal = props.balances?.[routeBalanceKey(r)];
|
|
1814
|
-
const
|
|
1903
|
+
const short2 = props.shortIds?.has(r.id) ?? false;
|
|
1815
1904
|
const held = props.heldIds?.has(r.id) ?? false;
|
|
1816
1905
|
return (
|
|
1817
1906
|
// a11y note: a native radio cannot contain the rich
|
|
@@ -1823,7 +1912,7 @@ function RouteList(props) {
|
|
|
1823
1912
|
{
|
|
1824
1913
|
className: "sg-route-item",
|
|
1825
1914
|
"data-selected": selected,
|
|
1826
|
-
"data-short":
|
|
1915
|
+
"data-short": short2 || void 0,
|
|
1827
1916
|
"data-held": held || void 0,
|
|
1828
1917
|
role: "radio",
|
|
1829
1918
|
"aria-checked": selected,
|
|
@@ -1858,7 +1947,7 @@ function RouteList(props) {
|
|
|
1858
1947
|
"bal ",
|
|
1859
1948
|
bal.formatted
|
|
1860
1949
|
] }) : null,
|
|
1861
|
-
|
|
1950
|
+
short2 ? /* @__PURE__ */ jsx("span", { className: "sg-badge", "data-tone": "warn", children: "Short" }) : r.state === "DIRECT" ? /* @__PURE__ */ jsx("span", { className: "sg-badge", "data-tone": "ok", children: "Direct" }) : r.recommended ? /* @__PURE__ */ jsx("span", { className: "sg-badge", "data-tone": "accent", children: "Best" }) : null,
|
|
1862
1951
|
/* @__PURE__ */ jsx("span", { className: "sg-radio", "aria-hidden": "true" })
|
|
1863
1952
|
] })
|
|
1864
1953
|
]
|
|
@@ -2095,8 +2184,8 @@ var CHAIN_ALIASES = {
|
|
|
2095
2184
|
137: ["matic"],
|
|
2096
2185
|
43114: ["avax"]
|
|
2097
2186
|
};
|
|
2098
|
-
function labelForms(
|
|
2099
|
-
const lower =
|
|
2187
|
+
function labelForms(label2) {
|
|
2188
|
+
const lower = label2.trim().toLowerCase();
|
|
2100
2189
|
if (!lower) return [];
|
|
2101
2190
|
const compact = lower.replace(/[^a-z0-9]/g, "");
|
|
2102
2191
|
return compact && compact !== lower ? [lower, compact] : [lower];
|
|
@@ -2107,8 +2196,8 @@ function buildChainSearchTerms(chains) {
|
|
|
2107
2196
|
for (const id of ids) {
|
|
2108
2197
|
const chain = chains.find((c) => Number(c.chainId) === id);
|
|
2109
2198
|
const terms = /* @__PURE__ */ new Set();
|
|
2110
|
-
for (const
|
|
2111
|
-
if (
|
|
2199
|
+
for (const label2 of [chain?.displayName, chain?.name, typeof chain?.slug === "string" ? chain.slug : void 0, CHAIN_LABELS[id]]) {
|
|
2200
|
+
if (label2) for (const form of labelForms(label2)) terms.add(form);
|
|
2112
2201
|
}
|
|
2113
2202
|
for (const alias of CHAIN_ALIASES[id] ?? []) terms.add(alias);
|
|
2114
2203
|
byId.set(id, [...terms]);
|
|
@@ -2480,7 +2569,7 @@ function TokenSelect(props) {
|
|
|
2480
2569
|
const members = g.deployments;
|
|
2481
2570
|
const multi = members.length > 1;
|
|
2482
2571
|
const single = members[0];
|
|
2483
|
-
const
|
|
2572
|
+
const label2 = multi ? g.symbol : tokenTicker(single.token);
|
|
2484
2573
|
const blocked = !!g.unavailable;
|
|
2485
2574
|
const opensNetworks = multi || blocked;
|
|
2486
2575
|
const zero = showBalances && g.amount === 0 || blocked;
|
|
@@ -2504,7 +2593,7 @@ function TokenSelect(props) {
|
|
|
2504
2593
|
/* @__PURE__ */ jsxs("span", { className: "sg-pk-left", children: [
|
|
2505
2594
|
/* @__PURE__ */ jsx(TokenPlate, { symbol: g.symbol, logoUrl: g.logoUrl }),
|
|
2506
2595
|
/* @__PURE__ */ jsxs("span", { className: "sg-pk-text", children: [
|
|
2507
|
-
/* @__PURE__ */ jsx("span", { className: "sg-pk-label", children:
|
|
2596
|
+
/* @__PURE__ */ jsx("span", { className: "sg-pk-label", children: label2 }),
|
|
2508
2597
|
/* @__PURE__ */ jsxs("span", { className: "sg-pk-line", children: [
|
|
2509
2598
|
/* @__PURE__ */ jsx("span", { className: "sg-pk-sub", children: multi ? showBalances ? "Total across" : "Available on" : `On ${chainName3(Number(single.token.chainId))}` }),
|
|
2510
2599
|
/* @__PURE__ */ jsx(ChainMarks, { chainIds: members.map((m) => Number(m.token.chainId)), chainById, decorative: !multi }),
|
|
@@ -2513,7 +2602,7 @@ function TokenSelect(props) {
|
|
|
2513
2602
|
!multi && single.hint ? /* @__PURE__ */ jsx("span", { className: "sg-pk-note", "data-testid": "lane-limit", children: single.hint }) : null
|
|
2514
2603
|
] })
|
|
2515
2604
|
] }),
|
|
2516
|
-
showBalances ? /* @__PURE__ */ jsx(BalanceColumn, { amount: g.amount, usd: g.usd, symbol:
|
|
2605
|
+
showBalances ? /* @__PURE__ */ jsx(BalanceColumn, { amount: g.amount, usd: g.usd, symbol: label2 }) : opensNetworks ? /* @__PURE__ */ jsx("span", { className: "sg-pk-chev", "aria-hidden": "true", children: /* @__PURE__ */ jsx(ChevronGlyph, {}) }) : null
|
|
2517
2606
|
]
|
|
2518
2607
|
},
|
|
2519
2608
|
g.key
|
|
@@ -2799,12 +2888,12 @@ function TriggerGlyph({ cv }) {
|
|
|
2799
2888
|
return /* @__PURE__ */ jsx(ShieldTick, {});
|
|
2800
2889
|
}
|
|
2801
2890
|
function CheckRow({ check: check2, onViewPolicy }) {
|
|
2802
|
-
const
|
|
2891
|
+
const label2 = check2.id === "risk" ? check2.ok ? "Risk screening passed" : "Risk screening failed" : check2.label;
|
|
2803
2892
|
return /* @__PURE__ */ jsxs("li", { className: "sg-cp-check", "data-ok": check2.ok, children: [
|
|
2804
2893
|
/* @__PURE__ */ jsxs("div", { className: "sg-cp-check-head", children: [
|
|
2805
2894
|
/* @__PURE__ */ jsxs("span", { className: "sg-cp-check-label", children: [
|
|
2806
2895
|
/* @__PURE__ */ jsx("span", { className: "sg-cp-check-mark", "data-ok": check2.ok, children: check2.ok ? /* @__PURE__ */ jsx(Tick, {}) : /* @__PURE__ */ jsx(Cross, {}) }),
|
|
2807
|
-
/* @__PURE__ */ jsx("span", { children:
|
|
2896
|
+
/* @__PURE__ */ jsx("span", { children: label2 }),
|
|
2808
2897
|
/* @__PURE__ */ jsx("span", { className: "sg-sr-only", children: check2.ok ? " \u2014 passed" : " \u2014 failed" })
|
|
2809
2898
|
] }),
|
|
2810
2899
|
check2.id === "risk" ? /* @__PURE__ */ jsxs("button", { type: "button", className: "sg-cp-link", onClick: onViewPolicy, children: [
|
|
@@ -2872,9 +2961,9 @@ function QuoteChecks({
|
|
|
2872
2961
|
] }) : null
|
|
2873
2962
|
] });
|
|
2874
2963
|
}
|
|
2875
|
-
function Fact({ label, value, title, mono = false }) {
|
|
2964
|
+
function Fact({ label: label2, value, title, mono = false }) {
|
|
2876
2965
|
return /* @__PURE__ */ jsxs("div", { className: "sg-cp-fact", children: [
|
|
2877
|
-
/* @__PURE__ */ jsx("dt", { children:
|
|
2966
|
+
/* @__PURE__ */ jsx("dt", { children: label2 }),
|
|
2878
2967
|
/* @__PURE__ */ jsx("dd", { title, className: mono ? "sg-mono" : void 0, children: value })
|
|
2879
2968
|
] });
|
|
2880
2969
|
}
|
|
@@ -3003,6 +3092,39 @@ function useTxHistory(account) {
|
|
|
3003
3092
|
}, [account]);
|
|
3004
3093
|
return entries;
|
|
3005
3094
|
}
|
|
3095
|
+
var WALLET_HISTORY_REFRESH_MS = 3e4;
|
|
3096
|
+
var hidden2 = () => typeof document !== "undefined" && document.visibilityState === "hidden";
|
|
3097
|
+
var travelling = (entries) => !!entries?.some((e) => e.delivery === "in-progress" || e.delivery === "attention");
|
|
3098
|
+
function useWalletHistory(engine, wallets) {
|
|
3099
|
+
const [entries, setEntries] = useState(null);
|
|
3100
|
+
const key = wallets.filter((w) => !!w).join("|");
|
|
3101
|
+
useEffect(() => {
|
|
3102
|
+
setEntries(null);
|
|
3103
|
+
if (!engine || !key) return;
|
|
3104
|
+
let alive = true;
|
|
3105
|
+
let timer2;
|
|
3106
|
+
const read = async () => {
|
|
3107
|
+
if (timer2) clearTimeout(timer2);
|
|
3108
|
+
timer2 = void 0;
|
|
3109
|
+
if (!hidden2()) {
|
|
3110
|
+
const next = await engine.fetchWalletHistory(key.split("|"));
|
|
3111
|
+
if (!alive) return;
|
|
3112
|
+
if (next) setEntries(next);
|
|
3113
|
+
if (!travelling(next)) return;
|
|
3114
|
+
}
|
|
3115
|
+
timer2 = setTimeout(read, WALLET_HISTORY_REFRESH_MS);
|
|
3116
|
+
};
|
|
3117
|
+
void read();
|
|
3118
|
+
const onRecorded = () => void read();
|
|
3119
|
+
if (typeof window !== "undefined") window.addEventListener(TX_HISTORY_EVENT, onRecorded);
|
|
3120
|
+
return () => {
|
|
3121
|
+
alive = false;
|
|
3122
|
+
if (timer2) clearTimeout(timer2);
|
|
3123
|
+
if (typeof window !== "undefined") window.removeEventListener(TX_HISTORY_EVENT, onRecorded);
|
|
3124
|
+
};
|
|
3125
|
+
}, [engine, key]);
|
|
3126
|
+
return entries;
|
|
3127
|
+
}
|
|
3006
3128
|
function BackGlyph() {
|
|
3007
3129
|
return /* @__PURE__ */ 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: [
|
|
3008
3130
|
/* @__PURE__ */ jsx("path", { d: "M19 12H5" }),
|
|
@@ -3086,7 +3208,15 @@ function TxLegs(props) {
|
|
|
3086
3208
|
] }, `${leg.index}:${leg.fromChainId}:${leg.toChainId}`)) })
|
|
3087
3209
|
] });
|
|
3088
3210
|
}
|
|
3089
|
-
function statusBadge(
|
|
3211
|
+
function statusBadge(entry) {
|
|
3212
|
+
if (entry.delivery === "delivered")
|
|
3213
|
+
return /* @__PURE__ */ jsx("span", { className: "sg-badge", "data-tone": "ok", children: "Delivered" });
|
|
3214
|
+
if (entry.delivery === "failed")
|
|
3215
|
+
return /* @__PURE__ */ jsx("span", { className: "sg-badge", "data-tone": "warn", children: "Not delivered" });
|
|
3216
|
+
if (entry.delivery === "attention")
|
|
3217
|
+
return /* @__PURE__ */ jsx("span", { className: "sg-badge", "data-tone": "warn", children: "Needs action" });
|
|
3218
|
+
if (entry.delivery === "in-progress") return /* @__PURE__ */ jsx("span", { className: "sg-badge", children: "On its way" });
|
|
3219
|
+
const status = entry.status;
|
|
3090
3220
|
if (status === "confirmed")
|
|
3091
3221
|
return /* @__PURE__ */ jsx("span", { className: "sg-badge", "data-tone": "ok", children: "Confirmed" });
|
|
3092
3222
|
if (status === "error")
|
|
@@ -3158,7 +3288,7 @@ function TxHistoryList(props) {
|
|
|
3158
3288
|
] }),
|
|
3159
3289
|
whenLabel(e.at) ? /* @__PURE__ */ jsx("span", { className: "sg-txrow-time", children: whenLabel(e.at) }) : null
|
|
3160
3290
|
] }),
|
|
3161
|
-
/* @__PURE__ */ jsx("span", { className: "sg-txrow-end", children: statusBadge(e
|
|
3291
|
+
/* @__PURE__ */ jsx("span", { className: "sg-txrow-end", children: statusBadge(e) })
|
|
3162
3292
|
] })
|
|
3163
3293
|
] }, `${e.hash}:${e.at}`)
|
|
3164
3294
|
)) });
|
|
@@ -3198,7 +3328,7 @@ function TxDetail(props) {
|
|
|
3198
3328
|
/* @__PURE__ */ jsxs("div", { className: "sg-meta", children: [
|
|
3199
3329
|
/* @__PURE__ */ jsxs("div", { className: "sg-meta-row", children: [
|
|
3200
3330
|
/* @__PURE__ */ jsx("span", { className: "sg-meta-label", children: "Status" }),
|
|
3201
|
-
statusBadge(e
|
|
3331
|
+
statusBadge(e)
|
|
3202
3332
|
] }),
|
|
3203
3333
|
/* @__PURE__ */ jsxs("div", { className: "sg-meta-row", children: [
|
|
3204
3334
|
/* @__PURE__ */ jsx("span", { className: "sg-meta-label", children: "You sent" }),
|
|
@@ -3234,18 +3364,21 @@ function displayableHistory(entries, account) {
|
|
|
3234
3364
|
}
|
|
3235
3365
|
function TxHistoryPanel(props) {
|
|
3236
3366
|
const account = props.account;
|
|
3237
|
-
const
|
|
3238
|
-
const
|
|
3239
|
-
const
|
|
3367
|
+
const stored = useTxHistory(account);
|
|
3368
|
+
const remote = useWalletHistory(props.engine, [account, props.solanaAccount]);
|
|
3369
|
+
const entries = useMemo(() => mergeHistory(displayableHistory(stored, account), remote), [stored, account, remote]);
|
|
3370
|
+
const linked = props.initialEntry && displayableHistory([props.initialEntry], account).length ? props.initialEntry : null;
|
|
3371
|
+
const [selectedHash, setSelectedHash] = useState(linked?.hash ?? null);
|
|
3372
|
+
const selected = selectedHash ? entries.find((e) => e.hash === selectedHash) ?? (linked?.hash === selectedHash ? linked : null) : null;
|
|
3240
3373
|
const backRef = useRef(null);
|
|
3241
|
-
useEffect(() =>
|
|
3374
|
+
useEffect(() => setSelectedHash(linked?.hash ?? null), [linked?.hash]);
|
|
3242
3375
|
const pick = (entry) => {
|
|
3243
|
-
|
|
3376
|
+
setSelectedHash(entry.hash);
|
|
3244
3377
|
requestAnimationFrame(() => backRef.current?.focus());
|
|
3245
3378
|
};
|
|
3246
3379
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
3247
3380
|
/* @__PURE__ */ jsxs("div", { className: "sg-sel-head", children: [
|
|
3248
|
-
/* @__PURE__ */ jsx("button", { type: "button", autoFocus: true, ref: backRef, className: "sg-back", onClick: selected ? () =>
|
|
3381
|
+
/* @__PURE__ */ jsx("button", { type: "button", autoFocus: true, ref: backRef, className: "sg-back", onClick: selected ? () => setSelectedHash(null) : props.onBack, "aria-label": "Back", children: /* @__PURE__ */ jsx(BackGlyph, {}) }),
|
|
3249
3382
|
/* @__PURE__ */ jsxs("div", { className: "sg-sel-title", children: [
|
|
3250
3383
|
selected ? "Transaction" : "Transaction history",
|
|
3251
3384
|
account ? /* @__PURE__ */ jsx("span", { className: "sg-sel-sub sg-mono", children: shortAddress(account) }) : null
|
|
@@ -3254,6 +3387,444 @@ function TxHistoryPanel(props) {
|
|
|
3254
3387
|
selected ? /* @__PURE__ */ jsx(TxDetail, { entry: selected, tokens: props.tokens, vaultIcons: props.vaultIcons }) : /* @__PURE__ */ jsx(TxHistoryList, { entries, tokens: props.tokens, vaultIcons: props.vaultIcons, onPick: pick })
|
|
3255
3388
|
] });
|
|
3256
3389
|
}
|
|
3390
|
+
|
|
3391
|
+
// src/provider/solana-wallet.ts
|
|
3392
|
+
var sources = /* @__PURE__ */ new WeakMap();
|
|
3393
|
+
var infos = /* @__PURE__ */ new WeakMap();
|
|
3394
|
+
var connected = /* @__PURE__ */ new WeakMap();
|
|
3395
|
+
var registries = /* @__PURE__ */ new WeakMap();
|
|
3396
|
+
var EMPTY = Object.freeze([]);
|
|
3397
|
+
function normalizeSolanaWalletName(name) {
|
|
3398
|
+
return name.trim().toLowerCase().replace(/\s+(wallet|evm|solana)$/i, "");
|
|
3399
|
+
}
|
|
3400
|
+
function solanaWalletInfo(provider) {
|
|
3401
|
+
const standard = "features" in provider;
|
|
3402
|
+
if (standard ? !provider.chains?.some((chain) => chain.startsWith("solana:")) || typeof provider.features?.["standard:connect"]?.connect !== "function" : typeof provider.connect !== "function") return null;
|
|
3403
|
+
let info = infos.get(provider);
|
|
3404
|
+
if (!info) {
|
|
3405
|
+
const name = provider.name || (!standard && provider.isPhantom ? "Phantom" : !standard && provider.isSolflare ? "Solflare" : "Solana wallet");
|
|
3406
|
+
info = Object.freeze({ name, icon: standard ? provider.icon : void 0, kind: standard ? "standard" : "legacy" });
|
|
3407
|
+
infos.set(provider, info);
|
|
3408
|
+
sources.set(info, provider);
|
|
3409
|
+
}
|
|
3410
|
+
return info;
|
|
3411
|
+
}
|
|
3412
|
+
function targetWindow(win) {
|
|
3413
|
+
return win ?? (typeof window === "undefined" ? void 0 : window);
|
|
3414
|
+
}
|
|
3415
|
+
function registry(win) {
|
|
3416
|
+
const existing = registries.get(win);
|
|
3417
|
+
if (existing) return existing;
|
|
3418
|
+
const standard = /* @__PURE__ */ new Set();
|
|
3419
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
3420
|
+
let snapshot = EMPTY;
|
|
3421
|
+
const read = () => {
|
|
3422
|
+
const candidates = [...standard].map(solanaWalletInfo);
|
|
3423
|
+
for (const [provider, name] of [[win.phantom?.solana, "Phantom"], [win.solflare, "Solflare"], [win.solana, void 0]]) {
|
|
3424
|
+
if (!provider || typeof provider.connect !== "function") continue;
|
|
3425
|
+
let info = solanaWalletInfo(provider);
|
|
3426
|
+
if (info && name && info.name === "Solana wallet") {
|
|
3427
|
+
info = Object.freeze({ ...info, name });
|
|
3428
|
+
infos.set(provider, info);
|
|
3429
|
+
sources.set(info, provider);
|
|
3430
|
+
}
|
|
3431
|
+
candidates.push(info);
|
|
3432
|
+
}
|
|
3433
|
+
const names = /* @__PURE__ */ new Set();
|
|
3434
|
+
const providers = /* @__PURE__ */ new Set();
|
|
3435
|
+
const next = candidates.filter((info) => {
|
|
3436
|
+
if (!info) return false;
|
|
3437
|
+
const name = normalizeSolanaWalletName(info.name);
|
|
3438
|
+
const provider = sources.get(info);
|
|
3439
|
+
if (names.has(name) || providers.has(provider)) return false;
|
|
3440
|
+
names.add(name);
|
|
3441
|
+
providers.add(provider);
|
|
3442
|
+
return true;
|
|
3443
|
+
});
|
|
3444
|
+
if (next.length !== snapshot.length || next.some((info) => !snapshot.includes(info))) snapshot = Object.freeze(next);
|
|
3445
|
+
return snapshot;
|
|
3446
|
+
};
|
|
3447
|
+
const refresh = () => {
|
|
3448
|
+
const previous = snapshot;
|
|
3449
|
+
read();
|
|
3450
|
+
if (previous !== snapshot) for (const cb of listeners) cb();
|
|
3451
|
+
};
|
|
3452
|
+
const api = {
|
|
3453
|
+
register(...wallets) {
|
|
3454
|
+
const added = wallets.filter((wallet) => !standard.has(wallet));
|
|
3455
|
+
for (const wallet of added) standard.add(wallet);
|
|
3456
|
+
refresh();
|
|
3457
|
+
return () => {
|
|
3458
|
+
for (const wallet of added) standard.delete(wallet);
|
|
3459
|
+
refresh();
|
|
3460
|
+
};
|
|
3461
|
+
}
|
|
3462
|
+
};
|
|
3463
|
+
const result = { read, watch: (cb) => {
|
|
3464
|
+
listeners.add(cb);
|
|
3465
|
+
return () => {
|
|
3466
|
+
listeners.delete(cb);
|
|
3467
|
+
};
|
|
3468
|
+
} };
|
|
3469
|
+
registries.set(win, result);
|
|
3470
|
+
win.addEventListener("wallet-standard:register-wallet", (event) => {
|
|
3471
|
+
const callback = event.detail;
|
|
3472
|
+
if (typeof callback === "function") callback(api);
|
|
3473
|
+
});
|
|
3474
|
+
win.addEventListener("focus", refresh);
|
|
3475
|
+
const EventClass = win.CustomEvent;
|
|
3476
|
+
win.dispatchEvent(new EventClass("wallet-standard:app-ready", { detail: api }));
|
|
3477
|
+
read();
|
|
3478
|
+
return result;
|
|
3479
|
+
}
|
|
3480
|
+
function discoverSolanaWallets(win) {
|
|
3481
|
+
const target = targetWindow(win);
|
|
3482
|
+
return target ? registry(target).read() : EMPTY;
|
|
3483
|
+
}
|
|
3484
|
+
function watchSolanaWallets(cb, win) {
|
|
3485
|
+
const target = targetWindow(win);
|
|
3486
|
+
if (!target) return () => {
|
|
3487
|
+
};
|
|
3488
|
+
const store = registry(target);
|
|
3489
|
+
const unsubscribe = store.watch(() => cb(store.read()));
|
|
3490
|
+
cb(store.read());
|
|
3491
|
+
return unsubscribe;
|
|
3492
|
+
}
|
|
3493
|
+
function source(info) {
|
|
3494
|
+
const provider = sources.get(info);
|
|
3495
|
+
if (!provider) throw new Error("Solana wallet is no longer available. Discover it before connecting.");
|
|
3496
|
+
return provider;
|
|
3497
|
+
}
|
|
3498
|
+
function validAddress(value) {
|
|
3499
|
+
const address = value?.toString().trim();
|
|
3500
|
+
return address && isSolanaAddress(address) ? address : null;
|
|
3501
|
+
}
|
|
3502
|
+
function accountAddress(accounts) {
|
|
3503
|
+
const account = accounts?.find((item) => !item.chains?.length || item.chains.some((chain) => chain.startsWith("solana:")));
|
|
3504
|
+
return validAddress(account?.address);
|
|
3505
|
+
}
|
|
3506
|
+
function connectedSolanaAddress(info) {
|
|
3507
|
+
const provider = source(info);
|
|
3508
|
+
return "features" in provider ? accountAddress(provider.accounts) : validAddress(provider.publicKey);
|
|
3509
|
+
}
|
|
3510
|
+
async function connectSolanaWallet(info, options = {}) {
|
|
3511
|
+
const provider = source(info);
|
|
3512
|
+
let address;
|
|
3513
|
+
if ("features" in provider) {
|
|
3514
|
+
const result = await provider.features["standard:connect"].connect(options.silent ? { silent: true } : void 0);
|
|
3515
|
+
const accounts = result?.accounts ?? provider.accounts;
|
|
3516
|
+
connected.set(provider, accounts ?? []);
|
|
3517
|
+
address = accountAddress(accounts);
|
|
3518
|
+
} else {
|
|
3519
|
+
const result = await provider.connect(options.silent ? { onlyIfTrusted: true } : void 0);
|
|
3520
|
+
address = validAddress(result?.publicKey ?? provider.publicKey);
|
|
3521
|
+
connected.set(provider, address ? [{ address }] : []);
|
|
3522
|
+
}
|
|
3523
|
+
if (!address) throw new Error("The wallet did not return a valid Solana address.");
|
|
3524
|
+
return address;
|
|
3525
|
+
}
|
|
3526
|
+
async function disconnectSolanaWallet(info) {
|
|
3527
|
+
const provider = source(info);
|
|
3528
|
+
if ("features" in provider) await provider.features["standard:disconnect"]?.disconnect();
|
|
3529
|
+
else await provider.disconnect?.();
|
|
3530
|
+
connected.delete(provider);
|
|
3531
|
+
}
|
|
3532
|
+
var CANNOT_PAY = "This wallet cannot pay from Solana here; use a Wallet Standard wallet (Phantom, Solflare, Backpack).";
|
|
3533
|
+
function solanaWalletSigner(info) {
|
|
3534
|
+
const provider = source(info);
|
|
3535
|
+
const accounts = "features" in provider ? provider.accounts?.length ? provider.accounts : connected.get(provider) : connected.get(provider);
|
|
3536
|
+
const address = accountAddress(accounts);
|
|
3537
|
+
if (!connected.has(provider) || !address) throw new Error("Connect a Solana wallet before paying.");
|
|
3538
|
+
if ("features" in provider ? typeof provider.features["solana:signTransaction"]?.signTransaction !== "function" : typeof provider.signTransactionBytes !== "function") throw new Error(CANNOT_PAY);
|
|
3539
|
+
return {
|
|
3540
|
+
publicKey: address,
|
|
3541
|
+
async signTransaction(bytes) {
|
|
3542
|
+
const current = "features" in provider ? provider.accounts?.length ? provider.accounts : connected.get(provider) : connected.get(provider);
|
|
3543
|
+
const account = current?.find((a) => a.address === address);
|
|
3544
|
+
if (!connected.has(provider) || !account || accountAddress(current) !== address) throw new Error("Solana wallet account changed; reconnect before paying.");
|
|
3545
|
+
let signed;
|
|
3546
|
+
if ("features" in provider) {
|
|
3547
|
+
if (!provider.chains.includes("solana:mainnet") || account.chains?.length && !account.chains.includes("solana:mainnet")) throw new Error("This wallet account cannot pay on Solana mainnet.");
|
|
3548
|
+
const result = await provider.features["solana:signTransaction"].signTransaction({ account, chain: "solana:mainnet", transaction: new Uint8Array(bytes) });
|
|
3549
|
+
if (result.length !== 1) throw new Error("Wallet returned an invalid Solana signing result.");
|
|
3550
|
+
signed = result[0]?.signedTransaction;
|
|
3551
|
+
} else signed = await provider.signTransactionBytes(new Uint8Array(bytes));
|
|
3552
|
+
if (!(signed instanceof Uint8Array)) throw new Error("Wallet did not return signed transaction bytes.");
|
|
3553
|
+
return new Uint8Array(signed);
|
|
3554
|
+
}
|
|
3555
|
+
};
|
|
3556
|
+
}
|
|
3557
|
+
function onSolanaAccountChange(info, cb) {
|
|
3558
|
+
const provider = source(info);
|
|
3559
|
+
if ("features" in provider) return provider.features["standard:events"]?.on("change", (change) => {
|
|
3560
|
+
if (change.accounts !== void 0) {
|
|
3561
|
+
connected.set(provider, change.accounts);
|
|
3562
|
+
cb(accountAddress(change.accounts));
|
|
3563
|
+
}
|
|
3564
|
+
}) ?? (() => {
|
|
3565
|
+
});
|
|
3566
|
+
const changed = (key) => {
|
|
3567
|
+
const address = validAddress(key);
|
|
3568
|
+
connected.set(provider, address ? [{ address }] : []);
|
|
3569
|
+
cb(address);
|
|
3570
|
+
};
|
|
3571
|
+
const disconnected = () => {
|
|
3572
|
+
connected.delete(provider);
|
|
3573
|
+
cb(null);
|
|
3574
|
+
};
|
|
3575
|
+
provider.on?.("accountChanged", changed);
|
|
3576
|
+
provider.on?.("connect", changed);
|
|
3577
|
+
provider.on?.("disconnect", disconnected);
|
|
3578
|
+
return () => {
|
|
3579
|
+
const off = provider.off ?? provider.removeListener;
|
|
3580
|
+
off?.call(provider, "accountChanged", changed);
|
|
3581
|
+
off?.call(provider, "connect", changed);
|
|
3582
|
+
off?.call(provider, "disconnect", disconnected);
|
|
3583
|
+
};
|
|
3584
|
+
}
|
|
3585
|
+
|
|
3586
|
+
// src/react/hooks/useSolanaWallet.ts
|
|
3587
|
+
var STORAGE_KEY = "sg-solana-wallet";
|
|
3588
|
+
function remember(name) {
|
|
3589
|
+
try {
|
|
3590
|
+
if (name) window.localStorage.setItem(STORAGE_KEY, name);
|
|
3591
|
+
else window.localStorage.removeItem(STORAGE_KEY);
|
|
3592
|
+
} catch {
|
|
3593
|
+
}
|
|
3594
|
+
}
|
|
3595
|
+
function remembered() {
|
|
3596
|
+
try {
|
|
3597
|
+
return window.localStorage.getItem(STORAGE_KEY);
|
|
3598
|
+
} catch {
|
|
3599
|
+
return null;
|
|
3600
|
+
}
|
|
3601
|
+
}
|
|
3602
|
+
var INITIAL = { address: null, walletName: null, status: "idle", error: null };
|
|
3603
|
+
function useSolanaWallet(provider) {
|
|
3604
|
+
const override = useMemo(() => provider ? solanaWalletInfo(provider) : null, [provider]);
|
|
3605
|
+
const [discovered, setDiscovered] = useState(discoverSolanaWallets);
|
|
3606
|
+
const wallets = useMemo(() => provider ? override ? [override] : [] : discovered, [provider, override, discovered]);
|
|
3607
|
+
const [state, setState] = useState(INITIAL);
|
|
3608
|
+
const active = useRef(null);
|
|
3609
|
+
const unsubscribe = useRef(() => {
|
|
3610
|
+
});
|
|
3611
|
+
const generation = useRef(0);
|
|
3612
|
+
const attempted = useRef(false);
|
|
3613
|
+
useEffect(() => {
|
|
3614
|
+
attempted.current = false;
|
|
3615
|
+
setState(INITIAL);
|
|
3616
|
+
return () => {
|
|
3617
|
+
generation.current += 1;
|
|
3618
|
+
unsubscribe.current();
|
|
3619
|
+
active.current = null;
|
|
3620
|
+
};
|
|
3621
|
+
}, [provider]);
|
|
3622
|
+
useEffect(() => provider ? void 0 : watchSolanaWallets(setDiscovered), [provider]);
|
|
3623
|
+
const runConnect = useCallback(async (info, silent = false) => {
|
|
3624
|
+
const request = ++generation.current;
|
|
3625
|
+
unsubscribe.current();
|
|
3626
|
+
active.current = null;
|
|
3627
|
+
setState({ ...INITIAL, status: "connecting" });
|
|
3628
|
+
try {
|
|
3629
|
+
const address = await connectSolanaWallet(info, { silent });
|
|
3630
|
+
if (request !== generation.current) return;
|
|
3631
|
+
active.current = info;
|
|
3632
|
+
unsubscribe.current = onSolanaAccountChange(info, (next) => {
|
|
3633
|
+
if (request !== generation.current) return;
|
|
3634
|
+
setState({ address: next, walletName: next ? info.name : null, status: next ? "connected" : "idle", error: null });
|
|
3635
|
+
if (!next) {
|
|
3636
|
+
generation.current += 1;
|
|
3637
|
+
unsubscribe.current();
|
|
3638
|
+
active.current = null;
|
|
3639
|
+
remember(null);
|
|
3640
|
+
}
|
|
3641
|
+
});
|
|
3642
|
+
setState({ address, walletName: info.name, status: "connected", error: null });
|
|
3643
|
+
remember(info.name);
|
|
3644
|
+
return address;
|
|
3645
|
+
} catch (error) {
|
|
3646
|
+
if (request === generation.current) setState(silent ? INITIAL : {
|
|
3647
|
+
...INITIAL,
|
|
3648
|
+
status: "error",
|
|
3649
|
+
error: error instanceof Error ? error.message : "Could not connect a Solana wallet."
|
|
3650
|
+
});
|
|
3651
|
+
}
|
|
3652
|
+
}, []);
|
|
3653
|
+
useEffect(() => {
|
|
3654
|
+
if (attempted.current || active.current) return;
|
|
3655
|
+
const name = remembered();
|
|
3656
|
+
const info = wallets.find((wallet) => connectedSolanaAddress(wallet)) ?? (name ? wallets.find((wallet) => normalizeSolanaWalletName(wallet.name) === normalizeSolanaWalletName(name)) : void 0);
|
|
3657
|
+
if (!info) return;
|
|
3658
|
+
attempted.current = true;
|
|
3659
|
+
void runConnect(info, true);
|
|
3660
|
+
}, [wallets, runConnect]);
|
|
3661
|
+
const connect = useCallback(async (name) => {
|
|
3662
|
+
if (!name && wallets.length > 1) return wallets;
|
|
3663
|
+
attempted.current = true;
|
|
3664
|
+
const info = name ? wallets.find((wallet) => normalizeSolanaWalletName(wallet.name) === normalizeSolanaWalletName(name)) : wallets[0];
|
|
3665
|
+
if (!info) {
|
|
3666
|
+
setState({ ...INITIAL, status: "error", error: name ? "Solana wallet is not available." : "No Solana wallet found." });
|
|
3667
|
+
return;
|
|
3668
|
+
}
|
|
3669
|
+
return runConnect(info);
|
|
3670
|
+
}, [wallets, runConnect]);
|
|
3671
|
+
const disconnect = useCallback(async () => {
|
|
3672
|
+
attempted.current = true;
|
|
3673
|
+
generation.current += 1;
|
|
3674
|
+
unsubscribe.current();
|
|
3675
|
+
const info = active.current;
|
|
3676
|
+
active.current = null;
|
|
3677
|
+
setState(INITIAL);
|
|
3678
|
+
remember(null);
|
|
3679
|
+
if (info) {
|
|
3680
|
+
try {
|
|
3681
|
+
await disconnectSolanaWallet(info);
|
|
3682
|
+
} catch {
|
|
3683
|
+
}
|
|
3684
|
+
}
|
|
3685
|
+
}, []);
|
|
3686
|
+
return { ...state, wallets, connect, disconnect };
|
|
3687
|
+
}
|
|
3688
|
+
|
|
3689
|
+
// src/react/hooks/useRecipient.ts
|
|
3690
|
+
function useRecipient(destinationChainId, hostRecipient, opts = {}) {
|
|
3691
|
+
const recipientFamily = isSolanaChainId(destinationChainId) ? "solana" : "evm";
|
|
3692
|
+
const own = useSolanaWallet();
|
|
3693
|
+
const wallet = opts.solanaWallet ?? own;
|
|
3694
|
+
const [custom, setCustom] = useState({});
|
|
3695
|
+
const [open, setOpen] = useState(false);
|
|
3696
|
+
const triggerRef = useRef(null);
|
|
3697
|
+
const evmManaged = recipientFamily === "evm" && Boolean(opts.sourceIsSolana);
|
|
3698
|
+
const managed = hostRecipient === void 0 && (recipientFamily === "solana" || evmManaged);
|
|
3699
|
+
const error = hostRecipient === void 0 ? null : recipientFamily === "solana" && !isSolanaAddress(hostRecipient) ? "The configured recipient is not a Solana address." : evmManaged && !isAddress(hostRecipient) ? "The configured recipient is not an EVM address." : null;
|
|
3700
|
+
const recipient = hostRecipient !== void 0 ? hostRecipient : recipientFamily === "solana" ? custom.solana || wallet.address || void 0 : evmManaged ? custom.evm || opts.evm?.account || void 0 : void 0;
|
|
3701
|
+
const missing = managed && !recipient;
|
|
3702
|
+
const familyWallet = recipientFamily === "solana" ? { address: wallet.address, wallets: wallet.wallets, connecting: wallet.status === "connecting", error: wallet.error } : { address: opts.evm?.account ?? null, wallets: [], connecting: Boolean(opts.evm?.connecting), error: null };
|
|
3703
|
+
const close = () => {
|
|
3704
|
+
setOpen(false);
|
|
3705
|
+
requestAnimationFrame(() => triggerRef.current?.focus());
|
|
3706
|
+
};
|
|
3707
|
+
const selectAddress = (address) => {
|
|
3708
|
+
setCustom((prev) => ({ ...prev, [recipientFamily]: address }));
|
|
3709
|
+
close();
|
|
3710
|
+
};
|
|
3711
|
+
const connect = async (name) => {
|
|
3712
|
+
if (recipientFamily === "evm") {
|
|
3713
|
+
if (opts.evm?.account) selectAddress("");
|
|
3714
|
+
else opts.evm?.connect();
|
|
3715
|
+
return;
|
|
3716
|
+
}
|
|
3717
|
+
if (wallet.address && !name) {
|
|
3718
|
+
selectAddress("");
|
|
3719
|
+
return;
|
|
3720
|
+
}
|
|
3721
|
+
if (!name && wallet.wallets.length !== 1) {
|
|
3722
|
+
setOpen(true);
|
|
3723
|
+
return;
|
|
3724
|
+
}
|
|
3725
|
+
const address = await wallet.connect(name);
|
|
3726
|
+
if (typeof address === "string") selectAddress("");
|
|
3727
|
+
else setOpen(true);
|
|
3728
|
+
};
|
|
3729
|
+
const recipientFor = (account) => recipientFamily === "solana" || evmManaged ? recipient || "" : hostRecipient || account;
|
|
3730
|
+
return { recipientFamily, recipient, recipientFor, managed, missing, error, wallet, familyWallet, open: open && managed, show: () => setOpen(true), close, selectAddress, connect, triggerRef };
|
|
3731
|
+
}
|
|
3732
|
+
var short = (address) => `${address.slice(0, 4)}\u2026${address.slice(-4)}`;
|
|
3733
|
+
function RecipientNote({ state, disabled }) {
|
|
3734
|
+
if (state.error) return /* @__PURE__ */ jsx(StatusPanel, { tone: "error", children: state.error });
|
|
3735
|
+
if (!state.managed) return null;
|
|
3736
|
+
const family = state.recipientFamily === "solana" ? "Solana" : "EVM";
|
|
3737
|
+
return /* @__PURE__ */ jsxs("div", { style: { display: "flex", justifyContent: "center", gap: 6, marginTop: 10, fontSize: 13, color: "var(--sg-text-muted)", flexWrap: "wrap" }, children: [
|
|
3738
|
+
state.recipient ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3739
|
+
"To ",
|
|
3740
|
+
/* @__PURE__ */ jsx("b", { className: "sg-mono", title: state.recipient, style: { color: "var(--sg-text)" }, children: short(state.recipient) }),
|
|
3741
|
+
" on ",
|
|
3742
|
+
family,
|
|
3743
|
+
" \xB7 "
|
|
3744
|
+
] }) : null,
|
|
3745
|
+
/* @__PURE__ */ jsx("button", { ref: state.triggerRef, type: "button", className: "sg-cp-link", onClick: state.show, disabled, "aria-haspopup": "dialog", children: state.recipient ? "Change" : "Send to a different address" })
|
|
3746
|
+
] });
|
|
3747
|
+
}
|
|
3748
|
+
function RecipientSheet({ state, symbol }) {
|
|
3749
|
+
const [draft, setDraft] = useState(state.recipient ?? "");
|
|
3750
|
+
const id = useId();
|
|
3751
|
+
const inputRef = useRef(null);
|
|
3752
|
+
const sheetRef = useRef(null);
|
|
3753
|
+
const closeRef = useRef(state.close);
|
|
3754
|
+
closeRef.current = state.close;
|
|
3755
|
+
const family = state.recipientFamily === "solana" ? "Solana" : "EVM";
|
|
3756
|
+
const valid = state.recipientFamily === "solana" ? isSolanaAddress(draft) : /^0x[0-9a-fA-F]{40}$/.test(draft.trim());
|
|
3757
|
+
const invalid = Boolean(draft.trim()) && !valid;
|
|
3758
|
+
const noWallet = state.recipientFamily === "solana" && !state.familyWallet.address && !state.familyWallet.wallets.length;
|
|
3759
|
+
useEffect(() => {
|
|
3760
|
+
(noWallet ? inputRef : sheetRef).current?.focus();
|
|
3761
|
+
const onKey = (event) => {
|
|
3762
|
+
if (event.key === "Escape") {
|
|
3763
|
+
event.stopPropagation();
|
|
3764
|
+
closeRef.current();
|
|
3765
|
+
}
|
|
3766
|
+
};
|
|
3767
|
+
document.addEventListener("keydown", onKey, true);
|
|
3768
|
+
return () => document.removeEventListener("keydown", onKey, true);
|
|
3769
|
+
}, [noWallet]);
|
|
3770
|
+
return /* @__PURE__ */ jsxs("div", { className: "sg-cp-sheet", role: "dialog", "aria-modal": "true", "aria-label": `${family} recipient`, ref: sheetRef, tabIndex: -1, children: [
|
|
3771
|
+
/* @__PURE__ */ jsxs("div", { className: "sg-cp-sheet-head", children: [
|
|
3772
|
+
/* @__PURE__ */ jsxs("h4", { className: "sg-cp-sheet-title", children: [
|
|
3773
|
+
family,
|
|
3774
|
+
" recipient"
|
|
3775
|
+
] }),
|
|
3776
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "sg-cp-close", onClick: state.close, "aria-label": "Close recipient", children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "m6 6 12 12M18 6 6 18", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) })
|
|
3777
|
+
] }),
|
|
3778
|
+
/* @__PURE__ */ jsxs("div", { className: "sg-cp-sheet-body", children: [
|
|
3779
|
+
/* @__PURE__ */ jsxs("section", { className: "sg-cp-card", children: [
|
|
3780
|
+
/* @__PURE__ */ jsxs("p", { className: "sg-cp-summary-sub", style: { margin: "0 0 12px" }, children: [
|
|
3781
|
+
symbol,
|
|
3782
|
+
" is delivered to a ",
|
|
3783
|
+
family,
|
|
3784
|
+
" wallet. Your EVM wallet stays the owner of the order and can cancel it."
|
|
3785
|
+
] }),
|
|
3786
|
+
/* @__PURE__ */ jsx(Button, { onClick: () => noWallet ? inputRef.current?.focus() : void state.connect(), busy: state.familyWallet.connecting, children: state.familyWallet.address ? `Use ${short(state.familyWallet.address)}` : `Connect ${family} wallet` }),
|
|
3787
|
+
!state.familyWallet.address && state.familyWallet.wallets.length > 1 ? state.familyWallet.wallets.map((wallet) => /* @__PURE__ */ jsx(Button, { variant: "ghost", onClick: () => void state.connect(wallet.name), disabled: state.familyWallet.connecting, children: wallet.name }, wallet.name)) : null,
|
|
3788
|
+
noWallet ? /* @__PURE__ */ jsxs("p", { className: "sg-cp-summary-sub", children: [
|
|
3789
|
+
"No ",
|
|
3790
|
+
family,
|
|
3791
|
+
" wallet found. Enter a ",
|
|
3792
|
+
family,
|
|
3793
|
+
" address instead."
|
|
3794
|
+
] }) : null,
|
|
3795
|
+
state.familyWallet.error ? /* @__PURE__ */ jsx(StatusPanel, { tone: "error", children: state.familyWallet.error }) : null
|
|
3796
|
+
] }),
|
|
3797
|
+
/* @__PURE__ */ jsxs("section", { className: "sg-cp-card", children: [
|
|
3798
|
+
/* @__PURE__ */ jsxs("div", { className: "sg-field", style: { margin: 0 }, children: [
|
|
3799
|
+
/* @__PURE__ */ jsx("label", { className: "sg-label", htmlFor: id, children: "Send to a different address" }),
|
|
3800
|
+
/* @__PURE__ */ jsx(
|
|
3801
|
+
"input",
|
|
3802
|
+
{
|
|
3803
|
+
ref: inputRef,
|
|
3804
|
+
id,
|
|
3805
|
+
className: "sg-input sg-mono",
|
|
3806
|
+
style: { fontSize: 14, padding: "12px 14px", border: "1px solid var(--sg-border)", borderRadius: "var(--sg-radius-control)", width: "100%", boxSizing: "border-box", background: "var(--sg-bg)" },
|
|
3807
|
+
placeholder: `${family} recipient address`,
|
|
3808
|
+
"aria-label": `${family} recipient address`,
|
|
3809
|
+
"aria-invalid": invalid || void 0,
|
|
3810
|
+
"aria-describedby": `${id}-help${invalid ? ` ${id}-error` : ""}`,
|
|
3811
|
+
value: draft,
|
|
3812
|
+
onChange: (event) => setDraft(event.target.value),
|
|
3813
|
+
spellCheck: false
|
|
3814
|
+
}
|
|
3815
|
+
)
|
|
3816
|
+
] }),
|
|
3817
|
+
invalid ? /* @__PURE__ */ jsx("div", { id: `${id}-error`, children: /* @__PURE__ */ jsxs(StatusPanel, { tone: "error", children: [
|
|
3818
|
+
"Not a valid ",
|
|
3819
|
+
family,
|
|
3820
|
+
" address."
|
|
3821
|
+
] }) }) : null,
|
|
3822
|
+
/* @__PURE__ */ jsx("p", { id: `${id}-help`, className: "sg-cp-summary-sub", style: { margin: "8px 0 12px" }, children: "Double-check it: a payment sent to a wrong address cannot be recovered." }),
|
|
3823
|
+
/* @__PURE__ */ jsx(Button, { disabled: !valid, onClick: () => state.selectAddress(draft.trim()), children: "Use this address" })
|
|
3824
|
+
] })
|
|
3825
|
+
] })
|
|
3826
|
+
] });
|
|
3827
|
+
}
|
|
3257
3828
|
var IDENTITY_KEY_PREFIX = "sg:link:v1:";
|
|
3258
3829
|
var LEGACY_IDENTITY_KEY = "zd-link-identity";
|
|
3259
3830
|
var ADDRESS_RE = /^0x[0-9a-fA-F]{40}$/;
|
|
@@ -3611,14 +4182,17 @@ function PaymentIsland(props) {
|
|
|
3611
4182
|
const exQuotable = !rampMode && exAmountValid && !exOverLimit && Boolean(exFromChainId && exFromAsset && exToChainId && exToAsset);
|
|
3612
4183
|
const payFundingAssets = props.fundingAssets?.length ? props.fundingAssets : ["USDC", "USDT", "USDE"];
|
|
3613
4184
|
const payParamsKey = `pay|${props.recipient}|${props.toChainId}|${props.toAsset}|${props.amount}|${payFundingAssets.join(",")}`;
|
|
3614
|
-
const
|
|
4185
|
+
const recipientState = useRecipient(isPay ? null : exToChainId ?? null, props.recipient);
|
|
4186
|
+
const recipient = recipientState.recipient;
|
|
4187
|
+
const needsRecipient = !isPay && (recipientState.missing || !!recipientState.error);
|
|
4188
|
+
const exParamsKey = `${kind}|${mode}|${exFromChainId}|${exFromAsset}|${exToChainId}|${exToAsset}|${normEx}|${recipient ?? ""}`;
|
|
3615
4189
|
const flow = useFlow({
|
|
3616
4190
|
engine,
|
|
3617
4191
|
wallet,
|
|
3618
4192
|
kind: isPay ? "payment" : "swap",
|
|
3619
4193
|
// Bank settlement parks the card, so gate the network work off too — otherwise the island would
|
|
3620
4194
|
// quote (and fire onQuote) for a payment whose CTA it never shows.
|
|
3621
|
-
enabled: isPay ? Boolean(props.recipient && props.amount) && !bankSettlement : exQuotable,
|
|
4195
|
+
enabled: isPay ? Boolean(props.recipient && props.amount) && !bankSettlement : exQuotable && !needsRecipient,
|
|
3622
4196
|
paramsKey: isPay ? payParamsKey : exParamsKey,
|
|
3623
4197
|
loadPlan: isPay ? (e, payer, chainId) => e.fetchPaymentPlan({ address: props.recipient, chainId: props.toChainId, asset: props.toAsset, amount: props.amount }, payer, {
|
|
3624
4198
|
chainId,
|
|
@@ -3630,11 +4204,11 @@ function PaymentIsland(props) {
|
|
|
3630
4204
|
fromToken: exFromAsset,
|
|
3631
4205
|
toToken: exToAsset,
|
|
3632
4206
|
amountIn: normEx,
|
|
3633
|
-
recipient
|
|
4207
|
+
recipient
|
|
3634
4208
|
},
|
|
3635
4209
|
payer
|
|
3636
4210
|
),
|
|
3637
|
-
recipientFor: (account) => isPay ? props.recipient :
|
|
4211
|
+
recipientFor: (account) => isPay ? props.recipient : recipientState.recipientFor(account),
|
|
3638
4212
|
onQuote: config.onQuote,
|
|
3639
4213
|
onSuccess: config.onSuccess,
|
|
3640
4214
|
onError: config.onError
|
|
@@ -3893,6 +4467,9 @@ function PaymentIsland(props) {
|
|
|
3893
4467
|
const selectedVisible = Boolean(sel && visibleRoutes.some((r) => r.id === sel.id));
|
|
3894
4468
|
const selBal = sel ? holdings.balances[balanceKey(sel.source.chainId, sel.source.tokenAddress)] : void 0;
|
|
3895
4469
|
const lastTxOwned = Boolean(flow.lastTxEntry?.hash && wallet.account && flow.lastTxEntry.account === wallet.account.toLowerCase());
|
|
4470
|
+
const evmDirect = flow.lastTxEntry?.settlement === "direct";
|
|
4471
|
+
const evmConfirmed = flow.verdict?.status === "confirmed";
|
|
4472
|
+
const evmDelivery = useDelivery(engine, (flow.status === "success" || flow.status === "pending") && !evmDirect ? flow.txHash : null);
|
|
3896
4473
|
const mismatch = flow.status === "error" && flow.verdict?.status === "mismatch";
|
|
3897
4474
|
const destTicker = isPay ? tickerOn(registryTokens, props.toChainId, props.toAsset ?? "") : exToToken ? tokenTicker(exToToken) : exToAsset ?? "";
|
|
3898
4475
|
const exFromTicker = exFromToken ? tokenTicker(exFromToken) : exFromAsset ?? "";
|
|
@@ -3950,9 +4527,13 @@ function PaymentIsland(props) {
|
|
|
3950
4527
|
linkMenu
|
|
3951
4528
|
] }) : void 0;
|
|
3952
4529
|
const activeStep = flow.steps.find((s) => s.state === "active");
|
|
3953
|
-
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" ?
|
|
4530
|
+
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" ? (
|
|
4531
|
+
// Announces what the receipt shows: delivery from the tracker, never settlement on the
|
|
4532
|
+
// source receipt alone (review 2026-10-28).
|
|
4533
|
+
`${isPay ? "Payment" : verb.past}: ${deliveryHeadline(evmDelivery, evmConfirmed, evmDirect)}.`
|
|
4534
|
+
) : "";
|
|
3954
4535
|
const loading = flow.status === "loading";
|
|
3955
|
-
const payReady = isPay ? Boolean(sel && selectedVisible) : Boolean(sel);
|
|
4536
|
+
const payReady = isPay ? Boolean(sel && selectedVisible) : Boolean(sel) && !needsRecipient;
|
|
3956
4537
|
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";
|
|
3957
4538
|
const exPct = (p) => {
|
|
3958
4539
|
if (!exFromBal || !exFromToken) return;
|
|
@@ -3995,7 +4576,7 @@ function PaymentIsland(props) {
|
|
|
3995
4576
|
] });
|
|
3996
4577
|
let body;
|
|
3997
4578
|
if (hist && wallet.account) {
|
|
3998
|
-
body = /* @__PURE__ */ jsx(TxHistoryPanel, { account: wallet.account, tokens: registryTokens, vaultIcons: catalogue?.vaultIcons, initialEntry: hist.entry ?? null, onBack: closeHistory });
|
|
4579
|
+
body = /* @__PURE__ */ jsx(TxHistoryPanel, { account: wallet.account, engine, tokens: registryTokens, vaultIcons: catalogue?.vaultIcons, initialEntry: hist.entry ?? null, onBack: closeHistory });
|
|
3999
4580
|
} else if (isPay && view === "select" && wallet.account) {
|
|
4000
4581
|
body = /* @__PURE__ */ jsx(
|
|
4001
4582
|
TokenSelect,
|
|
@@ -4034,6 +4615,8 @@ function PaymentIsland(props) {
|
|
|
4034
4615
|
}
|
|
4035
4616
|
}
|
|
4036
4617
|
);
|
|
4618
|
+
} else if (recipientState.open && !isPay) {
|
|
4619
|
+
body = /* @__PURE__ */ jsx(RecipientSheet, { state: recipientState, symbol: destTicker });
|
|
4037
4620
|
} else if (rampMode) {
|
|
4038
4621
|
body = /* @__PURE__ */ jsxs("div", { className: "sg-soonpanel", children: [
|
|
4039
4622
|
/* @__PURE__ */ jsx("div", { className: "sg-soonpanel-title", children: mode === "onramp" ? "Buying with fiat is coming soon" : "Cashing out to fiat is coming soon" }),
|
|
@@ -4071,7 +4654,7 @@ function PaymentIsland(props) {
|
|
|
4071
4654
|
] })
|
|
4072
4655
|
] });
|
|
4073
4656
|
} else if (paid || settling) {
|
|
4074
|
-
const confirmed =
|
|
4657
|
+
const confirmed = isDelivered(evmDelivery, evmConfirmed, evmDirect);
|
|
4075
4658
|
body = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4076
4659
|
/* @__PURE__ */ jsx(IdentityLine, { account: wallet.account, email: identity?.email }),
|
|
4077
4660
|
/* @__PURE__ */ jsxs("div", { className: "sg-receipt", children: [
|
|
@@ -4083,9 +4666,10 @@ function PaymentIsland(props) {
|
|
|
4083
4666
|
destTicker
|
|
4084
4667
|
] }),
|
|
4085
4668
|
/* @__PURE__ */ jsxs("div", { className: "sg-receipt-sub", children: [
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
] })
|
|
4669
|
+
deliveryHeadline(evmDelivery, evmConfirmed, evmDirect),
|
|
4670
|
+
(flow.lastTxEntry?.recipient || recipient) && (isPay || recipientState.recipientFamily === "solana") ? ` \xB7 ${shortAddress(flow.lastTxEntry?.recipient || recipient)}` : ""
|
|
4671
|
+
] }),
|
|
4672
|
+
evmDirect ? null : /* @__PURE__ */ jsx(DeliverySteps, { delivery: evmDelivery })
|
|
4089
4673
|
] }),
|
|
4090
4674
|
!identityMatchesWallet ? /* @__PURE__ */ jsxs("div", { className: "sg-remember", children: [
|
|
4091
4675
|
/* @__PURE__ */ jsxs("label", { className: "sg-remember-top", children: [
|
|
@@ -4200,16 +4784,23 @@ function PaymentIsland(props) {
|
|
|
4200
4784
|
quoteError ? /* @__PURE__ */ jsx(StatusPanel, { tone: "error", children: flow.error || "Couldn't get a price right now." }) : null,
|
|
4201
4785
|
walletError ? /* @__PURE__ */ jsx(StatusPanel, { tone: "error", children: flow.error || "The wallet could not complete this payment." }) : null,
|
|
4202
4786
|
submitting || walletError ? /* @__PURE__ */ jsx(StepList, { variant: "rich", steps: flow.steps, verdict: flow.verdict }) : null,
|
|
4203
|
-
/* @__PURE__ */
|
|
4204
|
-
Button,
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
|
|
4787
|
+
/* @__PURE__ */ jsxs("div", { className: "sg-cta-wrap", children: [
|
|
4788
|
+
recipientState.missing && !isPay && !submitting ? /* @__PURE__ */ jsxs(Button, { onClick: () => void recipientState.connect(), busy: recipientState.wallet.status === "connecting", children: [
|
|
4789
|
+
"Connect ",
|
|
4790
|
+
recipientState.recipientFamily === "solana" ? "Solana" : "EVM",
|
|
4791
|
+
" wallet"
|
|
4792
|
+
] }) : quoteError ? /* @__PURE__ */ jsx(Button, { onClick: flow.reload, children: "Try again" }) : walletError ? /* @__PURE__ */ jsx(Button, { onClick: payReady ? flow.submit : void 0, disabled: !payReady, children: "Try again" }) : /* @__PURE__ */ jsx(
|
|
4793
|
+
Button,
|
|
4794
|
+
{
|
|
4795
|
+
onClick: payReady && !submitting && !flow.insufficient && !flow.nativeShortfall && !loading ? flow.submit : void 0,
|
|
4796
|
+
busy: submitting || loading,
|
|
4797
|
+
softDisabled: submitting,
|
|
4798
|
+
disabled: !submitting && (!payReady || flow.insufficient || !!flow.nativeShortfall || loading),
|
|
4799
|
+
children: ctaLabel
|
|
4800
|
+
}
|
|
4801
|
+
),
|
|
4802
|
+
!isPay ? /* @__PURE__ */ jsx(RecipientNote, { state: recipientState, disabled: submitting }) : null
|
|
4803
|
+
] })
|
|
4213
4804
|
] })
|
|
4214
4805
|
] });
|
|
4215
4806
|
}
|
|
@@ -4503,6 +5094,9 @@ function PayCard(props) {
|
|
|
4503
5094
|
};
|
|
4504
5095
|
useEffect(() => setHist(null), [wallet.account]);
|
|
4505
5096
|
const lastTxOwned = Boolean(flow.lastTxEntry?.hash && wallet.account && flow.lastTxEntry.account === wallet.account.toLowerCase());
|
|
5097
|
+
const evmDirect = flow.lastTxEntry?.settlement === "direct";
|
|
5098
|
+
const evmConfirmed = flow.verdict?.status === "confirmed";
|
|
5099
|
+
const evmDelivery = useDelivery(engine, (flow.status === "success" || flow.status === "pending") && !evmDirect ? flow.txHash : null);
|
|
4506
5100
|
const pickFunding = (pick) => {
|
|
4507
5101
|
setPickError(null);
|
|
4508
5102
|
const r = visibleRoutes.find((x) => x.source.chainId === pick.chainId && symbolKey(x.source.asset) === symbolKey(pick.symbol));
|
|
@@ -4562,7 +5156,7 @@ function PayCard(props) {
|
|
|
4562
5156
|
...durationLabel(sel.quote.estimatedDuration) ? [{ label: "Estimated time", value: durationLabel(sel.quote.estimatedDuration) }] : []
|
|
4563
5157
|
] : [];
|
|
4564
5158
|
const loadingPlan = flow.status === "loading" || holdings.loading && !sel || pricing !== null;
|
|
4565
|
-
return /* @__PURE__ */ jsx(WidgetShell, { title: config.title || "Complete payment", theme: config.theme, heightPx: props.heightPx, walletSlot, onClose: props.onClose, children: hist && wallet.account ? /* @__PURE__ */ jsx(TxHistoryPanel, { account: wallet.account, tokens: registryTokens, vaultIcons: catalogue?.vaultIcons, initialEntry: hist.entry ?? null, onBack: closeHistory }) : view === "select" && wallet.account ? /* @__PURE__ */ jsx(
|
|
5159
|
+
return /* @__PURE__ */ jsx(WidgetShell, { title: config.title || "Complete payment", theme: config.theme, heightPx: props.heightPx, walletSlot, onClose: props.onClose, children: hist && wallet.account ? /* @__PURE__ */ jsx(TxHistoryPanel, { account: wallet.account, engine, tokens: registryTokens, vaultIcons: catalogue?.vaultIcons, initialEntry: hist.entry ?? null, onBack: closeHistory }) : view === "select" && wallet.account ? /* @__PURE__ */ jsx(
|
|
4566
5160
|
TokenSelect,
|
|
4567
5161
|
{
|
|
4568
5162
|
title: "Pay with",
|
|
@@ -4584,17 +5178,18 @@ function PayCard(props) {
|
|
|
4584
5178
|
] })
|
|
4585
5179
|
] }) : flow.status === "success" || flow.status === "pending" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4586
5180
|
/* @__PURE__ */ jsxs("div", { className: "sg-success", children: [
|
|
4587
|
-
/* @__PURE__ */ jsx("div", { className: "sg-success-check", "data-pending":
|
|
5181
|
+
/* @__PURE__ */ jsx("div", { className: "sg-success-check", "data-pending": !isDelivered(evmDelivery, evmConfirmed, evmDirect), children: /* @__PURE__ */ jsx(CheckGlyph3, {}) }),
|
|
4588
5182
|
/* @__PURE__ */ jsxs("div", { className: "sg-success-amt sg-mono", children: [
|
|
4589
5183
|
props.amount,
|
|
4590
5184
|
" ",
|
|
4591
5185
|
tickerOn(registryTokens, props.toChainId, props.toAsset)
|
|
4592
5186
|
] }),
|
|
4593
|
-
/* @__PURE__ */ jsxs("div", { className: "sg-success-sub", children: [
|
|
4594
|
-
|
|
5187
|
+
/* @__PURE__ */ jsxs("div", { className: "sg-success-sub", role: "status", "aria-live": "polite", children: [
|
|
5188
|
+
deliveryHeadline(evmDelivery, evmConfirmed, evmDirect),
|
|
4595
5189
|
" \xB7 ",
|
|
4596
5190
|
shortAddress(props.recipient)
|
|
4597
|
-
] })
|
|
5191
|
+
] }),
|
|
5192
|
+
evmDirect ? null : /* @__PURE__ */ jsx(DeliverySteps, { delivery: evmDelivery })
|
|
4598
5193
|
] }),
|
|
4599
5194
|
lastTxOwned ? /* @__PURE__ */ jsx("div", { className: "sg-cta-wrap", children: /* @__PURE__ */ jsx(Button, { variant: "ghost", onClick: () => setHist({ entry: flow.lastTxEntry }), children: "View transaction" }) }) : null
|
|
4600
5195
|
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -4671,6 +5266,9 @@ function StableGenieSwap(props) {
|
|
|
4671
5266
|
const [toChainId, setToChainId] = useState(props.defaultToChainId ?? 8453);
|
|
4672
5267
|
const [toAsset, setToAsset] = useState(props.defaultToAsset ?? "USDC");
|
|
4673
5268
|
const [amount, setAmount] = useState(props.defaultAmount ?? "");
|
|
5269
|
+
const recipientState = useRecipient(toChainId, props.recipient);
|
|
5270
|
+
const recipient = recipientState.recipient;
|
|
5271
|
+
const needsRecipient = recipientState.missing || !!recipientState.error;
|
|
4674
5272
|
const [catalogue, setCatalogue] = useState(null);
|
|
4675
5273
|
useEffect(() => {
|
|
4676
5274
|
if (props.variant === "pill") return;
|
|
@@ -4700,15 +5298,15 @@ function StableGenieSwap(props) {
|
|
|
4700
5298
|
}, [catalogue]);
|
|
4701
5299
|
const amountValid = /^\d+(\.\d+)?$/.test(amount.replace(",", ".")) && Number(amount.replace(",", ".")) > 0;
|
|
4702
5300
|
const enabled = amountValid && props.variant !== "pill";
|
|
4703
|
-
const paramsKey = `${fromChainId}|${fromAsset}|${toChainId}|${toAsset}|${amount}|${
|
|
5301
|
+
const paramsKey = `${fromChainId}|${fromAsset}|${toChainId}|${toAsset}|${amount}|${recipient ?? ""}`;
|
|
4704
5302
|
const flow = useFlow({
|
|
4705
5303
|
engine,
|
|
4706
5304
|
wallet,
|
|
4707
5305
|
kind: "swap",
|
|
4708
|
-
enabled,
|
|
5306
|
+
enabled: enabled && !needsRecipient,
|
|
4709
5307
|
paramsKey,
|
|
4710
|
-
loadPlan: (e, payer) => e.buildSwapPlan({ fromChainId, toChainId, fromToken: fromAsset, toToken: toAsset, amountIn: amount, recipient
|
|
4711
|
-
recipientFor:
|
|
5308
|
+
loadPlan: (e, payer) => e.buildSwapPlan({ fromChainId, toChainId, fromToken: fromAsset, toToken: toAsset, amountIn: amount, recipient }, payer),
|
|
5309
|
+
recipientFor: recipientState.recipientFor,
|
|
4712
5310
|
onQuote: config.onQuote,
|
|
4713
5311
|
onSuccess: config.onSuccess,
|
|
4714
5312
|
onError: config.onError
|
|
@@ -4743,27 +5341,32 @@ function StableGenieSwap(props) {
|
|
|
4743
5341
|
};
|
|
4744
5342
|
}, [engine, props.variant, hist]);
|
|
4745
5343
|
const lastTxOwned = Boolean(flow.lastTxEntry?.hash && wallet.account && flow.lastTxEntry.account === wallet.account.toLowerCase());
|
|
5344
|
+
const evmDirect = flow.lastTxEntry?.settlement === "direct";
|
|
5345
|
+
const evmConfirmed = flow.verdict?.status === "confirmed";
|
|
5346
|
+
const evmDelivery = useDelivery(engine, (flow.status === "success" || flow.status === "pending") && !evmDirect ? flow.txHash : null);
|
|
4746
5347
|
if (props.variant === "pill") return /* @__PURE__ */ jsx(PaymentIsland, { kind: "swap", ...props });
|
|
4747
5348
|
const walletSlot = wallet.account ? /* @__PURE__ */ jsxs("div", { className: "sg-head-tools", children: [
|
|
4748
5349
|
/* @__PURE__ */ jsx(HistoryButton, { btnRef: histBtnRef, disabled: submitting, onClick: () => setHist({}) }),
|
|
4749
5350
|
/* @__PURE__ */ jsx("div", { className: "sg-brand", children: "ZeroDelta" })
|
|
4750
5351
|
] }) : void 0;
|
|
4751
5352
|
if (hist && wallet.account) {
|
|
4752
|
-
return /* @__PURE__ */ jsx(WidgetShell, { title: config.title || "Swap", theme: config.theme, walletSlot, children: /* @__PURE__ */ jsx(TxHistoryPanel, { account: wallet.account, tokens: registryTokens, vaultIcons: catalogue?.vaultIcons, initialEntry: hist.entry ?? null, onBack: closeHistory }) });
|
|
5353
|
+
return /* @__PURE__ */ jsx(WidgetShell, { title: config.title || "Swap", theme: config.theme, walletSlot, children: /* @__PURE__ */ jsx(TxHistoryPanel, { account: wallet.account, engine, tokens: registryTokens, vaultIcons: catalogue?.vaultIcons, initialEntry: hist.entry ?? null, onBack: closeHistory }) });
|
|
4753
5354
|
}
|
|
5355
|
+
if (recipientState.open) return /* @__PURE__ */ jsx(WidgetShell, { title: config.title || "Swap", theme: config.theme, walletSlot, children: /* @__PURE__ */ jsx(RecipientSheet, { state: recipientState, symbol: toAsset }) });
|
|
4754
5356
|
if (flow.status === "success" || flow.status === "pending") {
|
|
4755
5357
|
return /* @__PURE__ */ jsxs(WidgetShell, { title: config.title || "Swap", theme: config.theme, walletSlot, children: [
|
|
4756
5358
|
/* @__PURE__ */ jsxs("div", { className: "sg-success", children: [
|
|
4757
|
-
/* @__PURE__ */ jsx("div", { className: "sg-success-check", "data-pending":
|
|
5359
|
+
/* @__PURE__ */ jsx("div", { className: "sg-success-check", "data-pending": !isDelivered(evmDelivery, evmConfirmed, evmDirect), children: /* @__PURE__ */ jsx(CheckGlyph4, {}) }),
|
|
4758
5360
|
/* @__PURE__ */ jsxs("div", { className: "sg-success-amt sg-mono", children: [
|
|
4759
5361
|
receive,
|
|
4760
5362
|
" ",
|
|
4761
5363
|
tickerOn(registryTokens, toChainId, toAsset)
|
|
4762
5364
|
] }),
|
|
4763
|
-
/* @__PURE__ */ jsxs("div", { className: "sg-success-sub", children: [
|
|
4764
|
-
|
|
4765
|
-
props.recipient ? ` \xB7 ${shortAddress(props.recipient)}` : ""
|
|
4766
|
-
] })
|
|
5365
|
+
/* @__PURE__ */ jsxs("div", { className: "sg-success-sub", role: "status", "aria-live": "polite", children: [
|
|
5366
|
+
deliveryHeadline(evmDelivery, evmConfirmed, evmDirect),
|
|
5367
|
+
recipientState.recipientFamily === "solana" ? ` \xB7 ${shortAddress(flow.lastTxEntry?.recipient || recipient)}` : props.recipient ? ` \xB7 ${shortAddress(props.recipient)}` : ""
|
|
5368
|
+
] }),
|
|
5369
|
+
evmDirect ? null : /* @__PURE__ */ jsx(DeliverySteps, { delivery: evmDelivery })
|
|
4767
5370
|
] }),
|
|
4768
5371
|
lastTxOwned ? /* @__PURE__ */ jsx("div", { className: "sg-cta-wrap", children: /* @__PURE__ */ jsx(Button, { variant: "ghost", onClick: () => setHist({ entry: flow.lastTxEntry }), children: "View transaction" }) }) : null
|
|
4769
5372
|
] });
|
|
@@ -4791,11 +5394,169 @@ function StableGenieSwap(props) {
|
|
|
4791
5394
|
flow.selected && flow.status !== "loading" ? /* @__PURE__ */ jsx(CompliancePanel, { compliance: flow.selected.quote.compliance, direct: flow.selected.state === "DIRECT" }) : null,
|
|
4792
5395
|
submitting ? /* @__PURE__ */ jsx(StepList, { steps: flow.steps }) : null,
|
|
4793
5396
|
/* @__PURE__ */ jsxs("div", { className: "sg-cta-wrap", children: [
|
|
4794
|
-
!wallet.account ? /* @__PURE__ */ jsx(Button, { onClick: wallet.connect, busy: wallet.connecting, children: "Connect wallet" }) : /* @__PURE__ */
|
|
5397
|
+
!wallet.account ? /* @__PURE__ */ jsx(Button, { onClick: wallet.connect, busy: wallet.connecting, children: "Connect wallet" }) : recipientState.missing && !submitting ? /* @__PURE__ */ jsxs(Button, { onClick: () => void recipientState.connect(), busy: recipientState.wallet.status === "connecting", children: [
|
|
5398
|
+
"Connect ",
|
|
5399
|
+
recipientState.recipientFamily === "solana" ? "Solana" : "EVM",
|
|
5400
|
+
" wallet"
|
|
5401
|
+
] }) : /* @__PURE__ */ jsx(Button, { onClick: flow.submit, busy: submitting, disabled: needsRecipient || !flow.selected || flow.insufficient || !!flow.nativeShortfall || !enabled || flow.status === "loading", children: swapLabel }),
|
|
5402
|
+
/* @__PURE__ */ jsx(RecipientNote, { state: recipientState, disabled: submitting }),
|
|
4795
5403
|
wallet.error ? /* @__PURE__ */ jsx(StatusPanel, { tone: "error", children: wallet.error }) : null
|
|
4796
5404
|
] })
|
|
4797
5405
|
] });
|
|
4798
5406
|
}
|
|
5407
|
+
function keyOf(a) {
|
|
5408
|
+
return `${a.fromSymbol}|${a.toChainId}|${a.toSymbol}|${a.amount}|${a.owner ?? ""}|${a.payer ?? ""}|${a.recipient ?? ""}`;
|
|
5409
|
+
}
|
|
5410
|
+
function useSolanaSourceFlow(args) {
|
|
5411
|
+
const { engine, enabled, fromSymbol, fromMint, toChainId, toSymbol, amount, owner, payer, recipient } = args;
|
|
5412
|
+
const [status, setStatus] = useState("idle");
|
|
5413
|
+
const [preview, setPreview] = useState(null);
|
|
5414
|
+
const [plan, setPlan] = useState(null);
|
|
5415
|
+
const [error, setError] = useState(null);
|
|
5416
|
+
const [balanceRaw, setBalanceRaw] = useState(void 0);
|
|
5417
|
+
const [cost, setCost] = useState(null);
|
|
5418
|
+
const [progress, setProgress] = useState(null);
|
|
5419
|
+
const [signature, setSignature] = useState(null);
|
|
5420
|
+
const [lastTxEntry, setLastTxEntry] = useState(null);
|
|
5421
|
+
const [sent, setSent] = useState(null);
|
|
5422
|
+
const [nonce, setNonce] = useState(0);
|
|
5423
|
+
const req = useRef(0);
|
|
5424
|
+
const busy = useRef(false);
|
|
5425
|
+
const latest = useRef(args);
|
|
5426
|
+
latest.current = args;
|
|
5427
|
+
const planKey = useRef(null);
|
|
5428
|
+
const planArgs = useRef(null);
|
|
5429
|
+
const changedWhileBusy = useRef(false);
|
|
5430
|
+
const addressed = Boolean(owner && payer && recipient);
|
|
5431
|
+
const key = keyOf(args);
|
|
5432
|
+
useEffect(() => {
|
|
5433
|
+
const id = ++req.current;
|
|
5434
|
+
if (!enabled || !fromSymbol || !toChainId || !toSymbol || !(Number(amount) > 0)) {
|
|
5435
|
+
setStatus("idle");
|
|
5436
|
+
setPreview(null);
|
|
5437
|
+
setPlan(null);
|
|
5438
|
+
setError(null);
|
|
5439
|
+
setCost(null);
|
|
5440
|
+
return;
|
|
5441
|
+
}
|
|
5442
|
+
if (busy.current) {
|
|
5443
|
+
changedWhileBusy.current = true;
|
|
5444
|
+
return;
|
|
5445
|
+
}
|
|
5446
|
+
setStatus("quoting");
|
|
5447
|
+
planKey.current = null;
|
|
5448
|
+
planArgs.current = null;
|
|
5449
|
+
setError(null);
|
|
5450
|
+
setPlan(null);
|
|
5451
|
+
setCost(null);
|
|
5452
|
+
const timer2 = setTimeout(async () => {
|
|
5453
|
+
try {
|
|
5454
|
+
if (!addressed) {
|
|
5455
|
+
const next = await engine.previewSolanaSource({ toChainId, fromToken: fromSymbol, toToken: toSymbol, amountIn: amount });
|
|
5456
|
+
if (id !== req.current) return;
|
|
5457
|
+
setPreview(next);
|
|
5458
|
+
setStatus("ready");
|
|
5459
|
+
return;
|
|
5460
|
+
}
|
|
5461
|
+
const input = { toChainId, fromToken: fromSymbol, toToken: toSymbol, amountIn: amount, owner, sender: payer, recipient };
|
|
5462
|
+
const quoted = await engine.quoteSolanaSource(input);
|
|
5463
|
+
const built = await engine.buildSolanaSourcePlan(input, quoted);
|
|
5464
|
+
if (id !== req.current) return;
|
|
5465
|
+
planKey.current = key;
|
|
5466
|
+
planArgs.current = { ...latest.current };
|
|
5467
|
+
setPreview(quoted);
|
|
5468
|
+
setPlan(built);
|
|
5469
|
+
setStatus("ready");
|
|
5470
|
+
engine.simulateSolanaCost(built).then(
|
|
5471
|
+
(c) => id === req.current && setCost(c),
|
|
5472
|
+
() => id === req.current && setCost(null)
|
|
5473
|
+
);
|
|
5474
|
+
} catch (e) {
|
|
5475
|
+
if (id !== req.current) return;
|
|
5476
|
+
setStatus("error");
|
|
5477
|
+
setError(e instanceof Error ? e.message : String(e));
|
|
5478
|
+
}
|
|
5479
|
+
}, 350);
|
|
5480
|
+
return () => clearTimeout(timer2);
|
|
5481
|
+
}, [engine, enabled, key, addressed, nonce]);
|
|
5482
|
+
useEffect(() => {
|
|
5483
|
+
let alive = true;
|
|
5484
|
+
setBalanceRaw(void 0);
|
|
5485
|
+
if (!enabled || !payer || !fromMint) return;
|
|
5486
|
+
engine.readSolanaBalance(payer, fromMint).then((b) => {
|
|
5487
|
+
if (alive) setBalanceRaw(b);
|
|
5488
|
+
});
|
|
5489
|
+
return () => {
|
|
5490
|
+
alive = false;
|
|
5491
|
+
};
|
|
5492
|
+
}, [engine, enabled, payer, fromMint]);
|
|
5493
|
+
const needsPreparation = plan ? solanaPlanNeedsPreparation(plan) : false;
|
|
5494
|
+
const run = useCallback(async () => {
|
|
5495
|
+
const current = plan;
|
|
5496
|
+
if (!current || busy.current) return;
|
|
5497
|
+
if (planKey.current !== keyOf(latest.current)) {
|
|
5498
|
+
setError("The order changed; review the new quote before signing.");
|
|
5499
|
+
setNonce((n) => n + 1);
|
|
5500
|
+
return;
|
|
5501
|
+
}
|
|
5502
|
+
busy.current = true;
|
|
5503
|
+
let broadcast = false;
|
|
5504
|
+
setError(null);
|
|
5505
|
+
setStatus(needsPreparation ? "preparing" : "submitting");
|
|
5506
|
+
try {
|
|
5507
|
+
const result = await engine.executeSolanaPlanStaged({ plan: current, signer: latest.current.signer(), onProgress: setProgress });
|
|
5508
|
+
if (result.status === "prepared") {
|
|
5509
|
+
setStatus("prepared");
|
|
5510
|
+
return;
|
|
5511
|
+
}
|
|
5512
|
+
const a = planArgs.current ?? latest.current;
|
|
5513
|
+
broadcast = true;
|
|
5514
|
+
setSent({ receive: current.preview.receive, toTicker: a.toTicker, recipient: a.recipient ?? "" });
|
|
5515
|
+
setSignature(result.signature);
|
|
5516
|
+
setStatus("sent");
|
|
5517
|
+
const entry = engine.recordTransaction({
|
|
5518
|
+
kind: "swap",
|
|
5519
|
+
hash: result.signature,
|
|
5520
|
+
txKind: "submitOrder",
|
|
5521
|
+
chainId: SOLANA_CHAIN_ID,
|
|
5522
|
+
chainName: a.chainName,
|
|
5523
|
+
fromAsset: a.fromSymbol ?? "",
|
|
5524
|
+
toAsset: a.toSymbol ?? "",
|
|
5525
|
+
fromTicker: a.fromTicker,
|
|
5526
|
+
toTicker: a.toTicker,
|
|
5527
|
+
payAmount: a.amount,
|
|
5528
|
+
receiveAmount: current.preview.receive,
|
|
5529
|
+
account: a.owner ?? "",
|
|
5530
|
+
recipient: a.recipient ?? "",
|
|
5531
|
+
settlement: "escrow",
|
|
5532
|
+
status: "submitted"
|
|
5533
|
+
});
|
|
5534
|
+
setLastTxEntry(entry.hash ? entry : null);
|
|
5535
|
+
appendTxHistory(a.owner, entry);
|
|
5536
|
+
} catch (e) {
|
|
5537
|
+
const err = e instanceof Error ? e : new Error(String(e));
|
|
5538
|
+
setStatus("failed");
|
|
5539
|
+
setError(err.message);
|
|
5540
|
+
latest.current.onError?.(err);
|
|
5541
|
+
} finally {
|
|
5542
|
+
busy.current = false;
|
|
5543
|
+
if (changedWhileBusy.current) {
|
|
5544
|
+
changedWhileBusy.current = false;
|
|
5545
|
+
if (!broadcast && planKey.current !== keyOf(latest.current)) setNonce((n) => n + 1);
|
|
5546
|
+
}
|
|
5547
|
+
}
|
|
5548
|
+
}, [engine, plan, needsPreparation]);
|
|
5549
|
+
const insufficient = balanceRaw !== void 0 && plan ? balanceRaw < BigInt(plan.expected.bidTokenAmount) : false;
|
|
5550
|
+
const solShort = cost ? !cost.sufficient : false;
|
|
5551
|
+
const reset = useCallback(() => {
|
|
5552
|
+
setSignature(null);
|
|
5553
|
+
setLastTxEntry(null);
|
|
5554
|
+
setSent(null);
|
|
5555
|
+
setProgress(null);
|
|
5556
|
+
setNonce((n) => n + 1);
|
|
5557
|
+
}, []);
|
|
5558
|
+
return { status, preview, plan, error, balanceRaw, cost, progress, signature, lastTxEntry, sent, addressed, needsPreparation, insufficient, solShort, run, reset };
|
|
5559
|
+
}
|
|
4799
5560
|
function QuoteSheet(props) {
|
|
4800
5561
|
const sheetRef = useRef(null);
|
|
4801
5562
|
const onCloseRef = useRef(props.onClose);
|
|
@@ -4904,7 +5665,7 @@ function ExchangeCard(props) {
|
|
|
4904
5665
|
useEffect(() => {
|
|
4905
5666
|
if (isPill) return;
|
|
4906
5667
|
let alive = true;
|
|
4907
|
-
engine.fetchCatalogue(allowed, product).then((next) => {
|
|
5668
|
+
engine.fetchCatalogue(allowed, product, { solanaSources: true }).then((next) => {
|
|
4908
5669
|
if (alive) setCatalogue(next);
|
|
4909
5670
|
});
|
|
4910
5671
|
return () => {
|
|
@@ -4937,6 +5698,16 @@ function ExchangeCard(props) {
|
|
|
4937
5698
|
() => props.defaultToChainId && props.defaultToAsset ? { chainId: props.defaultToChainId, symbol: symbolKey(props.defaultToAsset) } : null
|
|
4938
5699
|
);
|
|
4939
5700
|
const [amount, setAmount] = useState(props.defaultAmount ?? "");
|
|
5701
|
+
const solanaWallet = useSolanaWallet();
|
|
5702
|
+
const [payerChooser, setPayerChooser] = useState(false);
|
|
5703
|
+
const sourceIsSolana = isSolanaChainId(from?.chainId);
|
|
5704
|
+
const recipientState = useRecipient(to?.chainId ?? null, props.recipient, {
|
|
5705
|
+
solanaWallet,
|
|
5706
|
+
sourceIsSolana,
|
|
5707
|
+
evm: { account: wallet.account, connect: wallet.connect, connecting: wallet.connecting }
|
|
5708
|
+
});
|
|
5709
|
+
const recipient = recipientState.recipient;
|
|
5710
|
+
const needsRecipient = recipientState.missing || !!recipientState.error;
|
|
4940
5711
|
const onInputChange = useRef(props.onInputChange);
|
|
4941
5712
|
onInputChange.current = props.onInputChange;
|
|
4942
5713
|
const fromChainId = from?.chainId ?? null;
|
|
@@ -5032,7 +5803,7 @@ function ExchangeCard(props) {
|
|
|
5032
5803
|
if (id === balReq.current) setBalances(res);
|
|
5033
5804
|
});
|
|
5034
5805
|
}, [engine, wallet.account, tokens]);
|
|
5035
|
-
const
|
|
5806
|
+
const evmFromBal = from && fromToken ? balances[balanceKey(from.chainId, fromToken.address)] : void 0;
|
|
5036
5807
|
const [prices, setPrices] = useState({});
|
|
5037
5808
|
useEffect(() => {
|
|
5038
5809
|
if (isPill) return;
|
|
@@ -5046,24 +5817,47 @@ function ExchangeCard(props) {
|
|
|
5046
5817
|
alive = false;
|
|
5047
5818
|
};
|
|
5048
5819
|
}, [engine, from?.symbol, to?.symbol, isPill]);
|
|
5049
|
-
const paramsKey = `${mode}|${from?.chainId}|${from?.symbol}|${to?.chainId}|${toSymbol}|${normalizedAmount}|${
|
|
5820
|
+
const paramsKey = `${mode}|${from?.chainId}|${from?.symbol}|${to?.chainId}|${toSymbol}|${normalizedAmount}|${recipient ?? ""}`;
|
|
5050
5821
|
const flow = useFlow({
|
|
5051
5822
|
engine,
|
|
5052
5823
|
wallet,
|
|
5053
5824
|
kind: "swap",
|
|
5054
|
-
enabled: quotable && !isPill,
|
|
5825
|
+
enabled: quotable && !isPill && !needsRecipient && !sourceIsSolana,
|
|
5055
5826
|
paramsKey,
|
|
5056
|
-
loadPlan: (e, payer) => e.buildSwapPlan({ fromChainId: from.chainId, toChainId: to.chainId, fromToken: from.symbol, toToken: to.symbol, amountIn: normalizedAmount, recipient
|
|
5057
|
-
recipientFor:
|
|
5827
|
+
loadPlan: (e, payer) => e.buildSwapPlan({ fromChainId: from.chainId, toChainId: to.chainId, fromToken: from.symbol, toToken: to.symbol, amountIn: normalizedAmount, recipient }, payer),
|
|
5828
|
+
recipientFor: recipientState.recipientFor,
|
|
5058
5829
|
onQuote: config.onQuote,
|
|
5059
5830
|
onSuccess: config.onSuccess,
|
|
5060
5831
|
onError: config.onError
|
|
5061
5832
|
});
|
|
5833
|
+
const solActive = sourceIsSolana && !isPill && !rampMode;
|
|
5834
|
+
const solFlow = useSolanaSourceFlow({
|
|
5835
|
+
engine,
|
|
5836
|
+
enabled: solActive && quotable && !recipientState.error,
|
|
5837
|
+
fromSymbol: from?.symbol ?? null,
|
|
5838
|
+
fromMint: fromToken?.address ?? null,
|
|
5839
|
+
toChainId: to?.chainId ?? null,
|
|
5840
|
+
toSymbol: to ? toSymbol : null,
|
|
5841
|
+
amount: normalizedAmount,
|
|
5842
|
+
owner: wallet.account,
|
|
5843
|
+
payer: solanaWallet.address,
|
|
5844
|
+
recipient,
|
|
5845
|
+
signer: () => {
|
|
5846
|
+
const info = solanaWallet.wallets.find((w) => normalizeSolanaWalletName(w.name) === normalizeSolanaWalletName(solanaWallet.walletName ?? ""));
|
|
5847
|
+
if (!info) throw new Error("Connect a Solana wallet to pay from Solana.");
|
|
5848
|
+
return solanaWalletSigner(info);
|
|
5849
|
+
},
|
|
5850
|
+
chainName: "Solana",
|
|
5851
|
+
fromTicker,
|
|
5852
|
+
toTicker,
|
|
5853
|
+
onError: config.onError
|
|
5854
|
+
});
|
|
5855
|
+
const fromBal = solActive ? solFlow.balanceRaw !== void 0 && fromToken ? { ...evmFromBal, raw: solFlow.balanceRaw.toString(), formatted: formatUnits(solFlow.balanceRaw, assetDecimals(fromToken)) } : void 0 : evmFromBal;
|
|
5062
5856
|
const [preview, setPreview] = useState({ status: "idle" });
|
|
5063
5857
|
const { idle: idle2, returnedAt: returnedAt2 } = useUserPresence();
|
|
5064
5858
|
const prevReq = useRef(0);
|
|
5065
5859
|
useEffect(() => {
|
|
5066
|
-
if (isPill || wallet.account || !quotable) {
|
|
5860
|
+
if (isPill || sourceIsSolana || wallet.account && !needsRecipient || !quotable) {
|
|
5067
5861
|
prevReq.current += 1;
|
|
5068
5862
|
setPreview({ status: "idle" });
|
|
5069
5863
|
return;
|
|
@@ -5071,23 +5865,28 @@ function ExchangeCard(props) {
|
|
|
5071
5865
|
const id = ++prevReq.current;
|
|
5072
5866
|
setPreview({ status: "loading" });
|
|
5073
5867
|
const timer2 = setTimeout(() => {
|
|
5074
|
-
engine.quoteSwapPreview({ fromChainId: from.chainId, toChainId: to.chainId, fromToken: from.symbol, toToken: to.symbol, amountIn: normalizedAmount, recipient
|
|
5868
|
+
engine.quoteSwapPreview({ fromChainId: from.chainId, toChainId: to.chainId, fromToken: from.symbol, toToken: to.symbol, amountIn: normalizedAmount, recipient }, wallet.account ?? void 0).then((data) => {
|
|
5075
5869
|
if (id === prevReq.current) setPreview({ status: "ready", data });
|
|
5076
5870
|
}).catch((e) => {
|
|
5077
5871
|
if (id === prevReq.current) setPreview({ status: "error", error: e instanceof Error ? e.message : String(e), fieldError: amountFieldError(e) });
|
|
5078
5872
|
});
|
|
5079
5873
|
}, 350);
|
|
5080
5874
|
return () => clearTimeout(timer2);
|
|
5081
|
-
}, [engine, wallet.account, quotable, paramsKey, returnedAt2]);
|
|
5082
|
-
const
|
|
5083
|
-
const
|
|
5875
|
+
}, [engine, wallet.account, quotable, paramsKey, returnedAt2, needsRecipient, sourceIsSolana]);
|
|
5876
|
+
const connected2 = Boolean(wallet.account);
|
|
5877
|
+
const addressed = connected2 && !needsRecipient;
|
|
5878
|
+
const submitting = solActive ? solFlow.status === "preparing" || solFlow.status === "submitting" : flow.status === "submitting";
|
|
5084
5879
|
const lastTxOwned = Boolean(flow.lastTxEntry?.hash && wallet.account && flow.lastTxEntry.account === wallet.account.toLowerCase());
|
|
5085
|
-
const
|
|
5086
|
-
const
|
|
5087
|
-
const
|
|
5880
|
+
const evmDirect = flow.lastTxEntry?.settlement === "direct";
|
|
5881
|
+
const evmConfirmed = flow.verdict?.status === "confirmed";
|
|
5882
|
+
const evmDelivery = useDelivery(engine, (flow.status === "success" || flow.status === "pending") && !evmDirect ? flow.txHash : null);
|
|
5883
|
+
const solDelivery = useDelivery(engine, solActive && solFlow.status === "sent" ? solFlow.signature : null);
|
|
5884
|
+
const quoting = solActive ? solFlow.status === "quoting" : addressed ? flow.status === "loading" : preview.status === "loading";
|
|
5885
|
+
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;
|
|
5886
|
+
const gatewayAmountError = !quoteError || solActive ? null : addressed ? flow.fieldError : preview.fieldError ?? null;
|
|
5088
5887
|
const amountError = overLimit && laneLimit ? laneLimitError(laneLimit, limitSymbol) : gatewayAmountError;
|
|
5089
5888
|
const amountNote = mode === "exchange" ? amountError || (laneLimit ? laneLimitHint(laneLimit, limitSymbol) : null) : null;
|
|
5090
|
-
const receive =
|
|
5889
|
+
const receive = solActive ? solFlow.preview?.receive : addressed ? flow.selected?.receive.amount : preview.data?.receive;
|
|
5091
5890
|
const receiveOutRef = useRef(null);
|
|
5092
5891
|
const receiveSideRef = useRef(null);
|
|
5093
5892
|
const receiveShown = `${receive ?? ""}|${quoting}|${toTicker}`;
|
|
@@ -5100,7 +5899,7 @@ function ExchangeCard(props) {
|
|
|
5100
5899
|
return void 0;
|
|
5101
5900
|
}
|
|
5102
5901
|
}, [toToken]);
|
|
5103
|
-
const meta =
|
|
5902
|
+
const meta = solActive ? solFlow.preview ? { bridge: solFlow.preview.bridge || "ZeroDelta", feeBps: solFlow.preview.feeBps, duration: solFlow.preview.estimatedDuration } : null : addressed ? flow.selected ? { bridge: flow.selected.quote.bridge || "ZeroDelta", feeBps: Number(flow.selected.quote.feeBps || 0), duration: Number(flow.selected.quote.estimatedDuration || 0) } : null : preview.data ? { bridge: preview.data.bridge || "ZeroDelta", feeBps: preview.data.feeBps, duration: preview.data.estimatedDuration } : null;
|
|
5104
5903
|
const pct = (p) => {
|
|
5105
5904
|
if (!fromBal || !fromToken) return;
|
|
5106
5905
|
const raw = BigInt(fromBal.raw);
|
|
@@ -5108,9 +5907,9 @@ function ExchangeCard(props) {
|
|
|
5108
5907
|
};
|
|
5109
5908
|
const title = config.title || (mode === "onramp" ? "Buy stablecoins" : mode === "offramp" ? "Cash out" : "Exchange");
|
|
5110
5909
|
const soonLabel = mode === "onramp" ? "On-ramp coming soon" : "Off-ramp coming soon";
|
|
5111
|
-
const quotePaused =
|
|
5112
|
-
const ctaLabel = rampMode ? soonLabel : submitting ? "Exchanging\u2026" :
|
|
5113
|
-
const selected =
|
|
5910
|
+
const quotePaused = solActive ? false : addressed ? flow.quotePaused : idle2 && preview.status === "ready";
|
|
5911
|
+
const ctaLabel = rampMode ? soonLabel : submitting ? "Exchanging\u2026" : connected2 && flow.quoteStale ? flow.quotePaused ? "Refresh quote" : "Refreshing quote\u2026" : flow.insufficient ? "Insufficient balance" : flow.nativeShortfall || "Exchange";
|
|
5912
|
+
const selected = addressed ? flow.selected : null;
|
|
5114
5913
|
const hasQuote = Boolean(quotable && !quoting && !quoteError && receive);
|
|
5115
5914
|
const nativeWei = (() => {
|
|
5116
5915
|
try {
|
|
@@ -5120,14 +5919,14 @@ function ExchangeCard(props) {
|
|
|
5120
5919
|
return 0n;
|
|
5121
5920
|
}
|
|
5122
5921
|
})();
|
|
5123
|
-
const networkFee = nativeWei > 0n ? `~${formatNative(nativeWei)} ${nativeSymbol(from?.chainId ?? 1, chains)}` : "Gas only";
|
|
5922
|
+
const networkFee = solActive ? solFlow.cost ? `~${(solFlow.cost.lamports / 1e9).toFixed(6)} SOL` : "Paid in SOL" : nativeWei > 0n ? `~${formatNative(nativeWei)} ${nativeSymbol(from?.chainId ?? 1, chains)}` : "Gas only";
|
|
5124
5923
|
const eta = durationLabel(meta?.duration);
|
|
5125
5924
|
const rate = hasQuote && receive && Number(normalizedAmount) > 0 ? (Number(receive) / Number(normalizedAmount)).toFixed(6) : null;
|
|
5126
5925
|
const rateRows = hasQuote ? [{ label: "Network fee", value: networkFee }, ...eta ? [{ label: "Estimated time", value: eta }] : []] : [];
|
|
5127
5926
|
const via = selected ? selected.legs.length > 1 ? selected.legs[0]?.toTicker || selected.legs[0]?.toAsset || "" : null : preview.data?.via ?? null;
|
|
5128
5927
|
const routeShape = via === null ? "Direct" : via ? `Via ${via}` : "Two steps";
|
|
5129
|
-
const compliance = selected?.quote.compliance;
|
|
5130
|
-
const complianceHasQuote = Boolean(selected && flow.status !== "loading");
|
|
5928
|
+
const compliance = solActive ? solanaQuoteCompliance(solFlow.plan?.preview.quote) : selected?.quote.compliance;
|
|
5929
|
+
const complianceHasQuote = solActive ? Boolean(solFlow.plan && solFlow.status !== "quoting") : Boolean(selected && flow.status !== "loading");
|
|
5131
5930
|
const fromUsd = usdOf2(normalizedAmount, prices[from?.symbol ?? ""]);
|
|
5132
5931
|
const toUsd = usdOf2(receive, prices[to?.symbol ?? ""]);
|
|
5133
5932
|
const flippable = !rampMode && !submitting && Boolean(to && sourceTokens.some((t) => Number(t.chainId) === to.chainId && symbolKey(t.symbol) === to.symbol));
|
|
@@ -5137,8 +5936,8 @@ function ExchangeCard(props) {
|
|
|
5137
5936
|
setTo(from);
|
|
5138
5937
|
};
|
|
5139
5938
|
const walletSlot = /* @__PURE__ */ jsxs("div", { className: "sg-head-tools", children: [
|
|
5140
|
-
|
|
5141
|
-
/* @__PURE__ */ jsx("button", { type: "button", className: "sg-wallet", "data-connected":
|
|
5939
|
+
connected2 ? /* @__PURE__ */ jsx(HistoryButton, { btnRef: histBtnRef, disabled: submitting, onClick: () => setHist({}) }) : null,
|
|
5940
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "sg-wallet", "data-connected": connected2 || void 0, onClick: connected2 ? void 0 : wallet.connect, disabled: wallet.connecting, children: connected2 ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5142
5941
|
/* @__PURE__ */ jsx("span", { className: "sg-wallet-dot", "aria-hidden": "true" }),
|
|
5143
5942
|
" ",
|
|
5144
5943
|
shortAddress(wallet.account)
|
|
@@ -5186,7 +5985,7 @@ function ExchangeCard(props) {
|
|
|
5186
5985
|
}
|
|
5187
5986
|
);
|
|
5188
5987
|
const rateBox = (open) => /* @__PURE__ */ jsx(RateBox, { rate, fromSymbol: from?.symbol ?? "", fromLogoUrl: fromToken?.logoUrl, toTicker, rows: rateRows, defaultOpen: open, paused: quotePaused });
|
|
5189
|
-
const sheetBody = sheet === "compliance" ? /* @__PURE__ */ jsx(ComplianceSheet, { compliance, direct: selected?.state === "DIRECT", hasQuote: complianceHasQuote, onClose: closeSheet }) : sheet === "quote" && hasQuote ? /* @__PURE__ */ jsx(
|
|
5988
|
+
const sheetBody = recipientState.open ? /* @__PURE__ */ jsx(RecipientSheet, { state: recipientState, symbol: toTicker }) : sheet === "compliance" ? /* @__PURE__ */ jsx(ComplianceSheet, { compliance, direct: selected?.state === "DIRECT", hasQuote: complianceHasQuote, onClose: closeSheet }) : sheet === "quote" && hasQuote ? /* @__PURE__ */ jsx(
|
|
5190
5989
|
QuoteSheet,
|
|
5191
5990
|
{
|
|
5192
5991
|
onClose: closeSheet,
|
|
@@ -5203,9 +6002,41 @@ function ExchangeCard(props) {
|
|
|
5203
6002
|
legs: selected && selected.legs.length > 1 ? selected.legs : void 0
|
|
5204
6003
|
}
|
|
5205
6004
|
) : null;
|
|
6005
|
+
const connectPayer = async () => {
|
|
6006
|
+
const result = await solanaWallet.connect();
|
|
6007
|
+
setPayerChooser(Array.isArray(result) && result.length > 1);
|
|
6008
|
+
};
|
|
6009
|
+
const solanaCta = !solanaWallet.address ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6010
|
+
/* @__PURE__ */ jsx(Button, { onClick: () => void connectPayer(), busy: solanaWallet.status === "connecting", children: "Connect Solana wallet" }),
|
|
6011
|
+
payerChooser ? solanaWallet.wallets.map((w) => /* @__PURE__ */ jsx(Button, { variant: "ghost", onClick: () => void solanaWallet.connect(w.name).then(() => setPayerChooser(false)), disabled: solanaWallet.status === "connecting", children: w.name }, w.name)) : null,
|
|
6012
|
+
!solanaWallet.wallets.length ? /* @__PURE__ */ jsx("p", { className: "sg-cp-summary-sub", children: "No Solana wallet found. Install Phantom, Solflare or Backpack to pay from Solana." }) : null
|
|
6013
|
+
] }) : !connected2 ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6014
|
+
/* @__PURE__ */ jsx(Button, { onClick: wallet.connect, busy: wallet.connecting, children: "Connect EVM wallet" }),
|
|
6015
|
+
/* @__PURE__ */ jsx("p", { className: "sg-cp-summary-sub", style: { textAlign: "center", margin: "8px 0 0" }, children: "Your EVM wallet owns the order and can cancel it." })
|
|
6016
|
+
] }) : recipientState.missing ? /* @__PURE__ */ jsxs(Button, { onClick: () => void recipientState.connect(), busy: recipientState.familyWallet.connecting, children: [
|
|
6017
|
+
"Connect ",
|
|
6018
|
+
recipientState.recipientFamily === "solana" ? "Solana" : "EVM",
|
|
6019
|
+
" wallet"
|
|
6020
|
+
] }) : /* @__PURE__ */ jsx(
|
|
6021
|
+
Button,
|
|
6022
|
+
{
|
|
6023
|
+
onClick: solFlow.run,
|
|
6024
|
+
busy: submitting,
|
|
6025
|
+
disabled: !quotable || !cryptoReady || !!recipientState.error || !solFlow.plan || solFlow.insufficient || solFlow.solShort || solFlow.status === "quoting",
|
|
6026
|
+
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"
|
|
6027
|
+
}
|
|
6028
|
+
);
|
|
6029
|
+
const solanaSteps = solActive && solFlow.plan && connected2 && solanaWallet.address && solFlow.solShort && solFlow.cost ? /* @__PURE__ */ jsxs("p", { className: "sg-cp-summary-sub", style: { textAlign: "center", margin: "0 0 8px" }, "data-testid": "sol-shortfall", children: [
|
|
6030
|
+
"This order needs about ",
|
|
6031
|
+
(solFlow.cost.lamports / 1e9).toFixed(4),
|
|
6032
|
+
" SOL for network fees and rent; the wallet holds",
|
|
6033
|
+
" ",
|
|
6034
|
+
(solFlow.cost.balanceLamports / 1e9).toFixed(4),
|
|
6035
|
+
" SOL."
|
|
6036
|
+
] }) : null;
|
|
5206
6037
|
let body;
|
|
5207
|
-
if (hist &&
|
|
5208
|
-
body = /* @__PURE__ */ jsx(TxHistoryPanel, { account: wallet.account, tokens, vaultIcons: catalogue?.vaultIcons, initialEntry: hist.entry ?? null, onBack: closeHistory });
|
|
6038
|
+
if (hist && connected2) {
|
|
6039
|
+
body = /* @__PURE__ */ jsx(TxHistoryPanel, { account: wallet.account, engine, solanaAccount: solanaWallet.address, tokens, vaultIcons: catalogue?.vaultIcons, initialEntry: hist.entry ?? null, onBack: closeHistory });
|
|
5209
6040
|
} else if (view === "from" || view === "to") {
|
|
5210
6041
|
const isFrom = view === "from";
|
|
5211
6042
|
body = /* @__PURE__ */ jsx(
|
|
@@ -5229,19 +6060,41 @@ function ExchangeCard(props) {
|
|
|
5229
6060
|
);
|
|
5230
6061
|
} else if (sheetBody && !wide) {
|
|
5231
6062
|
body = sheetBody;
|
|
6063
|
+
} else if (solActive && solFlow.status === "sent") {
|
|
6064
|
+
body = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6065
|
+
/* @__PURE__ */ jsxs("div", { className: "sg-success", children: [
|
|
6066
|
+
/* @__PURE__ */ jsx("div", { className: "sg-success-check", "data-pending": !isDelivered(solDelivery, false), children: /* @__PURE__ */ jsx(CheckGlyph5, {}) }),
|
|
6067
|
+
/* @__PURE__ */ jsxs("div", { className: "sg-success-amt sg-mono", children: [
|
|
6068
|
+
solFlow.sent?.receive ?? receive,
|
|
6069
|
+
" ",
|
|
6070
|
+
solFlow.sent?.toTicker ?? toTicker
|
|
6071
|
+
] }),
|
|
6072
|
+
/* @__PURE__ */ jsxs("div", { className: "sg-success-sub", role: "status", "aria-live": "polite", children: [
|
|
6073
|
+
solDelivery.phase === "tracking" ? "Submitted on Solana \u2014 tracking delivery" : deliveryHeadline(solDelivery, true),
|
|
6074
|
+
solFlow.sent?.recipient ? ` \xB7 ${shortAddress(solFlow.sent.recipient)}` : ""
|
|
6075
|
+
] }),
|
|
6076
|
+
/* @__PURE__ */ jsx(DeliverySteps, { delivery: solDelivery })
|
|
6077
|
+
] }),
|
|
6078
|
+
/* @__PURE__ */ jsxs("div", { className: "sg-cta-wrap", children: [
|
|
6079
|
+
solFlow.signature ? /* @__PURE__ */ 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,
|
|
6080
|
+
solFlow.lastTxEntry && connected2 ? /* @__PURE__ */ jsx(Button, { variant: "ghost", onClick: () => setHist({ entry: solFlow.lastTxEntry }), children: "View transaction" }) : null,
|
|
6081
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", onClick: solFlow.reset, children: "Start a new exchange" })
|
|
6082
|
+
] })
|
|
6083
|
+
] });
|
|
5232
6084
|
} else if (flow.status === "success" || flow.status === "pending") {
|
|
5233
6085
|
body = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5234
6086
|
/* @__PURE__ */ jsxs("div", { className: "sg-success", children: [
|
|
5235
|
-
/* @__PURE__ */ jsx("div", { className: "sg-success-check", "data-pending":
|
|
6087
|
+
/* @__PURE__ */ jsx("div", { className: "sg-success-check", "data-pending": !isDelivered(evmDelivery, evmConfirmed, evmDirect), children: /* @__PURE__ */ jsx(CheckGlyph5, {}) }),
|
|
5236
6088
|
/* @__PURE__ */ jsxs("div", { className: "sg-success-amt sg-mono", children: [
|
|
5237
6089
|
receive,
|
|
5238
6090
|
" ",
|
|
5239
6091
|
toTicker
|
|
5240
6092
|
] }),
|
|
5241
|
-
/* @__PURE__ */ jsxs("div", { className: "sg-success-sub", children: [
|
|
5242
|
-
|
|
5243
|
-
props.recipient ? ` \xB7 ${shortAddress(props.recipient)}` : ""
|
|
5244
|
-
] })
|
|
6093
|
+
/* @__PURE__ */ jsxs("div", { className: "sg-success-sub", role: "status", "aria-live": "polite", children: [
|
|
6094
|
+
deliveryHeadline(evmDelivery, evmConfirmed, evmDirect),
|
|
6095
|
+
recipientState.recipientFamily === "solana" ? ` \xB7 ${shortAddress(flow.lastTxEntry?.recipient || recipient)}` : props.recipient ? ` \xB7 ${shortAddress(props.recipient)}` : ""
|
|
6096
|
+
] }),
|
|
6097
|
+
evmDirect ? null : /* @__PURE__ */ jsx(DeliverySteps, { delivery: evmDelivery })
|
|
5245
6098
|
] }),
|
|
5246
6099
|
/* @__PURE__ */ jsxs("div", { className: "sg-cta-wrap", children: [
|
|
5247
6100
|
lastTxOwned ? /* @__PURE__ */ jsx(Button, { variant: "ghost", onClick: () => setHist({ entry: flow.lastTxEntry }), children: "View transaction" }) : null,
|
|
@@ -5251,8 +6104,19 @@ function ExchangeCard(props) {
|
|
|
5251
6104
|
} else {
|
|
5252
6105
|
const payToken = mode === "onramp" ? /* @__PURE__ */ jsx(FiatButton, { fiat, onCurrency: setFiatCurrency, disabled: submitting }) : /* @__PURE__ */ jsx(TokenButton, { label: "You pay", symbol: from?.symbol ?? null, chainId: from?.chainId ?? null, token: fromToken, disabled: submitting, btnRef: fromTileRef, onClick: () => setView("from") });
|
|
5253
6106
|
const receiveToken = mode === "offramp" ? /* @__PURE__ */ jsx(FiatButton, { fiat, onCurrency: setFiatCurrency, disabled: submitting }) : /* @__PURE__ */ jsx(TokenButton, { label: "You receive", symbol: to?.symbol ?? null, chainId: to?.chainId ?? null, token: toToken, disabled: submitting, btnRef: toTileRef, onClick: () => setView("to") });
|
|
5254
|
-
const cta = /* @__PURE__ */ jsxs("div", { className: "sg-cta-wrap", children: [
|
|
5255
|
-
|
|
6107
|
+
const cta = solActive ? /* @__PURE__ */ jsxs("div", { className: "sg-cta-wrap", children: [
|
|
6108
|
+
solanaSteps,
|
|
6109
|
+
solanaCta,
|
|
6110
|
+
/* @__PURE__ */ jsx(RecipientNote, { state: recipientState, disabled: submitting }),
|
|
6111
|
+
solanaWallet.error ? /* @__PURE__ */ jsx(StatusPanel, { tone: "error", children: solanaWallet.error }) : null,
|
|
6112
|
+
wallet.error ? /* @__PURE__ */ jsx(StatusPanel, { tone: "error", children: wallet.error }) : null
|
|
6113
|
+
] }) : /* @__PURE__ */ jsxs("div", { className: "sg-cta-wrap", children: [
|
|
6114
|
+
!connected2 && !rampMode ? /* @__PURE__ */ jsx(Button, { onClick: wallet.connect, busy: wallet.connecting, children: "Connect wallet" }) : recipientState.missing && !rampMode && !submitting ? /* @__PURE__ */ jsxs(Button, { onClick: () => void recipientState.connect(), busy: recipientState.wallet.status === "connecting", children: [
|
|
6115
|
+
"Connect ",
|
|
6116
|
+
recipientState.recipientFamily === "solana" ? "Solana" : "EVM",
|
|
6117
|
+
" wallet"
|
|
6118
|
+
] }) : /* @__PURE__ */ jsx(Button, { onClick: rampMode ? void 0 : flow.submit, busy: submitting, disabled: needsRecipient || rampMode || !quotable || !cryptoReady || connected2 && (!flow.selected || flow.insufficient || !!flow.nativeShortfall || flow.status === "loading"), children: ctaLabel }),
|
|
6119
|
+
!rampMode ? /* @__PURE__ */ jsx(RecipientNote, { state: recipientState, disabled: submitting }) : null,
|
|
5256
6120
|
wallet.error ? /* @__PURE__ */ jsx(StatusPanel, { tone: "error", children: wallet.error }) : null
|
|
5257
6121
|
] });
|
|
5258
6122
|
const notices = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -5401,4 +6265,4 @@ function mount(el, config) {
|
|
|
5401
6265
|
return () => root.unmount();
|
|
5402
6266
|
}
|
|
5403
6267
|
|
|
5404
|
-
export { CompliancePanel, PaymentIsland, StableGenieExchange, StableGeniePay, StableGenieProvider, StableGenieRwaExchange, StableGenieSwap, darkTheme, lightTheme, mount, resolveTheme };
|
|
6268
|
+
export { CompliancePanel, PaymentIsland, StableGenieExchange, StableGeniePay, StableGenieProvider, StableGenieRwaExchange, StableGenieSwap, connectSolanaWallet, darkTheme, disconnectSolanaWallet, discoverSolanaWallets, lightTheme, mount, onSolanaAccountChange, resolveTheme, solanaWalletSigner, useSolanaWallet, watchSolanaWallets };
|