Skip to content

Commit

Permalink
update reference to common
Browse files Browse the repository at this point in the history
  • Loading branch information
EasterTheBunny committed Feb 21, 2025
1 parent a861246 commit 0e885d3
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 44 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ require (
github.com/prometheus/client_golang v1.20.5
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250203132120-f0d42463e405
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250206215114-fb6c3c35e8e3
github.com/smartcontractkit/chainlink-common v0.4.2-0.20250221044241-800d6b475fad
github.com/smartcontractkit/chainlink-common v0.4.2-0.20250221193850-cf5644cdb336
github.com/smartcontractkit/chainlink-framework/multinode v0.0.0-20250211162441-3d6cea220efb
github.com/smartcontractkit/libocr v0.0.0-20241223215956-e5b78d8e3919
github.com/stretchr/testify v1.10.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -584,8 +584,8 @@ github.com/smartcontractkit/chainlink-ccip v0.0.0-20250203132120-f0d42463e405 h1
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250203132120-f0d42463e405/go.mod h1:UEnHaxkUsfreeA7rR45LMmua1Uen95tOFUR8/AI9BAo=
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250206215114-fb6c3c35e8e3 h1:f4F/7OCuMybsPKKXXvLQz+Q1hGq07I1cfoWy5EA9iRg=
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250206215114-fb6c3c35e8e3/go.mod h1:Bmwq4lNb5tE47sydN0TKetcLEGbgl+VxHEWp4S0LI60=
github.com/smartcontractkit/chainlink-common v0.4.2-0.20250221044241-800d6b475fad h1:n7vQtigsgTKIhrN0FxfO9PpeqOVHNn9GBkQijwjPFBU=
github.com/smartcontractkit/chainlink-common v0.4.2-0.20250221044241-800d6b475fad/go.mod h1:Z2e1ynSJ4pg83b4Qldbmryc5lmnrI3ojOdg1FUloa68=
github.com/smartcontractkit/chainlink-common v0.4.2-0.20250221193850-cf5644cdb336 h1:BpKU+vD3k1cDdSFMb49i896PlRTOShM3Vdbd7fChtfM=
github.com/smartcontractkit/chainlink-common v0.4.2-0.20250221193850-cf5644cdb336/go.mod h1:Z2e1ynSJ4pg83b4Qldbmryc5lmnrI3ojOdg1FUloa68=
github.com/smartcontractkit/chainlink-framework/multinode v0.0.0-20250211162441-3d6cea220efb h1:LWijSyJ2lhppkFLN19EGsLHZXQ5wen2DEk1cyR0tV+o=
github.com/smartcontractkit/chainlink-framework/multinode v0.0.0-20250211162441-3d6cea220efb/go.mod h1:4JqpgFy01LaqG1yM2iFTzwX3ZgcAvW9WdstBZQgPHzU=
github.com/smartcontractkit/grpc-proxy v0.0.0-20240830132753-a7e17fec5ab7 h1:12ijqMM9tvYVEm+nR826WsrNi6zCKpwBhuApq127wHs=
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
github.com/rs/zerolog v1.33.0
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250212131315-e9b53b05b02a
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250206215114-fb6c3c35e8e3
github.com/smartcontractkit/chainlink-common v0.4.2-0.20250221044241-800d6b475fad
github.com/smartcontractkit/chainlink-common v0.4.2-0.20250221193850-cf5644cdb336
github.com/smartcontractkit/chainlink-solana v1.1.2-0.20250213035259-e727e73f6181
github.com/smartcontractkit/chainlink-testing-framework/lib v1.51.0
github.com/smartcontractkit/chainlink-testing-framework/seth v1.50.10
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1104,8 +1104,8 @@ github.com/smartcontractkit/chainlink-ccip v0.0.0-20250212131315-e9b53b05b02a h1
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250212131315-e9b53b05b02a/go.mod h1:Hht/OJq/PxC+gnBCIPyzHt4Otsw6mYwUVsmtOqIvlxo=
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250206215114-fb6c3c35e8e3 h1:f4F/7OCuMybsPKKXXvLQz+Q1hGq07I1cfoWy5EA9iRg=
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250206215114-fb6c3c35e8e3/go.mod h1:Bmwq4lNb5tE47sydN0TKetcLEGbgl+VxHEWp4S0LI60=
github.com/smartcontractkit/chainlink-common v0.4.2-0.20250221044241-800d6b475fad h1:n7vQtigsgTKIhrN0FxfO9PpeqOVHNn9GBkQijwjPFBU=
github.com/smartcontractkit/chainlink-common v0.4.2-0.20250221044241-800d6b475fad/go.mod h1:Z2e1ynSJ4pg83b4Qldbmryc5lmnrI3ojOdg1FUloa68=
github.com/smartcontractkit/chainlink-common v0.4.2-0.20250221193850-cf5644cdb336 h1:BpKU+vD3k1cDdSFMb49i896PlRTOShM3Vdbd7fChtfM=
github.com/smartcontractkit/chainlink-common v0.4.2-0.20250221193850-cf5644cdb336/go.mod h1:Z2e1ynSJ4pg83b4Qldbmryc5lmnrI3ojOdg1FUloa68=
github.com/smartcontractkit/chainlink-data-streams v0.1.1-0.20250128203428-08031923fbe5 h1:CvDfgWoLoYPapOumE/UZCplfCu5oNmy9BuH+6V6+fJ8=
github.com/smartcontractkit/chainlink-data-streams v0.1.1-0.20250128203428-08031923fbe5/go.mod h1:pDZagSGjs9U+l4YIFhveDznMHqxuuz+5vRxvVgpbdr8=
github.com/smartcontractkit/chainlink-feeds v0.1.1 h1:JzvUOM/OgGQA1sOqTXXl52R6AnNt+Wg64sVG+XSA49c=
Expand Down
39 changes: 1 addition & 38 deletions pkg/solana/chainreader/event_read_binding.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ func (b *eventReadBinding) extractFilterSubkeys(offChainParams any) ([]query.Exp
for offChainKey, idx := range b.indexedSubKeys.lookup {
itemType := codec.WrapItemType(true, b.namespace, b.genericName+"."+offChainKey)

fieldVal, err := valueForPath(reflect.ValueOf(offChainParams), offChainKey)
fieldVal, err := commoncodec.ValueForPath(reflect.ValueOf(offChainParams), offChainKey)
if err != nil {
return nil, fmt.Errorf("%w: no value for path %s; err: %w", types.ErrInternal, b.genericName+"."+offChainKey, err)
}
Expand Down Expand Up @@ -513,40 +513,3 @@ func (k *indexedSubkeys) indexForKey(key string) (uint64, bool) {

return idx, ok
}

func valueForPath(from reflect.Value, itemType string) (any, error) {
if itemType == "" {
return from.Interface(), nil
}

switch from.Kind() {
case reflect.Pointer:
if from.IsNil() {
from = reflect.New(from.Type().Elem())
}

elem, err := valueForPath(from.Elem(), itemType)
if err != nil {
return nil, err
}

return elem, nil
case reflect.Array, reflect.Slice:
return nil, fmt.Errorf("%w: cannot extract a field from an array or slice", types.ErrInvalidType)
case reflect.Struct:
head, tail := commoncodec.ItemTyper(itemType).Next()

field := from.FieldByName(head)
if !field.IsValid() {
return nil, fmt.Errorf("%w: field not found for path %s and itemType %s", types.ErrInvalidType, from, itemType)
}

if tail == "" {
return field.Interface(), nil
}

return valueForPath(field, tail)
default:
return nil, fmt.Errorf("%w: cannot extract a field from kind %s", types.ErrInvalidType, from.Kind())
}
}

0 comments on commit 0e885d3

Please sign in to comment.