UNPKG

openzeppelin-network-test

Version:

An easy to use and reliable library that provides one line access to Web3 API.

38 lines (37 loc) 1.13 kB
/// <reference types="node" /> import Web3 from 'web3'; import { Provider } from 'web3/providers'; import { EventEmitter } from 'events'; import { KeyPair } from '../wallet/keys'; export interface GSNOptions { dev: boolean; useGSN: boolean; ownerAddress: string; relayerAddress: string; signKey: KeyPair; } export interface Web3ContextOptions { timeout: number; pollInterval: number; gsn: boolean | GSNOptions; } export default class Web3Context extends EventEmitter { static NetworkIdChangedEventName: string; static AccountsChangedEventName: string; static ConnectionChangedEventName: string; readonly lib: Web3; readonly timeout: number; readonly pollInterval: number; readonly providerName: string; connected: boolean; accounts: string[] | null; networkId: number | null; networkName: string | null; private pollHandle?; constructor(provider: Provider, options?: Partial<Web3ContextOptions>); startPoll(): void; stopPoll(): void; poll(): Promise<void>; private updateValueAndFireEvent; requestAuth(): Promise<string[]>; }