Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support passing in a values.Value to the GetLatestValue and QueryKey methods #14488

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions .changeset/silly-zebras-exercise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

#internal add support for values.Value type in the contract reader GetLatestValue and QueryKey methods
2 changes: 1 addition & 1 deletion core/scripts/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ require (
github.com/prometheus/client_golang v1.20.0
github.com/shopspring/decimal v1.4.0
github.com/smartcontractkit/chainlink-automation v1.0.4
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240919092417-53e784c2e420
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240923160006-d50d3dac48c6
github.com/smartcontractkit/chainlink/v2 v2.0.0-00010101000000-000000000000
github.com/smartcontractkit/libocr v0.0.0-20240717100443-f6226e09bee7
github.com/spf13/cobra v1.8.1
Expand Down
1 change: 1 addition & 0 deletions core/scripts/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1085,6 +1085,7 @@ github.com/smartcontractkit/chainlink-ccip v0.0.0-20240920150748-cf2125c094fe h1
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240920150748-cf2125c094fe/go.mod h1:KP82vFCqm+M1G1t6Vos5CewGUGYJkxxCEdxnta4uLlE=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240919092417-53e784c2e420 h1:+xNnYYgkxzKUIkLCOfzfAKUxeLLtuxlalDI70kNJ8No=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240919092417-53e784c2e420/go.mod h1:zm+l8gN4LQS1+YvwQDhRz/njirVeWGNiDJKIhCGwaoQ=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240923160006-d50d3dac48c6/go.mod h1:F6WUS6N4mP5ScwpwyTyAJc9/vjR+GXbMCRUOVekQi1g=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240911175228-daf2600bb7b7 h1:lTGIOQYLk1Ufn++X/AvZnt6VOcuhste5yp+C157No/Q=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240911175228-daf2600bb7b7/go.mod h1:BMYE1vC/pGmdFSsOJdPrAA0/4gZ0Xo0SxTMdGspBtRo=
github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240916152957-433914114bd2 h1:yRk4ektpx/UxwarqAfgxUXLrsYXlaNeP1NOwzHGrK2Q=
Expand Down
54 changes: 52 additions & 2 deletions core/services/relay/evm/chain_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
commontypes "github.com/smartcontractkit/chainlink-common/pkg/types"
"github.com/smartcontractkit/chainlink-common/pkg/types/query"
"github.com/smartcontractkit/chainlink-common/pkg/types/query/primitives"
"github.com/smartcontractkit/chainlink-common/pkg/values"

evmclient "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller"
Expand Down Expand Up @@ -176,7 +177,28 @@ func (cr *chainReader) GetLatestValue(ctx context.Context, readName string, conf
return err
}

return binding.GetLatestValue(ctx, common.HexToAddress(address), confidenceLevel, params, returnVal)
ptrToValue, isValue := returnVal.(*values.Value)
if !isValue {
return binding.GetLatestValue(ctx, common.HexToAddress(address), confidenceLevel, params, returnVal)
}

contractType, err := cr.CreateContractType(readName, false)
if err != nil {
return err
}

if err = cr.GetLatestValue(ctx, readName, confidenceLevel, params, contractType); err != nil {
return err
}

value, err := values.Wrap(contractType)
if err != nil {
return err
}

*ptrToValue = value

return nil
}

func (cr *chainReader) BatchGetLatestValues(ctx context.Context, request commontypes.BatchGetLatestValuesRequest) (commontypes.BatchGetLatestValuesResult, error) {
Expand All @@ -195,7 +217,35 @@ func (cr *chainReader) QueryKey(
return nil, err
}

return binding.QueryKey(ctx, common.HexToAddress(address), filter, limitAndSort, sequenceDataType)
_, isValuePtr := sequenceDataType.(*values.Value)
if !isValuePtr {
return binding.QueryKey(ctx, common.HexToAddress(address), filter, limitAndSort, sequenceDataType)
}

dataTypeFromReadIdentifier, err := cr.CreateContractType(contract.ReadIdentifier(filter.Key), false)
if err != nil {
return nil, err
}

sequence, err := binding.QueryKey(ctx, common.HexToAddress(address), filter, limitAndSort, dataTypeFromReadIdentifier)
if err != nil {
return nil, err
}

sequenceOfValues := make([]commontypes.Sequence, len(sequence))
for idx, entry := range sequence {
value, err := values.Wrap(entry.Data)
if err != nil {
return nil, err
}
sequenceOfValues[idx] = commontypes.Sequence{
Cursor: entry.Cursor,
Head: entry.Head,
Data: &value,
}
}

return sequenceOfValues, nil
}

