From 71b20b432c3608516d7d76032c95c7bcb9ce49bb Mon Sep 17 00:00:00 2001 From: Zach Pomerantz Date: Thu, 7 Apr 2022 14:26:50 -0700 Subject: [PATCH] fix: block number stability (#3684) * fix: block number stability * fix: chainBlock logic --- src/lib/hooks/useBlockNumber.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/hooks/useBlockNumber.ts b/src/lib/hooks/useBlockNumber.ts index 76aa2e713d..e3407ee18d 100644 --- a/src/lib/hooks/useBlockNumber.ts +++ b/src/lib/hooks/useBlockNumber.ts @@ -19,9 +19,9 @@ function useUpdateChainBlock() { (block: number) => { setChainBlock((chainBlock) => { if (chainBlock.chainId === chainId) { - if (chainBlock.block === block) return chainBlock - if (typeof chainBlock.block !== 'number') return { chainId, block } - return { chainId, block: Math.max(block, chainBlock.block) } + if (!chainBlock.block || chainBlock.block < block) { + return { chainId, block } + } } return chainBlock })