From 626d21c0aa6f4aaf389aa9bea54820485edbc28e Mon Sep 17 00:00:00 2001 From: Madhur Shrimal Date: Mon, 1 Jul 2024 18:29:32 -0700 Subject: [PATCH] move builders to it's own package --- chainio/clients/elcontracts/builder.go | 49 ++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 chainio/clients/elcontracts/builder.go diff --git a/chainio/clients/elcontracts/builder.go b/chainio/clients/elcontracts/builder.go new file mode 100644 index 00000000..970de2dc --- /dev/null +++ b/chainio/clients/elcontracts/builder.go @@ -0,0 +1,49 @@ +package elcontracts + +import ( + "github.com/Layr-Labs/eigensdk-go/chainio/clients/eth" + "github.com/Layr-Labs/eigensdk-go/chainio/txmgr" + "github.com/Layr-Labs/eigensdk-go/logging" + "github.com/Layr-Labs/eigensdk-go/metrics" +) + +func BuildClients( + config Config, + ethHttpClient eth.Client, + txMgr txmgr.TxManager, + logger logging.Logger, + eigenMetrics *metrics.EigenMetrics, +) (*ELChainReader, *ELChainWriter, *ContractBindings, error) { + elContractBindings, err := NewBindingsFromConfig( + config, + ethHttpClient, + logger, + ) + if err != nil { + return nil, nil, nil, err + } + + elChainReader := NewELChainReader( + elContractBindings.Slasher, + elContractBindings.DelegationManager, + elContractBindings.StrategyManager, + elContractBindings.AvsDirectory, + logger, + ethHttpClient, + ) + + elChainWriter := NewELChainWriter( + elContractBindings.Slasher, + elContractBindings.DelegationManager, + elContractBindings.StrategyManager, + elContractBindings.RewardsCoordinator, + elContractBindings.StrategyManagerAddr, + elChainReader, + ethHttpClient, + logger, + eigenMetrics, + txMgr, + ) + + return elChainReader, elChainWriter, elContractBindings, nil +}