@turnkey/core
Version:
A core JavaScript web and React Native package for interfacing with Turnkey's infrastructure.
70 lines • 3.36 kB
TypeScript
import { CrossPlatformWalletStamper } from "../stamper";
import { CrossPlatformWalletConnector } from "../connector";
import { TWalletManagerConfig, WalletInterface, WalletProvider, WalletInterfaceType, Chain } from "../../__types__";
export declare class WebWalletManager {
private initializers;
private wcClient?;
readonly wallets: Partial<Record<WalletInterfaceType, WalletInterface>>;
private chainToInterfaces;
readonly stamper?: CrossPlatformWalletStamper;
readonly connector?: CrossPlatformWalletConnector;
/**
* Constructs a WebWalletManager instance based on the provided configuration.
*
* - Enables native Ethereum and/or Solana wallet support if configured.
* - Enables WalletConnect support for Ethereum and/or Solana chains if namespaces are provided.
* - Sets up `CrossPlatformWalletStamper` and `CrossPlatformWalletConnector` if auth or connecting features are enabled.
*
* @param cfg - Wallet manager configuration.
*/
constructor(cfg: TWalletManagerConfig);
private wcInitPromise?;
/**
* Initializes WalletConnect components and any registered wallet interfaces.
*
* - Initializes the low-level WalletConnect client with the provided config.
* - Runs any registered async wallet initializers (currently only `WalletConnectWallet`).
* - WalletConnect initialization happens in the background and does not block this method.
*
* @param cfg - Wallet manager configuration used for initializing the WalletConnect client.
*/
init(cfg: TWalletManagerConfig): Promise<void>;
/**
* Ensures WalletConnect is fully initialized before proceeding.
* This should be called before any WalletConnect operations.
*
* @returns A promise that resolves when WalletConnect is ready.
*/
ensureWalletConnectReady(): Promise<void>;
/**
* Retrieves available wallet providers, optionally filtered by chain.
*
* - If a chain is specified, filters wallet interfaces that support that chain.
* - Aggregates providers across all wallet interfaces and filters WalletConnect results accordingly.
* - Returns native wallet providers immediately without waiting for WalletConnect.
* - WalletConnect providers will only be included if WalletConnect has already initialized.
*
* @param chain - Optional chain to filter providers by (e.g., Ethereum, Solana).
* @returns A promise that resolves to an array of `WalletProvider` objects.
* @throws {Error} If no wallet interface is registered for the given chain.
*/
getProviders(chain?: Chain): Promise<WalletProvider[]>;
/**
* Registers a wallet interface type as supporting a specific blockchain chain.
*
* @param chain - Chain (e.g., Ethereum, Solana).
* @param interfaceType - Wallet interface type to associate with the chain.
*/
private addChainInterface;
/**
* Removes a wallet interface from the manager.
*
* - Deletes the wallet instance from the wallets map.
* - Cleans up references to the wallet interface in chainToInterfaces.
* - Removes the chain entry entirely if no interfaces remain.
*
* @param type - The WalletInterfaceType to remove.
*/
private removeWalletInterface;
}
//# sourceMappingURL=manager.d.ts.map