-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
670 lines (670 loc) · 18 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
/**
*
* Hex representation of a Keccak 256 hash
*
*/
export type Keccak = string;
/**
*
* Null
*
*/
export type Null = null;
/**
*
* The block hash or null when its the pending block
*
*/
export type BlockHashOrNull = Keccak | Null;
/**
*
* The hex representation of the block's height
*
*/
export type BlockNumber = string;
/**
*
* The block number or null when its the pending block
*
*/
export type BlockNumberOrNull = BlockNumber | Null;
/**
*
* The sender of the transaction
*
*/
export type From = string;
/**
*
* The gas limit provided by the sender in Wei
*
*/
export type TransactionGas = string;
/**
*
* The gas price willing to be paid by the sender in Wei
*
*/
export type TransactionGasPrice = string;
/**
*
* Keccak 256 Hash of the RLP encoding of a transaction
*
*/
export type TransactionHash = string;
/**
*
* The data field sent with the transaction
*
*/
export type TransactionInput = string;
/**
*
* The total number of prior transactions made by the sender
*
*/
export type TransactionNonce = string;
export type Address = string;
/**
*
* Destination address of the transaction. Null if it was a contract create.
*
*/
export type To = Address | Null;
/**
*
* Hex representation of the integer
*
*/
export type Integer = string;
/**
*
* The index of the transaction. null when its pending
*
*/
export type TransactionIndex = Integer | Null;
/**
*
* Value of Ether being transferred in Wei
*
*/
export type TransactionValue = string;
/**
*
* ECDSA recovery id
*
*/
export type TransactionSigV = string;
/**
*
* ECDSA signature r
*
*/
export type TransactionSigR = string;
/**
*
* ECDSA signature s
*
*/
export type TransactionSigS = string;
/**
*
* The optional block height description
*
*/
export type BlockNumberTag = "earliest" | "latest" | "pending";
/**
*
* List of contract addresses from which to monitor events
*
*/
export type Addresses = Address[];
export type OneOrArrayOfAddresses = Address | Addresses;
/**
*
* 32 Bytes DATA of indexed log arguments. (In solidity: The first topic is the hash of the signature of the event (e.g. Deposit(address,bytes32,uint256))
*
*/
export type Topic = string;
/**
*
* Topics are order-dependent. Each topic can also be an array of DATA with 'or' options.
*
*/
export type LogTopics = Topic[];
/**
*
* The key used to get the storage slot in its account tree.
*
*/
export type StorageProofKey = string;
/**
*
* The hex representation of the Keccak 256 of the RLP encoded block
*
*/
export type BlockHash = string;
/**
*
* A number only to be used once
*
*/
export type Nonce = string;
export type NonceOrNull = Nonce | Null;
/**
*
* Keccak hash of the uncles data in the block
*
*/
export type BlockShaUncles = string;
/**
*
* The bloom filter for the logs of the block or null when its the pending block
*
*/
export type BlockLogsBloom = string;
/**
*
* The root of the transactions trie of the block.
*
*/
export type BlockTransactionsRoot = string;
/**
*
* The root of the final state trie of the block
*
*/
export type BlockStateRoot = string;
/**
*
* The root of the receipts trie of the block
*
*/
export type BlockReceiptsRoot = string;
export type AddressOrNull = Address | Null;
/**
*
* Integer of the difficulty for this block
*
*/
export type BlockDifficulty = string;
/**
*
* Integer of the total difficulty of the chain until this block
*
*/
export type BlockTotalDifficulty = Integer | Null;
/**
*
* The 'extra data' field of this block
*
*/
export type BlockExtraData = string;
/**
*
* Integer the size of this block in bytes
*
*/
export type BlockSize = string;
/**
*
* The maximum gas allowed in this block
*
*/
export type BlockGasLimit = string;
/**
*
* The total used gas by all transactions in this block
*
*/
export type BlockGasUsed = string;
/**
*
* The unix timestamp for when the block was collated
*
*/
export type BlockTimeStamp = string;
export interface Transaction {
blockHash?: BlockHashOrNull;
blockNumber?: BlockNumberOrNull;
from?: From;
gas: TransactionGas;
gasPrice: TransactionGasPrice;
hash?: TransactionHash;
input?: TransactionInput;
nonce: TransactionNonce;
to?: To;
transactionIndex?: TransactionIndex;
value?: TransactionValue;
v?: TransactionSigV;
r?: TransactionSigR;
s?: TransactionSigS;
[k: string]: any;
}
export type TransactionOrTransactionHash = Transaction | TransactionHash;
/**
*
* Array of transaction objects, or 32 Bytes transaction hashes depending on the last given parameter
*
*/
export type TransactionsOrHashes = TransactionOrTransactionHash[];
/**
*
* Block hash of the RLP encoding of an uncle block
*
*/
export type UncleHash = string;
/**
*
* Array of uncle hashes
*
*/
export type UncleHashes = UncleHash[];
/**
*
* The Block is the collection of relevant pieces of information (known as the block header), together with information corresponding to the comprised transactions, and a set of other block headers that are known to have a parent equal to the present block’s parent’s parent.
*
*/
export interface Block {
number?: BlockNumberOrNull;
hash?: BlockHashOrNull;
parentHash?: BlockHash;
nonce?: NonceOrNull;
sha3Uncles?: BlockShaUncles;
logsBloom?: BlockLogsBloom;
transactionsRoot?: BlockTransactionsRoot;
stateRoot?: BlockStateRoot;
receiptsRoot?: BlockReceiptsRoot;
miner?: AddressOrNull;
difficulty?: BlockDifficulty;
totalDifficulty?: BlockTotalDifficulty;
extraData?: BlockExtraData;
size?: BlockSize;
gasLimit?: BlockGasLimit;
gasUsed?: BlockGasUsed;
timestamp?: BlockTimeStamp;
transactions?: TransactionsOrHashes;
uncles?: UncleHashes;
[k: string]: any;
}
/**
*
* Sender of the transaction
*
*/
export type LogAddress = string;
/**
*
* The data/input string sent along with the transaction
*
*/
export type LogData = string;
/**
*
* The index of the event within its transaction, null when its pending
*
*/
export type LogIndex = string;
/**
*
* Whether or not the log was orphaned off the main chain
*
*/
export type LogIsRemoved = boolean;
/**
*
* An indexed event generated during a transaction
*
*/
export interface Log {
address?: LogAddress;
blockHash?: BlockHash;
blockNumber?: BlockNumber;
data?: LogData;
logIndex?: LogIndex;
removed?: LogIsRemoved;
topics?: LogTopics;
transactionHash?: TransactionHash;
transactionIndex?: TransactionIndex;
[k: string]: any;
}
/**
*
* The contract address created, if the transaction was a contract creation, otherwise null
*
*/
export type ReceiptContractAddress = Address | Null;
/**
*
* The gas units used by the transaction
*
*/
export type ReceiptCumulativeGasUsed = string;
/**
*
* The total gas used by the transaction
*
*/
export type ReceiptGasUsed = string;
/**
*
* An array of all the logs triggered during the transaction
*
*/
export type Logs = Log[];
/**
*
* A 2048 bit bloom filter from the logs of the transaction. Each log sets 3 bits though taking the low-order 11 bits of each of the first three pairs of bytes in a Keccak 256 hash of the log's byte series
*
*/
export type BloomFilter = string;
/**
*
* The intermediate stateRoot directly after transaction execution.
*
*/
export type ReceiptPostTransactionState = string;
/**
*
* Whether or not the transaction threw an error.
*
*/
export type ReceiptStatus = boolean;
/**
*
* The receipt of a transaction
*
*/
export interface Receipt {
blockHash: BlockHash;
blockNumber: BlockNumber;
contractAddress: ReceiptContractAddress;
cumulativeGasUsed: ReceiptCumulativeGasUsed;
from: From;
gasUsed: ReceiptGasUsed;
logs: Logs;
logsBloom: BloomFilter;
to: To;
transactionHash: TransactionHash;
transactionIndex: TransactionIndex;
postTransactionState?: ReceiptPostTransactionState;
status?: ReceiptStatus;
[k: string]: any;
}
/**
*
* The address of the account or contract of the request
*
*/
export type ProofAccountAddress = string;
/**
*
* An individual node used to prove a path down a merkle-patricia-tree
*
*/
export type ProofNode = string;
/**
*
* The set of node values needed to traverse a patricia merkle tree (from root to leaf) to retrieve a value
*
*/
export type ProofNodes = ProofNode[];
/**
*
* The Ether balance of the account or contract of the request
*
*/
export type ProofAccountBalance = string;
/**
*
* The code hash of the contract of the request (keccak(NULL) if external account)
*
*/
export type ProofAccountCodeHash = string;
/**
*
* The transaction count of the account or contract of the request
*
*/
export type ProofAccountNonce = string;
/**
*
* The storage hash of the contract of the request (keccak(rlp(NULL)) if external account)
*
*/
export type ProofAccountStorageHash = string;
/**
*
* The value of the storage slot in its account tree
*
*/
export type StorageProofValue = string;
/**
*
* Object proving a relationship of a storage value to an account's storageHash.
*
*/
export interface StorageProof {
key?: StorageProofKey;
value?: StorageProofValue;
proof?: ProofNodes;
[k: string]: any;
}
/**
*
* Current block header PoW hash.
*
*/
export type StorageProofSet = StorageProof[];
/**
*
* The merkle proofs of the specified account connecting them to the blockhash of the block specified
*
*/
export interface ProofAccount {
address?: ProofAccountAddress;
accountProof?: ProofNodes;
balance?: ProofAccountBalance;
codeHash?: ProofAccountCodeHash;
nonce?: ProofAccountNonce;
storageHash?: ProofAccountStorageHash;
storageProof?: StorageProofSet;
[k: string]: any;
}
/**
*
* Current block header PoW hash.
*
*/
export type PowHash = string;
/**
*
* The seed hash used for the DAG.
*
*/
export type SeedHash = string;
/**
*
* The boundary condition ('target'), 2^256 / difficulty.
*
*/
export type Difficulty = string;
/**
*
* Block at which the import started (will only be reset, after the sync reached his head)
*
*/
export type SyncingDataStartingBlock = string;
/**
*
* The current block, same as eth_blockNumber
*
*/
export type SyncingDataCurrentBlock = string;
/**
*
* The estimated highest block
*
*/
export type SyncingDataHighestBlock = string;
/**
*
* The known states
*
*/
export type SyncingDataKnownStates = string;
/**
*
* The pulled states
*
*/
export type SyncingDataPulledStates = string;
/**
*
* An object with sync status data
*
*/
export interface SyncingData {
startingBlock?: SyncingDataStartingBlock;
currentBlock?: SyncingDataCurrentBlock;
highestBlock?: SyncingDataHighestBlock;
knownStates?: SyncingDataKnownStates;
pulledStates?: SyncingDataPulledStates;
[k: string]: any;
}
export type BooleanVyG3AETh = boolean;
export type Data = string;
export type BlockNumberOrTag = BlockNumber | BlockNumberTag;
export type IsTransactionsIncluded = boolean;
/**
*
* An identifier used to reference the filter.
*
*/
export type FilterId = string;
/**
*
* A filter used to monitor the blockchain for log/events
*
*/
export interface Filter {
fromBlock?: BlockNumber;
toBlock?: BlockNumber;
address?: OneOrArrayOfAddresses;
topics?: LogTopics;
[k: string]: any;
}
/**
*
* Hex representation of the storage slot where the variable exists
*
*/
export type Position = string;
/**
*
* A storage key is indexed from the solidity compiler by the order it is declared. For mappings it uses the keccak of the mapping key with its position (and recursively for X-dimensional mappings)
*
*/
export type StorageKeys = any;
/**
*
* Hex representation of a variable length byte array
*
*/
export type Bytes = string;
/**
*
* Hex representation of a 256 bit unit of data
*
*/
export type DataWord = string;
/**
*
* The mix digest.
*
*/
export type MixHash = string;
export type ClientVersion = string;
export type IsNetListening = boolean;
/**
*
* Hex representation of number of connected peers
*
*/
export type NumConnectedPeers = string;
export type NetworkId = string;
export type ChainId = string;
/**
*
* Integer of the current gas price
*
*/
export type GasPriceResult = string;
export type IntegerOrNull = Integer | Null;
export type BlockOrNull = Block | Null;
export type LogResult = Log[];
export type SetOfLogs = Log[];
export type TransactionOrNull = Transaction | Null;
export type TransactionReceiptOrNull = Receipt | Null;
export type ProofAccountOrNull = ProofAccount | Null;
export type GetWorkResults = [PowHash, SeedHash, Difficulty];
/**
*
* An array of transactions
*
*/
export type Transactions = Transaction[];
export type IsSyncingResult = SyncingData | BooleanVyG3AETh;
/**
*
* Generated! Represents an alias to any of the provided schemas
*
*/
export type AnyOfDataTransactionBlockNumberOrTagTransactionAddressBlockNumberBlockHashIsTransactionsIncludedBlockNumberOrTagIsTransactionsIncludedBlockHashBlockNumberOrTagAddressBlockNumberFilterIdFilterIdTransactionHashBlockHashIntegerBlockNumberOrTagIntegerFilterAddressPositionBlockNumberOrTagBlockHashIntegerBlockNumberOrTagIntegerTransactionHashAddressBlockNumberOrTagTransactionHashBlockHashIntegerBlockNumberIntegerBlockHashBlockNumberOrTagAddressStorageKeysBlockNumberOrTagFilterBytesDataWordDataWordNoncePowHashMixHashFilterIdClientVersionKeccakIsNetListeningNumConnectedPeersNetworkIdBlockNumberOrTagBytesChainIdAddressIntegerGasPriceResultIntegerOrNullBlockOrNullBlockOrNullIntegerOrNullIntegerOrNullBytesLogResultSetOfLogsBytesBytesBytesSetOfLogsDataWordTransactionOrNullTransactionOrNullTransactionOrNullNonceOrNullTransactionReceiptOrNullBlockOrNullBlockOrNullIntegerOrNullIntegerOrNullProofAccountOrNullGetWorkResultsIntegerBooleanVyG3AEThFilterIdIntegerFilterIdTransactionsIntegerKeccakBooleanVyG3AEThBooleanVyG3AEThIsSyncingResultBooleanVyG3AETh = Data | Transaction | BlockNumberOrTag | Address | BlockNumber | BlockHash | IsTransactionsIncluded | FilterId | TransactionHash | Integer | Filter | Position | StorageKeys | Bytes | DataWord | Nonce | PowHash | MixHash | ClientVersion | Keccak | IsNetListening | NumConnectedPeers | NetworkId | ChainId | GasPriceResult | IntegerOrNull | BlockOrNull | LogResult | SetOfLogs | TransactionOrNull | NonceOrNull | TransactionReceiptOrNull | ProofAccountOrNull | GetWorkResults | BooleanVyG3AETh | Transactions | IsSyncingResult;
export type Web3ClientVersion = () => Promise<ClientVersion>;
export type Web3Sha3 = (data: Data) => Promise<Keccak>;
export type NetListening = () => Promise<IsNetListening>;
export type NetPeerCount = () => Promise<NumConnectedPeers>;
export type NetVersion = () => Promise<NetworkId>;
export type EthBlockNumber = () => Promise<BlockNumberOrTag>;
export type EthCall = (transaction: Transaction, blockNumber: BlockNumberOrTag) => Promise<Bytes>;
export type EthChainId = () => Promise<ChainId>;
export type EthCoinbase = () => Promise<Address>;
export type EthEstimateGas = (transaction: Transaction) => Promise<Integer>;
export type EthGasPrice = () => Promise<GasPriceResult>;
export type EthGetBalance = (address: Address, blockNumber: BlockNumber) => Promise<IntegerOrNull>;
export type EthGetBlockByHash = (blockHash: BlockHash, includeTransactions: IsTransactionsIncluded) => Promise<BlockOrNull>;
export type EthGetBlockByNumber = (blockNumber: BlockNumberOrTag, includeTransactions: IsTransactionsIncluded) => Promise<BlockOrNull>;
export type EthGetBlockTransactionCountByHash = (blockHash: BlockHash) => Promise<IntegerOrNull>;
export type EthGetBlockTransactionCountByNumber = (blockNumber: BlockNumberOrTag) => Promise<IntegerOrNull>;
export type EthGetCode = (address: Address, blockNumber: BlockNumber) => Promise<Bytes>;
export type EthGetFilterChanges = (filterId: FilterId) => Promise<LogResult>;
export type EthGetFilterLogs = (filterId: FilterId) => Promise<SetOfLogs>;
export type EthGetRawTransactionByHash = (transactionHash: TransactionHash) => Promise<Bytes>;
export type EthGetRawTransactionByBlockHashAndIndex = (blockHash: BlockHash, index: Integer) => Promise<Bytes>;
export type EthGetRawTransactionByBlockNumberAndIndex = (blockNumber: BlockNumberOrTag, index: Integer) => Promise<Bytes>;
export type EthGetLogs = (filter: Filter) => Promise<SetOfLogs>;
export type EthGetStorageAt = (address: Address, key: Position, blockNumber: BlockNumberOrTag) => Promise<DataWord>;
export type EthGetTransactionByBlockHashAndIndex = (blockHash: BlockHash, index: Integer) => Promise<TransactionOrNull>;
export type EthGetTransactionByBlockNumberAndIndex = (blockNumber: BlockNumberOrTag, index: Integer) => Promise<TransactionOrNull>;
export type EthGetTransactionByHash = (transactionHash: TransactionHash) => Promise<TransactionOrNull>;
export type EthGetTransactionCount = (address: Address, blockNumber: BlockNumberOrTag) => Promise<NonceOrNull>;
export type EthGetTransactionReceipt = (transactionHash: TransactionHash) => Promise<TransactionReceiptOrNull>;
export type EthGetUncleByBlockHashAndIndex = (blockHash: BlockHash, index: Integer) => Promise<BlockOrNull>;
export type EthGetUncleByBlockNumberAndIndex = (uncleBlockNumber: BlockNumber, index: Integer) => Promise<BlockOrNull>;
export type EthGetUncleCountByBlockHash = (blockHash: BlockHash) => Promise<IntegerOrNull>;
export type EthGetUncleCountByBlockNumber = (blockNumber: BlockNumberOrTag) => Promise<IntegerOrNull>;
export type EthGetProof = (address: Address, storageKeys: StorageKeys, blockNumber: BlockNumberOrTag) => Promise<ProofAccountOrNull>;
export type EthGetWork = () => Promise<GetWorkResults>;
export type EthHashrate = () => Promise<Integer>;
export type EthMining = () => Promise<BooleanVyG3AETh>;
export type EthNewBlockFilter = () => Promise<FilterId>;
export type EthNewFilter = (filter: Filter) => Promise<Integer>;
export type EthNewPendingTransactionFilter = () => Promise<FilterId>;
export type EthPendingTransactions = () => Promise<Transactions>;
export type EthProtocolVersion = () => Promise<Integer>;
export type EthSendRawTransaction = (signedTransactionData: Bytes) => Promise<Keccak>;
export type EthSubmitHashrate = (hashRate: DataWord, id: DataWord) => Promise<BooleanVyG3AETh>;
export type EthSubmitWork = (nonce: Nonce, powHash: PowHash, mixHash: MixHash) => Promise<BooleanVyG3AETh>;
export type EthSyncing = () => Promise<IsSyncingResult>;
export type EthUninstallFilter = (filterId: FilterId) => Promise<BooleanVyG3AETh>;