From c4f9ec1e5915afab243ebf0e5debfddd19e9b8cc Mon Sep 17 00:00:00 2001 From: mchmatt <123990957+mchmatt@users.noreply.github.com> Date: Tue, 8 Aug 2023 10:31:29 -0300 Subject: [PATCH] Calculate EIP1559 gas price in JSON-RPC (#1783) * Calculate EIP1559 gas price in JSON-RPC for compatibility with existing tools * Fix cuddled return --------- Co-authored-by: mchmatt --- jsonrpc/eth_endpoint.go | 2 ++ jsonrpc/types.go | 1 + 2 files changed, 3 insertions(+) diff --git a/jsonrpc/eth_endpoint.go b/jsonrpc/eth_endpoint.go index a69fe55b1c..e0d646fb68 100644 --- a/jsonrpc/eth_endpoint.go +++ b/jsonrpc/eth_endpoint.go @@ -236,6 +236,8 @@ func (e *Eth) GetTransactionByHash(hash types.Hash) (interface{}, error) { // Find the transaction within the block if txn, idx := types.FindTxByHash(block.Transactions, hash); txn != nil { + txn.GasPrice = txn.GetGasPrice(block.Header.BaseFee) + return toTransaction( txn, argUintPtr(block.Number()), diff --git a/jsonrpc/types.go b/jsonrpc/types.go index 346788ff8a..5744d9e537 100644 --- a/jsonrpc/types.go +++ b/jsonrpc/types.go @@ -166,6 +166,7 @@ func toBlock(b *types.Block, fullTx bool) *block { for idx, txn := range b.Transactions { if fullTx { + txn.GasPrice = txn.GetGasPrice(b.Header.BaseFee) res.Transactions = append( res.Transactions, toTransaction(