@pollar/react 0.5.0 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -9,7 +9,6 @@ var jsxRuntime = require('react/jsx-runtime');
9
9
 
10
10
  // src/constants.ts
11
11
  var LOGO_POLLAR = "https://pollar.xyz/assets/logo_pollar.png";
12
- var LOGO_GITHUB = "https://pollar.xyz/assets/GitHub_Invertocat_White.png";
13
12
  var LOGO_FREIGHTER = "https://pollar.xyz/assets/logo_freighter.png";
14
13
  var LOGO_ALBEDO = "https://pollar.xyz/assets/logo_albedo.svg";
15
14
  var ModalErrorBoundary = class extends react.Component {
@@ -39,7 +38,7 @@ var PollarModalFooter = () => {
39
38
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-footer-name", children: "Pollar" }),
40
39
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-footer-version", children: [
41
40
  "v",
42
- "0.4.5"
41
+ "0.5.3"
43
42
  ] })
44
43
  ] })
45
44
  ] });
@@ -55,7 +54,7 @@ function ModalStatusBanner({ message, status, onCancel, onRetry }) {
55
54
  ] }) : status === "SUCCESS" ? /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", "aria-hidden": true, children: [
56
55
  /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "7", cy: "7", r: "7", fill: "currentColor" }),
57
56
  /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M3.5 7l2.5 2.5 4.5-5", stroke: "white", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })
58
- ] }) : status === "LOADING" ? /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "7", cy: "7", r: "5.5", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeDasharray: "22 10" }) }) : null;
57
+ ] }) : status === "LOADING" ? /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {}) : null;
59
58
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-status", "data-kind": status, children: [
60
59
  icon,
61
60
  /* @__PURE__ */ jsxRuntime.jsx("span", { children: message }),
@@ -99,15 +98,25 @@ function KycModalTemplate({
99
98
  const isDark = theme === "dark";
100
99
  const cssVars = {
101
100
  "--pollar-accent": accentColor,
102
- "--pollar-buttons-border-radius": "6px",
103
- "--pollar-buttons-height": "44px",
104
101
  "--pollar-bg": isDark ? "#1a1a1a" : "#ffffff",
105
102
  "--pollar-border": isDark ? "#374151" : "#e5e7eb",
106
103
  "--pollar-text": isDark ? "#ffffff" : "#111827",
107
104
  "--pollar-muted": isDark ? "#9ca3af" : "#6b7280",
108
- "--pollar-input-bg": isDark ? "#374151" : "#f9fafb"
105
+ "--pollar-input-bg": isDark ? "#374151" : "#f9fafb",
106
+ "--pollar-error-bg": isDark ? "#2a1515" : "#fef2f2",
107
+ "--pollar-error-border": isDark ? "#7f1d1d" : "#fecaca",
108
+ "--pollar-error-text": isDark ? "#f87171" : "#dc2626",
109
+ "--pollar-success-text": isDark ? "#4ade80" : "#16a34a",
110
+ "--pollar-buttons-border-radius": "6px",
111
+ "--pollar-buttons-height": "44px",
112
+ "--pollar-input-height": "44px",
113
+ "--pollar-input-border-radius": "0.5rem",
114
+ "--pollar-card-border-radius": "10px",
115
+ "--pollar-modal-padding": "2rem",
116
+ "--pollar-modal-heading-size": "1.375rem",
117
+ "--pollar-modal-subtitle-size": "0.9rem"
109
118
  };
110
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-kyc-modal", style: cssVars, onClick: (e) => e.stopPropagation(), children: [
119
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-card pollar-kyc-modal", style: cssVars, onClick: (e) => e.stopPropagation(), children: [
111
120
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-kyc-header", children: [
112
121
  /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "pollar-kyc-title", children: "Identity verification" }),
113
122
  /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "pollar-kyc-subtitle", children: [
@@ -266,8 +275,8 @@ function EmailCodeInput({ email, onSubmit }) {
266
275
  }
267
276
  var GithubButton = ({ disabled, onClick }) => {
268
277
  return /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "github-button", disabled, onClick, children: [
269
- /* @__PURE__ */ jsxRuntime.jsx("img", { src: LOGO_GITHUB, alt: "GitHub", className: "github-button-icon" }),
270
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "github-button-contents", children: "Continue with GitHub" })
278
+ /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "github-button-icon", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { fillRule: "evenodd", d: "M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z", clipRule: "evenodd" }) }),
279
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "github-button-contents", children: "GitHub" })
271
280
  ] });
272
281
  };
273
282
  var GoogleButton = ({ disabled, onClick }) => {
@@ -314,8 +323,8 @@ var GoogleButton = ({ disabled, onClick }) => {
314
323
  ]
315
324
  }
316
325
  ) }),
317
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "gsi-material-button-contents", children: "Continue with Google" }),
318
- /* @__PURE__ */ jsxRuntime.jsx("span", { style: { display: "none" }, children: "Continue with Google" })
326
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "gsi-material-button-contents", children: "Google" }),
327
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: { display: "none" }, children: "Google" })
319
328
  ] })
320
329
  ] });
321
330
  };
@@ -372,36 +381,76 @@ function LoginModalTemplate({
372
381
  onCancel,
373
382
  onRetry
374
383
  }) {
384
+ const [showWalletPicker, setShowWalletPicker] = react.useState(false);
375
385
  const isDark = theme === "dark";
376
386
  const enabledSocial = Object.entries(providers).filter(([, enabled]) => enabled);
377
387
  const cssVars = {
378
388
  "--pollar-accent": accentColor,
379
- "--pollar-buttons-border-radius": "6px",
380
- "--pollar-buttons-height": "44px",
381
389
  "--pollar-bg": isDark ? "#1a1a1a" : "#ffffff",
382
390
  "--pollar-border": isDark ? "#374151" : "#e5e7eb",
383
391
  "--pollar-text": isDark ? "#ffffff" : "#111827",
384
392
  "--pollar-muted": isDark ? "#9ca3af" : "#6b7280",
385
- "--pollar-input-bg": isDark ? "#374151" : "#ffffff",
393
+ "--pollar-input-bg": isDark ? "#374151" : "#f9fafb",
386
394
  "--pollar-error-bg": isDark ? "#2a1515" : "#fef2f2",
387
395
  "--pollar-error-border": isDark ? "#7f1d1d" : "#fecaca",
388
- "--pollar-error-text": isDark ? "#f87171" : "#dc2626"
396
+ "--pollar-error-text": isDark ? "#f87171" : "#dc2626",
397
+ "--pollar-success-text": isDark ? "#4ade80" : "#16a34a",
398
+ "--pollar-buttons-border-radius": "6px",
399
+ "--pollar-buttons-height": "44px",
400
+ "--pollar-input-height": "44px",
401
+ "--pollar-input-border-radius": "0.5rem",
402
+ "--pollar-card-border-radius": "10px",
403
+ "--pollar-modal-padding": "2rem",
404
+ "--pollar-modal-heading-size": "1.375rem",
405
+ "--pollar-modal-subtitle-size": "0.9rem"
389
406
  };
390
407
  const status = authStateToStatus(authState.step);
391
408
  const isLoading = status === "LOADING";
392
409
  const isEmailCodeError = authState.step === "error" && (authState.errorCode === core.AUTH_ERROR_CODES.EMAIL_CODE_EXPIRED || authState.errorCode === core.AUTH_ERROR_CODES.EMAIL_CODE_INVALID);
393
410
  const awaitingEmailCode = authState.step === "entering_code" || authState.step === "verifying_email_code" || isEmailCodeError;
394
411
  const statusMessage = authState.step === "error" ? authState.message : AUTH_STATE_MESSAGES[authState.step];
395
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal", style: cssVars, onClick: (e) => e.stopPropagation(), children: [
412
+ const BackButton = ({ onClick }) => /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-back-btn", onClick, "aria-label": "Back", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M15 19l-7-7 7-7" }) }) });
413
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-card pollar-modal", style: cssVars, onClick: (e) => e.stopPropagation(), children: [
414
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-close-btn", onClick: onCancel, "aria-label": "Close", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M18 6L6 18M6 6l12 12" }) }) }),
396
415
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-header", children: [
397
416
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-logo-wrap", children: /* @__PURE__ */ jsxRuntime.jsx("img", { src: logoUrl ?? LOGO_POLLAR, alt: "Logo", className: "pollar-logo" }) }),
398
417
  /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "pollar-title", children: appName }),
