chore(deps): bump ethers to propagate cancellations (#1116)

* chore(deps): bump ethers to propagate cancellations

Ethers was swallowing canellations and turning them into EthersErrors, which was causing the sales statemachine to error when it should have been simply cancelling the current state's run. Hopefully fixes the intermittently failing marketplace integration test.

* Add missing errors in async raises pragma

* bump to version of ethers that supports cancellations

---------

Co-authored-by: Arnaud <arnaud@status.im>
This commit is contained in:
Eric 2025-02-18 09:00:52 +11:00 committed by GitHub
parent dc08ff8840
commit 5af3477793
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 8 additions and 8 deletions

View File

@ -14,7 +14,7 @@ proc raiseProviderError(message: string) {.raises: [ProviderError].} =
proc blockNumberAndTimestamp*(
provider: Provider, blockTag: BlockTag
): Future[(UInt256, UInt256)] {.async: (raises: [ProviderError]).} =
): Future[(UInt256, UInt256)] {.async: (raises: [ProviderError, CancelledError]).} =
without latestBlock =? await provider.getBlock(blockTag):
raiseProviderError("Could not get latest block")
@ -25,7 +25,7 @@ proc blockNumberAndTimestamp*(
proc binarySearchFindClosestBlock(
provider: Provider, epochTime: int, low: UInt256, high: UInt256
): Future[UInt256] {.async: (raises: [ProviderError]).} =
): Future[UInt256] {.async: (raises: [ProviderError, CancelledError]).} =
let (_, lowTimestamp) = await provider.blockNumberAndTimestamp(BlockTag.init(low))
let (_, highTimestamp) = await provider.blockNumberAndTimestamp(BlockTag.init(high))
if abs(lowTimestamp.truncate(int) - epochTime) <
@ -39,7 +39,7 @@ proc binarySearchBlockNumberForEpoch(
epochTime: UInt256,
latestBlockNumber: UInt256,
earliestBlockNumber: UInt256,
): Future[UInt256] {.async: (raises: [ProviderError]).} =
): Future[UInt256] {.async: (raises: [ProviderError, CancelledError]).} =
var low = earliestBlockNumber
var high = latestBlockNumber
@ -65,7 +65,7 @@ proc binarySearchBlockNumberForEpoch(
proc blockNumberForEpoch*(
provider: Provider, epochTime: SecondsSince1970
): Future[UInt256] {.async: (raises: [ProviderError]).} =
): Future[UInt256] {.async: (raises: [ProviderError, CancelledError]).} =
let epochTimeUInt256 = epochTime.u256
let (latestBlockNumber, latestBlockTimestamp) =
await provider.blockNumberAndTimestamp(BlockTag.latest)
@ -118,6 +118,6 @@ proc blockNumberForEpoch*(
proc pastBlockTag*(
provider: Provider, blocksAgo: int
): Future[BlockTag] {.async: (raises: [ProviderError]).} =
): Future[BlockTag] {.async: (raises: [ProviderError, CancelledError]).} =
let head = await provider.getBlockNumber()
return BlockTag.init(head - blocksAgo.abs.u256)

View File

@ -13,7 +13,7 @@ type MockProvider* = ref object of Provider
method getBlock*(
provider: MockProvider, tag: BlockTag
): Future[?Block] {.async: (raises: [ProviderError]).} =
): Future[?Block] {.async: (raises: [ProviderError, CancelledError]).} =
try:
if tag == BlockTag.latest:
if latestBlock =? provider.latest:

View File

@ -12,7 +12,7 @@ type MockProvider = ref object of Provider
method getChainId*(
provider: MockProvider
): Future[UInt256] {.async: (raises: [ProviderError]).} =
): Future[UInt256] {.async: (raises: [ProviderError, CancelledError]).} =
return provider.chainId
proc configFactory(): CodexConf =

2
vendor/nim-ethers vendored

@ -1 +1 @@
Subproject commit 1cfccb9695fa47860bf7ef3d75da9019096a3933
Subproject commit d2b11a865796a55296027f8ffba68398035ad435