Skip to content
This repository was archived by the owner on May 9, 2024. It is now read-only.

Commit 20a5360

Browse files
authored
Remove logs reverted due to a chain reorg (#322)
1 parent b25168d commit 20a5360

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

chains/evm/calls/evmclient/evm-client.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,20 @@ func (c *EVMClient) GetTransactionByHash(h common.Hash) (tx *types.Transaction,
112112
}
113113

114114
func (c *EVMClient) FetchEventLogs(ctx context.Context, contractAddress common.Address, event string, startBlock *big.Int, endBlock *big.Int) ([]types.Log, error) {
115-
return c.FilterLogs(ctx, buildQuery(contractAddress, event, startBlock, endBlock))
115+
logs, err := c.FilterLogs(ctx, buildQuery(contractAddress, event, startBlock, endBlock))
116+
if err != nil {
117+
return []types.Log{}, err
118+
}
119+
120+
validLogs := make([]types.Log, 0)
121+
for _, log := range logs {
122+
if log.Removed {
123+
continue
124+
}
125+
126+
validLogs = append(validLogs, log)
127+
}
128+
return validLogs, nil
116129
}
117130

118131
// SendRawTransaction accepts rlp-encode of signed transaction and sends it via RPC call

0 commit comments

Comments
 (0)