From 115526644f56b354181c069485e2f44340ecebec Mon Sep 17 00:00:00 2001 From: Daniel Liu Date: Tue, 25 Jun 2024 17:21:52 +0800 Subject: [PATCH] internal/ethapi: implement eth_getBlockReceipts (#27702) --- internal/ethapi/api.go | 36 ++---------------------------------- 1 file changed, 2 insertions(+), 34 deletions(-) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index d2123af79674..c20d3d4261e4 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -2233,38 +2233,7 @@ func (s *PublicTransactionPoolAPI) GetTransactionReceipt(ctx context.Context, ha // Derive the sender. bigblock := new(big.Int).SetUint64(blockNumber) signer := types.MakeSigner(s.b.ChainConfig(), bigblock) - from, _ := types.Sender(signer, tx) - - fields := map[string]interface{}{ - "blockHash": blockHash, - "blockNumber": hexutil.Uint64(blockNumber), - "transactionHash": hash, - "transactionIndex": hexutil.Uint64(index), - "from": from, - "to": tx.To(), - "gasUsed": hexutil.Uint64(receipt.GasUsed), - "cumulativeGasUsed": hexutil.Uint64(receipt.CumulativeGasUsed), - "contractAddress": nil, - "logs": receipt.Logs, - "logsBloom": receipt.Bloom, - "type": hexutil.Uint(tx.Type()), - "effectiveGasPrice": (*hexutil.Big)(receipt.EffectiveGasPrice), - } - - // Assign receipt status or post state. - if len(receipt.PostState) > 0 { - fields["root"] = hexutil.Bytes(receipt.PostState) - } else { - fields["status"] = hexutil.Uint(receipt.Status) - } - if receipt.Logs == nil { - fields["logs"] = [][]*types.Log{} - } - // If the ContractAddress is 20 0x0 bytes, assume it is not a contract creation - if receipt.ContractAddress != (common.Address{}) { - fields["contractAddress"] = receipt.ContractAddress - } - return fields, nil + return marshalReceipt(receipt, blockHash, blockNumber, signer, tx, int(index)), nil } // marshalReceipt marshals a transaction receipt into a JSON object. @@ -2284,8 +2253,7 @@ func marshalReceipt(receipt *types.Receipt, blockHash common.Hash, blockNumber u "logs": receipt.Logs, "logsBloom": receipt.Bloom, "type": hexutil.Uint(tx.Type()), - // uncomment below line after EIP-1559 - // TODO: "effectiveGasPrice": (*hexutil.Big)(receipt.EffectiveGasPrice), + "effectiveGasPrice": (*hexutil.Big)(receipt.EffectiveGasPrice), } // Assign receipt status or post state.