///
import EventEmitter from 'events';
import { Account, Chain, EIP1193Provider, Transport, WalletClient as WalletClient_ } from 'viem';
import type { Address } from 'viem';
export type ConnectorData = {
account?: Address;
chain?: {
id: number;
unsupported: boolean;
};
};
export declare class ChainNotConfiguredForConnectorError extends Error {
name: string;
constructor({ chainId, connectorId, }: {
chainId: number;
connectorId?: string;
});
}
export declare class ConnectorNotFoundError extends Error {
name: string;
message: string;
}
type InjectedProviderFlags = {
isApexWallet?: true;
isAvalanche?: true;
isBackpack?: true;
isBifrost?: true;
isBitKeep?: true;
isBitski?: true;
isBlockWallet?: true;
isBraveWallet?: true;
isCoinbaseWallet?: true;
isDawn?: true;
isDefiant?: true;
isEnkrypt?: true;
isExodus?: true;
isFrame?: true;
isFrontier?: true;
isGamestop?: true;
isHaqqWallet?: true;
isHyperPay?: true;
isImToken?: true;
isKuCoinWallet?: true;
isMathWallet?: true;
isMetaMask?: true;
isNovaWallet?: true;
isOkxWallet?: true;
isOKExWallet?: true;
isOneInchAndroidWallet?: true;
isOneInchIOSWallet?: true;
isOpera?: true;
isPhantom?: true;
isPortal?: true;
isRabby?: true;
isRainbow?: true;
isStatus?: true;
isTalisman?: true;
isTally?: true;
isTokenPocket?: true;
isTokenary?: true;
isTrust?: true;
isTrustWallet?: true;
isTTWallet?: true;
isXDEFI?: true;
isZerion?: true;
isHaloWallet?: true;
};
type InjectedProviders = InjectedProviderFlags & {
isMetaMask: true;
/** Only exists in MetaMask as of 2022/04/03 */
_events: {
connect?: () => void;
};
/** Only exists in MetaMask as of 2022/04/03 */
_state?: {
accounts?: string[];
initialized?: boolean;
isConnected?: boolean;
isPermanentlyDisconnected?: boolean;
isUnlocked?: boolean;
};
};
export interface WindowProvider extends InjectedProviders, EIP1193Provider {
providers?: WindowProvider[];
}
export type WalletClient = WalletClient_;
export type Storage = {
getItem(key: string, defaultState?: T | null): T | null;
setItem(key: string, value: T | null): void;
removeItem(key: string): void;
};
export type StorageStoreData = {
state: {
data?: ConnectorData;
};
};
export declare abstract class Connector extends EventEmitter {
/** Unique connector id */
abstract readonly id: string;
/** Connector name */
abstract readonly name: string;
/** Chains connector supports */
readonly chains: Chain[];
/** Options to use with connector */
readonly options: Options;
/** Connector storage. */
protected storage?: Storage;
/** Whether connector is usable */
abstract readonly ready: boolean;
constructor({ chains, options, }: {
chains?: Chain[];
options: Options;
});
abstract connect(config?: {
chainId?: number;
}): Promise>;
abstract disconnect(): Promise;
abstract getAccount(): Promise;
abstract getChainId(): Promise;
abstract getProvider(config?: {
chainId?: number;
}): Promise;
abstract getWalletClient(config?: {
chainId?: number;
}): Promise;
abstract isAuthorized(): Promise;
switchChain?(chainId: number): Promise;
watchAsset?(asset: {
address: string;
decimals?: number;
image?: string;
symbol: string;
}): Promise;
protected abstract onAccountsChanged(accounts: Address[]): void;
protected abstract onChainChanged(chain: number | string): void;
protected abstract onDisconnect(error: Error): void;
protected getBlockExplorerUrls(chain: Chain): any[] | undefined;
protected isChainUnsupported(chainId: number): boolean;
setStorage(storage: Storage): void;
}
export declare function normalizeChainId(chainId: string | number | bigint | null): number | null;
export {};