@pollar/react 0.5.0 → 0.5.2
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.css +215 -63
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +117 -4
- package/dist/index.d.ts +117 -4
- package/dist/index.js +343 -139
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +338 -141
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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.
|
|
41
|
+
"0.5.2"
|
|
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(
|
|
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 }),
|
|
@@ -266,8 +265,8 @@ function EmailCodeInput({ email, onSubmit }) {
|
|
|
266
265
|
}
|
|
267
266
|
var GithubButton = ({ disabled, onClick }) => {
|
|
268
267
|
return /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "github-button", disabled, onClick, children: [
|
|
269
|
-
/* @__PURE__ */ jsxRuntime.jsx("
|
|
270
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "github-button-contents", children: "
|
|
268
|
+
/* @__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" }) }),
|
|
269
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "github-button-contents", children: "GitHub" })
|
|
271
270
|
] });
|
|
272
271
|
};
|
|
273
272
|
var GoogleButton = ({ disabled, onClick }) => {
|
|
@@ -314,8 +313,8 @@ var GoogleButton = ({ disabled, onClick }) => {
|
|
|
314
313
|
]
|
|
315
314
|
}
|
|
316
315
|
) }),
|
|
317
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "gsi-material-button-contents", children: "
|
|
318
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { display: "none" }, children: "
|
|
316
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "gsi-material-button-contents", children: "Google" }),
|
|
317
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { display: "none" }, children: "Google" })
|
|
319
318
|
] })
|
|
320
319
|
] });
|
|
321
320
|
};
|
|
@@ -372,6 +371,7 @@ function LoginModalTemplate({
|
|
|
372
371
|
onCancel,
|
|
373
372
|
onRetry
|
|
374
373
|
}) {
|
|
374
|
+
const [showWalletPicker, setShowWalletPicker] = react.useState(false);
|
|
375
375
|
const isDark = theme === "dark";
|
|
376
376
|
const enabledSocial = Object.entries(providers).filter(([, enabled]) => enabled);
|
|
377
377
|
const cssVars = {
|
|
@@ -392,16 +392,48 @@ function LoginModalTemplate({
|
|
|
392
392
|
const isEmailCodeError = authState.step === "error" && (authState.errorCode === core.AUTH_ERROR_CODES.EMAIL_CODE_EXPIRED || authState.errorCode === core.AUTH_ERROR_CODES.EMAIL_CODE_INVALID);
|
|
393
393
|
const awaitingEmailCode = authState.step === "entering_code" || authState.step === "verifying_email_code" || isEmailCodeError;
|
|
394
394
|
const statusMessage = authState.step === "error" ? authState.message : AUTH_STATE_MESSAGES[authState.step];
|
|
395
|
+
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" }) }) });
|
|
395
396
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal", style: cssVars, onClick: (e) => e.stopPropagation(), children: [
|
|
397
|
+
/* @__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
398
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-header", children: [
|
|
397
399
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-logo-wrap", children: /* @__PURE__ */ jsxRuntime.jsx("img", { src: logoUrl ?? LOGO_POLLAR, alt: "Logo", className: "pollar-logo" }) }),
|
|
398
400
|
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "pollar-title", children: appName }),
|
|
399
401
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-subtitle", children: "Log in or sign up" })
|
|
400
402
|
] }),
|
|
401
403
|
awaitingEmailCode ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
402
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
404
|
+
/* @__PURE__ */ jsxRuntime.jsx(BackButton, { onClick: onBack }),
|
|
403
405
|
/* @__PURE__ */ jsxRuntime.jsx(EmailCodeInput, { email, onSubmit: onCodeSubmit ?? (() => {
|
|
404
406
|
}) }, codeInputKey)
|
|
407
|
+
] }) : showWalletPicker ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
408
|
+
/* @__PURE__ */ jsxRuntime.jsx(BackButton, { onClick: () => setShowWalletPicker(false) }),
|
|
409
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-wallet-list", children: [
|
|
410
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
411
|
+
"button",
|
|
412
|
+
{
|
|
413
|
+
type: "button",
|
|
414
|
+
disabled: isLoading,
|
|
415
|
+
className: "pollar-wallet-list-btn",
|
|
416
|
+
onClick: onFreighterConnect,
|
|
417
|
+
children: [
|
|
418
|
+
/* @__PURE__ */ jsxRuntime.jsx("img", { src: LOGO_FREIGHTER, alt: "Freighter", className: "pollar-wallet-list-icon" }),
|
|
419
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-wallet-list-name", children: "Freighter" })
|
|
420
|
+
]
|
|
421
|
+
}
|
|
422
|
+
),
|
|
423
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
424
|
+
"button",
|
|
425
|
+
{
|
|
426
|
+
type: "button",
|
|
427
|
+
disabled: isLoading,
|
|
428
|
+
className: "pollar-wallet-list-btn",
|
|
429
|
+
onClick: onAlbedoConnect,
|
|
430
|
+
children: [
|
|
431
|
+
/* @__PURE__ */ jsxRuntime.jsx("img", { src: LOGO_ALBEDO, alt: "Albedo", className: "pollar-wallet-list-icon" }),
|
|
432
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-wallet-list-name", children: "Albedo" })
|
|
433
|
+
]
|
|
434
|
+
}
|
|
435
|
+
)
|
|
436
|
+
] })
|
|
405
437
|
] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
406
438
|
emailEnabled && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-email-section", children: [
|
|
407
439
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -426,17 +458,19 @@ function LoginModalTemplate({
|
|
|
426
458
|
enabledSocial.some(([key]) => key === "google") && /* @__PURE__ */ jsxRuntime.jsx(GoogleButton, { disabled: isLoading, onClick: () => onSocialLogin?.("google") }),
|
|
427
459
|
enabledSocial.some(([key]) => key === "github") && /* @__PURE__ */ jsxRuntime.jsx(GithubButton, { disabled: isLoading, onClick: () => onSocialLogin?.("github") })
|
|
428
460
|
] }),
|
|
429
|
-
embeddedWallets && /* @__PURE__ */ jsxRuntime.
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
461
|
+
embeddedWallets && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-wallet-section", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
462
|
+
"button",
|
|
463
|
+
{
|
|
464
|
+
type: "button",
|
|
465
|
+
disabled: isLoading,
|
|
466
|
+
className: "pollar-wallet-entry-btn",
|
|
467
|
+
onClick: () => setShowWalletPicker(true),
|
|
468
|
+
children: [
|
|
469
|
+
/* @__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" }) }),
|
|
470
|
+
"Wallet"
|
|
471
|
+
]
|
|
472
|
+
}
|
|
473
|
+
) })
|
|
440
474
|
] }),
|
|
441
475
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
442
476
|
ModalStatusBanner,
|
|
@@ -527,7 +561,7 @@ function LoginModal({ onClose }) {
|
|
|
527
561
|
codeInputKey,
|
|
528
562
|
onCodeSubmit: handleVerifyCode,
|
|
529
563
|
onBack: handleBack,
|
|
530
|
-
onCancel:
|
|
564
|
+
onCancel: handleClose,
|
|
531
565
|
onRetry: handleRetry
|
|
532
566
|
}
|
|
533
567
|
) });
|
|
@@ -836,12 +870,27 @@ function RampWidget({ onClose }) {
|
|
|
836
870
|
}
|
|
837
871
|
) });
|
|
838
872
|
}
|
|
873
|
+
var STATUS_MESSAGES = {
|
|
874
|
+
idle: "",
|
|
875
|
+
building: "Building transaction\u2026",
|
|
876
|
+
built: "Ready to sign and send",
|
|
877
|
+
signing: "Signing and sending transaction\u2026",
|
|
878
|
+
success: "Transaction sent successfully",
|
|
879
|
+
error: "Transaction failed"
|
|
880
|
+
};
|
|
839
881
|
function TransactionModalTemplate({
|
|
840
882
|
theme,
|
|
841
883
|
accentColor,
|
|
842
884
|
transaction,
|
|
885
|
+
showXdr,
|
|
886
|
+
copied,
|
|
887
|
+
explorerUrl,
|
|
888
|
+
walletType,
|
|
843
889
|
onClose,
|
|
844
|
-
onSignAndSend
|
|
890
|
+
onSignAndSend,
|
|
891
|
+
onToggleXdr,
|
|
892
|
+
onCopyHash,
|
|
893
|
+
onRetry
|
|
845
894
|
}) {
|
|
846
895
|
const isDark = theme === "dark";
|
|
847
896
|
const cssVars = {
|
|
@@ -856,8 +905,6 @@ function TransactionModalTemplate({
|
|
|
856
905
|
"--pollar-error-text": isDark ? "#f87171" : "#dc2626",
|
|
857
906
|
"--pollar-success-text": isDark ? "#4ade80" : "#16a34a"
|
|
858
907
|
};
|
|
859
|
-
const [showXdr, setShowXdr] = react.useState(false);
|
|
860
|
-
const [copied, setCopied] = react.useState(false);
|
|
861
908
|
const buildData = "buildData" in transaction ? transaction.buildData : null;
|
|
862
909
|
const hash = transaction.step === "success" ? transaction.hash : null;
|
|
863
910
|
const errorDetails = transaction.step === "error" ? transaction.details ?? null : null;
|
|
@@ -866,28 +913,23 @@ function TransactionModalTemplate({
|
|
|
866
913
|
const isSuccess = transaction.step === "success";
|
|
867
914
|
const isError = transaction.step === "error";
|
|
868
915
|
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
916
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-tx-modal", "data-theme": theme, style: cssVars, onClick: (e) => e.stopPropagation(), children: [
|
|
887
|
-
/* @__PURE__ */ jsxRuntime.
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
917
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-header", children: /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "pollar-modal-title", children: "Transaction" }) }),
|
|
918
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-close-btn", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
919
|
+
"svg",
|
|
920
|
+
{
|
|
921
|
+
width: "18",
|
|
922
|
+
height: "18",
|
|
923
|
+
viewBox: "0 0 24 24",
|
|
924
|
+
fill: "none",
|
|
925
|
+
stroke: "currentColor",
|
|
926
|
+
strokeWidth: "2.5",
|
|
927
|
+
strokeLinecap: "round",
|
|
928
|
+
strokeLinejoin: "round",
|
|
929
|
+
"aria-hidden": true,
|
|
930
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M18 6L6 18M6 6l12 12" })
|
|
931
|
+
}
|
|
932
|
+
) }),
|
|
891
933
|
showDetails && buildData && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
892
934
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-tx-summary", children: [
|
|
893
935
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-tx-summary-title", children: "Details" }),
|
|
@@ -904,7 +946,7 @@ function TransactionModalTemplate({
|
|
|
904
946
|
] })
|
|
905
947
|
] }),
|
|
906
948
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-tx-xdr", children: [
|
|
907
|
-
/* @__PURE__ */ jsxRuntime.jsxs("button", { className: "pollar-tx-xdr-toggle", onClick:
|
|
949
|
+
/* @__PURE__ */ jsxRuntime.jsxs("button", { className: "pollar-tx-xdr-toggle", onClick: onToggleXdr, children: [
|
|
908
950
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
909
951
|
"svg",
|
|
910
952
|
{
|
|
@@ -922,48 +964,147 @@ function TransactionModalTemplate({
|
|
|
922
964
|
showXdr && /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "pollar-tx-xdr-content", children: buildData.unsignedXdr })
|
|
923
965
|
] })
|
|
924
966
|
] }),
|
|
967
|
+
isError && errorDetails && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-tx-error-details", children: [
|
|
968
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-tx-error-details-label", children: "Error details" }),
|
|
969
|
+
/* @__PURE__ */ jsxRuntime.jsx("pre", { className: "pollar-tx-error-details-content", children: errorDetails })
|
|
970
|
+
] }),
|
|
971
|
+
isBuilt && /* @__PURE__ */ jsxRuntime.jsx("button", { className: "pollar-btn-primary pollar-tx-sign-btn", onClick: onSignAndSend, children: "Sign & Send" }),
|
|
972
|
+
(isSigning || isSuccess || isError) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-tx-wallet-spinner", children: [
|
|
973
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-tx-spinner-ring", children: [
|
|
974
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
975
|
+
"svg",
|
|
976
|
+
{
|
|
977
|
+
viewBox: "0 0 88 88",
|
|
978
|
+
width: "88",
|
|
979
|
+
height: "88",
|
|
980
|
+
className: `pollar-tx-spinner-svg${isSigning ? " pollar-tx-spinner-rotating" : ""}`,
|
|
981
|
+
"aria-hidden": true,
|
|
982
|
+
children: [
|
|
983
|
+
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "44", cy: "44", r: "36", fill: "none", stroke: "var(--pollar-border)", strokeWidth: "3" }),
|
|
984
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
985
|
+
"circle",
|
|
986
|
+
{
|
|
987
|
+
cx: "44",
|
|
988
|
+
cy: "44",
|
|
989
|
+
r: "36",
|
|
990
|
+
fill: "none",
|
|
991
|
+
stroke: isSuccess ? "var(--pollar-success-text)" : isError ? "var(--pollar-error-text)" : "var(--pollar-accent)",
|
|
992
|
+
strokeWidth: "3",
|
|
993
|
+
strokeLinecap: "round",
|
|
994
|
+
strokeDasharray: isSigning ? "169.6 56.6" : "999 0",
|
|
995
|
+
transform: "rotate(-90 44 44)",
|
|
996
|
+
style: { transition: isSigning ? "none" : "stroke 400ms, stroke-dasharray 400ms" }
|
|
997
|
+
}
|
|
998
|
+
)
|
|
999
|
+
]
|
|
1000
|
+
}
|
|
1001
|
+
),
|
|
1002
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-tx-wallet-icon", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1003
|
+
"img",
|
|
1004
|
+
{
|
|
1005
|
+
src: walletType === core.WalletType.FREIGHTER ? LOGO_FREIGHTER : walletType === core.WalletType.ALBEDO ? LOGO_ALBEDO : LOGO_POLLAR,
|
|
1006
|
+
alt: walletType === core.WalletType.FREIGHTER ? "Freighter" : walletType === core.WalletType.ALBEDO ? "Albedo" : "Pollar",
|
|
1007
|
+
className: "pollar-tx-wallet-img"
|
|
1008
|
+
}
|
|
1009
|
+
) })
|
|
1010
|
+
] }),
|
|
1011
|
+
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" }),
|
|
1012
|
+
isError && onRetry && "buildData" in transaction && transaction.buildData && /* @__PURE__ */ jsxRuntime.jsx("button", { className: "pollar-btn-secondary pollar-tx-retry-btn", onClick: onRetry, children: "Try again" })
|
|
1013
|
+
] }),
|
|
925
1014
|
isSuccess && hash && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-tx-result", children: [
|
|
926
1015
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-tx-result-label", children: "Transaction hash" }),
|
|
927
1016
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-tx-result-hash", children: hash }),
|
|
928
1017
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-tx-result-actions", children: [
|
|
929
|
-
/* @__PURE__ */ jsxRuntime.jsx("button", { className: "pollar-tx-result-btn", onClick:
|
|
1018
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { className: "pollar-tx-result-btn", onClick: onCopyHash, children: copied ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
930
1019
|
/* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "13", height: "13", viewBox: "0 0 14 14", fill: "none", "aria-hidden": true, children: [
|
|
931
1020
|
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "7", cy: "7", r: "7", fill: "currentColor" }),
|
|
932
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1021
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1022
|
+
"path",
|
|
1023
|
+
{
|
|
1024
|
+
d: "M3.5 7l2.5 2.5 4.5-5",
|
|
1025
|
+
stroke: "white",
|
|
1026
|
+
strokeWidth: "1.5",
|
|
1027
|
+
strokeLinecap: "round",
|
|
1028
|
+
strokeLinejoin: "round"
|
|
1029
|
+
}
|
|
1030
|
+
)
|
|
933
1031
|
] }),
|
|
934
1032
|
"Copied!"
|
|
935
1033
|
] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
936
1034
|
/* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "13", height: "13", viewBox: "0 0 13 13", fill: "none", "aria-hidden": true, children: [
|
|
937
1035
|
/* @__PURE__ */ jsxRuntime.jsx("rect", { x: "4", y: "4", width: "8", height: "8", rx: "1.5", stroke: "currentColor", strokeWidth: "1.5" }),
|
|
938
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1036
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1037
|
+
"path",
|
|
1038
|
+
{
|
|
1039
|
+
d: "M3 9H2a1 1 0 01-1-1V2a1 1 0 011-1h6a1 1 0 011 1v1",
|
|
1040
|
+
stroke: "currentColor",
|
|
1041
|
+
strokeWidth: "1.5",
|
|
1042
|
+
strokeLinecap: "round"
|
|
1043
|
+
}
|
|
1044
|
+
)
|
|
939
1045
|
] }),
|
|
940
1046
|
"Copy hash"
|
|
941
1047
|
] }) }),
|
|
942
1048
|
explorerUrl && /* @__PURE__ */ jsxRuntime.jsxs("a", { className: "pollar-tx-result-btn", href: explorerUrl, target: "_blank", rel: "noopener noreferrer", children: [
|
|
943
1049
|
/* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "13", height: "13", viewBox: "0 0 13 13", fill: "none", "aria-hidden": true, children: [
|
|
944
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
945
|
-
|
|
1050
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1051
|
+
"path",
|
|
1052
|
+
{
|
|
1053
|
+
d: "M5 2H2a1 1 0 00-1 1v8a1 1 0 001 1h8a1 1 0 001-1V8",
|
|
1054
|
+
stroke: "currentColor",
|
|
1055
|
+
strokeWidth: "1.5",
|
|
1056
|
+
strokeLinecap: "round"
|
|
1057
|
+
}
|
|
1058
|
+
),
|
|
1059
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1060
|
+
"path",
|
|
1061
|
+
{
|
|
1062
|
+
d: "M8 1h4m0 0v4m0-4L6 7",
|
|
1063
|
+
stroke: "currentColor",
|
|
1064
|
+
strokeWidth: "1.5",
|
|
1065
|
+
strokeLinecap: "round",
|
|
1066
|
+
strokeLinejoin: "round"
|
|
1067
|
+
}
|
|
1068
|
+
)
|
|
946
1069
|
] }),
|
|
947
1070
|
"View on Explorer"
|
|
948
1071
|
] })
|
|
949
1072
|
] })
|
|
950
1073
|
] }),
|
|
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
1074
|
isSuccess && /* @__PURE__ */ jsxRuntime.jsx("button", { className: "pollar-btn-primary pollar-tx-sign-btn", onClick: onClose, children: "Done" }),
|
|
958
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1075
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1076
|
+
ModalStatusBanner,
|
|
1077
|
+
{
|
|
1078
|
+
message: STATUS_MESSAGES[transaction.step],
|
|
1079
|
+
status: isError ? "ERROR" : isSigning || transaction.step === "building" ? "LOADING" : isSuccess ? "SUCCESS" : "NONE"
|
|
1080
|
+
}
|
|
1081
|
+
),
|
|
959
1082
|
/* @__PURE__ */ jsxRuntime.jsx(PollarModalFooter, {})
|
|
960
1083
|
] });
|
|
961
1084
|
}
|
|
962
1085
|
function TransactionModal({ onClose }) {
|
|
963
|
-
const { getClient, styles, transaction } = usePollar();
|
|
1086
|
+
const { getClient, styles, transaction, network, walletType } = usePollar();
|
|
964
1087
|
const { theme = "light", accentColor = "#005DB4" } = styles;
|
|
965
|
-
|
|
1088
|
+
const [showXdr, setShowXdr] = react.useState(false);
|
|
1089
|
+
const [copied, setCopied] = react.useState(false);
|
|
1090
|
+
const hash = transaction.step === "success" ? transaction.hash : null;
|
|
1091
|
+
const buildData = "buildData" in transaction ? transaction.buildData : null;
|
|
1092
|
+
const explorerNetwork = buildData?.summary.network?.toLowerCase().includes("testnet") ? "testnet" : "public";
|
|
1093
|
+
const explorerUrl = hash ? `https://stellar.expert/explorer/${explorerNetwork}/tx/${hash}` : null;
|
|
1094
|
+
function handleSignAndSend() {
|
|
966
1095
|
if (transaction.step === "built") {
|
|
1096
|
+
void getClient().signAndSubmitTx(transaction.buildData.unsignedXdr);
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
function handleCopyHash() {
|
|
1100
|
+
if (!hash) return;
|
|
1101
|
+
navigator.clipboard.writeText(hash).then(() => {
|
|
1102
|
+
setCopied(true);
|
|
1103
|
+
setTimeout(() => setCopied(false), 2e3);
|
|
1104
|
+
});
|
|
1105
|
+
}
|
|
1106
|
+
async function handleRetry() {
|
|
1107
|
+
if (transaction.step === "error" && transaction.buildData) {
|
|
967
1108
|
await getClient().signAndSubmitTx(transaction.buildData.unsignedXdr);
|
|
968
1109
|
}
|
|
969
1110
|
}
|
|
@@ -973,8 +1114,15 @@ function TransactionModal({ onClose }) {
|
|
|
973
1114
|
theme,
|
|
974
1115
|
accentColor,
|
|
975
1116
|
transaction,
|
|
1117
|
+
showXdr,
|
|
1118
|
+
copied,
|
|
1119
|
+
explorerUrl,
|
|
1120
|
+
walletType,
|
|
976
1121
|
onClose,
|
|
977
|
-
onSignAndSend: handleSignAndSend
|
|
1122
|
+
onSignAndSend: handleSignAndSend,
|
|
1123
|
+
onToggleXdr: () => setShowXdr((v) => !v),
|
|
1124
|
+
onCopyHash: handleCopyHash,
|
|
1125
|
+
onRetry: handleRetry
|
|
978
1126
|
}
|
|
979
1127
|
) });
|
|
980
1128
|
}
|
|
@@ -1129,9 +1277,14 @@ function BalanceItem({ record }) {
|
|
|
1129
1277
|
] })
|
|
1130
1278
|
] });
|
|
1131
1279
|
}
|
|
1132
|
-
function
|
|
1133
|
-
|
|
1134
|
-
|
|
1280
|
+
function WalletBalanceModalTemplate({
|
|
1281
|
+
theme,
|
|
1282
|
+
accentColor,
|
|
1283
|
+
walletBalance,
|
|
1284
|
+
walletAddress,
|
|
1285
|
+
onRefresh,
|
|
1286
|
+
onClose
|
|
1287
|
+
}) {
|
|
1135
1288
|
const isDark = theme === "dark";
|
|
1136
1289
|
const cssVars = {
|
|
1137
1290
|
"--pollar-accent": accentColor,
|
|
@@ -1142,27 +1295,13 @@ function WalletBalanceModal({ onClose }) {
|
|
|
1142
1295
|
"--pollar-input-bg": isDark ? "#374151" : "rgba(0,0,0,0.04)",
|
|
1143
1296
|
"--pollar-error-text": isDark ? "#f87171" : "#dc2626"
|
|
1144
1297
|
};
|
|
1145
|
-
const
|
|
1146
|
-
const
|
|
1147
|
-
|
|
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: [
|
|
1298
|
+
const isLoading = walletBalance.step === "loading";
|
|
1299
|
+
const data = walletBalance.step === "loaded" ? walletBalance.data : null;
|
|
1300
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-bal-modal", "data-theme": theme, style: cssVars, onClick: (e) => e.stopPropagation(), children: [
|
|
1162
1301
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-header", children: [
|
|
1163
1302
|
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "pollar-modal-title", children: "Wallet Balance" }),
|
|
1164
1303
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-header-actions", children: [
|
|
1165
|
-
/* @__PURE__ */ jsxRuntime.jsxs("button", { className: "pollar-modal-refresh-btn", onClick:
|
|
1304
|
+
/* @__PURE__ */ jsxRuntime.jsxs("button", { className: "pollar-modal-refresh-btn", onClick: onRefresh, disabled: isLoading, children: [
|
|
1166
1305
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1167
1306
|
"svg",
|
|
1168
1307
|
{
|
|
@@ -1185,16 +1324,34 @@ function WalletBalanceModal({ onClose }) {
|
|
|
1185
1324
|
] }),
|
|
1186
1325
|
walletAddress && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-bal-address", children: cropAddress(walletAddress) }),
|
|
1187
1326
|
isLoading && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-empty", children: "Loading\u2026" }),
|
|
1188
|
-
|
|
1189
|
-
|
|
1327
|
+
walletBalance.step === "error" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-error", children: walletBalance.message }),
|
|
1328
|
+
data && !data.exists && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-empty", children: [
|
|
1190
1329
|
"Account not found on ",
|
|
1191
1330
|
data.network,
|
|
1192
1331
|
"."
|
|
1193
1332
|
] }),
|
|
1194
|
-
|
|
1195
|
-
|
|
1333
|
+
data?.exists && data.balances.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-empty", children: "No balances found." }),
|
|
1334
|
+
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
1335
|
/* @__PURE__ */ jsxRuntime.jsx(PollarModalFooter, {})
|
|
1197
|
-
] })
|
|
1336
|
+
] });
|
|
1337
|
+
}
|
|
1338
|
+
function WalletBalanceModal({ onClose }) {
|
|
1339
|
+
const { walletBalance, refreshBalance, walletAddress, styles } = usePollar();
|
|
1340
|
+
const { theme = "light", accentColor = "#005DB4" } = styles;
|
|
1341
|
+
react.useEffect(() => {
|
|
1342
|
+
void refreshBalance();
|
|
1343
|
+
}, []);
|
|
1344
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-overlay", onClick: onClose, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1345
|
+
WalletBalanceModalTemplate,
|
|
1346
|
+
{
|
|
1347
|
+
theme,
|
|
1348
|
+
accentColor,
|
|
1349
|
+
walletBalance,
|
|
1350
|
+
walletAddress,
|
|
1351
|
+
onRefresh: () => refreshBalance(),
|
|
1352
|
+
onClose
|
|
1353
|
+
}
|
|
1354
|
+
) });
|
|
1198
1355
|
}
|
|
1199
1356
|
var emptyResponse = {
|
|
1200
1357
|
application: {
|
|
@@ -1210,13 +1367,10 @@ var PollarContext = react.createContext(null);
|
|
|
1210
1367
|
function PollarProvider({ config, styles: propStyles, children }) {
|
|
1211
1368
|
const [pollarClient] = react.useState(() => new core.PollarClient(config));
|
|
1212
1369
|
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
1370
|
const [sessionState, setSessionState] = react.useState(null);
|
|
1218
1371
|
const [transaction, setTransaction] = react.useState({ step: "idle" });
|
|
1219
1372
|
const [txHistory, setTxHistory] = react.useState({ step: "idle" });
|
|
1373
|
+
const [walletBalance, setWalletBalance] = react.useState({ step: "idle" });
|
|
1220
1374
|
const [remoteConfig, setRemoteConfig] = react.useState(emptyResponse);
|
|
1221
1375
|
const [styles, setStyles] = react.useState(propStyles ?? {});
|
|
1222
1376
|
react.useEffect(() => {
|
|
@@ -1225,6 +1379,9 @@ function PollarProvider({ config, styles: propStyles, children }) {
|
|
|
1225
1379
|
react.useEffect(() => {
|
|
1226
1380
|
return pollarClient.onTxHistoryStateChange(setTxHistory);
|
|
1227
1381
|
}, [pollarClient]);
|
|
1382
|
+
react.useEffect(() => {
|
|
1383
|
+
return pollarClient.onWalletBalanceStateChange(setWalletBalance);
|
|
1384
|
+
}, [pollarClient]);
|
|
1228
1385
|
react.useEffect(() => {
|
|
1229
1386
|
return pollarClient.onNetworkStateChange((state) => {
|
|
1230
1387
|
setNetworkState(state);
|
|
@@ -1265,14 +1422,15 @@ function PollarProvider({ config, styles: propStyles, children }) {
|
|
|
1265
1422
|
const [walletBalanceModalOpen, setWalletBalanceModalOpen] = react.useState(false);
|
|
1266
1423
|
const contextValue = react.useMemo(
|
|
1267
1424
|
() => ({
|
|
1268
|
-
walletAddress: sessionState?.wallet?.publicKey || "",
|
|
1425
|
+
walletAddress: sessionState?.data?.providers?.wallet?.address || sessionState?.wallet?.publicKey || "",
|
|
1269
1426
|
getClient: () => pollarClient,
|
|
1270
1427
|
transaction,
|
|
1271
1428
|
login: (options) => pollarClient.login(options),
|
|
1272
1429
|
logout: () => pollarClient.logout(),
|
|
1273
1430
|
isAuthenticated: !!sessionState?.wallet?.publicKey,
|
|
1274
1431
|
buildTx: (operation, params, options) => pollarClient.buildTx(operation, params, options),
|
|
1275
|
-
signAndSubmitTx: (
|
|
1432
|
+
signAndSubmitTx: (unsignedXdr) => pollarClient.signAndSubmitTx(unsignedXdr),
|
|
1433
|
+
walletType: pollarClient.getWalletType(),
|
|
1276
1434
|
openTransactionModal: () => setTransactionModalOpen(true),
|
|
1277
1435
|
openLoginModal: () => setLoginModalOpen(true),
|
|
1278
1436
|
openKycModal: (options = {}) => {
|
|
@@ -1283,13 +1441,14 @@ function PollarProvider({ config, styles: propStyles, children }) {
|
|
|
1283
1441
|
txHistory,
|
|
1284
1442
|
openTxHistoryModal: () => setTxHistoryModalOpen(true),
|
|
1285
1443
|
openWalletBalanceModal: () => setWalletBalanceModalOpen(true),
|
|
1444
|
+
walletBalance,
|
|
1445
|
+
refreshBalance: (publicKey) => pollarClient.refreshBalance(publicKey),
|
|
1286
1446
|
network: networkState.step === "connected" ? networkState.network : "testnet",
|
|
1287
1447
|
setNetwork: (network) => pollarClient.setNetwork(network),
|
|
1288
1448
|
config: remoteConfig,
|
|
1289
|
-
styles
|
|
1290
|
-
getBalance: (publicKey) => pollarClient.getWalletBalance(publicKey)
|
|
1449
|
+
styles
|
|
1291
1450
|
}),
|
|
1292
|
-
[sessionState, remoteConfig, styles, pollarClient, transaction, txHistory, networkState,
|
|
1451
|
+
[sessionState, remoteConfig, styles, pollarClient, transaction, txHistory, networkState, walletBalance]
|
|
1293
1452
|
);
|
|
1294
1453
|
return /* @__PURE__ */ jsxRuntime.jsxs(PollarContext.Provider, { value: contextValue, children: [
|
|
1295
1454
|
children,
|
|
@@ -1316,50 +1475,37 @@ function usePollar() {
|
|
|
1316
1475
|
}
|
|
1317
1476
|
return ctx;
|
|
1318
1477
|
}
|
|
1478
|
+
function ButtonLogo() {
|
|
1479
|
+
return /* @__PURE__ */ jsxRuntime.jsx("img", { src: LOGO_POLLAR, alt: "Pollar", width: 22, height: 22, className: "wallet-btn-logo" });
|
|
1480
|
+
}
|
|
1319
1481
|
function cropWallet(address) {
|
|
1320
1482
|
if (address.length <= 12) return address;
|
|
1321
1483
|
return `${address.slice(0, 6)}...${address.slice(-4)}`;
|
|
1322
1484
|
}
|
|
1323
|
-
function
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
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
|
-
}
|
|
1485
|
+
function WalletButtonTemplate({
|
|
1486
|
+
walletAddress,
|
|
1487
|
+
accentColor,
|
|
1488
|
+
open,
|
|
1489
|
+
copied,
|
|
1490
|
+
dropdownBg,
|
|
1491
|
+
dropdownBorder,
|
|
1492
|
+
itemColor,
|
|
1493
|
+
wrapperRef,
|
|
1494
|
+
onToggleOpen,
|
|
1495
|
+
onCopy,
|
|
1496
|
+
onWalletBalance,
|
|
1497
|
+
onTxHistory,
|
|
1498
|
+
onLogout,
|
|
1499
|
+
onLogin
|
|
1500
|
+
}) {
|
|
1355
1501
|
if (!walletAddress) {
|
|
1356
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "wallet-login-btn", style: { backgroundColor: accentColor }, onClick:
|
|
1502
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "wallet-login-btn", style: { backgroundColor: accentColor }, onClick: onLogin, children: [
|
|
1357
1503
|
/* @__PURE__ */ jsxRuntime.jsx(ButtonLogo, {}),
|
|
1358
1504
|
"Login with Pollar"
|
|
1359
1505
|
] });
|
|
1360
1506
|
}
|
|
1361
1507
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "wallet-wrapper", ref: wrapperRef, children: [
|
|
1362
|
-
/* @__PURE__ */ jsxRuntime.jsxs("button", { className: "wallet-btn", style: { backgroundColor: accentColor }, onClick:
|
|
1508
|
+
/* @__PURE__ */ jsxRuntime.jsxs("button", { className: "wallet-btn", style: { backgroundColor: accentColor }, onClick: onToggleOpen, children: [
|
|
1363
1509
|
cropWallet(walletAddress),
|
|
1364
1510
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1365
1511
|
"svg",
|
|
@@ -1376,7 +1522,7 @@ function WalletButton() {
|
|
|
1376
1522
|
)
|
|
1377
1523
|
] }),
|
|
1378
1524
|
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:
|
|
1525
|
+
/* @__PURE__ */ jsxRuntime.jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onCopy, children: [
|
|
1380
1526
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1381
1527
|
"svg",
|
|
1382
1528
|
{
|
|
@@ -1401,10 +1547,7 @@ function WalletButton() {
|
|
|
1401
1547
|
{
|
|
1402
1548
|
className: "wallet-dropdown-item",
|
|
1403
1549
|
style: { color: itemColor },
|
|
1404
|
-
onClick:
|
|
1405
|
-
setOpen(false);
|
|
1406
|
-
openWalletBalanceModal();
|
|
1407
|
-
},
|
|
1550
|
+
onClick: onWalletBalance,
|
|
1408
1551
|
children: [
|
|
1409
1552
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1410
1553
|
"svg",
|
|
@@ -1433,10 +1576,7 @@ function WalletButton() {
|
|
|
1433
1576
|
{
|
|
1434
1577
|
className: "wallet-dropdown-item",
|
|
1435
1578
|
style: { color: itemColor },
|
|
1436
|
-
onClick:
|
|
1437
|
-
setOpen(false);
|
|
1438
|
-
openTxHistoryModal();
|
|
1439
|
-
},
|
|
1579
|
+
onClick: onTxHistory,
|
|
1440
1580
|
children: [
|
|
1441
1581
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1442
1582
|
"svg",
|
|
@@ -1462,7 +1602,7 @@ function WalletButton() {
|
|
|
1462
1602
|
]
|
|
1463
1603
|
}
|
|
1464
1604
|
),
|
|
1465
|
-
/* @__PURE__ */ jsxRuntime.jsxs("button", { className: "wallet-dropdown-item danger", onClick:
|
|
1605
|
+
/* @__PURE__ */ jsxRuntime.jsxs("button", { className: "wallet-dropdown-item danger", onClick: onLogout, children: [
|
|
1466
1606
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1467
1607
|
"svg",
|
|
1468
1608
|
{
|
|
@@ -1486,12 +1626,76 @@ function WalletButton() {
|
|
|
1486
1626
|
] })
|
|
1487
1627
|
] });
|
|
1488
1628
|
}
|
|
1629
|
+
function WalletButton() {
|
|
1630
|
+
const { getClient, walletAddress, styles, openLoginModal, openTxHistoryModal, openWalletBalanceModal } = usePollar();
|
|
1631
|
+
const [open, setOpen] = react.useState(false);
|
|
1632
|
+
const [copied, setCopied] = react.useState(false);
|
|
1633
|
+
const wrapperRef = react.useRef(null);
|
|
1634
|
+
const { theme = "light", accentColor = "#005DB4" } = styles;
|
|
1635
|
+
const isDark = theme === "dark";
|
|
1636
|
+
const dropdownBg = isDark ? "#18181b" : "#fff";
|
|
1637
|
+
const dropdownBorder = isDark ? "#3f3f46" : "#e4e4e7";
|
|
1638
|
+
const itemColor = isDark ? "#fafafa" : "#18181b";
|
|
1639
|
+
react.useEffect(() => {
|
|
1640
|
+
function handleClickOutside(e) {
|
|
1641
|
+
if (wrapperRef.current && !wrapperRef.current.contains(e.target)) {
|
|
1642
|
+
setOpen(false);
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
1645
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
1646
|
+
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
1647
|
+
}, []);
|
|
1648
|
+
async function handleCopy() {
|
|
1649
|
+
if (!walletAddress) return;
|
|
1650
|
+
await navigator.clipboard.writeText(walletAddress);
|
|
1651
|
+
setCopied(true);
|
|
1652
|
+
setTimeout(() => setCopied(false), 1500);
|
|
1653
|
+
}
|
|
1654
|
+
function handleLogout() {
|
|
1655
|
+
setOpen(false);
|
|
1656
|
+
getClient().logout();
|
|
1657
|
+
}
|
|
1658
|
+
function handleWalletBalance() {
|
|
1659
|
+
setOpen(false);
|
|
1660
|
+
openWalletBalanceModal();
|
|
1661
|
+
}
|
|
1662
|
+
function handleTxHistory() {
|
|
1663
|
+
setOpen(false);
|
|
1664
|
+
openTxHistoryModal();
|
|
1665
|
+
}
|
|
1666
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1667
|
+
WalletButtonTemplate,
|
|
1668
|
+
{
|
|
1669
|
+
walletAddress: walletAddress ?? null,
|
|
1670
|
+
accentColor,
|
|
1671
|
+
open,
|
|
1672
|
+
copied,
|
|
1673
|
+
dropdownBg,
|
|
1674
|
+
dropdownBorder,
|
|
1675
|
+
itemColor,
|
|
1676
|
+
wrapperRef,
|
|
1677
|
+
onToggleOpen: () => setOpen((v) => !v),
|
|
1678
|
+
onCopy: handleCopy,
|
|
1679
|
+
onWalletBalance: handleWalletBalance,
|
|
1680
|
+
onTxHistory: handleTxHistory,
|
|
1681
|
+
onLogout: handleLogout,
|
|
1682
|
+
onLogin: openLoginModal
|
|
1683
|
+
}
|
|
1684
|
+
);
|
|
1685
|
+
}
|
|
1489
1686
|
|
|
1490
1687
|
exports.KycModal = KycModal;
|
|
1688
|
+
exports.KycModalTemplate = KycModalTemplate;
|
|
1491
1689
|
exports.KycStatus = KycStatus;
|
|
1690
|
+
exports.LoginModalTemplate = LoginModalTemplate;
|
|
1492
1691
|
exports.PollarProvider = PollarProvider;
|
|
1493
1692
|
exports.RampWidget = RampWidget;
|
|
1693
|
+
exports.RampWidgetTemplate = RampWidgetTemplate;
|
|
1494
1694
|
exports.RouteDisplay = RouteDisplay;
|
|
1695
|
+
exports.TransactionModalTemplate = TransactionModalTemplate;
|
|
1696
|
+
exports.TxHistoryModalTemplate = TxHistoryModalTemplate;
|
|
1697
|
+
exports.WalletBalanceModal = WalletBalanceModal;
|
|
1698
|
+
exports.WalletBalanceModalTemplate = WalletBalanceModalTemplate;
|
|
1495
1699
|
exports.WalletButton = WalletButton;
|
|
1496
1700
|
exports.usePollar = usePollar;
|
|
1497
1701
|
//# sourceMappingURL=index.js.map
|