Skip to content

Commit

Permalink
expose errorReason (#1015)
Browse files Browse the repository at this point in the history
  • Loading branch information
AnieeG authored Jul 3, 2024
1 parent fb8dd63 commit 8fdc1ba
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions blockchain/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ type EVMClient interface {
CancelFinalityPolling()
GetTxReceipt(txHash common.Hash) (*types.Receipt, error)
RevertReasonFromTx(txHash common.Hash, abiString string) (string, interface{}, error)
ErrorReason(b ethereum.ContractCaller, tx *types.Transaction, receipt *types.Receipt) (string, error)

ParallelTransactions(enabled bool)
Close() error
Expand Down
10 changes: 7 additions & 3 deletions blockchain/ethereum.go
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ func (e *EthereumClient) IsTxConfirmed(txHash common.Hash) (bool, error) {
if err == nil {
from = fromAddr.Hex()
}
reason, err := e.errorReason(e.Client, tx, receipt)
reason, err := e.ErrorReason(e.Client, tx, receipt)
if err != nil {
e.l.Warn().Str("TX Hash", txHash.Hex()).
Str("To", to).
Expand Down Expand Up @@ -797,7 +797,7 @@ func (e *EthereumClient) IsEventConfirmed(event *types.Log) (confirmed, removed
return false, event.Removed, err
}
if eventReceipt.Status == 0 { // Failed event tx
reason, err := e.errorReason(e.Client, eventTx, eventReceipt)
reason, err := e.ErrorReason(e.Client, eventTx, eventReceipt)
if err != nil {
e.l.Warn().Str("TX Hash", eventTx.Hash().Hex()).
Str("Error extracting reason", err.Error()).
Expand Down Expand Up @@ -839,7 +839,7 @@ func (e *EthereumClient) RevertReasonFromTx(txHash common.Hash, abiString string
if err != nil {
return "", nil, err
}
errData, err := e.errorReason(e.Client, tx, re)
errData, err := e.ErrorReason(e.Client, tx, re)
if err != nil {
return "", nil, err
}
Expand Down Expand Up @@ -1731,3 +1731,7 @@ func (e *EthereumMultinodeClient) WaitForEvents() error {
}
return g.Wait()
}

func (e *EthereumMultinodeClient) ErrorReason(b ethereum.ContractCaller, tx *types.Transaction, receipt *types.Receipt) (string, error) {
return e.DefaultClient.ErrorReason(b, tx, receipt)
}
4 changes: 2 additions & 2 deletions blockchain/transaction_confirmers.go
Original file line number Diff line number Diff line change
Expand Up @@ -522,8 +522,8 @@ func (e *EthereumClient) receiveHeader(header *SafeEVMHeader) error {
return nil
}

// errorReason decodes tx revert reason
func (e *EthereumClient) errorReason(
// ErrorReason decodes tx revert reason
func (e *EthereumClient) ErrorReason(
b ethereum.ContractCaller,
tx *types.Transaction,
receipt *types.Receipt,
Expand Down

0 comments on commit 8fdc1ba

Please sign in to comment.