Skip to content

Commit

Permalink
Rename ChainWriter Chain Component to ContractWriter
Browse files Browse the repository at this point in the history
  • Loading branch information
ilija42 committed Dec 5, 2024
1 parent 29871ce commit 18cfff0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 31 deletions.
8 changes: 0 additions & 8 deletions pkg/loop/internal/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,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)
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
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

0 comments on commit 18cfff0

Please sign in to comment.