import type { InjectedProvider, ProviderList, ProviderMeta } from '@soul-wallet/extension-inject/types'; import type { ProviderInterfaceEmitCb, ProviderInterfaceEmitted } from '@polkadot/rpc-provider/types'; import type { AnyFunction } from '@polkadot/types/types'; import type { SendRequest } from './types'; declare type CallbackHandler = (error?: null | Error, value?: unknown) => void; interface SubscriptionHandler { callback: CallbackHandler; type: string; } /** * @name PostMessageProvider * * @description Extension provider to be used by dapps */ export default class PostMessageProvider implements InjectedProvider { #private; isClonable: boolean; /** * @param {function} sendRequest The function to be called to send requests to the node * @param {function} subscriptionNotificationHandler Channel for receiving subscription messages */ constructor(_sendRequest: SendRequest); /** * @description Returns a clone of the object */ clone(): PostMessageProvider; /** * @description Manually disconnect from the connection, clearing autoconnect logic */ connect(): Promise; /** * @description Manually disconnect from the connection, clearing autoconnect logic */ disconnect(): Promise; /** * @summary `true` when this provider supports subscriptions */ get hasSubscriptions(): boolean; /** * @summary Whether the node is connected or not. * @return {boolean} true if connected */ get isConnected(): boolean; listProviders(): Promise; /** * @summary Listens on events after having subscribed using the [[subscribe]] function. * @param {ProviderInterfaceEmitted} type Event * @param {ProviderInterfaceEmitCb} sub Callback * @return unsubscribe function */ on(type: ProviderInterfaceEmitted, sub: ProviderInterfaceEmitCb): () => void; send(method: string, params: unknown[], _?: boolean, subscription?: SubscriptionHandler): Promise; /** * @summary Spawn a provider on the extension background. */ startProvider(key: string): Promise; subscribe(type: string, method: string, params: unknown[], callback: AnyFunction): Promise; /** * @summary Allows unsubscribing to subscriptions made with [[subscribe]]. */ unsubscribe(type: string, method: string, id: number): Promise; } export {};