@glacislabs/stablegenie-zerodelta 4.12.0 → 4.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { CHAIN_DISPLAY_NAMES, EXECUTABLE_STABLE_ASSETS, STABLE_ASSETS, SUPPORTED_ASSETS, complianceView, complianceTagOf, symbolKey, normalizeDecimalText, findToken, laneLimitFor, laneLimitSymbol, tokenTicker, exceedsLaneLimit, assetDecimals, parseUnitsDecimal, counterpartTokens, assetClassOf, brokenLaneFor, brokenLaneReason, destinationAvailability, laneLimitHint, tickerOn, laneLimitError, routeNativeValue, formatNative, nativeSymbol, amountFieldError, SUPPORTED_CHAIN_IDS, formatUnits, complianceChecks, DIRECT_CHECK_IDS, createEngine, checkNativeFee, nativeFeeShortLabel, nativeFeeShortMessage, allowanceCovers, validatePlannedTransaction, unattributedComplianceReasons, distinctScreenedWallets, formatJurisdiction, humanizeComplianceReason, DIRECT_SCOPE_NOTE, categoryLabel, SCREENING_BUCKETS, BUNDLED_RPC, foldTicker } from './chunk-A7ADZJXA.js';
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, SUPPORTED_CHAIN_IDS, complianceChecks, DIRECT_CHECK_IDS, isSolanaAddress, createEngine, isAddress, checkNativeFee, nativeFeeShortLabel, nativeFeeShortMessage, allowanceCovers, validatePlannedTransaction, solanaPlanNeedsPreparation, SOLANA_CHAIN_ID, unattributedComplianceReasons, distinctScreenedWallets, formatJurisdiction, humanizeComplianceReason, DIRECT_SCOPE_NOTE, categoryLabel, SCREENING_BUCKETS, BUNDLED_RPC, foldTicker } from './chunk-52MY5D3D.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';
@@ -1811,7 +1811,7 @@ function RouteList(props) {
1811
1811
  visible.map((r) => {
1812
1812
  const selected = props.selectedId === r.id;
1813
1813
  const bal = props.balances?.[routeBalanceKey(r)];
1814
- const short = props.shortIds?.has(r.id) ?? false;
1814
+ const short2 = props.shortIds?.has(r.id) ?? false;
1815
1815
  const held = props.heldIds?.has(r.id) ?? false;
1816
1816
  return (
1817
1817
  // a11y note: a native radio cannot contain the rich
@@ -1823,7 +1823,7 @@ function RouteList(props) {
1823
1823
  {
1824
1824
  className: "sg-route-item",
1825
1825
  "data-selected": selected,
1826
- "data-short": short || void 0,
1826
+ "data-short": short2 || void 0,
1827
1827
  "data-held": held || void 0,
1828
1828
  role: "radio",
1829
1829
  "aria-checked": selected,
@@ -1858,7 +1858,7 @@ function RouteList(props) {
1858
1858
  "bal ",
1859
1859
  bal.formatted
1860
1860
  ] }) : null,
1861
- short ? /* @__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,
1861
+ 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
1862
  /* @__PURE__ */ jsx("span", { className: "sg-radio", "aria-hidden": "true" })
1863
1863
  ] })
1864
1864
  ]
@@ -3254,6 +3254,444 @@ function TxHistoryPanel(props) {
3254
3254
  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
3255
  ] });
3256
3256
  }
