Skip to content

Commit

Permalink
ethreceipts: fix filter match logic (#140)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
attente authored Oct 8, 2024
1 parent c08d077 commit 6cd5ab0
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions ethreceipts/filterer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 6cd5ab0

Please sign in to comment.