func (cr *chainReader) CreateContractType(readIdentifier string, forEncoding bool) (any, error) {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ require (
github.com/smartcontractkit/chain-selectors v1.0.23
github.com/smartcontractkit/chainlink-automation v1.0.4
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240920150748-cf2125c094fe
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240919092417-53e784c2e420
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240923214950-7819384f0e47
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240911175228-daf2600bb7b7
github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240916152957-433914114bd2
github.com/smartcontractkit/chainlink-feeds v0.0.0-20240910155501-42f20443189f
Expand Down
16 changes: 16 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,22 @@ github.com/smartcontractkit/chainlink-ccip v0.0.0-20240920150748-cf2125c094fe h1
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240920150748-cf2125c094fe/go.mod h1:KP82vFCqm+M1G1t6Vos5CewGUGYJkxxCEdxnta4uLlE=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240919092417-53e784c2e420 h1:+xNnYYgkxzKUIkLCOfzfAKUxeLLtuxlalDI70kNJ8No=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240919092417-53e784c2e420/go.mod h1:zm+l8gN4LQS1+YvwQDhRz/njirVeWGNiDJKIhCGwaoQ=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240923152002-13eb9853f765 h1:lhuDU+ArHfrzHFlp58LEi+ufDwZd1MlQBELhtsPK3Xs=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240923152002-13eb9853f765/go.mod h1:F6WUS6N4mP5ScwpwyTyAJc9/vjR+GXbMCRUOVekQi1g=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240923160006-d50d3dac48c6 h1:M5Vgjsfx5qtPbLKxmzzpsdduUrVNtyrone6CvJfZ+no=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240923160006-d50d3dac48c6/go.mod h1:F6WUS6N4mP5ScwpwyTyAJc9/vjR+GXbMCRUOVekQi1g=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240923183555-872f9613e27e h1:3feQjKsO24JsX2Z63l1oRVnfKQ6l9BhYGCiJkFxEJS0=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240923183555-872f9613e27e/go.mod h1:F6WUS6N4mP5ScwpwyTyAJc9/vjR+GXbMCRUOVekQi1g=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240923185555-f7e9f9b04734 h1:vvJcaZuPU9+ghBiswzwIAEEgX2CmoDSsO1S3SKvRJTs=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240923185555-f7e9f9b04734/go.mod h1:F6WUS6N4mP5ScwpwyTyAJc9/vjR+GXbMCRUOVekQi1g=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240923185945-cdc4f1512b3d h1:zuKW8rPjM7TTpzgzCy9+T2j0W4CjYkdDFibMyu7aSJQ=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240923185945-cdc4f1512b3d/go.mod h1:F6WUS6N4mP5ScwpwyTyAJc9/vjR+GXbMCRUOVekQi1g=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240923194257-102f116cbb2e h1:kVszKtqDTo4r6U4ZunBeJFoTRAxT5LgHDfjzwaJ+PWA=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240923194257-102f116cbb2e/go.mod h1:F6WUS6N4mP5ScwpwyTyAJc9/vjR+GXbMCRUOVekQi1g=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240923214331-4db08b9c3a0b h1:8GFs0egUnwWT5geVUo3MVedQBBq3WOHXpz2sB2JUd+k=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240923214331-4db08b9c3a0b/go.mod h1:F6WUS6N4mP5ScwpwyTyAJc9/vjR+GXbMCRUOVekQi1g=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240923214950-7819384f0e47 h1:/fEYV987kht8XVgobrLxHNEgkI1tioDOScHgi0JT9MQ=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240923214950-7819384f0e47/go.mod h1:F6WUS6N4mP5ScwpwyTyAJc9/vjR+GXbMCRUOVekQi1g=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240911175228-daf2600bb7b7 h1:lTGIOQYLk1Ufn++X/AvZnt6VOcuhste5yp+C157No/Q=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240911175228-daf2600bb7b7/go.mod h1:BMYE1vC/pGmdFSsOJdPrAA0/4gZ0Xo0SxTMdGspBtRo=
github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240916152957-433914114bd2 h1:yRk4ektpx/UxwarqAfgxUXLrsYXlaNeP1NOwzHGrK2Q=
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ require (
github.com/smartcontractkit/chain-selectors v1.0.23
github.com/smartcontractkit/chainlink-automation v1.0.4
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240920150748-cf2125c094fe
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240919092417-53e784c2e420
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240923160006-d50d3dac48c6
github.com/smartcontractkit/chainlink-testing-framework/havoc v1.50.0
github.com/smartcontractkit/chainlink-testing-framework/lib v1.50.8
github.com/smartcontractkit/chainlink-testing-framework/lib/grafana v1.50.0
Expand Down
1 change: 1 addition & 0 deletions integration-tests/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1427,6 +1427,7 @@ github.com/smartcontractkit/chainlink-ccip v0.0.0-20240920150748-cf2125c094fe h1
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240920150748-cf2125c094fe/go.mod h1:KP82vFCqm+M1G1t6Vos5CewGUGYJkxxCEdxnta4uLlE=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240919092417-53e784c2e420 h1:+xNnYYgkxzKUIkLCOfzfAKUxeLLtuxlalDI70kNJ8No=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240919092417-53e784c2e420/go.mod h1:zm+l8gN4LQS1+YvwQDhRz/njirVeWGNiDJKIhCGwaoQ=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240923160006-d50d3dac48c6/go.mod h1:F6WUS6N4mP5ScwpwyTyAJc9/vjR+GXbMCRUOVekQi1g=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240911175228-daf2600bb7b7 h1:lTGIOQYLk1Ufn++X/AvZnt6VOcuhste5yp+C157No/Q=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240911175228-daf2600bb7b7/go.mod h1:BMYE1vC/pGmdFSsOJdPrAA0/4gZ0Xo0SxTMdGspBtRo=
github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240916152957-433914114bd2 h1:yRk4ektpx/UxwarqAfgxUXLrsYXlaNeP1NOwzHGrK2Q=
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/load/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/pkg/errors v0.9.1
github.com/rs/zerolog v1.33.0
github.com/slack-go/slack v0.12.2
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240919092417-53e784c2e420
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240923160006-d50d3dac48c6
github.com/smartcontractkit/chainlink-testing-framework/lib v1.50.8
github.com/smartcontractkit/chainlink-testing-framework/seth v1.50.1
github.com/smartcontractkit/chainlink-testing-framework/wasp v1.50.0
Expand Down
1 change: 1 addition & 0 deletions integration-tests/load/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1401,6 +1401,7 @@ github.com/smartcontractkit/chainlink-ccip v0.0.0-20240920150748-cf2125c094fe h1
github.com/smartcontractkit/chainlink-ccip v0.0.0-20240920150748-cf2125c094fe/go.mod h1:KP82vFCqm+M1G1t6Vos5CewGUGYJkxxCEdxnta4uLlE=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240919092417-53e784c2e420 h1:+xNnYYgkxzKUIkLCOfzfAKUxeLLtuxlalDI70kNJ8No=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240919092417-53e784c2e420/go.mod h1:zm+l8gN4LQS1+YvwQDhRz/njirVeWGNiDJKIhCGwaoQ=
github.com/smartcontractkit/chainlink-common v0.2.3-0.20240923160006-d50d3dac48c6/go.mod h1:F6WUS6N4mP5ScwpwyTyAJc9/vjR+GXbMCRUOVekQi1g=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240911175228-daf2600bb7b7 h1:lTGIOQYLk1Ufn++X/AvZnt6VOcuhste5yp+C157No/Q=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240911175228-daf2600bb7b7/go.mod h1:BMYE1vC/pGmdFSsOJdPrAA0/4gZ0Xo0SxTMdGspBtRo=
github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240916152957-433914114bd2 h1:yRk4ektpx/UxwarqAfgxUXLrsYXlaNeP1NOwzHGrK2Q=
Expand Down
Loading