399
418
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-subtitle", children: "Log in or sign up" })
400
419
  ] }),
401
420
  awaitingEmailCode ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
402
- /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-back-btn", onClick: onBack, children: "\u2190 Back" }),
421
+ /* @__PURE__ */ jsxRuntime.jsx(BackButton, { onClick: onBack }),
403
422
  /* @__PURE__ */ jsxRuntime.jsx(EmailCodeInput, { email, onSubmit: onCodeSubmit ?? (() => {
404
423
  }) }, codeInputKey)
424
+ ] }) : showWalletPicker ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
425
+ /* @__PURE__ */ jsxRuntime.jsx(BackButton, { onClick: () => setShowWalletPicker(false) }),
426
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-wallet-list", children: [
427
+ /* @__PURE__ */ jsxRuntime.jsxs(
428
+ "button",
429
+ {
430
+ type: "button",
431
+ disabled: isLoading,
432
+ className: "pollar-wallet-list-btn",
433
+ onClick: onFreighterConnect,
434
+ children: [
435
+ /* @__PURE__ */ jsxRuntime.jsx("img", { src: LOGO_FREIGHTER, alt: "Freighter", className: "pollar-wallet-list-icon" }),
436
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-wallet-list-name", children: "Freighter" })
437
+ ]
438
+ }
439
+ ),
440
+ /* @__PURE__ */ jsxRuntime.jsxs(
441
+ "button",
442
+ {
443
+ type: "button",
444
+ disabled: isLoading,
445
+ className: "pollar-wallet-list-btn",
446
+ onClick: onAlbedoConnect,
447
+ children: [
448
+ /* @__PURE__ */ jsxRuntime.jsx("img", { src: LOGO_ALBEDO, alt: "Albedo", className: "pollar-wallet-list-icon" }),
449
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-wallet-list-name", children: "Albedo" })
450
+ ]
451
+ }
452
+ )
453
+ ] })
405
454
  ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
406
455
  emailEnabled && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-email-section", children: [
407
456
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -416,7 +465,7 @@ function LoginModalTemplate({
416
465
  onKeyDown: (e) => e.key === "Enter" && onEmailSubmit?.()
417
466
  }
418
467
  ),
419
- /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", disabled: isLoading || !email, className: "pollar-submit-btn", onClick: onEmailSubmit, children: "Submit" })
468
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", disabled: isLoading || !email, className: "pollar-btn-primary", style: { marginTop: "0.75rem", width: "100%" }, onClick: onEmailSubmit, children: "Submit" })
420
469
  ] }),
421
470
  emailEnabled && enabledSocial.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-divider", children: [
422
471
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-divider-line" }),
@@ -426,17 +475,19 @@ function LoginModalTemplate({
426
475
  enabledSocial.some(([key]) => key === "google") && /* @__PURE__ */ jsxRuntime.jsx(GoogleButton, { disabled: isLoading, onClick: () => onSocialLogin?.("google") }),
427
476
  enabledSocial.some(([key]) => key === "github") && /* @__PURE__ */ jsxRuntime.jsx(GithubButton, { disabled: isLoading, onClick: () => onSocialLogin?.("github") })
428
477
  ] }),
429
- embeddedWallets && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-wallet-section", children: [
430
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-wallet-label", children: "Continue with a wallet" }),
431
- /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", disabled: isLoading, className: "pollar-wallet-btn", onClick: onFreighterConnect, children: [
432
- /* @__PURE__ */ jsxRuntime.jsx("img", { src: LOGO_FREIGHTER, alt: "Freighter", className: "pollar-wallet-icon" }),
433
- "Freighter"
434
- ] }),
435
- /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", disabled: isLoading, className: "pollar-wallet-btn", onClick: onAlbedoConnect, children: [
436
- /* @__PURE__ */ jsxRuntime.jsx("img", { src: LOGO_ALBEDO, alt: "Albedo", className: "pollar-wallet-icon" }),
437
- "Albedo"
438
- ] })
439
- ] })
478
+ embeddedWallets && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-wallet-section", children: /* @__PURE__ */ jsxRuntime.jsxs(
479
+ "button",
480
+ {
481
+ type: "button",
482
+ disabled: isLoading,
483
+ className: "pollar-wallet-entry-btn",
484
+ onClick: () => setShowWalletPicker(true),
485
+ children: [
486
+ /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "18", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M3 10h18M7 15h1m4 0h1m-7 4h12a3 3 0 003-3V8a3 3 0 00-3-3H6a3 3 0 00-3 3v8a3 3 0 003 3z" }) }),
487
+ "Wallet"
488
+ ]
489
+ }
490
+ ) })
440
491
  ] }),
441
492
  /* @__PURE__ */ jsxRuntime.jsx(
442
493
  ModalStatusBanner,
@@ -527,7 +578,7 @@ function LoginModal({ onClose }) {
527
578
  codeInputKey,
528
579
  onCodeSubmit: handleVerifyCode,
529
580
  onBack: handleBack,
530
- onCancel: () => getClient().cancelLogin(),
581
+ onCancel: handleClose,
531
582
  onRetry: handleRetry
532
583
  }
533
584
  ) });
