Skip to content

Commit

Permalink
fix linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
silaslenihan committed Sep 26, 2024
1 parent e37679c commit 4af0076
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .changeset/nervous-books-push.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"chainlink": minor
---

Updated QueryKey to be able to do advanced queries on contract event data words
#internal Updated QueryKey to be able to do advanced queries on contract event data words
5 changes: 5 additions & 0 deletions contracts/.changeset/tall-donkeys-flow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@chainlink/contracts': minor
---

#internal Updated ChainReaderTester to include dynamic and static nested structs in TestStruct
2 changes: 1 addition & 1 deletion core/chains/evm/logpoller/orm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@ func TestORM_DataWords(t *testing.T) {
},
}))

wordFilter := func(wordIdx uint8, word1, word2 uint64) []query.Expression {
wordFilter := func(wordIdx int, word1, word2 uint64) []query.Expression {
return []query.Expression{
logpoller.NewAddressFilter(addr),
logpoller.NewEventSigFilter(eventSig),
Expand Down
4 changes: 2 additions & 2 deletions core/chains/evm/logpoller/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -498,11 +498,11 @@ type HashedValueComparator struct {
}

type eventByWordFilter struct {
WordIndex uint8
WordIndex int
HashedValueComparers []HashedValueComparator
}

func NewEventByWordFilter(wordIndex uint8, valueComparers []HashedValueComparator) query.Expression {
func NewEventByWordFilter(wordIndex int, valueComparers []HashedValueComparator) query.Expression {
return query.Expression{Primitive: &eventByWordFilter{
WordIndex: wordIndex,
HashedValueComparers: valueComparers,
Expand Down
13 changes: 6 additions & 7 deletions core/services/relay/evm/chain_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,11 +365,10 @@ func (cr *chainReader) initDWQuerying(contractName, eventName string, eventDWs m
dWsDetail := make(map[string]read.DataWordDetail)

for genericName, onChainName := range dWDefs {
for eventId, dWDetail := range eventDWs {
for eventID, dWDetail := range eventDWs {
// Extract field name in this manner to account for nested fields
fieldName := strings.Join(strings.Split(eventId, ".")[1:], ".")
fieldName := strings.Join(strings.Split(eventID, ".")[1:], ".")
if fieldName == onChainName {

dWsDetail[genericName] = dWDetail

dwTypeID := eventName + "." + genericName
Expand Down Expand Up @@ -428,7 +427,7 @@ func getEventTypes(event abi.Event) ([]abi.Argument, types.CodecEntry, map[strin
indexedAsUnIndexedTypes := make([]abi.Argument, 0, types.MaxTopicFields)
indexedTypes := make([]abi.Argument, 0, len(event.Inputs))
dataWords := make(map[string]read.DataWordDetail)
var dwIndex uint8
var dwIndex int

for _, input := range event.Inputs {
if !input.Indexed {
Expand All @@ -446,15 +445,15 @@ func getEventTypes(event abi.Event) ([]abi.Argument, types.CodecEntry, map[strin
return indexedAsUnIndexedTypes, types.NewCodecEntry(indexedTypes, nil, nil), dataWords
}

func findFieldIndex(arg abi.Argument, fieldPath string, dataWords map[string]read.DataWordDetail, index uint8) uint8 {
func findFieldIndex(arg abi.Argument, fieldPath string, dataWords map[string]read.DataWordDetail, index int) int {
if isDynamic(arg.Type) {
return index + 1
}

return processFields(arg.Type, fieldPath, dataWords, index)
}

func processFields(fieldType abi.Type, parentFieldPath string, dataWords map[string]read.DataWordDetail, index uint8) uint8 {
func processFields(fieldType abi.Type, parentFieldPath string, dataWords map[string]read.DataWordDetail, index int) int {
switch fieldType.T {
case abi.TupleTy:
// Recursively process tuple elements
Expand All @@ -467,7 +466,7 @@ func processFields(fieldType abi.Type, parentFieldPath string, dataWords map[str
case abi.ArrayTy:
// Static arrays are not searchable, however, we can reliably calculate their size so that the fields
// after them can be searched.
return index + uint8(fieldType.Size)
return index + fieldType.Size
default:
dataWords[parentFieldPath] = read.DataWordDetail{
Index: index,
Expand Down
2 changes: 1 addition & 1 deletion core/services/relay/evm/read/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ type TopicDetail struct {
// DataWordDetail contains all the information about a single evm Data word.
// For b.g. first evm data word(32bytes) of USDC log event is uint256 var called valub.
type DataWordDetail struct {
Index uint8
Index int
abi.Argument
}

Expand Down

0 comments on commit 4af0076

Please sign in to comment.