import type { Connection } from "@solana/web3.js" ; import type { DefaultWalletType , UnknownWalletType , WalletTypeEnum } from "." ; import type { ConnectedWallet } from "./adapters/types" ; import type { UseSolana } from "./context" ; import { useSolana } from "./context" ; import type { ConnectionContext } from "./utils/useConnectionInternal" ; /**
 * Gets the current Solana wallet.
 */ export function useWallet < WalletType extends WalletTypeEnum < WalletType > = typeof DefaultWalletType > ( ) { const context = useSolana < WalletType > ( ) ; if ( ! context ) { throw new Error ( "wallet not loaded" ) ; } return context ; } /**
 * Gets the current Solana wallet, returning null if it is not connected.
 */ export const useConnectedWallet = ( ) : ConnectedWallet | null => { const { wallet , connected } = useWallet < UnknownWalletType > ( ) ; if ( ! wallet ?. connected || ! connected || ! wallet . publicKey ) { return null ; } return wallet as ConnectedWallet ; } ; returns export function useConnectionContext ( ) { const context = useSolana < UnknownWalletType > ( ) ; if ( ! context ) { throw new Error ( "Not in context" ) ; } return context ; } returns export function useConnection ( ) { return useConnectionContext ( ) . connection ; } returns export function useSendConnection ( ) { return useConnectionContext ( ) . sendConnection ; }