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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import { AUTH_ERROR_CODES, rampLegTitle, rampRequirementCopy, rampTrustlineAsset, rampWalletStep, rampResolutionText, describeRampAction, rampLegStatus, rampNextApproval, rampOrderStopped, rampOrderReceive, countryName, rampRailLabel, rampNoRouteText, rampFieldError, rampFieldValid, rampLegNote, rampStepTitle, rampStepStatusText, rampLegTimeLeft, rampOrderResolutionText, rampCountries, rampQuoteFields, isPollarApiError, transactionErrorMessage, WalletType, bridgeSourceChains, bridgeTargetChains, isBridgeSettled, isPollarClient, PollarClient, isInteractiveAuthAdapter, isAuthEntryAdapterStep, completeAuthEntryStep, rampTrustlineErrorText, isPollarNetworkError, toBaseUnits, resolveLanguage, languageFromTag, localizedText, appUnavailableMessage, fromBaseUnits, cosignRefusalMessage, assertRampStellarSigner } from '@pollar/core';
2
+ import { AUTH_ERROR_CODES, authErrorMessage, 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.14"
1287
+ "0.12.1-rc.15"
1288
1288
  ] })
1289
1289
  ] });
1290
1290
  };
@@ -3635,7 +3635,7 @@ function LoginModalTemplate({
3635
3635
  const isLoading = status === "LOADING";
3636
3636
  const isEmailCodeError = authState.step === "error" && (authState.errorCode === AUTH_ERROR_CODES.EMAIL_CODE_EXPIRED || authState.errorCode === AUTH_ERROR_CODES.EMAIL_CODE_INVALID);
3637
3637
  const awaitingEmailCode = authState.step === "entering_code" || authState.step === "verifying_email_code" || isEmailCodeError;
3638
- const statusMessage = authState.step === "error" ? authState.message : copy.status[authState.step];
3638
+ const statusMessage = authState.step === "error" ? authErrorMessage(authState.code, language) ?? authState.message : copy.status[authState.step];
3639
3639
  const BackButton = ({ onClick }) => /* @__PURE__ */ jsx("button", { type: "button", className: "pollar-back-btn", onClick, "aria-label": copy.back, children: /* @__PURE__ */ jsx(
3640
3640
  "svg",
3641
3641
  {
@@ -5396,7 +5396,7 @@ var REGISTRATION_COPY = {
5396
5396
  fix: "Review my details",
5397
5397
  incomplete: "Your registration with the provider did not finish. Register again to complete it.",
5398
5398
  providerDown: "The provider is not responding right now. Please try again in a few minutes.",
5399
- ipNotSupported: "The provider cannot accept your current connection (IPv6). Please try again from another network, for example Wi-Fi.",
5399
+ ipNotSupported: "We could not verify your connection with the provider. Please try again in a few minutes.",
5400
5400
  emailTaken: "This email is already registered with the provider through another app. Use a different email to register here.",
5401
5401
  loadError: "Could not load the registration. Please try again.",
5402
5402
  submitError: "Could not register you. Please try again.",
@@ -5416,7 +5416,7 @@ var REGISTRATION_COPY = {
5416
5416
  fix: "Revisar mis datos",
5417
5417
  incomplete: "Tu registro con el proveedor no se complet\xF3. Reg\xEDstrate de nuevo para terminarlo.",
5418
5418
  providerDown: "El proveedor no responde en este momento. Intenta de nuevo en unos minutos.",
5419
- ipNotSupported: "El proveedor no acepta tu conexi\xF3n actual (IPv6). Intenta desde otra red, por ejemplo Wi-Fi.",
5419
+ ipNotSupported: "No pudimos verificar tu conexi\xF3n con el proveedor. Intenta de nuevo en unos minutos.",
5420
5420
  emailTaken: "Este email ya est\xE1 registrado con el proveedor desde otra app. Usa otro email para registrarte aqu\xED.",
5421
5421
  loadError: "No se pudo cargar el registro. Intenta de nuevo.",
5422
5422
  submitError: "No se pudo completar el registro. Intenta de nuevo.",
@@ -5436,7 +5436,7 @@ var REGISTRATION_COPY = {
5436
5436
  fix: "Revisar meus dados",
5437
5437
  incomplete: "Seu cadastro no provedor n\xE3o foi conclu\xEDdo. Cadastre-se novamente para termin\xE1-lo.",
5438
5438
  providerDown: "O provedor n\xE3o est\xE1 respondendo agora. Tente novamente em alguns minutos.",
5439
- ipNotSupported: "O provedor n\xE3o aceita sua conex\xE3o atual (IPv6). Tente de outra rede, por exemplo Wi-Fi.",
5439
+ ipNotSupported: "N\xE3o conseguimos verificar sua conex\xE3o com o provedor. Tente novamente em alguns minutos.",
5440
5440
  emailTaken: "Este email j\xE1 est\xE1 cadastrado no provedor por outro app. Use outro email para se cadastrar aqui.",
5441
5441
  loadError: "N\xE3o foi poss\xEDvel carregar o cadastro. Tente novamente.",
5442
5442
  submitError: "N\xE3o foi poss\xEDvel concluir o cadastro. Tente novamente.",
@@ -6102,11 +6102,16 @@ function RampWidget({ onClose, language: languageProp, initial }) {
6102
6102
  setErrorMsg((current) => current === shown ? null : current);
6103
6103
  }, [awaitingPayment]);
6104
6104
  const approval = order?.pendingAction?.kind === "COSIGN_APPROVAL" ? order.pendingAction.actionId : null;
6105
+ const approvalRequest = order?.pendingAction?.kind === "COSIGN_APPROVAL" ? order.pendingAction.cosignRequestId : null;
6105
6106
  useEffect(() => {
6106
6107
  if (!approval || promptedApproval.current === approval) return;
6107
6108
  promptedApproval.current = approval;
6108
- void client.cosign.pending().catch(() => void 0).then(() => openCosignModal());
6109
- }, [approval, client, openCosignModal]);
6109
+ void client.cosign.pending().catch(() => []).then(async (requests) => {
6110
+ const request = requests.find((r) => r.id === approvalRequest);
6111
+ if (request && await client.autoApproveSignIn(request)) return;
6112
+ openCosignModal();
6113
+ });
6114
+ }, [approval, approvalRequest, client, openCosignModal]);
6110
6115
  const nextApproval = step === "status" && order ? rampNextApproval(order, language) : null;
6111
6116
  useEffect(() => {
6112
6117
  setCosignNextStep(nextApproval);
@@ -7078,7 +7083,13 @@ var TX_REVIEW_COPY = {
7078
7083
  approve: (asset, spender) => `Allow ${spender} to use your ${asset}`,
7079
7084
  swap: (from, to) => `Swap ${from} for ${to}`,
7080
7085
  payment: (amount, to) => `Pay ${amount} to ${to}`,
7081
- createAccount: "Create an account"
7086
+ createAccount: "Create an account",
7087
+ signIn: "Confirm it's you"
7088
+ },
7089
+ signIn: {
7090
+ body: "The payment provider needs to confirm this account is yours before it can process your order.",
7091
+ noMoney: "No money moves",
7092
+ nothingSent: "Nothing is sent"
7082
7093
  },
7083
7094
  earn: {
7084
7095
  deposit: "Deposit",
@@ -7133,7 +7144,13 @@ var TX_REVIEW_COPY = {
7133
7144
  approve: (asset, spender) => `Permitir que ${spender} use tu ${asset}`,
7134
7145
  swap: (from, to) => `Cambiar ${from} por ${to}`,
7135
7146
  payment: (amount, to) => `Pagar ${amount} a ${to}`,
7136
- createAccount: "Crear una cuenta"
7147
+ createAccount: "Crear una cuenta",
7148
+ signIn: "Confirma que eres t\xFA"
7149
+ },
7150
+ signIn: {
7151
+ body: "El proveedor de pagos necesita confirmar que esta cuenta es tuya antes de procesar tu orden.",
7152
+ noMoney: "No se mueve dinero",
7153
+ nothingSent: "No se env\xEDa nada"
7137
7154
  },
7138
7155
  earn: {
7139
7156
  deposit: "Depositar",
@@ -7188,7 +7205,13 @@ var TX_REVIEW_COPY = {
7188
7205
  approve: (asset, spender) => `Permitir que ${spender} use seu ${asset}`,
7189
7206
  swap: (from, to) => `Trocar ${from} por ${to}`,
7190
7207
  payment: (amount, to) => `Pagar ${amount} para ${to}`,
7191
- createAccount: "Criar uma conta"
7208
+ createAccount: "Criar uma conta",
7209
+ signIn: "Confirme que \xE9 voc\xEA"
7210
+ },
7211
+ signIn: {
7212
+ body: "O provedor de pagamentos precisa confirmar que esta conta \xE9 sua antes de processar seu pedido.",
7213
+ noMoney: "Nenhum dinheiro se move",
7214
+ nothingSent: "Nada \xE9 enviado"
7192
7215
  },
7193
7216
  earn: {
7194
7217
  deposit: "Depositar",
@@ -7269,6 +7292,8 @@ function titleOf(data, fallback, copy) {
7269
7292
  return from?.amount && to?.label ? copy.titles.payment(withAsset(from), displayName(to.label)) : fallback;
7270
7293
  case "create_account":
7271
7294
  return copy.titles.createAccount;
7295
+ case "sign_in":
7296
+ return copy.titles.signIn;
7272
7297
  default:
7273
7298
  return fallback;
7274
7299
  }
@@ -7354,6 +7379,23 @@ function earnOutcome(parts, copy) {
7354
7379
  }
7355
7380
  return parts.name ? copy.earn.withdrew(moved, parts.name, chain) : copy.earn.withdrewOn(moved, chain);
7356
7381
  }
7382
+ function isSignIn(operation, details) {
7383
+ return operation === "provider_sign_in" || operation === "sep10" || details.purpose === "sign_in";
7384
+ }
7385
+ function reviewForSignIn(parts, copy) {
7386
+ const rows = [
7387
+ { label: copy.rows.network, value: [copy.chains[parts.chain], parts.network].filter(Boolean).join(" ") }
7388
+ ];
7389
+ if (parts.signWith) rows.push({ label: copy.yourWallet, value: shortAddress(parts.signWith), copyValue: parts.signWith });
7390
+ rows.push(...parts.extraRows ?? []);
7391
+ return {
7392
+ kind: "sign_in",
7393
+ title: copy.titles.signIn,
7394
+ rows,
7395
+ ...parts.raw ? { raw: parts.raw } : {},
7396
+ ...parts.hash ? { hash: parts.hash } : {}
7397
+ };
7398
+ }
7357
7399
  function reviewFromRequest(parts, copy) {
7358
7400
  const details = parts.details ?? {};
7359
7401
  const earnAction = parts.operation === "earn_deposit" ? "deposit" : parts.operation === "earn_withdraw" ? "withdraw" : null;
@@ -7379,6 +7421,7 @@ function reviewFromRequest(parts, copy) {
7379
7421
  copy
7380
7422
  );
7381
7423
  }
7424
+ if (isSignIn(parts.operation, details)) return reviewForSignIn(parts, copy);
7382
7425
  const flow = rampFlow(details);
7383
7426
  const rows = [];
7384
7427
  let data;
@@ -7573,6 +7616,30 @@ function ContractGlyph() {
7573
7616
  /* @__PURE__ */ jsx("path", { d: "M7 9V6.75a3 3 0 0 1 6 0V9", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round" })
7574
7617
  ] }) });
7575
7618
  }
7619
+ function SignInGlyph() {
7620
+ return /* @__PURE__ */ jsx("span", { className: "pollar-txr-signin-glyph", "aria-hidden": true, children: /* @__PURE__ */ jsxs("svg", { width: "26", height: "26", viewBox: "0 0 24 24", fill: "none", children: [
7621
+ /* @__PURE__ */ jsx(
7622
+ "path",
7623
+ {
7624
+ d: "M12 2.75 4.75 5.5v5.25c0 4.6 3.05 8.55 7.25 10 4.2-1.45 7.25-5.4 7.25-10V5.5L12 2.75Z",
7625
+ stroke: "currentColor",
7626
+ strokeWidth: "1.6",
7627
+ strokeLinejoin: "round"
7628
+ }
7629
+ ),
7630
+ /* @__PURE__ */ jsx("circle", { cx: "12", cy: "10", r: "2.25", stroke: "currentColor", strokeWidth: "1.6" }),
7631
+ /* @__PURE__ */ jsx("path", { d: "M12 12.25v3.5M12 14.25h1.75", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round" })
7632
+ ] }) });
7633
+ }
7634
+ function Assurance({ text }) {
7635
+ return /* @__PURE__ */ jsxs("li", { className: "pollar-txr-assurance", children: [
7636
+ /* @__PURE__ */ jsxs("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", "aria-hidden": true, children: [
7637
+ /* @__PURE__ */ jsx("circle", { cx: "7", cy: "7", r: "7", fill: "currentColor" }),
7638
+ /* @__PURE__ */ jsx("path", { d: "M3.5 7l2.5 2.5 4.5-5", stroke: "white", strokeWidth: "1.4", strokeLinecap: "round", strokeLinejoin: "round" })
7639
+ ] }),
7640
+ text
7641
+ ] });
7642
+ }
7576
7643
  function Node2({
7577
7644
  party,
7578
7645
  showAmount,
@@ -7644,6 +7711,14 @@ function TxReview({ data, open: openProp, onToggle, language: languageProp }) {
7644
7711
  /* @__PURE__ */ jsx(Node2, { party: to, showAmount: kind !== "approve" && toShowsAmount, glyph: toGlyph, copy })
7645
7712
  ] }),
7646
7713
  kind === "approve" && /* @__PURE__ */ jsx("p", { className: "pollar-txr-note", children: copy.approveNote }),
7714
+ kind === "sign_in" && /* @__PURE__ */ jsxs("div", { className: "pollar-txr-signin", children: [
7715
+ /* @__PURE__ */ jsx(SignInGlyph, {}),
7716
+ /* @__PURE__ */ jsx("p", { className: "pollar-txr-signin-body", children: copy.signIn.body }),
7717
+ /* @__PURE__ */ jsxs("ul", { className: "pollar-txr-assurances", children: [
7718
+ /* @__PURE__ */ jsx(Assurance, { text: copy.signIn.noMoney }),
7719
+ /* @__PURE__ */ jsx(Assurance, { text: copy.signIn.nothingSent })
7720
+ ] })
7721
+ ] }),
7647
7722
  /* @__PURE__ */ jsxs("div", { className: "pollar-txr-bar", children: [
7648
7723
  data.fee?.sponsored !== void 0 ? /* @__PURE__ */ jsx(FeeBadge, { sponsored: data.fee.sponsored, copy }) : /* @__PURE__ */ jsx("span", {}),
7649
7724
  /* @__PURE__ */ jsxs("button", { type: "button", className: "pollar-txr-toggle", "aria-expanded": open, onClick: toggle, children: [
@@ -11169,7 +11244,7 @@ var CARD_COPY = {
11169
11244
  },
11170
11245
  errors: {
11171
11246
  SDK_CARDS_PROVIDER_ERROR: "The card provider is not responding right now. Please try again in a few minutes.",
11172
- SDK_CARDS_IP_NOT_SUPPORTED: "The card provider cannot accept your current connection (IPv6). Please try again from another network, for example Wi-Fi.",
11247
+ SDK_CARDS_IP_NOT_SUPPORTED: "We could not verify your connection with the card provider. Please try again in a few minutes.",
11173
11248
  SDK_CARDS_PROVIDER_USER_TAKEN: "This email is already registered with the card provider through another app. Use a different email to get a card here."
11174
11249
  },
11175
11250
  blocked: {
@@ -11339,7 +11414,7 @@ var CARD_COPY = {
11339
11414
  },
11340
11415
  errors: {
11341
11416
  SDK_CARDS_PROVIDER_ERROR: "El proveedor de la tarjeta no responde en este momento. Intenta de nuevo en unos minutos.",
11342
- SDK_CARDS_IP_NOT_SUPPORTED: "El proveedor de la tarjeta no acepta tu conexi\xF3n actual (IPv6). Intenta de nuevo desde otra red, por ejemplo Wi-Fi.",
11417
+ SDK_CARDS_IP_NOT_SUPPORTED: "No pudimos verificar tu conexi\xF3n con el proveedor de la tarjeta. Intenta de nuevo en unos minutos.",
11343
11418
  SDK_CARDS_PROVIDER_USER_TAKEN: "Este correo ya est\xE1 registrado con el proveedor de la tarjeta a trav\xE9s de otra app. Usa otro correo para obtener una tarjeta aqu\xED."
11344
11419
  },
11345
11420
  blocked: {
@@ -11509,7 +11584,7 @@ var CARD_COPY = {
11509
11584
  },
11510
11585
  errors: {
11511
11586
  SDK_CARDS_PROVIDER_ERROR: "O provedor do cart\xE3o n\xE3o est\xE1 respondendo agora. Tente de novo em alguns minutos.",
11512
- SDK_CARDS_IP_NOT_SUPPORTED: "O provedor do cart\xE3o n\xE3o aceita sua conex\xE3o atual (IPv6). Tente de novo a partir de outra rede, por exemplo Wi-Fi.",
11587
+ SDK_CARDS_IP_NOT_SUPPORTED: "N\xE3o conseguimos verificar sua conex\xE3o com o provedor do cart\xE3o. Tente de novo em alguns minutos.",
11513
11588
  SDK_CARDS_PROVIDER_USER_TAKEN: "Este e-mail j\xE1 est\xE1 cadastrado no provedor do cart\xE3o por meio de outro app. Use outro e-mail para obter um cart\xE3o aqui."
11514
11589
  },
11515
11590
  blocked: {
@@ -12835,8 +12910,8 @@ var COSIGN_COPY = {
12835
12910
  expired: "expired",
12836
12911
  expiresIn: "Expires in",
12837
12912
  checking: "Checking...",
12838
- verified: "Verified",
12839
- checkedAgainstTurnkey: "Checked against Turnkey: this is exactly what will be signed.",
12913
+ verified: "Checked",
12914
+ checkedExact: "We checked this is exactly what you're approving.",
12840
12915
  notVerified: "Not verified:",
12841
12916
  reject: "Reject",
12842
12917
  rejecting: "Rejecting...",
@@ -12860,7 +12935,9 @@ var COSIGN_COPY = {
12860
12935
  swap: "Swap",
12861
12936
  earn_deposit: "Deposit",
12862
12937
  earn_withdraw: "Withdraw",
12863
- evm_delegation: "Enable atomic transactions"
12938
+ evm_delegation: "Enable atomic transactions",
12939
+ provider_sign_in: "Confirm it's you",
12940
+ sep10: "Confirm it's you"
12864
12941
  }
12865
12942
  },
12866
12943
  es: {
@@ -12880,8 +12957,8 @@ var COSIGN_COPY = {
12880
12957
  expired: "vencida",
12881
12958
  expiresIn: "Vence en",
12882
12959
  checking: "Verificando...",
12883
- verified: "Verificada",
12884
- checkedAgainstTurnkey: "Verificada con Turnkey: esto es exactamente lo que se firmar\xE1.",
12960
+ verified: "Comprobada",
12961
+ checkedExact: "Comprobamos que esto es exactamente lo que est\xE1s aprobando.",
12885
12962
  notVerified: "Sin verificar:",
12886
12963
  reject: "Rechazar",
12887
12964
  rejecting: "Rechazando...",
@@ -12905,7 +12982,9 @@ var COSIGN_COPY = {
12905
12982
  swap: "Intercambiar",
12906
12983
  earn_deposit: "Depositar",
12907
12984
  earn_withdraw: "Retirar",
12908
- evm_delegation: "Activar transacciones at\xF3micas"
12985
+ evm_delegation: "Activar transacciones at\xF3micas",
12986
+ provider_sign_in: "Confirma que eres t\xFA",
12987
+ sep10: "Confirma que eres t\xFA"
12909
12988
  }
12910
12989
  },
12911
12990
  pt: {
@@ -12925,8 +13004,8 @@ var COSIGN_COPY = {
12925
13004
  expired: "expirada",
12926
13005
  expiresIn: "Expira em",
12927
13006
  checking: "Verificando...",
12928
- verified: "Verificada",
12929
- checkedAgainstTurnkey: "Conferida com a Turnkey: isto \xE9 exatamente o que ser\xE1 assinado.",
13007
+ verified: "Conferida",
13008
+ checkedExact: "Conferimos que isto \xE9 exatamente o que voc\xEA est\xE1 aprovando.",
12930
13009
  notVerified: "N\xE3o verificada:",
12931
13010
  reject: "Rejeitar",
12932
13011
  rejecting: "Rejeitando...",
@@ -12950,7 +13029,9 @@ var COSIGN_COPY = {
12950
13029
  swap: "Trocar",
12951
13030
  earn_deposit: "Depositar",
12952
13031
  earn_withdraw: "Sacar",
12953
- evm_delegation: "Ativar transa\xE7\xF5es at\xF4micas"
13032
+ evm_delegation: "Ativar transa\xE7\xF5es at\xF4micas",
13033
+ provider_sign_in: "Confirme que \xE9 voc\xEA",
13034
+ sep10: "Confirme que \xE9 voc\xEA"
12954
13035
  }
12955
13036
  }
12956
13037
  };
@@ -13104,7 +13185,7 @@ function CosignModalTemplate({
13104
13185
  )
13105
13186
  ] }),
13106
13187
  /* @__PURE__ */ jsx(TxReview, { data: review, language }, current.id),
13107
- verified && verifiedOpen && /* @__PURE__ */ jsx("div", { className: "pollar-cosign-verify pollar-cosign-verify-ok", children: copy.checkedAgainstTurnkey }),
13188
+ verified && verifiedOpen && /* @__PURE__ */ jsx("div", { className: "pollar-cosign-verify pollar-cosign-verify-ok", children: copy.checkedExact }),
13108
13189
  deviceNotLinked ? /* @__PURE__ */ jsxs("div", { className: "pollar-cosign-verify pollar-cosign-verify-bad", children: [
13109
13190
  copy.deviceNotLinked,
13110
13191
  onLinkDevice && /* @__PURE__ */ jsx("button", { type: "button", className: "pollar-cosign-link", onClick: onLinkDevice, children: copy.linkDevice })