UNPKG

@robincore/flutter-dapp-provider

Version:

a javascript ethereum provider injector used as an interface between wallet and dApps. [for flutter]

40 lines (39 loc) 1.54 kB
/// <reference types="node" /> import { EventEmitter } from 'events'; import { InitProviderTypes } from './InitProviderTypes'; import { JsonRpcEngine, JsonRpcId, JsonRpcVersion } from 'json-rpc-engine'; import { IParams, IPayload } from "../bridge/IParams"; import { ISetup } from "../bridge/ISetup"; declare global { interface Window { coreDapp: any; } } export declare type funcType<T> = T | undefined; export interface NonValidatedRequest { id?: JsonRpcId; jsonrpc?: JsonRpcVersion; method: string; params?: unknown; } declare abstract class InitProvider extends EventEmitter implements InitProviderTypes { address: string | undefined; provider: string | undefined; chainId: string | undefined; protected rpcEngine: JsonRpcEngine; protected _isConnected: boolean; protected constructor(setup: ISetup); private _initState; isConnected(): boolean; _onMessage(listener: string, data: object): void; request<T>(args: IPayload): Promise<funcType<T>>; protected _rpcRequest(payload: NonValidatedRequest | NonValidatedRequest[], callback: (...args: any[]) => void): void; protected _handleAccountsChanged(accounts: (string | undefined)[]): void; eth_Accounts(): string[]; eth_chainId(): string | undefined; eth_sign(payload: IParams): void; handleChainChange(chainId: string): void; protected _onChainChanged(chainId: string): void; protected _handleOnDisconnect(): void; } export default InitProvider;