/* @flow */ import type BigNumber from 'bignumber.js'; import type { EthereumUnitT, EthereumAddressT } from 'ethereum-types'; declare module 'web3' { declare type HttpProviderT = { host: string; timeout: number; isConnected: () => boolean; send: (payload: any) => any; sendAsync: (payload: any, callback: (error: Error, result: any) => void) => any; }; declare type WebsocketProviderT = { connection: { close: () => void; }; // WebSocket type on: (type: string, callback: () => any) => void; removeAllListeners: (type: string) => void; reset: () => void; connected: boolean; } declare class Web3T { static providers: { HttpProvider: (host: string, timeout?: number) => HttpProviderT; WebsocketProvider: (host: string, options?: any) => WebsocketProviderT; }; // constructor(HttpProviderT): Web3T; constructor(WebsocketProviderT): Web3T; // currentProvider: HttpProviderT; currentProvider: WebsocketProviderT; eth: Eth; utils: Utils; toHex: (str: string | number) => string; isAddress: (address: string) => boolean; toWei: (number: BigNumber, unit?: EthereumUnitT) => BigNumber; toWei: (number: string, unit?: EthereumUnitT) => string; toDecimal: (number: BigNumber) => number; toDecimal: (number: string) => number; soliditySha3: (payload: string | number | BigNumber | Object) => String; fromWei: (number: string, unit?: EthereumUnitT) => string; version: { api: string; network: string; // and many more } } declare export type EstimateGasOptions = { to: string; data: string; value?: string; gasPrice?: string; } declare export type RawTransaction = { id: string; } declare export type TransactionStatus = { blockHash: string, blockNumber: ?number, from: string, gas: number, gasPrice: BigNumber, hash: string, input: string, nonce: number, r: string, s: string, v: string, to: string, transactionIndex: number, value: BigNumber } declare export type TransactionReceipt = { blockHash: string, blockNumber: number, contractAddress: ?string, cumulativeGasUsed: number, from: string, gasUsed: number, logs: Array, status: string, to: string, transactionHash: string, transactionIndex: number } //declare function F_CardanoGetAddress(params: (P.$Common & CARDANO.$CardanoGetAddress)): Promise; //declare function F_CardanoGetAddress(params: (P.$Common & { bundle: Array })): Promise; declare type PromiseEvent = { once: typeof F_PromiseEventOn; on: typeof F_PromiseEventOn; off: (type: string, callback: Function) => PromiseEvent; then: () => (result: T) => PromiseEvent; catch: () => (error: Error) => PromiseEvent; } declare function F_PromiseEventOn(type: 'transactionHash', callback: (hash: string) => void): PromiseEvent; declare function F_PromiseEventOn(type: 'receipt', callback: (receipt: TransactionReceipt) => void): PromiseEvent; declare function F_PromiseEventOn(type: 'confirmation', callback: (confirmations: number, receipt: TransactionReceipt) => void): PromiseEvent; declare function F_PromiseEventOn(type: 'error', callback: (error: Error) => void): PromiseEvent; declare class Eth { getBalance: (address: string) => Promise; getTransactionCount: (address: string) => Promise; estimateGas: (options: EstimateGasOptions) => Promise; getGasPrice: () => Promise; getBlockNumber: () => Promise; Contract: (abi: Array, options?: any) => Contract; sendSignedTransaction: (tx: string) => PromiseEvent; getTransaction: (txid: string) => Promise; getTransactionReceipt: (txid: string) => Promise; subscribe: (type: string, callback: Function) => any; } declare export class Filter { watch: (callback: (error: ?Error, blockHash: ?string) => void | Promise) => void, stopWatching: (callback: any) => void, } declare type ContractMethod = { call: () => Promise; } declare export class Contract { clone: () => Contract; options: { address: string; jsonInterface: JSON; }; methods: { name: () => ContractMethod; symbol: () => ContractMethod; decimals: () => ContractMethod; balanceOf: (address: string) => ContractMethod; transfer: (to: string, amount: any) => { encodeABI: () => string; } }; } declare class Utils { toHex: (str: string | number) => string; hexToNumberString: (str: string) => string; isAddress: (address: string) => boolean; toWei: (number: BigNumber, unit?: EthereumUnitT) => BigNumber; toWei: (number: string, unit?: EthereumUnitT) => string; toDecimal: (number: BigNumber) => number; toDecimal: (number: string) => number; soliditySha3: (payload: string | number | BigNumber | Object) => String; } declare export default typeof Web3T; }