@algobright/solana-connector 0.1.2 → 0.1.4
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/{Button.module-HQNNX6IB.module.css → Button.module-QCTUNBHA.module.css} +1 -0
- package/dist/ConnectButton.d.mts +24 -0
- package/dist/ConnectButton.d.ts +24 -0
- package/dist/ConnectButton.js +68 -72
- package/dist/ConnectButton.js.map +1 -1
- package/dist/ConnectButton.mjs +43 -47
- package/dist/ConnectButton.mjs.map +1 -1
- package/dist/{ConnectButton.module-O3M32YJK.module.css → ConnectButton.module-AR6WQXQS.module.css} +0 -3
- package/dist/WalletDropdown.d.mts +20 -5
- package/dist/WalletDropdown.d.ts +20 -5
- package/dist/WalletDropdown.js +31 -28
- package/dist/WalletDropdown.js.map +1 -1
- package/dist/WalletDropdown.mjs +19 -16
- package/dist/WalletDropdown.mjs.map +1 -1
- package/dist/WalletModal.d.mts +13 -2
- package/dist/WalletModal.d.ts +13 -2
- package/dist/WalletModal.js +28 -30
- package/dist/WalletModal.js.map +1 -1
- package/dist/WalletModal.mjs +15 -17
- package/dist/WalletModal.mjs.map +1 -1
- package/dist/index.d.mts +10 -2
- package/dist/index.d.ts +10 -2
- package/dist/index.js +8 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -1
package/dist/ConnectButton.d.mts
CHANGED
|
@@ -1,13 +1,37 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
|
|
3
3
|
interface ConnectButtonProps {
|
|
4
|
+
/** * The visual theme for the button and modals.
|
|
5
|
+
* @default 'light'
|
|
6
|
+
*/
|
|
4
7
|
theme?: 'light' | 'dark';
|
|
8
|
+
/** * Custom Tailwind or CSS class for the main button element.
|
|
9
|
+
* If not passed, standard kit styling is applied.
|
|
10
|
+
*/
|
|
5
11
|
CN_ConnectButton?: string;
|
|
12
|
+
/** * Custom CSS class for the dropdown menu.
|
|
13
|
+
* If not passed, it defaults to the standard dropdown layout.
|
|
14
|
+
*/
|
|
6
15
|
CN_DropdownMenu?: string;
|
|
16
|
+
/** * Custom CSS class for the connection modal.
|
|
17
|
+
* This modal displays all wallet options and the QR code for mobile linking.
|
|
18
|
+
*/
|
|
7
19
|
CN_Modal?: string;
|
|
20
|
+
/** * Initial text shown when the wallet is disconnected.
|
|
21
|
+
* @default "Connect Wallet"
|
|
22
|
+
*/
|
|
8
23
|
connectText?: string;
|
|
24
|
+
/** * Text displayed while the wallet is in the 'connecting' state.
|
|
25
|
+
* @default "Connecting..."
|
|
26
|
+
*/
|
|
9
27
|
connectingText?: string;
|
|
28
|
+
/** * If true, fetches and displays the native SOL balance.
|
|
29
|
+
* @default false
|
|
30
|
+
*/
|
|
10
31
|
showSolBalance?: boolean;
|
|
32
|
+
/** * If provided, displays a specific SPL token balance (e.g., USDC).
|
|
33
|
+
* If null/undefined, only SOL or no balance is shown.
|
|
34
|
+
*/
|
|
11
35
|
showDefaultToken?: {
|
|
12
36
|
address: string;
|
|
13
37
|
symbol: string;
|
package/dist/ConnectButton.d.ts
CHANGED
|
@@ -1,13 +1,37 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
|
|
3
3
|
interface ConnectButtonProps {
|
|
4
|
+
/** * The visual theme for the button and modals.
|
|
5
|
+
* @default 'light'
|
|
6
|
+
*/
|
|
4
7
|
theme?: 'light' | 'dark';
|
|
8
|
+
/** * Custom Tailwind or CSS class for the main button element.
|
|
9
|
+
* If not passed, standard kit styling is applied.
|
|
10
|
+
*/
|
|
5
11
|
CN_ConnectButton?: string;
|
|
12
|
+
/** * Custom CSS class for the dropdown menu.
|
|
13
|
+
* If not passed, it defaults to the standard dropdown layout.
|
|
14
|
+
*/
|
|
6
15
|
CN_DropdownMenu?: string;
|
|
16
|
+
/** * Custom CSS class for the connection modal.
|
|
17
|
+
* This modal displays all wallet options and the QR code for mobile linking.
|
|
18
|
+
*/
|
|
7
19
|
CN_Modal?: string;
|
|
20
|
+
/** * Initial text shown when the wallet is disconnected.
|
|
21
|
+
* @default "Connect Wallet"
|
|
22
|
+
*/
|
|
8
23
|
connectText?: string;
|
|
24
|
+
/** * Text displayed while the wallet is in the 'connecting' state.
|
|
25
|
+
* @default "Connecting..."
|
|
26
|
+
*/
|
|
9
27
|
connectingText?: string;
|
|
28
|
+
/** * If true, fetches and displays the native SOL balance.
|
|
29
|
+
* @default false
|
|
30
|
+
*/
|
|
10
31
|
showSolBalance?: boolean;
|
|
32
|
+
/** * If provided, displays a specific SPL token balance (e.g., USDC).
|
|
33
|
+
* If null/undefined, only SOL or no balance is shown.
|
|
34
|
+
*/
|
|
11
35
|
showDefaultToken?: {
|
|
12
36
|
address: string;
|
|
13
37
|
symbol: string;
|
package/dist/ConnectButton.js
CHANGED
|
@@ -36,16 +36,16 @@ __export(ConnectButton_exports, {
|
|
|
36
36
|
module.exports = __toCommonJS(ConnectButton_exports);
|
|
37
37
|
|
|
38
38
|
// src/components/ConnectButton/ConnectButton.tsx
|
|
39
|
-
var
|
|
40
|
-
var import_ConnectButton = __toESM(require("./ConnectButton.module-
|
|
39
|
+
var import_react10 = require("react");
|
|
40
|
+
var import_ConnectButton = __toESM(require("./ConnectButton.module-AR6WQXQS.module.css"));
|
|
41
41
|
var import_connector4 = require("@solana/connector");
|
|
42
42
|
|
|
43
43
|
// src/components/shared/Button/Button.tsx
|
|
44
|
-
var
|
|
44
|
+
var import_react = require("react");
|
|
45
45
|
var import_button = require("@base-ui/react/button");
|
|
46
|
-
var import_Button = __toESM(require("./Button.module-
|
|
46
|
+
var import_Button = __toESM(require("./Button.module-QCTUNBHA.module.css"));
|
|
47
47
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
48
|
-
var Button =
|
|
48
|
+
var Button = (0, import_react.forwardRef)(
|
|
49
49
|
({ className, variant = "default", size = "default", ...props }, ref) => {
|
|
50
50
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
51
51
|
import_button.Button,
|
|
@@ -79,21 +79,21 @@ var Spinner_default2 = Spinner_default;
|
|
|
79
79
|
// src/components/WalletModal/WalletModal.tsx
|
|
80
80
|
var import_connector = require("@solana/connector");
|
|
81
81
|
var import_lucide_react3 = require("lucide-react");
|
|
82
|
-
var
|
|
82
|
+
var import_react6 = require("react");
|
|
83
83
|
var import_WalletModal = __toESM(require("./WalletModal.module-ZRTJGOQY.module.css"));
|
|
84
84
|
|
|
85
85
|
// src/components/shared/Dialog/Dialog.tsx
|
|
86
|
-
var React2 = __toESM(require("react"));
|
|
87
86
|
var import_dialog = require("@base-ui/react/dialog");
|
|
88
87
|
var import_lucide_react = require("lucide-react");
|
|
89
88
|
var import_Dialog = __toESM(require("./Dialog.module-AYJTMDAD.module.css"));
|
|
90
89
|
var import_clsx = __toESM(require("clsx"));
|
|
90
|
+
var import_react2 = require("react");
|
|
91
91
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
92
92
|
var Dialog = import_dialog.Dialog.Root;
|
|
93
93
|
var DialogTrigger = import_dialog.Dialog.Trigger;
|
|
94
94
|
var DialogPortal = import_dialog.Dialog.Portal;
|
|
95
95
|
var DialogClose = import_dialog.Dialog.Close;
|
|
96
|
-
var DialogBackdrop =
|
|
96
|
+
var DialogBackdrop = (0, import_react2.forwardRef)(
|
|
97
97
|
({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
98
98
|
import_dialog.Dialog.Backdrop,
|
|
99
99
|
{
|
|
@@ -104,7 +104,7 @@ var DialogBackdrop = React2.forwardRef(
|
|
|
104
104
|
)
|
|
105
105
|
);
|
|
106
106
|
DialogBackdrop.displayName = "DialogBackdrop";
|
|
107
|
-
var DialogContent =
|
|
107
|
+
var DialogContent = (0, import_react2.forwardRef)(
|
|
108
108
|
({ className, children, theme, showCloseButton = true, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(DialogPortal, { children: [
|
|
109
109
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(DialogBackdrop, { "data-theme": theme }),
|
|
110
110
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
@@ -127,7 +127,7 @@ var DialogHeader = ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_r
|
|
|
127
127
|
DialogHeader.displayName = "DialogHeader";
|
|
128
128
|
var DialogFooter = ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: `${import_Dialog.default.footer} ${className || ""}`, ...props });
|
|
129
129
|
DialogFooter.displayName = "DialogFooter";
|
|
130
|
-
var DialogTitle =
|
|
130
|
+
var DialogTitle = (0, import_react2.forwardRef)(
|
|
131
131
|
({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
132
132
|
import_dialog.Dialog.Title,
|
|
133
133
|
{
|
|
@@ -138,7 +138,7 @@ var DialogTitle = React2.forwardRef(
|
|
|
138
138
|
)
|
|
139
139
|
);
|
|
140
140
|
DialogTitle.displayName = "DialogTitle";
|
|
141
|
-
var DialogDescription =
|
|
141
|
+
var DialogDescription = (0, import_react2.forwardRef)(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
142
142
|
import_dialog.Dialog.Description,
|
|
143
143
|
{
|
|
144
144
|
ref,
|
|
@@ -149,7 +149,7 @@ var DialogDescription = React2.forwardRef(({ className, ...props }, ref) => /* @
|
|
|
149
149
|
DialogDescription.displayName = "DialogDescription";
|
|
150
150
|
|
|
151
151
|
// src/components/shared/CustomQRCode/CustomQRCode.tsx
|
|
152
|
-
var
|
|
152
|
+
var import_react3 = require("react");
|
|
153
153
|
var import_qrcode = __toESM(require("qrcode"));
|
|
154
154
|
var import_CustomQRCode = __toESM(require("./CustomQRCode.module-JW3JU3FX.module.css"));
|
|
155
155
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
@@ -171,7 +171,7 @@ function QRCodeSVG({
|
|
|
171
171
|
}) {
|
|
172
172
|
const logoSize = clearArea ? 76 : 0;
|
|
173
173
|
const size = sizeProp - 10 * 2;
|
|
174
|
-
const dots = (0,
|
|
174
|
+
const dots = (0, import_react3.useMemo)(() => {
|
|
175
175
|
const dots2 = [];
|
|
176
176
|
const matrix = generateMatrix(value, ecl);
|
|
177
177
|
const cellSize = size / matrix.length;
|
|
@@ -402,12 +402,12 @@ var CustomQRCode_default = CustomQRCode;
|
|
|
402
402
|
var import_si = require("react-icons/si");
|
|
403
403
|
|
|
404
404
|
// src/components/shared/Collapsible/Collapsible.tsx
|
|
405
|
-
var React3 = __toESM(require("react"));
|
|
406
405
|
var import_collapsible = require("@base-ui/react/collapsible");
|
|
407
406
|
var import_Collapsible = __toESM(require("./Collapsible.module-F4VIL5FH.module.css"));
|
|
407
|
+
var import_react4 = require("react");
|
|
408
408
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
409
409
|
var Collapsible = import_collapsible.Collapsible.Root;
|
|
410
|
-
var CollapsibleTrigger =
|
|
410
|
+
var CollapsibleTrigger = (0, import_react4.forwardRef)(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
411
411
|
import_collapsible.Collapsible.Trigger,
|
|
412
412
|
{
|
|
413
413
|
ref,
|
|
@@ -416,7 +416,7 @@ var CollapsibleTrigger = React3.forwardRef(({ className, ...props }, ref) => /*
|
|
|
416
416
|
}
|
|
417
417
|
));
|
|
418
418
|
CollapsibleTrigger.displayName = "CollapsibleTrigger";
|
|
419
|
-
var CollapsibleContent =
|
|
419
|
+
var CollapsibleContent = (0, import_react4.forwardRef)(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
420
420
|
import_collapsible.Collapsible.Panel,
|
|
421
421
|
{
|
|
422
422
|
ref,
|
|
@@ -427,7 +427,7 @@ var CollapsibleContent = React3.forwardRef(({ className, ...props }, ref) => /*
|
|
|
427
427
|
CollapsibleContent.displayName = "CollapsibleContent";
|
|
428
428
|
|
|
429
429
|
// src/components/shared/Avatar/Avatar.tsx
|
|
430
|
-
var
|
|
430
|
+
var import_react5 = require("react");
|
|
431
431
|
var import_Avatar = __toESM(require("./Avatar.module-AACAT34D.module.css"));
|
|
432
432
|
var import_lucide_react2 = require("lucide-react");
|
|
433
433
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
@@ -438,7 +438,7 @@ function Avatar({
|
|
|
438
438
|
alt,
|
|
439
439
|
theme = "light"
|
|
440
440
|
}) {
|
|
441
|
-
const [hasError, setHasError] = (0,
|
|
441
|
+
const [hasError, setHasError] = (0, import_react5.useState)(false);
|
|
442
442
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: import_Avatar.default.avatar, "data-theme": theme, children: src && !hasError ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
443
443
|
"img",
|
|
444
444
|
{
|
|
@@ -463,29 +463,27 @@ function WalletModal(props) {
|
|
|
463
463
|
CN_Modal,
|
|
464
464
|
theme = "light",
|
|
465
465
|
open,
|
|
466
|
-
onOpenChange
|
|
467
|
-
walletConnectUri,
|
|
468
|
-
onClearWalletConnectUri
|
|
466
|
+
onOpenChange
|
|
469
467
|
} = props;
|
|
470
|
-
const { walletStatus: { status }, isConnecting, connectorId, connectors, connectWallet, disconnectWallet } = (0, import_connector.useConnector)();
|
|
471
|
-
const [connectingConnectorId, setConnectingConnectorId] = (0,
|
|
472
|
-
const [isOtherWalletsOpen, setIsOtherWalletsOpen] = (0,
|
|
473
|
-
const [errorConnectorId, setErrorConnectorId] = (0,
|
|
474
|
-
const [errorMessage, setErrorMessage] = (0,
|
|
475
|
-
const [copied, setCopied] = (0,
|
|
476
|
-
const isClient = (0,
|
|
468
|
+
const { walletConnectUri, clearWalletConnectUri, walletStatus: { status }, isConnecting, connectorId, connectors, connectWallet, disconnectWallet } = (0, import_connector.useConnector)();
|
|
469
|
+
const [connectingConnectorId, setConnectingConnectorId] = (0, import_react6.useState)(null);
|
|
470
|
+
const [isOtherWalletsOpen, setIsOtherWalletsOpen] = (0, import_react6.useState)(false);
|
|
471
|
+
const [errorConnectorId, setErrorConnectorId] = (0, import_react6.useState)(null);
|
|
472
|
+
const [errorMessage, setErrorMessage] = (0, import_react6.useState)(null);
|
|
473
|
+
const [copied, setCopied] = (0, import_react6.useState)(false);
|
|
474
|
+
const isClient = (0, import_react6.useSyncExternalStore)(
|
|
477
475
|
() => () => {
|
|
478
476
|
},
|
|
479
477
|
() => true,
|
|
480
478
|
() => false
|
|
481
479
|
);
|
|
482
|
-
const recentlyConnectedConnectorId = (0,
|
|
480
|
+
const recentlyConnectedConnectorId = (0, import_react6.useSyncExternalStore)(
|
|
483
481
|
() => () => {
|
|
484
482
|
},
|
|
485
483
|
() => localStorage.getItem("recentlyConnectedConnectorId"),
|
|
486
484
|
() => null
|
|
487
485
|
);
|
|
488
|
-
(0,
|
|
486
|
+
(0, import_react6.useEffect)(() => {
|
|
489
487
|
if (status === "connected" && connectorId) {
|
|
490
488
|
localStorage.setItem("recentlyConnectedConnectorId", connectorId);
|
|
491
489
|
}
|
|
@@ -493,7 +491,7 @@ function WalletModal(props) {
|
|
|
493
491
|
const walletConnectConnector = (_a = connectors.find((c) => c.name === "WalletConnect")) != null ? _a : null;
|
|
494
492
|
const isWalletConnectFlow = !!walletConnectConnector && (connectingConnectorId === walletConnectConnector.id || status === "connecting" && connectorId === walletConnectConnector.id) || !!walletConnectUri;
|
|
495
493
|
function cancelConnection() {
|
|
496
|
-
|
|
494
|
+
clearWalletConnectUri == null ? void 0 : clearWalletConnectUri();
|
|
497
495
|
setConnectingConnectorId(null);
|
|
498
496
|
disconnectWallet().catch(() => {
|
|
499
497
|
});
|
|
@@ -507,7 +505,7 @@ function WalletModal(props) {
|
|
|
507
505
|
setConnectingConnectorId(connector.id);
|
|
508
506
|
try {
|
|
509
507
|
if (connector.name === "WalletConnect") {
|
|
510
|
-
|
|
508
|
+
clearWalletConnectUri == null ? void 0 : clearWalletConnectUri();
|
|
511
509
|
}
|
|
512
510
|
await connectWallet(connector.id);
|
|
513
511
|
localStorage.setItem("recentlyConnectedConnectorId", connector.id);
|
|
@@ -845,14 +843,14 @@ var WalletModal_default2 = WalletModal_default;
|
|
|
845
843
|
var import_clsx4 = __toESM(require("clsx"));
|
|
846
844
|
|
|
847
845
|
// src/components/shared/Menu/Menu.tsx
|
|
848
|
-
var React4 = __toESM(require("react"));
|
|
849
846
|
var import_menu = require("@base-ui/react/menu");
|
|
850
847
|
var import_Menu = __toESM(require("./Menu.module-6ATSLATI.module.css"));
|
|
848
|
+
var import_react7 = require("react");
|
|
851
849
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
852
850
|
var Menu = import_menu.Menu.Root;
|
|
853
851
|
var MenuPortal = import_menu.Menu.Portal;
|
|
854
852
|
var MenuGroup = import_menu.Menu.Group;
|
|
855
|
-
var MenuTrigger =
|
|
853
|
+
var MenuTrigger = (0, import_react7.forwardRef)(
|
|
856
854
|
({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
857
855
|
import_menu.Menu.Trigger,
|
|
858
856
|
{
|
|
@@ -863,11 +861,11 @@ var MenuTrigger = React4.forwardRef(
|
|
|
863
861
|
)
|
|
864
862
|
);
|
|
865
863
|
MenuTrigger.displayName = "MenuTrigger";
|
|
866
|
-
var MenuPositioner =
|
|
864
|
+
var MenuPositioner = (0, import_react7.forwardRef)(
|
|
867
865
|
({ sideOffset = 8, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_menu.Menu.Positioner, { ref, sideOffset, ...props })
|
|
868
866
|
);
|
|
869
867
|
MenuPositioner.displayName = "MenuPositioner";
|
|
870
|
-
var MenuPopup =
|
|
868
|
+
var MenuPopup = (0, import_react7.forwardRef)(
|
|
871
869
|
({ className, theme, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
872
870
|
import_menu.Menu.Popup,
|
|
873
871
|
{
|
|
@@ -879,7 +877,7 @@ var MenuPopup = React4.forwardRef(
|
|
|
879
877
|
)
|
|
880
878
|
);
|
|
881
879
|
MenuPopup.displayName = "MenuPopup";
|
|
882
|
-
var MenuItem =
|
|
880
|
+
var MenuItem = (0, import_react7.forwardRef)(
|
|
883
881
|
({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
884
882
|
import_menu.Menu.Item,
|
|
885
883
|
{
|
|
@@ -890,11 +888,11 @@ var MenuItem = React4.forwardRef(
|
|
|
890
888
|
)
|
|
891
889
|
);
|
|
892
890
|
MenuItem.displayName = "MenuItem";
|
|
893
|
-
var MenuSeparator =
|
|
891
|
+
var MenuSeparator = (0, import_react7.forwardRef)(
|
|
894
892
|
({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_menu.Menu.Separator, { ref, className: `${import_Menu.default.separator} ${className || ""}`, ...props })
|
|
895
893
|
);
|
|
896
894
|
MenuSeparator.displayName = "MenuSeparator";
|
|
897
|
-
var MenuGroupLabel =
|
|
895
|
+
var MenuGroupLabel = (0, import_react7.forwardRef)(
|
|
898
896
|
({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_menu.Menu.GroupLabel, { ref, className: `${import_Menu.default.groupLabel} ${className || ""}`, ...props })
|
|
899
897
|
);
|
|
900
898
|
MenuGroupLabel.displayName = "MenuGroupLabel";
|
|
@@ -903,10 +901,10 @@ MenuGroupLabel.displayName = "MenuGroupLabel";
|
|
|
903
901
|
var import_lucide_react5 = require("lucide-react");
|
|
904
902
|
|
|
905
903
|
// src/components/WalletDropdown/WalletDropdown.tsx
|
|
906
|
-
var
|
|
904
|
+
var import_react8 = require("react");
|
|
907
905
|
var import_kit2 = require("@solana/kit");
|
|
908
906
|
var import_WalletDropdown = __toESM(require("./WalletDropdown.module-DOK7CUOQ.module.css"));
|
|
909
|
-
var
|
|
907
|
+
var import_react9 = require("motion/react");
|
|
910
908
|
var import_lucide_react4 = require("lucide-react");
|
|
911
909
|
var import_connector3 = require("@solana/connector");
|
|
912
910
|
var import_clsx3 = require("clsx");
|
|
@@ -945,7 +943,10 @@ async function getTokenBalance(client, pubkey, mintAddress) {
|
|
|
945
943
|
const pubkeyAddress = (0, import_connector2.address)(pubkey);
|
|
946
944
|
const mintPubkey = (0, import_connector2.address)(mintAddress);
|
|
947
945
|
const rpc = (0, import_kit.createSolanaRpc)(rpcUrl);
|
|
948
|
-
const mintInfo = await rpc.getAccountInfo(
|
|
946
|
+
const mintInfo = await rpc.getAccountInfo(
|
|
947
|
+
mintPubkey,
|
|
948
|
+
{ encoding: "base64" }
|
|
949
|
+
).send();
|
|
949
950
|
const ownerProgram = (_a = mintInfo.value) == null ? void 0 : _a.owner;
|
|
950
951
|
if (!ownerProgram) {
|
|
951
952
|
throw new Error("Failed to fetch mint account info");
|
|
@@ -961,7 +962,6 @@ async function getTokenBalance(client, pubkey, mintAddress) {
|
|
|
961
962
|
balance = parseFloat(tokenBalance.value.uiAmountString);
|
|
962
963
|
}
|
|
963
964
|
} catch (error) {
|
|
964
|
-
console.error("Error fetching token balance:", error);
|
|
965
965
|
} finally {
|
|
966
966
|
return balance;
|
|
967
967
|
}
|
|
@@ -978,23 +978,24 @@ var networkColor = {
|
|
|
978
978
|
function WalletDropdown(props) {
|
|
979
979
|
const client = (0, import_connector3.useConnectorClient)();
|
|
980
980
|
const {
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
theme,
|
|
986
|
-
allowNetworkSwitch,
|
|
987
|
-
showSolBalance,
|
|
981
|
+
CN_DropdownMenu,
|
|
982
|
+
theme = "light",
|
|
983
|
+
allowNetworkSwitch = true,
|
|
984
|
+
showSolBalance = true,
|
|
988
985
|
showDefaultToken
|
|
989
986
|
} = props;
|
|
990
|
-
const [view, setView] = (0,
|
|
991
|
-
const [copied, setCopied] = (0,
|
|
992
|
-
const
|
|
993
|
-
const
|
|
994
|
-
const
|
|
995
|
-
const
|
|
996
|
-
const [
|
|
997
|
-
const [
|
|
987
|
+
const [view, setView] = (0, import_react8.useState)("wallet");
|
|
988
|
+
const [copied, setCopied] = (0, import_react8.useState)(false);
|
|
989
|
+
const { account, connector } = (0, import_connector3.useConnector)();
|
|
990
|
+
const fetchingSolBalance = (0, import_react8.useRef)(false);
|
|
991
|
+
const [isFetchingBalance, setIsFetchingBalance] = (0, import_react8.useState)(false);
|
|
992
|
+
const fetchingDefaultToken = (0, import_react8.useRef)(false);
|
|
993
|
+
const [isFetchingDefaultTokenBalance, setIsFetchingDefaultTokenBalance] = (0, import_react8.useState)(false);
|
|
994
|
+
const [solBalance, setSolBalance] = (0, import_react8.useState)(null);
|
|
995
|
+
const [defaultTokenBalance, setDefaultTokenBalance] = (0, import_react8.useState)(null);
|
|
996
|
+
const selectedAccount = account || "";
|
|
997
|
+
const walletName = (connector == null ? void 0 : connector.name) || "Unknown Wallet";
|
|
998
|
+
const walletIcon = (connector == null ? void 0 : connector.icon) || void 0;
|
|
998
999
|
const shortAddress = `${selectedAccount.slice(0, 4)}...${selectedAccount.slice(-4)}`;
|
|
999
1000
|
async function handleCopy() {
|
|
1000
1001
|
try {
|
|
@@ -1029,7 +1030,7 @@ function WalletDropdown(props) {
|
|
|
1029
1030
|
setIsFetchingDefaultTokenBalance(false);
|
|
1030
1031
|
fetchingDefaultToken.current = false;
|
|
1031
1032
|
}
|
|
1032
|
-
(0,
|
|
1033
|
+
(0, import_react8.useEffect)(() => {
|
|
1033
1034
|
if (showSolBalance && selectedAccount && client) {
|
|
1034
1035
|
fetchSolBalance();
|
|
1035
1036
|
}
|
|
@@ -1039,13 +1040,13 @@ function WalletDropdown(props) {
|
|
|
1039
1040
|
}, [selectedAccount, client, showSolBalance, showDefaultToken]);
|
|
1040
1041
|
if (view === "wallet") {
|
|
1041
1042
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1042
|
-
|
|
1043
|
+
import_react9.motion.div,
|
|
1043
1044
|
{
|
|
1044
1045
|
initial: { opacity: 0 },
|
|
1045
1046
|
animate: { opacity: 1 },
|
|
1046
1047
|
exit: { opacity: 0 },
|
|
1047
1048
|
transition: { duration: 0.2 },
|
|
1048
|
-
className: (0, import_clsx3.clsx)(import_WalletDropdown.default.WalletDropdown,
|
|
1049
|
+
className: (0, import_clsx3.clsx)(import_WalletDropdown.default.WalletDropdown, CN_DropdownMenu),
|
|
1049
1050
|
"data-theme": theme,
|
|
1050
1051
|
children: [
|
|
1051
1052
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: import_WalletDropdown.default.Header, children: [
|
|
@@ -1184,13 +1185,13 @@ function WalletDropdown(props) {
|
|
|
1184
1185
|
}
|
|
1185
1186
|
if (view === "network") {
|
|
1186
1187
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1187
|
-
|
|
1188
|
+
import_react9.motion.div,
|
|
1188
1189
|
{
|
|
1189
1190
|
initial: { opacity: 0 },
|
|
1190
1191
|
animate: { opacity: 1 },
|
|
1191
1192
|
exit: { opacity: 0 },
|
|
1192
1193
|
transition: { duration: 0.2 },
|
|
1193
|
-
className: (0, import_clsx3.clsx)(import_WalletDropdown.default.WalletDropdown,
|
|
1194
|
+
className: (0, import_clsx3.clsx)(import_WalletDropdown.default.WalletDropdown, CN_DropdownMenu),
|
|
1194
1195
|
"data-theme": theme,
|
|
1195
1196
|
children: [
|
|
1196
1197
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: import_WalletDropdown.default.NetworkHeader, children: [
|
|
@@ -1213,7 +1214,7 @@ function WalletDropdown(props) {
|
|
|
1213
1214
|
{
|
|
1214
1215
|
render: ({ cluster, clusters, setCluster }) => {
|
|
1215
1216
|
const currentClusterId = (cluster == null ? void 0 : cluster.id) || "solana:mainnet";
|
|
1216
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: import_WalletDropdown.default.networkOptions, children: clusters.map((network
|
|
1217
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: import_WalletDropdown.default.networkOptions, children: clusters.map((network) => {
|
|
1217
1218
|
const isSelected = currentClusterId === network.id;
|
|
1218
1219
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1219
1220
|
"div",
|
|
@@ -1270,7 +1271,7 @@ function ConnectButton(props) {
|
|
|
1270
1271
|
showSolBalance = false,
|
|
1271
1272
|
showDefaultToken
|
|
1272
1273
|
} = props;
|
|
1273
|
-
const [isModalOpen, setIsModalOpen] = (0,
|
|
1274
|
+
const [isModalOpen, setIsModalOpen] = (0, import_react10.useState)(false);
|
|
1274
1275
|
const { isConnected, isConnecting, account, connector, walletConnectUri, clearWalletConnectUri } = (0, import_connector4.useConnector)();
|
|
1275
1276
|
if (isConnected && account && connector) {
|
|
1276
1277
|
const shortAddress = `${account.slice(0, 4)}...${account.slice(-4)}`;
|
|
@@ -1302,10 +1303,7 @@ function ConnectButton(props) {
|
|
|
1302
1303
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(MenuPortal, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(MenuPositioner, { sideOffset: 8, align: "end", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(MenuPopup, { theme, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1303
1304
|
WalletDropdown_default2,
|
|
1304
1305
|
{
|
|
1305
|
-
|
|
1306
|
-
selectedAccount: account,
|
|
1307
|
-
walletIcon,
|
|
1308
|
-
walletName: connector.name,
|
|
1306
|
+
CN_DropdownMenu,
|
|
1309
1307
|
allowNetworkSwitch: true,
|
|
1310
1308
|
theme,
|
|
1311
1309
|
showSolBalance,
|
|
@@ -1340,9 +1338,7 @@ function ConnectButton(props) {
|
|
|
1340
1338
|
{
|
|
1341
1339
|
theme,
|
|
1342
1340
|
open: isModalOpen,
|
|
1343
|
-
onOpenChange
|
|
1344
|
-
walletConnectUri,
|
|
1345
|
-
onClearWalletConnectUri: clearWalletConnectUri
|
|
1341
|
+
onOpenChange
|
|
1346
1342
|
}
|
|
1347
1343
|
)
|
|
1348
1344
|
] });
|