Skip to content

Commit

Permalink
fix decode logs in ws
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Jun 2, 2023
1 parent 0ea7b86 commit 6218fa1
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions rpc/websockets.go
Original file line number Diff line number Diff line change
Expand Up @@ -575,13 +575,21 @@ func (api *pubSubAPI) subscribeLogs(wsConn *wsConn, subID rpc.ID, extra interfac
continue
}

txResponse, err := evmtypes.DecodeTxResponse(dataTx.TxResult.Result.Data)
if err != nil {
api.logger.Error("failed to decode tx response", "error", err.Error())
return
unfiltered := make([]*ethtypes.Log, 0)
for _, event := range dataTx.Result.Events {
if event.Type != evmtypes.EventTypeTxLog {
continue
}
for _, attr := range event.Attributes {
if bytes.Equal(attr.Key, []byte(evmtypes.AttributeKeyTxLog)) {
var log evmtypes.Log
if json.Unmarshal(attr.Value, &log) == nil {
unfiltered = append(unfiltered, log.ToEthereum())
}
}
}
}

logs := rpcfilters.FilterLogs(evmtypes.LogsToEthereum(txResponse.Logs), crit.FromBlock, crit.ToBlock, crit.Addresses, crit.Topics)
logs := rpcfilters.FilterLogs(unfiltered, crit.FromBlock, crit.ToBlock, crit.Addresses, crit.Topics)
if len(logs) == 0 {
continue
}
Expand Down

0 comments on commit 6218fa1

Please sign in to comment.