Skip to content

Commit

Permalink
Update getBlockNumber to use getBlock latest
Browse files Browse the repository at this point in the history
  • Loading branch information
therealjmj committed Jun 9, 2023
1 parent 1f0f27e commit 32c05f1
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/utils/available-rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,14 @@ const getBlockNumber = async (
): Promise<Optional<number>> => {
try {
const rpcProvider = new JsonRpcProvider(provider);
const blockNumber = await promiseTimeout(
rpcProvider.getBlockNumber(),
const block = await promiseTimeout(
rpcProvider.getBlock('latest'),
BLOCK_NUMBER_TIMEOUT_MS,
);
return blockNumber;
if (block == null) {
throw new Error('Block is null');
}
return block.number;
} catch (err) {
if (!(err instanceof Error)) {
throw err;
Expand Down

0 comments on commit 32c05f1

Please sign in to comment.