import type { Transaction } from 'algosdk'; import type { WalletAdapter, WalletAdapterConfig, WalletAccount, SigningOptions, SignAndSendResult, WalletConnectConfig } from './types.js'; /** * Event emitter for WalletConnect modal control. * Components can subscribe to show/hide the QR modal. */ export type WalletConnectModalHandler = (event: WalletConnectModalEvent) => void; export type WalletConnectModalEvent = { type: 'show'; uri: string; walletName: string; } | { type: 'hide'; }; /** * Event emitter for session state changes. * Components can subscribe to handle session invalidation. */ export type SessionStateHandler = (event: SessionStateEvent) => void; export type SessionStateEvent = { type: 'expired'; walletId: string; } | { type: 'deleted'; walletId: string; } | { type: 'disconnected'; walletId: string; }; /** * Register a handler for session state changes. * Use this to update UI when sessions expire or disconnect. * @param handler - The handler function * @param scopeId - Scope identifier (defaults to 'default') */ export declare function onSessionStateChange(handler: SessionStateHandler, scopeId?: string): () => void; /** * Register a handler for WalletConnect modal events. * @param handler - The handler function * @param scopeId - Scope identifier (defaults to 'default') */ export declare function onWalletConnectModal(handler: WalletConnectModalHandler, scopeId?: string): () => void; /** * Clean up the shared provider. */ export declare function destroySharedProvider(): Promise; /** * WalletConnect wallet adapter. * Supports generic WalletConnect, Biatec, and VoiWallet variants. */ export declare class WalletConnectAdapter implements WalletAdapter { readonly id: 'walletconnect' | 'biatec' | 'voiwallet'; readonly name: string; readonly icon: string; readonly supportsAuth = true; readonly isWatchOnly = false; private config; private wcConfig; private provider; private session; private chainId; private _accounts; private initialized; private initPromise; private scopeId; constructor(variant?: 'walletconnect' | 'biatec' | 'voiwallet'); initialize(config: WalletAdapterConfig): Promise; /** * Set WalletConnect project configuration. * Must be called before connect(). */ setWalletConnectConfig(wcConfig: WalletConnectConfig): void; /** * Set the scope ID for this adapter. * Used to namespace localStorage keys and handler lookups. */ setScopeId(id: string): void; /** * Get the scoped localStorage key for session owner. */ private get sessionOwnerKey(); /** * Get the scoped localStorage key for chain ID. */ private get chainIdKey(); private ensureInitialized; private doInitialize; /** * Handler for session deletion events. * Bound as an instance method to allow proper removal. */ private handleSessionDelete; /** * Handler for session expiration events. * This is CRITICAL - WalletConnect sessions can expire due to: * - Natural timeout (default 7 days) * - Relay server issues * - Wallet app disconnecting */ private handleSessionExpire; /** * Handler for display_uri events. * Bound as an instance method to allow proper removal. */ private handleDisplayUri; /** * Handler for page visibility changes. * Validates session when user returns to the page. */ private handleVisibilityChange; /** * Validate that the current session is still active. * Called on visibility change and can be called proactively. */ validateSession(): Promise; private tryRestoreSession; /** * Clean up an invalid session. */ private cleanupInvalidSession; private extractAccounts; private persistSession; private clearPersistedSession; connect(): Promise; reconnect(): Promise; disconnect(): Promise; isConnected(): boolean; signTransactions(transactions: Transaction[][], _options?: SigningOptions): Promise; signAndSendTransactions(transactions: Transaction[][], options?: SigningOptions): Promise; authenticate(address: string): Promise; /** * Clear all WalletConnect storage for debugging. */ clearAllSessions(): Promise; /** * Clean up adapter resources. * Removes event listeners but preserves the shared provider. */ destroy(): Promise; } /** * Factory function for creating WalletConnect adapter instances. */ export declare function createWalletConnectAdapter(variant?: 'walletconnect' | 'biatec' | 'voiwallet'): WalletConnectAdapter;