From fd8d60afdb918e78c43e623ca859254593f352ff Mon Sep 17 00:00:00 2001 From: maskpp Date: Mon, 29 Apr 2024 19:38:09 +0800 Subject: [PATCH 1/3] fix bug --- bindings/encoding/custom_error.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bindings/encoding/custom_error.go b/bindings/encoding/custom_error.go index da0b4b445..d114e99c6 100644 --- a/bindings/encoding/custom_error.go +++ b/bindings/encoding/custom_error.go @@ -15,6 +15,7 @@ import ( type BlockHashContractCallerAndTransactionReader interface { bind.BlockHashContractCaller ethereum.TransactionReader + HeaderByHash(context.Context, common.Hash) (*types.Header, error) } // TryParsingCustomErrorFromReceipt tries to parse the custom error from the given receipt. @@ -24,6 +25,11 @@ func TryParsingCustomErrorFromReceipt( from common.Address, receipt *types.Receipt, ) error { + // get header + 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 { @@ -42,7 +48,7 @@ func TryParsingCustomErrorFromReceipt( AccessList: tx.AccessList(), BlobGasFeeCap: tx.BlobGasFeeCap(), BlobHashes: tx.BlobHashes(), - }, receipt.BlockHash) + }, header.ParentHash) return TryParsingCustomError(err) } From 4a08bbf056afe48a7f6f5ffa95c55149693c4ad5 Mon Sep 17 00:00:00 2001 From: David Date: Mon, 29 Apr 2024 19:54:05 +0800 Subject: [PATCH 2/3] feat: update comments --- bindings/encoding/custom_error.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bindings/encoding/custom_error.go b/bindings/encoding/custom_error.go index d114e99c6..6616d4904 100644 --- a/bindings/encoding/custom_error.go +++ b/bindings/encoding/custom_error.go @@ -12,24 +12,25 @@ import ( ) // BlockHashContractCallerAndTransactionReader represents a contract caller and transaction reader. -type BlockHashContractCallerAndTransactionReader interface { +type BlockHashContractCallerAndChainReader interface { bind.BlockHashContractCaller ethereum.TransactionReader - HeaderByHash(context.Context, common.Hash) (*types.Header, error) + 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 header + // 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 { From 7c960acd7080066c081c79e4af8f0ebe7e0c70ac Mon Sep 17 00:00:00 2001 From: David Date: Mon, 29 Apr 2024 19:55:20 +0800 Subject: [PATCH 3/3] feat: update comments --- bindings/encoding/custom_error.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bindings/encoding/custom_error.go b/bindings/encoding/custom_error.go index 6616d4904..df598b494 100644 --- a/bindings/encoding/custom_error.go +++ b/bindings/encoding/custom_error.go @@ -11,7 +11,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" ) -// BlockHashContractCallerAndTransactionReader represents a contract caller and transaction reader. +// BlockHashContractCallerAndChainReader represents a contract caller and chain reader. type BlockHashContractCallerAndChainReader interface { bind.BlockHashContractCaller ethereum.TransactionReader