@@ -602,13 +653,23 @@ function RampWidgetTemplate({
602
653
  const isDark = theme === "dark";
603
654
  const cssVars = {
604
655
  "--pollar-accent": accentColor,
605
- "--pollar-buttons-border-radius": "6px",
606
- "--pollar-buttons-height": "44px",
607
656
  "--pollar-bg": isDark ? "#1a1a1a" : "#ffffff",
608
657
  "--pollar-border": isDark ? "#374151" : "#e5e7eb",
609
658
  "--pollar-text": isDark ? "#ffffff" : "#111827",
610
659
  "--pollar-muted": isDark ? "#9ca3af" : "#6b7280",
611
- "--pollar-input-bg": isDark ? "#374151" : "#f9fafb"
660
+ "--pollar-input-bg": isDark ? "#374151" : "#f9fafb",
661
+ "--pollar-error-bg": isDark ? "#2a1515" : "#fef2f2",
662
+ "--pollar-error-border": isDark ? "#7f1d1d" : "#fecaca",
663
+ "--pollar-error-text": isDark ? "#f87171" : "#dc2626",
664
+ "--pollar-success-text": isDark ? "#4ade80" : "#16a34a",
665
+ "--pollar-buttons-border-radius": "6px",
666
+ "--pollar-buttons-height": "44px",
667
+ "--pollar-input-height": "44px",
668
+ "--pollar-input-border-radius": "0.5rem",
669
+ "--pollar-card-border-radius": "10px",
670
+ "--pollar-modal-padding": "2rem",
671
+ "--pollar-modal-heading-size": "1.375rem",
672
+ "--pollar-modal-subtitle-size": "0.9rem"
612
673
  };
613
674
  const stepTitle = {
614
675
  input: direction === "onramp" ? "Buy crypto" : "Sell crypto",
@@ -622,7 +683,7 @@ function RampWidgetTemplate({
622
683
  select_route: "All prices include fees",
623
684
  payment_instructions: "Send the exact amount to complete your transaction"
624
685
  };
625
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-modal", style: cssVars, onClick: (e) => e.stopPropagation(), children: [
686
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-card pollar-ramp-modal", style: cssVars, onClick: (e) => e.stopPropagation(), children: [
626
687
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-header", children: [
627
688
  /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "pollar-ramp-title", children: stepTitle[step] }),
628
689
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-subtitle", children: stepSubtitle[step] })
@@ -836,28 +897,46 @@ function RampWidget({ onClose }) {
836
897
  }
837
898
  ) });
838
899
  }
900
+ var STATUS_MESSAGES = {
901
+ idle: "",
902
+ building: "Building transaction\u2026",
903
+ built: "Ready to sign and send",
904
+ signing: "Signing and sending transaction\u2026",
905
+ success: "Transaction sent successfully",
906
+ error: "Transaction failed"
907
+ };
839
908
  function TransactionModalTemplate({
840
909
  theme,
841
910
  accentColor,
842
911
  transaction,
912
+ showXdr,
913
+ copied,
914
+ explorerUrl,
915
+ walletType,
843
916
  onClose,
844
- onSignAndSend
917
+ onSignAndSend,
918
+ onToggleXdr,
919
+ onCopyHash,
920
+ onRetry
845
921
  }) {
846
922
  const isDark = theme === "dark";
847
923
  const cssVars = {
848
924
  "--pollar-accent": accentColor,
849
- "--pollar-buttons-border-radius": "8px",
850
- "--pollar-buttons-height": "44px",
851
925
  "--pollar-bg": isDark ? "#1a1a1a" : "#ffffff",
852
926
  "--pollar-border": isDark ? "#374151" : "#e5e7eb",
853
927
  "--pollar-text": isDark ? "#ffffff" : "#111827",
854
928
  "--pollar-muted": isDark ? "#9ca3af" : "#6b7280",
855
- "--pollar-input-bg": isDark ? "#374151" : "rgba(0,0,0,0.04)",
929
+ "--pollar-input-bg": isDark ? "#374151" : "#f9fafb",
930
+ "--pollar-error-bg": isDark ? "#2a1515" : "#fef2f2",
931
+ "--pollar-error-border": isDark ? "#7f1d1d" : "#fecaca",
856
932
  "--pollar-error-text": isDark ? "#f87171" : "#dc2626",
857
- "--pollar-success-text": isDark ? "#4ade80" : "#16a34a"
933
+ "--pollar-success-text": isDark ? "#4ade80" : "#16a34a",
934
+ "--pollar-buttons-border-radius": "6px",
935
+ "--pollar-buttons-height": "44px",
936
+ "--pollar-input-height": "44px",
937
+ "--pollar-input-border-radius": "0.5rem",
938
+ "--pollar-card-border-radius": "10px"
858
939
  };
859
- const [showXdr, setShowXdr] = react.useState(false);
860
- const [copied, setCopied] = react.useState(false);
861
940
  const buildData = "buildData" in transaction ? transaction.buildData : null;
862
941
  const hash = transaction.step === "success" ? transaction.hash : null;
863
942
  const errorDetails = transaction.step === "error" ? transaction.details ?? null : null;
@@ -866,28 +945,23 @@ function TransactionModalTemplate({
866
945
  const isSuccess = transaction.step === "success";
867
946
  const isError = transaction.step === "error";
868
947
  const showDetails = buildData !== null && (isBuilt || isSigning || isSuccess);
869
- const explorerNetwork = buildData?.summary.network?.toLowerCase().includes("testnet") ? "testnet" : "public";
870
- const explorerUrl = hash ? `https://stellar.expert/explorer/${explorerNetwork}/tx/${hash}` : null;
871
- function handleCopyHash() {
872
- if (!hash) return;
873
- navigator.clipboard.writeText(hash).then(() => {
874
- setCopied(true);
875
- setTimeout(() => setCopied(false), 2e3);
876
- });
877
- }
878
- const statusMessage = {
879
- idle: "",
880
- building: "Building transaction\u2026",
881
- built: "Ready to sign and send",
882
- signing: "Signing and sending transaction\u2026",
883
- success: "Transaction sent successfully",
884
- error: "Transaction failed"
885
- };
886
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-tx-modal", "data-theme": theme, style: cssVars, onClick: (e) => e.stopPropagation(), children: [
887
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-header", children: [
888
- /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "pollar-modal-title", children: "Transaction" }),
889
- /* @__PURE__ */ jsxRuntime.jsx("button", { className: "pollar-modal-close", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M2 2l12 12M14 2L2 14", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) })
890
- ] }),
948
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-card pollar-tx-modal", "data-theme": theme, style: cssVars, onClick: (e) => e.stopPropagation(), children: [
949
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-header", children: /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "pollar-modal-title", children: "Transaction" }) }),
950
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-close-btn", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsxRuntime.jsx(
951
+ "svg",
952
+ {
953
+ width: "18",
954
+ height: "18",
955
+ viewBox: "0 0 24 24",
956
+ fill: "none",
957
+ stroke: "currentColor",
958
+ strokeWidth: "2.5",
959
+ strokeLinecap: "round",
960
+ strokeLinejoin: "round",
961
+ "aria-hidden": true,
962
+ children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M18 6L6 18M6 6l12 12" })
963
+ }
964
+ ) }),
891
965
  showDetails && buildData && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
892
966
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-tx-summary", children: [
893
967
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-tx-summary-title", children: "Details" }),
@@ -904,7 +978,7 @@ function TransactionModalTemplate({
904
978
  ] })
905
979
  ] }),
906
980
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-tx-xdr", children: [
907
- /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "pollar-tx-xdr-toggle", onClick: () => setShowXdr((v) => !v), children: [
981
+ /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "pollar-tx-xdr-toggle", onClick: onToggleXdr, children: [
908
982
  /* @__PURE__ */ jsxRuntime.jsx(
909
983
  "svg",
910
984
  {
@@ -922,48 +996,147 @@ function TransactionModalTemplate({
922
996
  showXdr && /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "pollar-tx-xdr-content", children: buildData.unsignedXdr })
923
997
  ] })
924
998
  ] }),
