core, graphql, internal: expose effectiveGasPrice in receipts

This commit is contained in:
Péter Szilágyi
2021-06-16 08:23:50 +03:00
parent 7a7abe3de8
commit aa69d36152
7 changed files with 42 additions and 8 deletions

View File

@ -1561,7 +1561,17 @@ func (s *PublicTransactionPoolAPI) GetTransactionReceipt(ctx context.Context, ha
"logsBloom": receipt.Bloom,
"type": hexutil.Uint(tx.Type()),
}
// Assign the effective gas price paid
if !s.b.ChainConfig().IsLondon(bigblock) {
fields["effectiveGasPrice"] = hexutil.Uint64(tx.GasPrice().Uint64())
} else {
header, err := s.b.HeaderByHash(ctx, blockHash)
if err != nil {
return nil, err
}
gasPrice := new(big.Int).Add(header.BaseFee, tx.EffectiveGasTipValue(header.BaseFee))
fields["effectiveGasPrice"] = hexutil.Uint64(gasPrice.Uint64())
}
// Assign receipt status or post state.
if len(receipt.PostState) > 0 {
fields["root"] = hexutil.Bytes(receipt.PostState)

File diff suppressed because one or more lines are too long

View File

@ -3807,7 +3807,9 @@ var outputTransactionReceiptFormatter = function (receipt){
receipt.transactionIndex = utils.toDecimal(receipt.transactionIndex);
receipt.cumulativeGasUsed = utils.toDecimal(receipt.cumulativeGasUsed);
receipt.gasUsed = utils.toDecimal(receipt.gasUsed);
if(receipt.effectiveGasPrice !== undefined) {
receipt.effectiveGasPrice = utils.toBigNumber(receipt.effectiveGasPrice);
}
if(utils.isArray(receipt.logs)) {
receipt.logs = receipt.logs.map(function(log){
return outputLogFormatter(log);