import type { Account, Chain, ChainId, Client, Compute, HttpRpcClient, } from '@bigmi/core' import type { Emitter } from '../factories/createEmitter.js' import type { Storage } from './storage.js' export type Connector< createConnectorFn extends CreateConnectorFn = CreateConnectorFn, > = ReturnType & { emitter: Emitter uid: string } export type ConnectorEventMap = { change: { accounts?: readonly Account[] | undefined chainId?: ChainId | undefined } connect: { accounts: readonly Account[]; chainId: ChainId } disconnect: never error: { error: Error } message: { type: string; data?: unknown | undefined } } export type CreateConnectorFn< provider = unknown, properties extends Record = Record, storageItem extends Record = Record, > = (config: { chains: readonly [Chain, ...Chain[]] emitter: Emitter storage?: Compute> | null | undefined transports?: Record | undefined }) => Compute< { readonly icon?: string | undefined readonly id: string readonly name: string readonly rdns?: string | readonly string[] | undefined /** @deprecated */ readonly supportsSimulation?: boolean | undefined readonly type: string setup?(): Promise connect( parameters?: | { chainId?: ChainId | undefined isReconnecting?: boolean | undefined } | undefined ): Promise<{ accounts: readonly Account[] chainId: ChainId }> disconnect(): Promise getAccounts(): Promise getChainId(): Promise getProvider( parameters?: { chainId?: ChainId | undefined } | undefined ): Promise getClient?( parameters?: { chainId?: ChainId | undefined } | undefined ): Promise isAuthorized(): Promise switchChain?(parameters: { chainId: ChainId }): Promise onAccountsChanged(accounts: Account[]): void onChainChanged(chainId: ChainId): void onConnect?(connectInfo: ProviderConnectInfo): void onDisconnect(error?: Error | undefined): void onMessage?(message: ProviderMessage): void } & properties > interface ProviderConnectInfo { readonly chainId: ChainId } interface ProviderMessage { readonly type: string readonly data: unknown }