999
+ isError && errorDetails && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-tx-error-details", children: [
1000
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-tx-error-details-label", children: "Error details" }),
1001
+ /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "pollar-tx-error-details-content", children: errorDetails })
1002
+ ] }),
1003
+ isBuilt && /* @__PURE__ */ jsxRuntime.jsx("button", { className: "pollar-btn-primary pollar-tx-sign-btn", onClick: onSignAndSend, children: "Sign & Send" }),
1004
+ (isSigning || isSuccess || isError) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-tx-wallet-spinner", children: [
1005
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-tx-spinner-ring", children: [
1006
+ /* @__PURE__ */ jsxRuntime.jsxs(
1007
+ "svg",
1008
+ {
1009
+ viewBox: "0 0 88 88",
1010
+ width: "88",
1011
+ height: "88",
1012
+ className: `pollar-tx-spinner-svg${isSigning ? " pollar-tx-spinner-rotating" : ""}`,
1013
+ "aria-hidden": true,
1014
+ children: [
1015
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "44", cy: "44", r: "36", fill: "none", stroke: "var(--pollar-border)", strokeWidth: "3" }),
1016
+ /* @__PURE__ */ jsxRuntime.jsx(
1017
+ "circle",
1018
+ {
1019
+ cx: "44",
1020
+ cy: "44",
1021
+ r: "36",
1022
+ fill: "none",
1023
+ stroke: isSuccess ? "var(--pollar-success-text)" : isError ? "var(--pollar-error-text)" : "var(--pollar-accent)",
1024
+ strokeWidth: "3",
1025
+ strokeLinecap: "round",
1026
+ strokeDasharray: isSigning ? "169.6 56.6" : "999 0",
1027
+ transform: "rotate(-90 44 44)",
1028
+ style: { transition: isSigning ? "none" : "stroke 400ms, stroke-dasharray 400ms" }
1029
+ }
1030
+ )
1031
+ ]
1032
+ }
1033
+ ),
1034
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-tx-wallet-icon", children: /* @__PURE__ */ jsxRuntime.jsx(
1035
+ "img",
1036
+ {
1037
+ src: walletType === core.WalletType.FREIGHTER ? LOGO_FREIGHTER : walletType === core.WalletType.ALBEDO ? LOGO_ALBEDO : LOGO_POLLAR,
1038
+ alt: walletType === core.WalletType.FREIGHTER ? "Freighter" : walletType === core.WalletType.ALBEDO ? "Albedo" : "Pollar",
1039
+ className: "pollar-tx-wallet-img"
1040
+ }
1041
+ ) })
1042
+ ] }),
1043
+ isSigning && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-tx-spinner-label", children: walletType === core.WalletType.FREIGHTER ? "Waiting for Freighter\u2026" : walletType === core.WalletType.ALBEDO ? "Waiting for Albedo\u2026" : "Signing and sending\u2026" }),
1044
+ isError && onRetry && "buildData" in transaction && transaction.buildData && /* @__PURE__ */ jsxRuntime.jsx("button", { className: "pollar-btn-secondary pollar-tx-retry-btn", onClick: onRetry, children: "Try again" })
1045
+ ] }),
925
1046
  isSuccess && hash && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-tx-result", children: [
926
1047
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-tx-result-label", children: "Transaction hash" }),
927
1048
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-tx-result-hash", children: hash }),
928
1049
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-tx-result-actions", children: [
929
- /* @__PURE__ */ jsxRuntime.jsx("button", { className: "pollar-tx-result-btn", onClick: handleCopyHash, children: copied ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1050
+ /* @__PURE__ */ jsxRuntime.jsx("button", { className: "pollar-tx-result-btn", onClick: onCopyHash, children: copied ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
930
1051
  /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "13", height: "13", viewBox: "0 0 14 14", fill: "none", "aria-hidden": true, children: [
931
1052
  /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "7", cy: "7", r: "7", fill: "currentColor" }),
932
- /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M3.5 7l2.5 2.5 4.5-5", stroke: "white", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })
1053
+ /* @__PURE__ */ jsxRuntime.jsx(
1054
+ "path",
1055
+ {
1056
+ d: "M3.5 7l2.5 2.5 4.5-5",
1057
+ stroke: "white",
1058
+ strokeWidth: "1.5",
1059
+ strokeLinecap: "round",
1060
+ strokeLinejoin: "round"
1061
+ }
1062
+ )
933
1063
  ] }),
934
1064
  "Copied!"
935
1065
  ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
936
1066
  /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "13", height: "13", viewBox: "0 0 13 13", fill: "none", "aria-hidden": true, children: [
937
1067
  /* @__PURE__ */ jsxRuntime.jsx("rect", { x: "4", y: "4", width: "8", height: "8", rx: "1.5", stroke: "currentColor", strokeWidth: "1.5" }),
938
- /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M3 9H2a1 1 0 01-1-1V2a1 1 0 011-1h6a1 1 0 011 1v1", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" })
1068
+ /* @__PURE__ */ jsxRuntime.jsx(
1069
+ "path",
1070
+ {
1071
+ d: "M3 9H2a1 1 0 01-1-1V2a1 1 0 011-1h6a1 1 0 011 1v1",
1072
+ stroke: "currentColor",
1073
+ strokeWidth: "1.5",
1074
+ strokeLinecap: "round"
1075
+ }
1076
+ )
939
1077
  ] }),
940
1078
  "Copy hash"
941
1079
  ] }) }),
942
1080
  explorerUrl && /* @__PURE__ */ jsxRuntime.jsxs("a", { className: "pollar-tx-result-btn", href: explorerUrl, target: "_blank", rel: "noopener noreferrer", children: [
943
1081
  /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "13", height: "13", viewBox: "0 0 13 13", fill: "none", "aria-hidden": true, children: [
944
- /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M5 2H2a1 1 0 00-1 1v8a1 1 0 001 1h8a1 1 0 001-1V8", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }),
945
- /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M8 1h4m0 0v4m0-4L6 7", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })
1082
+ /* @__PURE__ */ jsxRuntime.jsx(
1083
+ "path",
1084
+ {
1085
+ d: "M5 2H2a1 1 0 00-1 1v8a1 1 0 001 1h8a1 1 0 001-1V8",
1086
+ stroke: "currentColor",
1087
+ strokeWidth: "1.5",
1088
+ strokeLinecap: "round"
1089
+ }
1090
+ ),
1091
+ /* @__PURE__ */ jsxRuntime.jsx(
1092
+ "path",
1093
+ {
1094
+ d: "M8 1h4m0 0v4m0-4L6 7",
1095
+ stroke: "currentColor",
1096
+ strokeWidth: "1.5",
1097
+ strokeLinecap: "round",
1098
+ strokeLinejoin: "round"
1099
+ }
1100
+ )
946
1101
  ] }),
947
1102
  "View on Explorer"
948
1103
  ] })
949
1104
  ] })
950
1105
  ] }),
951
- isError && errorDetails && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-tx-error-details", children: [
952
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-tx-error-details-label", children: "Error details" }),
953
- /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "pollar-tx-error-details-content", children: errorDetails })
954
- ] }),
955
- isBuilt && /* @__PURE__ */ jsxRuntime.jsx("button", { className: "pollar-btn-primary pollar-tx-sign-btn", onClick: onSignAndSend, children: "Sign & Send" }),
956
- isSigning && /* @__PURE__ */ jsxRuntime.jsx("button", { className: "pollar-btn-primary pollar-tx-sign-btn", disabled: true, children: "Signing & sending\u2026" }),
957
1106
  isSuccess && /* @__PURE__ */ jsxRuntime.jsx("button", { className: "pollar-btn-primary pollar-tx-sign-btn", onClick: onClose, children: "Done" }),
