From 6cd5ab0b2e1f2f877860f33415b1b8c0a1dbfccf Mon Sep 17 00:00:00 2001 From: William Hua Date: Tue, 8 Oct 2024 18:13:58 -0400 Subject: [PATCH] ethreceipts: fix filter match logic (#140) We were returning a "missing filter condition" error when a log topic filter was set, but the receipt had no logs. Also, we should be able to filter on logs even if there are none. --- ethreceipts/filterer.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/ethreceipts/filterer.go b/ethreceipts/filterer.go index da80d03c..efe487e3 100644 --- a/ethreceipts/filterer.go +++ b/ethreceipts/filterer.go @@ -233,7 +233,7 @@ func (f *filter) Match(ctx context.Context, receipt Receipt) (bool, error) { return ok, nil } - if c.LogTopic != nil && len(receipt.Logs()) > 0 { + if c.LogTopic != nil { for _, log := range receipt.Logs() { if len(log.Topics) == 0 { continue @@ -245,12 +245,9 @@ func (f *filter) Match(ctx context.Context, receipt Receipt) (bool, error) { return false, nil } - if c.Logs != nil && len(receipt.Logs()) > 0 { + if c.Logs != nil { ok := c.Logs(receipt.Logs()) return ok, nil - } else if c.Logs != nil { - // no log matches, but a log filter is present - return false, nil } return false, ErrFilterCond