Skip to content

Commit c8fe881

Browse files
committed
fix: ensure only one from_block field is set in subscribeToTransactionsWithProofs
1 parent d2ca233 commit c8fe881

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

packages/js-dapi-client/lib/methods/core/subscribeToTransactionsWithProofsFactory.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function subscribeToTransactionsWithProofsFactory(grpcTransport) {
3939
...options,
4040
};
4141

42-
if (options.fromBlockHeight === 0) {
42+
if ('fromBlockHeight' in options && options.fromBlockHeight === 0) {
4343
throw new DAPIClientError('Invalid argument: minimum value for `fromBlockHeight` is 1');
4444
}
4545

@@ -59,14 +59,14 @@ function subscribeToTransactionsWithProofsFactory(grpcTransport) {
5959
const request = new TransactionsWithProofsRequest();
6060
request.setBloomFilter(bloomFilterMessage);
6161

62-
if (options.fromBlockHeight !== undefined) {
63-
request.setFromBlockHeight(options.fromBlockHeight);
64-
}
65-
66-
if (options.fromBlockHash) {
62+
if ('fromBlockHash' in options) {
6763
request.setFromBlockHash(
68-
Buffer.from(options.fromBlockHash, 'hex'),
64+
Buffer.isBuffer(options.fromBlockHash)
65+
? options.fromBlockHash
66+
: Buffer.from(options.fromBlockHash, 'hex'),
6967
);
68+
} else if ('fromBlockHeight' in options) {
69+
request.setFromBlockHeight(options.fromBlockHeight);
7070
}
7171

7272
request.setCount(options.count);

0 commit comments

Comments
 (0)