@pollar/react 0.12.1-rc.10 → 0.12.1-rc.11

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/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import { AUTH_ERROR_CODES, rampLegTitle, rampRequirementCopy, rampTrustlineAsset, rampWalletStep, rampResolutionText, describeRampAction, rampLegStatus, rampNextApproval, rampOrderStopped, rampOrderReceive, countryName, rampRailLabel, rampNoRouteText, rampFieldError, rampFieldValid, rampLegNote, rampStepTitle, rampStepStatusText, rampLegTimeLeft, rampOrderResolutionText, rampCountries, rampQuoteFields, isPollarApiError, transactionErrorMessage, WalletType, bridgeSourceChains, bridgeTargetChains, isBridgeSettled, isPollarClient, PollarClient, isInteractiveAuthAdapter, isAuthEntryAdapterStep, completeAuthEntryStep, rampTrustlineErrorText, isPollarNetworkError, toBaseUnits, resolveLanguage, languageFromTag, localizedText, appUnavailableMessage, cosignRefusalMessage, fromBaseUnits, assertRampStellarSigner } from '@pollar/core';
2
+ import { AUTH_ERROR_CODES, rampLegTitle, rampRequirementCopy, rampTrustlineAsset, rampWalletStep, rampResolutionText, describeRampAction, rampLegStatus, rampNextApproval, rampOrderStopped, rampOrderReceive, countryName, rampRailLabel, rampNoRouteText, rampFieldError, rampFieldValid, rampLegNote, rampStepTitle, rampStepStatusText, rampLegTimeLeft, rampOrderResolutionText, rampCountries, rampQuoteFields, isPollarApiError, transactionErrorMessage, WalletType, bridgeSourceChains, bridgeTargetChains, isBridgeSettled, isPollarClient, PollarClient, isInteractiveAuthAdapter, isAuthEntryAdapterStep, completeAuthEntryStep, rampTrustlineErrorText, isPollarNetworkError, toBaseUnits, resolveLanguage, languageFromTag, localizedText, appUnavailableMessage, fromBaseUnits, cosignRefusalMessage, assertRampStellarSigner } from '@pollar/core';
3
3
  import { createContext, forwardRef, useState, useCallback, useEffect, useMemo, useRef, useContext, useSyncExternalStore, Component } from 'react';
4
4
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
5
5
  import { createPortal } from 'react-dom';
@@ -1284,7 +1284,7 @@ var PollarModalFooter = ({ language: languageProp }) => {
1284
1284
  /* @__PURE__ */ jsx("img", { src: LOGO_POLLAR_WORDMARK_ON_DARK, alt: "Pollar", className: "pollar-footer-logo pollar-logo-on-dark" }),
1285
1285
  /* @__PURE__ */ jsxs("span", { className: "pollar-footer-version", children: [
1286
1286
  "v",
1287
- "0.12.1-rc.10"
1287
+ "0.12.1-rc.11"
1288
1288
  ] })
1289
1289
  ] });
1290
1290
  };
@@ -5260,6 +5260,13 @@ function RampWidgetTemplate({
5260
5260
  )
5261
5261
  ] }) })
5262
5262
  ] }),
