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