958
- /* @__PURE__ */ jsxRuntime.jsx(ModalStatusBanner, { message: statusMessage[transaction.step], status: isError ? "ERROR" : isSigning || transaction.step === "building" ? "LOADING" : isSuccess ? "SUCCESS" : "NONE" }),
1107
+ /* @__PURE__ */ jsxRuntime.jsx(
1108
+ ModalStatusBanner,
1109
+ {
1110
+ message: STATUS_MESSAGES[transaction.step],
1111
+ status: isError ? "ERROR" : isSigning || transaction.step === "building" ? "LOADING" : isSuccess ? "SUCCESS" : "NONE"
1112
+ }
1113
+ ),
959
1114
  /* @__PURE__ */ jsxRuntime.jsx(PollarModalFooter, {})
960
1115
  ] });
961
1116
  }
962
1117
  function TransactionModal({ onClose }) {
963
- const { getClient, styles, transaction } = usePollar();
1118
+ const { getClient, styles, transaction, network, walletType } = usePollar();
964
1119
  const { theme = "light", accentColor = "#005DB4" } = styles;
965
- async function handleSignAndSend() {
1120
+ const [showXdr, setShowXdr] = react.useState(false);
1121
+ const [copied, setCopied] = react.useState(false);
1122
+ const hash = transaction.step === "success" ? transaction.hash : null;
1123
+ const buildData = "buildData" in transaction ? transaction.buildData : null;
1124
+ const explorerNetwork = buildData?.summary.network?.toLowerCase().includes("testnet") ? "testnet" : buildData ? "public" : network === "testnet" ? "testnet" : "public";
1125
+ const explorerUrl = hash ? `https://stellar.expert/explorer/${explorerNetwork}/tx/${hash}` : null;
1126
+ function handleSignAndSend() {
966
1127
  if (transaction.step === "built") {
1128
+ void getClient().signAndSubmitTx(transaction.buildData.unsignedXdr);
1129
+ }
1130
+ }
1131
+ function handleCopyHash() {
1132
+ if (!hash) return;
1133
+ navigator.clipboard.writeText(hash).then(() => {
1134
+ setCopied(true);
1135
+ setTimeout(() => setCopied(false), 2e3);
1136
+ });
1137
+ }
1138
+ async function handleRetry() {
1139
+ if (transaction.step === "error" && transaction.buildData) {
967
1140
  await getClient().signAndSubmitTx(transaction.buildData.unsignedXdr);
968
1141
  }
969
1142
  }
@@ -973,8 +1146,15 @@ function TransactionModal({ onClose }) {
973
1146
  theme,
974
1147
  accentColor,
975
1148
  transaction,
1149
+ showXdr,
1150
+ copied,
1151
+ explorerUrl,
1152
+ walletType,
976
1153
  onClose,
977
- onSignAndSend: handleSignAndSend
1154
+ onSignAndSend: handleSignAndSend,
1155
+ onToggleXdr: () => setShowXdr((v) => !v),
1156
+ onCopyHash: handleCopyHash,
1157
+ onRetry: handleRetry
978
1158
  }
979
1159
  ) });
980
1160
  }
@@ -998,15 +1178,20 @@ function TxHistoryModalTemplate({
998
1178
  const isDark = theme === "dark";
999
1179
  const cssVars = {
1000
1180
  "--pollar-accent": accentColor,
1001
- "--pollar-buttons-border-radius": "8px",
1002
- "--pollar-buttons-height": "44px",
1003
1181
  "--pollar-bg": isDark ? "#1a1a1a" : "#ffffff",
1004
1182
  "--pollar-border": isDark ? "#374151" : "#e5e7eb",
1005
1183
  "--pollar-text": isDark ? "#ffffff" : "#111827",
1006
1184
  "--pollar-muted": isDark ? "#9ca3af" : "#6b7280",
1007
- "--pollar-input-bg": isDark ? "#374151" : "rgba(0,0,0,0.04)",
1185
+ "--pollar-input-bg": isDark ? "#374151" : "#f9fafb",
1186
+ "--pollar-error-bg": isDark ? "#2a1515" : "#fef2f2",
1187
+ "--pollar-error-border": isDark ? "#7f1d1d" : "#fecaca",
1008
1188
  "--pollar-error-text": isDark ? "#f87171" : "#dc2626",
1009
- "--pollar-success-text": isDark ? "#4ade80" : "#16a34a"
1189
+ "--pollar-success-text": isDark ? "#4ade80" : "#16a34a",
1190
+ "--pollar-buttons-border-radius": "6px",
1191
+ "--pollar-buttons-height": "44px",
1192
+ "--pollar-input-height": "44px",
1193
+ "--pollar-input-border-radius": "0.5rem",
1194
+ "--pollar-card-border-radius": "10px"
1010
1195
  };
1011
1196
  const isLoading = txHistory.step === "loading";
1012
1197
  const records = txHistory.step === "loaded" ? txHistory.data.records : [];
@@ -1014,7 +1199,7 @@ function TxHistoryModalTemplate({
1014
1199
  const hasPrev = offset > 0;
1015
1200
  const hasNext = offset + PAGE_SIZE < total;
1016
1201
  const showPagination = txHistory.step === "loaded" && total > PAGE_SIZE;
1017
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-hist-modal", "data-theme": theme, style: cssVars, onClick: (e) => e.stopPropagation(), children: [
1202
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-card pollar-hist-modal", "data-theme": theme, style: cssVars, onClick: (e) => e.stopPropagation(), children: [
1018
1203
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-header", children: [
1019
1204
  /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "pollar-modal-title", children: "Transaction History" }),
1020
1205
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-header-actions", children: [
@@ -1052,22 +1237,33 @@ function TxHistoryModalTemplate({
1052
1237
  isLoading && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-empty", children: "Loading\u2026" }),
1053
1238
  txHistory.step === "error" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-empty", children: txHistory.message }),
1054
1239
  txHistory.step === "loaded" && records.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-empty", children: "No transactions yet." }),
1055
- records.map((record) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-hist-item", children: [
1056
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-hist-item-summary", children: record.summary }),
1057
- /* @__PURE__ */ jsxRuntime.jsx(StatusBadge, { status: record.status }),
1058
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-hist-item-meta", children: [
1059
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: record.operation }),
1060
- record.feeXlm && /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
1061
- "\xB7 ",
1062
- record.feeXlm,
1063
- " XLM"
1064
- ] }),
1065
- /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
1066
- "\xB7 ",
1067
- formatDate(record.createdAt)
1240
+ records.map((record) => {
1241
+ const explorerUrl = `https://stellar.expert/explorer/${record.network === "testnet" ? "testnet" : "public"}/tx/${record.hash}`;
1242
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-hist-item", children: [
1243
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-hist-item-summary", children: record.summary }),
1244
+ /* @__PURE__ */ jsxRuntime.jsx(StatusBadge, { status: record.status }),
1245
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-hist-item-meta", children: [
1246
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: record.operation }),
1247
+ record.feeXlm && /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
1248
+ "\xB7 ",
1249
+ record.feeXlm,
1250
+ " XLM"
1251
+ ] }),
1252
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
1253
+ "\xB7 ",
1254
+ formatDate(record.createdAt)
1255
+ ] }),
1256
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "\xB7" }),
1257
+ /* @__PURE__ */ jsxRuntime.jsxs("a", { className: "pollar-hist-item-explorer", href: explorerUrl, target: "_blank", rel: "noopener noreferrer", "aria-label": "View on Stellar Explorer", children: [
1258
+ /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "11", height: "11", viewBox: "0 0 13 13", fill: "none", "aria-hidden": true, children: [
1259
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M5 2H2a1 1 0 00-1 1v8a1 1 0 001 1h8a1 1 0 001-1V8", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }),
1260
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M8 1h4m0 0v4m0-4L6 7", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })
1261
+ ] }),
1262
+ "Explorer"
1263
+ ] })
1068
1264
  ] })
