-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7c76ea7
commit 5a62887
Showing
19 changed files
with
4,873 additions
and
5,289 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package eigenpod | ||
|
||
import ( | ||
"github.com/Layr-Labs/eigensdk-go/chainio/clients/eth" | ||
"github.com/Layr-Labs/eigensdk-go/logging" | ||
"github.com/Layr-Labs/eigensdk-go/utils" | ||
"github.com/ethereum/go-ethereum/common" | ||
|
||
eigenpod "github.com/Layr-Labs/eigensdk-go/contracts/bindings/IEigenPod" | ||
eigenpodmanager "github.com/Layr-Labs/eigensdk-go/contracts/bindings/IEigenPodManager" | ||
) | ||
|
||
// ContractBindings contains the addresses and bindings for the EigenPod contracts | ||
type ContractBindings struct { | ||
EigenPodAddr common.Address | ||
EigenPodManagerAddr common.Address | ||
EigenPod *eigenpod.ContractIEigenPod | ||
EigenPodManager *eigenpodmanager.ContractIEigenPodManager | ||
} | ||
|
||
// NewBindingsFromConfig creates a new ContractBindings struct from the provided config | ||
func NewBindingsFromConfig( | ||
cfg Config, | ||
client eth.HttpBackend, | ||
logger logging.Logger, | ||
) (*ContractBindings, error) { | ||
var ( | ||
err error | ||
|
||
eigenPod *eigenpod.ContractIEigenPod | ||
eigenPodManager *eigenpodmanager.ContractIEigenPodManager | ||
) | ||
|
||
if utils.IsZeroAddress(cfg.EigenPodAddress) { | ||
logger.Debug("EigenPod address not provided, the calls to the contract will not work") | ||
} else { | ||
eigenPod, err = eigenpod.NewContractIEigenPod(cfg.EigenPodAddress, client) | ||
if err != nil { | ||
return nil, utils.WrapError("Failed to create EigenPod contract", err) | ||
} | ||
} | ||
|
||
if utils.IsZeroAddress(cfg.EigenPodManagerAddress) { | ||
logger.Debug("EigenPodManager address not provided, the calls to the contract will not work") | ||
} else { | ||
eigenPodManager, err = eigenpodmanager.NewContractIEigenPodManager(cfg.EigenPodManagerAddress, client) | ||
if err != nil { | ||
return nil, utils.WrapError("Failed to create EigenPodManager contract", err) | ||
} | ||
} | ||
|
||
return &ContractBindings{ | ||
EigenPodAddr: cfg.EigenPodAddress, | ||
EigenPodManagerAddr: cfg.EigenPodManagerAddress, | ||
EigenPod: eigenPod, | ||
EigenPodManager: eigenPodManager, | ||
}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package eigenpod | ||
|
||
import ( | ||
"github.com/Layr-Labs/eigensdk-go/chainio/clients/eth" | ||
eigenpod "github.com/Layr-Labs/eigensdk-go/contracts/bindings/IEigenPod" | ||
eigenpodmanager "github.com/Layr-Labs/eigensdk-go/contracts/bindings/IEigenPodManager" | ||
"github.com/Layr-Labs/eigensdk-go/logging" | ||
"github.com/ethereum/go-ethereum/common" | ||
) | ||
|
||
type Config struct { | ||
EigenPodAddress common.Address | ||
EigenPodManagerAddress common.Address | ||
} | ||
|
||
type ChainReader struct { | ||
logger logging.Logger | ||
ethClient eth.HttpBackend | ||
|
||
eigenpod.ContractIEigenPodCaller | ||
eigenpodmanager.ContractIEigenPodManagerCaller | ||
} | ||
|
||
func NewChainReader( | ||
cfg Config, | ||
ethClient eth.HttpBackend, | ||
logger logging.Logger, | ||
) (*ChainReader, error) { | ||
logger = logger.With(logging.ComponentKey, "eigenpod/reader") | ||
|
||
bindings, err := NewBindingsFromConfig(cfg, ethClient, logger) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &ChainReader{ | ||
logger: logger, | ||
ethClient: ethClient, | ||
ContractIEigenPodCaller: bindings.EigenPod.ContractIEigenPodCaller, | ||
ContractIEigenPodManagerCaller: bindings.EigenPodManager.ContractIEigenPodManagerCaller, | ||
}, nil | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.