Skip to content

Commit

Permalink
Fix TS types for subscription categories
Browse files Browse the repository at this point in the history
  • Loading branch information
Velenir authored and cgewecke committed Oct 28, 2019
1 parent 9dd09db commit 93fe751
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 18 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,11 @@ Released with 1.0.0-beta.37 code base.
- Fix hexToNumber and hexToNumberString prefix validation (#3086)
- The receipt will now returned on a EVM error (this got removed on beta.18) (#3129)
- Fixes transaction confirmations with the HttpProvider (#3140)

## [1.2.3]

### Added

### Fixed

- Fix TS types for eth.subscribe syncing, newBlockHeaders, pendingTransactions (#3159)
13 changes: 1 addition & 12 deletions packages/web3-eth/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,32 +78,21 @@ export class Eth {

subscribe(
type: 'logs',
options?: LogsOptions,
options: LogsOptions,
callback?: (error: Error, log: Log) => void
): Subscription<Log>;
subscribe(
type: 'syncing',
options?: null,
callback?: (error: Error, result: Syncing) => void
): Subscription<Syncing>;
subscribe(
type: 'newBlockHeaders',
options?: null,
callback?: (error: Error, blockHeader: BlockHeader) => void
): Subscription<BlockHeader>;
subscribe(
type: 'pendingTransactions',
options?: null,
callback?: (error: Error, transactionHash: string) => void
): Subscription<string>;
subscribe(
type: 'pendingTransactions' | 'logs' | 'syncing' | 'newBlockHeaders',
options?: null | LogsOptions,
callback?: (
error: Error,
item: Log | Syncing | BlockHeader | string
) => void
): Subscription<Log | BlockHeader | Syncing | string>;

getProtocolVersion(
callback?: (error: Error, protocolVersion: string) => void
Expand Down
10 changes: 4 additions & 6 deletions packages/web3-eth/types/tests/eth.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@ eth.net;
// $ExpectType void
eth.clearSubscriptions(() => {});

// $ExpectType Subscription<Log>
eth.subscribe('logs');

// $ExpectType Subscription<Log>
eth.subscribe('logs', {});
// $ExpectType Subscription<Log>
Expand All @@ -90,14 +87,16 @@ eth.subscribe('logs', {}, (error: Error, log: Log) => {});
// $ExpectType Subscription<Syncing>
eth.subscribe('syncing');
// $ExpectType Subscription<Syncing>
eth.subscribe('syncing', null, (error: Error, result: Syncing) => {});
eth.subscribe(
'syncing',
(error: Error, result: Syncing) => {}
);

// $ExpectType Subscription<BlockHeader>
eth.subscribe('newBlockHeaders');
// $ExpectType Subscription<BlockHeader>
eth.subscribe(
'newBlockHeaders',
null,
(error: Error, blockHeader: BlockHeader) => {}
);

Expand All @@ -106,7 +105,6 @@ eth.subscribe('pendingTransactions');
// $ExpectType Subscription<string>
eth.subscribe(
'pendingTransactions',
null,
(error: Error, transactionHash: string) => {}
);

Expand Down

0 comments on commit 93fe751

Please sign in to comment.