From f49d90eb695c0d10a0d9426f4eb3a0ab35457032 Mon Sep 17 00:00:00 2001 From: Daniel Liu <139250065@qq.com> Date: Thu, 28 Aug 2025 18:54:48 +0800 Subject: [PATCH] ethclient: simplify error handling in TransactionReceipt #28748 (#1384) --- ethclient/ethclient.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ethclient/ethclient.go b/ethclient/ethclient.go index f00cdf7154..c965eadbea 100644 --- a/ethclient/ethclient.go +++ b/ethclient/ethclient.go @@ -307,10 +307,8 @@ func (ec *Client) TransactionInBlock(ctx context.Context, blockHash common.Hash, func (ec *Client) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error) { var r *types.Receipt err := ec.c.CallContext(ctx, &r, "eth_getTransactionReceipt", txHash) - if err == nil { - if r == nil { - return nil, ethereum.ErrNotFound - } + if err == nil && r == nil { + return nil, ethereum.ErrNotFound } return r, err }