fix: block number stability (#3684)

* fix: block number stability

* fix: chainBlock logic
This commit is contained in:
Zach Pomerantz 2022-04-07 14:26:50 -07:00 committed by GitHub
parent ecfa179b3f
commit 71b20b432c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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
})