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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -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.11"
1287
+ "0.12.1-rc.14"
1288
1288
  ] })
1289
1289
  ] });
1290
1290
  };
@@ -4678,6 +4678,7 @@ function AmountField({
4678
4678
  value,
4679
4679
  onChange,
4680
4680
  unit,
4681
+ unitIcon,
4681
4682
  available,
4682
4683
  onMax,
4683
4684
  placeholder = "0.00",
@@ -4725,6 +4726,7 @@ function AmountField({
4725
4726
  children: copy.max
4726
4727
  }
4727
4728
  ),
4729
+ unitIcon,
4728
4730
  unit && /* @__PURE__ */ jsx("span", { children: unit })
4729
4731
  ] })
4730
4732
  ] })
@@ -7078,11 +7080,24 @@ var TX_REVIEW_COPY = {
7078
7080
  payment: (amount, to) => `Pay ${amount} to ${to}`,
7079
7081
  createAccount: "Create an account"
7080
7082
  },
7083
+ earn: {
7084
+ deposit: "Deposit",
7085
+ withdraw: "Withdraw",
7086
+ depositInto: (target) => `Deposit into ${target}`,
7087
+ withdrawFrom: (source) => `Withdraw from ${source}`,
7088
+ depositAmount: (amount) => `Deposit ${amount}`,
7089
+ withdrawAmount: (amount) => `Withdraw ${amount}`,
7090
+ fallbackName: "Earn",
7091
+ deposited: (amount, target, chain) => `Deposited ${amount} into the ${target} on ${chain}`,
7092
+ withdrew: (amount, source, chain) => `Withdrew ${amount} from the ${source} on ${chain}`,
7093
+ depositedOn: (amount, chain) => `Deposited ${amount} on ${chain}`,
7094
+ withdrewOn: (amount, chain) => `Withdrew ${amount} on ${chain}`
7095
+ },
7081
7096
  yourWallet: "Your wallet",
7082
7097
  newAccount: "New account",
7083
7098
  atLeast: "at least",
7084
7099
  approveNote: "This only gives permission. Nothing moves yet.",
7085
- feeSponsored: "Fee covered by the app",
7100
+ feeSponsored: "The app pays the network fee",
7086
7101
  feePaid: "You pay the network fee",
7087
7102
  showDetails: "Show details",
7088
7103
  hideDetails: "Hide details",
