import { Adapter , MessageSignerWalletAdapterProps , SendTransactionOptions , SignerWalletAdapterProps , WalletName , WalletReadyState , } from '@solana/wallet-adapter-base' ; import { Connection , PublicKey , Transaction , TransactionSignature } from '@solana/web3.js' ; import { createContext , useContext } from 'react' ; export interface Wallet { adapter : Adapter ; readyState : WalletReadyState ; } export interface WalletContextState { autoConnect : boolean ; wallets : Wallet [ ] ; wallet : Wallet | null ; publicKey : PublicKey | null ; connecting : boolean ; connected : boolean ; disconnecting : boolean ; select ( walletName ) : void ; connect ( ) : Promise < void > ; disconnect ( ) : Promise < void > ; sendTransaction ( transaction , connection , options ? ) : Promise < TransactionSignature > ; signTransaction : SignerWalletAdapterProps [ 'signTransaction' ] | undefined ; signAllTransactions : SignerWalletAdapterProps [ 'signAllTransactions' ] | undefined ; signMessage : MessageSignerWalletAdapterProps [ 'signMessage' ] | undefined ; } export const WalletContext = createContext < WalletContextState > ( { } as WalletContextState ) ; export function useWallet ( ) { return useContext ( WalletContext ) ; }