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

refactor: remove interfaces of el reader writer #301

Merged
merged 5 commits into from
Jul 18, 2024
Merged
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
14 changes: 12 additions & 2 deletions chainio/clients/avsregistry/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,23 @@ type Writer interface {
) (*gethtypes.Receipt, error)
}

type ELReader interface {
CalculateOperatorAVSRegistrationDigestHash(
opts *bind.CallOpts,
operatorAddr gethcommon.Address,
serviceManagerAddr gethcommon.Address,
operatorToAvsRegistrationSigSalt [32]byte,
operatorToAvsRegistrationSigExpiry *big.Int,
) ([32]byte, error)
}

type ChainWriter struct {
serviceManagerAddr gethcommon.Address
registryCoordinator *regcoord.ContractRegistryCoordinator
operatorStateRetriever *opstateretriever.ContractOperatorStateRetriever
stakeRegistry *stakeregistry.ContractStakeRegistry
blsApkRegistry *blsapkregistry.ContractBLSApkRegistry
elReader elcontracts.Reader
elReader ELReader
logger logging.Logger
ethClient eth.Client
txMgr txmgr.TxManager
Expand All @@ -108,7 +118,7 @@ func NewChainWriter(
operatorStateRetriever *opstateretriever.ContractOperatorStateRetriever,
stakeRegistry *stakeregistry.ContractStakeRegistry,
blsApkRegistry *blsapkregistry.ContractBLSApkRegistry,
elReader elcontracts.Reader,
elReader ELReader,
logger logging.Logger,
ethClient eth.Client,
txMgr txmgr.TxManager,
Expand Down
47 changes: 0 additions & 47 deletions chainio/clients/elcontracts/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,50 +22,6 @@ import (
"github.com/Layr-Labs/eigensdk-go/utils"
)

type Reader interface {
IsOperatorRegistered(opts *bind.CallOpts, operator types.Operator) (bool, error)

GetOperatorDetails(opts *bind.CallOpts, operator types.Operator) (types.Operator, error)

// GetStrategyAndUnderlyingToken returns the strategy contract and the underlying token address
// use GetStrategyAndUnderlyingERC20Token if the contract address confirms with ERC20 standard
GetStrategyAndUnderlyingToken(
opts *bind.CallOpts, strategyAddr gethcommon.Address,
) (*strategy.ContractIStrategy, gethcommon.Address, error)

// GetStrategyAndUnderlyingERC20Token returns the strategy contract and the underlying ERC20 token address
GetStrategyAndUnderlyingERC20Token(
opts *bind.CallOpts, strategyAddr gethcommon.Address,
) (*strategy.ContractIStrategy, erc20.ContractIERC20Methods, gethcommon.Address, error)

ServiceManagerCanSlashOperatorUntilBlock(
opts *bind.CallOpts,
operatorAddr gethcommon.Address,
serviceManagerAddr gethcommon.Address,
) (uint32, error)

OperatorIsFrozen(opts *bind.CallOpts, operatorAddr gethcommon.Address) (bool, error)

GetOperatorSharesInStrategy(
opts *bind.CallOpts,
operatorAddr gethcommon.Address,
strategyAddr gethcommon.Address,
) (*big.Int, error)

CalculateDelegationApprovalDigestHash(
opts *bind.CallOpts, staker gethcommon.Address, operator gethcommon.Address,
delegationApprover gethcommon.Address, approverSalt [32]byte, expiry *big.Int,
) ([32]byte, error)

CalculateOperatorAVSRegistrationDigestHash(
opts *bind.CallOpts, operator gethcommon.Address, avs gethcommon.Address, salt [32]byte, expiry *big.Int,
) ([32]byte, error)

GetDistributionRootsLength(opts *bind.CallOpts) (*big.Int, error)

CurrRewardsCalculationEndTimestamp(opts *bind.CallOpts) (uint32, error)
}

type Config struct {
DelegationManagerAddress common.Address
AvsDirectoryAddress common.Address
Expand All @@ -82,9 +38,6 @@ type ChainReader struct {
ethClient eth.Client
}

// forces EthReader to implement the chainio.Reader interface
var _ Reader = (*ChainReader)(nil)

func NewChainReader(
slasher slasher.ContractISlasherCalls,
delegationManager *delegationmanager.ContractDelegationManager,
Expand Down
36 changes: 6 additions & 30 deletions chainio/clients/elcontracts/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,42 +15,20 @@ import (
"github.com/Layr-Labs/eigensdk-go/chainio/clients/eth"
"github.com/Layr-Labs/eigensdk-go/chainio/txmgr"
delegationmanager "github.com/Layr-Labs/eigensdk-go/contracts/bindings/DelegationManager"
erc20 "github.com/Layr-Labs/eigensdk-go/contracts/bindings/IERC20"
rewardscoordinator "github.com/Layr-Labs/eigensdk-go/contracts/bindings/IRewardsCoordinator"
slasher "github.com/Layr-Labs/eigensdk-go/contracts/bindings/ISlasher"
strategy "github.com/Layr-Labs/eigensdk-go/contracts/bindings/IStrategy"
strategymanager "github.com/Layr-Labs/eigensdk-go/contracts/bindings/StrategyManager"
"github.com/Layr-Labs/eigensdk-go/logging"
"github.com/Layr-Labs/eigensdk-go/metrics"
"github.com/Layr-Labs/eigensdk-go/types"
)

type Writer interface {
// RegisterAsOperator registers an operator onchain.
RegisterAsOperator(ctx context.Context, operator types.Operator) (*gethtypes.Receipt, error)

// UpdateOperatorDetails updates the operator details onchain.
// This doesn't update the metadata URI. Use UpdateMetadataURI for that.
UpdateOperatorDetails(ctx context.Context, operator types.Operator) (*gethtypes.Receipt, error)

// UpdateMetadataURI updates the operator metadata URI onchain
UpdateMetadataURI(ctx context.Context, uri string) (*gethtypes.Receipt, error)

// DepositERC20IntoStrategy deposits ERC20 tokens into a strategy contract.
DepositERC20IntoStrategy(
ctx context.Context,
strategyAddr gethcommon.Address,
amount *big.Int,
) (*gethtypes.Receipt, error)

SetClaimerFor(
ctx context.Context,
claimer gethcommon.Address,
) (*gethtypes.Receipt, error)

ProcessClaim(
ctx context.Context,
claim rewardscoordinator.IRewardsCoordinatorRewardsMerkleClaim,
earnerAddress gethcommon.Address,
) (*gethtypes.Receipt, error)
type Reader interface {
GetStrategyAndUnderlyingERC20Token(
opts *bind.CallOpts, strategyAddr gethcommon.Address,
) (*strategy.ContractIStrategy, erc20.ContractIERC20Methods, gethcommon.Address, error)
}

type ChainWriter struct {
Expand All @@ -65,8 +43,6 @@ type ChainWriter struct {
txMgr txmgr.TxManager
}

var _ Writer = (*ChainWriter)(nil)

func NewChainWriter(
slasher *slasher.ContractISlasher,
delegationManager *delegationmanager.ContractDelegationManager,
Expand Down
2 changes: 0 additions & 2 deletions chainio/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ 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 -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
213 changes: 0 additions & 213 deletions chainio/mocks/elContractsReader.go

This file was deleted.

Loading