From 5e74b5462c8f067d6309f3e4c57747fb570247d4 Mon Sep 17 00:00:00 2001 From: Awbrey Hughlett Date: Mon, 5 Aug 2024 10:49:02 -0500 Subject: [PATCH] pass contract address through --- median/plugin.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/median/plugin.go b/median/plugin.go index f81d418..c6954b9 100644 --- a/median/plugin.go +++ b/median/plugin.go @@ -27,7 +27,7 @@ func NewPlugin(lggr logger.Logger) *Plugin { return &Plugin{Plugin: loop.Plugin{Logger: lggr}, stop: make(services.StopChan)} } -func (p *Plugin) NewMedianFactory(ctx context.Context, provider types.MedianProvider, dataSource, juelsPerFeeCoin, gasPriceSubunits median.DataSource, errorLog loop.ErrorLog) (loop.ReportingPluginFactory, error) { +func (p *Plugin) NewMedianFactory(ctx context.Context, provider types.MedianProvider, contractAddr string, dataSource, juelsPerFeeCoin, gasPriceSubunits median.DataSource, errorLog loop.ErrorLog) (loop.ReportingPluginFactory, error) { var ctxVals loop.ContextValues ctxVals.SetValues(ctx) lggr := logger.With(p.Logger, ctxVals.Args()...) @@ -56,7 +56,13 @@ func (p *Plugin) NewMedianFactory(ctx context.Context, provider types.MedianProv } if cr := provider.ChainReader(); cr != nil { - factory.ContractTransmitter = &contractReaderContract{contractReader: cr, lggr: lggr} + if err := provider.ChainReader().Bind(ctx, []types.BoundContract{ + {Address: contractAddr, Name: contractAddr}, + }); err != nil { + return nil, err + } + + factory.ContractTransmitter = &contractReaderContract{contractAddr: contractAddr, contractReader: cr, lggr: lggr} } else { factory.ContractTransmitter = provider.MedianContract() } @@ -103,6 +109,7 @@ func (r *reportingPluginFactoryService) HealthReport() map[string]error { // contractReaderContract adapts a [types.ContractReader] to [median.MedianContract]. type contractReaderContract struct { + contractAddr string contractReader types.ContractReader lggr logger.Logger } @@ -125,7 +132,7 @@ func (c *contractReaderContract) LatestTransmissionDetails(ctx context.Context) var resp latestTransmissionDetailsResponse binding := types.BoundContract{ - Address: "TODO", + Address: c.contractAddr, Name: contractName, } @@ -153,7 +160,7 @@ func (c *contractReaderContract) LatestRoundRequested(ctx context.Context, lookb var resp latestRoundRequested binding := types.BoundContract{ - Address: "TODO", + Address: c.contractAddr, Name: contractName, }