@phantom/react-sdk 1.0.0-beta.22 → 1.0.0-beta.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/PhantomProvider.tsx
2
- import { useState as useState7, useEffect as useEffect4, useMemo as useMemo3 } from "react";
2
+ import { useState as useState8, useEffect as useEffect5, useMemo as useMemo3 } from "react";
3
3
  import { BrowserSDK } from "@phantom/browser-sdk";
4
4
  import { mergeTheme, darkTheme, ThemeProvider } from "@phantom/wallet-sdk-ui";
5
5
 
@@ -15,7 +15,7 @@ function usePhantom() {
15
15
  }
16
16
 
17
17
  // src/ModalProvider.tsx
18
- import { useState as useState6, useCallback as useCallback4, useMemo as useMemo2 } from "react";
18
+ import { useState as useState7, useCallback as useCallback5, useMemo as useMemo2 } from "react";
19
19
 
20
20
  // src/ModalContext.ts
21
21
  import { createContext as createContext2, useContext as useContext2 } from "react";
@@ -37,9 +37,22 @@ import { isMobileDevice as isMobileDevice2 } from "@phantom/browser-sdk";
37
37
  import { Modal } from "@phantom/wallet-sdk-ui";
38
38
 
39
39
  // src/components/ConnectModalContent.tsx
40
- import { useState as useState3, useCallback as useCallback2, useMemo } from "react";
41
- import { isMobileDevice, getDeeplinkToPhantom } from "@phantom/browser-sdk";
42
- import { Button, LoginWithPhantomButton, Icon, BoundedIcon, Text, hexToRgba, useTheme } from "@phantom/wallet-sdk-ui";
40
+ import { useState as useState4, useCallback as useCallback3, useMemo } from "react";
41
+ import {
42
+ isMobileDevice,
43
+ getDeeplinkToPhantom
44
+ } from "@phantom/browser-sdk";
45
+ import {
46
+ Button,
47
+ LoginWithPhantomButton,
48
+ Icon as Icon2,
49
+ BoundedIcon,
50
+ Text,
51
+ hexToRgba,
52
+ useTheme as useTheme2,
53
+ ModalHeader
54
+ } from "@phantom/wallet-sdk-ui";
55
+ import { getProviderName } from "@phantom/constants";
43
56
 
44
57
  // src/hooks/useIsExtensionInstalled.ts
45
58
  import * as React from "react";
@@ -134,38 +147,154 @@ function useConnect() {
134
147
  };
135
148
  }
136
149
 
150
+ // src/hooks/useDiscoveredWallets.ts
151
+ import { useCallback as useCallback2, useState as useState3, useEffect as useEffect3 } from "react";
152
+ function useDiscoveredWallets() {
153
+ const { sdk } = usePhantom();
154
+ const [wallets, setWallets] = useState3([]);
155
+ const [isLoading, setIsLoading] = useState3(true);
156
+ const [error, setError] = useState3(null);
157
+ const refetch = useCallback2(async () => {
158
+ if (!sdk) {
159
+ setWallets([]);
160
+ setError(null);
161
+ setIsLoading(false);
162
+ return;
163
+ }
164
+ try {
165
+ setIsLoading(true);
166
+ setError(null);
167
+ const initialWallets = sdk.getDiscoveredWallets();
168
+ if (initialWallets.length > 0) {
169
+ setWallets(initialWallets);
170
+ setIsLoading(false);
171
+ } else {
172
+ await sdk.discoverWallets();
173
+ const discoveredWallets = sdk.getDiscoveredWallets();
174
+ setWallets(discoveredWallets);
175
+ setIsLoading(false);
176
+ }
177
+ } catch (err) {
178
+ const error2 = err instanceof Error ? err : new Error("Failed to fetch discovered wallets");
179
+ setError(error2);
180
+ setWallets([]);
181
+ setIsLoading(false);
182
+ }
183
+ }, [sdk]);
184
+ useEffect3(() => {
185
+ refetch();
186
+ }, [refetch]);
187
+ return {
188
+ wallets,
189
+ isLoading,
190
+ error,
191
+ refetch
192
+ };
193
+ }
194
+
195
+ // src/components/ChainIcon.tsx
196
+ import { Icon, useTheme } from "@phantom/wallet-sdk-ui";
197
+ import { jsx } from "react/jsx-runtime";
198
+ var IconWrapper = ({ children }) => {
199
+ const theme = useTheme();
200
+ return /* @__PURE__ */ jsx(
201
+ "span",
202
+ {
203
+ style: {
204
+ display: "inline-flex",
205
+ alignItems: "center",
206
+ justifyContent: "center",
207
+ borderRadius: "4px",
208
+ backgroundColor: theme.aux,
209
+ color: theme.text,
210
+ padding: "2px"
211
+ },
212
+ children
213
+ }
214
+ );
215
+ };
216
+ function ChainIcon({ addressType, size = 8 }) {
217
+ const theme = useTheme();
218
+ const type = addressType.toLowerCase();
219
+ if (type.includes("solana")) {
220
+ return /* @__PURE__ */ jsx(IconWrapper, { children: /* @__PURE__ */ jsx(Icon, { type: "solana", size, color: theme.text }) });
221
+ }
222
+ if (type.includes("ethereum") || type.includes("evm")) {
223
+ return /* @__PURE__ */ jsx(IconWrapper, { children: /* @__PURE__ */ jsx(Icon, { type: "ethereum", size, color: theme.text }) });
224
+ }
225
+ if (type.includes("bitcoin")) {
226
+ return /* @__PURE__ */ jsx(IconWrapper, { children: /* @__PURE__ */ jsx(Icon, { type: "bitcoin", size, color: theme.text }) });
227
+ }
228
+ if (type.includes("sui")) {
229
+ return /* @__PURE__ */ jsx(IconWrapper, { children: /* @__PURE__ */ jsx(Icon, { type: "sui", size, color: theme.text }) });
230
+ }
231
+ return /* @__PURE__ */ jsx(
232
+ "span",
233
+ {
234
+ style: {
235
+ display: "inline-flex",
236
+ alignItems: "center",
237
+ justifyContent: "center",
238
+ borderRadius: "4px",
239
+ backgroundColor: theme.aux,
240
+ color: theme.text,
241
+ fontSize: "6px",
242
+ fontWeight: "bold",
243
+ lineHeight: "1",
244
+ padding: "2px"
245
+ },
246
+ title: addressType,
247
+ children: addressType.charAt(0).toUpperCase()
248
+ }
249
+ );
250
+ }
251
+
137
252
  // src/components/ConnectModalContent.tsx
