Skip to content

Commit

Permalink
add missing log fields at marshal receipt
Browse files Browse the repository at this point in the history
  • Loading branch information
beer-1 committed Sep 10, 2024
1 parent e6ad0f9 commit 8617b35
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 0 additions & 1 deletion indexer/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions jsonrpc/backend/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Check warning on line 438 in jsonrpc/backend/tx.go

View check run for this annotation

Codecov / codecov/patch

jsonrpc/backend/tx.go#L427-L438

Added lines #L427 - L438 were not covered by tests
}

fields := map[string]interface{}{
"blockHash": tx.BlockHash,
"blockNumber": hexutil.Uint64(tx.BlockNumber.ToInt().Uint64()),
Expand Down

0 comments on commit 8617b35

Please sign in to comment.