Skip to content

Commit

Permalink
fix mocks and subscribers
Browse files Browse the repository at this point in the history
  • Loading branch information
shrimalmadhur committed Jul 2, 2024
1 parent 5616c1d commit 3527ffd
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 14 deletions.
12 changes: 8 additions & 4 deletions chainio/clients/avsregistry/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
func BuildClients(
config Config,
client eth.Client,
wsClient eth.Client,
txMgr txmgr.TxManager,
logger logging.Logger,
) (*ChainReader, *ChainSubscriber, *ChainWriter, *ContractBindings, error) {
Expand All @@ -33,13 +34,16 @@ func BuildClients(
client,
)

chainSubscriber := NewChainSubscriber(
avsBindings.RegistryCoordinator,
avsBindings.BlsApkRegistry,
chainSubscriber, err := NewSubscriberFromConfig(
config,
wsClient,
logger,
)
if err != nil {
return nil, nil, nil, nil, err
}

// This is ugly but we need elReader to be able to create the AVS writer
// This is ugly, but we need elReader to be able to create the AVS writer
elChainReader, err := elcontracts.NewReaderFromConfig(
elcontracts.Config{
DelegationManagerAddress: avsBindings.DelegationManagerAddr,
Expand Down
9 changes: 7 additions & 2 deletions chainio/clients/avsregistry/subscriber.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ type ChainSubscriber struct {
// forces EthSubscriber to implement the chainio.Subscriber interface
var _ Subscriber = (*ChainSubscriber)(nil)

// NewChainSubscriber creates a new instance of ChainSubscriber
// The bindings must be created using websocket ETH Client
func NewChainSubscriber(
regCoord regcoord.ContractRegistryCoordinatorFilters,
blsApkRegistry blsapkreg.ContractBLSApkRegistryFilters,
Expand All @@ -40,6 +42,8 @@ func NewChainSubscriber(
}
}

// BuildAvsRegistryChainSubscriber creates a new instance of ChainSubscriber
// Deprecated: Use NewSubscriberFromConfig instead
func BuildAvsRegistryChainSubscriber(
regCoordAddr common.Address,
ethWsClient eth.Client,
Expand All @@ -60,12 +64,13 @@ func BuildAvsRegistryChainSubscriber(
return NewChainSubscriber(regCoord, blsApkReg, logger), nil
}

// NewSubscriberFromConfig creates a new instance of ChainSubscriber
func NewSubscriberFromConfig(
cfg Config,
ethClient eth.Client,
wsClient eth.Client,
logger logging.Logger,
) (*ChainSubscriber, error) {
bindings, err := NewBindingsFromConfig(cfg, ethClient, logger)
bindings, err := NewBindingsFromConfig(cfg, wsClient, logger)
if err != nil {
return nil, err
}
Expand Down
1 change: 1 addition & 0 deletions chainio/clients/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ func BuildAll(
OperatorStateRetrieverAddress: gethcommon.HexToAddress(config.OperatorStateRetrieverAddr),
},
ethHttpClient,
ethWsClient,
txMgr,
logger,
)
Expand Down
4 changes: 2 additions & 2 deletions chainio/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package chainio
//go:generate mockgen -destination=./mocks/avsRegistryContractsReader.go -package=mocks -mock_names=Reader=MockAVSReader github.com/Layr-Labs/eigensdk-go/chainio/clients/avsregistry Reader
//go:generate mockgen -destination=./mocks/avsRegistryContractsSubscriber.go -package=mocks -mock_names=Subscriber=MockAVSSubscriber github.com/Layr-Labs/eigensdk-go/chainio/clients/avsregistry Subscriber
//go:generate mockgen -destination=./mocks/avsRegistryContractsWriter.go -package=mocks -mock_names=Writer=MockAVSWriter github.com/Layr-Labs/eigensdk-go/chainio/clients/avsregistry Writer
//go:generate mockgen -destination=./mocks/elContractsReader.go -package=mocks github.com/Layr-Labs/eigensdk-go/chainio/clients/elcontracts ELReader
//go:generate mockgen -destination=./mocks/elContractsWriter.go -package=mocks github.com/Layr-Labs/eigensdk-go/chainio/clients/elcontracts ELWriter
//go:generate mockgen -destination=./mocks/elContractsReader.go -package=mocks -mock_names=Reader=MockELReader github.com/Layr-Labs/eigensdk-go/chainio/clients/elcontracts Reader
//go:generate mockgen -destination=./mocks/elContractsWriter.go -package=mocks -mock_names=Writer=MockELWriter github.com/Layr-Labs/eigensdk-go/chainio/clients/elcontracts Writer
//go:generate mockgen -destination=./mocks/ethclient.go -package=mocks -mock_names=Client=MockEthClient github.com/Layr-Labs/eigensdk-go/chainio/clients/eth Client
//go:generate mockgen -destination=./mocks/eventSubscription.go -package=mocks github.com/ethereum/go-ethereum/event Subscription
//go:generate mockgen -destination=./clients/mocks/fireblocks.go -package=mocks -mock_names=Client=MockFireblocksClient github.com/Layr-Labs/eigensdk-go/chainio/clients/fireblocks Client
Expand Down
6 changes: 3 additions & 3 deletions chainio/mocks/elContractsReader.go

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

6 changes: 3 additions & 3 deletions chainio/mocks/elContractsWriter.go

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

0 comments on commit 3527ffd

Please sign in to comment.