Skip to content

Commit 8e9a81b

Browse files
committed
fix(providers): remove redundant assert call
1 parent 65a303f commit 8e9a81b

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

.changeset/lemon-plants-arrive.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@near-js/providers": patch
3+
"near-api-js": patch
4+
---
5+
6+
Remove a redundant `assert` call in `@near-js/providers`

packages/providers/src/json-rpc-provider.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ import { Provider } from './provider';
5555
import { ConnectionInfo, fetchJsonRpc, retryConfig } from './fetch_json';
5656
import { TxExecutionStatus } from '@near-js/types';
5757
import { PublicKey } from '@near-js/crypto';
58-
import assert from 'assert';
5958

6059
/** @hidden */
6160
// Default number of retries before giving up on a request.
@@ -302,13 +301,11 @@ export class JsonRpcProvider implements Provider {
302301
* - `null`: Current epoch.
303302
*/
304303
public async viewValidatorsV2(params: { blockId: string | number } | { epochId: string } | null): Promise<EpochValidatorInfo> {
305-
assert(typeof params === 'object');
306-
307304
if (params === null) return this.sendJsonRpc('validators', [null]);
308305

309-
if ('blockId' in params) return this.sendJsonRpc('validators', { block_id: params.blockId });
306+
if (typeof params === 'object' && 'blockId' in params) return this.sendJsonRpc('validators', { block_id: params.blockId });
310307

311-
if ('epochId' in params) return this.sendJsonRpc('validators', { epoch_id: params.epochId });
308+
if (typeof params === 'object' && 'epochId' in params) return this.sendJsonRpc('validators', { epoch_id: params.epochId });
312309

313310
throw new Error('Invalid parameters for validatorsV2');
314311
}

0 commit comments

Comments
 (0)