catch contract errors to return bool

# Conflicts:
#	codex/contracts/proofs.nim
#	vendor/nim-ethers
This commit is contained in:
Eric Mastro 2022-09-19 16:38:23 +10:00 committed by Eric Mastro
parent ae9467b780
commit dab65eb6bd
1 changed files with 8 additions and 4 deletions

View File

@ -26,15 +26,19 @@ method isProofRequired*(proofs: OnChainProofs,
id: SlotId): Future[bool] {.async.} =
try:
return await proofs.storage.isProofRequired(id)
except ValueError:
return false
except JsonRpcProviderError as e:
if e.revertReason == "Slot empty":
return false
raise e
method willProofBeRequired*(proofs: OnChainProofs,
id: SlotId): Future[bool] {.async.} =
try:
return await proofs.storage.willProofBeRequired(id)
except ValueError:
return false
except JsonRpcProviderError:
if e.revertReason == "Slot empty":
return false
raise e
method getProofEnd*(proofs: OnChainProofs,
id: SlotId): Future[UInt256] {.async.} =