mirror of
https://github.com/logos-storage/nim-ethers.git
synced 2026-06-07 01:39:32 +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?
|
# TODO: handle TransactionStatus.Invalid?
|
||||||
if receipt.status == TransactionStatus.Failure:
|
if receipt.status == TransactionStatus.Failure:
|
||||||
logScope:
|
logScope:
|
||||||
transactionHash = receipt.transactionHash
|
transactionHash = receipt.transactionHash.to0xHex
|
||||||
|
|
||||||
trace "transaction failed, replaying transaction to get revert reason"
|
trace "transaction failed, replaying transaction to get revert reason"
|
||||||
|
|
||||||
|
|||||||
@ -156,14 +156,11 @@ proc replay*(provider: Provider, tx: PastTransaction, blockNumber: UInt256) {.as
|
|||||||
|
|
||||||
method getRevertReason*(
|
method getRevertReason*(
|
||||||
provider: Provider,
|
provider: Provider,
|
||||||
receipt: TransactionReceipt
|
hash: TransactionHash,
|
||||||
|
blockNumber: UInt256
|
||||||
): Future[?string] {.base, async.} =
|
): Future[?string] {.base, async.} =
|
||||||
|
|
||||||
if receipt.status != TransactionStatus.Failure:
|
without transaction =? await provider.getTransaction(hash):
|
||||||
raiseProviderError "cannot get revert reason, transaction not failed"
|
|
||||||
|
|
||||||
without blockNumber =? receipt.blockNumber or
|
|
||||||
transaction =? await provider.getTransaction(receipt.transactionHash):
|
|
||||||
return none string
|
return none string
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -173,6 +170,29 @@ method getRevertReason*(
|
|||||||
# should contain the revert reason
|
# should contain the revert reason
|
||||||
return some e.msg
|
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,
|
proc confirm*(tx: TransactionResponse,
|
||||||
confirmations = EthersDefaultConfirmations,
|
confirmations = EthersDefaultConfirmations,
|
||||||
timeout = EthersReceiptTimeoutBlks):
|
timeout = EthersReceiptTimeoutBlks):
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import std/json
|
|||||||
import std/options
|
import std/options
|
||||||
import pkg/asynctest
|
import pkg/asynctest
|
||||||
import pkg/questionable
|
import pkg/questionable
|
||||||
|
import pkg/stew/byteutils
|
||||||
import pkg/stint
|
import pkg/stint
|
||||||
import pkg/ethers
|
import pkg/ethers
|
||||||
import pkg/ethers/erc20
|
import pkg/ethers/erc20
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user