cdp-wallet-onramp-kit
Version:
Complete toolkit for Coinbase Developer Platform (CDP) Embedded Wallets and Onramp integration with reusable components, utilities, and documentation
69 lines (68 loc) • 2.32 kB
TypeScript
/**
* Hook return type detection and normalization utilities
* Handles compatibility between different CDP SDK versions that return different types
*/
/**
* Normalized user data structure
*/
export interface NormalizedUser {
userId: string;
email?: string;
evmAccounts: string[];
}
/**
* Safe extraction of EVM address from CDP hooks
* Handles both primitive string returns and object returns
*
* @param evmAddressResult - Result from useEvmAddress() hook
* @returns string | null - The EVM address or null
*/
export declare function getEvmAddress(evmAddressResult: any): string | null;
/**
* Safe extraction of current user from CDP hooks
* Handles both primitive object returns and nested object returns
*
* @param currentUserResult - Result from useCurrentUser() hook
* @returns NormalizedUser | null - The normalized user data or null
*/
export declare function getCurrentUser(currentUserResult: any): NormalizedUser | null;
/**
* Safe extraction of initialization status
* Handles both boolean returns and object returns
*
* @param isInitializedResult - Result from useIsInitialized() hook
* @returns boolean - The initialization status
*/
export declare function getIsInitialized(isInitializedResult: any): boolean;
/**
* Safe extraction of action hooks (signOut, signInWithEmail, etc.)
* These hooks typically return objects with action functions
*
* @param hookResult - Result from action hook (useSignOut, useSignInWithEmail, etc.)
* @returns object - The action functions or empty object
*/
export declare function getHookActions(hookResult: any): Record<string, Function>;
/**
* Detect CDP SDK environment and version compatibility
* Provides diagnostic information for troubleshooting
*
* @returns object - Environment diagnostic information
*/
export declare function detectCDPEnvironment(): {
hasWindow: boolean;
hasProcess: boolean;
nodeEnv: string;
userAgent: string;
recommendations: string[];
};
/**
* Validate that CDP hooks are returning expected types
* Run this in development to catch compatibility issues early
*
* @param hookResults - Object containing results from various hooks
*/
export declare function validateHookReturns(hookResults: {
evmAddress?: any;
currentUser?: any;
isInitialized?: any;
}): void;