From 73cfd74f95101069914c3bb095f05340cb2f816f Mon Sep 17 00:00:00 2001 From: Samuel Furter Date: Tue, 26 Mar 2019 22:52:41 +0100 Subject: [PATCH] types checked and updated --- packages/web3-eth/types/index.d.ts | 15 +++++++------- packages/web3-eth/types/tests/eth.tests.ts | 23 ++++++++++++++++++---- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/packages/web3-eth/types/index.d.ts b/packages/web3-eth/types/index.d.ts index b1b83da3c28..e6dc2072d5e 100644 --- a/packages/web3-eth/types/index.d.ts +++ b/packages/web3-eth/types/index.d.ts @@ -54,11 +54,11 @@ export class Eth extends AbstractWeb3Module { clearSubscriptions(): Promise; - subscribe( - type: string, - options?: LogsOptions, - callback?: (error: Error, item: Log | Syncing | BlockHeader | string) => void - ): Subscription; + subscribe(type: 'logs', options?: LogsOptions, callback?: (error: Error, log: Log) => void): Subscription; + subscribe(type: 'syncing', options?: null, callback?: (error: Error, result: Syncing) => void): Subscription; + subscribe(type: 'newBlockHeaders', options?: null, callback?: (error: Error, blockHeader: BlockHeader) => void): Subscription; + subscribe(type: 'pendingTransactions', options?: null, callback?: (error: Error, transactionHash: string) => void): Subscription; + subscribe(type: 'pendingTransactions' | 'logs' | 'syncing' | 'newBlockHeaders', options?: any, callback?: (error: Error, result: any) => void): Subscription; getProtocolVersion(callback?: (error: Error, protocolVersion: string) => void): Promise; @@ -192,9 +192,8 @@ export interface PastLogsOptions { } export interface LogsOptions { - fromBlock?: number | string, - toBlock?: number | string, - address?: string | string[] + fromBlock?: number | string; + address?: string | string[]; topics?: Array } diff --git a/packages/web3-eth/types/tests/eth.tests.ts b/packages/web3-eth/types/tests/eth.tests.ts index 53e8049e081..5141bcb2e67 100644 --- a/packages/web3-eth/types/tests/eth.tests.ts +++ b/packages/web3-eth/types/tests/eth.tests.ts @@ -45,13 +45,28 @@ eth.net; eth.clearSubscriptions(); -// $ExpectType Subscription +// $ExpectType Subscription eth.subscribe('logs'); -// $ExpectType Subscription +// $ExpectType Subscription eth.subscribe('logs', {}); -// $ExpectType Subscription -eth.subscribe('logs', {}, (error: Error, log: string | Log | Syncing | BlockHeader) => {}); +// $ExpectType Subscription +eth.subscribe('logs', {}, (error: Error, log: Log) => {}); + +// $ExpectType Subscription +eth.subscribe('syncing'); +// $ExpectType Subscription +eth.subscribe('syncing', null, (error: Error, result: Syncing) => {}); + +// $ExpectType Subscription +eth.subscribe('newBlockHeaders'); +// $ExpectType Subscription +eth.subscribe('newBlockHeaders', null, (error: Error, blockHeader: BlockHeader) => {}); + +// $ExpectType Subscription +eth.subscribe('pendingTransactions'); +// $ExpectType Subscription +eth.subscribe('pendingTransactions', null, (error: Error, transactionHash: string) => {}); // $ExpectType Providers Eth.providers;