Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ettec committed Nov 26, 2024
1 parent a2ec904 commit 0c8546d
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions core/services/relay/evm/read/multieventtype.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"reflect"
"strconv"
"strings"

"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -36,7 +37,7 @@ func MultiEventTypeQuery(ctx context.Context, lp logpoller.LogPoller, eventQueri
ReturnVal: eq.SequenceDataType,
}, "", eventReadType)
} else {
err = fmt.Errorf("no event queries provided: %v", err)
err = fmt.Errorf("no event queries provided: %w", err)
}
}
}()
Expand All @@ -47,8 +48,8 @@ func MultiEventTypeQuery(ctx context.Context, lp logpoller.LogPoller, eventQueri
}
}

var allFilterExpressions []query.Expression
for _, eq := range eventQueries {
allFilterExpressions := make([]query.Expression, 0, len(eventQueries))
for idx, eq := range eventQueries {
var expressions []query.Expression

defaultExpressions := []query.Expression{
Expand All @@ -57,15 +58,15 @@ func MultiEventTypeQuery(ctx context.Context, lp logpoller.LogPoller, eventQueri
}
expressions = append(expressions, defaultExpressions...)

remapped, err := eq.EventBinding.remap(eq.Filter)
if err != nil {
return nil, fmt.Errorf("error remapping filter: %v", err)
remapped, remapErr := eq.EventBinding.remap(eq.Filter)
if remapErr != nil {
return nil, fmt.Errorf("error remapping filter: %w", err)
}
expressions = append(expressions, remapped.Expressions...)

filterExpression := query.And(expressions...)

allFilterExpressions = append(allFilterExpressions, filterExpression)
allFilterExpressions[idx] = filterExpression
}

eventQuery := query.Or(allFilterExpressions...)
Expand All @@ -74,7 +75,7 @@ func MultiEventTypeQuery(ctx context.Context, lp logpoller.LogPoller, eventQueri
for _, eq := range eventQueries {
queryName += eq.EventBinding.contractName + "-" + eq.Address.String() + "-" + eq.EventBinding.eventName + "-"
}
strings.TrimSuffix(queryName, "-")
queryName = strings.TrimSuffix(queryName, "-")

logs, err := lp.FilteredLogs(ctx, []query.Expression{eventQuery}, limitAndSort, queryName)
if err != nil {
Expand Down Expand Up @@ -116,9 +117,9 @@ func decodeMultiEventTypeLogsIntoSequences(ctx context.Context, logs []logpoller
Sequence: commontypes.Sequence{
Cursor: logpoller.FormatContractReaderCursor(logEntry),
Head: commontypes.Head{
Height: fmt.Sprint(logEntry.BlockNumber),
Height: strconv.FormatInt(logEntry.BlockNumber, 10),
Hash: logEntry.BlockHash.Bytes(),
Timestamp: uint64(logEntry.BlockTimestamp.Unix()),
Timestamp: uint64(logEntry.BlockTimestamp.Unix()), //nolint:gosec // G115 false positive
},
},
}
Expand Down

0 comments on commit 0c8546d

Please sign in to comment.