import type { NetworkId, Network, ConnectionMode, Session, AvailableAddress, TransactionRequest, TransactionResult, WalletError, EVMCapabilities, SignatureType, EIP712TypedData, WalletMetadata } from './index'; /** * WalletConnect connection interface for the useConnection hook */ export interface WalletConnectConnection { /** * Connects to the specified wallet using WalletConnect protocol * @param networkId - Optional network ID to connect to. If not provided, uses the default network * @returns Promise that resolves when connection is established */ connect: (networkId?: NetworkId) => Promise; /** * The WalletConnect connection URI for QR code display * Will be undefined if not using WalletConnect or if connection is already established */ connectionURI: string | undefined; /** * Indicates if the WalletConnect connection is currently being established */ isLoading: boolean; /** * Error from the last connection attempt, undefined if no error occurred */ error: WalletError | undefined; /** * Indicates if WalletConnect is currently available for use * This depends on whether the wallet supports WalletConnect */ available: boolean; } /** * Injected wallet connection interface for the useConnection hook */ export interface InjectedConnection { /** * Connects to the specified wallet using browser injection (MetaMask, Trust Wallet, etc.) * @param networkId - Optional network ID to connect to. If not provided, uses the default network * @returns Promise that resolves when connection is established */ connect: (networkId?: NetworkId) => Promise; /** * Indicates if the injected wallet connection is currently being established */ isLoading: boolean; /** * Error from the last connection attempt, undefined if no error occurred */ error: WalletError | undefined; /** * Indicates if injected connection is currently available for use */ available: boolean; } /** * TON Connect connection interface for the useConnection hook. * Used for connecting to TON mobile wallets via QR code / universal link. */ export interface TonConnectConnection { /** * Connects to the specified wallet using TON Connect protocol * @param networkId - Optional network ID (defaults to TON mainnet) */ connect: (networkId?: NetworkId) => Promise; /** * The TON Connect connection URI for QR code display. * Available after connect() is called, before the wallet approves. */ connectionURI: string | undefined; isLoading: boolean; error: WalletError | undefined; /** Whether TON Connect is available for this wallet */ available: boolean; } /** * Return type for the useConnection hook * @example * ```tsx * const { walletConnect, injected, tonConnect } = useConnection('metamask') * * // Connect with WalletConnect * await walletConnect.connect('eip155:1') * console.log(walletConnect.connectionURI) // Display QR code * * // Connect with injected wallet * await injected.connect('eip155:1') * * // Connect with TON Connect * await tonConnect.connect('tvm:-239') * ``` */ export interface UseConnectionReturn { /** * WalletConnect connection methods and state */ walletConnect: WalletConnectConnection; /** * Injected wallet connection methods and state */ injected: InjectedConnection; /** * TON Connect connection methods and state */ tonConnect: TonConnectConnection; /** * Indicates if wallet detection has completed and the connector is ready to use */ isReady: boolean; } /** * Return type for the useSession hook * Provides access to the current wallet session state * @example * ```tsx * const { activeAddress, activeNetwork, session } = useSession() * * if (activeAddress) { * console.log(`Connected to ${activeNetwork?.name} with ${activeAddress}`) * } * ``` */ export interface UseSessionReturn { /** * The complete session object containing all wallet connection state */ session: Session; /** * The currently connected wallet address, or null if not connected */ activeAddress: string | null; /** * The currently selected network, or null if not connected */ activeNetwork: Network | null; /** * The capabilities of the currently connected wallet, or null if not connected */ activeWalletCapabilities: Record | null; /** * The capabilities of the currently connected wallet on the active network, or null if not connected */ activeNetworkWalletCapabilities: EVMCapabilities | null; /** * List of networks available for the connected wallet */ availableNetworks: Network[]; /** * The active connection mode ('injected' or 'walletConnect'), or null if not connected */ activeConnector: ConnectionMode | null; /** * List of available addresses for the connected wallet */ availableAddresses: AvailableAddress[]; /** * The public key of the connected wallet, or null if not available. * Currently only returned for TON wallets (Ed25519 hex string, no 0x prefix). */ publicKey: string | null; } /** * Return type for the useSwitchNetwork hook * Provides network switching functionality with loading states * @example * ```tsx * const { switchNetwork, isLoading, isWaitingForUserApproval } = useSwitchNetwork() * * const handleNetworkSwitch = async () => { * await switchNetwork('eip155:8453') // Switch to Base * * if (isWaitingForUserApproval) { * console.log('Waiting for user to approve in wallet...') * } * } * ``` */ export interface UseSwitchNetworkReturn { /** * Switches the connected wallet to the specified network * @param networkId - The ID of the network to switch to (e.g., 'eip155:1' for Ethereum mainnet) * @returns Promise that resolves when the network switch is complete * @throws Error if network switch fails or is rejected by the user */ switchNetwork: (networkId: NetworkId) => Promise; /** * Indicates if a network switch operation is currently in progress */ isLoading: boolean; /** * Indicates if the wallet is waiting for user approval to switch networks * This depends on the wallet's metadata configuration (requiresUserApprovalOnNetworkSwitch) */ isWaitingForUserApproval: boolean; /** * Error from the last network switch attempt, undefined if no error occurred */ error: WalletError | undefined; } /** * Return type for the useSignMessage hook * Provides message signing functionality with loading state and signature result * @example * ```tsx * const { signMessage, isLoading, signature } = useSignMessage() * * const handleSign = async () => { * const sig = await signMessage('Hello World') * console.log('Signature:', sig) * // The signature state will also contain the result * } * ``` */ export interface UseSignMessageReturn { /** * Signs a message with the connected wallet * @param message - The message to sign * @returns Promise that resolves to the signature string * @throws Error if no wallet is connected or signing fails */ signMessage: (message: string) => Promise; /** * Indicates if a message signing operation is currently in progress */ isLoading: boolean; /** * The last signature result, undefined if no message has been signed yet */ signature: SignatureType | undefined; /** * Error from the last signing attempt, undefined if no error occurred */ error: WalletError | undefined; } /** * Return type for the useSignTypedData hook. * Provides EIP-712 typed data signing (eth_signTypedData_v4) for EVM wallets. * Used by ERC-3009 (Transfer With Authorization) and EIP-2612 (Permit) relay flows. */ export interface UseSignTypedDataReturn { /** * Signs EIP-712 typed data with the connected EVM wallet * @param typedData - The EIP-712 typed data to sign * @returns Promise that resolves to the 65-byte hex signature (0x-prefixed) * @throws Error if no wallet is connected, the wallet is non-EVM, or signing fails */ signTypedData: (typedData: EIP712TypedData) => Promise; /** * Indicates if a typed-data signing operation is currently in progress */ isLoading: boolean; /** * The raw hex signature from the last successful sign, undefined if not yet signed */ signature: string | undefined; /** * Error from the last signing attempt, undefined if no error occurred */ error: WalletError | undefined; } /** * Return type for useSignSolanaTransaction — sign-only Solana signing (bytes in, * bytes out) for fee-payer relay flows where the relay, not the wallet, broadcasts. * @example * const signed = await signSolanaTransaction(unsignedBytes) */ export interface UseSignSolanaTransactionReturn { /** Sign serialized tx bytes without broadcasting. Throws if no wallet / signing fails. */ signSolanaTransaction: (serializedTx: Uint8Array) => Promise; isLoading: boolean; error: WalletError | undefined; } /** * Return type for the useTransaction hook * Provides transaction sending functionality with loading state and result * @example * ```tsx * const { sendTransaction, isLoading, transactionResult } = useTransaction() * * const handleSend = async () => { * const result = await sendTransaction({ * to: '0x...', * amount: BigInt('1000000000000000000'), * from: session.activeAddress * }) * console.log('Transaction hash:', result.hash) * } * ``` */ export interface UseTransactionReturn { /** * Sends a transaction with the connected wallet * @param request - The transaction request object * @returns Promise that resolves to the transaction result * @throws Error if no wallet is connected or transaction fails */ sendTransaction: (request: TransactionRequest) => Promise; /** * Indicates if a transaction is currently being processed */ isLoading: boolean; /** * The last transaction result, undefined if no transaction has been sent yet */ transactionResult: TransactionResult | undefined; /** * Error from the last transaction attempt, undefined if no error occurred */ error: WalletError | undefined; } /** * Return type for the useWallet hook * Provides access to a specific wallet configuration * @example * ```tsx * const { wallet, error } = useWallet('metamask') * console.log(wallet?.name) // 'MetaMask' * ``` */ export interface UseWalletReturn { /** * The wallet metadata, undefined if no wallet has been found */ wallet?: WalletMetadata; /** * Error from the last wallet query attempt, undefined if no error occurred */ error?: WalletError; } /** * Return type for the useWalletCapabilities hook * Provides access to wallet capabilities for the current session * @example * ```tsx * const { capabilities, networkCapabilities, isLoading, error } = useWalletCapabilities() * * if (capabilities['eip155:1']?.atomicBatching.supported) { * console.log('Atomic batching is supported on Ethereum') * } * ``` */ export interface UseWalletCapabilitiesReturn { fetchCapabilities: () => Promise; /** * Indicates if wallet capabilities are being fetched */ isLoading: boolean; /** * Error from the last capabilities fetch attempt, undefined if no error occurred */ error: WalletError | undefined; } /** * Return type for the useDetectedWallets hook * Return a list of detected wallets and status of the detection process * @example * ```tsx * const { detectedWallets, isReady } = useDetectedWallets() * console.log(detectedWallets) // Array of detected wallets * console.log(isReady) // Boolean indicating the detection process is complete * ``` */ export interface UseDetectedWalletsReturn { /** * List of detected wallets */ detectedWallets: WalletMetadata[]; /** * Indicates if the detection process is complete */ isReady: boolean; } //# sourceMappingURL=react-hooks.d.ts.map