mirror of
https://github.com/logos-storage/nim-ethers.git
synced 2026-01-03 14:13:10 +00:00
Handle custom errors when estimating gas
This commit is contained in:
parent
55ab97fb7b
commit
c4f1d7529c
@ -5,6 +5,7 @@ import ../signer
|
||||
import ./contract
|
||||
import ./contractcall
|
||||
import ./transactions
|
||||
import ./errors
|
||||
import ./syntax
|
||||
|
||||
type ContractGasEstimations[C] = distinct C
|
||||
@ -42,4 +43,4 @@ func createGasEstimationCall*(procedure: NimNode): NimNode =
|
||||
result.addAsyncPragma()
|
||||
result.addUsedPragma()
|
||||
result.addEstimateCall()
|
||||
|
||||
result.addErrorHandling()
|
||||
|
||||
@ -97,7 +97,7 @@ suite "Contract custom errors":
|
||||
expect ErrorWithArguments:
|
||||
await contract.revertsMultipleErrors(simple = false)
|
||||
|
||||
test "handles gas estimation errors":
|
||||
test "handles gas estimation errors when calling a contract function":
|
||||
proc revertsTransaction(contract: TestCustomErrors)
|
||||
{.contract, errors:[ErrorWithArguments].}
|
||||
|
||||
@ -109,6 +109,18 @@ suite "Contract custom errors":
|
||||
check error.arguments.one == 1.u256
|
||||
check error.arguments.two == true
|
||||
|
||||
test "handles errors when only doing gas estimation":
|
||||
proc revertsTransaction(contract: TestCustomErrors)
|
||||
{.contract, errors:[ErrorWithArguments], used.}
|
||||
|
||||
let contract = contract.connect(provider.getSigner())
|
||||
try:
|
||||
discard await contract.estimateGas.revertsTransaction()
|
||||
fail()
|
||||
except ErrorWithArguments as error:
|
||||
check error.arguments.one == 1.u256
|
||||
check error.arguments.two == true
|
||||
|
||||
test "handles transaction submission errors":
|
||||
proc revertsTransaction(contract: TestCustomErrors)
|
||||
{.contract, errors:[ErrorWithArguments].}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user