Skip to content

Commit

Permalink
internal/ethapi: implement eth_getBlockReceipts (ethereum#27702)
Browse files Browse the repository at this point in the history
  • Loading branch information
gzliudan committed Sep 22, 2024
1 parent 22bfa6c commit 23c5fda
Showing 1 changed file with 2 additions and 34 deletions.
36 changes: 2 additions & 34 deletions internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down

0 comments on commit 23c5fda

Please sign in to comment.