diff --git a/ethers/provider.nim b/ethers/provider.nim index bc15c25..5e447de 100644 --- a/ethers/provider.nim +++ b/ethers/provider.nim @@ -10,6 +10,7 @@ push: {.upraises: [].} type Provider* = ref object of RootObj + ProviderError* = object of EthersError Subscription* = ref object of RootObj Filter* = object address*: Address diff --git a/ethers/providers/jsonrpc.nim b/ethers/providers/jsonrpc.nim index 4083364..5627790 100644 --- a/ethers/providers/jsonrpc.nim +++ b/ethers/providers/jsonrpc.nim @@ -25,7 +25,7 @@ type JsonRpcSigner* = ref object of Signer provider: JsonRpcProvider address: ?Address - JsonRpcProviderError* = object of EthersError + JsonRpcProviderError* = object of ProviderError SubscriptionHandler = proc(id, arguments: JsonNode): Future[void] {.gcsafe, upraises:[].} proc raiseProviderError(message: string) {.upraises: [JsonRpcProviderError].} = diff --git a/ethers/testing.nim b/ethers/testing.nim index cc8674c..ea2cfcb 100644 --- a/ethers/testing.nim +++ b/ethers/testing.nim @@ -1,8 +1,7 @@ -import std/json import std/strutils import pkg/ethers -proc revertReason*(e: ref JsonRpcProviderError): string = +proc revertReason*(e: ref ProviderError): string = try: var msg = e.msg const revertPrefixes = @[ @@ -26,7 +25,7 @@ proc reverts*[T](call: Future[T]): Future[bool] {.async.} = else: discard await call # TODO test this return false - except JsonRpcProviderError: + except ProviderError: return true proc reverts*[T](call: Future[T], reason: string): Future[bool] {.async.} = @@ -36,5 +35,5 @@ proc reverts*[T](call: Future[T], reason: string): Future[bool] {.async.} = else: discard await call # TODO test this return false - except JsonRpcProviderError as error: + except ProviderError as error: return reason == error.revertReason diff --git a/testmodule/testTesting.nim b/testmodule/testTesting.nim index 2af51c4..e88dda9 100644 --- a/testmodule/testTesting.nim +++ b/testmodule/testTesting.nim @@ -13,13 +13,13 @@ suite "Testing helpers": test "checks that call reverts": proc call() {.async.} = - raise newException(JsonRpcProviderError, $rpcResponse) + raise newException(ProviderError, $rpcResponse) check await call().reverts() test "checks reason for revert": proc call() {.async.} = - raise newException(JsonRpcProviderError, $rpcResponse) + raise newException(ProviderError, $rpcResponse) check await call().reverts(revertReason) @@ -28,14 +28,14 @@ suite "Testing helpers": check not await call().reverts() - test "reverts only checks JsonRpcProviderErrors": + test "reverts only checks ProviderErrors": proc call() {.async.} = raise newException(ContractError, "test") expect ContractError: check await call().reverts() - test "reverts with reason only checks JsonRpcProviderErrors": + test "reverts with reason only checks ProviderErrors": proc call() {.async.} = raise newException(ContractError, "test") @@ -49,14 +49,14 @@ suite "Testing helpers": test "reverts is false when the revert reason doesn't match": proc call() {.async.} = - raise newException(JsonRpcProviderError, "other reason") + raise newException(ProviderError, "other reason") check not await call().reverts(revertReason) test "revert handles non-standard revert prefix": let nonStdMsg = fmt"Provider VM Exception: reverted with {revertReason}" proc call() {.async.} = - raise newException(JsonRpcProviderError, nonStdMsg) + raise newException(ProviderError, nonStdMsg) check await call().reverts(nonStdMsg)