Skip to content

Commit

Permalink
Rearrange Relayer ChainService
Browse files Browse the repository at this point in the history
  • Loading branch information
ilija42 committed Nov 12, 2024
1 parent 5d958d7 commit 51ba2fc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 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

// NewChainWriter returns a new ChainWriter.
// The format of config depends on the implementation.
NewChainWriter(ctx context.Context, chainWriterConfig []byte) (types.ChainWriter, 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
3 changes: 3 additions & 0 deletions pkg/types/chain_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ const (
ErrSettingTransactionGasLimitNotSupported = InvalidArgumentError("setting transaction gas limit is not supported")
)

type ContractWriter = ChainWriter

// Deprecated: Use ContractWriter instead.
type ChainWriter interface {
services.Service

Expand Down
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 IChainWriter interface {
// NewChainWriter returns a new ChainWriter.
// The format of config depends on the implementation.
NewChainWriter(ctx context.Context, config []byte) (ChainWriter, 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
IChainWriter
}

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

// NewChainWriter returns a new ChainWriter.
// The format of config depends on the implementation.
NewChainWriter(ctx context.Context, config []byte) (ChainWriter, 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 51ba2fc

Please sign in to comment.