Skip to content
This repository has been archived by the owner on May 11, 2024. It is now read-only.

Commit

Permalink
feat(pkg): TryParsingCustomErrorFromReceipt returns nil (#778)
Browse files Browse the repository at this point in the history
Co-authored-by: David <[email protected]>
  • Loading branch information
mask-pp and davidtaikocha authored Apr 29, 2024
1 parent c421f0f commit 57351e4
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions bindings/encoding/custom_error.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,26 @@ import (
"github.com/ethereum/go-ethereum/core/types"
)

// BlockHashContractCallerAndTransactionReader represents a contract caller and transaction reader.
type BlockHashContractCallerAndTransactionReader interface {
// BlockHashContractCallerAndChainReader represents a contract caller and chain reader.
type BlockHashContractCallerAndChainReader interface {
bind.BlockHashContractCaller
ethereum.TransactionReader
ethereum.ChainReader
}

// TryParsingCustomErrorFromReceipt tries to parse the custom error from the given receipt.
func TryParsingCustomErrorFromReceipt(
ctx context.Context,
rpc BlockHashContractCallerAndTransactionReader,
rpc BlockHashContractCallerAndChainReader,
from common.Address,
receipt *types.Receipt,
) error {
// Get the block header of the receipt.
header, err := rpc.HeaderByHash(ctx, receipt.BlockHash)
if err != nil {
return err
}

// Fetch the raw transaction.
tx, _, err := rpc.TransactionByHash(ctx, receipt.TxHash)
if err != nil {
Expand All @@ -42,7 +49,7 @@ func TryParsingCustomErrorFromReceipt(
AccessList: tx.AccessList(),
BlobGasFeeCap: tx.BlobGasFeeCap(),
BlobHashes: tx.BlobHashes(),
}, receipt.BlockHash)
}, header.ParentHash)

return TryParsingCustomError(err)
}
Expand Down

0 comments on commit 57351e4

Please sign in to comment.