/** * SolanaStoreHandler * * Handles wallet event tracking by subscribing to framework-kit's zustand store. * This provides automatic event capture (autocapture) for Solana wallets without * wrapping any wallet methods — similar to how WagmiEventHandler subscribes to * TanStack Query's mutation/query caches. * * Subscribes to: * - `state.wallet` — connect/disconnect events * - `state.transactions` — transaction lifecycle events (sending → confirmed/failed) * * @see https://github.com/solana-foundation/framework-kit */ import type { WalletRestore } from "../wallet/WalletStateStore"; import { SolanaClientStore } from "./storeTypes"; import { SolanaCluster, SolanaStoreHandlerDeps } from "./types"; export declare class SolanaStoreHandler { private deps; private store; private unsubscribers; private cluster; private chainId; /** * Track last known wallet status to detect transitions. */ private lastWalletStatus; private lastAddress?; /** Whether the observed connection may be put back after a disconnect. */ private restorable; private lastChainId?; /** * Track processed transaction state changes to prevent duplicate events. * Key format: `${signature}:${status}` */ private processedTransactions; /** * Track transactions we've emitted STARTED for (status was "sending"). * Ensures we only emit STARTED once per transaction key. */ private startedTransactions; /** * Per-transaction sender address captured at STARTED time. * Ensures terminal events (confirmed/failed) are attributed correctly * even if the wallet disconnects before the transaction settles. */ private transactionSenders; /** * Whether the cluster was explicitly set (via options or setCluster). * When true, auto-detection from the store endpoint is disabled. */ private explicitCluster; private onClusterChange?; private afterWalletDisconnect?; private beforeWalletConnect?; constructor(deps: SolanaStoreHandlerDeps, store: SolanaClientStore, options?: { cluster?: SolanaCluster; beforeWalletConnect?: (connection: { address: string; chainId: number; rdns: string; }) => boolean; /** Called when the cluster is re-detected from a changed endpoint. */ onClusterChange?: (cluster: SolanaCluster) => void; /** * Runs once the store's wallet has left central state. `restore` puts * a still-live wallet back; it refuses if the namespace changed hands * or was reset while the disconnect was in flight. `captured` says * whether `disconnect()` ran, and so whether the slot was cleared. */ afterWalletDisconnect?: (wallet: { address: string; chainId: number; }, restore: WalletRestore, captured: boolean) => void; }); /** * Update the cluster/network. */ setCluster(cluster: SolanaCluster): void; /** Move the observed wallet to the current cluster. */ private applyCluster; /** * Get the current chain ID. */ getChainId(): number; /** * Resolve the current chainId from the live store state. * This ensures correctness when wallet and cluster change in the same tick * (the cluster subscription may not have fired yet). */ private resolveCurrentChainId; private setupWalletSubscription; private checkInitialWalletState; private handleWalletChange; private handleConnect; /** * The store's wallet as last observed, if it is connected and may be put * back into central state: a connection from before a reset() may not. */ restorableConnection(): { address: string; chainId: number; } | undefined; /** reset() ran: the observed connection is not put back until observed again. */ onReset(): void; private handleDisconnect; private setupClusterSubscription; private handleClusterChange; private setupTransactionSubscription; private handleTransactionChanges; private handleTransactionStatusChange; /** * Attempt to detect the Solana cluster from the store's endpoint URL. */ private detectClusterFromStore; /** * Detect cluster from an RPC endpoint URL. */ private detectClusterFromEndpoint; cleanup(): void; } //# sourceMappingURL=SolanaStoreHandler.d.ts.map