1069
- ] })
1070
- ] }, record.id))
1265
+ ] }, record.id);
1266
+ })
1071
1267
  ] }),
1072
1268
  showPagination && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-hist-pagination", children: [
1073
1269
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-hist-pagination-info", children: [
@@ -1129,9 +1325,14 @@ function BalanceItem({ record }) {
1129
1325
  ] })
1130
1326
  ] });
1131
1327
  }
1132
- function WalletBalanceModal({ onClose }) {
1133
- const { getBalance, walletAddress, styles } = usePollar();
1134
- const { theme = "light", accentColor = "#005DB4" } = styles;
1328
+ function WalletBalanceModalTemplate({
1329
+ theme,
1330
+ accentColor,
1331
+ walletBalance,
1332
+ walletAddress,
1333
+ onRefresh,
1334
+ onClose
1335
+ }) {
1135
1336
  const isDark = theme === "dark";
1136
1337
  const cssVars = {
1137
1338
  "--pollar-accent": accentColor,
@@ -1139,30 +1340,24 @@ function WalletBalanceModal({ onClose }) {
1139
1340
  "--pollar-border": isDark ? "#374151" : "#e5e7eb",
1140
1341
  "--pollar-text": isDark ? "#ffffff" : "#111827",
1141
1342
  "--pollar-muted": isDark ? "#9ca3af" : "#6b7280",
1142
- "--pollar-input-bg": isDark ? "#374151" : "rgba(0,0,0,0.04)",
1143
- "--pollar-error-text": isDark ? "#f87171" : "#dc2626"
1343
+ "--pollar-input-bg": isDark ? "#374151" : "#f9fafb",
1344
+ "--pollar-error-bg": isDark ? "#2a1515" : "#fef2f2",
1345
+ "--pollar-error-border": isDark ? "#7f1d1d" : "#fecaca",
1346
+ "--pollar-error-text": isDark ? "#f87171" : "#dc2626",
1347
+ "--pollar-success-text": isDark ? "#4ade80" : "#16a34a",
1348
+ "--pollar-buttons-border-radius": "6px",
1349
+ "--pollar-buttons-height": "44px",
1350
+ "--pollar-input-height": "44px",
1351
+ "--pollar-input-border-radius": "0.5rem",
1352
+ "--pollar-card-border-radius": "10px"
1144
1353
  };
1145
- const [status, setStatus] = react.useState("loading");
1146
- const [data, setData] = react.useState(null);
1147
- async function load() {
1148
- setStatus("loading");
1149
- const result = await getBalance();
1150
- if (result) {
1151
- setData(result);
1152
- setStatus("loaded");
1153
- } else {
1154
- setStatus("error");
1155
- }
1156
- }
1157
- react.useEffect(() => {
1158
- void load();
1159
- }, []);
1160
- const isLoading = status === "loading";
1161
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-overlay", onClick: onClose, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-bal-modal", "data-theme": theme, style: cssVars, onClick: (e) => e.stopPropagation(), children: [
1354
+ const isLoading = walletBalance.step === "loading";
1355
+ const data = walletBalance.step === "loaded" ? walletBalance.data : null;
1356
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-card pollar-bal-modal", "data-theme": theme, style: cssVars, onClick: (e) => e.stopPropagation(), children: [
1162
1357
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-header", children: [
1163
1358
  /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "pollar-modal-title", children: "Wallet Balance" }),
1164
1359
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-header-actions", children: [
1165
- /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "pollar-modal-refresh-btn", onClick: load, disabled: isLoading, children: [
1360
+ /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "pollar-modal-refresh-btn", onClick: onRefresh, disabled: isLoading, children: [
1166
1361
  /* @__PURE__ */ jsxRuntime.jsxs(
1167
1362
  "svg",
1168
1363
  {
@@ -1185,16 +1380,34 @@ function WalletBalanceModal({ onClose }) {
1185
1380
  ] }),
1186
1381
  walletAddress && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-bal-address", children: cropAddress(walletAddress) }),
1187
1382
  isLoading && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-empty", children: "Loading\u2026" }),
1188
- status === "error" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-error", children: "Failed to load balances. Check your connection." }),
1189
- status === "loaded" && data && !data.exists && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-empty", children: [
1383
+ walletBalance.step === "error" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-error", children: walletBalance.message }),
1384
+ data && !data.exists && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-empty", children: [
1190
1385
  "Account not found on ",
1191
1386
  data.network,
1192
1387
  "."
1193
1388
  ] }),
1194
- status === "loaded" && data?.exists && data.balances.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-empty", children: "No balances found." }),
1195
- status === "loaded" && data?.exists && data.balances.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-bal-list", children: data.balances.map((b) => /* @__PURE__ */ jsxRuntime.jsx(BalanceItem, { record: b }, b.code + (b.issuer ?? ""))) }),
1389
+ data?.exists && data.balances.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-empty", children: "No balances found." }),
1390
+ data?.exists && data.balances.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-bal-list", children: data.balances.map((b) => /* @__PURE__ */ jsxRuntime.jsx(BalanceItem, { record: b }, b.code + (b.issuer ?? ""))) }),
1196
1391
  /* @__PURE__ */ jsxRuntime.jsx(PollarModalFooter, {})
1197
- ] }) });
1392
+ ] });
1393
+ }
1394
+ function WalletBalanceModal({ onClose }) {
1395
+ const { walletBalance, refreshBalance, walletAddress, styles } = usePollar();
1396
+ const { theme = "light", accentColor = "#005DB4" } = styles;
1397
+ react.useEffect(() => {
1398
+ void refreshBalance();
1399
+ }, []);
1400
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-overlay", onClick: onClose, children: /* @__PURE__ */ jsxRuntime.jsx(
1401
+ WalletBalanceModalTemplate,
1402
+ {
1403
+ theme,
1404
+ accentColor,
1405
+ walletBalance,
1406
+ walletAddress,
1407
+ onRefresh: () => refreshBalance(),
1408
+ onClose
1409
+ }
1410
+ ) });
1198
1411
  }
