Skip to content

Commit

Permalink
use maps instaed fo ToCamelCase to allow consistnacy, also safer if c…
Browse files Browse the repository at this point in the history
…ustomers have foo and foo_ both as varibles.
  • Loading branch information
nolag committed Jan 16, 2024
1 parent 8ee5f12 commit bce2e3b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
3 changes: 1 addition & 2 deletions core/internal/features/ocr2/features_ocr2_test.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions core/services/relay/evm/codec_entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package evm
import (
"fmt"
"reflect"
"strings"

"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -66,8 +67,7 @@ func (entry *codecEntry) Init() error {
return fmt.Errorf("%w: empty field names are not supported for multiple returns", commontypes.ErrInvalidType)
}

// To match decoding in abi
name := abi.ToCamelCase(arg.Name)
name := strings.ToUpper(arg.Name[:1]) + arg.Name[1:]
if seenNames[name] {
return fmt.Errorf("%w: duplicate field name %s, after ToCamelCase", commontypes.ErrInvalidConfig, name)
}
Expand Down
4 changes: 2 additions & 2 deletions core/services/relay/evm/event_binding.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@ func (e *eventBinding) decodeLog(ctx context.Context, log *logpoller.Log, into a
topics[i] = common.Hash(log.Topics[i+1])
}

topicsInto := reflect.New(e.topicInfo.nativeType).Interface()
if err := abi.ParseTopics(topicsInto, e.topicInfo.Args, topics); err != nil {
topicsInto := map[string]any{}
if err := abi.ParseTopicsIntoMap(topicsInto, e.topicInfo.Args, topics); err != nil {
return fmt.Errorf("%w: %w", commontypes.ErrInvalidType, err)
}

Expand Down
2 changes: 1 addition & 1 deletion integration-tests/actions/ocr2_helpers_local.go

Large diffs are not rendered by default.

0 comments on commit bce2e3b

Please sign in to comment.