@jim4565/dapp-wrapper-react
Version:
React components and hooks for @jim4565/dapp-wrapper with persistent wallet connection
70 lines • 1.91 kB
TypeScript
import { StoredWalletData, ContractConfig } from '../types';
/**
* PersistenceService - MetaMask-style LocalStorage Management
*
* Handles secure storage and retrieval of wallet connection data
* with proper error handling and data validation.
*/
export declare class PersistenceService {
private static readonly VERSION;
private static readonly STORAGE_PREFIX;
/**
* Save wallet connection data securely
*/
static saveWalletData(address: string): void;
/**
* Load stored wallet connection data
*/
static loadWalletData(): StoredWalletData;
/**
* Clear all wallet-related data
*/
static clearWalletData(): void;
/**
* Save contract configurations
*/
static saveContracts(contracts: ContractConfig[]): void;
/**
* Load contract configurations
*/
static loadContracts(): {
name: string;
address: string;
hasABI: boolean;
}[];
/**
* Check if wallet should auto-reconnect
*
* Returns true only if:
* 1. User has ever connected before (prevents popup for first-time users)
* 2. Was connected in last session
* 3. Has valid stored address
* 4. Connection is not too old
*/
static shouldAutoReconnect(): boolean;
/**
* Get storage usage statistics
*/
static getStorageStats(): {
totalItems: number;
totalSize: number;
items: any[];
};
/**
* Validate if address format is correct
*/
private static isValidAddress;
/**
* Get empty wallet data structure
*/
private static getEmptyWalletData;
/**
* Check if localStorage is available
*/
static isStorageAvailable(): boolean;
/**
* Migrate data from old storage format (if needed)
*/
static migrateStorageIfNeeded(): void;
}
//# sourceMappingURL=PersistenceService.d.ts.map