5263
+ !settled && view.pasteCode && /* @__PURE__ */ jsxs("div", { className: "pollar-ramp-payment-field", children: [
5264
+ /* @__PURE__ */ jsx("span", { className: "pollar-ramp-payment-label", children: view.pasteCode.label }),
5265
+ /* @__PURE__ */ jsx("div", { className: "pollar-ramp-payment-value", children: /* @__PURE__ */ jsxs("span", { style: { display: "flex", alignItems: "center", gap: 6 }, children: [
5266
+ /* @__PURE__ */ jsx("code", { style: { flex: 1, wordBreak: "break-all" }, children: view.pasteCode.value }),
5267
+ /* @__PURE__ */ jsx(CopyButton, { value: view.pasteCode.value, label: copy.copyLabel(view.pasteCode.label), language })
5268
+ ] }) })
5269
+ ] }),
5263
5270
  !settled && view.details.map((d) => /* @__PURE__ */ jsxs("div", { className: "pollar-ramp-payment-field", children: [
5264
5271
  /* @__PURE__ */ jsx("span", { className: "pollar-ramp-payment-label", children: d.label }),
5265
5272
  /* @__PURE__ */ jsx("div", { className: "pollar-ramp-payment-value", children: /* @__PURE__ */ jsxs("span", { style: { display: "flex", alignItems: "center", gap: 6 }, children: [
@@ -5267,6 +5274,7 @@ function RampWidgetTemplate({
5267
5274
  /* @__PURE__ */ jsx(CopyButton, { value: d.value, label: copy.copyLabel(d.label), language })
5268
5275
  ] }) })
5269
5276
  ] }, d.label)),
5277
+ !settled && view.action?.kind === "FIAT_PAYMENT" && view.note && /* @__PURE__ */ jsx("p", { className: "pollar-ramp-payment-note", children: view.note }),
5270
5278
  !settled && view.action?.kind === "FIAT_PAYMENT" && onCheckPayment && /* @__PURE__ */ jsx("button", { type: "button", className: "pollar-btn-primary", disabled: checkingPayment, onClick: onCheckPayment, children: checkingPayment ? /* @__PURE__ */ jsxs(Fragment, { children: [
5271
5279
  /* @__PURE__ */ jsx("span", { className: "pollar-spinner pollar-spinner-sm" }),
5272
5280
  " ",
@@ -6007,7 +6015,7 @@ function RampWidget({ onClose, language: languageProp, initial }) {
6007
6015
  return [...seen.values()];
6008
6016
  }, [routes, country, fiat]);
6009
6017
  const asset = assets.find((a) => assetKey3(a) === assetChoice) ?? assets[0] ?? null;
6010
- const fields = selected ? rampQuoteFields(selected) : [];
6018
+ const fields = selected ? rampQuoteFields(selected, language) : [];
6011
6019
  const sellAvailable = useWalletAvailable(
6012
6020
  direction === "OFFRAMP" && asset ? { chain: asset.chain, code: asset.code, issuer: asset.identifier } : null
6013
6021
  );
@@ -7094,7 +7102,9 @@ var TX_REVIEW_COPY = {
7094
7102
  asset: "Asset",
7095
7103
  expiresIn: "Expires in",
7096
7104
  rawTx: "Raw transaction",
7097
- txHash: "Transaction hash"
7105
+ txHash: "Transaction hash",
7106
+ deliversTo: "Delivers to",
7107
+ call: (n) => `Call ${n}`
7098
7108
  },
7099
7109
  viewOnExplorer: "View on explorer"
7100
7110
  },
@@ -7131,7 +7141,9 @@ var TX_REVIEW_COPY = {
7131
7141
  asset: "Activo",
7132
7142
  expiresIn: "Vence en",
7133
7143
  rawTx: "Transacci\xF3n en bruto",
7134
- txHash: "Hash de la transacci\xF3n"
7144
+ txHash: "Hash de la transacci\xF3n",
7145
+ deliversTo: "Entrega en",
7146
+ call: (n) => `Llamada ${n}`
7135
7147
  },
7136
7148
  viewOnExplorer: "Ver en el explorador"
7137
7149
  },
@@ -7168,7 +7180,9 @@ var TX_REVIEW_COPY = {
7168
7180
  asset: "Ativo",
7169
7181
  expiresIn: "Expira em",
7170
7182
  rawTx: "Transa\xE7\xE3o bruta",
7171
- txHash: "Hash da transa\xE7\xE3o"
7183
+ txHash: "Hash da transa\xE7\xE3o",
7184
+ deliversTo: "Entrega em",
7185
+ call: (n) => `Chamada ${n}`
7172
7186
  },
7173
7187
  viewOnExplorer: "Ver no explorador"
7174
7188
  }
@@ -7294,6 +7308,21 @@ function reviewFromRequest(parts, copy) {
7294
7308
  if (contract) rows.push({ label: copy.rows.contract, value: contract, copyValue: contract, mono: true });
7295
7309
  const method = asString(details.method);
7296
7310
  if (method) rows.push({ label: copy.rows.method, value: method, mono: true });
7311
+ const destinationChain = asChain(details.destinationChain);
7312
+ const destinationAddress = asString(details.destinationAddress);
7313
+ if (destinationChain && destinationChain !== parts.chain) {
7314
+ rows.push({
7315
+ label: copy.rows.deliversTo,
7316
+ value: [copy.chains[destinationChain], destinationAddress].filter(Boolean).join(" "),
7317
+ ...destinationAddress ? { copyValue: destinationAddress, mono: true } : {}
7318
+ });
7319
+ }
7320
+ if (Array.isArray(details.calls)) {
7321
+ details.calls.forEach((call, index) => {
7322
+ const target = asString(call?.to);
7323
+ if (target) rows.push({ label: copy.rows.call(index + 1), value: target, copyValue: target, mono: true });
7324
+ });
7325
+ }
7297
7326
  if (parts.appPaysFee) rows.push({ label: copy.rows.fee, value: copy.rows.feeCovered });
7298
7327
  rows.push(...parts.extraRows ?? []);
7299
7328
  return {
@@ -8396,7 +8425,26 @@ var SWAP_COPY = {
8396
8425
  invalidAmount: "Enter a valid amount",
8397
8426
  insufficientBalance: "Insufficient balance",
8398
8427
  noRouteForPair: "No route available for this pair",
8399
- quoteFailed: "Failed to fetch quote"
8428
+ quoteFailed: "Failed to fetch quote",
8429
+ receiveOn: "Receive on",
8430
+ multichainVenue: "Cross-chain route",
8431
+ fees: {
8432
+ routing: "Routing fee",
8433
+ integrator: "App fee",
8434
+ bridge_and_slippage: "Network transfer and slippage",
8435
+ other: "Other fees"
8436
+ },
8437
+ totalFees: "Total fees",
8438
+ priceRefreshesIn: (seconds) => `This price is good for ${seconds}s; a new one is asked for after.`,
8439
+ useTransferForUsdc: "USDC moves between networks with a transfer, not a swap. Choose another asset.",
8440
+ deliveredTo: "Delivered to",
8441
+ settlement: {
8442
+ pending: (chain) => `Sent from Solana. Delivering to your ${chain} wallet; this updates on its own.`,
8443
+ completed: (chain) => `Delivered to your ${chain} wallet.`,
8444
+ held: () => "Support is checking this swap. Your funds are not lost; this updates on its own.",
8445
+ refunded: () => "The delivery did not complete and the funds were returned to your Solana wallet.",
8446
+ failed: () => "The delivery did not complete. If your funds do not return, contact this app's support."
8447
+ }
8400
8448
  },
8401
8449
  es: {
8402
8450
  title: "Intercambiar",
@@ -8446,7 +8494,26 @@ var SWAP_COPY = {
8446
8494
  invalidAmount: "Ingresa un monto v\xE1lido",
8447
8495
  insufficientBalance: "Saldo insuficiente",
8448
8496
  noRouteForPair: "No hay una ruta disponible para este par",
8449
- quoteFailed: "No se pudo obtener la cotizaci\xF3n"
8497
+ quoteFailed: "No se pudo obtener la cotizaci\xF3n",
8498
+ receiveOn: "Recibir en",
8499
+ multichainVenue: "Ruta entre redes",
8500
+ fees: {
8501
+ routing: "Comisi\xF3n de ruta",
8502
+ integrator: "Comisi\xF3n de la app",
8503
+ bridge_and_slippage: "Transferencia entre redes y deslizamiento",
8504
+ other: "Otras comisiones"
8505
+ },
8506
+ totalFees: "Comisiones totales",
8507
+ priceRefreshesIn: (seconds) => `Este precio vale por ${seconds}s; luego se pide uno nuevo.`,
8508
+ useTransferForUsdc: "USDC se mueve entre redes con una transferencia, no con un intercambio. Elige otro activo.",
8509
+ deliveredTo: "Entregado en",
8510
+ settlement: {
8511
+ pending: (chain) => `Enviado desde Solana. Entregando en tu billetera de ${chain}; esto se actualiza solo.`,
8512
+ completed: (chain) => `Entregado en tu billetera de ${chain}.`,
8513
+ held: () => "Soporte est\xE1 revisando este intercambio. Tus fondos no se perdieron; esto se actualiza solo.",
8514
+ refunded: () => "La entrega no se complet\xF3 y los fondos volvieron a tu billetera de Solana.",
8515
+ failed: () => "La entrega no se complet\xF3. Si tus fondos no vuelven, contacta al soporte de esta app."
8516
+ }
8450
8517
  },
8451
8518
  pt: {
8452
8519
  title: "Trocar",
@@ -8496,7 +8563,26 @@ var SWAP_COPY = {
8496
8563
  invalidAmount: "Digite um valor v\xE1lido",
8497
8564
  insufficientBalance: "Saldo insuficiente",
8498
8565
  noRouteForPair: "Nenhuma rota dispon\xEDvel para este par",
8499
- quoteFailed: "N\xE3o foi poss\xEDvel obter a cota\xE7\xE3o"
8566
+ quoteFailed: "N\xE3o foi poss\xEDvel obter a cota\xE7\xE3o",
8567
+ receiveOn: "Receber em",
8568
+ multichainVenue: "Rota entre redes",
8569
+ fees: {
8570
+ routing: "Taxa de rota",
8571
+ integrator: "Taxa do app",
8572
+ bridge_and_slippage: "Transfer\xEAncia entre redes e derrapagem",
8573
+ other: "Outras taxas"
8574
+ },
8575
+ totalFees: "Taxas totais",
8576
+ priceRefreshesIn: (seconds) => `Este pre\xE7o vale por ${seconds}s; depois um novo \xE9 pedido.`,
8577
+ useTransferForUsdc: "USDC se move entre redes com uma transfer\xEAncia, n\xE3o com uma troca. Escolha outro ativo.",
8578
+ deliveredTo: "Entregue em",
8579
+ settlement: {
8580
+ pending: (chain) => `Enviado da Solana. Entregando na sua carteira ${chain}; isto se atualiza sozinho.`,
8581
+ completed: (chain) => `Entregue na sua carteira ${chain}.`,
8582
+ held: () => "O suporte est\xE1 verificando esta troca. Seus fundos n\xE3o foram perdidos; isto se atualiza sozinho.",
8583
+ refunded: () => "A entrega n\xE3o foi conclu\xEDda e os fundos voltaram para a sua carteira Solana.",
8584
+ failed: () => "A entrega n\xE3o foi conclu\xEDda. Se seus fundos n\xE3o voltarem, fale com o suporte deste app."
8585
+ }
8500
8586
  }
8501
8587
  };
8502
8588
  function assetOptionKey(o) {
@@ -8509,8 +8595,12 @@ var PROVIDER_LABELS = {
8509
8595
  jupiter: "Jupiter",
8510
8596
  titan: "Titan"
8511
8597
  };
8512
- var providerLabel = (provider, copy) => provider === "auto" ? copy.bestPrice : PROVIDER_LABELS[provider] ?? provider;
8513
- var CHAIN_LABELS = { STELLAR: "Stellar", SOLANA: "Solana" };
8598
+ var providerLabel = (provider, copy) => provider === "auto" ? copy.bestPrice : provider === "multichain" ? copy.multichainVenue : PROVIDER_LABELS[provider] ?? provider;
8599
+ var CHAIN_LABELS = {
8600
+ STELLAR: "Stellar",
8601
+ SOLANA: "Solana",
8602
+ POLYGON: "Polygon"
8603
+ };
8514
8604
  function formatAmount2(value) {
8515
8605
  if (value === void 0) return "\u2014";
8516
8606
  const n = parseFloat(value);
@@ -8591,6 +8681,10 @@ function SwapModalTemplate({
8591
8681
  amount,
8592
8682
  chains,
8593
8683
  chain,
8684
+ destinations = [],
8685
+ destination = "SOLANA",
8686
+ usdcAcross = false,
8687
+ settlement = null,
8594
8688
  provider,
8595
8689
  providers,
8596
8690
  quote,
@@ -8620,6 +8714,7 @@ function SwapModalTemplate({
8620
8714
  onMax,
8621
8715
  onAmountChange,
8622
8716
  onChainChange,
8717
+ onDestinationChange,
8623
8718
  onProviderChange,
8624
8719
  onSwap,
8625
8720
  onToggleXdr,
@@ -8648,7 +8743,7 @@ function SwapModalTemplate({
8648
8743
  const sellKey = selectedSell ? assetOptionKey(selectedSell) : "";
8649
8744
  const buyKey = selectedBuy ? assetOptionKey(selectedBuy) : "";
8650
8745
  const sameAsset = !!selectedSell && !!selectedBuy && sellKey === buyKey;
8651
- const canSwap = !smartUnsupported && !sameAsset && !!selectedSell && !!selectedBuy && !!amount && !!quote && !quoteLoading && !isLoadingData;
8746
+ const canSwap = !smartUnsupported && !sameAsset && !!selectedSell && !!selectedBuy && !!amount && !!quote && !quoteLoading && !usdcAcross && !isLoadingData;
8652
8747
  const rate = quote && amount ? formatRate(quote.amountOut, amount) : null;
8653
8748
  const title = step === "form" ? copy.title : txTitle;
8654
8749
  const selectSell = (key) => {
@@ -8704,6 +8799,24 @@ function SwapModalTemplate({
8704
8799
  }
8705
8800
  )
8706
8801
  ] }),
8802
+ destinations.length > 1 && /* @__PURE__ */ jsxs("label", { className: "pollar-swap-route-wrap pollar-swap-chain-wrap", children: [
8803
+ /* @__PURE__ */ jsx("span", { className: "sr-only", children: copy.receiveOn }),
8804
+ /* @__PURE__ */ jsx(
8805
+ "select",
8806
+ {
8807
+ className: "pollar-swap-route-pill",
8808
+ "aria-label": copy.receiveOn,
8809
+ value: destination,
8810
+ disabled: configLoading || isLoadingData,
8811
+ onChange: (event) => onDestinationChange?.(event.target.value),
8812
+ children: destinations.map((c) => /* @__PURE__ */ jsxs("option", { value: c, children: [
8813
+ copy.receiveOn,
8814
+ " ",
8815
+ CHAIN_LABELS[c]
8816
+ ] }, c))
8817
+ }
8818
+ )
8819
+ ] }),
8707
8820
  smartUnsupported && chain === "STELLAR" && /* @__PURE__ */ jsx("div", { className: "pollar-modal-error", children: copy.smartUnavailable }),
8708
8821
  /* @__PURE__ */ jsxs("div", { className: "pollar-swap-panels", children: [
8709
8822
  /* @__PURE__ */ jsxs("section", { className: "pollar-swap-panel", "aria-labelledby": "pollar-swap-pay-label", children: [
@@ -8879,7 +8992,8 @@ function SwapModalTemplate({
8879
8992
  ] })
8880
8993
  ] }),
8881
8994
  !quoteLoading && quoteError && /* @__PURE__ */ jsx("div", { className: "pollar-modal-error", children: quoteError }),
8882
- !quoteLoading && !quoteError && !quote && selectedSell && selectedBuy && !!amount && /* @__PURE__ */ jsx("div", { className: "pollar-send-hint", children: copy.noRoute }),
8995
+ usdcAcross && /* @__PURE__ */ jsx("div", { className: "pollar-send-hint", children: copy.useTransferForUsdc }),
8996
+ !usdcAcross && !quoteLoading && !quoteError && !quote && selectedSell && selectedBuy && !!amount && /* @__PURE__ */ jsx("div", { className: "pollar-send-hint", children: copy.noRoute }),
8883
8997
  quote && /* @__PURE__ */ jsxs("div", { className: "pollar-swap-quote", children: [
8884
8998
  /* @__PURE__ */ jsxs("div", { className: "pollar-swap-quote-row", children: [
8885
8999
  /* @__PURE__ */ jsx("span", { children: copy.minimumReceived }),
@@ -8896,7 +9010,19 @@ function SwapModalTemplate({
8896
9010
  /* @__PURE__ */ jsxs("div", { className: "pollar-swap-quote-row", children: [
8897
9011
  /* @__PURE__ */ jsx("span", { children: copy.route }),
8898
9012
  /* @__PURE__ */ jsx("strong", { children: providerLabel(quote.provider, copy) })
8899
- ] })
9013
+ ] }),
9014
+ (quote.fees ?? []).map((fee) => /* @__PURE__ */ jsxs("div", { className: "pollar-swap-quote-row", children: [
9015
+ /* @__PURE__ */ jsx("span", { children: fee.label }),
9016
+ /* @__PURE__ */ jsx("strong", { children: fee.value })
9017
+ ] }, fee.label)),
9018
+ quote.totalFeesUsd != null && /* @__PURE__ */ jsxs("div", { className: "pollar-swap-quote-row", children: [
9019
+ /* @__PURE__ */ jsx("span", { children: copy.totalFees }),
9020
+ /* @__PURE__ */ jsxs("strong", { children: [
9021
+ "$",
9022
+ quote.totalFeesUsd.toFixed(2)
9023
+ ] })
9024
+ ] }),
9025
+ quote.expiresInSeconds != null && /* @__PURE__ */ jsx("div", { className: "pollar-send-hint", "aria-live": "off", children: copy.priceRefreshesIn(quote.expiresInSeconds) })
8900
9026
  ] }),
8901
9027
  buyNeedsTrustline && selectedBuy && /* @__PURE__ */ jsx("div", { className: "pollar-swap-trustline-notice", children: copy.trustlineNotice(selectedBuy.code) }),
8902
9028
  sameAsset && /* @__PURE__ */ jsx("div", { className: "pollar-modal-error", children: copy.sameAsset }),
@@ -8919,12 +9045,42 @@ function SwapModalTemplate({
8919
9045
  onDone
8920
9046
  }
8921
9047
  ),
9048
+ step === "tx" && settlement && /* @__PURE__ */ jsxs(
9049
+ "div",
9050
+ {
9051
+ className: settlement.kind === "failed" ? "pollar-modal-error" : "pollar-swap-quote",
9052
+ role: "status",
9053
+ "aria-live": "polite",
9054
+ children: [
9055
+ /* @__PURE__ */ jsx("div", { children: settlement.text }),
9056
+ settlement.address && /* @__PURE__ */ jsxs("div", { className: "pollar-swap-quote-row", children: [
9057
+ /* @__PURE__ */ jsx("span", { children: copy.deliveredTo }),
9058
+ /* @__PURE__ */ jsx("code", { style: { wordBreak: "break-all" }, children: settlement.address })
9059
+ ] }),
9060
+ settlement.explorerUrl && /* @__PURE__ */ jsx("a", { href: settlement.explorerUrl, target: "_blank", rel: "noopener noreferrer", children: settlement.explorerUrl.replace(/^https:\/\//, "").split("/")[0] })
9061
+ ]
9062
+ }
9063
+ ),
8922
9064
  /* @__PURE__ */ jsx(PollarModalFooter, {})
8923
9065
  ]
8924
9066
  }
8925
9067
  );
8926
9068
  }
8927
9069
  var QUOTE_DEBOUNCE_MS = 400;
9070
+ var SETTLEMENT_POLL_MS = 5e3;
9071
+ var SETTLEMENT_FINAL = /* @__PURE__ */ new Set(["COMPLETED", "FAILED", "REFUNDED", "EXPIRED"]);
9072
+ function newSwapKey() {
9073
+ return typeof crypto !== "undefined" && "randomUUID" in crypto ? crypto.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
9074
+ }
9075
+ function chargeText(charge) {
9076
+ if (charge.amount !== null && charge.decimals !== null && charge.symbol) {
9077
+ try {
9078
+ return `${fromBaseUnits(charge.amount, charge.decimals)} ${charge.symbol}`;
9079
+ } catch {
9080
+ }
9081
+ }
9082
+ return charge.amountUsd !== null ? `$${charge.amountUsd.toFixed(2)}` : null;
9083
+ }
8928
9084
  function toRef(a) {
8929
9085
  if (a.type === "native") return { type: "native" };
8930
9086
  if (a.type === "credit_alphanum4") return { type: "credit_alphanum4", code: a.code, issuer: a.issuer };
@@ -8955,9 +9111,10 @@ function SwapModal({ onClose, initial }) {
8955
9111
  getSwapTokens,
8956
9112
  getSwapQuote,
8957
9113
  swap,
8958
- getSolanaSwapConfig,
9114
+ getSolanaSwapOptions,
8959
9115
  getSolanaSwapQuote,
8960
9116
  swapSolana,
9117
+ getSwapStatus,
8961
9118
  walletBalance,
8962
9119
  refreshWalletBalance,
8963
9120
  enabledAssets,
@@ -8983,6 +9140,12 @@ function SwapModal({ onClose, initial }) {
8983
9140
  const [venues, setVenues] = useState(null);
8984
9141
  const [solanaVenues, setSolanaVenues] = useState(null);
8985
9142
  const [solanaQuotes, setSolanaQuotes] = useState([]);
9143
+ const [destinationChains, setDestinationChains] = useState([]);
9144
+ const destinationSeed = useRef(initial?.destinationChain);
9145
+ const [destination, setDestination] = useState("SOLANA");
9146
+ const [requote, setRequote] = useState(0);
9147
+ const [now, setNow] = useState(() => Date.now());
9148
+ const [settlement, setSettlement] = useState(null);
8986
9149
  const [catalogTokens, setCatalogTokens] = useState([]);
8987
9150
  const [customTokens, setCustomTokens] = useState([]);
8988
9151
  const [quotes, setQuotes] = useState([]);
@@ -9003,9 +9166,21 @@ function SwapModal({ onClose, initial }) {
9003
9166
  return Promise.all([
9004
9167
  getSwapConfig().then(setVenues).catch(() => setVenues([])),
9005
9168
  // treat a failed config as "unavailable"
9006
- getSolanaSwapConfig().then(setSolanaVenues).catch(() => setSolanaVenues([]))
9169
+ getSolanaSwapOptions().then((options) => {
9170
+ setSolanaVenues(options.venues);
9171
+ setDestinationChains(options.destinationChains);
9172
+ }).catch(() => {
9173
+ setSolanaVenues([]);
9174
+ setDestinationChains([]);
9175
+ })
9007
9176
  ]);
9008
- }, [getSwapConfig, getSolanaSwapConfig]);
9177
+ }, [getSwapConfig, getSolanaSwapOptions]);
9178
+ useEffect(() => {
9179
+ const wanted = destinationSeed.current;
9180
+ if (!wanted || solanaVenues === null) return;
9181
+ destinationSeed.current = void 0;
9182
+ if (wanted === "SOLANA" || destinationChains.includes(wanted)) setDestination(wanted);
9183
+ }, [solanaVenues, destinationChains]);
9009
9184
  useEffect(() => {
9010
9185
  void loadConfig();
9011
9186
  }, [loadConfig]);
@@ -9087,8 +9262,16 @@ function SwapModal({ onClose, initial }) {
9087
9262
  enabledInApp: true
9088
9263
  }))
9089
9264
  ];
9265
+ const crossChain = chain === "SOLANA" && destination !== "SOLANA";
9266
+ const destinationBuy = assetRecords.filter((a) => a.chain === destination && a.type === "token" && !!a.issuer && a.decimals !== void 0).map((a) => ({
9267
+ code: a.code,
9268
+ issuer: a.issuer,
9269
+ decimals: a.decimals,
9270
+ available: balances.find((b) => b.chain === destination && b.issuer?.toLowerCase() === a.issuer.toLowerCase())?.available ?? void 0,
9271
+ enabledInApp: true
9272
+ }));
9090
9273
  const sellOptions = chain === "SOLANA" ? solanaSell : stellarSell;
9091
- const buyOptions = (chain === "SOLANA" ? solanaBuy : stellarBuy).filter(
9274
+ const buyOptions = (chain === "SOLANA" ? crossChain ? destinationBuy : solanaBuy : stellarBuy).filter(
9092
9275
  (o) => optKey(o) !== buyKeyOfSell || optKey(o) === (selectedBuy ? optKey(selectedBuy) : "")
9093
9276
  );
9094
9277
  useEffect(() => {
@@ -9141,16 +9324,38 @@ function SwapModal({ onClose, initial }) {
9141
9324
  [venues, solanaVenues]
9142
9325
  );
9143
9326
  const swapUnavailable = !configLoading && chains.length === 0;
9144
- const chainVenues = (chain === "SOLANA" ? solanaVenues : venues) ?? [];
9327
+ const chainVenues = ((chain === "SOLANA" ? solanaVenues : venues) ?? []).filter(
9328
+ (v) => !crossChain || v === "multichain"
9329
+ );
9330
+ const destinations = chain === "SOLANA" && destinationChains.length > 0 ? ["SOLANA", ...destinationChains] : [];
9331
+ const usdcAcross = crossChain && selectedSell?.code === "USDC" && selectedBuy?.code === "USDC";
9145
9332
  const providers = chainVenues.length > 0 ? ["auto", ...chainVenues] : [];
9146
9333
  const quote = quotes[0] ?? null;
9147
- const solanaQuote = solanaQuotes[0] ?? null;
9148
- const quoteView = chain === "SOLANA" ? solanaQuote && selectedBuy?.decimals !== void 0 ? {
9334
+ const quotedSolana = solanaQuotes[0] ?? null;
9335
+ const solanaQuote = quotedSolana?.expiresAt && Date.parse(quotedSolana.expiresAt) <= now ? null : quotedSolana;
9336
+ const outDecimals = solanaQuote?.outputDecimals ?? selectedBuy?.decimals;
9337
+ const quoteView = chain === "SOLANA" ? solanaQuote && outDecimals !== void 0 ? {
9149
9338
  provider: solanaQuote.provider,
9150
- amountOut: fromBaseUnits3(solanaQuote.outAmount, selectedBuy.decimals),
9151
- minReceived: fromBaseUnits3(solanaQuote.minOut, selectedBuy.decimals),
9152
- priceImpactPct: solanaQuote.priceImpactPct
9339
+ amountOut: fromBaseUnits3(solanaQuote.outAmount, outDecimals),
9340
+ minReceived: fromBaseUnits3(solanaQuote.minOut, outDecimals),
9341
+ priceImpactPct: solanaQuote.priceImpactPct,
9342
+ fees: (solanaQuote.feeBreakdown?.charges ?? []).flatMap((charge) => {
9343
+ const value = chargeText(charge);
9344
+ return value ? [{ label: copy.fees[charge.kind] ?? copy.fees.other, value }] : [];
9345
+ }),
9346
+ totalFeesUsd: solanaQuote.feeBreakdown?.totalFeesUsd ?? null,
9347
+ expiresInSeconds: solanaQuote.expiresAt ? Math.max(0, Math.round((Date.parse(solanaQuote.expiresAt) - now) / 1e3)) : null
9153
9348
  } : null : quote;
9349
+ useEffect(() => {
9350
+ const expiresAt = quotedSolana?.expiresAt ? Date.parse(quotedSolana.expiresAt) : NaN;
9351
+ if (step !== "form" || Number.isNaN(expiresAt)) return;
9352
+ const tick = setInterval(() => setNow(Date.now()), 1e3);
9353
+ const lapse = setTimeout(() => setRequote((n) => n + 1), Math.max(0, expiresAt - Date.now()));
9354
+ return () => {
9355
+ clearInterval(tick);
9356
+ clearTimeout(lapse);
9357
+ };
9358
+ }, [quotedSolana, step]);
9154
9359
  useEffect(() => {
9155
9360
  if (chains.length > 0 && !chains.includes(chain)) setChain(chains[0]);
9156
9361
  }, [chains, chain]);
@@ -9166,8 +9371,16 @@ function SwapModal({ onClose, initial }) {
9166
9371
  setSolanaQuotes([]);
9167
9372
  setFormError("");
9168
9373
  }
9374
+ function handleDestinationChange(next) {
9375
+ buySeed.current = void 0;
9376
+ setDestination(next);
9377
+ setSelectedBuy(null);
9378
+ setProvider("auto");
9379
+ setSolanaQuotes([]);
9380
+ setFormError("");
9381
+ }
9169
9382
  useEffect(() => {
9170
- if (step !== "form" || swapUnavailable || configLoading || !selectedSell || !selectedBuy || !amount || parseFloat(amount) <= 0) {
9383
+ if (step !== "form" || swapUnavailable || configLoading || !selectedSell || !selectedBuy || !amount || parseFloat(amount) <= 0 || usdcAcross) {
9171
9384
  setQuotes([]);
9172
9385
  setSolanaQuotes([]);
9173
9386
  setQuoteError("");
@@ -9187,7 +9400,8 @@ function SwapModal({ onClose, initial }) {
9187
9400
  outputMint: selectedBuy.issuer,
9188
9401
  amount: units,
9189
9402
  provider,
9190
- slippageBps
9403
+ slippageBps,
9404
+ ...crossChain && { destinationChain: destination }
9191
9405
  });
9192
9406
  if (!cancelled) setSolanaQuotes(qs);
9193
9407
  } else {
@@ -9226,13 +9440,49 @@ function SwapModal({ onClose, initial }) {
9226
9440
  provider,
9227
9441
  getSwapQuote,
9228
9442
  getSolanaSwapQuote,
9229
- copy
9443
+ copy,
9444
+ crossChain,
9445
+ destination,
9446
+ usdcAcross,
9447
+ requote
9230
9448
  ]);
9449
+ const settlementKey = settlement?.key ?? null;
9450
+ const settlementDone = !!settlement?.value && SETTLEMENT_FINAL.has(settlement.value.status);
9451
+ const originLanded = transaction.step === "success";
9452
+ useEffect(() => {
9453
+ if (!settlementKey || settlementDone || !originLanded) return;
9454
+ let cancelled = false;
9455
+ const read = () => getSwapStatus(settlementKey).then((status) => {
9456
+ if (!cancelled)
9457
+ setSettlement((cur) => cur && cur.key === settlementKey ? { ...cur, value: status.settlement } : cur);
9458
+ }).catch(() => {
9459
+ });
9460
+ void read();
9461
+ const id = setInterval(read, SETTLEMENT_POLL_MS);
9462
+ return () => {
9463
+ cancelled = true;
9464
+ clearInterval(id);
9465
+ };
9466
+ }, [settlementKey, settlementDone, originLanded, getSwapStatus]);
9231
9467
  const hash = transaction.step === "success" ? transaction.hash : null;
9232
9468
  useSuccessReport(transaction, step === "tx", initial?.onSuccess);
9233
9469
  const buildData = "buildData" in transaction ? transaction.buildData : null;
9234
9470
  const explorerNetwork = buildData?.summary.network?.toLowerCase().includes("testnet") ? "testnet" : buildData ? "public" : network === "testnet" ? "testnet" : "public";
9235
9471
  const explorerUrl = !hash ? null : chain === "SOLANA" ? `https://solscan.io/tx/${hash}${network === "testnet" ? "?cluster=devnet" : ""}` : `https://stellar.expert/explorer/${explorerNetwork}/tx/${hash}`;
9472
+ const settlementView = (() => {
9473
+ if (!settlement || transaction.step !== "success") return null;
9474
+ const chainName = settlement.chain === "POLYGON" ? "Polygon" : "Solana";
9475
+ const status = settlement.value?.status ?? "PENDING";
9476
+ const kind = status === "COMPLETED" ? "completed" : status === "HELD" ? "held" : status === "REFUNDED" ? "refunded" : status === "FAILED" || status === "EXPIRED" ? "failed" : "pending";
9477
+ const destinationHash = settlement.value?.destinationTxHash ?? null;
9478
+ const scan = network === "testnet" ? "https://amoy.polygonscan.com" : "https://polygonscan.com";
9479
+ return {
9480
+ kind,
9481
+ text: copy.settlement[kind](chainName),
9482
+ address: settlement.value?.destinationAddress ?? null,
9483
+ explorerUrl: destinationHash && settlement.chain === "POLYGON" ? `${scan}/tx/${destinationHash}` : null
9484
+ };
9485
+ })();
9236
9486
  const IN_FLIGHT_STEPS3 = [
9237
9487
  "building",
9238
9488
  "signing",
@@ -9268,8 +9518,11 @@ function SwapModal({ onClose, initial }) {
9268
9518
  setFormError(copy.noRouteForPair);
9269
9519
  return;
9270
9520
  }
9521
+ const key = newSwapKey();
9522
+ const toward = solanaQuote.destinationChain;
9523
+ setSettlement(toward && toward !== "SOLANA" ? { key, chain: toward, value: null } : null);
9271
9524
  setStep("tx");
9272
- await swapSolana(solanaQuote, { slippageBps });
9525
+ await swapSolana(solanaQuote, { slippageBps, idempotencyKey: key });
9273
9526
  return;
9274
9527
  }
9275
9528
  if (!quote) {
@@ -9282,7 +9535,11 @@ function SwapModal({ onClose, initial }) {
9282
9535
  async function handleRetry() {
9283
9536
  if (transaction.step !== "error") return;
9284
9537
  if (chain === "SOLANA") {
9285
- if (solanaQuote) await swapSolana(solanaQuote, { slippageBps });
9538
+ if (!solanaQuote) return;
9539
+ const key = newSwapKey();
9540
+ const toward = solanaQuote.destinationChain;
9541
+ setSettlement(toward && toward !== "SOLANA" ? { key, chain: toward, value: null } : null);
9542
+ await swapSolana(solanaQuote, { slippageBps, idempotencyKey: key });
9286
9543
  return;
9287
9544
  }
9288
9545
  if (quote) await swap(quote);
@@ -9310,6 +9567,7 @@ function SwapModal({ onClose, initial }) {
9310
9567
  });
9311
9568
  }
9312
9569
  function handleBack() {
9570
+ setSettlement(null);
9313
9571
  setStep("form");
9314
9572
  setShowXdr(false);
9315
9573
  setCopied(false);
@@ -9329,6 +9587,10 @@ function SwapModal({ onClose, initial }) {
9329
9587
  amount,
9330
9588
  chains,
9331
9589
  chain,
9590
+ destinations,
9591
+ destination,
9592
+ usdcAcross,
9593
+ settlement: settlementView,
9332
9594
  provider,
9333
9595
  providers,
9334
9596
  quote: quoteView,
@@ -9364,6 +9626,7 @@ function SwapModal({ onClose, initial }) {
9364
9626
  onAddCustomToken: addCustomToken,
9365
9627
  onAmountChange: setAmount,
9366
9628
  onChainChange: handleChainChange,
9629
+ onDestinationChange: handleDestinationChange,
9367
9630
  onProviderChange: setProvider,
9368
9631
  onSwap: () => void handleSwap(),
9369
9632
  onToggleXdr: () => setShowXdr((v) => !v),
@@ -10024,7 +10287,13 @@ var EARN_COPY = {
10024
10287
  exceedsWallet: "Amount exceeds your wallet balance",
10025
10288
  exceedsPosition: "Amount exceeds your position",
10026
10289
  trustlineFailed: (code, details) => `Trustline for ${code} failed: ${details}`,
10027
- unknownError: "unknown error"
10290
+ unknownError: "unknown error",
10291
+ network: "Network",
10292
+ opportunity: "Opportunity",
10293
+ apyAfterFees: "APY after fees",
10294
+ profit: "Earned after fees",
10295
+ stale: "Last known figures; they refresh on their own.",
10296
+ actionUnavailable: (action) => `This opportunity does not take ${action === "deposit" ? "deposits" : "withdrawals"} right now.`
10028
10297
  },
10029
10298
  es: {
10030
10299
  title: "Rendimientos",
@@ -10059,7 +10328,13 @@ var EARN_COPY = {
10059
10328
  exceedsWallet: "El monto supera el saldo de tu billetera",
10060
10329
  exceedsPosition: "El monto supera tu posici\xF3n",
10061
10330
  trustlineFailed: (code, details) => `No se pudo crear la trustline de ${code}: ${details}`,
10062
- unknownError: "error desconocido"
10331
+ unknownError: "error desconocido",
10332
+ network: "Red",
10333
+ opportunity: "Oportunidad",
10334
+ apyAfterFees: "APY despu\xE9s de comisiones",
10335
+ profit: "Ganado despu\xE9s de comisiones",
10336
+ stale: "\xDAltimas cifras conocidas; se actualizan solas.",
10337
+ actionUnavailable: (action) => `Esta oportunidad no acepta ${action === "deposit" ? "dep\xF3sitos" : "retiros"} en este momento.`
10063
10338
  },
10064
10339
  pt: {
10065
10340
  title: "Rendimentos",
@@ -10094,7 +10369,13 @@ var EARN_COPY = {
10094
10369
  exceedsWallet: "O valor excede o saldo da sua carteira",
10095
10370
  exceedsPosition: "O valor excede a sua posi\xE7\xE3o",
10096
10371
  trustlineFailed: (code, details) => `N\xE3o foi poss\xEDvel criar a trustline de ${code}: ${details}`,
10097
- unknownError: "erro desconhecido"
10372
+ unknownError: "erro desconhecido",
10373
+ network: "Rede",
10374
+ opportunity: "Oportunidade",
10375
+ apyAfterFees: "APY ap\xF3s taxas",
10376
+ profit: "Ganho ap\xF3s taxas",
10377
+ stale: "\xDAltimos valores conhecidos; eles se atualizam sozinhos.",
10378
+ actionUnavailable: (action) => `Esta oportunidade n\xE3o aceita ${action === "deposit" ? "dep\xF3sitos" : "saques"} no momento.`
10098
10379
  }
10099
10380
  };
10100
10381
  var POSITION_POLL_MS = 1e4;
@@ -10121,6 +10402,11 @@ function EarnModal({ onClose, initial }) {
10121
10402
  getEarnPosition,
10122
10403
  earnDeposit,
10123
10404
  earnWithdraw,
10405
+ getSolanaEarnProviders,
10406
+ getSolanaEarnOpportunities,
10407
+ getSolanaEarnPosition,
10408
+ earnSolanaDeposit,
10409
+ earnSolanaWithdraw,
10124
10410
  tx: transaction,
10125
10411
  wallet,
10126
10412
  refreshWalletBalance,
@@ -10132,13 +10418,20 @@ function EarnModal({ onClose, initial }) {
10132
10418
  } = usePollar();
10133
10419
  const copy = EARN_COPY[useModalLanguage()];
10134
10420
  const walletType = wallet?.custody === "external" ? wallet.provider : null;
10135
- const smartUnsupported = wallet?.custody === "smart";
10421
+ const [earnChain, setEarnChain] = useState(
10422
+ () => oneOf(["STELLAR", "SOLANA"], initial?.chain) ?? "STELLAR"
10423
+ );
10424
+ const onSolana = earnChain === "SOLANA";
10425
+ const smartUnsupported = !onSolana && wallet?.custody === "smart";
10136
10426
  const { theme, accentColor, styleOverrides, overlayStyle } = modalChrome(styles);
10137
10427
  const [step, setStep] = useState("form");
10138
10428
  const [tab, setTab] = useState(
10139
10429
  () => oneOf(["deposit", "withdraw"], initial?.tab) ?? "deposit"
10140
10430
  );
10141
10431
  const [providers, setProviders] = useState(null);
10432
+ const [solanaProviders, setSolanaProviders] = useState(null);
10433
+ const [solanaOpportunities, setSolanaOpportunities] = useState([]);
10434
+ const [solanaPosition, setSolanaPosition] = useState(null);
10142
10435
  const [provider, setProvider] = useState(null);
10143
10436
  const [opportunities, setOpportunities] = useState([]);
10144
10437
  const [opportunityId, setOpportunityId] = useState(() => initial?.opportunityId ?? "");
@@ -10152,11 +10445,15 @@ function EarnModal({ onClose, initial }) {
10152
10445
  const copyTimerRef = useRef(null);
10153
10446
  const loadProviders = useCallback(() => {
10154
10447
  setProviders(null);
10155
- return getEarnProviders().then((ps) => {
10156
- setProviders(ps);
10157
- setProvider((cur) => cur ?? oneOf(ps, initial?.provider) ?? ps[0] ?? null);
10158
- }).catch(() => setProviders([]));
10159
- }, [getEarnProviders, initial?.provider]);
10448
+ setSolanaProviders(null);
10449
+ return Promise.all([
10450
+ getEarnProviders().then((ps) => {
10451
+ setProviders(ps);
10452
+ setProvider((cur) => cur ?? oneOf(ps, initial?.provider) ?? ps[0] ?? null);
10453
+ }).catch(() => setProviders([])),
10454
+ getSolanaEarnProviders().then(setSolanaProviders).catch(() => setSolanaProviders([]))
10455
+ ]);
10456
+ }, [getEarnProviders, getSolanaEarnProviders, initial?.provider]);
10160
10457
  useEffect(() => {
10161
10458
  void loadProviders();
10162
10459
  }, [loadProviders]);
@@ -10165,7 +10462,7 @@ function EarnModal({ onClose, initial }) {
10165
10462
  void refreshAssets();
10166
10463
  }, [refreshWalletBalance, refreshAssets]);
10167
10464
  useEffect(() => {
10168
- if (!provider) return;
10465
+ if (!provider || onSolana) return;
10169
10466
  let cancelled = false;
10170
10467
  setLoadingOpps(true);
10171
10468
  getEarnOpportunities(provider).then((opps) => {
@@ -10180,35 +10477,66 @@ function EarnModal({ onClose, initial }) {
10180
10477
  return () => {
10181
10478
  cancelled = true;
10182
10479
  };
10183
- }, [provider, getEarnOpportunities]);
10184
- const selectedOpportunity = opportunities.find((o) => o.id === opportunityId) ?? null;
10480
+ }, [provider, onSolana, getEarnOpportunities]);
10481
+ const networks = useMemo(
10482
+ () => [
10483
+ ...providers && providers.length > 0 ? ["STELLAR"] : [],
10484
+ ...solanaProviders && solanaProviders.length > 0 ? ["SOLANA"] : []
10485
+ ],
10486
+ [providers, solanaProviders]
10487
+ );
10488
+ const networksLoading = providers === null || solanaProviders === null;
10489
+ useEffect(() => {
10490
+ if (!networksLoading && networks.length > 0 && !networks.includes(earnChain)) setEarnChain(networks[0]);
10491
+ }, [networksLoading, networks, earnChain]);
10492
+ const loadSolanaOpportunities = useCallback(() => {
10493
+ setLoadingOpps(true);
10494
+ return getSolanaEarnOpportunities().then((opps) => {
10495
+ setSolanaOpportunities(opps);
10496
+ setOpportunityId((cur) => opps.some((o) => o.id === cur) ? cur : opps[0]?.id ?? "");
10497
+ }).catch(() => setSolanaOpportunities([])).finally(() => setLoadingOpps(false));
10498
+ }, [getSolanaEarnOpportunities]);
10499
+ useEffect(() => {
10500
+ if (onSolana && solanaProviders && solanaProviders.length > 0) void loadSolanaOpportunities();
10501
+ }, [onSolana, solanaProviders, loadSolanaOpportunities]);
10502
+ const selectedOpportunity = onSolana ? null : opportunities.find((o) => o.id === opportunityId) ?? null;
10503
+ const selectedSolana = onSolana ? solanaOpportunities.find((o) => o.id === opportunityId) ?? null : null;
10185
10504
  const refreshPosition = useCallback(() => {
10186
- if (!provider || !opportunityId || !wallet) return;
10505
+ if (!opportunityId || !wallet) return;
10506
+ if (onSolana) {
10507
+ getSolanaEarnPosition(opportunityId).then(setSolanaPosition).catch(() => {
10508
+ });
10509
+ return;
10510
+ }
10511
+ if (!provider) return;
10187
10512
  getEarnPosition({ provider, opportunity: opportunityId }).then(setPosition).catch(() => {
10188
10513
  });
10189
- }, [provider, opportunityId, wallet, getEarnPosition]);
10514
+ }, [onSolana, provider, opportunityId, wallet, getEarnPosition, getSolanaEarnPosition]);
10190
10515
  useEffect(() => {
10191
10516
  setPosition(null);
10517
+ setSolanaPosition(null);
10192
10518
  refreshPosition();
10193
10519
  }, [refreshPosition]);
10194
10520
  useEffect(() => {
10195
- if (step !== "form" || !provider || !opportunityId) return;
10521
+ if (step !== "form" || !onSolana && !provider || !opportunityId) return;
10196
10522
  const id = setInterval(refreshPosition, POSITION_POLL_MS);
10197
10523
  return () => clearInterval(id);
10198
- }, [step, provider, opportunityId, refreshPosition]);
10524
+ }, [step, onSolana, provider, opportunityId, refreshPosition]);
10199
10525
  useEffect(
10200
10526
  () => () => {
10201
10527
  if (copyTimerRef.current !== null) clearTimeout(copyTimerRef.current);
10202
10528
  },
10203
10529
  []
10204
10530
  );
10205
- const providersLoading = providers === null;
10206
- const earnUnavailable = providers !== null && providers.length === 0;
10207
- const withdrawUnit = position?.withdrawUnit ?? "asset";
10208
- const assetCode = selectedOpportunity?.asset.code ?? "";
10531
+ const providersLoading = networksLoading;
10532
+ const earnUnavailable = !networksLoading && networks.length === 0;
10533
+ const withdrawUnit = onSolana ? "asset" : position?.withdrawUnit ?? "asset";
10534
+ const assetCode = (onSolana ? selectedSolana?.asset.code : selectedOpportunity?.asset.code) ?? "";
10209
10535
  const amountUnitLabel = tab === "deposit" ? assetCode : withdrawUnit === "shares" ? copy.shares : assetCode;
10536
+ const actionUnavailable = !!selectedSolana && !selectedSolana.actions.includes(tab);
10537
+ const withdrawable = onSolana ? solanaPosition?.withdrawable : position?.withdrawable;
10210
10538
  const walletAvailable = useWalletAvailable(
10211
- selectedOpportunity ? { chain: "STELLAR", code: assetCode, issuer: selectedOpportunity.asset.issuer } : null
10539
+ selectedSolana ? { chain: "SOLANA", code: assetCode, issuer: selectedSolana.asset.address } : selectedOpportunity ? { chain: "STELLAR", code: assetCode, issuer: selectedOpportunity.asset.issuer } : null
10212
10540
  );
10213
10541
  const depositAssetRecord = (() => {
10214
10542
  if (!selectedOpportunity?.asset.issuer || enabledAssets.step !== "loaded") return void 0;
@@ -10216,18 +10544,18 @@ function EarnModal({ onClose, initial }) {
10216
10544
  (a) => (a.chain === void 0 || a.chain === "STELLAR") && a.code === assetCode && a.issuer === selectedOpportunity.asset.issuer
10217
10545
  );
10218
10546
  })();
10219
- const depositNeedsTrustline = tab === "deposit" && !smartUnsupported && !!selectedOpportunity?.asset.issuer && !depositAssetRecord?.trustlineEstablished;
10547
+ const depositNeedsTrustline = !onSolana && tab === "deposit" && !smartUnsupported && !!selectedOpportunity?.asset.issuer && !depositAssetRecord?.trustlineEstablished;
10220
10548
  const hash = transaction.step === "success" ? transaction.hash : null;
10221
10549
  useSuccessReport(transaction, step === "tx", initial?.onSuccess);
10222
10550
  const buildData = "buildData" in transaction ? transaction.buildData : null;
10223
10551
  const explorerNetwork = buildData?.summary.network?.toLowerCase().includes("testnet") ? "testnet" : buildData ? "public" : network === "testnet" ? "testnet" : "public";
10224
- const explorerUrl = hash ? `https://stellar.expert/explorer/${explorerNetwork}/tx/${hash}` : null;
10552
+ const explorerUrl = !hash ? null : onSolana ? `https://solscan.io/tx/${hash}${network === "testnet" ? "?cluster=devnet" : ""}` : `https://stellar.expert/explorer/${explorerNetwork}/tx/${hash}`;
10225
10553
  const isInProgress = IN_FLIGHT_STEPS2.includes(transaction.step);
10226
10554
  const showBack = step === "tx" && (transaction.step === "error" || transaction.step === "success") && !isInProgress;
10227
10555
  const txTitle = isInProgress ? tab === "deposit" ? copy.depositing : copy.withdrawing : transaction.step === "success" ? copy.done : transaction.step === "error" ? tab === "deposit" ? copy.depositFailed : copy.withdrawFailed : copy.confirm;
10228
10556
  const parsedAmount = parseFloat(amount);
10229
- const exceedsAvailable = tab === "deposit" ? walletAvailable != null && parsedAmount > parseFloat(walletAvailable) : position != null && parsedAmount > parseFloat(position.withdrawable);
10230
- const canSubmit = !smartUnsupported && !!provider && !!opportunityId && !!amount && parsedAmount > 0 && !exceedsAvailable && !providersLoading && !loadingOpps;
10557
+ const exceedsAvailable = tab === "deposit" ? walletAvailable != null && parsedAmount > parseFloat(walletAvailable) : withdrawable != null && parsedAmount > parseFloat(withdrawable);
10558
+ const canSubmit = !smartUnsupported && (onSolana || !!provider) && !actionUnavailable && !!opportunityId && !!amount && parsedAmount > 0 && !exceedsAvailable && !providersLoading && !loadingOpps;
10231
10559
  const cssVars = buildModalCssVars(theme, accentColor, styleOverrides);
10232
10560
  async function handleSubmit() {
10233
10561
  setFormError("");
@@ -10235,10 +10563,14 @@ function EarnModal({ onClose, initial }) {
10235
10563
  setFormError(copy.smartNotSupported);
10236
10564
  return;
10237
10565
  }
10238
- if (!provider || !opportunityId) {
10566
+ if (!onSolana && !provider || !opportunityId) {
10239
10567
  setFormError(copy.selectOpportunity);
10240
10568
  return;
10241
10569
  }
10570
+ if (actionUnavailable) {
10571
+ setFormError(copy.actionUnavailable(tab));
10572
+ return;
10573
+ }
10242
10574
  const parsed = parseFloat(amount);
10243
10575
  if (!amount || isNaN(parsed) || parsed <= 0) {
10244
10576
  setFormError(copy.invalidAmount);
@@ -10248,7 +10580,7 @@ function EarnModal({ onClose, initial }) {
10248
10580
  setFormError(copy.exceedsWallet);
10249
10581
  return;
10250
10582
  }
10251
- if (tab === "withdraw" && position && parsed > parseFloat(position.withdrawable)) {
10583
+ if (tab === "withdraw" && withdrawable != null && parsed > parseFloat(withdrawable)) {
10252
10584
  setFormError(copy.exceedsPosition);
10253
10585
  return;
10254
10586
  }
@@ -10262,18 +10594,24 @@ function EarnModal({ onClose, initial }) {
10262
10594
  }
10263
10595
  await refreshAssets();
10264
10596
  }
10265
- const params = { provider, opportunity: opportunityId, amount };
10266
- const outcome = tab === "deposit" ? await earnDeposit(params) : await earnWithdraw(params);
10267
- if (outcome.status === "success" || outcome.status === "pending") {
10597
+ const outcome = await runEarn();
10598
+ if (outcome && (outcome.status === "success" || outcome.status === "pending")) {
10268
10599
  setAmount("");
10269
10600
  refreshPosition();
10270
10601
  }
10271
10602
  }
10272
- async function handleRetry() {
10273
- if (transaction.step !== "error" || !provider || !opportunityId) return;
10603
+ function runEarn() {
10604
+ if (onSolana) {
10605
+ const params2 = { opportunity: opportunityId, amount };
10606
+ return tab === "deposit" ? earnSolanaDeposit(params2) : earnSolanaWithdraw(params2);
10607
+ }
10608
+ if (!provider) return null;
10274
10609
  const params = { provider, opportunity: opportunityId, amount };
10275
- if (tab === "deposit") await earnDeposit(params);
10276
- else await earnWithdraw(params);
10610
+ return tab === "deposit" ? earnDeposit(params) : earnWithdraw(params);
10611
+ }
10612
+ async function handleRetry() {
10613
+ if (transaction.step !== "error" || !opportunityId) return;
10614
+ await runEarn();
10277
10615
  }
10278
10616
  function handleCopyHash() {
10279
10617
  if (!hash) return;
@@ -10293,10 +10631,16 @@ function EarnModal({ onClose, initial }) {
10293
10631
  refreshPosition();
10294
10632
  }
10295
10633
  async function handleRefresh() {
10296
- if (refreshing || !provider) return;
10634
+ if (refreshing || !onSolana && !provider) return;
10297
10635
  setRefreshing(true);
10298
10636
  try {
10299
10637
  void refreshWalletBalance();
10638
+ if (onSolana) {
10639
+ await loadSolanaOpportunities();
10640
+ refreshPosition();
10641
+ return;
10642
+ }
10643
+ if (!provider) return;
10300
10644
  const opps = await getEarnOpportunities(provider);
10301
10645
  setOpportunities(opps);
10302
10646
  setOpportunityId((cur) => opps.some((o) => o.id === cur) ? cur : opps[0]?.id ?? "");
@@ -10386,7 +10730,24 @@ function EarnModal({ onClose, initial }) {
10386
10730
  }
10387
10731
  )
10388
10732
  ] }),
10389
- providers && providers.length > 1 && /* @__PURE__ */ jsxs("div", { className: "pollar-send-field", children: [
10733
+ networks.length > 1 && /* @__PURE__ */ jsxs("div", { className: "pollar-send-field", children: [
10734
+ /* @__PURE__ */ jsx("label", { className: "pollar-send-label", children: copy.network }),
10735
+ /* @__PURE__ */ jsx(
10736
+ "select",
10737
+ {
10738
+ className: "pollar-input pollar-send-select",
10739
+ value: earnChain,
10740
+ onChange: (e) => {
10741
+ setEarnChain(e.target.value);
10742
+ setOpportunityId("");
10743
+ setAmount("");
10744
+ setFormError("");
10745
+ },
10746
+ children: networks.map((n) => /* @__PURE__ */ jsx("option", { value: n, children: n === "SOLANA" ? "Solana" : "Stellar" }, n))
10747
+ }
10748
+ )
10749
+ ] }),
10750
+ !onSolana && providers && providers.length > 1 && /* @__PURE__ */ jsxs("div", { className: "pollar-send-field", children: [
10390
10751
  /* @__PURE__ */ jsx("label", { className: "pollar-send-label", children: copy.provider }),
10391
10752
  /* @__PURE__ */ jsx(
10392
10753
  "select",
@@ -10399,7 +10760,7 @@ function EarnModal({ onClose, initial }) {
10399
10760
  )
10400
10761
  ] }),
10401
10762
  /* @__PURE__ */ jsxs("div", { className: "pollar-send-field", children: [
10402
- /* @__PURE__ */ jsx("label", { className: "pollar-send-label", children: provider === "defindex" ? copy.vault : copy.pool }),
10763
+ /* @__PURE__ */ jsx("label", { className: "pollar-send-label", children: onSolana ? copy.opportunity : provider === "defindex" ? copy.vault : copy.pool }),
10403
10764
  loadingOpps || providersLoading ? /* @__PURE__ */ jsxs("div", { className: "pollar-input pollar-select-loading", children: [
10404
10765
  /* @__PURE__ */ jsx("span", { className: "pollar-spinner pollar-spinner-sm" }),
10405
10766
  /* @__PURE__ */ jsx("span", { children: copy.loadingOptions })
@@ -10408,9 +10769,9 @@ function EarnModal({ onClose, initial }) {
10408
10769
  {
10409
10770
  className: "pollar-input pollar-send-select",
10410
10771
  value: opportunityId,
10411
- disabled: opportunities.length === 0,
10772
+ disabled: (onSolana ? solanaOpportunities : opportunities).length === 0,
10412
10773
  onChange: (e) => setOpportunityId(e.target.value),
10413
- children: opportunities.length === 0 ? /* @__PURE__ */ jsx("option", { value: "", children: copy.noneAvailable }) : opportunities.map((o) => /* @__PURE__ */ jsxs("option", { value: o.id, children: [
10774
+ children: (onSolana ? solanaOpportunities : opportunities).length === 0 ? /* @__PURE__ */ jsx("option", { value: "", children: copy.noneAvailable }) : (onSolana ? solanaOpportunities : opportunities).map((o) => /* @__PURE__ */ jsxs("option", { value: o.id, children: [
10414
10775
  o.name,
10415
10776
  " \xB7 ",
10416
10777
  o.apy.toFixed(2),
@@ -10419,6 +10780,41 @@ function EarnModal({ onClose, initial }) {
10419
10780
  }
10420
10781
  )
10421
10782
  ] }),
10783
+ selectedSolana && /* @__PURE__ */ jsxs("div", { className: "pollar-swap-quote", children: [
10784
+ tab === "deposit" && /* @__PURE__ */ jsxs("div", { className: "pollar-swap-quote-row", children: [
10785
+ /* @__PURE__ */ jsx("span", { className: "pollar-send-hint", children: copy.inYourWallet }),
10786
+ /* @__PURE__ */ jsxs("span", { children: [
10787
+ walletAvailable != null ? formatAmount3(walletAvailable) : "...",
10788
+ " ",
10789
+ assetCode
10790
+ ] })
10791
+ ] }),
10792
+ /* @__PURE__ */ jsxs("div", { className: "pollar-swap-quote-row", children: [
10793
+ /* @__PURE__ */ jsx("span", { className: "pollar-send-hint", children: copy.yourPosition }),
10794
+ /* @__PURE__ */ jsxs("span", { children: [
10795
+ solanaPosition ? formatAmount3(solanaPosition.balance) : "...",
10796
+ " ",
10797
+ assetCode
10798
+ ] })
10799
+ ] }),
10800
+ solanaPosition?.profit != null && /* @__PURE__ */ jsxs("div", { className: "pollar-swap-quote-row", children: [
10801
+ /* @__PURE__ */ jsx("span", { className: "pollar-send-hint", children: copy.profit }),
10802
+ /* @__PURE__ */ jsxs("span", { children: [
10803
+ formatAmount3(solanaPosition.profit),
10804
+ " ",
10805
+ assetCode
10806
+ ] })
10807
+ ] }),
10808
+ /* @__PURE__ */ jsxs("div", { className: "pollar-swap-quote-row", children: [
10809
+ /* @__PURE__ */ jsx("span", { className: "pollar-send-hint", children: copy.apyAfterFees }),
10810
+ /* @__PURE__ */ jsxs("span", { className: "pollar-earn-live", children: [
10811
+ (solanaPosition?.apy ?? selectedSolana.apy).toFixed(2),
10812
+ "%"
10813
+ ] })
10814
+ ] }),
10815
+ solanaPosition?.stale && /* @__PURE__ */ jsx("div", { className: "pollar-send-hint", children: copy.stale })
10816
+ ] }),
10817
+ actionUnavailable && /* @__PURE__ */ jsx("div", { className: "pollar-send-hint", children: copy.actionUnavailable(tab) }),
10422
10818
  selectedOpportunity && /* @__PURE__ */ jsxs("div", { className: "pollar-swap-quote", children: [
10423
10819
  tab === "deposit" && /* @__PURE__ */ jsxs("div", { className: "pollar-swap-quote-row", children: [
10424
10820
  /* @__PURE__ */ jsx("span", { className: "pollar-send-hint", children: copy.inYourWallet }),
@@ -10452,7 +10848,7 @@ function EarnModal({ onClose, initial }) {
10452
10848
  value: amount,
10453
10849
  onChange: setAmount,
10454
10850
  unit: amountUnitLabel,
10455
- available: tab === "deposit" ? walletAvailable : position ? position.withdrawable : void 0
10851
+ available: tab === "deposit" ? walletAvailable : withdrawable ?? void 0
10456
10852
  }
10457
10853
  ),
10458
10854
  formError && /* @__PURE__ */ jsx("div", { className: "pollar-modal-error", children: formError }),
@@ -12200,7 +12596,11 @@ var COSIGN_COPY = {
12200
12596
  manage_data: "Manage data",
12201
12597
  transfer: "Send",
12202
12598
  ramp_payment: "Ramp payment",
12203
- cctp_burn: "Move USDC"
12599
+ cctp_burn: "Move USDC",
12600
+ swap: "Swap",
12601
+ earn_deposit: "Deposit",
12602
+ earn_withdraw: "Withdraw",
12603
+ evm_delegation: "Enable atomic transactions"
12204
12604
  }
12205
12605
  },
12206
12606
  es: {
@@ -12241,7 +12641,11 @@ var COSIGN_COPY = {
12241
12641
  manage_data: "Gestionar datos",
12242
12642
  transfer: "Enviar",
12243
12643
  ramp_payment: "Pago de rampa",
12244
- cctp_burn: "Mover USDC"
12644
+ cctp_burn: "Mover USDC",
12645
+ swap: "Intercambiar",
12646
+ earn_deposit: "Depositar",
12647
+ earn_withdraw: "Retirar",
12648
+ evm_delegation: "Activar transacciones at\xF3micas"
12245
12649
  }
12246
12650
  },
12247
12651
  pt: {
@@ -12282,7 +12686,11 @@ var COSIGN_COPY = {
12282
12686
  manage_data: "Gerenciar dados",
12283
12687
  transfer: "Enviar",
12284
12688
  ramp_payment: "Pagamento de rampa",
12285
- cctp_burn: "Mover USDC"
12689
+ cctp_burn: "Mover USDC",
12690
+ swap: "Trocar",
12691
+ earn_deposit: "Depositar",
12692
+ earn_withdraw: "Sacar",
12693
+ evm_delegation: "Ativar transa\xE7\xF5es at\xF4micas"
12286
12694
  }
12287
12695
  }
12288
12696
  };
@@ -13222,6 +13630,8 @@ function RecoveryModalTemplate(p) {
13222
13630
  }
13223
13631
  );
13224
13632
  }
13633
+ var APPROVAL_POLL_MS = 3e3;
13634
+ var APPROVAL_WINDOW_MS = 15 * 6e4;
13225
13635
  function errorText3(err, language) {
13226
13636
  return cosignRefusalMessage(err, language) ?? transactionErrorMessage(isPollarApiError(err) ? err.code : null, err instanceof Error ? err.message : null, language);
13227
13637
  }
@@ -13284,6 +13694,21 @@ function RecoveryModal({ onClose }) {
13284
13694
  [load]
13285
13695
  );
13286
13696
  const enrolled = !!thisDeviceKey && !!devices?.devices.some((d) => d.publicKey.toLowerCase() === thisDeviceKey);
13697
+ const [awaitingApproval, setAwaitingApproval] = useState(false);
13698
+ useEffect(() => {
13699
+ if (!awaitingApproval) return;
13700
+ if (enrolled) {
13701
+ setAwaitingApproval(false);
13702
+ setNotice(copy.deviceAdded);
13703
+ return;
13704
+ }
13705
+ const timer = setInterval(() => void load().catch(() => void 0), APPROVAL_POLL_MS);
13706
+ const stop = setTimeout(() => setAwaitingApproval(false), APPROVAL_WINDOW_MS);
13707
+ return () => {
13708
+ clearInterval(timer);
13709
+ clearTimeout(stop);
13710
+ };
13711
+ }, [awaitingApproval, enrolled, load, copy]);
13287
13712
  return /* @__PURE__ */ jsx(PollarOverlay, { style: overlayStyle, onClick: onClose, children: /* @__PURE__ */ jsx(
13288
13713
  RecoveryModalTemplate,
13289
13714
  {
@@ -13320,9 +13745,14 @@ function RecoveryModal({ onClose }) {
13320
13745
  onConfirmEmail: (code) => void run("email-confirm", () => recovery.confirmEmail(code.trim()), { notice: copy.emailConfirmed, view: "overview" }),
13321
13746
  onApproveDevice: (id) => void run(`approve:${id}`, () => recovery.approveDevice(id), { notice: copy.deviceAdded }),
13322
13747
  onRejectDevice: (id) => void run(`reject:${id}`, () => recovery.rejectDevice(id)),
13323
- onRequestEnrollment: () => void run("enroll", () => recovery.requestDeviceEnrollment(), {
13324
- notice: copy.requestSent
13325
- }),
13748
+ onRequestEnrollment: () => void run(
13749
+ "enroll",
13750
+ async () => {
13751
+ await recovery.requestDeviceEnrollment();
13752
+ setAwaitingApproval(true);
13753
+ },
13754
+ { notice: copy.requestSent }
13755
+ ),
13326
13756
  onRecoverWithPasskey: () => void run("recover-passkey", () => recovery.recoverWithPasskey(), {
13327
13757
  notice: copy.recovered
13328
13758
  }),
@@ -14627,6 +15057,8 @@ function PollarProvider({
14627
15057
  getSolanaSwapConfig: () => pollarClient.getSolanaSwapConfig(),
14628
15058
  getSolanaSwapQuote: (params) => pollarClient.getSolanaSwapQuote(params),
14629
15059
  swapSolana: (quote, opts) => pollarClient.swapSolana(quote, opts),
15060
+ getSolanaSwapOptions: () => pollarClient.getSolanaSwapOptions(),
15061
+ getSwapStatus: (idempotencyKey) => pollarClient.getSwapStatus(idempotencyKey),
14630
15062
  openSwapModal: (options) => {
14631
15063
  setSwapModalOptions(options);
14632
15064
  pollarClient.resetTransactionState();
@@ -14644,6 +15076,11 @@ function PollarProvider({
14644
15076
  getEarnPosition: (params) => pollarClient.getEarnPosition(params),
14645
15077
  earnDeposit: (params) => pollarClient.earnDeposit(params),
14646
15078
  earnWithdraw: (params) => pollarClient.earnWithdraw(params),
15079
+ getSolanaEarnProviders: () => pollarClient.getSolanaEarnProviders(),
15080
+ getSolanaEarnOpportunities: () => pollarClient.getSolanaEarnOpportunities(),
15081
+ getSolanaEarnPosition: (opportunity) => pollarClient.getSolanaEarnPosition(opportunity),
15082
+ earnSolanaDeposit: (params) => pollarClient.earnSolanaDeposit(params),
15083
+ earnSolanaWithdraw: (params) => pollarClient.earnSolanaWithdraw(params),
14647
15084
  openEarnModal: (options) => {
14648
15085
  setEarnModalOptions(options);
14649
15086
  pollarClient.resetTransactionState();