From 8617b357223e05e4584577c124f2c8cb5824255d Mon Sep 17 00:00:00 2001 From: beer-1 Date: Tue, 10 Sep 2024 16:17:56 +0900 Subject: [PATCH] add missing log fields at marshal receipt --- indexer/abci.go | 1 - jsonrpc/backend/tx.go | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/indexer/abci.go b/indexer/abci.go index 3c35cfec..4c5682c3 100644 --- a/indexer/abci.go +++ b/indexer/abci.go @@ -167,7 +167,6 @@ func (e *EVMIndexerImpl) ListenFinalizeBlock(ctx context.Context, req abci.Reque return err } - // emit log events if len(e.logsChans) > 0 { for idx, log := range receipt.Logs { // fill in missing fields before emitting diff --git a/jsonrpc/backend/tx.go b/jsonrpc/backend/tx.go index b2dbe1ea..890d71cd 100644 --- a/jsonrpc/backend/tx.go +++ b/jsonrpc/backend/tx.go @@ -424,6 +424,20 @@ func (b *JSONRPCBackend) GetBlockReceipts(ctx context.Context, blockNrOrHash rpc // marshalReceipt marshals a transaction receipt into a JSON object. func marshalReceipt(receipt *coretypes.Receipt, tx *rpctypes.RPCTransaction) map[string]interface{} { + for idx, log := range receipt.Logs { + log.Index = uint(idx) + if tx.BlockHash != nil { + log.BlockHash = *tx.BlockHash + } + if tx.BlockNumber != nil { + log.BlockNumber = tx.BlockNumber.ToInt().Uint64() + } + log.TxHash = tx.Hash + if tx.TransactionIndex != nil { + log.TxIndex = uint(*tx.TransactionIndex) + } + } + fields := map[string]interface{}{ "blockHash": tx.BlockHash, "blockNumber": hexutil.Uint64(tx.BlockNumber.ToInt().Uint64()),