3257
+
3258
+ // src/provider/solana-wallet.ts
3259
+ var sources = /* @__PURE__ */ new WeakMap();
3260
+ var infos = /* @__PURE__ */ new WeakMap();
3261
+ var connected = /* @__PURE__ */ new WeakMap();
3262
+ var registries = /* @__PURE__ */ new WeakMap();
3263
+ var EMPTY = Object.freeze([]);
3264
+ function normalizeSolanaWalletName(name) {
3265
+ return name.trim().toLowerCase().replace(/\s+(wallet|evm|solana)$/i, "");
3266
+ }
3267
+ function solanaWalletInfo(provider) {
3268
+ const standard = "features" in provider;
3269
+ if (standard ? !provider.chains?.some((chain) => chain.startsWith("solana:")) || typeof provider.features?.["standard:connect"]?.connect !== "function" : typeof provider.connect !== "function") return null;
3270
+ let info = infos.get(provider);
3271
+ if (!info) {
3272
+ const name = provider.name || (!standard && provider.isPhantom ? "Phantom" : !standard && provider.isSolflare ? "Solflare" : "Solana wallet");
3273
+ info = Object.freeze({ name, icon: standard ? provider.icon : void 0, kind: standard ? "standard" : "legacy" });
3274
+ infos.set(provider, info);
3275
+ sources.set(info, provider);
3276
+ }
3277
+ return info;
3278
+ }
3279
+ function targetWindow(win) {
3280
+ return win ?? (typeof window === "undefined" ? void 0 : window);
3281
+ }
3282
+ function registry(win) {
3283
+ const existing = registries.get(win);
3284
+ if (existing) return existing;
3285
+ const standard = /* @__PURE__ */ new Set();
3286
+ const listeners = /* @__PURE__ */ new Set();
3287
+ let snapshot = EMPTY;
3288
+ const read = () => {
3289
+ const candidates = [...standard].map(solanaWalletInfo);
3290
+ for (const [provider, name] of [[win.phantom?.solana, "Phantom"], [win.solflare, "Solflare"], [win.solana, void 0]]) {
3291
+ if (!provider || typeof provider.connect !== "function") continue;
3292
+ let info = solanaWalletInfo(provider);
3293
+ if (info && name && info.name === "Solana wallet") {
3294
+ info = Object.freeze({ ...info, name });
3295
+ infos.set(provider, info);
3296
+ sources.set(info, provider);
3297
+ }
3298
+ candidates.push(info);
3299
+ }
3300
+ const names = /* @__PURE__ */ new Set();
3301
+ const providers = /* @__PURE__ */ new Set();
3302
+ const next = candidates.filter((info) => {
3303
+ if (!info) return false;
3304
+ const name = normalizeSolanaWalletName(info.name);
3305
+ const provider = sources.get(info);
3306
+ if (names.has(name) || providers.has(provider)) return false;
3307
+ names.add(name);
3308
+ providers.add(provider);
3309
+ return true;
3310
+ });
3311
+ if (next.length !== snapshot.length || next.some((info) => !snapshot.includes(info))) snapshot = Object.freeze(next);
3312
+ return snapshot;
3313
+ };
3314
+ const refresh = () => {
3315
+ const previous = snapshot;
3316
+ read();
3317
+ if (previous !== snapshot) for (const cb of listeners) cb();
3318
+ };
3319
+ const api = {
3320
+ register(...wallets) {
3321
+ const added = wallets.filter((wallet) => !standard.has(wallet));
3322
+ for (const wallet of added) standard.add(wallet);
3323
+ refresh();
3324
+ return () => {
3325
+ for (const wallet of added) standard.delete(wallet);
3326
+ refresh();
3327
+ };
3328
+ }
3329
+ };
3330
+ const result = { read, watch: (cb) => {
3331
+ listeners.add(cb);
3332
+ return () => {
3333
+ listeners.delete(cb);
3334
+ };
3335
+ } };
3336
+ registries.set(win, result);
3337
+ win.addEventListener("wallet-standard:register-wallet", (event) => {
3338
+ const callback = event.detail;
3339
+ if (typeof callback === "function") callback(api);
3340
+ });
3341
+ win.addEventListener("focus", refresh);
3342
+ const EventClass = win.CustomEvent;
3343
+ win.dispatchEvent(new EventClass("wallet-standard:app-ready", { detail: api }));
3344
+ read();
3345
+ return result;
3346
+ }
3347
+ function discoverSolanaWallets(win) {
3348
+ const target = targetWindow(win);
3349
+ return target ? registry(target).read() : EMPTY;
3350
+ }
3351
+ function watchSolanaWallets(cb, win) {
3352
+ const target = targetWindow(win);
3353
+ if (!target) return () => {
3354
+ };
3355
+ const store = registry(target);
3356
+ const unsubscribe = store.watch(() => cb(store.read()));
3357
+ cb(store.read());
3358
+ return unsubscribe;
3359
+ }
3360
+ function source(info) {
3361
+ const provider = sources.get(info);
3362
+ if (!provider) throw new Error("Solana wallet is no longer available. Discover it before connecting.");
3363
+ return provider;
3364
+ }
3365
+ function validAddress(value) {
3366
+ const address = value?.toString().trim();
3367
+ return address && isSolanaAddress(address) ? address : null;
3368
+ }
3369
+ function accountAddress(accounts) {
3370
+ const account = accounts?.find((item) => !item.chains?.length || item.chains.some((chain) => chain.startsWith("solana:")));
3371
+ return validAddress(account?.address);
3372
+ }
3373
+ function connectedSolanaAddress(info) {
3374
+ const provider = source(info);
3375
+ return "features" in provider ? accountAddress(provider.accounts) : validAddress(provider.publicKey);
3376
+ }
3377
+ async function connectSolanaWallet(info, options = {}) {
3378
+ const provider = source(info);
3379
+ let address;
3380
+ if ("features" in provider) {
3381
+ const result = await provider.features["standard:connect"].connect(options.silent ? { silent: true } : void 0);
3382
+ const accounts = result?.accounts ?? provider.accounts;
3383
+ connected.set(provider, accounts ?? []);
3384
+ address = accountAddress(accounts);
3385
+ } else {
3386
+ const result = await provider.connect(options.silent ? { onlyIfTrusted: true } : void 0);
3387
+ address = validAddress(result?.publicKey ?? provider.publicKey);
3388
+ connected.set(provider, address ? [{ address }] : []);
3389
+ }
3390
+ if (!address) throw new Error("The wallet did not return a valid Solana address.");
3391
+ return address;
3392
+ }
3393
+ async function disconnectSolanaWallet(info) {
3394
+ const provider = source(info);
3395
+ if ("features" in provider) await provider.features["standard:disconnect"]?.disconnect();
3396
+ else await provider.disconnect?.();
3397
+ connected.delete(provider);
3398
+ }
3399
+ var CANNOT_PAY = "This wallet cannot pay from Solana here; use a Wallet Standard wallet (Phantom, Solflare, Backpack).";
3400
+ function solanaWalletSigner(info) {
3401
+ const provider = source(info);
3402
+ const accounts = "features" in provider ? provider.accounts?.length ? provider.accounts : connected.get(provider) : connected.get(provider);
3403
+ const address = accountAddress(accounts);
3404
+ if (!connected.has(provider) || !address) throw new Error("Connect a Solana wallet before paying.");
3405
+ if ("features" in provider ? typeof provider.features["solana:signTransaction"]?.signTransaction !== "function" : typeof provider.signTransactionBytes !== "function") throw new Error(CANNOT_PAY);
3406
+ return {
3407
+ publicKey: address,
3408
+ async signTransaction(bytes) {
3409
+ const current = "features" in provider ? provider.accounts?.length ? provider.accounts : connected.get(provider) : connected.get(provider);
3410
+ const account = current?.find((a) => a.address === address);
3411
+ if (!connected.has(provider) || !account || accountAddress(current) !== address) throw new Error("Solana wallet account changed; reconnect before paying.");
3412
+ let signed;
3413
+ if ("features" in provider) {
3414
+ 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.");
3415
+ const result = await provider.features["solana:signTransaction"].signTransaction({ account, chain: "solana:mainnet", transaction: new Uint8Array(bytes) });
3416
+ if (result.length !== 1) throw new Error("Wallet returned an invalid Solana signing result.");
3417
+ signed = result[0]?.signedTransaction;
3418
+ } else signed = await provider.signTransactionBytes(new Uint8Array(bytes));
3419
+ if (!(signed instanceof Uint8Array)) throw new Error("Wallet did not return signed transaction bytes.");
3420
+ return new Uint8Array(signed);
3421
+ }
3422
+ };
3423
+ }
3424
+ function onSolanaAccountChange(info, cb) {
3425
+ const provider = source(info);
3426
+ if ("features" in provider) return provider.features["standard:events"]?.on("change", (change) => {
3427
+ if (change.accounts !== void 0) {
3428
+ connected.set(provider, change.accounts);
3429
+ cb(accountAddress(change.accounts));
3430
+ }
3431
+ }) ?? (() => {
3432
+ });
3433
+ const changed = (key) => {
3434
+ const address = validAddress(key);
3435
+ connected.set(provider, address ? [{ address }] : []);
3436
+ cb(address);
3437
+ };
3438
+ const disconnected = () => {
3439
+ connected.delete(provider);
3440
+ cb(null);
3441
+ };
3442
+ provider.on?.("accountChanged", changed);
3443
+ provider.on?.("connect", changed);
3444
+ provider.on?.("disconnect", disconnected);
3445
+ return () => {
3446
+ const off = provider.off ?? provider.removeListener;
3447
+ off?.call(provider, "accountChanged", changed);
3448
+ off?.call(provider, "connect", changed);
3449
+ off?.call(provider, "disconnect", disconnected);
3450
+ };
3451
+ }
3452
+
3453
+ // src/react/hooks/useSolanaWallet.ts
3454
+ var STORAGE_KEY = "sg-solana-wallet";
3455
+ function remember(name) {
3456
+ try {
3457
+ if (name) window.localStorage.setItem(STORAGE_KEY, name);
3458
+ else window.localStorage.removeItem(STORAGE_KEY);
3459
+ } catch {
3460
+ }
3461
+ }
3462
+ function remembered() {
3463
+ try {
3464
+ return window.localStorage.getItem(STORAGE_KEY);
3465
+ } catch {
3466
+ return null;
3467
+ }
3468
+ }
3469
+ var INITIAL = { address: null, walletName: null, status: "idle", error: null };
3470
+ function useSolanaWallet(provider) {
3471
+ const override = useMemo(() => provider ? solanaWalletInfo(provider) : null, [provider]);
3472
+ const [discovered, setDiscovered] = useState(discoverSolanaWallets);
3473
+ const wallets = useMemo(() => provider ? override ? [override] : [] : discovered, [provider, override, discovered]);
3474
+ const [state, setState] = useState(INITIAL);
3475
+ const active = useRef(null);
3476
+ const unsubscribe = useRef(() => {
3477
+ });
3478
+ const generation = useRef(0);
3479
+ const attempted = useRef(false);
3480
+ useEffect(() => {
3481
+ attempted.current = false;
3482
+ setState(INITIAL);
3483
+ return () => {
3484
+ generation.current += 1;
3485
+ unsubscribe.current();
3486
+ active.current = null;
3487
+ };
3488
+ }, [provider]);
3489
+ useEffect(() => provider ? void 0 : watchSolanaWallets(setDiscovered), [provider]);
3490
+ const runConnect = useCallback(async (info, silent = false) => {
3491
+ const request = ++generation.current;
3492
+ unsubscribe.current();
3493
+ active.current = null;
3494
+ setState({ ...INITIAL, status: "connecting" });
3495
+ try {
3496
+ const address = await connectSolanaWallet(info, { silent });
3497
+ if (request !== generation.current) return;
3498
+ active.current = info;
3499
+ unsubscribe.current = onSolanaAccountChange(info, (next) => {
3500
+ if (request !== generation.current) return;
3501
+ setState({ address: next, walletName: next ? info.name : null, status: next ? "connected" : "idle", error: null });
3502
+ if (!next) {
3503
+ generation.current += 1;
3504
+ unsubscribe.current();
3505
+ active.current = null;
3506
+ remember(null);
3507
+ }
3508
+ });
3509
+ setState({ address, walletName: info.name, status: "connected", error: null });
3510
+ remember(info.name);
3511
+ return address;
3512
+ } catch (error) {
3513
+ if (request === generation.current) setState(silent ? INITIAL : {
3514
+ ...INITIAL,
3515
+ status: "error",
3516
+ error: error instanceof Error ? error.message : "Could not connect a Solana wallet."
3517
+ });
3518
+ }
3519
+ }, []);
3520
+ useEffect(() => {
3521
+ if (attempted.current || active.current) return;
3522
+ const name = remembered();
3523
+ const info = wallets.find((wallet) => connectedSolanaAddress(wallet)) ?? (name ? wallets.find((wallet) => normalizeSolanaWalletName(wallet.name) === normalizeSolanaWalletName(name)) : void 0);
3524
+ if (!info) return;
3525
+ attempted.current = true;
3526
+ void runConnect(info, true);
3527
+ }, [wallets, runConnect]);
3528
+ const connect = useCallback(async (name) => {
3529
+ if (!name && wallets.length > 1) return wallets;
3530
+ attempted.current = true;
3531
+ const info = name ? wallets.find((wallet) => normalizeSolanaWalletName(wallet.name) === normalizeSolanaWalletName(name)) : wallets[0];
3532
+ if (!info) {
3533
+ setState({ ...INITIAL, status: "error", error: name ? "Solana wallet is not available." : "No Solana wallet found." });
3534
+ return;
3535
+ }
3536
+ return runConnect(info);
3537
+ }, [wallets, runConnect]);
3538
+ const disconnect = useCallback(async () => {
3539
+ attempted.current = true;
3540
+ generation.current += 1;
3541
+ unsubscribe.current();
3542
+ const info = active.current;
3543
+ active.current = null;
3544
+ setState(INITIAL);
3545
+ remember(null);
3546
+ if (info) {
3547
+ try {
3548
+ await disconnectSolanaWallet(info);
3549
+ } catch {
3550
+ }
3551
+ }
3552
+ }, []);
3553
+ return { ...state, wallets, connect, disconnect };
3554
+ }
3555
+
3556
+ // src/react/hooks/useRecipient.ts
3557
+ function useRecipient(destinationChainId, hostRecipient, opts = {}) {
3558
+ const recipientFamily = isSolanaChainId(destinationChainId) ? "solana" : "evm";
3559
+ const own = useSolanaWallet();
3560
+ const wallet = opts.solanaWallet ?? own;
3561
+ const [custom, setCustom] = useState({});
3562
+ const [open, setOpen] = useState(false);
3563
+ const triggerRef = useRef(null);
3564
+ const evmManaged = recipientFamily === "evm" && Boolean(opts.sourceIsSolana);
3565
+ const managed = hostRecipient === void 0 && (recipientFamily === "solana" || evmManaged);
3566
+ 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;
3567
+ const recipient = hostRecipient !== void 0 ? hostRecipient : recipientFamily === "solana" ? custom.solana || wallet.address || void 0 : evmManaged ? custom.evm || opts.evm?.account || void 0 : void 0;
3568
+ const missing = managed && !recipient;
3569
+ 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 };
3570
+ const close = () => {
3571
+ setOpen(false);
3572
+ requestAnimationFrame(() => triggerRef.current?.focus());
3573
+ };
3574
+ const selectAddress = (address) => {
3575
+ setCustom((prev) => ({ ...prev, [recipientFamily]: address }));
3576
+ close();
3577
+ };
3578
+ const connect = async (name) => {
3579
+ if (recipientFamily === "evm") {
3580
+ if (opts.evm?.account) selectAddress("");
3581
+ else opts.evm?.connect();
3582
+ return;
3583
+ }
3584
+ if (wallet.address && !name) {
3585
+ selectAddress("");
3586
+ return;
3587
+ }
3588
+ if (!name && wallet.wallets.length !== 1) {
3589
+ setOpen(true);
3590
+ return;
3591
+ }
3592
+ const address = await wallet.connect(name);
3593
+ if (typeof address === "string") selectAddress("");
3594
+ else setOpen(true);
3595
+ };
3596
+ const recipientFor = (account) => recipientFamily === "solana" || evmManaged ? recipient || "" : hostRecipient || account;
3597
+ return { recipientFamily, recipient, recipientFor, managed, missing, error, wallet, familyWallet, open: open && managed, show: () => setOpen(true), close, selectAddress, connect, triggerRef };
3598
+ }
3599
+ var short = (address) => `${address.slice(0, 4)}\u2026${address.slice(-4)}`;
3600
+ function RecipientNote({ state, disabled }) {
3601
+ if (state.error) return /* @__PURE__ */ jsx(StatusPanel, { tone: "error", children: state.error });
3602
+ if (!state.managed) return null;
3603
+ const family = state.recipientFamily === "solana" ? "Solana" : "EVM";
3604
+ return /* @__PURE__ */ jsxs("div", { style: { display: "flex", justifyContent: "center", gap: 6, marginTop: 10, fontSize: 13, color: "var(--sg-text-muted)", flexWrap: "wrap" }, children: [
3605
+ state.recipient ? /* @__PURE__ */ jsxs(Fragment, { children: [
3606
+ "To ",
3607
+ /* @__PURE__ */ jsx("b", { className: "sg-mono", title: state.recipient, style: { color: "var(--sg-text)" }, children: short(state.recipient) }),
3608
+ " on ",
3609
+ family,
3610
+ " \xB7 "
3611
+ ] }) : null,
3612
+ /* @__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" })
3613
+ ] });
3614
+ }
3615
+ function RecipientSheet({ state, symbol }) {
3616
+ const [draft, setDraft] = useState(state.recipient ?? "");
3617
+ const id = useId();
3618
+ const inputRef = useRef(null);
3619
+ const sheetRef = useRef(null);
3620
+ const closeRef = useRef(state.close);
3621
+ closeRef.current = state.close;
3622
+ const family = state.recipientFamily === "solana" ? "Solana" : "EVM";
3623
+ const valid = state.recipientFamily === "solana" ? isSolanaAddress(draft) : /^0x[0-9a-fA-F]{40}$/.test(draft.trim());
3624
+ const invalid = Boolean(draft.trim()) && !valid;
3625
+ const noWallet = state.recipientFamily === "solana" && !state.familyWallet.address && !state.familyWallet.wallets.length;
3626
+ useEffect(() => {
3627
+ (noWallet ? inputRef : sheetRef).current?.focus();
3628
+ const onKey = (event) => {
3629
+ if (event.key === "Escape") {
3630
+ event.stopPropagation();
3631
+ closeRef.current();
3632
+ }
3633
+ };
3634
+ document.addEventListener("keydown", onKey, true);
3635
+ return () => document.removeEventListener("keydown", onKey, true);
3636
+ }, [noWallet]);
3637
+ return /* @__PURE__ */ jsxs("div", { className: "sg-cp-sheet", role: "dialog", "aria-modal": "true", "aria-label": `${family} recipient`, ref: sheetRef, tabIndex: -1, children: [
3638
+ /* @__PURE__ */ jsxs("div", { className: "sg-cp-sheet-head", children: [
3639
+ /* @__PURE__ */ jsxs("h4", { className: "sg-cp-sheet-title", children: [
3640
+ family,
3641
+ " recipient"
3642
+ ] }),
3643
+ /* @__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" }) }) })
3644
+ ] }),
3645
+ /* @__PURE__ */ jsxs("div", { className: "sg-cp-sheet-body", children: [
3646
+ /* @__PURE__ */ jsxs("section", { className: "sg-cp-card", children: [
3647
+ /* @__PURE__ */ jsxs("p", { className: "sg-cp-summary-sub", style: { margin: "0 0 12px" }, children: [
3648
+ symbol,
3649
+ " is delivered to a ",
3650
+ family,
3651
+ " wallet. Your EVM wallet stays the owner of the order and can cancel it."
3652
+ ] }),
3653
+ /* @__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` }),
3654
+ !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,
3655
+ noWallet ? /* @__PURE__ */ jsxs("p", { className: "sg-cp-summary-sub", children: [
3656
+ "No ",
3657
+ family,
3658
+ " wallet found. Enter a ",
3659
+ family,
3660
+ " address instead."
3661
+ ] }) : null,
3662
+ state.familyWallet.error ? /* @__PURE__ */ jsx(StatusPanel, { tone: "error", children: state.familyWallet.error }) : null
3663
+ ] }),
3664
+ /* @__PURE__ */ jsxs("section", { className: "sg-cp-card", children: [
3665
+ /* @__PURE__ */ jsxs("div", { className: "sg-field", style: { margin: 0 }, children: [
3666
+ /* @__PURE__ */ jsx("label", { className: "sg-label", htmlFor: id, children: "Send to a different address" }),
3667
+ /* @__PURE__ */ jsx(
3668
+ "input",
3669
+ {
3670
+ ref: inputRef,
3671
+ id,
3672
+ className: "sg-input sg-mono",
3673
+ 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)" },
3674
+ placeholder: `${family} recipient address`,
3675
+ "aria-label": `${family} recipient address`,
3676
+ "aria-invalid": invalid || void 0,
3677
+ "aria-describedby": `${id}-help${invalid ? ` ${id}-error` : ""}`,
3678
+ value: draft,
3679
+ onChange: (event) => setDraft(event.target.value),
3680
+ spellCheck: false
3681
+ }
3682
+ )
3683
+ ] }),
3684
+ invalid ? /* @__PURE__ */ jsx("div", { id: `${id}-error`, children: /* @__PURE__ */ jsxs(StatusPanel, { tone: "error", children: [
3685
+ "Not a valid ",
3686
+ family,
3687
+ " address."
3688
+ ] }) }) : null,
3689
+ /* @__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." }),
3690
+ /* @__PURE__ */ jsx(Button, { disabled: !valid, onClick: () => state.selectAddress(draft.trim()), children: "Use this address" })
3691
+ ] })
3692
+ ] })
3693
+ ] });
3694
+ }
3257
3695
  var IDENTITY_KEY_PREFIX = "sg:link:v1:";
3258
3696
  var LEGACY_IDENTITY_KEY = "zd-link-identity";
3259
3697
  var ADDRESS_RE = /^0x[0-9a-fA-F]{40}$/;
@@ -3611,14 +4049,17 @@ function PaymentIsland(props) {
3611
4049
  const exQuotable = !rampMode && exAmountValid && !exOverLimit && Boolean(exFromChainId && exFromAsset && exToChainId && exToAsset);
3612
4050
  const payFundingAssets = props.fundingAssets?.length ? props.fundingAssets : ["USDC", "USDT", "USDE"];
3613
4051
  const payParamsKey = `pay|${props.recipient}|${props.toChainId}|${props.toAsset}|${props.amount}|${payFundingAssets.join(",")}`;
3614
- const exParamsKey = `${kind}|${mode}|${exFromChainId}|${exFromAsset}|${exToChainId}|${exToAsset}|${normEx}|${props.recipient ?? ""}`;
4052
+ const recipientState = useRecipient(isPay ? null : exToChainId ?? null, props.recipient);
4053
+ const recipient = recipientState.recipient;
4054
+ const needsRecipient = !isPay && (recipientState.missing || !!recipientState.error);
4055
+ const exParamsKey = `${kind}|${mode}|${exFromChainId}|${exFromAsset}|${exToChainId}|${exToAsset}|${normEx}|${recipient ?? ""}`;
3615
4056
  const flow = useFlow({
3616
4057
  engine,
3617
4058
  wallet,
3618
4059
  kind: isPay ? "payment" : "swap",
3619
4060
  // Bank settlement parks the card, so gate the network work off too — otherwise the island would
3620
4061
  // quote (and fire onQuote) for a payment whose CTA it never shows.
3621
- enabled: isPay ? Boolean(props.recipient && props.amount) && !bankSettlement : exQuotable,
4062
+ enabled: isPay ? Boolean(props.recipient && props.amount) && !bankSettlement : exQuotable && !needsRecipient,
3622
4063
  paramsKey: isPay ? payParamsKey : exParamsKey,
3623
4064
  loadPlan: isPay ? (e, payer, chainId) => e.fetchPaymentPlan({ address: props.recipient, chainId: props.toChainId, asset: props.toAsset, amount: props.amount }, payer, {
3624
4065
  chainId,
@@ -3630,11 +4071,11 @@ function PaymentIsland(props) {
3630
4071
  fromToken: exFromAsset,
3631
4072
  toToken: exToAsset,
3632
4073
  amountIn: normEx,
3633
- recipient: props.recipient
4074
+ recipient
3634
4075
  },
3635
4076
  payer
3636
4077
  ),
3637
- recipientFor: (account) => isPay ? props.recipient : props.recipient || account,
4078
+ recipientFor: (account) => isPay ? props.recipient : recipientState.recipientFor(account),
3638
4079
  onQuote: config.onQuote,
3639
4080
  onSuccess: config.onSuccess,
3640
4081
  onError: config.onError
@@ -3952,7 +4393,7 @@ function PaymentIsland(props) {
3952
4393
  const activeStep = flow.steps.find((s) => s.state === "active");
3953
4394
  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" ? flow.verdict?.status === "confirmed" ? isPay ? "Payment confirmed on-chain \u2014 the merchant has been settled." : `${verb.past} \u2014 confirmed on-chain.` : isPay ? "Payment sent \u2014 confirmation is still pending." : "Submitted \u2014 confirmation is still pending." : "";
3954
4395
  const loading = flow.status === "loading";
3955
- const payReady = isPay ? Boolean(sel && selectedVisible) : Boolean(sel);
4396
+ const payReady = isPay ? Boolean(sel && selectedVisible) : Boolean(sel) && !needsRecipient;
3956
4397
  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
4398
  const exPct = (p) => {
3958
4399
  if (!exFromBal || !exFromToken) return;
@@ -4034,6 +4475,8 @@ function PaymentIsland(props) {
4034
4475
  }
4035
4476
  }
4036
4477
  );
4478
+ } else if (recipientState.open && !isPay) {
4479
+ body = /* @__PURE__ */ jsx(RecipientSheet, { state: recipientState, symbol: destTicker });
4037
4480
  } else if (rampMode) {
4038
4481
  body = /* @__PURE__ */ jsxs("div", { className: "sg-soonpanel", children: [
4039
4482
  /* @__PURE__ */ jsx("div", { className: "sg-soonpanel-title", children: mode === "onramp" ? "Buying with fiat is coming soon" : "Cashing out to fiat is coming soon" }),
@@ -4084,7 +4527,7 @@ function PaymentIsland(props) {
4084
4527
  ] }),
4085
4528
  /* @__PURE__ */ jsxs("div", { className: "sg-receipt-sub", children: [
4086
4529
  confirmed ? "Confirmed on-chain" : "Confirmation pending",
4087
- isPay && props.recipient ? ` \xB7 ${shortAddress(props.recipient)}` : ""
4530
+ (flow.lastTxEntry?.recipient || recipient) && (isPay || recipientState.recipientFamily === "solana") ? ` \xB7 ${shortAddress(flow.lastTxEntry?.recipient || recipient)}` : ""
4088
4531
  ] })
4089
4532
  ] }),
4090
4533
  !identityMatchesWallet ? /* @__PURE__ */ jsxs("div", { className: "sg-remember", children: [
@@ -4200,16 +4643,23 @@ function PaymentIsland(props) {
4200
4643
  quoteError ? /* @__PURE__ */ jsx(StatusPanel, { tone: "error", children: flow.error || "Couldn't get a price right now." }) : null,
4201
4644
  walletError ? /* @__PURE__ */ jsx(StatusPanel, { tone: "error", children: flow.error || "The wallet could not complete this payment." }) : null,
4202
4645
  submitting || walletError ? /* @__PURE__ */ jsx(StepList, { variant: "rich", steps: flow.steps, verdict: flow.verdict }) : null,
4203
- /* @__PURE__ */ jsx("div", { className: "sg-cta-wrap", children: 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(
4204
- Button,
4205
- {
4206
- onClick: payReady && !submitting && !flow.insufficient && !flow.nativeShortfall && !loading ? flow.submit : void 0,
4207
- busy: submitting || loading,
4208
- softDisabled: submitting,
4209
- disabled: !submitting && (!payReady || flow.insufficient || !!flow.nativeShortfall || loading),
4210
- children: ctaLabel
4211
- }
4212
- ) })
4646
+ /* @__PURE__ */ jsxs("div", { className: "sg-cta-wrap", children: [
4647
+ recipientState.missing && !isPay && !submitting ? /* @__PURE__ */ jsxs(Button, { onClick: () => void recipientState.connect(), busy: recipientState.wallet.status === "connecting", children: [
4648
+ "Connect ",
4649
+ recipientState.recipientFamily === "solana" ? "Solana" : "EVM",
4650
+ " wallet"
4651
+ ] }) : 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(
4652
+ Button,
4653
+ {
4654
+ onClick: payReady && !submitting && !flow.insufficient && !flow.nativeShortfall && !loading ? flow.submit : void 0,
4655
+ busy: submitting || loading,
4656
+ softDisabled: submitting,
4657
+ disabled: !submitting && (!payReady || flow.insufficient || !!flow.nativeShortfall || loading),
4658
+ children: ctaLabel
4659
+ }
4660
+ ),
4661
+ !isPay ? /* @__PURE__ */ jsx(RecipientNote, { state: recipientState, disabled: submitting }) : null
4662
+ ] })
4213
4663
  ] })
4214
4664
  ] });
4215
4665
  }
@@ -4671,6 +5121,9 @@ function StableGenieSwap(props) {
4671
5121
  const [toChainId, setToChainId] = useState(props.defaultToChainId ?? 8453);
4672
5122
  const [toAsset, setToAsset] = useState(props.defaultToAsset ?? "USDC");
4673
5123
  const [amount, setAmount] = useState(props.defaultAmount ?? "");
5124
+ const recipientState = useRecipient(toChainId, props.recipient);
5125
+ const recipient = recipientState.recipient;
5126
+ const needsRecipient = recipientState.missing || !!recipientState.error;
4674
5127
  const [catalogue, setCatalogue] = useState(null);
4675
5128
  useEffect(() => {
4676
5129
  if (props.variant === "pill") return;
@@ -4700,15 +5153,15 @@ function StableGenieSwap(props) {
4700
5153
  }, [catalogue]);
4701
5154
  const amountValid = /^\d+(\.\d+)?$/.test(amount.replace(",", ".")) && Number(amount.replace(",", ".")) > 0;
4702
5155
  const enabled = amountValid && props.variant !== "pill";
4703
- const paramsKey = `${fromChainId}|${fromAsset}|${toChainId}|${toAsset}|${amount}|${props.recipient ?? ""}`;
5156
+ const paramsKey = `${fromChainId}|${fromAsset}|${toChainId}|${toAsset}|${amount}|${recipient ?? ""}`;
4704
5157
  const flow = useFlow({
4705
5158
  engine,
4706
5159
  wallet,
4707
5160
  kind: "swap",
4708
- enabled,
5161
+ enabled: enabled && !needsRecipient,
4709
5162
  paramsKey,
4710
- loadPlan: (e, payer) => e.buildSwapPlan({ fromChainId, toChainId, fromToken: fromAsset, toToken: toAsset, amountIn: amount, recipient: props.recipient }, payer),
4711
- recipientFor: (account) => props.recipient || account,
5163
+ loadPlan: (e, payer) => e.buildSwapPlan({ fromChainId, toChainId, fromToken: fromAsset, toToken: toAsset, amountIn: amount, recipient }, payer),
5164
+ recipientFor: recipientState.recipientFor,
4712
5165
  onQuote: config.onQuote,
4713
5166
  onSuccess: config.onSuccess,
4714
5167
  onError: config.onError
@@ -4751,6 +5204,7 @@ function StableGenieSwap(props) {
4751
5204
  if (hist && wallet.account) {
4752
5205
  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 }) });
4753
5206
  }
5207
+ if (recipientState.open) return /* @__PURE__ */ jsx(WidgetShell, { title: config.title || "Swap", theme: config.theme, walletSlot, children: /* @__PURE__ */ jsx(RecipientSheet, { state: recipientState, symbol: toAsset }) });
4754
5208
  if (flow.status === "success" || flow.status === "pending") {
4755
5209
  return /* @__PURE__ */ jsxs(WidgetShell, { title: config.title || "Swap", theme: config.theme, walletSlot, children: [
4756
5210
  /* @__PURE__ */ jsxs("div", { className: "sg-success", children: [
@@ -4762,7 +5216,7 @@ function StableGenieSwap(props) {
4762
5216
  ] }),
4763
5217
  /* @__PURE__ */ jsxs("div", { className: "sg-success-sub", children: [
4764
5218
  flow.verdict?.status === "confirmed" ? "Confirmed on-chain" : "Submitted \u2014 awaiting confirmation",
4765
- props.recipient ? ` \xB7 ${shortAddress(props.recipient)}` : ""
5219
+ recipientState.recipientFamily === "solana" ? ` \xB7 ${shortAddress(flow.lastTxEntry?.recipient || recipient)}` : props.recipient ? ` \xB7 ${shortAddress(props.recipient)}` : ""
4766
5220
  ] })
4767
5221
  ] }),
4768
5222
  lastTxOwned ? /* @__PURE__ */ jsx("div", { className: "sg-cta-wrap", children: /* @__PURE__ */ jsx(Button, { variant: "ghost", onClick: () => setHist({ entry: flow.lastTxEntry }), children: "View transaction" }) }) : null
@@ -4791,11 +5245,169 @@ function StableGenieSwap(props) {
4791
5245
  flow.selected && flow.status !== "loading" ? /* @__PURE__ */ jsx(CompliancePanel, { compliance: flow.selected.quote.compliance, direct: flow.selected.state === "DIRECT" }) : null,
4792
5246
  submitting ? /* @__PURE__ */ jsx(StepList, { steps: flow.steps }) : null,
4793
5247
  /* @__PURE__ */ jsxs("div", { className: "sg-cta-wrap", children: [
4794
- !wallet.account ? /* @__PURE__ */ jsx(Button, { onClick: wallet.connect, busy: wallet.connecting, children: "Connect wallet" }) : /* @__PURE__ */ jsx(Button, { onClick: flow.submit, busy: submitting, disabled: !flow.selected || flow.insufficient || !!flow.nativeShortfall || !enabled || flow.status === "loading", children: swapLabel }),
5248
+ !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: [
5249
+ "Connect ",
5250
+ recipientState.recipientFamily === "solana" ? "Solana" : "EVM",
5251
+ " wallet"
5252
+ ] }) : /* @__PURE__ */ jsx(Button, { onClick: flow.submit, busy: submitting, disabled: needsRecipient || !flow.selected || flow.insufficient || !!flow.nativeShortfall || !enabled || flow.status === "loading", children: swapLabel }),
5253
+ /* @__PURE__ */ jsx(RecipientNote, { state: recipientState, disabled: submitting }),
4795
5254
  wallet.error ? /* @__PURE__ */ jsx(StatusPanel, { tone: "error", children: wallet.error }) : null
4796
5255
  ] })
4797
5256
  ] });
4798
5257
  }
5258
+ function keyOf(a) {
5259
+ return `${a.fromSymbol}|${a.toChainId}|${a.toSymbol}|${a.amount}|${a.owner ?? ""}|${a.payer ?? ""}|${a.recipient ?? ""}`;
5260
+ }
5261
+ function useSolanaSourceFlow(args) {
5262
+ const { engine, enabled, fromSymbol, fromMint, toChainId, toSymbol, amount, owner, payer, recipient } = args;
5263
+ const [status, setStatus] = useState("idle");
5264
+ const [preview, setPreview] = useState(null);
5265
+ const [plan, setPlan] = useState(null);
5266
+ const [error, setError] = useState(null);
5267
+ const [balanceRaw, setBalanceRaw] = useState(void 0);
5268
+ const [cost, setCost] = useState(null);
5269
+ const [progress, setProgress] = useState(null);
5270
+ const [signature, setSignature] = useState(null);
5271
+ const [lastTxEntry, setLastTxEntry] = useState(null);
5272
+ const [sent, setSent] = useState(null);
5273
+ const [nonce, setNonce] = useState(0);
5274
+ const req = useRef(0);
5275
+ const busy = useRef(false);
5276
+ const latest = useRef(args);
5277
+ latest.current = args;
5278
+ const planKey = useRef(null);
5279
+ const planArgs = useRef(null);
5280
+ const changedWhileBusy = useRef(false);
5281
+ const addressed = Boolean(owner && payer && recipient);
5282
+ const key = keyOf(args);
5283
+ useEffect(() => {
5284
+ const id = ++req.current;
5285
+ if (!enabled || !fromSymbol || !toChainId || !toSymbol || !(Number(amount) > 0)) {
5286
+ setStatus("idle");
5287
+ setPreview(null);
5288
+ setPlan(null);
5289
+ setError(null);
5290
+ setCost(null);
5291
+ return;
5292
+ }
5293
+ if (busy.current) {
5294
+ changedWhileBusy.current = true;
5295
+ return;
5296
+ }
5297
+ setStatus("quoting");
5298
+ planKey.current = null;
5299
+ planArgs.current = null;
5300
+ setError(null);
5301
+ setPlan(null);
5302
+ setCost(null);
5303
+ const timer2 = setTimeout(async () => {
5304
+ try {
5305
+ if (!addressed) {
5306
+ const next = await engine.previewSolanaSource({ toChainId, fromToken: fromSymbol, toToken: toSymbol, amountIn: amount });
5307
+ if (id !== req.current) return;
5308
+ setPreview(next);
5309
+ setStatus("ready");
5310
+ return;
5311
+ }
5312
+ const input = { toChainId, fromToken: fromSymbol, toToken: toSymbol, amountIn: amount, owner, sender: payer, recipient };
5313
+ const quoted = await engine.quoteSolanaSource(input);
5314
+ const built = await engine.buildSolanaSourcePlan(input, quoted);
5315
+ if (id !== req.current) return;
5316
+ planKey.current = key;
5317
+ planArgs.current = { ...latest.current };
5318
+ setPreview(quoted);
5319
+ setPlan(built);
5320
+ setStatus("ready");
5321
+ engine.simulateSolanaCost(built).then(
5322
+ (c) => id === req.current && setCost(c),
5323
+ () => id === req.current && setCost(null)
5324
+ );
5325
+ } catch (e) {
5326
+ if (id !== req.current) return;
5327
+ setStatus("error");
5328
+ setError(e instanceof Error ? e.message : String(e));
5329
+ }
5330
+ }, 350);
5331
+ return () => clearTimeout(timer2);
5332
+ }, [engine, enabled, key, addressed, nonce]);
5333
+ useEffect(() => {
5334
+ let alive = true;
5335
+ setBalanceRaw(void 0);
5336
+ if (!enabled || !payer || !fromMint) return;
5337
+ engine.readSolanaBalance(payer, fromMint).then((b) => {
5338
+ if (alive) setBalanceRaw(b);
5339
+ });
5340
+ return () => {
5341
+ alive = false;
5342
+ };
5343
+ }, [engine, enabled, payer, fromMint]);
5344
+ const needsPreparation = plan ? solanaPlanNeedsPreparation(plan) : false;
5345
+ const run = useCallback(async () => {
5346
+ const current = plan;
5347
+ if (!current || busy.current) return;
5348
+ if (planKey.current !== keyOf(latest.current)) {
5349
+ setError("The order changed; review the new quote before signing.");
5350
+ setNonce((n) => n + 1);
5351
+ return;
5352
+ }
5353
+ busy.current = true;
5354
+ let broadcast = false;
5355
+ setError(null);
5356
+ setStatus(needsPreparation ? "preparing" : "submitting");
5357
+ try {
5358
+ const result = await engine.executeSolanaPlanStaged({ plan: current, signer: latest.current.signer(), onProgress: setProgress });
5359
+ if (result.status === "prepared") {
5360
+ setStatus("prepared");
5361
+ return;
5362
+ }
5363
+ const a = planArgs.current ?? latest.current;
5364
+ broadcast = true;
5365
+ setSent({ receive: current.preview.receive, toTicker: a.toTicker, recipient: a.recipient ?? "" });
5366
+ setSignature(result.signature);
5367
+ setStatus("sent");
5368
+ const entry = engine.recordTransaction({
5369
+ kind: "swap",
5370
+ hash: result.signature,
5371
+ txKind: "submitOrder",
5372
+ chainId: SOLANA_CHAIN_ID,
5373
+ chainName: a.chainName,
5374
+ fromAsset: a.fromSymbol ?? "",
5375
+ toAsset: a.toSymbol ?? "",
5376
+ fromTicker: a.fromTicker,
5377
+ toTicker: a.toTicker,
5378
+ payAmount: a.amount,
5379
+ receiveAmount: current.preview.receive,
5380
+ account: a.owner ?? "",
5381
+ recipient: a.recipient ?? "",
5382
+ settlement: "escrow",
5383
+ status: "submitted"
5384
+ });
5385
+ setLastTxEntry(entry.hash ? entry : null);
5386
+ appendTxHistory(a.owner, entry);
5387
+ } catch (e) {
5388
+ const err = e instanceof Error ? e : new Error(String(e));
5389
+ setStatus("failed");
5390
+ setError(err.message);
5391
+ latest.current.onError?.(err);
5392
+ } finally {
5393
+ busy.current = false;
5394
+ if (changedWhileBusy.current) {
5395
+ changedWhileBusy.current = false;
5396
+ if (!broadcast && planKey.current !== keyOf(latest.current)) setNonce((n) => n + 1);
5397
+ }
5398
+ }
5399
+ }, [engine, plan, needsPreparation]);
5400
+ const insufficient = balanceRaw !== void 0 && plan ? balanceRaw < BigInt(plan.expected.bidTokenAmount) : false;
5401
+ const solShort = cost ? !cost.sufficient : false;
5402
+ const reset = useCallback(() => {
5403
+ setSignature(null);
5404
+ setLastTxEntry(null);
5405
+ setSent(null);
5406
+ setProgress(null);
5407
+ setNonce((n) => n + 1);
5408
+ }, []);
5409
+ return { status, preview, plan, error, balanceRaw, cost, progress, signature, lastTxEntry, sent, addressed, needsPreparation, insufficient, solShort, run, reset };
5410
+ }
4799
5411
  function QuoteSheet(props) {
4800
5412
  const sheetRef = useRef(null);
4801
5413
  const onCloseRef = useRef(props.onClose);
@@ -4904,7 +5516,7 @@ function ExchangeCard(props) {
4904
5516
  useEffect(() => {
4905
5517
  if (isPill) return;
4906
5518
  let alive = true;
4907
- engine.fetchCatalogue(allowed, product).then((next) => {
5519
+ engine.fetchCatalogue(allowed, product, { solanaSources: true }).then((next) => {
4908
5520
  if (alive) setCatalogue(next);
4909
5521
  });
4910
5522
  return () => {
@@ -4937,6 +5549,16 @@ function ExchangeCard(props) {
4937
5549
  () => props.defaultToChainId && props.defaultToAsset ? { chainId: props.defaultToChainId, symbol: symbolKey(props.defaultToAsset) } : null
4938
5550
  );
4939
5551
  const [amount, setAmount] = useState(props.defaultAmount ?? "");
5552
+ const solanaWallet = useSolanaWallet();
5553
+ const [payerChooser, setPayerChooser] = useState(false);
5554
+ const sourceIsSolana = isSolanaChainId(from?.chainId);
5555
+ const recipientState = useRecipient(to?.chainId ?? null, props.recipient, {
5556
+ solanaWallet,
5557
+ sourceIsSolana,
5558
+ evm: { account: wallet.account, connect: wallet.connect, connecting: wallet.connecting }
5559
+ });
5560
+ const recipient = recipientState.recipient;
5561
+ const needsRecipient = recipientState.missing || !!recipientState.error;
4940
5562
  const onInputChange = useRef(props.onInputChange);
4941
5563
  onInputChange.current = props.onInputChange;
4942
5564
  const fromChainId = from?.chainId ?? null;
@@ -5032,7 +5654,7 @@ function ExchangeCard(props) {
5032
5654
  if (id === balReq.current) setBalances(res);
5033
5655
  });
5034
5656
  }, [engine, wallet.account, tokens]);
5035
- const fromBal = from && fromToken ? balances[balanceKey(from.chainId, fromToken.address)] : void 0;
5657
+ const evmFromBal = from && fromToken ? balances[balanceKey(from.chainId, fromToken.address)] : void 0;
5036
5658
  const [prices, setPrices] = useState({});
5037
5659
  useEffect(() => {
5038
5660
  if (isPill) return;
@@ -5046,24 +5668,47 @@ function ExchangeCard(props) {
5046
5668
  alive = false;
5047
5669
  };
5048
5670
  }, [engine, from?.symbol, to?.symbol, isPill]);
5049
- const paramsKey = `${mode}|${from?.chainId}|${from?.symbol}|${to?.chainId}|${toSymbol}|${normalizedAmount}|${props.recipient ?? ""}`;
5671
+ const paramsKey = `${mode}|${from?.chainId}|${from?.symbol}|${to?.chainId}|${toSymbol}|${normalizedAmount}|${recipient ?? ""}`;
5050
5672
  const flow = useFlow({
5051
5673
  engine,
5052
5674
  wallet,
5053
5675
  kind: "swap",
5054
- enabled: quotable && !isPill,
5676
+ enabled: quotable && !isPill && !needsRecipient && !sourceIsSolana,
5055
5677
  paramsKey,
5056
- loadPlan: (e, payer) => e.buildSwapPlan({ fromChainId: from.chainId, toChainId: to.chainId, fromToken: from.symbol, toToken: to.symbol, amountIn: normalizedAmount, recipient: props.recipient }, payer),
5057
- recipientFor: (account) => props.recipient || account,
5678
+ loadPlan: (e, payer) => e.buildSwapPlan({ fromChainId: from.chainId, toChainId: to.chainId, fromToken: from.symbol, toToken: to.symbol, amountIn: normalizedAmount, recipient }, payer),
5679
+ recipientFor: recipientState.recipientFor,
5058
5680
  onQuote: config.onQuote,
5059
5681
  onSuccess: config.onSuccess,
5060
5682
  onError: config.onError
5061
5683
  });
5684
+ const solActive = sourceIsSolana && !isPill && !rampMode;
5685
+ const solFlow = useSolanaSourceFlow({
5686
+ engine,
5687
+ enabled: solActive && quotable && !recipientState.error,
5688
+ fromSymbol: from?.symbol ?? null,
5689
+ fromMint: fromToken?.address ?? null,
5690
+ toChainId: to?.chainId ?? null,
5691
+ toSymbol: to ? toSymbol : null,
5692
+ amount: normalizedAmount,
5693
+ owner: wallet.account,
5694
+ payer: solanaWallet.address,
5695
+ recipient,
5696
+ signer: () => {
5697
+ const info = solanaWallet.wallets.find((w) => normalizeSolanaWalletName(w.name) === normalizeSolanaWalletName(solanaWallet.walletName ?? ""));
5698
+ if (!info) throw new Error("Connect a Solana wallet to pay from Solana.");
5699
+ return solanaWalletSigner(info);
5700
+ },
5701
+ chainName: "Solana",
5702
+ fromTicker,
5703
+ toTicker,
5704
+ onError: config.onError
5705
+ });
5706
+ const fromBal = solActive ? solFlow.balanceRaw !== void 0 && fromToken ? { ...evmFromBal, raw: solFlow.balanceRaw.toString(), formatted: formatUnits(solFlow.balanceRaw, assetDecimals(fromToken)) } : void 0 : evmFromBal;
5062
5707
  const [preview, setPreview] = useState({ status: "idle" });
5063
5708
  const { idle: idle2, returnedAt: returnedAt2 } = useUserPresence();
5064
5709
  const prevReq = useRef(0);
5065
5710
  useEffect(() => {
5066
- if (isPill || wallet.account || !quotable) {
5711
+ if (isPill || sourceIsSolana || wallet.account && !needsRecipient || !quotable) {
5067
5712
  prevReq.current += 1;
5068
5713
  setPreview({ status: "idle" });
5069
5714
  return;
@@ -5071,23 +5716,24 @@ function ExchangeCard(props) {
5071
5716
  const id = ++prevReq.current;
5072
5717
  setPreview({ status: "loading" });
5073
5718
  const timer2 = setTimeout(() => {
5074
- engine.quoteSwapPreview({ fromChainId: from.chainId, toChainId: to.chainId, fromToken: from.symbol, toToken: to.symbol, amountIn: normalizedAmount, recipient: props.recipient }).then((data) => {
5719
+ engine.quoteSwapPreview({ fromChainId: from.chainId, toChainId: to.chainId, fromToken: from.symbol, toToken: to.symbol, amountIn: normalizedAmount, recipient }, wallet.account ?? void 0).then((data) => {
5075
5720
  if (id === prevReq.current) setPreview({ status: "ready", data });
5076
5721
  }).catch((e) => {
5077
5722
  if (id === prevReq.current) setPreview({ status: "error", error: e instanceof Error ? e.message : String(e), fieldError: amountFieldError(e) });
5078
5723
  });
5079
5724
  }, 350);
5080
5725
  return () => clearTimeout(timer2);
5081
- }, [engine, wallet.account, quotable, paramsKey, returnedAt2]);
5082
- const connected = Boolean(wallet.account);
5083
- const submitting = flow.status === "submitting";
5726
+ }, [engine, wallet.account, quotable, paramsKey, returnedAt2, needsRecipient, sourceIsSolana]);
5727
+ const connected2 = Boolean(wallet.account);
5728
+ const addressed = connected2 && !needsRecipient;
5729
+ const submitting = solActive ? solFlow.status === "preparing" || solFlow.status === "submitting" : flow.status === "submitting";
5084
5730
  const lastTxOwned = Boolean(flow.lastTxEntry?.hash && wallet.account && flow.lastTxEntry.account === wallet.account.toLowerCase());
5085
- const quoting = connected ? flow.status === "loading" : preview.status === "loading";
5086
- const quoteError = !quotable ? null : connected ? flow.status === "error" ? flow.error : null : preview.status === "error" ? preview.error ?? "No route." : null;
5087
- const gatewayAmountError = !quoteError ? null : connected ? flow.fieldError : preview.fieldError ?? null;
5731
+ const quoting = solActive ? solFlow.status === "quoting" : addressed ? flow.status === "loading" : preview.status === "loading";
5732
+ 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;
5733
+ const gatewayAmountError = !quoteError || solActive ? null : addressed ? flow.fieldError : preview.fieldError ?? null;
5088
5734
  const amountError = overLimit && laneLimit ? laneLimitError(laneLimit, limitSymbol) : gatewayAmountError;
5089
5735
  const amountNote = mode === "exchange" ? amountError || (laneLimit ? laneLimitHint(laneLimit, limitSymbol) : null) : null;
5090
- const receive = connected ? flow.selected?.receive.amount : preview.data?.receive;
5736
+ const receive = solActive ? solFlow.preview?.receive : addressed ? flow.selected?.receive.amount : preview.data?.receive;
5091
5737
  const receiveOutRef = useRef(null);
5092
5738
  const receiveSideRef = useRef(null);
5093
5739
  const receiveShown = `${receive ?? ""}|${quoting}|${toTicker}`;
@@ -5100,7 +5746,7 @@ function ExchangeCard(props) {
5100
5746
  return void 0;
5101
5747
  }
5102
5748
  }, [toToken]);
5103
- const meta = connected ? 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;
5749
+ 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
5750
  const pct = (p) => {
5105
5751
  if (!fromBal || !fromToken) return;
5106
5752
  const raw = BigInt(fromBal.raw);
@@ -5108,9 +5754,9 @@ function ExchangeCard(props) {
5108
5754
  };
5109
5755
  const title = config.title || (mode === "onramp" ? "Buy stablecoins" : mode === "offramp" ? "Cash out" : "Exchange");
5110
5756
  const soonLabel = mode === "onramp" ? "On-ramp coming soon" : "Off-ramp coming soon";
5111
- const quotePaused = connected ? flow.quotePaused : idle2 && preview.status === "ready";
5112
- const ctaLabel = rampMode ? soonLabel : submitting ? "Exchanging\u2026" : connected && flow.quoteStale ? flow.quotePaused ? "Refresh quote" : "Refreshing quote\u2026" : flow.insufficient ? "Insufficient balance" : flow.nativeShortfall || "Exchange";
5113
- const selected = connected ? flow.selected : null;
5757
+ const quotePaused = solActive ? false : addressed ? flow.quotePaused : idle2 && preview.status === "ready";
5758
+ const ctaLabel = rampMode ? soonLabel : submitting ? "Exchanging\u2026" : connected2 && flow.quoteStale ? flow.quotePaused ? "Refresh quote" : "Refreshing quote\u2026" : flow.insufficient ? "Insufficient balance" : flow.nativeShortfall || "Exchange";
5759
+ const selected = addressed ? flow.selected : null;
5114
5760
  const hasQuote = Boolean(quotable && !quoting && !quoteError && receive);
5115
5761
  const nativeWei = (() => {
5116
5762
  try {
@@ -5120,7 +5766,7 @@ function ExchangeCard(props) {
5120
5766
  return 0n;
5121
5767
  }
5122
5768
  })();
5123
- const networkFee = nativeWei > 0n ? `~${formatNative(nativeWei)} ${nativeSymbol(from?.chainId ?? 1, chains)}` : "Gas only";
5769
+ 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
5770
  const eta = durationLabel(meta?.duration);
5125
5771
  const rate = hasQuote && receive && Number(normalizedAmount) > 0 ? (Number(receive) / Number(normalizedAmount)).toFixed(6) : null;
5126
5772
  const rateRows = hasQuote ? [{ label: "Network fee", value: networkFee }, ...eta ? [{ label: "Estimated time", value: eta }] : []] : [];
@@ -5137,8 +5783,8 @@ function ExchangeCard(props) {
5137
5783
  setTo(from);
5138
5784
  };
5139
5785
  const walletSlot = /* @__PURE__ */ jsxs("div", { className: "sg-head-tools", children: [
5140
- connected ? /* @__PURE__ */ jsx(HistoryButton, { btnRef: histBtnRef, disabled: submitting, onClick: () => setHist({}) }) : null,
5141
- /* @__PURE__ */ jsx("button", { type: "button", className: "sg-wallet", "data-connected": connected || void 0, onClick: connected ? void 0 : wallet.connect, disabled: wallet.connecting, children: connected ? /* @__PURE__ */ jsxs(Fragment, { children: [
5786
+ connected2 ? /* @__PURE__ */ jsx(HistoryButton, { btnRef: histBtnRef, disabled: submitting, onClick: () => setHist({}) }) : null,
5787
+ /* @__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
5788
  /* @__PURE__ */ jsx("span", { className: "sg-wallet-dot", "aria-hidden": "true" }),
5143
5789
  " ",
5144
5790
  shortAddress(wallet.account)
@@ -5186,7 +5832,7 @@ function ExchangeCard(props) {
5186
5832
  }
5187
5833
  );
5188
5834
  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(
5835
+ 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
5836
  QuoteSheet,
5191
5837
  {
5192
5838
  onClose: closeSheet,
@@ -5203,8 +5849,33 @@ function ExchangeCard(props) {
5203
5849
  legs: selected && selected.legs.length > 1 ? selected.legs : void 0
5204
5850
  }
5205
5851
  ) : null;
5852
+ const connectPayer = async () => {
5853
+ const result = await solanaWallet.connect();
5854
+ setPayerChooser(Array.isArray(result) && result.length > 1);
5855
+ };
5856
+ const solanaCta = !solanaWallet.address ? /* @__PURE__ */ jsxs(Fragment, { children: [
5857
+ /* @__PURE__ */ jsx(Button, { onClick: () => void connectPayer(), busy: solanaWallet.status === "connecting", children: "Connect Solana wallet" }),
5858
+ 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,
5859
+ !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
5860
+ ] }) : !connected2 ? /* @__PURE__ */ jsxs(Fragment, { children: [
5861
+ /* @__PURE__ */ jsx(Button, { onClick: wallet.connect, busy: wallet.connecting, children: "Connect EVM wallet" }),
5862
+ /* @__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." })
5863
+ ] }) : recipientState.missing ? /* @__PURE__ */ jsxs(Button, { onClick: () => void recipientState.connect(), busy: recipientState.familyWallet.connecting, children: [
5864
+ "Connect ",
5865
+ recipientState.recipientFamily === "solana" ? "Solana" : "EVM",
5866
+ " wallet"
5867
+ ] }) : /* @__PURE__ */ jsx(
5868
+ Button,
5869
+ {
5870
+ onClick: solFlow.run,
5871
+ busy: submitting,
5872
+ disabled: !quotable || !cryptoReady || !!recipientState.error || !solFlow.plan || solFlow.insufficient || solFlow.solShort || solFlow.status === "quoting",
5873
+ 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"
5874
+ }
5875
+ );
5876
+ const solanaSteps = solActive && solFlow.plan && connected2 && solanaWallet.address ? /* @__PURE__ */ jsx("p", { className: "sg-cp-summary-sub", style: { textAlign: "center", margin: "0 0 8px" }, "data-testid": "solana-steps", children: solFlow.needsPreparation || solFlow.status === "preparing" ? "Prepare order \xB7 Submit \xB7 Track" : solFlow.status === "prepared" ? "Prepare order \u2713 \xB7 Submit \xB7 Track" : "Submit \xB7 Track" }) : null;
5206
5877
  let body;
5207
- if (hist && connected) {
5878
+ if (hist && connected2) {
5208
5879
  body = /* @__PURE__ */ jsx(TxHistoryPanel, { account: wallet.account, tokens, vaultIcons: catalogue?.vaultIcons, initialEntry: hist.entry ?? null, onBack: closeHistory });
5209
5880
  } else if (view === "from" || view === "to") {
5210
5881
  const isFrom = view === "from";
@@ -5229,6 +5900,26 @@ function ExchangeCard(props) {
5229
5900
  );
5230
5901
  } else if (sheetBody && !wide) {
5231
5902
  body = sheetBody;
5903
+ } else if (solActive && solFlow.status === "sent") {
5904
+ body = /* @__PURE__ */ jsxs(Fragment, { children: [
5905
+ /* @__PURE__ */ jsxs("div", { className: "sg-success", children: [
5906
+ /* @__PURE__ */ jsx("div", { className: "sg-success-check", "data-pending": "true", children: /* @__PURE__ */ jsx(CheckGlyph5, {}) }),
5907
+ /* @__PURE__ */ jsxs("div", { className: "sg-success-amt sg-mono", children: [
5908
+ solFlow.sent?.receive ?? receive,
5909
+ " ",
5910
+ solFlow.sent?.toTicker ?? toTicker
5911
+ ] }),
5912
+ /* @__PURE__ */ jsxs("div", { className: "sg-success-sub", children: [
5913
+ "Submitted on Solana \u2014 ZeroDelta delivers it",
5914
+ solFlow.sent?.recipient ? ` \xB7 ${shortAddress(solFlow.sent.recipient)}` : ""
5915
+ ] })
5916
+ ] }),
5917
+ /* @__PURE__ */ jsxs("div", { className: "sg-cta-wrap", children: [
5918
+ 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,
5919
+ solFlow.lastTxEntry && connected2 ? /* @__PURE__ */ jsx(Button, { variant: "ghost", onClick: () => setHist({ entry: solFlow.lastTxEntry }), children: "View transaction" }) : null,
5920
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", onClick: solFlow.reset, children: "Start a new exchange" })
5921
+ ] })
5922
+ ] });
5232
5923
  } else if (flow.status === "success" || flow.status === "pending") {
5233
5924
  body = /* @__PURE__ */ jsxs(Fragment, { children: [
5234
5925
  /* @__PURE__ */ jsxs("div", { className: "sg-success", children: [
@@ -5240,7 +5931,7 @@ function ExchangeCard(props) {
5240
5931
  ] }),
5241
5932
  /* @__PURE__ */ jsxs("div", { className: "sg-success-sub", children: [
5242
5933
  flow.verdict?.status === "confirmed" ? "Confirmed on-chain" : "Submitted \u2014 awaiting confirmation",
5243
- props.recipient ? ` \xB7 ${shortAddress(props.recipient)}` : ""
5934
+ recipientState.recipientFamily === "solana" ? ` \xB7 ${shortAddress(flow.lastTxEntry?.recipient || recipient)}` : props.recipient ? ` \xB7 ${shortAddress(props.recipient)}` : ""
5244
5935
  ] })
5245
5936
  ] }),
5246
5937
  /* @__PURE__ */ jsxs("div", { className: "sg-cta-wrap", children: [
@@ -5251,8 +5942,19 @@ function ExchangeCard(props) {
5251
5942
  } else {
5252
5943
  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
5944
  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
- !connected && !rampMode ? /* @__PURE__ */ jsx(Button, { onClick: wallet.connect, busy: wallet.connecting, children: "Connect wallet" }) : /* @__PURE__ */ jsx(Button, { onClick: rampMode ? void 0 : flow.submit, busy: submitting, disabled: rampMode || !quotable || !cryptoReady || connected && (!flow.selected || flow.insufficient || !!flow.nativeShortfall || flow.status === "loading"), children: ctaLabel }),
5945
+ const cta = solActive ? /* @__PURE__ */ jsxs("div", { className: "sg-cta-wrap", children: [
5946
+ solanaSteps,
5947
+ solanaCta,
5948
+ /* @__PURE__ */ jsx(RecipientNote, { state: recipientState, disabled: submitting }),
5949
+ solanaWallet.error ? /* @__PURE__ */ jsx(StatusPanel, { tone: "error", children: solanaWallet.error }) : null,
5950
+ wallet.error ? /* @__PURE__ */ jsx(StatusPanel, { tone: "error", children: wallet.error }) : null
5951
+ ] }) : /* @__PURE__ */ jsxs("div", { className: "sg-cta-wrap", children: [
5952
+ !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: [
5953
+ "Connect ",
5954
+ recipientState.recipientFamily === "solana" ? "Solana" : "EVM",
5955
+ " wallet"
5956
+ ] }) : /* @__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 }),
5957
+ !rampMode ? /* @__PURE__ */ jsx(RecipientNote, { state: recipientState, disabled: submitting }) : null,
5256
5958
  wallet.error ? /* @__PURE__ */ jsx(StatusPanel, { tone: "error", children: wallet.error }) : null
5257
5959
  ] });
5258
5960
  const notices = /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -5401,4 +6103,4 @@ function mount(el, config) {
5401
6103
  return () => root.unmount();
5402
6104
  }
5403
6105
 
5404
- export { CompliancePanel, PaymentIsland, StableGenieExchange, StableGeniePay, StableGenieProvider, StableGenieRwaExchange, StableGenieSwap, darkTheme, lightTheme, mount, resolveTheme };
6106
+ export { CompliancePanel, PaymentIsland, StableGenieExchange, StableGeniePay, StableGenieProvider, StableGenieRwaExchange, StableGenieSwap, connectSolanaWallet, darkTheme, disconnectSolanaWallet, discoverSolanaWallets, lightTheme, mount, onSolanaAccountChange, resolveTheme, solanaWalletSigner, useSolanaWallet, watchSolanaWallets };