diff --git a/__tests__/provider.test.ts b/__tests__/provider.test.ts index fbd6f61c3..0b8d4078a 100644 --- a/__tests__/provider.test.ts +++ b/__tests__/provider.test.ts @@ -26,6 +26,7 @@ describe('defaultProvider', () => { if (transaction.status !== 'REJECTED') { exampleBlockHash = transaction.block_hash; exampleBlockNumber = transaction.block_number; + console.log(exampleBlockNumber); } }); diff --git a/src/account/default.ts b/src/account/default.ts index 949c3c791..3fd68ea89 100644 --- a/src/account/default.ts +++ b/src/account/default.ts @@ -269,7 +269,7 @@ export class Account extends Provider implements AccountInterface { */ public async verifyMessageHash(hash: BigNumberish, signature: Signature): Promise { try { - const response = await this.callContract({ + await this.callContract({ contractAddress: this.address, entrypoint: 'is_valid_signature', calldata: compileCalldata({ @@ -277,10 +277,7 @@ export class Account extends Provider implements AccountInterface { signature: signature.map((x) => toBN(x).toString()), }), }); - if (response.result) { - return true; - } - return false; + return true; } catch { return false; } diff --git a/src/provider/default.ts b/src/provider/default.ts index ed6bbf632..71e5c0bd4 100644 --- a/src/provider/default.ts +++ b/src/provider/default.ts @@ -159,7 +159,12 @@ export class Provider implements ProviderInterface { body: stringify(request), headers, }) - .then((res) => res.text()) + .then((res) => { + if (res.status !== 200) { + throw Error(res.statusText); + } + return res.text(); + }) .then((res) => { if (endpoint === 'estimate_fee') { return parse(res, (_, v) => { @@ -170,6 +175,9 @@ export class Provider implements ProviderInterface { }); } return parse(res) as Endpoints[T]['RESPONSE']; + }) + .catch((err) => { + throw Error(`Could not ${method} from endpoint: ${url} ${err.message}`); }); } diff --git a/src/provider/utils.ts b/src/provider/utils.ts index 1f85538dc..e1d4e4434 100644 --- a/src/provider/utils.ts +++ b/src/provider/utils.ts @@ -49,7 +49,7 @@ export function getBlockIdentifier(blockIdentifier: BlockIdentifier): BlockIdent if (blockIdentifier === 'pending') { return { type: 'BLOCK_NUMBER', data: 'pending' }; } - if (typeof blockIdentifier === 'number') { + if (typeof blockIdentifier === 'number' || typeof blockIdentifier === 'bigint') { return { type: 'BLOCK_NUMBER', data: blockIdentifier }; } if (typeof blockIdentifier === 'string' && blockIdentifier.startsWith('0x')) {