do not crash when we cannot get block number

Co-Authored-By: Eric <5089238+emizzle@users.noreply.github.com>
This commit is contained in:
Mark Spanbroek 2024-11-12 08:48:21 +01:00 committed by markspanbroek
parent 35aebdb46f
commit e9d862ceca
1 changed files with 9 additions and 5 deletions

View File

@ -240,11 +240,15 @@ proc confirm*(
var blockNumber: UInt256
let blockEvent = newAsyncEvent()
proc updateBlockNumber {.async: (raises: [ProviderError]).} =
proc updateBlockNumber {.async: (raises: []).} =
try:
let number = await tx.provider.getBlockNumber()
if number > blockNumber:
blockNumber = number
blockEvent.fire()
except ProviderError:
# there's nothing we can do here
discard
proc onBlock(_: Block) =
# ignore block parameter; hardhat may call this with pending blocks