mirror of
https://github.com/logos-storage/nim-ethers.git
synced 2026-02-26 16:43:12 +00:00
Add test to see if hardhat returns reason string (it doesn't)
This commit is contained in:
parent
a6aeb7ec49
commit
affaa2e621
@ -261,7 +261,7 @@ proc confirm*(tx: Future[?TransactionResponse],
|
||||
# TODO: handle TransactionStatus.Invalid?
|
||||
if receipt.status == TransactionStatus.Failure:
|
||||
logScope:
|
||||
transactionHash = receipt.transactionHash
|
||||
transactionHash = receipt.transactionHash.to0xHex
|
||||
|
||||
trace "transaction failed, replaying transaction to get revert reason"
|
||||
|
||||
|
||||
@ -156,14 +156,11 @@ proc replay*(provider: Provider, tx: PastTransaction, blockNumber: UInt256) {.as
|
||||
|
||||
method getRevertReason*(
|
||||
provider: Provider,
|
||||
receipt: TransactionReceipt
|
||||
hash: TransactionHash,
|
||||
blockNumber: UInt256
|
||||
): Future[?string] {.base, async.} =
|
||||
|
||||
if receipt.status != TransactionStatus.Failure:
|
||||
raiseProviderError "cannot get revert reason, transaction not failed"
|
||||
|
||||
without blockNumber =? receipt.blockNumber or
|
||||
transaction =? await provider.getTransaction(receipt.transactionHash):
|
||||
without transaction =? await provider.getTransaction(hash):
|
||||
return none string
|
||||
|
||||
try:
|
||||
@ -173,6 +170,29 @@ method getRevertReason*(
|
||||
# should contain the revert reason
|
||||
return some e.msg
|
||||
|
||||
method getRevertReason*(
|
||||
provider: Provider,
|
||||
receipt: TransactionReceipt
|
||||
): Future[?string] {.base, async.} =
|
||||
|
||||
if receipt.status != TransactionStatus.Failure:
|
||||
raiseProviderError "cannot get revert reason, transaction not failed"
|
||||
|
||||
without blockNumber =? receipt.blockNumber:
|
||||
return none string
|
||||
|
||||
return await provider.getRevertReason(receipt.transactionHash, blockNumber)
|
||||
# without blockNumber =? receipt.blockNumber or
|
||||
# transaction =? await provider.getTransaction(receipt.transactionHash):
|
||||
# return none string
|
||||
|
||||
# try:
|
||||
# await provider.replay(transaction, blockNumber)
|
||||
# return none string
|
||||
# except ProviderError as e:
|
||||
# # should contain the revert reason
|
||||
# return some e.msg
|
||||
|
||||
proc confirm*(tx: TransactionResponse,
|
||||
confirmations = EthersDefaultConfirmations,
|
||||
timeout = EthersReceiptTimeoutBlks):
|
||||
|
||||
@ -2,6 +2,7 @@ import std/json
|
||||
import std/options
|
||||
import pkg/asynctest
|
||||
import pkg/questionable
|
||||
import pkg/stew/byteutils
|
||||
import pkg/stint
|
||||
import pkg/ethers
|
||||
import pkg/ethers/erc20
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user