Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Commit 49f3eac

Browse files
Velenirnivida
authored andcommitted
Fix TS types for subscription categories
1 parent 9dd09db commit 49f3eac

File tree

3 files changed

+13
-18
lines changed

3 files changed

+13
-18
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,11 @@ Released with 1.0.0-beta.37 code base.
8282
- Fix hexToNumber and hexToNumberString prefix validation (#3086)
8383
- The receipt will now returned on a EVM error (this got removed on beta.18) (#3129)
8484
- Fixes transaction confirmations with the HttpProvider (#3140)
85+
86+
## [1.2.3]
87+
88+
### Added
89+
90+
### Fixed
91+
92+
- Fix TS types for eth.subscribe syncing, newBlockHeaders, pendingTransactions (#3159)

packages/web3-eth/types/index.d.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,32 +78,21 @@ export class Eth {
7878

7979
subscribe(
8080
type: 'logs',
81-
options?: LogsOptions,
81+
options: LogsOptions,
8282
callback?: (error: Error, log: Log) => void
8383
): Subscription<Log>;
8484
subscribe(
8585
type: 'syncing',
86-
options?: null,
8786
callback?: (error: Error, result: Syncing) => void
8887
): Subscription<Syncing>;
8988
subscribe(
9089
type: 'newBlockHeaders',
91-
options?: null,
9290
callback?: (error: Error, blockHeader: BlockHeader) => void
9391
): Subscription<BlockHeader>;
9492
subscribe(
9593
type: 'pendingTransactions',
96-
options?: null,
9794
callback?: (error: Error, transactionHash: string) => void
9895
): Subscription<string>;
99-
subscribe(
100-
type: 'pendingTransactions' | 'logs' | 'syncing' | 'newBlockHeaders',
101-
options?: null | LogsOptions,
102-
callback?: (
103-
error: Error,
104-
item: Log | Syncing | BlockHeader | string
105-
) => void
106-
): Subscription<Log | BlockHeader | Syncing | string>;
10796

10897
getProtocolVersion(
10998
callback?: (error: Error, protocolVersion: string) => void

packages/web3-eth/types/tests/eth.tests.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,6 @@ eth.net;
7979
// $ExpectType void
8080
eth.clearSubscriptions(() => {});
8181

82-
// $ExpectType Subscription<Log>
83-
eth.subscribe('logs');
84-
8582
// $ExpectType Subscription<Log>
8683
eth.subscribe('logs', {});
8784
// $ExpectType Subscription<Log>
@@ -90,14 +87,16 @@ eth.subscribe('logs', {}, (error: Error, log: Log) => {});
9087
// $ExpectType Subscription<Syncing>
9188
eth.subscribe('syncing');
9289
// $ExpectType Subscription<Syncing>
93-
eth.subscribe('syncing', null, (error: Error, result: Syncing) => {});
90+
eth.subscribe(
91+
'syncing',
92+
(error: Error, result: Syncing) => {}
93+
);
9494

9595
// $ExpectType Subscription<BlockHeader>
9696
eth.subscribe('newBlockHeaders');
9797
// $ExpectType Subscription<BlockHeader>
9898
eth.subscribe(
9999
'newBlockHeaders',
100-
null,
101100
(error: Error, blockHeader: BlockHeader) => {}
102101
);
103102

@@ -106,7 +105,6 @@ eth.subscribe('pendingTransactions');
106105
// $ExpectType Subscription<string>
107106
eth.subscribe(
108107
'pendingTransactions',
109-
null,
110108
(error: Error, transactionHash: string) => {}
111109
);
112110

0 commit comments

Comments
 (0)