Skip to content

Commit

Permalink
pass contract address through
Browse files Browse the repository at this point in the history
  • Loading branch information
EasterTheBunny committed Aug 5, 2024
1 parent ac9f986 commit 5e74b54
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions median/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()...)
Expand Down Expand Up @@ -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()
}
Expand Down Expand Up @@ -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
}
Expand All @@ -125,7 +132,7 @@ func (c *contractReaderContract) LatestTransmissionDetails(ctx context.Context)
var resp latestTransmissionDetailsResponse

binding := types.BoundContract{
Address: "TODO",
Address: c.contractAddr,
Name: contractName,
}

Expand Down Expand Up @@ -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,
}

Expand Down

0 comments on commit 5e74b54

Please sign in to comment.