From d3c1bdcdca996bce273673cf9c8220156e965863 Mon Sep 17 00:00:00 2001 From: Janek Rahrt Date: Thu, 31 Mar 2022 14:00:26 +0200 Subject: [PATCH] feat: default to pending block --- src/provider/default.ts | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/provider/default.ts b/src/provider/default.ts index a0cfb49b5..293c17db3 100644 --- a/src/provider/default.ts +++ b/src/provider/default.ts @@ -168,14 +168,18 @@ export class Provider implements ProviderInterface { */ public async callContract( { contractAddress, entrypoint, calldata = [] }: Call, - options: { blockIdentifier: BlockIdentifier } = { blockIdentifier: null } + { blockIdentifier = 'pending' }: { blockIdentifier?: BlockIdentifier } = {} ): Promise { - return this.fetchEndpoint('call_contract', options, { - signature: [], - contract_address: contractAddress, - entry_point_selector: getSelectorFromName(entrypoint), - calldata, - }); + return this.fetchEndpoint( + 'call_contract', + { blockIdentifier }, + { + signature: [], + contract_address: contractAddress, + entry_point_selector: getSelectorFromName(entrypoint), + calldata, + } + ); } /** @@ -187,7 +191,7 @@ export class Provider implements ProviderInterface { * @param blockNumber * @returns the block object { block_number, previous_block_number, state_root, status, timestamp, transaction_receipts, transactions } */ - public async getBlock(blockIdentifier: BlockIdentifier = null): Promise { + public async getBlock(blockIdentifier: BlockIdentifier = 'pending'): Promise { return this.fetchEndpoint('get_block', { blockIdentifier }); } @@ -203,7 +207,7 @@ export class Provider implements ProviderInterface { */ public async getCode( contractAddress: string, - blockIdentifier: BlockIdentifier = null + blockIdentifier: BlockIdentifier = 'pending' ): Promise { return this.fetchEndpoint('get_code', { blockIdentifier, contractAddress }); } @@ -223,7 +227,7 @@ export class Provider implements ProviderInterface { public async getStorageAt( contractAddress: string, key: number, - blockIdentifier: BlockIdentifier = null + blockIdentifier: BlockIdentifier = 'pending' ): Promise { return this.fetchEndpoint('get_storage_at', { blockIdentifier, contractAddress, key }); }