@jim4565/dapp-wrapper-react
Version:
React components and hooks for @jim4565/dapp-wrapper with persistent wallet connection
96 lines • 2.74 kB
TypeScript
import { ContractConfig, ContractInstance } from '../types';
/**
* IncentivWalletService - Professional wrapper around @jim4565/dapp-wrapper
*
* Provides MetaMask-style connection patterns and 3-tier reconnection strategy
* for seamless integration with React components.
*/
export declare class IncentivWalletService {
private wrapper;
private isInitialized;
private eventListeners;
constructor();
/**
* Initialize with IncentivWrapper instance
*/
initialize(wrapperInstance?: any): Promise<void>;
/**
* 3-TIER RECONNECTION STRATEGY
* Following MetaMask and wagmi best practices
*/
/**
* TIER 1: Silent Connection Check
* Check if SDK already has an active session without triggering any popups
*/
checkSilentConnection(): Promise<string | null>;
/**
* TIER 2: Session Restore
* Try to restore previous session without user interaction
*/
tryRestoreSession(expectedAddress: string): Promise<boolean>;
/**
* TIER 3: Full Connect
* Complete connection flow with user interaction (popup)
*/
connect(): Promise<string>;
/**
* Get wallet balance with multiple fallback strategies
*/
getBalance(address?: string): Promise<string>;
/**
* Get contract instance
*/
getContract(contractName: string): ContractInstance | null;
/**
* Register contracts with the wrapper
*/
registerContracts(contracts: ContractConfig[]): void;
/**
* Send transaction through wrapper
*/
sendTransaction(txRequest: any): Promise<any>;
/**
* Disconnect wallet
*/
disconnect(): void;
/**
* Check if wallet is connected
*/
isConnected(): boolean;
/**
* Get current user address
*/
getUserAddress(): Promise<string | null>;
/**
* Event handling (MetaMask-style)
*/
on(event: string, callback: Function): void;
off(event: string, callback: Function): void;
private emit;
/**
* Initialize event handlers for wrapper events
*/
private initializeEventHandlers;
/**
* Extract address from wrapper with multiple fallback strategies
*/
private extractAddressFromWrapper;
/**
* Debug wrapper state for troubleshooting
*/
private debugWrapperState;
/**
* Normalize and validate Ethereum address with flexible handling
* Handles various formats that MetaMask/wallets might return
*/
private normalizeAndValidateAddress;
/**
* Legacy method for backward compatibility
*/
private isValidAddress;
/**
* Cleanup resources
*/
destroy(): void;
}
//# sourceMappingURL=IncentivWalletService.d.ts.map