From 20a53601c48a59b88a8c695bd674fcafdaf432a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matija=20Petruni=C4=87?= Date: Thu, 29 Sep 2022 12:40:51 +0200 Subject: [PATCH] Remove logs reverted due to a chain reorg (#322) --- chains/evm/calls/evmclient/evm-client.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/chains/evm/calls/evmclient/evm-client.go b/chains/evm/calls/evmclient/evm-client.go index 68aac1bd..67604cad 100644 --- a/chains/evm/calls/evmclient/evm-client.go +++ b/chains/evm/calls/evmclient/evm-client.go @@ -112,7 +112,20 @@ func (c *EVMClient) GetTransactionByHash(h common.Hash) (tx *types.Transaction, } func (c *EVMClient) FetchEventLogs(ctx context.Context, contractAddress common.Address, event string, startBlock *big.Int, endBlock *big.Int) ([]types.Log, error) { - return c.FilterLogs(ctx, buildQuery(contractAddress, event, startBlock, endBlock)) + logs, err := c.FilterLogs(ctx, buildQuery(contractAddress, event, startBlock, endBlock)) + if err != nil { + return []types.Log{}, err + } + + validLogs := make([]types.Log, 0) + for _, log := range logs { + if log.Removed { + continue + } + + validLogs = append(validLogs, log) + } + return validLogs, nil } // SendRawTransaction accepts rlp-encode of signed transaction and sends it via RPC call