diff --git a/chainio/clients/elcontracts/bindings.go b/chainio/clients/elcontracts/bindings.go index 8d67e319..86dab45a 100644 --- a/chainio/clients/elcontracts/bindings.go +++ b/chainio/clients/elcontracts/bindings.go @@ -1,11 +1,8 @@ -// bindings.go contains functions that create contract bindings for the Eigenlayer and AVS contracts. +// Package elcontracts bindings.go contains functions that create contract bindings for the Eigenlayer Core contracts // These functions are meant to be used by constructors of the chainio package. package elcontracts import ( - "github.com/Layr-Labs/eigensdk-go/logging" - "github.com/Layr-Labs/eigensdk-go/types" - "github.com/Layr-Labs/eigensdk-go/utils" "github.com/ethereum/go-ethereum/accounts/abi/bind" gethcommon "github.com/ethereum/go-ethereum/common" @@ -14,9 +11,13 @@ import ( delegationmanager "github.com/Layr-Labs/eigensdk-go/contracts/bindings/DelegationManager" slasher "github.com/Layr-Labs/eigensdk-go/contracts/bindings/ISlasher" strategymanager "github.com/Layr-Labs/eigensdk-go/contracts/bindings/StrategyManager" + "github.com/Layr-Labs/eigensdk-go/logging" + "github.com/Layr-Labs/eigensdk-go/utils" ) -// ContractBindings Unclear to me why geth bindings don't store and expose the contract address... +// ContractBindings contains the contract bindings for the EigenLayer Core contracts +// +// Unclear why geth bindings don't store and expose the contract address, // so we also store them here in case the different constructors that use this struct need them type ContractBindings struct { SlasherAddr gethcommon.Address @@ -30,7 +31,7 @@ type ContractBindings struct { } func NewBindingsFromConfig( - cfg types.ElChainReaderConfig, + cfg ElChainReaderConfig, client eth.Client, logger logging.Logger, ) (*ContractBindings, error) { diff --git a/chainio/clients/elcontracts/reader.go b/chainio/clients/elcontracts/reader.go index aa5a8ee0..a534a48f 100644 --- a/chainio/clients/elcontracts/reader.go +++ b/chainio/clients/elcontracts/reader.go @@ -61,6 +61,11 @@ type ELReader interface { ) ([32]byte, error) } +type ElChainReaderConfig struct { + DelegationManagerAddress common.Address + AvsDirectoryAddress common.Address +} + type ELChainReader struct { logger logging.Logger slasher slasher.ContractISlasherCalls @@ -73,7 +78,6 @@ type ELChainReader struct { // forces EthReader to implement the chainio.Reader interface var _ ELReader = (*ELChainReader)(nil) -// TODO(madhur): make this private. All clients should use build functions func NewELChainReader( slasher slasher.ContractISlasherCalls, delegationManager delegationmanager.ContractDelegationManagerCalls, @@ -82,6 +86,8 @@ func NewELChainReader( logger logging.Logger, ethClient eth.Client, ) *ELChainReader { + logger = logger.With("module", "elcontracts/reader") + return &ELChainReader{ slasher: slasher, delegationManager: delegationManager, @@ -119,8 +125,8 @@ func BuildELChainReader( ), nil } -func BuildFromConfig( - cfg types.ElChainReaderConfig, +func NewReaderFromConfig( + cfg ElChainReaderConfig, ethClient eth.Client, logger logging.Logger, ) (*ELChainReader, error) { diff --git a/types/config.go b/types/config.go index a3679d51..ab1254f4 100644 --- a/types/config.go +++ b/types/config.go @@ -1,8 +1 @@ package types - -import "github.com/ethereum/go-ethereum/common" - -type ElChainReaderConfig struct { - DelegationManagerAddress common.Address - AvsDirectoryAddress common.Address -}