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

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/README.md CHANGED
@@ -601,7 +601,12 @@ import { useSolana } from "@phantom/react-sdk";
601
601
  import { VersionedTransaction, TransactionMessage, SystemProgram, PublicKey, Connection } from "@solana/web3.js";
602
602
 
603
603
  function SolanaOperations() {
604
- const { solana } = useSolana();
604
+ const { solana, isAvailable } = useSolana();
605
+
606
+ // Check if Solana is available before using it
607
+ if (!isAvailable) {
608
+ return <div>Solana is not available for the current wallet</div>;
609
+ }
605
610
 
606
611
  const signMessage = async () => {
607
612
  const signature = await solana.signMessage("Hello Solana!");
@@ -656,7 +661,19 @@ function SolanaOperations() {
656
661
  - `switchNetwork(network)` - Switch between mainnet/devnet
657
662
  - `getPublicKey()` - Get current public key
658
663
  - `isConnected` - Connection status
659
- - `isAvailable` - Provider availability
664
+ - `isAvailable` - Provider availability (see note below)
665
+
666
+ **Note on `isAvailable`:**
667
+
668
+ The `isAvailable` property indicates whether the Solana chain is available for the currently connected wallet:
669
+
670
+ - **For embedded wallets** (Google, Apple, Phantom Login, etc.): `isAvailable` will be `true` for all networks configured in your `addressTypes` array, as embedded wallets support all configured networks.
671
+
672
+ - **For Phantom injected wallet**: `isAvailable` will be `true` for all networks configured in your `addressTypes` array, as Phantom supports multiple networks.
673
+
674
+ - **For other injected wallets** (discovered via Wallet Standard or EIP-6963): `isAvailable` depends on which networks the specific wallet supports. For example, if you connect to a wallet that only supports Ethereum, `isAvailable` will be `false` for Solana even if Solana is in your `addressTypes` configuration.
675
+
676
+ Always check `isAvailable` before attempting to use chain-specific methods when working with injected wallets that may not support all networks.
660
677
 
661
678
  #### useEthereum
662
679
 
@@ -666,7 +683,12 @@ Hook for Ethereum chain operations:
666
683
  import { useEthereum } from "@phantom/react-sdk";
667
684
 
668
685
  function EthereumOperations() {
669
- const { ethereum } = useEthereum();
686
+ const { ethereum, isAvailable } = useEthereum();
687
+
688
+ // Check if Ethereum is available before using it
689
+ if (!isAvailable) {
690
+ return <div>Ethereum is not available for the current wallet</div>;
691
+ }
670
692
 
671
693
  const signPersonalMessage = async () => {
672
694
  const accounts = await ethereum.getAccounts();
@@ -755,7 +777,19 @@ function EthereumOperations() {
755
777
  - `getChainId()` - Get current chain ID
756
778
  - `getAccounts()` - Get connected accounts
757
779
  - `isConnected` - Connection status
758
- - `isAvailable` - Provider availability
780
+ - `isAvailable` - Provider availability (see note below)
781
+
782
+ **Note on `isAvailable`:**
783
+
784
+ The `isAvailable` property indicates whether the Ethereum chain is available for the currently connected wallet:
785
+
786
+ - **For embedded wallets** (Google, Apple, Phantom Login, etc.): `isAvailable` will be `true` for all networks configured in your `addressTypes` array, as embedded wallets support all configured networks.
787
+
788
+ - **For Phantom injected wallet**: `isAvailable` will be `true` for all networks configured in your `addressTypes` array, as Phantom supports multiple networks.
789
+
790
+ - **For other injected wallets** (discovered via Wallet Standard or EIP-6963): `isAvailable` depends on which networks the specific wallet supports. For example, if you connect to a wallet that only supports Solana, `isAvailable` will be `false` for Ethereum even if Ethereum is in your `addressTypes` configuration.
791
+
792
+ Always check `isAvailable` before attempting to use chain-specific methods when working with injected wallets that may not support all networks.
759
793
 
760
794
  **Supported EVM Networks:**
761
795
 
@@ -772,6 +806,39 @@ function EthereumOperations() {
772
806
  | Monad Mainnet | `143` | `ethereum.switchChain(143)` |
773
807
  | Monad Testnet | `10143` | `ethereum.switchChain(10143)` |
774
808
 
809
+ ### Wallet Discovery Hook
810
+
811
+ #### useDiscoveredWallets
812
+
813
+ Hook to get discovered injected wallets with automatic loading and error states. Discovers wallets using Wallet Standard (Solana) and EIP-6963 (Ethereum) standards.
814
+
815
+ ```tsx
816
+ import { useDiscoveredWallets } from "@phantom/react-sdk";
817
+
818
+ function WalletSelector() {
819
+ const { wallets, isLoading, error, refetch } = useDiscoveredWallets();
820
+
821
+ // wallets: InjectedWalletInfo[] - Array of discovered wallets
822
+ // isLoading: boolean - Loading state during discovery
823
+ // error: Error | null - Error state if discovery fails
824
+ // refetch: () => Promise<void> - Function to manually trigger discovery
825
+ }
826
+ ```
827
+
828
+ **Returns:**
829
+
830
+ - `wallets: InjectedWalletInfo[]` - Array of discovered wallet information
831
+ - `isLoading: boolean` - `true` while discovery is in progress
832
+ - `error: Error | null` - Error object if discovery fails, `null` otherwise
833
+ - `refetch: () => Promise<void>` - Async function to manually refresh the wallet list
834
+
835
+ **Behavior:**
836
+
837
+ - Automatically fetches discovered wallets when the SDK becomes available
838
+ - If no wallets are found in the registry, triggers async `discoverWallets()` to discover them
839
+ - Wallets are filtered based on the `addressTypes` configured in `PhantomProvider`
840
+ - Phantom wallet is automatically included if available
841
+
775
842
  ### Auto-Confirm Hook (Injected Provider Only)
776
843
 
777
844
  #### useAutoConfirm
@@ -1042,9 +1109,10 @@ Quick reference of all available hooks:
1042
1109
  | `useIsPhantomLoginAvailable` | Check Phantom Login availability | `{ isLoading, isAvailable }` |
1043
1110
  | `useDisconnect` | Disconnect from wallet | `{ disconnect, isDisconnecting }` |
1044
1111
  | `useAutoConfirm` | Auto-confirm management (injected only) | `{ enable, disable, status, supportedChains, ... }` |
1112
+ | `useDiscoveredWallets` | Get discovered injected wallets | `{ wallets, isLoading, error, refetch }` |
1045
1113
  | `useSolana` | Solana chain operations | `{ signMessage, signAndSendTransaction, ... }` |
1046
1114
  | `useEthereum` | Ethereum chain operations | `{ signPersonalMessage, sendTransaction, ... }` |
1047
- | `useTheme` | Access current theme | `CompletePhantomTheme` |
1115
+ | `useTheme` | Access current theme | `PhantomTheme` |
1048
1116
  | `usePhantom` | Get provider context | `{ isConnected, isReady }` |
1049
1117
 
1050
1118
  ## Configuration Reference
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ReactNode } from 'react';
3
3
  import * as _phantom_browser_sdk from '@phantom/browser-sdk';
4
- import { BrowserSDKConfig, DebugConfig, AuthOptions, BrowserSDK, WalletAddress, ConnectResult, AuthProviderType, AutoConfirmEnableParams, AutoConfirmResult, AutoConfirmSupportedChainsResult, AddressType } from '@phantom/browser-sdk';
5
- export { AddressType, AuthOptions, AutoConfirmEnableParams, AutoConfirmResult, AutoConfirmSupportedChainsResult, ConnectErrorEventData, ConnectEventData, ConnectStartEventData, DebugLevel, DebugMessage, DisconnectEventData, EmbeddedProviderEvent, EmbeddedProviderEventMap, EventCallback, NetworkId, SignedTransaction, WalletAddress, debug, isMobileDevice } from '@phantom/browser-sdk';
6
- import { PhantomTheme, CompletePhantomTheme } from '@phantom/wallet-sdk-ui';
7
- export { CompletePhantomTheme, HexColor, PhantomTheme, darkTheme, lightTheme, mergeTheme, useTheme } from '@phantom/wallet-sdk-ui';
4
+ import { BrowserSDKConfig, DebugConfig, AuthOptions, BrowserSDK, WalletAddress, ConnectResult, AuthProviderType, AutoConfirmEnableParams, AutoConfirmResult, AutoConfirmSupportedChainsResult, InjectedWalletInfo, AddressType } from '@phantom/browser-sdk';
5
+ export { AddressType, AuthOptions, AutoConfirmEnableParams, AutoConfirmResult, AutoConfirmSupportedChainsResult, ConnectErrorEventData, ConnectEventData, ConnectStartEventData, DebugLevel, DebugMessage, DisconnectEventData, EmbeddedProviderEvent, EmbeddedProviderEventMap, EventCallback, InjectedWalletId, InjectedWalletInfo, NetworkId, SignedTransaction, WalletAddress, debug, isMobileDevice } from '@phantom/browser-sdk';
6
+ import { PhantomTheme } from '@phantom/wallet-sdk-ui';
7
+ export { ComputedPhantomTheme, HexColor, PhantomTheme, darkTheme, lightTheme, mergeTheme, useTheme } from '@phantom/wallet-sdk-ui';
8
8
  import { ISolanaChain, IEthereumChain } from '@phantom/chain-interfaces';
9
9
  export { EthTransactionRequest, IEthereumChain, ISolanaChain } from '@phantom/chain-interfaces';
10
10
  import * as _phantom_embedded_provider_core from '@phantom/embedded-provider-core';
@@ -35,7 +35,7 @@ interface PhantomContextValue {
35
35
  addresses: WalletAddress[];
36
36
  isClient: boolean;
37
37
  user: ConnectResult | null;
38
- theme: CompletePhantomTheme;
38
+ theme: PhantomTheme;
39
39
  allowedProviders: AuthProviderType[];
40
40
  }
41
41
  declare function usePhantom(): PhantomContextValue;
@@ -110,6 +110,14 @@ declare function useEthereum(): {
110
110
  isAvailable: boolean;
111
111
  };
112
112
 
113
+ interface UseDiscoveredWalletsResult {
114
+ wallets: InjectedWalletInfo[];
115
+ isLoading: boolean;
116
+ error: Error | null;
117
+ refetch: () => Promise<void>;
118
+ }
119
+ declare function useDiscoveredWallets(): UseDiscoveredWalletsResult;
120
+
113
121
  interface UseModalResult {
114
122
  open: () => void;
115
123
  close: () => void;
@@ -122,4 +130,4 @@ interface ConnectButtonProps {
122
130
  }
123
131
  declare function ConnectButton({ addressType, fullWidth }: ConnectButtonProps): react_jsx_runtime.JSX.Element;
124
132
 
125
- export { ConnectButton, ConnectButtonProps, ConnectOptions, PhantomDebugConfig, PhantomProvider, PhantomProviderProps, PhantomSDKConfig, UseModalResult, useAccounts, useAutoConfirm, useConnect, useDisconnect, useEthereum, useIsExtensionInstalled, useIsPhantomLoginAvailable, useModal, usePhantom, useSolana };
133
+ export { ConnectButton, ConnectButtonProps, ConnectOptions, PhantomDebugConfig, PhantomProvider, PhantomProviderProps, PhantomSDKConfig, UseDiscoveredWalletsResult, UseModalResult, useAccounts, useAutoConfirm, useConnect, useDisconnect, useDiscoveredWallets, useEthereum, useIsExtensionInstalled, useIsPhantomLoginAvailable, useModal, usePhantom, useSolana };