UNPKG

@turnkey/core

Version:

A core JavaScript web and React Native package for interfacing with Turnkey's infrastructure.

60 lines 3.23 kB
import { SignIntent, WalletProvider, WalletInterface, WalletInterfaceType, SwitchableChain } from "../__types__"; export interface CrossPlatformWalletConnectorInterface { sign(message: string | Uint8Array, walletProvider: WalletProvider, intent: SignIntent): Promise<string>; } export declare class CrossPlatformWalletConnector implements CrossPlatformWalletConnectorInterface { private readonly wallets; /** * Constructs a CrossPlatformWalletConnector. * * - Validates that at least one wallet interface is provided. * - Stores the provided mapping of wallet interfaces. * * @param wallets - A partial mapping of wallet interfaces by type. * @throws {Error} If no wallet interfaces are provided. */ constructor(wallets: Partial<Record<WalletInterfaceType, WalletInterface>>); /** * Connects the wallet account for the given provider. * * @param provider - The wallet provider to connect. * @returns A promise that resolves with the connected wallet's address. */ connectWalletAccount(provider: WalletProvider): Promise<string>; /** * Disconnects the wallet account for the given provider. * * @param provider - The wallet provider to disconnect. * @returns A promise that resolves once the wallet account is disconnected. */ disconnectWalletAccount(provider: WalletProvider): Promise<void>; /** * Switches the chain for an EVM-compatible wallet provider (native or WalletConnect). * * - Only supported for wallet providers on the Ethereum namespace. * - Native (extension) wallets: * - If `chainOrId` is a hex string and the wallet doesn't support it, the switch will fail. * - If `chainOrId` is a `SwitchableChain` object, the wallet will attempt to switch; if the chain * is unsupported, it will first add the chain (via `wallet_addEthereumChain`) and then retry switching. * - WalletConnect wallets: * - Chain support is negotiated up front via namespaces. If the target chain isn't in the session's * `ethereumNamespaces`, the switch will fail. To support a new chain, you must specify it in the walletConfig. * * @param provider - The EVM-compatible wallet provider to switch chains for. * @param chainOrId - The target chain ID (hex string) or full chain config (`SwitchableChain`). * @returns A promise that resolves once the chain switch is complete. * @throws {Error} If the provider is not Ethereum-based or doesn't support switching. */ switchChain(provider: WalletProvider, chainOrId: string | SwitchableChain): Promise<void>; /** * Signs a payload using the appropriate wallet based on the provider. * * @param payload - The payload to be signed. * @param walletProvider - The wallet provider used for signing. * @param intent - The signing intent (e.g., message, transaction). * @returns A promise that resolves to a hex string (signature or tx hash). * @throws {Error} If the wallet is not initialized. */ sign(payload: string, walletProvider: WalletProvider, intent: SignIntent): Promise<string>; } //# sourceMappingURL=connector.d.ts.map