UNPKG

3.8 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}
39export interface IEthFilterLog {
40 removed: boolean;
41 logIndex: string;
42 transactionIndex: string;
43 transactionHash: string;
44 blockHash: string;
45 blockNumber: string;
46 address: string;
47 data: string;
48 topics: Array<string>;
49}
50/**
51 * Web3 provider that interacts with EVM contracts deployed on Loom DAppChains.
52 */
53export declare class LoomProvider {
54 private _client;
55 protected notificationCallbacks: Array<Function>;
56 readonly accounts: Map<string, Uint8Array>;
57 readonly accountsAddrList: Array<string>;
58 /**
59 * Constructs the LoomProvider to bridges communication between Web3 and Loom DappChains
60 *
61 * @param client Client from LoomJS
62 * @param privateKey Account private key
63 */
64 constructor(client: Client, privateKey: Uint8Array);
65 /**
66 * Creates new accounts by passing the private key array
67 *
68 * Accounts will be available on public properties accounts and accountsAddrList
69 *
70 * @param accountsPrivateKey Array of private keys to create new accounts
71 */
72 addAccounts(accountsPrivateKey: Array<Uint8Array>): void;
73 on(type: string, callback: any): void;
74 addDefaultEvents(): void;
75 removeListener(type: string, callback: (...args: any[]) => void): void;
76 removeAllListeners(type: string, callback: Function): void;
77 reset(): void;
78 disconnect(): void;
79 sendAsync(payload: any, callback?: Function): Promise<any | void>;
80 /**
81 * Should be used to make async request
82 * This method is used internally by web3, so we adapt it to be used with loom contract
83 * when we are wrapping the evm on a DAppChain
84 * @param payload JSON payload generated by web3 which will be translated to loom transaction/call
85 * @param callback Triggered on end with (err, result)
86 */
87 send(payload: any, callback: Function): Promise<void>;
88 private _ethAccounts;
89 private _ethBlockNumber;
90 private _ethCall;
91 private _ethEstimateGas;
92 private _ethGasPrice;
93 private _ethGetBlockByHash;
94 private _ethGetBlockByNumber;
95 private _ethGetCode;
96 private _ethGetFilterChanges;
97 private _ethGetLogs;
98 private _ethGetTransactionByHash;
99 private _ethGetTransactionReceipt;
100 private _ethNewBlockFilter;
101 private _ethNewFilter;
102 private _ethNewPendingTransactionFilter;
103 private _ethSendTransaction;
104 private _ethSubscribe;
105 private _ethUninstallFilter;
106 private _ethUnsubscribe;
107 private _netVersion;
108 private _deployAsync;
109 private _callAsync;
110 private _callStaticAsync;
111 private _createBlockInfo;
112 private _createReceiptResult;
113 private _getTransaction;
114 private _getReceipt;
115 private _createLogResult;
116 private _getLogs;
117 private _onWebSocketMessage;
118 private _commitTransaction;
119 private _okResponse;
120}