@pollar/react 0.12.1-rc.10 → 0.12.1-rc.13
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.d.mts +47 -3
- package/dist/index.d.ts +47 -3
- package/dist/index.js +547 -97
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +548 -98
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
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,
|
|
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.
|
|
1287
|
+
"0.12.1-rc.13"
|
|
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 = {
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
9169
|
+
getSolanaSwapOptions().then((options) => {
|
|
9170
|
+
setSolanaVenues(options.venues);
|
|
9171
|
+
setDestinationChains(options.destinationChains);
|
|
9172
|
+
}).catch(() => {
|
|
9173
|
+
setSolanaVenues([]);
|
|
9174
|
+
setDestinationChains([]);
|
|
9175
|
+
})
|
|
9007
9176
|
]);
|
|
9008
|
-
}, [getSwapConfig,
|
|
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
|
|
9148
|
-
const
|
|
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,
|
|
9151
|
-
minReceived: fromBaseUnits3(solanaQuote.minOut,
|
|
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)
|
|
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
|
|
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
|
-
|
|
10156
|
-
|
|
10157
|
-
|
|
10158
|
-
|
|
10159
|
-
|
|
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
|
|
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 (!
|
|
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 =
|
|
10206
|
-
const earnUnavailable =
|
|
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}
|
|
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) :
|
|
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" &&
|
|
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
|
|
10266
|
-
|
|
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
|
-
|
|
10273
|
-
if (
|
|
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
|
-
|
|
10276
|
-
|
|
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
|
-
|
|
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 :
|
|
10851
|
+
available: tab === "deposit" ? walletAvailable : withdrawable ?? void 0
|
|
10456
10852
|
}
|
|
10457
10853
|
),
|
|
10458
10854
|
formError && /* @__PURE__ */ jsx("div", { className: "pollar-modal-error", children: formError }),
|
|
@@ -10487,11 +10883,11 @@ var CARD_COPY = {
|
|
|
10487
10883
|
funding: {
|
|
10488
10884
|
CREATED: {
|
|
10489
10885
|
title: "Confirming your payment",
|
|
10490
|
-
hint: "Your USDC payment is being confirmed
|
|
10886
|
+
hint: "Your USDC payment is being confirmed. This takes a few seconds."
|
|
10491
10887
|
},
|
|
10492
10888
|
BURNED: {
|
|
10493
10889
|
title: "Sending it to the card network",
|
|
10494
|
-
hint: "Your USDC left
|
|
10890
|
+
hint: "Your USDC left your wallet. Circle is confirming the transfer, usually within a few minutes."
|
|
10495
10891
|
},
|
|
10496
10892
|
ATTESTED: {
|
|
10497
10893
|
title: "Crossing to the card network",
|
|
@@ -10507,7 +10903,7 @@ var CARD_COPY = {
|
|
|
10507
10903
|
fundingSolana: {
|
|
10508
10904
|
CREATED: {
|
|
10509
10905
|
title: "Confirming your payment",
|
|
10510
|
-
hint: "Your USDC payment is being confirmed
|
|
10906
|
+
hint: "Your USDC payment is being confirmed. This takes a few seconds."
|
|
10511
10907
|
},
|
|
10512
10908
|
SENT: {
|
|
10513
10909
|
title: "Arrived, crediting your card",
|
|
@@ -10646,18 +11042,20 @@ var CARD_COPY = {
|
|
|
10646
11042
|
noBalance: "Your wallet does not have enough USDC for this amount.",
|
|
10647
11043
|
notPaid: "The payment was not sent.",
|
|
10648
11044
|
failed: "The payment could not be completed. Please try again.",
|
|
10649
|
-
delayed: "Taking longer than usual. We are following up with the card provider."
|
|
11045
|
+
delayed: "Taking longer than usual. We are following up with the card provider.",
|
|
11046
|
+
crossing: "Your USDC crosses to the card network. It takes a few minutes, and the network fees are covered.",
|
|
11047
|
+
noRoute: "Your wallets cannot fund this card right now."
|
|
10650
11048
|
}
|
|
10651
11049
|
},
|
|
10652
11050
|
es: {
|
|
10653
11051
|
funding: {
|
|
10654
11052
|
CREATED: {
|
|
10655
11053
|
title: "Confirmando tu pago",
|
|
10656
|
-
hint: "Tu pago en USDC se est\xE1 confirmando
|
|
11054
|
+
hint: "Tu pago en USDC se est\xE1 confirmando. Esto toma unos segundos."
|
|
10657
11055
|
},
|
|
10658
11056
|
BURNED: {
|
|
10659
11057
|
title: "Envi\xE1ndolo a la red de la tarjeta",
|
|
10660
|
-
hint: "Tus USDC salieron de
|
|
11058
|
+
hint: "Tus USDC salieron de tu wallet. Circle est\xE1 confirmando la transferencia, normalmente en unos minutos."
|
|
10661
11059
|
},
|
|
10662
11060
|
ATTESTED: {
|
|
10663
11061
|
title: "Cruzando a la red de la tarjeta",
|
|
@@ -10673,7 +11071,7 @@ var CARD_COPY = {
|
|
|
10673
11071
|
fundingSolana: {
|
|
10674
11072
|
CREATED: {
|
|
10675
11073
|
title: "Confirmando tu pago",
|
|
10676
|
-
hint: "Tu pago en USDC se est\xE1 confirmando
|
|
11074
|
+
hint: "Tu pago en USDC se est\xE1 confirmando. Esto toma unos segundos."
|
|
10677
11075
|
},
|
|
10678
11076
|
SENT: {
|
|
10679
11077
|
title: "Lleg\xF3, acreditando tu tarjeta",
|
|
@@ -10812,18 +11210,20 @@ var CARD_COPY = {
|
|
|
10812
11210
|
noBalance: "Tu wallet no tiene suficiente USDC para este monto.",
|
|
10813
11211
|
notPaid: "El pago no se envi\xF3.",
|
|
10814
11212
|
failed: "No se pudo completar el pago. Intenta de nuevo.",
|
|
10815
|
-
delayed: "Est\xE1 tardando m\xE1s de lo normal. Estamos haciendo seguimiento con el emisor de la tarjeta."
|
|
11213
|
+
delayed: "Est\xE1 tardando m\xE1s de lo normal. Estamos haciendo seguimiento con el emisor de la tarjeta.",
|
|
11214
|
+
crossing: "Tus USDC cruzan a la red de la tarjeta. Toma unos minutos y las comisiones de red est\xE1n cubiertas.",
|
|
11215
|
+
noRoute: "Tus wallets no pueden fondear esta tarjeta por ahora."
|
|
10816
11216
|
}
|
|
10817
11217
|
},
|
|
10818
11218
|
pt: {
|
|
10819
11219
|
funding: {
|
|
10820
11220
|
CREATED: {
|
|
10821
11221
|
title: "Confirmando seu pagamento",
|
|
10822
|
-
hint: "Seu pagamento em USDC est\xE1 sendo confirmado
|
|
11222
|
+
hint: "Seu pagamento em USDC est\xE1 sendo confirmado. Isso leva alguns segundos."
|
|
10823
11223
|
},
|
|
10824
11224
|
BURNED: {
|
|
10825
11225
|
title: "Enviando para a rede do cart\xE3o",
|
|
10826
|
-
hint: "Seus USDC sa\xEDram da
|
|
11226
|
+
hint: "Seus USDC sa\xEDram da sua carteira. A Circle est\xE1 confirmando a transfer\xEAncia, normalmente em alguns minutos."
|
|
10827
11227
|
},
|
|
10828
11228
|
ATTESTED: {
|
|
10829
11229
|
title: "Atravessando para a rede do cart\xE3o",
|
|
@@ -10839,7 +11239,7 @@ var CARD_COPY = {
|
|
|
10839
11239
|
fundingSolana: {
|
|
10840
11240
|
CREATED: {
|
|
10841
11241
|
title: "Confirmando seu pagamento",
|
|
10842
|
-
hint: "Seu pagamento em USDC est\xE1 sendo confirmado
|
|
11242
|
+
hint: "Seu pagamento em USDC est\xE1 sendo confirmado. Isso leva alguns segundos."
|
|
10843
11243
|
},
|
|
10844
11244
|
SENT: {
|
|
10845
11245
|
title: "Chegou, creditando seu cart\xE3o",
|
|
@@ -10978,7 +11378,9 @@ var CARD_COPY = {
|
|
|
10978
11378
|
noBalance: "Sua carteira n\xE3o tem USDC suficiente para este valor.",
|
|
10979
11379
|
notPaid: "O pagamento n\xE3o foi enviado.",
|
|
10980
11380
|
failed: "N\xE3o foi poss\xEDvel concluir o pagamento. Tente novamente.",
|
|
10981
|
-
delayed: "Est\xE1 demorando mais que o normal. Estamos acompanhando com o emissor do cart\xE3o."
|
|
11381
|
+
delayed: "Est\xE1 demorando mais que o normal. Estamos acompanhando com o emissor do cart\xE3o.",
|
|
11382
|
+
crossing: "Seus USDC atravessam para a rede do cart\xE3o. Leva alguns minutos, e as taxas de rede est\xE3o cobertas.",
|
|
11383
|
+
noRoute: "Suas carteiras n\xE3o podem recarregar este cart\xE3o por enquanto."
|
|
10982
11384
|
}
|
|
10983
11385
|
}
|
|
10984
11386
|
};
|
|
@@ -11040,11 +11442,9 @@ function newFundingKey() {
|
|
|
11040
11442
|
return `fund-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
|
|
11041
11443
|
}
|
|
11042
11444
|
var FUNDING_STEPS = {
|
|
11043
|
-
|
|
11044
|
-
|
|
11445
|
+
CCTP: ["CREATED", "BURNED", "ATTESTED", "MINTED"],
|
|
11446
|
+
DIRECT: ["CREATED", "SENT"]
|
|
11045
11447
|
};
|
|
11046
|
-
var FUNDING_CHAINS = ["STELLAR", "SOLANA"];
|
|
11047
|
-
var isFundingChain = (chain) => FUNDING_CHAINS.includes(chain);
|
|
11048
11448
|
var INCOME_RANGES = ["0-1000", "1000-5000", "5000-10000", "10000+"];
|
|
11049
11449
|
var KYC_PENDING = /* @__PURE__ */ new Set(["PENDING", "NEEDS_ACTION", "IN_REVIEW"]);
|
|
11050
11450
|
var KYC_FINAL = /* @__PURE__ */ new Set(["DENIED", "LOCKED", "CANCELED"]);
|
|
@@ -11118,6 +11518,7 @@ function CardModal({ onClose, initial }) {
|
|
|
11118
11518
|
const [fundAmount, setFundAmount] = useState(() => seededAmount(initial?.amount));
|
|
11119
11519
|
const fundKey = useRef(null);
|
|
11120
11520
|
const [fundChain, setFundChain] = useState(initial?.chain ?? null);
|
|
11521
|
+
const [fundRoutes, setFundRoutes] = useState(null);
|
|
11121
11522
|
const fundPanelSeed = useRef(initial?.panel === "fund");
|
|
11122
11523
|
const [showManual, setShowManual] = useState(false);
|
|
11123
11524
|
const [occupations, setOccupations] = useState([]);
|
|
@@ -11131,8 +11532,10 @@ function CardModal({ onClose, initial }) {
|
|
|
11131
11532
|
const revealTimer = useRef(null);
|
|
11132
11533
|
const provider = providers?.[0] ?? null;
|
|
11133
11534
|
const fundingAsset = provider?.fundingAssets[0] ?? "USDC";
|
|
11134
|
-
const
|
|
11535
|
+
const appOrder = useChains().chains;
|
|
11536
|
+
const fundChains = (fundRoutes ?? []).map((route) => route.source).sort((a, b) => appOrder.indexOf(a) - appOrder.indexOf(b));
|
|
11135
11537
|
const selectedFundChain = (fundChain && fundChains.includes(fundChain) ? fundChain : null) ?? fundChains[0] ?? "STELLAR";
|
|
11538
|
+
const selectedRoute = fundRoutes?.find((route) => route.source === selectedFundChain);
|
|
11136
11539
|
const fundAvailable = useWalletAvailable(panel === "fund" ? { chain: selectedFundChain, code: fundingAsset } : null);
|
|
11137
11540
|
const card = cards?.[0] ?? null;
|
|
11138
11541
|
const expiry = card?.expMonth && card.expYear ? `${card.expMonth}/${card.expYear.slice(-2)}` : null;
|
|
@@ -11291,7 +11694,9 @@ function CardModal({ onClose, initial }) {
|
|
|
11291
11694
|
const openFund = () => run(
|
|
11292
11695
|
"fund",
|
|
11293
11696
|
async () => {
|
|
11294
|
-
|
|
11697
|
+
const [list, routes] = await Promise.all([getClient().listCardFundings(), getClient().getCardFundingRoutes()]);
|
|
11698
|
+
setFundings(list);
|
|
11699
|
+
setFundRoutes(routes);
|
|
11295
11700
|
setPanel("fund");
|
|
11296
11701
|
},
|
|
11297
11702
|
copy.failed.loadFundings
|
|
@@ -11307,10 +11712,12 @@ function CardModal({ onClose, initial }) {
|
|
|
11307
11712
|
fundKey.current ?? (fundKey.current = newFundingKey());
|
|
11308
11713
|
let outcome;
|
|
11309
11714
|
try {
|
|
11310
|
-
|
|
11715
|
+
const client = getClient();
|
|
11716
|
+
outcome = await client.fundCard({
|
|
11311
11717
|
amount: fundAmount.trim(),
|
|
11312
11718
|
chain: selectedFundChain,
|
|
11313
|
-
idempotencyKey: fundKey.current
|
|
11719
|
+
idempotencyKey: fundKey.current,
|
|
11720
|
+
signBridgeStep: (transferId, actionId) => signStepWithWallet(client, transferId, actionId, BRIDGE_COPY[language])
|
|
11314
11721
|
});
|
|
11315
11722
|
} catch (e) {
|
|
11316
11723
|
if (isPollarApiError(e)) fundKey.current = null;
|
|
@@ -11702,6 +12109,8 @@ function CardModal({ onClose, initial }) {
|
|
|
11702
12109
|
language
|
|
11703
12110
|
}
|
|
11704
12111
|
),
|
|
12112
|
+
fundRoutes?.length === 0 && /* @__PURE__ */ jsx("p", { className: "pollar-card-note", children: copy.fundingProblem.noRoute }),
|
|
12113
|
+
selectedRoute?.route === "CCTP" && /* @__PURE__ */ jsx("p", { className: "pollar-card-note", children: copy.fundingProblem.crossing }),
|
|
11705
12114
|
/* @__PURE__ */ jsx(
|
|
11706
12115
|
AmountField,
|
|
11707
12116
|
{
|
|
@@ -11721,15 +12130,15 @@ function CardModal({ onClose, initial }) {
|
|
|
11721
12130
|
type: "button",
|
|
11722
12131
|
className: "pollar-btn-primary",
|
|
11723
12132
|
onClick: () => void fund(),
|
|
11724
|
-
disabled: busy !== null || !(Number(fundAmount) >= 1),
|
|
12133
|
+
disabled: busy !== null || !selectedRoute || !(Number(fundAmount) >= 1),
|
|
11725
12134
|
children: busy === "fund-send" ? copy.sending : copy.fundFromWallet
|
|
11726
12135
|
}
|
|
11727
12136
|
) }),
|
|
11728
12137
|
fundings && fundings.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
11729
12138
|
/* @__PURE__ */ jsx("p", { className: "pollar-card-section-title", children: copy.yourFundings }),
|
|
11730
12139
|
fundings.map((f) => {
|
|
11731
|
-
const state = (f.
|
|
11732
|
-
const steps = FUNDING_STEPS[
|
|
12140
|
+
const state = (f.route === "DIRECT" ? copy.fundingSolana[f.status] : void 0) ?? copy.funding[f.status];
|
|
12141
|
+
const steps = FUNDING_STEPS[f.route];
|
|
11733
12142
|
const step = steps.indexOf(f.status) + 1;
|
|
11734
12143
|
const inflight = FUNDING_INFLIGHT.has(f.status);
|
|
11735
12144
|
return /* @__PURE__ */ jsxs("div", { className: "pollar-card-tx", "aria-busy": inflight, children: [
|
|
@@ -12200,7 +12609,11 @@ var COSIGN_COPY = {
|
|
|
12200
12609
|
manage_data: "Manage data",
|
|
12201
12610
|
transfer: "Send",
|
|
12202
12611
|
ramp_payment: "Ramp payment",
|
|
12203
|
-
cctp_burn: "Move USDC"
|
|
12612
|
+
cctp_burn: "Move USDC",
|
|
12613
|
+
swap: "Swap",
|
|
12614
|
+
earn_deposit: "Deposit",
|
|
12615
|
+
earn_withdraw: "Withdraw",
|
|
12616
|
+
evm_delegation: "Enable atomic transactions"
|
|
12204
12617
|
}
|
|
12205
12618
|
},
|
|
12206
12619
|
es: {
|
|
@@ -12241,7 +12654,11 @@ var COSIGN_COPY = {
|
|
|
12241
12654
|
manage_data: "Gestionar datos",
|
|
12242
12655
|
transfer: "Enviar",
|
|
12243
12656
|
ramp_payment: "Pago de rampa",
|
|
12244
|
-
cctp_burn: "Mover USDC"
|
|
12657
|
+
cctp_burn: "Mover USDC",
|
|
12658
|
+
swap: "Intercambiar",
|
|
12659
|
+
earn_deposit: "Depositar",
|
|
12660
|
+
earn_withdraw: "Retirar",
|
|
12661
|
+
evm_delegation: "Activar transacciones at\xF3micas"
|
|
12245
12662
|
}
|
|
12246
12663
|
},
|
|
12247
12664
|
pt: {
|
|
@@ -12282,7 +12699,11 @@ var COSIGN_COPY = {
|
|
|
12282
12699
|
manage_data: "Gerenciar dados",
|
|
12283
12700
|
transfer: "Enviar",
|
|
12284
12701
|
ramp_payment: "Pagamento de rampa",
|
|
12285
|
-
cctp_burn: "Mover USDC"
|
|
12702
|
+
cctp_burn: "Mover USDC",
|
|
12703
|
+
swap: "Trocar",
|
|
12704
|
+
earn_deposit: "Depositar",
|
|
12705
|
+
earn_withdraw: "Sacar",
|
|
12706
|
+
evm_delegation: "Ativar transa\xE7\xF5es at\xF4micas"
|
|
12286
12707
|
}
|
|
12287
12708
|
}
|
|
12288
12709
|
};
|
|
@@ -13222,6 +13643,8 @@ function RecoveryModalTemplate(p) {
|
|
|
13222
13643
|
}
|
|
13223
13644
|
);
|
|
13224
13645
|
}
|
|
13646
|
+
var APPROVAL_POLL_MS = 3e3;
|
|
13647
|
+
var APPROVAL_WINDOW_MS = 15 * 6e4;
|
|
13225
13648
|
function errorText3(err, language) {
|
|
13226
13649
|
return cosignRefusalMessage(err, language) ?? transactionErrorMessage(isPollarApiError(err) ? err.code : null, err instanceof Error ? err.message : null, language);
|
|
13227
13650
|
}
|
|
@@ -13284,6 +13707,21 @@ function RecoveryModal({ onClose }) {
|
|
|
13284
13707
|
[load]
|
|
13285
13708
|
);
|
|
13286
13709
|
const enrolled = !!thisDeviceKey && !!devices?.devices.some((d) => d.publicKey.toLowerCase() === thisDeviceKey);
|
|
13710
|
+
const [awaitingApproval, setAwaitingApproval] = useState(false);
|
|
13711
|
+
useEffect(() => {
|
|
13712
|
+
if (!awaitingApproval) return;
|
|
13713
|
+
if (enrolled) {
|
|
13714
|
+
setAwaitingApproval(false);
|
|
13715
|
+
setNotice(copy.deviceAdded);
|
|
13716
|
+
return;
|
|
13717
|
+
}
|
|
13718
|
+
const timer = setInterval(() => void load().catch(() => void 0), APPROVAL_POLL_MS);
|
|
13719
|
+
const stop = setTimeout(() => setAwaitingApproval(false), APPROVAL_WINDOW_MS);
|
|
13720
|
+
return () => {
|
|
13721
|
+
clearInterval(timer);
|
|
13722
|
+
clearTimeout(stop);
|
|
13723
|
+
};
|
|
13724
|
+
}, [awaitingApproval, enrolled, load, copy]);
|
|
13287
13725
|
return /* @__PURE__ */ jsx(PollarOverlay, { style: overlayStyle, onClick: onClose, children: /* @__PURE__ */ jsx(
|
|
13288
13726
|
RecoveryModalTemplate,
|
|
13289
13727
|
{
|
|
@@ -13320,9 +13758,14 @@ function RecoveryModal({ onClose }) {
|
|
|
13320
13758
|
onConfirmEmail: (code) => void run("email-confirm", () => recovery.confirmEmail(code.trim()), { notice: copy.emailConfirmed, view: "overview" }),
|
|
13321
13759
|
onApproveDevice: (id) => void run(`approve:${id}`, () => recovery.approveDevice(id), { notice: copy.deviceAdded }),
|
|
13322
13760
|
onRejectDevice: (id) => void run(`reject:${id}`, () => recovery.rejectDevice(id)),
|
|
13323
|
-
onRequestEnrollment: () => void run(
|
|
13324
|
-
|
|
13325
|
-
|
|
13761
|
+
onRequestEnrollment: () => void run(
|
|
13762
|
+
"enroll",
|
|
13763
|
+
async () => {
|
|
13764
|
+
await recovery.requestDeviceEnrollment();
|
|
13765
|
+
setAwaitingApproval(true);
|
|
13766
|
+
},
|
|
13767
|
+
{ notice: copy.requestSent }
|
|
13768
|
+
),
|
|
13326
13769
|
onRecoverWithPasskey: () => void run("recover-passkey", () => recovery.recoverWithPasskey(), {
|
|
13327
13770
|
notice: copy.recovered
|
|
13328
13771
|
}),
|
|
@@ -14627,6 +15070,8 @@ function PollarProvider({
|
|
|
14627
15070
|
getSolanaSwapConfig: () => pollarClient.getSolanaSwapConfig(),
|
|
14628
15071
|
getSolanaSwapQuote: (params) => pollarClient.getSolanaSwapQuote(params),
|
|
14629
15072
|
swapSolana: (quote, opts) => pollarClient.swapSolana(quote, opts),
|
|
15073
|
+
getSolanaSwapOptions: () => pollarClient.getSolanaSwapOptions(),
|
|
15074
|
+
getSwapStatus: (idempotencyKey) => pollarClient.getSwapStatus(idempotencyKey),
|
|
14630
15075
|
openSwapModal: (options) => {
|
|
14631
15076
|
setSwapModalOptions(options);
|
|
14632
15077
|
pollarClient.resetTransactionState();
|
|
@@ -14644,6 +15089,11 @@ function PollarProvider({
|
|
|
14644
15089
|
getEarnPosition: (params) => pollarClient.getEarnPosition(params),
|
|
14645
15090
|
earnDeposit: (params) => pollarClient.earnDeposit(params),
|
|
14646
15091
|
earnWithdraw: (params) => pollarClient.earnWithdraw(params),
|
|
15092
|
+
getSolanaEarnProviders: () => pollarClient.getSolanaEarnProviders(),
|
|
15093
|
+
getSolanaEarnOpportunities: () => pollarClient.getSolanaEarnOpportunities(),
|
|
15094
|
+
getSolanaEarnPosition: (opportunity) => pollarClient.getSolanaEarnPosition(opportunity),
|
|
15095
|
+
earnSolanaDeposit: (params) => pollarClient.earnSolanaDeposit(params),
|
|
15096
|
+
earnSolanaWithdraw: (params) => pollarClient.earnSolanaWithdraw(params),
|
|
14647
15097
|
openEarnModal: (options) => {
|
|
14648
15098
|
setEarnModalOptions(options);
|
|
14649
15099
|
pollarClient.resetTransactionState();
|