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

Rearrange Relayer Chain interactions interfaces #903

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
8 changes: 0 additions & 8 deletions pkg/loop/internal/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,6 @@ type OCR3CapabilityProvider interface {
// Relayer is like types.Relayer, but with a dynamic NewPluginProvider method.
type Relayer interface {
types.ChainService

// NewContractWriter returns a new ContractWriter.
// The format of config depends on the implementation.
NewContractWriter(ctx context.Context, contractWriterConfig []byte) (types.ContractWriter, error)

// NewContractReader returns a new ContractReader.
// The format of contractReaderConfig depends on the implementation.
NewContractReader(ctx context.Context, contractReaderConfig []byte) (types.ContractReader, error)
NewConfigProvider(context.Context, types.RelayArgs) (types.ConfigProvider, error)
ilija42 marked this conversation as resolved.
Show resolved Hide resolved
pablolagreca marked this conversation as resolved.
Show resolved Hide resolved
NewPluginProvider(context.Context, types.RelayArgs, types.PluginArgs) (types.PluginProvider, error)
NewLLOProvider(context.Context, types.RelayArgs, types.PluginArgs) (types.LLOProvider, error)
Expand Down
20 changes: 10 additions & 10 deletions pkg/loop/mocks/relayer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 18 additions & 13 deletions pkg/types/relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,33 +78,38 @@ type NodeStatus struct {
State string
}

// ChainService is a sub-interface that encapsulates the explicit interactions with a chain, rather than through a provider.
type ChainService interface {
Service

type ChainReader interface {
// NewContractReader returns a new ContractReader.
// The format of contractReaderConfig depends on the implementation.
NewContractReader(ctx context.Context, contractReaderConfig []byte) (ContractReader, error)
// LatestHead returns the latest head for the underlying chain.
LatestHead(ctx context.Context) (Head, error)
// GetChainStatus returns the ChainStatus for this Relayer.
GetChainStatus(ctx context.Context) (ChainStatus, error)
// ListNodeStatuses returns the status of RPC nodes.
ListNodeStatuses(ctx context.Context, pageSize int32, pageToken string) (stats []NodeStatus, nextPageToken string, total int, err error)
}

type ChainWriter interface {
// NewContractWriter returns a new ContractWriter.
// The format of config depends on the implementation.
NewContractWriter(ctx context.Context, config []byte) (ContractWriter, error)
// Transact submits a transaction to transfer tokens.
// If balanceCheck is true, the balance will be checked before submitting.
Transact(ctx context.Context, from, to string, amount *big.Int, balanceCheck bool) error
}

// ChainService encapsulates ChainReader and IChainWriter sub-interfaces that encapsulate explicit read/write interactions with a chain and smart contract read/write components ContractReader and ContractWriter.
type ChainService interface {
Service

ChainReader
ilija42 marked this conversation as resolved.
Show resolved Hide resolved
ChainWriter
}

// Relayer extends ChainService with providers for each product.
type Relayer interface {
ChainService

// NewContractWriter returns a new ContractWriter.
// The format of config depends on the implementation.
NewContractWriter(ctx context.Context, config []byte) (ContractWriter, error)

// NewContractReader returns a new ContractReader.
// The format of contractReaderConfig depends on the implementation.
NewContractReader(ctx context.Context, contractReaderConfig []byte) (ContractReader, error)

NewConfigProvider(ctx context.Context, rargs RelayArgs) (ConfigProvider, error)

NewMedianProvider(ctx context.Context, rargs RelayArgs, pargs PluginArgs) (MedianProvider, error)
Expand Down
Loading