Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pkg/assets/link.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ var linkFmtThreshold = (*Link)(new(big.Int).Exp(big.NewInt(10), big.NewInt(12),
// MarshalText implements the encoding.TextMarshaler interface.
func (l *Link) MarshalText() ([]byte, error) {
if l.Cmp(linkFmtThreshold) >= 0 {
return []byte(fmt.Sprintf("%s link", decimal.NewFromBigInt(l.ToInt(), -18))), nil
return fmt.Appendf(nil, "%s link", decimal.NewFromBigInt(l.ToInt(), -18)), nil
}
return (*big.Int)(l).MarshalText()
}
Expand All @@ -109,7 +109,7 @@ func (l Link) MarshalJSON() ([]byte, error) {
if err != nil {
return nil, err
}
return []byte(fmt.Sprintf(`"%s"`, value)), nil
return fmt.Appendf(nil, `"%s"`, value), nil
}

// UnmarshalJSON implements the json.Unmarshaler interface.
Expand Down Expand Up @@ -166,7 +166,7 @@ func (l Link) Value() (driver.Value, error) {
}

// Scan reads the database value and returns an instance.
func (l *Link) Scan(value interface{}) error {
func (l *Link) Scan(value any) error {
switch v := value.(type) {
case string:
decoded, ok := l.SetString(v, 10)
Expand Down
5 changes: 2 additions & 3 deletions pkg/beholder/chip_ingress_emitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package beholder
import (
"context"
"fmt"
"maps"

"github.com/smartcontractkit/chainlink-common/pkg/chipingress"
)
Expand Down Expand Up @@ -83,9 +84,7 @@ func ExtractAttributes(attrKVs ...any) map[string]any {
attributes := newAttributes(attrKVs...)

attributesMap := make(map[string]any)
for key, value := range attributes {
attributesMap[key] = value
}
maps.Copy(attributesMap, attributes)

return attributesMap
}
13 changes: 4 additions & 9 deletions pkg/beholder/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package beholder
import (
"errors"
"fmt"
"maps"
"regexp"
"strings"

Expand Down Expand Up @@ -80,9 +81,7 @@ func newAttributes(attrKVs ...any) Attributes {
for i := 0; i < l; {
switch t := attrKVs[i].(type) {
case Attributes:
for k, v := range t {
a[k] = v
}
maps.Copy(a, t)
i++
case string:
if i+1 >= l {
Expand Down Expand Up @@ -111,9 +110,7 @@ func (e *Message) AddAttributes(attrKVs ...any) {
if e.Attrs == nil {
e.Attrs = make(map[string]any, len(attrs)/2)
}
for k, v := range attrs {
e.Attrs[k] = v
}
maps.Copy(e.Attrs, attrs)
}

func (e *Message) OtelRecord() otellog.Record {
Expand All @@ -122,9 +119,7 @@ func (e *Message) OtelRecord() otellog.Record {

func (e *Message) Copy() Message {
attrs := make(Attributes, len(e.Attrs))
for k, v := range e.Attrs {
attrs[k] = v
}
maps.Copy(attrs, e.Attrs)
c := Message{
Attrs: attrs,
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/capabilities/capabilities_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ func TestOCRTriggerEvent_ToMapFromMap(t *testing.T) {
// Test error handling

t.Run("invalid map missing key", func(t *testing.T) {
invalidMap, err := values.NewMap(map[string]interface{}{
invalidMap, err := values.NewMap(map[string]any{
"WrongKey": "value",
})
require.NoError(t, err)
Expand Down
4 changes: 2 additions & 2 deletions pkg/capabilities/cli/cmd/generate-user-types/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func genForStruct() func(string) bool {

func buildSkipGen() map[string]bool {
skipGen := map[string]bool{}
for _, skip := range strings.Split(*skipCap, ",") {
for skip := range strings.SplitSeq(*skipCap, ",") {
skipGen[skip] = true
}
return skipGen
Expand All @@ -86,7 +86,7 @@ func buildGenPkgType() func(string) bool {
genPkgType := func(_ string) bool { return true }
if *types != "" {
genPkg := map[string]bool{}
for _, t := range strings.Split(*types, ",") {
for t := range strings.SplitSeq(*types, ",") {
genPkg[t] = true
}
genPkgType = func(s string) bool {
Expand Down
5 changes: 2 additions & 3 deletions pkg/capabilities/cli/cmd/generate_user_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"errors"
"maps"
"os"
"path"
"strings"
Expand Down Expand Up @@ -43,9 +44,7 @@ func GenerateUserTypes(info UserGenerationInfo) error {
if i == 0 {
generatedInfo = fileGeneratedInfo
} else {
for name, strct := range fileGeneratedInfo.Types {
generatedInfo.Types[name] = strct
}
maps.Copy(generatedInfo.Types, fileGeneratedInfo.Types)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"math"
"math/big"
"slices"
"sort"
"strconv"
"time"
Expand Down Expand Up @@ -229,7 +230,7 @@ func (a *reduceAggregator) shouldReport(lggr logger.Logger, field AggregationFie
if !bytes.Equal(v, unwrappedSingleValue.([]byte)) {
return true, nil
}
case map[string]interface{}, []any:
case map[string]any, []any:
marshalledOldValue, err := proto.MarshalOptions{Deterministic: true}.Marshal(values.Proto(oldValue))
if err != nil {
return false, err
Expand Down Expand Up @@ -545,12 +546,7 @@ func formatReport(report map[string]any, format string) (any, error) {
}

func isOneOf(toCheck string, options []string) bool {
for _, option := range options {
if toCheck == option {
return true
}
}
return false
return slices.Contains(options, toCheck)
}

func NewReduceAggregator(config values.Map) (types.Aggregator, error) {
Expand Down
Loading
Loading