UNPKG

3.51 kBTypeScriptView Raw
1import { Client } from './client';
2export interface IEthReceipt {
3 transactionHash: string;
4 transactionIndex: string;
5 blockHash: string;
6 blockNumber: string;
7 gasUsed: string;
8 cumulativeGasUsed: string;
9 contractAddress: string;
10 logs: Array<any>;
11 status: string;
12}
13export interface IEthTransaction {
14 hash: string;
15 nonce: string;
16 blockHash: string;
17 blockNumber: string;
18 transactionIndex: string;
19 from: string;
20 to: string;
21 value: string;
22 gasPrice: string;
23 gas: string;
24 input: string;
25}
26export interface IEthBlock {
27 blockNumber: string;
28 transactionHash: string;
29 parentHash: string;
30 logsBloom: string;
31 timestamp: number;
32 transactions: Array<IEthReceipt | string>;
33}
34export interface IEthRPCPayload {
35 id: number;
36 method: string;
37 params: Array<any>;
38}
39/**
40 * Web3 provider that interacts with EVM contracts deployed on Loom DAppChains.
41 */
42export declare class LoomProvider {
43 private _client;
44 protected notificationCallbacks: Array<Function>;
45 readonly accounts: Map<string, Uint8Array>;
46 readonly accountsAddrList: Array<string>;
47 /**
48 * Constructs the LoomProvider to bridges communication between Web3 and Loom DappChains
49 *
50 * @param client Client from LoomJS
51 * @param privateKey Account private key
52 */
53 constructor(client: Client, privateKey: Uint8Array);
54 /**
55 * Creates new accounts by passing the private key array
56 *
57 * Accounts will be available on public properties accounts and accountsAddrList
58 *
59 * @param accountsPrivateKey Array of private keys to create new accounts
60 */
61 addAccounts(accountsPrivateKey: Array<Uint8Array>): void;
62 on(type: string, callback: any): void;
63 addDefaultEvents(): void;
64 removeListener(type: string, callback: (...args: any[]) => void): void;
65 removeAllListeners(type: string, callback: Function): void;
66 reset(): void;
67 disconnect(): void;
68 sendAsync(payload: any, callback?: Function): Promise<any | void>;
69 /**
70 * Should be used to make async request
71 * This method is used internally by web3, so we adapt it to be used with loom contract
72 * when we are wrapping the evm on a DAppChain
73 * @param payload JSON payload generated by web3 which will be translated to loom transaction/call
74 * @param callback Triggered on end with (err, result)
75 */
76 send(payload: any, callback: Function): Promise<void>;
77 private _ethAccounts;
78 private _ethBlockNumber;
79 private _ethCall;
80 private _ethEstimateGas;
81 private _ethGasPrice;
82 private _ethGetBlockByHash;
83 private _ethGetBlockByNumber;
84 private _ethGetCode;
85 private _ethGetFilterChanges;
86 private _ethGetLogs;
87 private _ethGetTransactionByHash;
88 private _ethGetTransactionReceipt;
89 private _ethNewBlockFilter;
90 private _ethNewFilter;
91 private _ethNewPendingTransactionFilter;
92 private _ethSendTransaction;
93 private _ethSubscribe;
94 private _ethUninstallFilter;
95 private _ethUnsubscribe;
96 private _netVersion;
97 private _deployAsync;
98 private _callAsync;
99 private _callStaticAsync;
100 private _createBlockInfo;
101 private _createReceiptResult;
102 private _getTransaction;
103 private _getReceipt;
104 private _getLogs;
105 private _onWebSocketMessage;
106 private _commitTransaction;
107 private _okResponse;
108}