138
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
253
+ import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
139
254
  function ConnectModalContent({ appIcon, appName = "App Name", onClose }) {
140
- const theme = useTheme();
255
+ const theme = useTheme2();
141
256
  const { isLoading, allowedProviders } = usePhantom();
142
257
  const baseConnect = useConnect();
143
258
  const isExtensionInstalled = useIsExtensionInstalled();
144
259
  const isPhantomLoginAvailable2 = useIsPhantomLoginAvailable();
145
260
  const isMobile = useMemo(() => isMobileDevice(), []);
146
- const [isConnecting, setIsConnecting] = useState3(false);
147
- const [error, setError] = useState3(null);
148
- const [providerType, setProviderType] = useState3(null);
261
+ const { wallets: discoveredWallets } = useDiscoveredWallets();
262
+ const [isConnecting, setIsConnecting] = useState4(false);
263
+ const [error, setError] = useState4(null);
264
+ const [providerType, setProviderType] = useState4(null);
265
+ const [showOtherWallets, setShowOtherWallets] = useState4(false);
266
+ const [selectedWalletId, setSelectedWalletId] = useState4(null);
149
267
  const showDivider = !(allowedProviders.length === 1 && allowedProviders.includes("injected"));
150
- const connectWithAuthProvider = useCallback2(
151
- async (provider) => {
268
+ const shouldShowOtherWalletsButton = discoveredWallets.length > 2;
269
+ const walletsToShowInline = shouldShowOtherWalletsButton ? [] : discoveredWallets;
270
+ const connectWithAuthProvider = useCallback3(
271
+ async (provider, walletId) => {
152
272
  try {
153
273
  setIsConnecting(true);
154
274
  setError(null);
155
275
  setProviderType(provider);
156
- await baseConnect.connect({ provider });
276
+ setSelectedWalletId(walletId || null);
277
+ await baseConnect.connect({ provider, walletId });
157
278
  onClose();
158
- } catch (err) {
159
- const error2 = err instanceof Error ? err : new Error(String(err));
160
- setError(error2);
279
+ } catch {
280
+ const wallet = discoveredWallets.find((w) => w.id === walletId);
281
+ const providerName = wallet?.name || getProviderName(provider);
282
+ setError(`Failed to connect to ${providerName}`);
161
283
  } finally {
162
284
  setIsConnecting(false);
163
285
  setProviderType(null);
286
+ setSelectedWalletId(null);
164
287
  }
165
288
  },
166
- [baseConnect, onClose]
289
+ [baseConnect, discoveredWallets, onClose]
290
+ );
291
+ const connectWithWallet = useCallback3(
292
+ async (wallet) => {
293
+ await connectWithAuthProvider("injected", wallet.id);
294
+ },
295
+ [connectWithAuthProvider]
167
296
  );
168
- const connectWithDeeplink = useCallback2(() => {
297
+ const connectWithDeeplink = useCallback3(() => {
169
298
  try {
170
299
  setIsConnecting(true);
171
300
  setError(null);
@@ -173,9 +302,8 @@ function ConnectModalContent({ appIcon, appName = "App Name", onClose }) {
173
302
  const deeplinkUrl = getDeeplinkToPhantom();
174
303
  window.location.href = deeplinkUrl;
175
304
  onClose();
176
- } catch (err) {
177
- const error2 = err instanceof Error ? err : new Error(String(err));
178
- setError(error2);
305
+ } catch {
306
+ setError("Failed to open deeplink");
179
307
  } finally {
180
308
  setIsConnecting(false);
181
309
  setProviderType(null);
@@ -186,25 +314,32 @@ function ConnectModalContent({ appIcon, appName = "App Name", onClose }) {
186
314
  height: "56px",
187
315
  borderRadius: "50%",
188
316
  display: "block",
189
- objectFit: "cover"
317
+ objectFit: "cover",
318
+ marginBottom: "12px"
190
319
  };
191
- const buttonContainerStyle = {
320
+ const connectContentContainerStyle = {
321
+ transition: "opacity 0.15s ease-in-out, transform 0.15s ease-in-out",
192
322
  display: "flex",
193
323
  flexDirection: "column",
194
324
  alignItems: "center",
195
325
  gap: "12px",
196
- width: "100%"
326
+ padding: "0 32px"
197
327
  };
198
- const socialButtonRowStyle = {
328
+ const otherWalletsContainerStyle = {
199
329
  display: "flex",
330
+ flexDirection: "column",
331
+ alignItems: "center",
200
332
  gap: "12px",
201
- width: "100%"
333
+ maxHeight: "480px",
334
+ overflowY: "auto",
335
+ padding: "0 32px 32px 32px",
336
+ transition: "opacity 0.15s ease-in-out, transform 0.15s ease-in-out"
202
337
  };
203
338
  const dividerStyle = {
204
339
  display: "flex",
205
340
  alignItems: "center",
206
341
  width: "100%",
207
- margin: "24px 0",
342
+ margin: "12px 0",
208
343
  ...theme.typography.caption,
209
344
  color: theme.secondary,
210
345
  textTransform: "uppercase"
@@ -222,6 +357,7 @@ function ConnectModalContent({ appIcon, appName = "App Name", onClose }) {
222
357
  color: "#ff6b6b",
223
358
  border: "1px solid rgba(220, 53, 69, 0.3)",
224
359
  borderRadius: theme.borderRadius,
360
+ boxSizing: "border-box",
225
361
  padding: "12px",
226
362
  width: "100%",
227
363
  fontSize: "14px"
@@ -242,108 +378,214 @@ function ConnectModalContent({ appIcon, appName = "App Name", onClose }) {
242
378
  borderRadius: "50%",
243
379
  animation: "spin 1s linear infinite"
244
380
  };
245
- return /* @__PURE__ */ jsxs(Fragment, { children: [
246
- /* @__PURE__ */ jsx("style", { children: `
381
+ const walletIconStyle = {
382
+ width: "32px",
383
+ height: "32px",
384
+ borderRadius: "8px",
385
+ objectFit: "cover"
386
+ };
387
+ const walletButtonContentStyle = {
388
+ display: "flex",
389
+ alignItems: "center",
390
+ justifyContent: "space-between",
391
+ gap: "8px",
392
+ width: "100%"
393
+ };
394
+ const walletButtonLeftStyle = {
395
+ display: "flex",
396
+ alignItems: "center",
397
+ gap: "8px",
398
+ flex: 1
399
+ };
400
+ const walletNameContainerStyle = {
401
+ display: "flex",
402
+ flexDirection: "column",
403
+ gap: "4px",
404
+ alignItems: "flex-start"
405
+ };
406
+ const chainIndicatorsStyle = {
407
+ display: "flex",
408
+ alignItems: "center",
409
+ gap: "4px"
410
+ };
411
+ const walletButtonRightStyle = {
412
+ display: "flex",
413
+ alignItems: "center",
414
+ gap: "8px",
415
+ color: theme.secondary
416
+ };
417
+ const footerStyle = {
418
+ display: "flex",
419
+ padding: "16px",
420
+ justifyContent: "center",
421
+ alignItems: "center",
422
+ gap: "4px",
423
+ borderTop: "1px solid rgba(152, 151, 156, 0.10)",
424
+ ...theme.typography.caption,
425
+ color: theme.secondary
426
+ };
427
+ const contentWrapperStyle = {
428
+ display: "flex",
429
+ flexDirection: "column",
430
+ justifyContent: "space-between",
431
+ gap: "24px"
432
+ };
433
+ return /* @__PURE__ */ jsxs("div", { style: contentWrapperStyle, children: [
434
+ /* @__PURE__ */ jsx2("style", { children: `
247
435
  @keyframes spin {
248
436
  0% { transform: rotate(0deg); }
249
437
  100% { transform: rotate(360deg); }
250
438
  }
251
439
  ` }),
252
- appIcon && /* @__PURE__ */ jsx("img", { src: appIcon, alt: appName, style: appIconStyle }),
253
- error && /* @__PURE__ */ jsx("div", { style: errorStyle, children: error.message }),
254
440
  isLoading ? /* @__PURE__ */ jsxs("div", { style: loadingContainerStyle, children: [
255
- /* @__PURE__ */ jsx("div", { style: spinnerStyle }),
256
- /* @__PURE__ */ jsx(Text, { variant: "label", color: theme.secondary, children: "Loading..." })
257
- ] }) : /* @__PURE__ */ jsxs("div", { style: buttonContainerStyle, children: [
258
- isMobile && !isExtensionInstalled.isInstalled && /* @__PURE__ */ jsx(
259
- Button,
260
- {
261
- onClick: connectWithDeeplink,
262
- disabled: isConnecting,
263
- isLoading: isConnecting && providerType === "deeplink",
264
- fullWidth: true,
265
- children: isConnecting && providerType === "deeplink" ? "Opening Phantom..." : "Open in Phantom App"
266
- }
267
- ),
268
- !isMobile && allowedProviders.includes("phantom") && isPhantomLoginAvailable2.isAvailable && /* @__PURE__ */ jsx(
269
- LoginWithPhantomButton,
441
+ /* @__PURE__ */ jsx2("div", { style: spinnerStyle }),
442
+ /* @__PURE__ */ jsx2(Text, { variant: "label", color: theme.secondary, children: "Loading..." })
443
+ ] }) : showOtherWallets ? /* @__PURE__ */ jsxs(Fragment, { children: [
444
+ /* @__PURE__ */ jsx2(
445
+ ModalHeader,
270
446
  {
271
- onClick: () => connectWithAuthProvider("phantom"),
272
- disabled: isConnecting,
273
- isLoading: isConnecting && providerType === "phantom"
447
+ goBack: true,
448
+ onGoBack: () => {
449
+ setError(null);
450
+ setShowOtherWallets(false);
451
+ },
452
+ title: "Other Wallets",
453
+ onClose
274
454
  }
275
455
  ),
276
- (allowedProviders.includes("google") || allowedProviders.includes("apple")) && /* @__PURE__ */ jsxs("div", { style: socialButtonRowStyle, children: [
277
- allowedProviders.includes("google") && /* @__PURE__ */ jsxs(
456
+ /* @__PURE__ */ jsxs("div", { style: otherWalletsContainerStyle, children: [
457
+ error && /* @__PURE__ */ jsx2("div", { style: errorStyle, children: error }),
458
+ discoveredWallets.map((wallet) => /* @__PURE__ */ jsx2(
278
459
  Button,
279
460
  {
280
- onClick: () => connectWithAuthProvider("google"),
461
+ onClick: () => connectWithWallet(wallet),
281
462
  disabled: isConnecting,
282
- isLoading: isConnecting && providerType === "google",
463
+ isLoading: isConnecting && providerType === "injected" && selectedWalletId === wallet.id,
464
+ fullWidth: true,
465
+ children: /* @__PURE__ */ jsxs("span", { style: walletButtonContentStyle, children: [
466
+ /* @__PURE__ */ jsxs("span", { style: walletButtonLeftStyle, children: [
467
+ wallet.id === "phantom" ? /* @__PURE__ */ jsx2(BoundedIcon, { type: "phantom", size: 20, background: "#aba0f2", color: "white" }) : wallet.icon ? /* @__PURE__ */ jsx2("img", { src: wallet.icon, alt: wallet.name, style: walletIconStyle }) : /* @__PURE__ */ jsx2(BoundedIcon, { type: "wallet", size: 20, background: theme.aux, color: theme.text }),
468
+ /* @__PURE__ */ jsx2("span", { style: walletNameContainerStyle, children: /* @__PURE__ */ jsx2(Text, { variant: "captionBold", children: wallet.name }) })
469
+ ] }),
470
+ /* @__PURE__ */ jsxs("span", { style: walletButtonRightStyle, children: [
471
+ wallet.addressTypes && wallet.addressTypes.length > 0 && /* @__PURE__ */ jsx2("span", { style: chainIndicatorsStyle, children: wallet.addressTypes.map((addressType) => /* @__PURE__ */ jsx2("span", { children: /* @__PURE__ */ jsx2(ChainIcon, { addressType, size: 8 }) }, `${wallet.id}-chain-${addressType}`)) }),
472
+ /* @__PURE__ */ jsx2(Icon2, { type: "chevron-right", size: 16, color: theme.secondary })
473
+ ] })
474
+ ] })
475
+ },
476
+ wallet.id
477
+ ))
478
+ ] })
479
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
480
+ /* @__PURE__ */ jsx2(ModalHeader, { title: "Login or Sign Up", onClose }),
481
+ /* @__PURE__ */ jsxs("div", { style: connectContentContainerStyle, children: [
482
+ appIcon && /* @__PURE__ */ jsx2("img", { src: appIcon, alt: appName, style: appIconStyle }),
483
+ error && /* @__PURE__ */ jsx2("div", { style: errorStyle, children: error }),
484
+ isMobile && !isExtensionInstalled.isInstalled && /* @__PURE__ */ jsx2(
485
+ Button,
486
+ {
487
+ onClick: connectWithDeeplink,
488
+ disabled: isConnecting,
489
+ isLoading: isConnecting && providerType === "deeplink",
283
490
  fullWidth: true,
284
- centered: allowedProviders.includes("apple"),
285
- children: [
286
- /* @__PURE__ */ jsx(Icon, { type: "google", size: 20 }),
287
- !allowedProviders.includes("apple") && /* @__PURE__ */ jsx(Text, { variant: "captionBold", children: "Continue with Google" })
288
- ]
491
+ children: isConnecting && providerType === "deeplink" ? "Opening Phantom..." : "Open in Phantom App"
492
+ }
493
+ ),
494
+ !isMobile && allowedProviders.includes("phantom") && isPhantomLoginAvailable2.isAvailable && /* @__PURE__ */ jsx2(
495
+ LoginWithPhantomButton,
496
+ {
497
+ onClick: () => connectWithAuthProvider("phantom"),
498
+ disabled: isConnecting,
499
+ isLoading: isConnecting && providerType === "phantom"
289
500
  }
290
501
  ),
291
- allowedProviders.includes("apple") && /* @__PURE__ */ jsxs(
502
+ allowedProviders.includes("google") && /* @__PURE__ */ jsx2(
292
503
  Button,
293
504
  {
294
- onClick: () => connectWithAuthProvider("apple"),
505
+ onClick: () => connectWithAuthProvider("google"),
295
506
  disabled: isConnecting,
296
- isLoading: isConnecting && providerType === "apple",
507
+ isLoading: isConnecting && providerType === "google",
297
508
  fullWidth: true,
298
- centered: allowedProviders.includes("google"),
299
- children: [
300
- /* @__PURE__ */ jsx(Icon, { type: "apple", size: 20 }),
301
- !allowedProviders.includes("google") && /* @__PURE__ */ jsx(Text, { variant: "captionBold", children: "Continue with Apple" })
302
- ]
509
+ children: /* @__PURE__ */ jsxs("span", { style: walletButtonContentStyle, children: [
510
+ /* @__PURE__ */ jsxs("span", { style: walletButtonLeftStyle, children: [
511
+ /* @__PURE__ */ jsx2(Icon2, { type: "google", size: 20 }),
512
+ /* @__PURE__ */ jsx2(Text, { variant: "captionBold", children: "Continue with Google" })
513
+ ] }),
514
+ /* @__PURE__ */ jsx2("span", { style: walletButtonRightStyle, children: /* @__PURE__ */ jsx2(Icon2, { type: "chevron-right", size: 16, color: theme.secondary }) })
515
+ ] })
303
516
  }
304
- )
305
- ] }),
306
- !isMobile && allowedProviders.includes("injected") && isExtensionInstalled.isInstalled && /* @__PURE__ */ jsxs(Fragment, { children: [
307
- showDivider && /* @__PURE__ */ jsxs("div", { style: dividerStyle, children: [
308
- /* @__PURE__ */ jsx("div", { style: dividerLineStyle }),
309
- /* @__PURE__ */ jsx("span", { style: dividerTextStyle, children: "OR" }),
310
- /* @__PURE__ */ jsx("div", { style: dividerLineStyle })
311
- ] }),
312
- /* @__PURE__ */ jsx(
517
+ ),
518
+ allowedProviders.includes("apple") && /* @__PURE__ */ jsx2(
313
519
  Button,
314
520
  {
315
- onClick: () => connectWithAuthProvider("injected"),
521
+ onClick: () => connectWithAuthProvider("apple"),
316
522
  disabled: isConnecting,
317
- isLoading: isConnecting && providerType === "injected",
523
+ isLoading: isConnecting && providerType === "apple",
318
524
  fullWidth: true,
319
- children: /* @__PURE__ */ jsxs("span", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: "8px" }, children: [
320
- /* @__PURE__ */ jsxs("span", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
321
- /* @__PURE__ */ jsx(BoundedIcon, { type: "phantom", size: 20, background: "#AB9FF2", color: "white" }),
322
- /* @__PURE__ */ jsx(Text, { variant: "captionBold", children: "Phantom" })
525
+ children: /* @__PURE__ */ jsxs("span", { style: walletButtonContentStyle, children: [
526
+ /* @__PURE__ */ jsxs("span", { style: walletButtonLeftStyle, children: [
527
+ /* @__PURE__ */ jsx2(Icon2, { type: "apple", size: 20 }),
528
+ /* @__PURE__ */ jsx2(Text, { variant: "captionBold", children: "Continue with Apple" })
323
529
  ] }),
324
- /* @__PURE__ */ jsxs("span", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
325
- /* @__PURE__ */ jsx(Text, { variant: "label", color: theme.secondary, children: "Detected" }),
326
- /* @__PURE__ */ jsx(Icon, { type: "chevron-right", size: 16 })
327
- ] })
530
+ /* @__PURE__ */ jsx2("span", { style: walletButtonRightStyle, children: /* @__PURE__ */ jsx2(Icon2, { type: "chevron-right", size: 16, color: theme.secondary }) })
328
531
  ] })
329
532
  }
330
- )
533
+ ),
534
+ !isMobile && allowedProviders.includes("injected") && isExtensionInstalled.isInstalled && /* @__PURE__ */ jsxs(Fragment, { children: [
535
+ showDivider && /* @__PURE__ */ jsxs("div", { style: dividerStyle, children: [
536
+ /* @__PURE__ */ jsx2("div", { style: dividerLineStyle }),
537
+ /* @__PURE__ */ jsx2("span", { style: dividerTextStyle, children: "OR" }),
538
+ /* @__PURE__ */ jsx2("div", { style: dividerLineStyle })
539
+ ] }),
540
+ walletsToShowInline.map((wallet) => /* @__PURE__ */ jsx2(
541
+ Button,
542
+ {
543
+ onClick: () => connectWithWallet(wallet),
544
+ disabled: isConnecting,
545
+ isLoading: isConnecting && providerType === "injected" && selectedWalletId === wallet.id,
546
+ fullWidth: true,
547
+ children: /* @__PURE__ */ jsxs("span", { style: walletButtonContentStyle, children: [
548
+ /* @__PURE__ */ jsxs("span", { style: walletButtonLeftStyle, children: [
549
+ wallet.id === "phantom" ? /* @__PURE__ */ jsx2(BoundedIcon, { type: "phantom", size: 20, background: "#aba0f2", color: "white" }) : wallet.icon ? /* @__PURE__ */ jsx2("img", { src: wallet.icon, alt: wallet.name, style: walletIconStyle }) : /* @__PURE__ */ jsx2(BoundedIcon, { type: "wallet", size: 10, background: theme.aux, color: theme.text }),
550
+ /* @__PURE__ */ jsx2("span", { style: walletNameContainerStyle, children: /* @__PURE__ */ jsx2(Text, { variant: "captionBold", children: wallet.name }) })
551
+ ] }),
552
+ /* @__PURE__ */ jsxs("span", { style: walletButtonRightStyle, children: [
553
+ wallet.addressTypes && wallet.addressTypes.length > 0 && /* @__PURE__ */ jsx2("span", { style: chainIndicatorsStyle, children: wallet.addressTypes.map((addressType) => /* @__PURE__ */ jsx2("span", { children: /* @__PURE__ */ jsx2(ChainIcon, { addressType, size: 8 }) }, `${wallet.id}-chain-${addressType}`)) }),
554
+ /* @__PURE__ */ jsx2(Icon2, { type: "chevron-right", size: 16, color: theme.secondary })
555
+ ] })
556
+ ] })
557
+ },
558
+ wallet.id
559
+ )),
560
+ shouldShowOtherWalletsButton && /* @__PURE__ */ jsx2(Button, { onClick: () => setShowOtherWallets(true), disabled: isConnecting, fullWidth: true, children: /* @__PURE__ */ jsxs("span", { style: walletButtonContentStyle, children: [
561
+ /* @__PURE__ */ jsxs("span", { style: walletButtonLeftStyle, children: [
562
+ /* @__PURE__ */ jsx2(BoundedIcon, { type: "wallet", size: 20, background: theme.aux, color: theme.text }),
563
+ /* @__PURE__ */ jsx2(Text, { variant: "captionBold", children: "Other Wallets" })
564
+ ] }),
565
+ /* @__PURE__ */ jsx2("span", { style: walletButtonRightStyle, children: /* @__PURE__ */ jsx2(Icon2, { type: "chevron-right", size: 16, color: theme.secondary }) })
566
+ ] }) })
567
+ ] })
568
+ ] }),
569
+ /* @__PURE__ */ jsxs("div", { style: footerStyle, children: [
570
+ /* @__PURE__ */ jsx2(Text, { variant: "label", color: theme.secondary, children: "Powered by" }),
571
+ /* @__PURE__ */ jsx2(Icon2, { type: "phantom", size: 16 }),
572
+ /* @__PURE__ */ jsx2(Text, { variant: "label", color: theme.secondary, children: "Phantom" })
331
573
  ] })
332
574
  ] })
333
575
  ] });
334
576
  }
335
577
 
336
578
  // src/components/ConnectedModalContent.tsx
337
- import { useState as useState5, useEffect as useEffect3 } from "react";
338
- import { Button as Button2, Text as Text2, useTheme as useTheme2 } from "@phantom/wallet-sdk-ui";
579
+ import { useState as useState6, useEffect as useEffect4 } from "react";
580
+ import { Button as Button2, Text as Text2, useTheme as useTheme3, ModalHeader as ModalHeader2 } from "@phantom/wallet-sdk-ui";
339
581
 
340
582
  // src/hooks/useDisconnect.ts
341
- import { useCallback as useCallback3, useState as useState4 } from "react";
583
+ import { useCallback as useCallback4, useState as useState5 } from "react";
342
584
  function useDisconnect() {
343
585
  const { sdk } = usePhantom();
344
- const [isDisconnecting, setIsDisconnecting] = useState4(false);
345
- const [error, setError] = useState4(null);
346
- const disconnect = useCallback3(async () => {
586
+ const [isDisconnecting, setIsDisconnecting] = useState5(false);
587
+ const [error, setError] = useState5(null);
588
+ const disconnect = useCallback4(async () => {
347
589
  if (!sdk) {
348
590
  throw new Error("SDK not initialized");
349
591
  }
@@ -367,14 +609,14 @@ function useDisconnect() {
367
609
  }
368
610
 
369
611
  // src/components/ConnectedModalContent.tsx
370
- import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
612
+ import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
371
613
  function ConnectedModalContent({ onClose }) {
372
- const theme = useTheme2();
614
+ const theme = useTheme3();
373
615
  const { addresses } = usePhantom();
374
616
  const { disconnect } = useDisconnect();
375
- const [isDisconnecting, setIsDisconnecting] = useState5(false);
376
- const [disconnectError, setDisconnectError] = useState5(null);
377
- useEffect3(() => {
617
+ const [isDisconnecting, setIsDisconnecting] = useState6(false);
618
+ const [disconnectError, setDisconnectError] = useState6(null);
619
+ useEffect4(() => {
378
620
  setDisconnectError(null);
379
621
  }, []);
380
622
  const handleDisconnect = async () => {
@@ -394,45 +636,81 @@ function ConnectedModalContent({ onClose }) {
394
636
  display: "flex",
395
637
  flexDirection: "column",
396
638
  gap: "16px",
397
- width: "100%"
639
+ width: "100%",
640
+ minWidth: 0,
641
+ boxSizing: "border-box"
398
642
  };
399
643
  const accountItemStyle = {
400
644
  display: "flex",
401
645
  flexDirection: "column",
402
646
  gap: "8px",
403
- width: "100%"
647
+ width: "100%",
648
+ minWidth: 0,
649
+ boxSizing: "border-box"
404
650
  };
405
651
  const addressTextStyle = {
406
652
  fontFamily: "monospace",
407
- wordBreak: "break-all"
653
+ wordBreak: "break-all",
654
+ overflowWrap: "break-word",
655
+ minWidth: 0
408
656
  };
409
657
  const errorContainerStyle = {
410
658
  padding: "12px",
411
659
  backgroundColor: "rgba(220, 53, 69, 0.1)",
412
660
  borderRadius: theme.borderRadius,
413
661
  border: "1px solid rgba(220, 53, 69, 0.3)",
414
- width: "100%"
662
+ width: "100%",
663
+ boxSizing: "border-box",
664
+ minWidth: 0
415
665
  };
416
- return /* @__PURE__ */ jsxs2(Fragment2, { children: [
417
- addresses && addresses.length > 0 && /* @__PURE__ */ jsx2("div", { style: accountListStyle, children: addresses.map((account, index) => /* @__PURE__ */ jsxs2("div", { style: accountItemStyle, children: [
418
- /* @__PURE__ */ jsx2(Text2, { variant: "label", color: theme.secondary, style: { textTransform: "uppercase" }, children: account.addressType }),
419
- /* @__PURE__ */ jsx2("div", { style: addressTextStyle, children: /* @__PURE__ */ jsx2(Text2, { variant: "caption", children: account.address }) })
420
- ] }, index)) }),
421
- disconnectError && /* @__PURE__ */ jsx2("div", { style: errorContainerStyle, children: /* @__PURE__ */ jsx2(Text2, { variant: "caption", color: theme.error, children: "Failed to disconnect" }) }),
422
- /* @__PURE__ */ jsx2(Button2, { onClick: handleDisconnect, disabled: isDisconnecting, isLoading: isDisconnecting, fullWidth: true, children: /* @__PURE__ */ jsx2(Text2, { variant: "captionBold", children: isDisconnecting ? "Disconnecting..." : "Disconnect" }) })
666
+ const contentWrapperStyle = {
667
+ display: "flex",
668
+ flexDirection: "column",
669
+ gap: "24px"
670
+ };
671
+ const accountListContainerStyle = {
672
+ display: "flex",
673
+ flexDirection: "column",
674
+ alignItems: "center",
675
+ gap: "12px",
676
+ padding: "0 32px 24px 32px",
677
+ boxSizing: "border-box",
678
+ width: "100%",
679
+ minWidth: 0
680
+ };
681
+ const disconnectButtonContainerStyle = {
682
+ display: "flex",
683
+ flexDirection: "column",
684
+ alignItems: "center",
685
+ gap: "12px",
686
+ padding: "0 32px 24px 32px",
687
+ boxSizing: "border-box",
688
+ width: "100%",
689
+ minWidth: 0
690
+ };
691
+ return /* @__PURE__ */ jsxs2("div", { style: contentWrapperStyle, children: [
692
+ /* @__PURE__ */ jsx3(ModalHeader2, { title: "Wallet", onClose }),
693
+ /* @__PURE__ */ jsxs2("div", { style: accountListContainerStyle, children: [
694
+ disconnectError && /* @__PURE__ */ jsx3("div", { style: errorContainerStyle, children: /* @__PURE__ */ jsx3(Text2, { variant: "caption", color: theme.error, children: "Failed to disconnect" }) }),
695
+ addresses && addresses.length > 0 && /* @__PURE__ */ jsx3("div", { style: accountListStyle, children: addresses.map((account, index) => /* @__PURE__ */ jsxs2("div", { style: accountItemStyle, children: [
696
+ /* @__PURE__ */ jsx3(Text2, { variant: "label", color: theme.secondary, style: { textTransform: "uppercase" }, children: account.addressType }),
697
+ /* @__PURE__ */ jsx3("div", { style: addressTextStyle, children: /* @__PURE__ */ jsx3(Text2, { variant: "caption", children: account.address }) })
698
+ ] }, index)) })
699
+ ] }),
700
+ /* @__PURE__ */ jsx3("div", { style: disconnectButtonContainerStyle, children: /* @__PURE__ */ jsx3(Button2, { onClick: handleDisconnect, disabled: isDisconnecting, isLoading: isDisconnecting, fullWidth: true, children: /* @__PURE__ */ jsx3(Text2, { variant: "captionBold", children: isDisconnecting ? "Disconnecting..." : "Disconnect" }) }) })
423
701
  ] });
424
702
  }
425
703
 
426
704
  // src/ModalProvider.tsx
427
- import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
705
+ import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
428
706
  function ModalProvider({ children, appIcon, appName }) {
429
707
  const { isConnected } = usePhantom();
430
- const [isModalOpen, setIsModalOpen] = useState6(false);
708
+ const [isModalOpen, setIsModalOpen] = useState7(false);
431
709
  const isMobile = useMemo2(() => isMobileDevice2(), []);
432
- const openModal = useCallback4(() => {
710
+ const openModal = useCallback5(() => {
433
711
  setIsModalOpen(true);
434
712
  }, []);
435
- const closeModal = useCallback4(() => {
713
+ const closeModal = useCallback5(() => {
436
714
  setIsModalOpen(false);
437
715
  }, []);
438
716
  const modalContextValue = useMemo2(
@@ -445,44 +723,33 @@ function ModalProvider({ children, appIcon, appName }) {
445
723
  );
446
724
  return /* @__PURE__ */ jsxs3(ModalContext.Provider, { value: modalContextValue, children: [
447
725
  children,
448
- /* @__PURE__ */ jsx3(
449
- Modal,
450
- {
451
- isVisible: isModalOpen,
452
- onClose: closeModal,
453
- appIcon,
454
- appName,
455
- isConnected,
456
- isMobile,
457
- children: isConnected ? /* @__PURE__ */ jsx3(ConnectedModalContent, { onClose: closeModal }) : /* @__PURE__ */ jsx3(ConnectModalContent, { appIcon, appName, onClose: closeModal })
458
- }
459
- )
726
+ /* @__PURE__ */ jsx4(Modal, { isVisible: isModalOpen, onClose: closeModal, appIcon, appName, isMobile, children: isConnected ? /* @__PURE__ */ jsx4(ConnectedModalContent, { onClose: closeModal }) : /* @__PURE__ */ jsx4(ConnectModalContent, { appIcon, appName, onClose: closeModal }) })
460
727
  ] });
461
728
  }
462
729
 
463
730
  // src/PhantomProvider.tsx
464
- import { jsx as jsx4 } from "react/jsx-runtime";
731
+ import { jsx as jsx5 } from "react/jsx-runtime";
465
732
  function PhantomProvider({ children, config, debugConfig, theme, appIcon, appName }) {
466
733
  const memoizedConfig = useMemo3(() => config, [config]);
467
734
  const resolvedTheme = useMemo3(() => mergeTheme(theme || darkTheme), [theme]);
468
- const [sdk, setSdk] = useState7(null);
469
- const [isClient, setIsClient] = useState7(false);
470
- const [isConnected, setIsConnected] = useState7(false);
471
- const [isConnecting, setIsConnecting] = useState7(false);
472
- const [isLoading, setIsLoading] = useState7(true);
473
- const [connectError, setConnectError] = useState7(null);
474
- const [addresses, setAddresses] = useState7([]);
475
- const [user, setUser] = useState7(null);
476
- useEffect4(() => {
735
+ const [sdk, setSdk] = useState8(null);
736
+ const [isClient, setIsClient] = useState8(false);
737
+ const [isConnected, setIsConnected] = useState8(false);
738
+ const [isConnecting, setIsConnecting] = useState8(false);
739
+ const [isLoading, setIsLoading] = useState8(true);
740
+ const [connectError, setConnectError] = useState8(null);
741
+ const [addresses, setAddresses] = useState8([]);
742
+ const [user, setUser] = useState8(null);
743
+ useEffect5(() => {
477
744
  setIsClient(true);
478
745
  }, []);
479
- useEffect4(() => {
746
+ useEffect5(() => {
480
747
  if (!isClient)
481
748
  return;
482
749
  const sdkInstance = new BrowserSDK(memoizedConfig);
483
750
  setSdk(sdkInstance);
484
751
  }, [isClient, memoizedConfig]);
485
- useEffect4(() => {
752
+ useEffect5(() => {
486
753
  if (!sdk)
487
754
  return;
488
755
  const handleConnectStart = () => {
@@ -529,12 +796,12 @@ function PhantomProvider({ children, config, debugConfig, theme, appIcon, appNam
529
796
  sdk.off("disconnect", handleDisconnect);
530
797
  };
531
798
  }, [sdk]);
532
- useEffect4(() => {
799
+ useEffect5(() => {
533
800
  if (!debugConfig || !sdk)
534
801
  return;
535
802
  sdk.configureDebug(debugConfig);
536
803
  }, [sdk, debugConfig]);
537
- useEffect4(() => {
804
+ useEffect5(() => {
538
805
  if (!isClient || !sdk)
539
806
  return;
540
807
  const initialize = async () => {
@@ -573,7 +840,7 @@ function PhantomProvider({ children, config, debugConfig, theme, appIcon, appNam
573
840
  memoizedConfig.providers
574
841
  ]
575
842
  );
576
- return /* @__PURE__ */ jsx4(ThemeProvider, { theme: resolvedTheme, children: /* @__PURE__ */ jsx4(PhantomContext.Provider, { value, children: /* @__PURE__ */ jsx4(ModalProvider, { appIcon, appName, children }) }) });
843
+ return /* @__PURE__ */ jsx5(ThemeProvider, { theme: resolvedTheme, children: /* @__PURE__ */ jsx5(PhantomContext.Provider, { value, children: /* @__PURE__ */ jsx5(ModalProvider, { appIcon, appName, children }) }) });
577
844
  }
578
845
 
579
846
  // src/hooks/useAccounts.ts
@@ -583,15 +850,15 @@ function useAccounts() {
583
850
  }
584
851
 
585
852
  // src/hooks/useAutoConfirm.ts
586
- import { useCallback as useCallback5, useState as useState8, useEffect as useEffect5 } from "react";
853
+ import { useCallback as useCallback6, useState as useState9, useEffect as useEffect6 } from "react";
587
854
  function useAutoConfirm() {
588
855
  const { sdk, user } = usePhantom();
589
- const [status, setStatus] = useState8(null);
590
- const [supportedChains, setSupportedChains] = useState8(null);
591
- const [isLoading, setIsLoading] = useState8(false);
592
- const [error, setError] = useState8(null);
856
+ const [status, setStatus] = useState9(null);
857
+ const [supportedChains, setSupportedChains] = useState9(null);
858
+ const [isLoading, setIsLoading] = useState9(false);
859
+ const [error, setError] = useState9(null);
593
860
  const isInjected = user?.authProvider === "injected";
594
- const enable = useCallback5(
861
+ const enable = useCallback6(
595
862
  async (params) => {
596
863
  if (!sdk) {
597
864
  throw new Error("SDK not initialized");
@@ -615,7 +882,7 @@ function useAutoConfirm() {
615
882
  },
616
883
  [sdk, isInjected]
617
884
  );
618
- const disable = useCallback5(async () => {
885
+ const disable = useCallback6(async () => {
619
886
  if (!sdk) {
620
887
  throw new Error("SDK not initialized");
621
888
  }
@@ -636,7 +903,7 @@ function useAutoConfirm() {
636
903
  setIsLoading(false);
637
904
  }
638
905
  }, [sdk, isInjected]);
639
- const refetch = useCallback5(async () => {
906
+ const refetch = useCallback6(async () => {
640
907
  if (!sdk || !isInjected) {
641
908
  return;
642
909
  }
@@ -656,7 +923,7 @@ function useAutoConfirm() {
656
923
  setIsLoading(false);
657
924
  }
658
925
  }, [sdk, isInjected]);
659
- useEffect5(() => {
926
+ useEffect6(() => {
660
927
  if (sdk && isInjected) {
661
928
  refetch();
662
929
  } else {
@@ -677,50 +944,76 @@ function useAutoConfirm() {
677
944
  }
678
945
 
679
946
  // src/hooks/useSolana.ts
947
+ import { AddressType } from "@phantom/browser-sdk";
680
948
  function useSolana() {
681
- const { sdk, isConnected, isClient } = usePhantom();
682
- if (!isClient || !sdk) {
949
+ const { sdk, isClient, isLoading } = usePhantom();
950
+ if (!isClient || !sdk || isLoading) {
951
+ return {
952
+ solana: {},
953
+ isAvailable: false
954
+ };
955
+ }
956
+ const enabledAddressTypes = sdk.getEnabledAddressTypes();
957
+ const isAvailable = enabledAddressTypes.includes(AddressType.solana);
958
+ if (!isAvailable) {
959
+ return {
960
+ solana: {},
961
+ isAvailable: false
962
+ };
963
+ }
964
+ try {
965
+ return {
966
+ solana: sdk.solana,
967
+ isAvailable: true
968
+ };
969
+ } catch (error) {
683
970
  return {
684
971
  solana: {},
685
- // This will be replaced when SDK is ready
686
972
  isAvailable: false
687
973
  };
688
974
  }
689
- return {
690
- // Chain instance with connection enforcement for signing methods
691
- solana: sdk.solana,
692
- // State
693
- isAvailable: !!isConnected
694
- };
695
975
  }
696
976
 
697
977
  // src/hooks/useEthereum.ts
978
+ import { AddressType as AddressType2 } from "@phantom/browser-sdk";
698
979
  function useEthereum() {
699
- const { sdk, isConnected, isClient } = usePhantom();
700
- if (!isClient || !sdk) {
980
+ const { sdk, isClient, isLoading } = usePhantom();
981
+ if (!isClient || !sdk || isLoading) {
982
+ return {
983
+ ethereum: {},
984
+ isAvailable: false
985
+ };
986
+ }
987
+ const enabledAddressTypes = sdk.getEnabledAddressTypes();
988
+ const isAvailable = enabledAddressTypes.includes(AddressType2.ethereum);
989
+ if (!isAvailable) {
990
+ return {
991
+ ethereum: {},
992
+ isAvailable: false
993
+ };
994
+ }
995
+ try {
996
+ return {
997
+ ethereum: sdk.ethereum,
998
+ isAvailable: true
999
+ };
1000
+ } catch (error) {
701
1001
  return {
702
1002
  ethereum: {},
703
- // This will be replaced when SDK is ready
704
1003
  isAvailable: false
705
1004
  };
706
1005
  }
707
- return {
708
- // Chain instance with connection enforcement for signing methods
709
- ethereum: sdk.ethereum,
710
- // State
711
- isAvailable: !!isConnected
712
- };
713
1006
  }
714
1007
 
715
1008
  // src/hooks/index.ts
716
- import { useTheme as useTheme3 } from "@phantom/wallet-sdk-ui";
1009
+ import { useTheme as useTheme4 } from "@phantom/wallet-sdk-ui";
717
1010
 
718
1011
  // src/components/ConnectButton.tsx
719
1012
  import { useMemo as useMemo4 } from "react";
720
- import { useTheme as useTheme4 } from "@phantom/wallet-sdk-ui";
721
- import { jsx as jsx5 } from "react/jsx-runtime";
1013
+ import { useTheme as useTheme5 } from "@phantom/wallet-sdk-ui";
1014
+ import { jsx as jsx6 } from "react/jsx-runtime";
722
1015
  function ConnectButton({ addressType, fullWidth = false }) {
723
- const theme = useTheme4();
1016
+ const theme = useTheme5();
724
1017
  const { open } = useModal();
725
1018
  const { isConnected, addresses } = usePhantom();
726
1019
  const displayAddress = useMemo4(() => {
@@ -765,16 +1058,16 @@ function ConnectButton({ addressType, fullWidth = false }) {
765
1058
  cursor: "pointer"
766
1059
  };
767
1060
  if (isConnected && displayAddress) {
768
- return /* @__PURE__ */ jsx5("button", { style: connectedButtonStyle, onClick: open, children: /* @__PURE__ */ jsx5("span", { style: { fontFamily: "monospace" }, children: truncatedAddress }) });
1061
+ return /* @__PURE__ */ jsx6("button", { style: connectedButtonStyle, onClick: open, children: /* @__PURE__ */ jsx6("span", { style: { fontFamily: "monospace" }, children: truncatedAddress }) });
769
1062
  }
770
- return /* @__PURE__ */ jsx5("button", { style: buttonStyle, onClick: open, children: "Connect Wallet" });
1063
+ return /* @__PURE__ */ jsx6("button", { style: buttonStyle, onClick: open, children: "Connect Wallet" });
771
1064
  }
772
1065
 
773
1066
  // src/index.ts
774
1067
  import { darkTheme as darkTheme2, lightTheme, mergeTheme as mergeTheme2 } from "@phantom/wallet-sdk-ui";
775
- import { NetworkId, AddressType, DebugLevel, debug, isMobileDevice as isMobileDevice3 } from "@phantom/browser-sdk";
1068
+ import { NetworkId, AddressType as AddressType3, DebugLevel, debug, isMobileDevice as isMobileDevice3 } from "@phantom/browser-sdk";
776
1069
  export {
777
- AddressType,
1070
+ AddressType3 as AddressType,
778
1071
  ConnectButton,
779
1072
  DebugLevel,
780
1073
  NetworkId,
@@ -788,11 +1081,12 @@ export {
788
1081
  useAutoConfirm,
789
1082
  useConnect,
790
1083
  useDisconnect,
1084
+ useDiscoveredWallets,
791
1085
  useEthereum,
792
1086
  useIsExtensionInstalled,
793
1087
  useIsPhantomLoginAvailable,
794
1088
  useModal,
795
1089
  usePhantom,
796
1090
  useSolana,
797
- useTheme3 as useTheme
1091
+ useTheme4 as useTheme
798
1092
  };