Skip to content

Commit

Permalink
implement contract reader interface changes
Browse files Browse the repository at this point in the history
  • Loading branch information
EasterTheBunny committed Jul 1, 2024
1 parent 6301037 commit 0bb1539
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.21.3

require (
github.com/hashicorp/go-plugin v1.6.0
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240522203001-10ea0211efd7
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240701152910-a52e4442f39d
github.com/smartcontractkit/libocr v0.0.0-20240419185742-fd3cab206b2c
github.com/stretchr/testify v1.9.0
)
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5g
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240522203001-10ea0211efd7 h1:od+11B83s0mQwAMPP3lhtb0nYz63pIKpJEKddfFpu/M=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240522203001-10ea0211efd7/go.mod h1:cFHRblGbGn/rFYOOGsNbtLicMc1+5YdN0KoebYr93pk=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240701152910-a52e4442f39d h1:fbU9SDtBgf5dMgT1xnqdeagry9pxTCBzB4OuIykv8R0=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240701152910-a52e4442f39d/go.mod h1:L32xvCpk84Nglit64OhySPMP1tM3TTBK7Tw0qZl7Sd4=
github.com/smartcontractkit/go-plugin v0.0.0-20240208201424-b3b91517de16 h1:TFe+FvzxClblt6qRfqEhUfa4kFQx5UobuoFGO2W4mMo=
github.com/smartcontractkit/go-plugin v0.0.0-20240208201424-b3b91517de16/go.mod h1:lBS5MtSSBZk0SHc66KACcjjlU6WzEVP/8pwz68aMkCI=
github.com/smartcontractkit/grpc-proxy v0.0.0-20230731113816-f1be6620749f h1:hgJif132UCdjo8u43i7iPN1/MFnu49hv7lFGFftCHKU=
Expand Down
20 changes: 16 additions & 4 deletions median/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ func (r *reportingPluginFactoryService) HealthReport() map[string]error {
return map[string]error{r.Name(): r.Healthy()}
}

// chainReaderContract adapts a [types.ChainReader] to [median.MedianContract].
// chainReaderContract adapts a [types.ContractReader] to [median.MedianContract].
type chainReaderContract struct {
chainReader types.ChainReader
chainReader types.ContractReader
lggr logger.Logger
}

Expand All @@ -123,7 +123,13 @@ type latestRoundRequested struct {
func (c *chainReaderContract) LatestTransmissionDetails(ctx context.Context) (configDigest ocrtypes.ConfigDigest, epoch uint32, round uint8, latestAnswer *big.Int, latestTimestamp time.Time, err error) {
var resp latestTransmissionDetailsResponse

err = c.chainReader.GetLatestValue(ctx, contractName, "LatestTransmissionDetails", nil, &resp)
binding := types.BoundContract{
Address: "TODO",
Contract: contractName,
Method: "LatestTransmissionDetails",
}

err = c.chainReader.GetLatestValue(ctx, binding, nil, &resp)
if err != nil {
if !errors.Is(err, types.ErrNotFound) {
return
Expand All @@ -146,7 +152,13 @@ func (c *chainReaderContract) LatestTransmissionDetails(ctx context.Context) (co
func (c *chainReaderContract) LatestRoundRequested(ctx context.Context, lookback time.Duration) (configDigest ocrtypes.ConfigDigest, epoch uint32, round uint8, err error) {
var resp latestRoundRequested

err = c.chainReader.GetLatestValue(ctx, contractName, "LatestRoundRequested", nil, &resp)
binding := types.BoundContract{
Address: "TODO",
Contract: contractName,
Method: "LatestRoundRequested",
}

err = c.chainReader.GetLatestValue(ctx, binding, nil, &resp)
if err != nil {
if !errors.Is(err, types.ErrNotFound) {
return
Expand Down

0 comments on commit 0bb1539

Please sign in to comment.