1199
1412
  var emptyResponse = {
1200
1413
  application: {
@@ -1207,16 +1420,13 @@ async function fetchRemoteConfig(client) {
1207
1420
  return content ?? emptyResponse;
1208
1421
  }
1209
1422
  var PollarContext = react.createContext(null);
1210
- function PollarProvider({ config, styles: propStyles, children }) {
1423
+ function PollarProvider({ config, styles: propStyles, adapters, children }) {
1211
1424
  const [pollarClient] = react.useState(() => new core.PollarClient(config));
1212
1425
  const [networkState, setNetworkState] = react.useState(() => pollarClient.getNetworkState());
1213
- const stellarClient = react.useMemo(() => {
1214
- const network = networkState.step === "connected" ? networkState.network : "testnet";
1215
- return new core.StellarClient(network);
1216
- }, [networkState]);
1217
1426
  const [sessionState, setSessionState] = react.useState(null);
1218
1427
  const [transaction, setTransaction] = react.useState({ step: "idle" });
1219
1428
  const [txHistory, setTxHistory] = react.useState({ step: "idle" });
1429
+ const [walletBalance, setWalletBalance] = react.useState({ step: "idle" });
1220
1430
  const [remoteConfig, setRemoteConfig] = react.useState(emptyResponse);
1221
1431
  const [styles, setStyles] = react.useState(propStyles ?? {});
1222
1432
  react.useEffect(() => {
@@ -1225,6 +1435,9 @@ function PollarProvider({ config, styles: propStyles, children }) {
1225
1435
  react.useEffect(() => {
1226
1436
  return pollarClient.onTxHistoryStateChange(setTxHistory);
1227
1437
  }, [pollarClient]);
1438
+ react.useEffect(() => {
1439
+ return pollarClient.onWalletBalanceStateChange(setWalletBalance);
1440
+ }, [pollarClient]);
1228
1441
  react.useEffect(() => {
1229
1442
  return pollarClient.onNetworkStateChange((state) => {
1230
1443
  setNetworkState(state);
@@ -1265,14 +1478,15 @@ function PollarProvider({ config, styles: propStyles, children }) {
1265
1478
  const [walletBalanceModalOpen, setWalletBalanceModalOpen] = react.useState(false);
1266
1479
  const contextValue = react.useMemo(
1267
1480
  () => ({
1268
- walletAddress: sessionState?.wallet?.publicKey || "",
1481
+ walletAddress: sessionState?.data?.providers?.wallet?.address || sessionState?.wallet?.publicKey || "",
1269
1482
  getClient: () => pollarClient,
1270
1483
  transaction,
1271
1484
  login: (options) => pollarClient.login(options),
1272
1485
  logout: () => pollarClient.logout(),
1273
1486
  isAuthenticated: !!sessionState?.wallet?.publicKey,
1274
1487
  buildTx: (operation, params, options) => pollarClient.buildTx(operation, params, options),
1275
- signAndSubmitTx: (signedXdr) => pollarClient.signAndSubmitTx(signedXdr),
1488
+ signAndSubmitTx: (unsignedXdr) => pollarClient.signAndSubmitTx(unsignedXdr),
1489
+ walletType: pollarClient.getWalletType(),
1276
1490
  openTransactionModal: () => setTransactionModalOpen(true),
1277
1491
  openLoginModal: () => setLoginModalOpen(true),
1278
1492
  openKycModal: (options = {}) => {
@@ -1283,13 +1497,15 @@ function PollarProvider({ config, styles: propStyles, children }) {
1283
1497
  txHistory,
1284
1498
  openTxHistoryModal: () => setTxHistoryModalOpen(true),
1285
1499
  openWalletBalanceModal: () => setWalletBalanceModalOpen(true),
1500
+ walletBalance,
1501
+ refreshBalance: (publicKey) => pollarClient.refreshBalance(publicKey),
1286
1502
  network: networkState.step === "connected" ? networkState.network : "testnet",
1287
1503
  setNetwork: (network) => pollarClient.setNetwork(network),
1288
1504
  config: remoteConfig,
1289
1505
  styles,
1290
- getBalance: (publicKey) => pollarClient.getWalletBalance(publicKey)
1506
+ adapters
1291
1507
  }),
1292
- [sessionState, remoteConfig, styles, pollarClient, transaction, txHistory, networkState, stellarClient]
1508
+ [sessionState, remoteConfig, styles, pollarClient, transaction, txHistory, networkState, walletBalance]
1293
1509
  );
1294
1510
  return /* @__PURE__ */ jsxRuntime.jsxs(PollarContext.Provider, { value: contextValue, children: [
1295
1511
  children,
@@ -1316,50 +1532,57 @@ function usePollar() {
1316
1532
  }
1317
1533
  return ctx;
1318
1534
  }
1319
- function cropWallet(address) {
1320
- if (address.length <= 12) return address;
1321
- return `${address.slice(0, 6)}...${address.slice(-4)}`;
1535
+
1536
+ // src/usePollarAdapter.ts
1537
+ function createPollarAdapterHook(key) {
1538
+ return function usePollarAdapter() {
1539
+ const { adapters, signAndSubmitTx } = usePollar();
1540
+ const adapter = adapters?.[key];
1541
+ if (!adapter) {
1542
+ throw new Error(`No adapter "${key}" provided to PollarProvider`);
1543
+ }
1544
+ return Object.fromEntries(
1545
+ Object.entries(adapter).map(([name, fn]) => [
1546
+ name,
1547
+ async (params) => {
1548
+ const { unsignedTransaction } = await fn(params);
1549
+ await signAndSubmitTx(unsignedTransaction);
1550
+ }
1551
+ ])
1552
+ );
1553
+ };
1322
1554
  }
1323
1555
  function ButtonLogo() {
1324
1556
  return /* @__PURE__ */ jsxRuntime.jsx("img", { src: LOGO_POLLAR, alt: "Pollar", width: 22, height: 22, className: "wallet-btn-logo" });
1325
1557
  }
1326
- function WalletButton() {
1327
- const { getClient, walletAddress, styles, openLoginModal, openTxHistoryModal, openWalletBalanceModal } = usePollar();
1328
- const [open, setOpen] = react.useState(false);
1329
- const [copied, setCopied] = react.useState(false);
1330
- const wrapperRef = react.useRef(null);
1331
- const { theme = "light", accentColor = "#005DB4" } = styles;
1332
- const isDark = theme === "dark";
1333
- const dropdownBg = isDark ? "#18181b" : "#fff";
1334
- const dropdownBorder = isDark ? "#3f3f46" : "#e4e4e7";
1335
- const itemColor = isDark ? "#fafafa" : "#18181b";
1336
- react.useEffect(() => {
1337
- function handleClickOutside(e) {
1338
- if (wrapperRef.current && !wrapperRef.current.contains(e.target)) {
1339
- setOpen(false);
1340
- }
1341
- }
1342
- document.addEventListener("mousedown", handleClickOutside);
1343
- return () => document.removeEventListener("mousedown", handleClickOutside);
1344
- }, []);
1345
- async function handleCopy() {
1346
- if (!walletAddress) return;
1347
- await navigator.clipboard.writeText(walletAddress);
1348
- setCopied(true);
1349
- setTimeout(() => setCopied(false), 1500);
1350
- }
1351
- function handleLogout() {
1352
- setOpen(false);
1353
- getClient().logout();
1354
- }
1558
+ function cropWallet(address) {
1559
+ if (address.length <= 12) return address;
1560
+ return `${address.slice(0, 6)}...${address.slice(-4)}`;
1561
+ }
1562
+ function WalletButtonTemplate({
1563
+ walletAddress,
1564
+ accentColor,
1565
+ open,
1566
+ copied,
1567
+ dropdownBg,
1568
+ dropdownBorder,
1569
+ itemColor,
1570
+ wrapperRef,
1571
+ onToggleOpen,
1572
+ onCopy,
1573
+ onWalletBalance,
1574
+ onTxHistory,
1575
+ onLogout,
1576
+ onLogin
1577
+ }) {
1355
1578
  if (!walletAddress) {
1356
- return /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "wallet-login-btn", style: { backgroundColor: accentColor }, onClick: openLoginModal, children: [
1579
+ return /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "wallet-login-btn", style: { backgroundColor: accentColor }, onClick: onLogin, children: [
1357
1580
  /* @__PURE__ */ jsxRuntime.jsx(ButtonLogo, {}),
1358
1581
  "Login with Pollar"
1359
1582
  ] });
1360
1583
  }
1361
1584
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "wallet-wrapper", ref: wrapperRef, children: [
1362
- /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "wallet-btn", style: { backgroundColor: accentColor }, onClick: () => setOpen((v) => !v), children: [
1585
+ /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "wallet-btn", style: { backgroundColor: accentColor }, onClick: onToggleOpen, children: [
1363
1586
  cropWallet(walletAddress),
1364
1587
  /* @__PURE__ */ jsxRuntime.jsx(
1365
1588
  "svg",
@@ -1376,7 +1599,7 @@ function WalletButton() {
1376
1599
  )
1377
1600
  ] }),
1378
1601
  open && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "wallet-dropdown", style: { backgroundColor: dropdownBg, borderColor: dropdownBorder }, children: [
1379
- /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: handleCopy, children: [
1602
+ /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onCopy, children: [
1380
1603
  /* @__PURE__ */ jsxRuntime.jsxs(
1381
1604
  "svg",
1382
1605
  {
@@ -1401,10 +1624,7 @@ function WalletButton() {
1401
1624
  {
1402
1625
  className: "wallet-dropdown-item",
1403
1626
  style: { color: itemColor },
1404
- onClick: () => {
1405
- setOpen(false);
1406
- openWalletBalanceModal();
1407
- },
1627
+ onClick: onWalletBalance,
1408
1628
  children: [
1409
1629
  /* @__PURE__ */ jsxRuntime.jsxs(
1410
1630
  "svg",
@@ -1433,10 +1653,7 @@ function WalletButton() {
1433
1653
  {
1434
1654
  className: "wallet-dropdown-item",
1435
1655
  style: { color: itemColor },
1436
- onClick: () => {
1437
- setOpen(false);
1438
- openTxHistoryModal();
1439
- },
1656
+ onClick: onTxHistory,
1440
1657
  children: [
1441
1658
  /* @__PURE__ */ jsxRuntime.jsxs(
1442
1659
  "svg",
@@ -1462,7 +1679,7 @@ function WalletButton() {
1462
1679
  ]
1463
1680
  }
1464
1681
  ),
1465
- /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "wallet-dropdown-item danger", onClick: handleLogout, children: [
1682
+ /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "wallet-dropdown-item danger", onClick: onLogout, children: [
1466
1683
  /* @__PURE__ */ jsxRuntime.jsxs(
1467
1684
  "svg",
1468
1685
  {
@@ -1486,13 +1703,78 @@ function WalletButton() {
1486
1703
  ] })
1487
1704
  ] });
1488
1705
  }
1706
+ function WalletButton() {
1707
+ const { getClient, walletAddress, styles, openLoginModal, openTxHistoryModal, openWalletBalanceModal } = usePollar();
1708
+ const [open, setOpen] = react.useState(false);
1709
+ const [copied, setCopied] = react.useState(false);
1710
+ const wrapperRef = react.useRef(null);
1711
+ const { theme = "light", accentColor = "#005DB4" } = styles;
1712
+ const isDark = theme === "dark";
1713
+ const dropdownBg = isDark ? "#18181b" : "#fff";
1714
+ const dropdownBorder = isDark ? "#3f3f46" : "#e4e4e7";
1715
+ const itemColor = isDark ? "#fafafa" : "#18181b";
1716
+ react.useEffect(() => {
1717
+ function handleClickOutside(e) {
1718
+ if (wrapperRef.current && !wrapperRef.current.contains(e.target)) {
1719
+ setOpen(false);
1720
+ }
1721
+ }
1722
+ document.addEventListener("mousedown", handleClickOutside);
1723
+ return () => document.removeEventListener("mousedown", handleClickOutside);
1724
+ }, []);
1725
+ async function handleCopy() {
1726
+ if (!walletAddress) return;
1727
+ await navigator.clipboard.writeText(walletAddress);
1728
+ setCopied(true);
1729
+ setTimeout(() => setCopied(false), 1500);
1730
+ }
1731
+ function handleLogout() {
1732
+ setOpen(false);
1733
+ getClient().logout();
1734
+ }
1735
+ function handleWalletBalance() {
1736
+ setOpen(false);
1737
+ openWalletBalanceModal();
1738
+ }
1739
+ function handleTxHistory() {
1740
+ setOpen(false);
1741
+ openTxHistoryModal();
1742
+ }
1743
+ return /* @__PURE__ */ jsxRuntime.jsx(
1744
+ WalletButtonTemplate,
1745
+ {
1746
+ walletAddress: walletAddress ?? null,
1747
+ accentColor,
1748
+ open,
1749
+ copied,
1750
+ dropdownBg,
1751
+ dropdownBorder,
1752
+ itemColor,
1753
+ wrapperRef,
1754
+ onToggleOpen: () => setOpen((v) => !v),
1755
+ onCopy: handleCopy,
1756
+ onWalletBalance: handleWalletBalance,
1757
+ onTxHistory: handleTxHistory,
1758
+ onLogout: handleLogout,
1759
+ onLogin: openLoginModal
1760
+ }
1761
+ );
1762
+ }
1489
1763
 
1490
1764
  exports.KycModal = KycModal;
1765
+ exports.KycModalTemplate = KycModalTemplate;
1491
1766
  exports.KycStatus = KycStatus;
1767
+ exports.LoginModalTemplate = LoginModalTemplate;
1492
1768
  exports.PollarProvider = PollarProvider;
1493
1769
  exports.RampWidget = RampWidget;
1770
+ exports.RampWidgetTemplate = RampWidgetTemplate;
1494
1771
  exports.RouteDisplay = RouteDisplay;
1772
+ exports.TransactionModalTemplate = TransactionModalTemplate;
1773
+ exports.TxHistoryModalTemplate = TxHistoryModalTemplate;
1774
+ exports.WalletBalanceModal = WalletBalanceModal;
1775
+ exports.WalletBalanceModalTemplate = WalletBalanceModalTemplate;
1495
1776
  exports.WalletButton = WalletButton;
1777
+ exports.createPollarAdapterHook = createPollarAdapterHook;
1496
1778
  exports.usePollar = usePollar;
1497
1779
  //# sourceMappingURL=index.js.map
1498
1780
  //# sourceMappingURL=index.js.map