diff --git a/codex/contracts/market.nim b/codex/contracts/market.nim index ca092ab0..48992633 100644 --- a/codex/contracts/market.nim +++ b/codex/contracts/market.nim @@ -1,4 +1,6 @@ +import std/strutils import pkg/ethers +import pkg/ethers/testing import pkg/upraises import pkg/questionable import ../market @@ -38,9 +40,10 @@ method getRequest(market: OnChainMarket, id: RequestId): Future[?StorageRequest] {.async.} = try: return some await market.contract.getRequest(id) - except ValueError: - # Unknown request - return none StorageRequest + except JsonRpcProviderError as e: + if e.revertReason.contains("Unknown request"): + # Unknown request + return none StorageRequest method getHost(market: OnChainMarket, requestId: RequestId, diff --git a/codex/contracts/proofs.nim b/codex/contracts/proofs.nim index ba8a890f..794c2a7d 100644 --- a/codex/contracts/proofs.nim +++ b/codex/contracts/proofs.nim @@ -1,3 +1,4 @@ +import std/strutils import pkg/ethers import pkg/ethers/testing import ../storageproofs/timing/proofs @@ -28,7 +29,7 @@ method isProofRequired*(proofs: OnChainProofs, try: return await proofs.storage.isProofRequired(id) except JsonRpcProviderError as e: - if e.revertReason == "Slot empty": + if e.revertReason.contains("Slot empty"): return false raise e @@ -37,13 +38,18 @@ method willProofBeRequired*(proofs: OnChainProofs, try: return await proofs.storage.willProofBeRequired(id) except JsonRpcProviderError as e: - if e.revertReason == "Slot empty": + if e.revertReason.contains("Slot empty"): return false raise e method getProofEnd*(proofs: OnChainProofs, id: SlotId): Future[UInt256] {.async.} = - return await proofs.storage.proofEnd(id) + try: + return await proofs.storage.proofEnd(id) + except JsonRpcProviderError as e: + if e.revertReason.contains("Slot empty"): + return 0.u256 + raise e method submitProof*(proofs: OnChainProofs, id: SlotId, diff --git a/vendor/nim-ethers b/vendor/nim-ethers index a4787aaf..90d432db 160000 --- a/vendor/nim-ethers +++ b/vendor/nim-ethers @@ -1 +1 @@ -Subproject commit a4787aaf0a6635035cc19246e3dc063f661a48cb +Subproject commit 90d432db56f74a15c4b5c734da6999cbfa18737f