@@ -7097,6 +7112,9 @@ var TX_REVIEW_COPY = {
7097
7112
  via: "Via",
7098
7113
  fee: "Network fee",
7099
7114
  feeCovered: "Covered by the app",
7115
+ feeWallet: "Paid by your wallet",
7116
+ opportunity: "Opportunity",
7117
+ apy: "APY after fees",
7100
7118
  contract: "Contract",
7101
7119
  method: "Method",
7102
7120
  asset: "Asset",
@@ -7117,11 +7135,24 @@ var TX_REVIEW_COPY = {
7117
7135
  payment: (amount, to) => `Pagar ${amount} a ${to}`,
7118
7136
  createAccount: "Crear una cuenta"
7119
7137
  },
7138
+ earn: {
7139
+ deposit: "Depositar",
7140
+ withdraw: "Retirar",
7141
+ depositInto: (target) => `Depositar en ${target}`,
7142
+ withdrawFrom: (source) => `Retirar de ${source}`,
7143
+ depositAmount: (amount) => `Depositar ${amount}`,
7144
+ withdrawAmount: (amount) => `Retirar ${amount}`,
7145
+ fallbackName: "Rendimientos",
7146
+ deposited: (amount, target, chain) => `Depositaste ${amount} en ${target}, en ${chain}`,
7147
+ withdrew: (amount, source, chain) => `Retiraste ${amount} de ${source}, en ${chain}`,
7148
+ depositedOn: (amount, chain) => `Depositaste ${amount} en ${chain}`,
7149
+ withdrewOn: (amount, chain) => `Retiraste ${amount} en ${chain}`
7150
+ },
7120
7151
  yourWallet: "Tu billetera",
7121
7152
  newAccount: "Cuenta nueva",
7122
7153
  atLeast: "al menos",
7123
7154
  approveNote: "Solo das permiso. Todav\xEDa no se mueve nada.",
7124
- feeSponsored: "La app cubre la comisi\xF3n",
7155
+ feeSponsored: "La app paga la comisi\xF3n de red",
7125
7156
  feePaid: "T\xFA pagas la comisi\xF3n de red",
7126
7157
  showDetails: "Ver detalles",
7127
7158
  hideDetails: "Ocultar detalles",
@@ -7136,6 +7167,9 @@ var TX_REVIEW_COPY = {
7136
7167
  via: "V\xEDa",
7137
7168
  fee: "Comisi\xF3n de red",
7138
7169
  feeCovered: "La cubre la app",
7170
+ feeWallet: "La paga tu billetera",
7171
+ opportunity: "Oportunidad",
7172
+ apy: "APY despu\xE9s de comisiones",
7139
7173
  contract: "Contrato",
7140
7174
  method: "M\xE9todo",
7141
7175
  asset: "Activo",
@@ -7156,11 +7190,24 @@ var TX_REVIEW_COPY = {
7156
7190
  payment: (amount, to) => `Pagar ${amount} para ${to}`,
7157
7191
  createAccount: "Criar uma conta"
7158
7192
  },
7193
+ earn: {
7194
+ deposit: "Depositar",
7195
+ withdraw: "Sacar",
7196
+ depositInto: (target) => `Depositar em ${target}`,
7197
+ withdrawFrom: (source) => `Sacar de ${source}`,
7198
+ depositAmount: (amount) => `Depositar ${amount}`,
7199
+ withdrawAmount: (amount) => `Sacar ${amount}`,
7200
+ fallbackName: "Rendimentos",
7201
+ deposited: (amount, target, chain) => `Voc\xEA depositou ${amount} em ${target}, na ${chain}`,
7202
+ withdrew: (amount, source, chain) => `Voc\xEA sacou ${amount} de ${source}, na ${chain}`,
7203
+ depositedOn: (amount, chain) => `Voc\xEA depositou ${amount} na ${chain}`,
7204
+ withdrewOn: (amount, chain) => `Voc\xEA sacou ${amount} na ${chain}`
7205
+ },
7159
7206
  yourWallet: "Sua carteira",
7160
7207
  newAccount: "Conta nova",
7161
7208
  atLeast: "pelo menos",
7162
7209
  approveNote: "Isto s\xF3 d\xE1 permiss\xE3o. Nada se move ainda.",
7163
- feeSponsored: "O app cobre a taxa",
7210
+ feeSponsored: "O app paga a taxa de rede",
7164
7211
  feePaid: "Voc\xEA paga a taxa de rede",
7165
7212
  showDetails: "Ver detalhes",
7166
7213
  hideDetails: "Ocultar detalhes",
@@ -7175,6 +7222,9 @@ var TX_REVIEW_COPY = {
7175
7222
  via: "Via",
7176
7223
  fee: "Taxa de rede",
7177
7224
  feeCovered: "Coberta pelo app",
7225
+ feeWallet: "Paga pela sua carteira",
7226
+ opportunity: "Oportunidade",
7227
+ apy: "APY ap\xF3s taxas",
7178
7228
  contract: "Contrato",
7179
7229
  method: "M\xE9todo",
7180
7230
  asset: "Ativo",
@@ -7240,7 +7290,7 @@ function rampFlow(details) {
7240
7290
  return out;
7241
7291
  };
7242
7292
  const from = { ...party(flow.from), self: true };
7243
- const to = { ...party(flow.to), self: kind === "bridge" || kind === "swap" };
7293
+ const to = { ...party(flow.to), self: (kind === "bridge" || kind === "swap") && !flow.to.label };
7244
7294
  return { kind, from, to, via: asString(flow.via) };
7245
7295
  }
7246
7296
  function readableAmount(details) {
@@ -7252,8 +7302,83 @@ function readableAmount(details) {
7252
7302
  return null;
7253
7303
  }
7254
7304
  }
7305
+ var earnOpportunities = /* @__PURE__ */ new Map();
7306
+ function rememberEarnOpportunities(list) {
7307
+ for (const o of list) {
7308
+ earnOpportunities.set(o.id, {
7309
+ name: o.name,
7310
+ ...o.asset?.code ? { asset: o.asset.code } : {},
7311
+ ...typeof o.apy === "number" ? { apy: o.apy } : {}
7312
+ });
7313
+ }
7314
+ }
7315
+ function earnOpportunityLabel(id) {
7316
+ return id ? earnOpportunities.get(id) : void 0;
7317
+ }
7318
+ function reviewForEarn(parts, copy) {
7319
+ const deposit = parts.action === "deposit";
7320
+ const asset = parts.asset ? { asset: parts.asset } : {};
7321
+ const wallet = { chain: parts.chain, self: true, ...asset, ...parts.wallet ? { address: parts.wallet } : {} };
7322
+ const opportunity = { chain: parts.chain, label: parts.name ?? copy.earn.fallbackName, ...asset };
7323
+ const amount = parts.amount ? { amount: parts.amount } : {};
7324
+ const from = deposit ? { ...wallet, ...amount } : { ...opportunity, ...amount };
7325
+ const to = deposit ? opportunity : wallet;
7326
+ const moved = withAsset(from);
7327
+ const rows = [];
7328
+ if (parts.name) rows.push({ label: copy.rows.opportunity, value: parts.name });
7329
+ if (typeof parts.apy === "number") rows.push({ label: copy.rows.apy, value: `${parts.apy.toFixed(2)}%` });
7330
+ if (parts.amount) rows.push({ label: copy.rows.amount, value: moved });
7331
+ rows.push({ label: copy.rows.network, value: [copy.chains[parts.chain], parts.network].filter(Boolean).join(" ") });
7332
+ const walletRow = partyRow(deposit ? copy.rows.from : copy.rows.to, wallet, copy);
7333
+ if (walletRow) rows.push(walletRow);
7334
+ if (parts.sponsored !== void 0)
7335
+ rows.push({ label: copy.rows.fee, value: parts.sponsored ? copy.rows.feeCovered : copy.rows.feeWallet });
7336
+ rows.push(...parts.extraRows ?? []);
7337
+ const title = parts.name ? deposit ? copy.earn.depositInto(parts.name) : copy.earn.withdrawFrom(parts.name) : parts.amount ? deposit ? copy.earn.depositAmount(moved) : copy.earn.withdrawAmount(moved) : deposit ? copy.earn.deposit : copy.earn.withdraw;
7338
+ return {
7339
+ title,
7340
+ kind: deposit ? "deposit" : "withdraw",
7341
+ from,
7342
+ to,
7343
+ ...parts.sponsored !== void 0 ? { fee: { sponsored: parts.sponsored } } : {},
7344
+ rows,
7345
+ ...parts.raw ? { raw: parts.raw } : {},
7346
+ ...parts.hash ? { hash: parts.hash } : {}
7347
+ };
7348
+ }
7349
+ function earnOutcome(parts, copy) {
7350
+ const moved = [parts.amount, parts.asset].filter(Boolean).join(" ");
7351
+ const chain = copy.chains[parts.chain];
7352
+ if (parts.action === "deposit") {
7353
+ return parts.name ? copy.earn.deposited(moved, parts.name, chain) : copy.earn.depositedOn(moved, chain);
7354
+ }
7355
+ return parts.name ? copy.earn.withdrew(moved, parts.name, chain) : copy.earn.withdrewOn(moved, chain);
7356
+ }
7255
7357
  function reviewFromRequest(parts, copy) {
7256
7358
  const details = parts.details ?? {};
7359
+ const earnAction = parts.operation === "earn_deposit" ? "deposit" : parts.operation === "earn_withdraw" ? "withdraw" : null;
7360
+ if (earnAction) {
7361
+ const known = earnOpportunityLabel(asString(details.opportunityId) ?? asString(details.opportunity));
7362
+ const feePayer = asString(details.feePayer);
7363
+ const sponsored = typeof details.sponsored === "boolean" ? details.sponsored : feePayer && parts.signWith ? feePayer !== parts.signWith : parts.appPaysFee;
7364
+ return reviewForEarn(
7365
+ {
7366
+ action: earnAction,
7367
+ chain: parts.chain,
7368
+ network: parts.network,
7369
+ amount: asString(details.amount),
7370
+ asset: asString(details.assetCode) ?? known?.asset,
7371
+ name: known?.name,
7372
+ apy: known?.apy,
7373
+ wallet: parts.signWith,
7374
+ sponsored,
7375
+ raw: parts.raw,
7376
+ hash: parts.hash,
7377
+ ...parts.extraRows ? { extraRows: parts.extraRows } : {}
7378
+ },
7379
+ copy
7380
+ );
7381
+ }
7257
7382
  const flow = rampFlow(details);
7258
7383
  const rows = [];
7259
7384
  let data;
@@ -7407,11 +7532,26 @@ function ChainBadge({ chain, copy }) {
7407
7532
  if (!chain) return null;
7408
7533
  return /* @__PURE__ */ jsx("img", { className: "pollar-txr-chain", src: CHAIN_LOGOS[chain], alt: copy.chains[chain], title: copy.chains[chain] });
7409
7534
  }
7410
- function AssetLogo({ asset }) {
7535
+ function AssetLogo({ asset, small = false }) {
7411
7536
  const url = TOKEN_LOGOS[asset.toUpperCase()];
7412
7537
  const [failed, setFailed] = useState(false);
7413
- if (url && !failed) return /* @__PURE__ */ jsx("img", { className: "pollar-txr-logo", src: url, alt: asset, onError: () => setFailed(true) });
7414
- return /* @__PURE__ */ jsx("span", { className: "pollar-txr-logo pollar-txr-logo-initial", "aria-hidden": true, children: asset.slice(0, 1).toUpperCase() });
7538
+ const size = small ? " pollar-txr-logo-sm" : "";
7539
+ if (url && !failed) return /* @__PURE__ */ jsx("img", { className: `pollar-txr-logo${size}`, src: url, alt: asset, onError: () => setFailed(true) });
7540
+ return /* @__PURE__ */ jsx("span", { className: `pollar-txr-logo pollar-txr-logo-initial${size}`, "aria-hidden": true, children: asset.slice(0, 1).toUpperCase() });
7541
+ }
7542
+ function ChainLogo({ chain }) {
7543
+ return /* @__PURE__ */ jsx("img", { className: "pollar-txr-chain-inline", src: CHAIN_LOGOS[chain], alt: "", "aria-hidden": true });
7544
+ }
7545
+ function TxExplorerLink({
7546
+ chain,
7547
+ url,
7548
+ language: languageProp
7549
+ }) {
7550
+ const copy = TX_REVIEW_COPY[useInheritedLanguage(languageProp)];
7551
+ return /* @__PURE__ */ jsxs("a", { className: "pollar-txr-link pollar-txr-explorer", href: url, target: "_blank", rel: "noopener noreferrer", children: [
7552
+ /* @__PURE__ */ jsx(ChainLogo, { chain }),
7553
+ copy.viewOnExplorer
7554
+ ] });
7415
7555
  }
7416
7556
  function AccountGlyph() {
7417
7557
  return /* @__PURE__ */ jsx("span", { className: "pollar-txr-logo pollar-txr-logo-glyph", "aria-hidden": true, children: /* @__PURE__ */ jsxs("svg", { width: "18", height: "18", viewBox: "0 0 20 20", fill: "none", children: [
@@ -7496,7 +7636,7 @@ function TxReview({ data, open: openProp, onToggle, language: languageProp }) {
7496
7636
  const toggle = onToggle ?? (() => setOpenState((v) => !v));
7497
7637
  const { from, to, kind } = data;
7498
7638
  const toShowsAmount = !!to?.amount && (to.amount !== from?.amount || to.asset !== from?.asset);
7499
- const toGlyph = kind === "approve" ? "contract" : kind === "bridge" || kind === "swap" ? "asset" : "account";
7639
+ const toGlyph = kind === "approve" ? "contract" : kind === "bridge" || kind === "swap" || kind === "deposit" || kind === "withdraw" ? "asset" : "account";
7500
7640
  return /* @__PURE__ */ jsxs("div", { className: "pollar-txr", children: [
7501
7641
  from && to && /* @__PURE__ */ jsxs("div", { className: "pollar-txr-flow", children: [
7502
7642
  /* @__PURE__ */ jsx(Node2, { party: from, showAmount: true, glyph: from.asset ? "asset" : "account", copy }),
@@ -7657,7 +7797,10 @@ function TxStatusView({
7657
7797
  onToggleXdr,
7658
7798
  onRetry,
7659
7799
  onDone,
7660
- language: languageProp
7800
+ language: languageProp,
7801
+ review: reviewProp,
7802
+ successMessage,
7803
+ successExtra
7661
7804
  }) {
7662
7805
  const language = useInheritedLanguage(languageProp);
7663
7806
  const copy = TRANSACTION_COPY[language];
@@ -7672,19 +7815,23 @@ function TxStatusView({
7672
7815
  const reviewCopy = TX_REVIEW_COPY[language];
7673
7816
  const hashInfo = hash ? { value: hash, explorerUrl } : void 0;
7674
7817
  const sponsored = "sponsored" in transaction ? transaction.sponsored : void 0;
7675
- const review = buildData ? reviewFromBuild(buildData, reviewCopy, copy.title, hashInfo, sponsored) : hashInfo ? { title: copy.title, kind: "other", rows: [], hash: hashInfo, ...sponsored !== void 0 && { fee: { sponsored } } } : null;
7818
+ const review = reviewProp ? {
7819
+ ...reviewProp,
7820
+ ...hashInfo && { hash: hashInfo },
7821
+ ...sponsored !== void 0 && { fee: { sponsored } }
7822
+ } : buildData ? reviewFromBuild(buildData, reviewCopy, copy.title, hashInfo, sponsored) : hashInfo ? { title: copy.title, kind: "other", rows: [], hash: hashInfo, ...sponsored !== void 0 && { fee: { sponsored } } } : null;
7676
7823
  const walletImg = walletType === WalletType.FREIGHTER ? LOGO_FREIGHTER : walletType === WalletType.ALBEDO ? LOGO_ALBEDO : null;
7677
7824
  const walletAlt = walletType === WalletType.FREIGHTER ? "Freighter" : walletType === WalletType.ALBEDO ? "Albedo" : "Pollar";
7678
7825
  const statusBanner = /* @__PURE__ */ jsx(
7679
7826
  ModalStatusBanner,
7680
7827
  {
7681
- message: copy.status[transaction.step],
7828
+ message: isSuccess && successMessage ? successMessage : copy.status[transaction.step],
7682
7829
  status: isError ? "ERROR" : isInFlight ? "LOADING" : isSuccess ? "SUCCESS" : "NONE"
7683
7830
  }
7684
7831
  );
7685
7832
  const showSpinner = isInFlight || isSuccess || isError;
7686
7833
  const reviewBlock = showDetails && review && /* @__PURE__ */ jsxs("div", { className: "pollar-tx-review", children: [
7687
- buildData && /* @__PURE__ */ jsx("p", { className: "pollar-tx-review-title", children: review.title }),
7834
+ (buildData || reviewProp) && /* @__PURE__ */ jsx("p", { className: "pollar-tx-review-title", children: review.title }),
7688
7835
  /* @__PURE__ */ jsx(TxReview, { data: review, open: showXdr, onToggle: onToggleXdr, language })
7689
7836
  ] });
7690
7837
  return /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -7734,6 +7881,7 @@ function TxStatusView({
7734
7881
  isError && onRetry && "buildData" in transaction && transaction.buildData && /* @__PURE__ */ jsx("button", { className: "pollar-btn-secondary pollar-tx-retry-btn", onClick: onRetry, children: copy.tryAgain })
7735
7882
  ] }),
7736
7883
  isSuccess && reviewBlock,
7884
+ isSuccess && successExtra,
7737
7885
  isSuccess && /* @__PURE__ */ jsx("button", { className: "pollar-btn-primary pollar-tx-sign-btn", onClick: onDone, children: copy.done }),
7738
7886
  !showSpinner && statusBanner
7739
7887
  ] });
@@ -10293,7 +10441,11 @@ var EARN_COPY = {
10293
10441
  apyAfterFees: "APY after fees",
10294
10442
  profit: "Earned after fees",
10295
10443
  stale: "Last known figures; they refresh on their own.",
10296
- actionUnavailable: (action) => `This opportunity does not take ${action === "deposit" ? "deposits" : "withdrawals"} right now.`
10444
+ actionUnavailable: (action) => `This opportunity does not take ${action === "deposit" ? "deposits" : "withdrawals"} right now.`,
10445
+ deposited: "Deposited",
10446
+ depositDone: "Deposit complete",
10447
+ withdrawDone: "Withdrawal complete",
10448
+ positionNow: "Your position now"
10297
10449
  },
10298
10450
  es: {
10299
10451
  title: "Rendimientos",
@@ -10334,7 +10486,11 @@ var EARN_COPY = {
10334
10486
  apyAfterFees: "APY despu\xE9s de comisiones",
10335
10487
  profit: "Ganado despu\xE9s de comisiones",
10336
10488
  stale: "\xDAltimas cifras conocidas; se actualizan solas.",
10337
- actionUnavailable: (action) => `Esta oportunidad no acepta ${action === "deposit" ? "dep\xF3sitos" : "retiros"} en este momento.`
10489
+ actionUnavailable: (action) => `Esta oportunidad no acepta ${action === "deposit" ? "dep\xF3sitos" : "retiros"} en este momento.`,
10490
+ deposited: "Depositado",
10491
+ depositDone: "Dep\xF3sito completado",
10492
+ withdrawDone: "Retiro completado",
10493
+ positionNow: "Tu posici\xF3n ahora"
10338
10494
  },
10339
10495
  pt: {
10340
10496
  title: "Rendimentos",
@@ -10375,7 +10531,11 @@ var EARN_COPY = {
10375
10531
  apyAfterFees: "APY ap\xF3s taxas",
10376
10532
  profit: "Ganho ap\xF3s taxas",
10377
10533
  stale: "\xDAltimos valores conhecidos; eles se atualizam sozinhos.",
10378
- actionUnavailable: (action) => `Esta oportunidade n\xE3o aceita ${action === "deposit" ? "dep\xF3sitos" : "saques"} no momento.`
10534
+ actionUnavailable: (action) => `Esta oportunidade n\xE3o aceita ${action === "deposit" ? "dep\xF3sitos" : "saques"} no momento.`,
10535
+ deposited: "Depositado",
10536
+ depositDone: "Dep\xF3sito conclu\xEDdo",
10537
+ withdrawDone: "Saque conclu\xEDdo",
10538
+ positionNow: "Sua posi\xE7\xE3o agora"
10379
10539
  }
10380
10540
  };
10381
10541
  var POSITION_POLL_MS = 1e4;
@@ -10395,6 +10555,38 @@ function formatAmount3(value) {
10395
10555
  const n = parseFloat(value);
10396
10556
  return isNaN(n) ? value : n.toLocaleString(void 0, { maximumFractionDigits: 7 });
10397
10557
  }
10558
+ function PositionCard({
10559
+ copy,
10560
+ assetCode,
10561
+ name,
10562
+ apy,
10563
+ apyLabel,
10564
+ rows,
10565
+ stale
10566
+ }) {
10567
+ return /* @__PURE__ */ jsxs("div", { className: "pollar-swap-quote pollar-earn-card", children: [
10568
+ /* @__PURE__ */ jsxs("div", { className: "pollar-earn-card-head", children: [
10569
+ assetCode && /* @__PURE__ */ jsx(AssetLogo, { asset: assetCode, small: true }),
10570
+ /* @__PURE__ */ jsx("strong", { className: "pollar-earn-card-name", children: name }),
10571
+ typeof apy === "number" && /* @__PURE__ */ jsxs("span", { className: "pollar-earn-live", children: [
10572
+ apy.toFixed(2),
10573
+ "% APY"
10574
+ ] })
10575
+ ] }),
10576
+ rows.map((row) => /* @__PURE__ */ jsxs("div", { className: "pollar-swap-quote-row", children: [
10577
+ /* @__PURE__ */ jsx("span", { className: "pollar-send-hint", children: row.label }),
10578
+ /* @__PURE__ */ jsx("span", { children: row.value == null ? "..." : `${formatAmount3(row.value)} ${assetCode}`.trim() })
10579
+ ] }, row.label)),
10580
+ typeof apy === "number" && /* @__PURE__ */ jsxs("div", { className: "pollar-swap-quote-row", children: [
10581
+ /* @__PURE__ */ jsx("span", { className: "pollar-send-hint", children: apyLabel }),
10582
+ /* @__PURE__ */ jsxs("span", { className: "pollar-earn-live", children: [
10583
+ apy.toFixed(2),
10584
+ "%"
10585
+ ] })
10586
+ ] }),
10587
+ stale && /* @__PURE__ */ jsx("div", { className: "pollar-send-hint", children: copy.stale })
10588
+ ] });
10589
+ }
10398
10590
  function EarnModal({ onClose, initial }) {
10399
10591
  const {
10400
10592
  getEarnProviders,
@@ -10409,6 +10601,7 @@ function EarnModal({ onClose, initial }) {
10409
10601
  earnSolanaWithdraw,
10410
10602
  tx: transaction,
10411
10603
  wallet,
10604
+ wallets,
10412
10605
  refreshWalletBalance,
10413
10606
  enabledAssets,
10414
10607
  refreshAssets,
@@ -10416,7 +10609,9 @@ function EarnModal({ onClose, initial }) {
10416
10609
  network,
10417
10610
  styles
10418
10611
  } = usePollar();
10419
- const copy = EARN_COPY[useModalLanguage()];
10612
+ const language = useModalLanguage();
10613
+ const copy = EARN_COPY[language];
10614
+ const reviewCopy = TX_REVIEW_COPY[language];
10420
10615
  const walletType = wallet?.custody === "external" ? wallet.provider : null;
10421
10616
  const [earnChain, setEarnChain] = useState(
10422
10617
  () => oneOf(["STELLAR", "SOLANA"], initial?.chain) ?? "STELLAR"
@@ -10441,6 +10636,7 @@ function EarnModal({ onClose, initial }) {
10441
10636
  const [formError, setFormError] = useState("");
10442
10637
  const [refreshing, setRefreshing] = useState(false);
10443
10638
  const [showXdr, setShowXdr] = useState(false);
10639
+ const [submission, setSubmission] = useState(null);
10444
10640
  const [copied, setCopied] = useState(false);
10445
10641
  const copyTimerRef = useRef(null);
10446
10642
  const loadProviders = useCallback(() => {
@@ -10552,7 +10748,7 @@ function EarnModal({ onClose, initial }) {
10552
10748
  const explorerUrl = !hash ? null : onSolana ? `https://solscan.io/tx/${hash}${network === "testnet" ? "?cluster=devnet" : ""}` : `https://stellar.expert/explorer/${explorerNetwork}/tx/${hash}`;
10553
10749
  const isInProgress = IN_FLIGHT_STEPS2.includes(transaction.step);
10554
10750
  const showBack = step === "tx" && (transaction.step === "error" || transaction.step === "success") && !isInProgress;
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;
10751
+ const txTitle = isInProgress ? tab === "deposit" ? copy.depositing : copy.withdrawing : transaction.step === "success" ? tab === "deposit" ? copy.depositDone : copy.withdrawDone : transaction.step === "error" ? tab === "deposit" ? copy.depositFailed : copy.withdrawFailed : copy.confirm;
10556
10752
  const parsedAmount = parseFloat(amount);
10557
10753
  const exceedsAvailable = tab === "deposit" ? walletAvailable != null && parsedAmount > parseFloat(walletAvailable) : withdrawable != null && parsedAmount > parseFloat(withdrawable);
10558
10754
  const canSubmit = !smartUnsupported && (onSolana || !!provider) && !actionUnavailable && !!opportunityId && !!amount && parsedAmount > 0 && !exceedsAvailable && !providersLoading && !loadingOpps;
@@ -10584,6 +10780,16 @@ function EarnModal({ onClose, initial }) {
10584
10780
  setFormError(copy.exceedsPosition);
10585
10781
  return;
10586
10782
  }
10783
+ const chosen = onSolana ? selectedSolana : selectedOpportunity;
10784
+ setSubmission({
10785
+ action: tab,
10786
+ chain: earnChain,
10787
+ amount,
10788
+ // A DeFindex withdrawal is counted in shares, not in the asset.
10789
+ asset: tab === "withdraw" && withdrawUnit === "shares" ? copy.shares : assetCode,
10790
+ name: chosen?.name,
10791
+ apy: onSolana ? solanaPosition?.apy ?? selectedSolana?.apy ?? void 0 : selectedOpportunity?.apy
10792
+ });
10587
10793
  setStep("tx");
10588
10794
  if (tab === "deposit" && depositNeedsTrustline && selectedOpportunity?.asset.issuer) {
10589
10795
  const tl = await setTrustline({ code: assetCode, issuer: selectedOpportunity.asset.issuer });
@@ -10597,6 +10803,8 @@ function EarnModal({ onClose, initial }) {
10597
10803
  const outcome = await runEarn();
10598
10804
  if (outcome && (outcome.status === "success" || outcome.status === "pending")) {
10599
10805
  setAmount("");
10806
+ setPosition(null);
10807
+ setSolanaPosition(null);
10600
10808
  refreshPosition();
10601
10809
  }
10602
10810
  }
@@ -10651,6 +10859,44 @@ function EarnModal({ onClose, initial }) {
10651
10859
  }
10652
10860
  }
10653
10861
  const title = step === "form" ? copy.title : txTitle;
10862
+ const submissionReview = submission ? reviewForEarn(
10863
+ {
10864
+ action: submission.action,
10865
+ chain: submission.chain,
10866
+ network,
10867
+ amount: submission.amount,
10868
+ asset: submission.asset,
10869
+ name: submission.name,
10870
+ apy: submission.apy,
10871
+ wallet: wallets.find((w) => (w.chain ?? "STELLAR") === submission.chain)?.address
10872
+ },
10873
+ reviewCopy
10874
+ ) : null;
10875
+ const resultPosition = submission?.chain === "SOLANA" && selectedSolana && solanaPosition ? /* @__PURE__ */ jsx(
10876
+ PositionCard,
10877
+ {
10878
+ copy,
10879
+ assetCode,
10880
+ name: copy.positionNow,
10881
+ apy: solanaPosition.apy ?? selectedSolana.apy,
10882
+ apyLabel: copy.apyAfterFees,
10883
+ rows: [
10884
+ { label: copy.deposited, value: solanaPosition.principal },
10885
+ ...solanaPosition.profit != null ? [{ label: copy.profit, value: solanaPosition.profit }] : [],
10886
+ { label: copy.yourPosition, value: solanaPosition.balance }
10887
+ ]
10888
+ }
10889
+ ) : submission?.chain === "STELLAR" && selectedOpportunity && position ? /* @__PURE__ */ jsx(
10890
+ PositionCard,
10891
+ {
10892
+ copy,
10893
+ assetCode,
10894
+ name: copy.positionNow,
10895
+ apy: selectedOpportunity.apy,
10896
+ apyLabel: "APY",
10897
+ rows: [{ label: copy.yourPosition, value: position.balance }]
10898
+ }
10899
+ ) : null;
10654
10900
  return /* @__PURE__ */ jsx(PollarOverlay, { style: overlayStyle, onClick: !isInProgress ? onClose : void 0, children: /* @__PURE__ */ jsxs(
10655
10901
  "div",
10656
10902
  {
@@ -10731,21 +10977,30 @@ function EarnModal({ onClose, initial }) {
10731
10977
  )
10732
10978
  ] }),
10733
10979
  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",
10980
+ /* @__PURE__ */ jsx("span", { className: "pollar-send-label", children: copy.network }),
10981
+ /* @__PURE__ */ jsx("div", { className: "pollar-tabs pollar-earn-networks", role: "radiogroup", "aria-label": copy.network, children: networks.map((n) => /* @__PURE__ */ jsxs(
10982
+ "button",
10737
10983
  {
10738
- className: "pollar-input pollar-send-select",
10739
- value: earnChain,
10740
- onChange: (e) => {
10741
- setEarnChain(e.target.value);
10984
+ type: "button",
10985
+ role: "radio",
10986
+ "aria-checked": earnChain === n,
10987
+ className: "pollar-tab pollar-earn-network",
10988
+ "data-active": earnChain === n,
10989
+ "data-chain": n,
10990
+ onClick: () => {
10991
+ if (n === earnChain) return;
10992
+ setEarnChain(n);
10742
10993
  setOpportunityId("");
10743
10994
  setAmount("");
10744
10995
  setFormError("");
10745
10996
  },
10746
- children: networks.map((n) => /* @__PURE__ */ jsx("option", { value: n, children: n === "SOLANA" ? "Solana" : "Stellar" }, n))
10747
- }
10748
- )
10997
+ children: [
10998
+ /* @__PURE__ */ jsx(ChainLogo, { chain: n }),
10999
+ reviewCopy.chains[n]
11000
+ ]
11001
+ },
11002
+ n
11003
+ )) })
10749
11004
  ] }),
10750
11005
  !onSolana && providers && providers.length > 1 && /* @__PURE__ */ jsxs("div", { className: "pollar-send-field", children: [
10751
11006
  /* @__PURE__ */ jsx("label", { className: "pollar-send-label", children: copy.provider }),
@@ -10780,66 +11035,34 @@ function EarnModal({ onClose, initial }) {
10780
11035
  }
10781
11036
  )
10782
11037
  ] }),
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
- ] }),
11038
+ selectedSolana && /* @__PURE__ */ jsx(
11039
+ PositionCard,
11040
+ {
11041
+ copy,
11042
+ assetCode,
11043
+ name: selectedSolana.name,
11044
+ apy: solanaPosition?.apy ?? selectedSolana.apy,
11045
+ apyLabel: copy.apyAfterFees,
11046
+ rows: [
11047
+ { label: copy.deposited, value: solanaPosition?.principal },
11048
+ ...solanaPosition?.profit != null ? [{ label: copy.profit, value: solanaPosition.profit }] : [],
11049
+ { label: copy.yourPosition, value: solanaPosition?.balance }
11050
+ ],
11051
+ stale: solanaPosition?.stale
11052
+ }
11053
+ ),
10817
11054
  actionUnavailable && /* @__PURE__ */ jsx("div", { className: "pollar-send-hint", children: copy.actionUnavailable(tab) }),
10818
- selectedOpportunity && /* @__PURE__ */ jsxs("div", { className: "pollar-swap-quote", children: [
10819
- tab === "deposit" && /* @__PURE__ */ jsxs("div", { className: "pollar-swap-quote-row", children: [
10820
- /* @__PURE__ */ jsx("span", { className: "pollar-send-hint", children: copy.inYourWallet }),
10821
- /* @__PURE__ */ jsxs("span", { children: [
10822
- walletAvailable != null ? formatAmount3(walletAvailable) : "\u2026",
10823
- " ",
10824
- assetCode
10825
- ] })
10826
- ] }),
10827
- /* @__PURE__ */ jsxs("div", { className: "pollar-swap-quote-row", children: [
10828
- /* @__PURE__ */ jsx("span", { className: "pollar-send-hint", children: copy.yourPosition }),
10829
- /* @__PURE__ */ jsxs("span", { children: [
10830
- position ? formatAmount3(position.balance) : "\u2026",
10831
- " ",
10832
- assetCode
10833
- ] })
10834
- ] }),
10835
- /* @__PURE__ */ jsxs("div", { className: "pollar-swap-quote-row", children: [
10836
- /* @__PURE__ */ jsx("span", { className: "pollar-send-hint", children: "APY" }),
10837
- /* @__PURE__ */ jsxs("span", { className: "pollar-earn-live", children: [
10838
- selectedOpportunity.apy.toFixed(2),
10839
- "%"
10840
- ] })
10841
- ] })
10842
- ] }),
11055
+ selectedOpportunity && /* @__PURE__ */ jsx(
11056
+ PositionCard,
11057
+ {
11058
+ copy,
11059
+ assetCode,
11060
+ name: selectedOpportunity.name,
11061
+ apy: selectedOpportunity.apy,
11062
+ apyLabel: "APY",
11063
+ rows: [{ label: copy.yourPosition, value: position?.balance }]
11064
+ }
11065
+ ),
10843
11066
  /* @__PURE__ */ jsx(
10844
11067
  AmountField,
10845
11068
  {
@@ -10848,6 +11071,7 @@ function EarnModal({ onClose, initial }) {
10848
11071
  value: amount,
10849
11072
  onChange: setAmount,
10850
11073
  unit: amountUnitLabel,
11074
+ unitIcon: amountUnitLabel === assetCode && assetCode ? /* @__PURE__ */ jsx(AssetLogo, { asset: assetCode, small: true }) : void 0,
10851
11075
  available: tab === "deposit" ? walletAvailable : withdrawable ?? void 0
10852
11076
  }
10853
11077
  ),
@@ -10868,7 +11092,14 @@ function EarnModal({ onClose, initial }) {
10868
11092
  onToggleXdr: () => setShowXdr((v) => !v),
10869
11093
  onCopyHash: handleCopyHash,
10870
11094
  onRetry: () => void handleRetry(),
10871
- onDone: onClose
11095
+ onDone: onClose,
11096
+ language,
11097
+ review: submissionReview,
11098
+ successMessage: submission ? earnOutcome(submission, reviewCopy) : void 0,
11099
+ successExtra: submission && /* @__PURE__ */ jsxs(Fragment, { children: [
11100
+ resultPosition,
11101
+ explorerUrl && /* @__PURE__ */ jsx(TxExplorerLink, { chain: submission.chain, url: explorerUrl, language })
11102
+ ] })
10872
11103
  }
10873
11104
  ),
10874
11105
  /* @__PURE__ */ jsx(PollarModalFooter, {})
@@ -10883,11 +11114,11 @@ var CARD_COPY = {
10883
11114
  funding: {
10884
11115
  CREATED: {
10885
11116
  title: "Confirming your payment",
10886
- hint: "Your USDC payment is being confirmed on Stellar. This takes a few seconds."
11117
+ hint: "Your USDC payment is being confirmed. This takes a few seconds."
10887
11118
  },
10888
11119
  BURNED: {
10889
11120
  title: "Sending it to the card network",
10890
- hint: "Your USDC left Stellar. Circle is confirming the transfer, usually in about a minute."
11121
+ hint: "Your USDC left your wallet. Circle is confirming the transfer, usually within a few minutes."
10891
11122
  },
10892
11123
  ATTESTED: {
10893
11124
  title: "Crossing to the card network",
@@ -10903,7 +11134,7 @@ var CARD_COPY = {
10903
11134
  fundingSolana: {
10904
11135
  CREATED: {
10905
11136
  title: "Confirming your payment",
10906
- hint: "Your USDC payment is being confirmed on Solana. This takes a few seconds."
11137
+ hint: "Your USDC payment is being confirmed. This takes a few seconds."
10907
11138
  },
10908
11139
  SENT: {
10909
11140
  title: "Arrived, crediting your card",
@@ -11042,18 +11273,22 @@ var CARD_COPY = {
11042
11273
  noBalance: "Your wallet does not have enough USDC for this amount.",
11043
11274
  notPaid: "The payment was not sent.",
11044
11275
  failed: "The payment could not be completed. Please try again.",
11045
- delayed: "Taking longer than usual. We are following up with the card provider."
11046
- }
11276
+ delayed: "Taking longer than usual. We are following up with the card provider.",
11277
+ crossing: "Your USDC crosses to the card network. It takes a few minutes, and the network fees are covered.",
11278
+ noRoute: "Your wallets cannot fund this card right now."
11279
+ },
11280
+ networkError: "We could not reach the card service. Check your connection and try again.",
11281
+ retry: "Try again"
11047
11282
  },
11048
11283
  es: {
11049
11284
  funding: {
11050
11285
  CREATED: {
11051
11286
  title: "Confirmando tu pago",
11052
- hint: "Tu pago en USDC se est\xE1 confirmando en Stellar. Esto toma unos segundos."
11287
+ hint: "Tu pago en USDC se est\xE1 confirmando. Esto toma unos segundos."
11053
11288
  },
11054
11289
  BURNED: {
11055
11290
  title: "Envi\xE1ndolo a la red de la tarjeta",
11056
- hint: "Tus USDC salieron de Stellar. Circle est\xE1 confirmando la transferencia, normalmente en un minuto."
11291
+ hint: "Tus USDC salieron de tu wallet. Circle est\xE1 confirmando la transferencia, normalmente en unos minutos."
11057
11292
  },
11058
11293
  ATTESTED: {
11059
11294
  title: "Cruzando a la red de la tarjeta",
@@ -11069,7 +11304,7 @@ var CARD_COPY = {
11069
11304
  fundingSolana: {
11070
11305
  CREATED: {
11071
11306
  title: "Confirmando tu pago",
11072
- hint: "Tu pago en USDC se est\xE1 confirmando en Solana. Esto toma unos segundos."
11307
+ hint: "Tu pago en USDC se est\xE1 confirmando. Esto toma unos segundos."
11073
11308
  },
11074
11309
  SENT: {
11075
11310
  title: "Lleg\xF3, acreditando tu tarjeta",
@@ -11208,18 +11443,22 @@ var CARD_COPY = {
11208
11443
  noBalance: "Tu wallet no tiene suficiente USDC para este monto.",
11209
11444
  notPaid: "El pago no se envi\xF3.",
11210
11445
  failed: "No se pudo completar el pago. Intenta de nuevo.",
11211
- delayed: "Est\xE1 tardando m\xE1s de lo normal. Estamos haciendo seguimiento con el emisor de la tarjeta."
11212
- }
11446
+ delayed: "Est\xE1 tardando m\xE1s de lo normal. Estamos haciendo seguimiento con el emisor de la tarjeta.",
11447
+ crossing: "Tus USDC cruzan a la red de la tarjeta. Toma unos minutos y las comisiones de red est\xE1n cubiertas.",
11448
+ noRoute: "Tus wallets no pueden fondear esta tarjeta por ahora."
11449
+ },
11450
+ networkError: "No pudimos conectar con el servicio de la tarjeta. Revisa tu conexi\xF3n e intenta de nuevo.",
11451
+ retry: "Intentar de nuevo"
11213
11452
  },
11214
11453
  pt: {
11215
11454
  funding: {
11216
11455
  CREATED: {
11217
11456
  title: "Confirmando seu pagamento",
11218
- hint: "Seu pagamento em USDC est\xE1 sendo confirmado na Stellar. Isso leva alguns segundos."
11457
+ hint: "Seu pagamento em USDC est\xE1 sendo confirmado. Isso leva alguns segundos."
11219
11458
  },
11220
11459
  BURNED: {
11221
11460
  title: "Enviando para a rede do cart\xE3o",
11222
- hint: "Seus USDC sa\xEDram da Stellar. A Circle est\xE1 confirmando a transfer\xEAncia, normalmente em cerca de um minuto."
11461
+ hint: "Seus USDC sa\xEDram da sua carteira. A Circle est\xE1 confirmando a transfer\xEAncia, normalmente em alguns minutos."
11223
11462
  },
11224
11463
  ATTESTED: {
11225
11464
  title: "Atravessando para a rede do cart\xE3o",
@@ -11235,7 +11474,7 @@ var CARD_COPY = {
11235
11474
  fundingSolana: {
11236
11475
  CREATED: {
11237
11476
  title: "Confirmando seu pagamento",
11238
- hint: "Seu pagamento em USDC est\xE1 sendo confirmado na Solana. Isso leva alguns segundos."
11477
+ hint: "Seu pagamento em USDC est\xE1 sendo confirmado. Isso leva alguns segundos."
11239
11478
  },
11240
11479
  SENT: {
11241
11480
  title: "Chegou, creditando seu cart\xE3o",
@@ -11374,8 +11613,12 @@ var CARD_COPY = {
11374
11613
  noBalance: "Sua carteira n\xE3o tem USDC suficiente para este valor.",
11375
11614
  notPaid: "O pagamento n\xE3o foi enviado.",
11376
11615
  failed: "N\xE3o foi poss\xEDvel concluir o pagamento. Tente novamente.",
11377
- delayed: "Est\xE1 demorando mais que o normal. Estamos acompanhando com o emissor do cart\xE3o."
11378
- }
11616
+ delayed: "Est\xE1 demorando mais que o normal. Estamos acompanhando com o emissor do cart\xE3o.",
11617
+ crossing: "Seus USDC atravessam para a rede do cart\xE3o. Leva alguns minutos, e as taxas de rede est\xE3o cobertas.",
11618
+ noRoute: "Suas carteiras n\xE3o podem recarregar este cart\xE3o por enquanto."
11619
+ },
11620
+ networkError: "N\xE3o conseguimos conectar ao servi\xE7o do cart\xE3o. Verifique sua conex\xE3o e tente novamente.",
11621
+ retry: "Tentar novamente"
11379
11622
  }
11380
11623
  };
11381
11624
  var CREDIT_DELAYED = "provider_credit_delayed";
@@ -11386,7 +11629,7 @@ function fundingProblemText(error, copy) {
11386
11629
  return /token balance/i.test(raw) ? copy.fundingProblem.noBalance : copy.fundingProblem.noGas;
11387
11630
  }
11388
11631
  if (/insufficient_usdc/.test(raw)) return copy.fundingProblem.noBalance;
11389
- if (/^(payment_not_received|cosign_rejected|cosign_expired)/.test(raw)) return copy.fundingProblem.notPaid;
11632
+ if (/^(payment_not_received|cosign_rejected|cosign_expired)/i.test(raw)) return copy.fundingProblem.notPaid;
11390
11633
  return copy.fundingProblem.failed;
11391
11634
  }
11392
11635
 
@@ -11436,11 +11679,9 @@ function newFundingKey() {
11436
11679
  return `fund-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
11437
11680
  }
11438
11681
  var FUNDING_STEPS = {
11439
- STELLAR: ["CREATED", "BURNED", "ATTESTED", "MINTED"],
11440
- SOLANA: ["CREATED", "SENT"]
11682
+ CCTP: ["CREATED", "BURNED", "ATTESTED", "MINTED"],
11683
+ DIRECT: ["CREATED", "SENT"]
11441
11684
  };
11442
- var FUNDING_CHAINS = ["STELLAR", "SOLANA"];
11443
- var isFundingChain = (chain) => FUNDING_CHAINS.includes(chain);
11444
11685
  var INCOME_RANGES = ["0-1000", "1000-5000", "5000-10000", "10000+"];
11445
11686
  var KYC_PENDING = /* @__PURE__ */ new Set(["PENDING", "NEEDS_ACTION", "IN_REVIEW"]);
11446
11687
  var KYC_FINAL = /* @__PURE__ */ new Set(["DENIED", "LOCKED", "CANCELED"]);
@@ -11493,6 +11734,7 @@ function errorText2(e, fallback, copy) {
11493
11734
  if (typeof message === "string" && message) return message;
11494
11735
  return e.code;
11495
11736
  }
11737
+ if (isPollarNetworkError(e)) return copy.networkError;
11496
11738
  return e instanceof Error && e.message ? e.message : fallback;
11497
11739
  }
11498
11740
  function CardModal({ onClose, initial }) {
@@ -11512,8 +11754,11 @@ function CardModal({ onClose, initial }) {
11512
11754
  const [deposit, setDeposit] = useState(null);
11513
11755
  const [fundings, setFundings] = useState(null);
11514
11756
  const [fundAmount, setFundAmount] = useState(() => seededAmount(initial?.amount));
11757
+ const [loadAttempt, setLoadAttempt] = useState(0);
11758
+ const [loadFailed, setLoadFailed] = useState(false);
11515
11759
  const fundKey = useRef(null);
11516
11760
  const [fundChain, setFundChain] = useState(initial?.chain ?? null);
11761
+ const [fundRoutes, setFundRoutes] = useState(null);
11517
11762
  const fundPanelSeed = useRef(initial?.panel === "fund");
11518
11763
  const [showManual, setShowManual] = useState(false);
11519
11764
  const [occupations, setOccupations] = useState([]);
@@ -11527,8 +11772,10 @@ function CardModal({ onClose, initial }) {
11527
11772
  const revealTimer = useRef(null);
11528
11773
  const provider = providers?.[0] ?? null;
11529
11774
  const fundingAsset = provider?.fundingAssets[0] ?? "USDC";
11530
- const fundChains = useChains().chains.filter(isFundingChain);
11775
+ const appOrder = useChains().chains;
11776
+ const fundChains = (fundRoutes ?? []).map((route) => route.source).sort((a, b) => appOrder.indexOf(a) - appOrder.indexOf(b));
11531
11777
  const selectedFundChain = (fundChain && fundChains.includes(fundChain) ? fundChain : null) ?? fundChains[0] ?? "STELLAR";
11778
+ const selectedRoute = fundRoutes?.find((route) => route.source === selectedFundChain);
11532
11779
  const fundAvailable = useWalletAvailable(panel === "fund" ? { chain: selectedFundChain, code: fundingAsset } : null);
11533
11780
  const card = cards?.[0] ?? null;
11534
11781
  const expiry = card?.expMonth && card.expYear ? `${card.expMonth}/${card.expYear.slice(-2)}` : null;
@@ -11577,13 +11824,19 @@ function CardModal({ onClose, initial }) {
11577
11824
  if (!cancelled) {
11578
11825
  setProviders((cur) => cur ?? []);
11579
11826
  setError(errorText2(e, copy.failed.load, copy));
11827
+ setLoadFailed(true);
11580
11828
  }
11581
11829
  }
11582
11830
  })();
11583
11831
  return () => {
11584
11832
  cancelled = true;
11585
11833
  };
11586
- }, [getClient, loadHolder, loadRequirements, loadCardData]);
11834
+ }, [getClient, loadHolder, loadRequirements, loadCardData, loadAttempt]);
11835
+ const retryLoad = () => {
11836
+ setLoadFailed(false);
11837
+ setError("");
11838
+ setLoadAttempt((n) => n + 1);
11839
+ };
11587
11840
  const stage = cardStage(holder, requirements);
11588
11841
  useEffect(() => {
11589
11842
  if (stage !== "provider-form") return;
@@ -11687,7 +11940,9 @@ function CardModal({ onClose, initial }) {
11687
11940
  const openFund = () => run(
11688
11941
  "fund",
11689
11942
  async () => {
11690
- setFundings(await getClient().listCardFundings());
11943
+ const [list, routes] = await Promise.all([getClient().listCardFundings(), getClient().getCardFundingRoutes()]);
11944
+ setFundings(list);
11945
+ setFundRoutes(routes);
11691
11946
  setPanel("fund");
11692
11947
  },
11693
11948
  copy.failed.loadFundings
@@ -11703,10 +11958,12 @@ function CardModal({ onClose, initial }) {
11703
11958
  fundKey.current ?? (fundKey.current = newFundingKey());
11704
11959
  let outcome;
11705
11960
  try {
11706
- outcome = await getClient().fundCard({
11961
+ const client = getClient();
11962
+ outcome = await client.fundCard({
11707
11963
  amount: fundAmount.trim(),
11708
11964
  chain: selectedFundChain,
11709
- idempotencyKey: fundKey.current
11965
+ idempotencyKey: fundKey.current,
11966
+ signBridgeStep: (transferId, actionId) => signStepWithWallet(client, transferId, actionId, BRIDGE_COPY[language])
11710
11967
  });
11711
11968
  } catch (e) {
11712
11969
  if (isPollarApiError(e)) fundKey.current = null;
@@ -12098,6 +12355,8 @@ function CardModal({ onClose, initial }) {
12098
12355
  language
12099
12356
  }
12100
12357
  ),
12358
+ fundRoutes?.length === 0 && /* @__PURE__ */ jsx("p", { className: "pollar-card-note", children: copy.fundingProblem.noRoute }),
12359
+ selectedRoute?.route === "CCTP" && /* @__PURE__ */ jsx("p", { className: "pollar-card-note", children: copy.fundingProblem.crossing }),
12101
12360
  /* @__PURE__ */ jsx(
12102
12361
  AmountField,
12103
12362
  {
@@ -12117,15 +12376,15 @@ function CardModal({ onClose, initial }) {
12117
12376
  type: "button",
12118
12377
  className: "pollar-btn-primary",
12119
12378
  onClick: () => void fund(),
12120
- disabled: busy !== null || !(Number(fundAmount) >= 1),
12379
+ disabled: busy !== null || !selectedRoute || !(Number(fundAmount) >= 1),
12121
12380
  children: busy === "fund-send" ? copy.sending : copy.fundFromWallet
12122
12381
  }
12123
12382
  ) }),
12124
12383
  fundings && fundings.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
12125
12384
  /* @__PURE__ */ jsx("p", { className: "pollar-card-section-title", children: copy.yourFundings }),
12126
12385
  fundings.map((f) => {
12127
- const state = (f.chain === "SOLANA" ? copy.fundingSolana[f.status] : void 0) ?? copy.funding[f.status];
12128
- const steps = FUNDING_STEPS[isFundingChain(f.chain) ? f.chain : "STELLAR"];
12386
+ const state = (f.route === "DIRECT" ? copy.fundingSolana[f.status] : void 0) ?? copy.funding[f.status];
12387
+ const steps = FUNDING_STEPS[f.route];
12129
12388
  const step = steps.indexOf(f.status) + 1;
12130
12389
  const inflight = FUNDING_INFLIGHT.has(f.status);
12131
12390
  return /* @__PURE__ */ jsxs("div", { className: "pollar-card-tx", "aria-busy": inflight, children: [
@@ -12177,6 +12436,7 @@ function CardModal({ onClose, initial }) {
12177
12436
  showManual && /* @__PURE__ */ jsx("p", { className: "pollar-card-note", children: /* @__PURE__ */ jsx("button", { type: "button", className: "pollar-card-link", onClick: () => setShowManual(false), children: copy.hideDeposit }) })
12178
12437
  ] }),
12179
12438
  error && /* @__PURE__ */ jsx("div", { className: "pollar-modal-error", children: error }),
12439
+ loadFailed && /* @__PURE__ */ jsx("div", { className: "pollar-modal-actions", children: /* @__PURE__ */ jsx("button", { type: "button", className: "pollar-btn-primary", onClick: retryLoad, children: copy.retry }) }),
12180
12440
  /* @__PURE__ */ jsx(PollarModalFooter, { language })
12181
12441
  ]
12182
12442
  }
@@ -13789,7 +14049,9 @@ var CONFIRM_COPY = {
13789
14049
  create_account: "Create account",
13790
14050
  invoke_contract: "Contract call",
13791
14051
  transfer: "Authorize payment",
13792
- manage_data: "Manage data"
14052
+ manage_data: "Manage data",
14053
+ earn_deposit: "Deposit",
14054
+ earn_withdraw: "Withdraw"
13793
14055
  }
13794
14056
  },
13795
14057
  es: {
@@ -13806,7 +14068,9 @@ var CONFIRM_COPY = {
13806
14068
  create_account: "Crear cuenta",
13807
14069
  invoke_contract: "Llamada a contrato",
13808
14070
  transfer: "Autorizar pago",
13809
- manage_data: "Gestionar datos"
14071
+ manage_data: "Gestionar datos",
14072
+ earn_deposit: "Depositar",
14073
+ earn_withdraw: "Retirar"
13810
14074
  }
13811
14075
  },
13812
14076
  pt: {
@@ -13823,7 +14087,9 @@ var CONFIRM_COPY = {
13823
14087
  create_account: "Criar conta",
13824
14088
  invoke_contract: "Chamada de contrato",
13825
14089
  transfer: "Autorizar pagamento",
13826
- manage_data: "Gerenciar dados"
14090
+ manage_data: "Gerenciar dados",
14091
+ earn_deposit: "Depositar",
14092
+ earn_withdraw: "Sacar"
13827
14093
  }
13828
14094
  }
13829
14095
  };
@@ -14717,6 +14983,10 @@ var browserRecoveryPasskey = {
14717
14983
  };
14718
14984
  }
14719
14985
  };
14986
+ function remembered(list) {
14987
+ rememberEarnOpportunities(list);
14988
+ return list;
14989
+ }
14720
14990
  var DEFAULT_APP_CONFIG = {
14721
14991
  application: { name: "", network: "testnet", chains: [] },
14722
14992
  styles: {}
@@ -15072,12 +15342,12 @@ function PollarProvider({
15072
15342
  },
15073
15343
  // earn
15074
15344
  getEarnProviders: () => pollarClient.getEarnProviders(),
15075
- getEarnOpportunities: (provider) => pollarClient.getEarnOpportunities(provider),
15345
+ getEarnOpportunities: (provider) => pollarClient.getEarnOpportunities(provider).then(remembered),
15076
15346
  getEarnPosition: (params) => pollarClient.getEarnPosition(params),
15077
15347
  earnDeposit: (params) => pollarClient.earnDeposit(params),
15078
15348
  earnWithdraw: (params) => pollarClient.earnWithdraw(params),
15079
15349
  getSolanaEarnProviders: () => pollarClient.getSolanaEarnProviders(),
15080
- getSolanaEarnOpportunities: () => pollarClient.getSolanaEarnOpportunities(),
15350
+ getSolanaEarnOpportunities: () => pollarClient.getSolanaEarnOpportunities().then(remembered),
15081
15351
  getSolanaEarnPosition: (opportunity) => pollarClient.getSolanaEarnPosition(opportunity),
15082
15352
  earnSolanaDeposit: (params) => pollarClient.earnSolanaDeposit(params),
15083
15353
  earnSolanaWithdraw: (params) => pollarClient.earnSolanaWithdraw(params),