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

New factory constructors with stable function signature. #538

Open
wants to merge 3 commits into
base: main
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
35 changes: 35 additions & 0 deletions commit/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,43 @@ type PluginFactory struct {
rmnCrypto cciptypes.RMNCrypto
}

type CommitPluginFactoryParams struct {
Lggr logger.Logger
DonID plugintypes.DonID
OcrConfig reader.OCR3ConfigWithMeta
CommitCodec cciptypes.CommitPluginCodec
MsgHasher cciptypes.MessageHasher
ExtraDataCodec cciptypes.ExtraDataCodec
HomeChainReader reader.HomeChain
HomeChainSelector cciptypes.ChainSelector
ContractReaders map[cciptypes.ChainSelector]types.ContractReader
ContractWriters map[cciptypes.ChainSelector]types.ContractWriter
RmnPeerClient rmn.PeerClient
RmnCrypto cciptypes.RMNCrypto
}

// NewCommitPluginFactory creates a new PluginFactory instance. For commit plugin, oracle instances are not managed by
// the factory. It is safe to assume that a factory instance will create exactly one plugin instance.
func NewCommitPluginFactory(params CommitPluginFactoryParams) *PluginFactory {
return &PluginFactory{
baseLggr: params.Lggr,
donID: params.DonID,
ocrConfig: params.OcrConfig,
commitCodec: params.CommitCodec,
msgHasher: params.MsgHasher,
extraDataCodec: params.ExtraDataCodec,
homeChainReader: params.HomeChainReader,
homeChainSelector: params.HomeChainSelector,
contractReaders: params.ContractReaders,
chainWriters: params.ContractWriters,
rmnPeerClient: params.RmnPeerClient,
rmnCrypto: params.RmnCrypto,
}
}

// NewPluginFactory creates a new PluginFactory instance. For commit plugin, oracle instances are not managed by the
// factory. It is safe to assume that a factory instance will create exactly one plugin instance.
// deprecated: use NewCommitPluginFactory instead
func NewPluginFactory(
lggr logger.Logger,
donID plugintypes.DonID,
Expand Down
33 changes: 33 additions & 0 deletions execute/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,39 @@ type PluginFactory struct {
chainWriters map[cciptypes.ChainSelector]types.ContractWriter
}

type PluginFactoryParams struct {
Lggr logger.Logger
DonID plugintypes.DonID
OcrConfig reader.OCR3ConfigWithMeta
ExecCodec cciptypes.ExecutePluginCodec
MsgHasher cciptypes.MessageHasher
ExtraDataCodec cciptypes.ExtraDataCodec
HomeChainReader reader.HomeChain
TokenDataEncoder cciptypes.TokenDataEncoder
EstimateProvider cciptypes.EstimateProvider
ContractReaders map[cciptypes.ChainSelector]types.ContractReader
ContractWriters map[cciptypes.ChainSelector]types.ContractWriter
}

// NewExecutePluginFactory creates a new PluginFactory instance. For execute plugin, oracle instances are not managed by
// the factory. It is safe to assume that a factory instance will create exactly one plugin instance.
func NewExecutePluginFactory(params PluginFactoryParams) *PluginFactory {
return &PluginFactory{
baseLggr: params.Lggr,
donID: params.DonID,
ocrConfig: params.OcrConfig,
execCodec: params.ExecCodec,
msgHasher: params.MsgHasher,
extraDataCodec: params.ExtraDataCodec,
homeChainReader: params.HomeChainReader,
estimateProvider: params.EstimateProvider,
tokenDataEncoder: params.TokenDataEncoder,
contractReaders: params.ContractReaders,
chainWriters: params.ContractWriters,
}
}

// deprectated: use NewExececutePluginFactory
func NewPluginFactory(
lggr logger.Logger,
donID plugintypes.DonID,
Expand Down
Loading