Skip to content

Commit

Permalink
feat: eigenpod bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
shrimalmadhur committed Jul 26, 2024
1 parent 7c76ea7 commit 5a62887
Show file tree
Hide file tree
Showing 19 changed files with 4,873 additions and 5,289 deletions.
58 changes: 58 additions & 0 deletions chainio/clients/eigenpod/bindings.go
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
}
42 changes: 42 additions & 0 deletions chainio/clients/eigenpod/reader.go
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
}
2 changes: 1 addition & 1 deletion contracts/bindings/AVSDirectory/binding.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contracts/bindings/BLSApkRegistry/binding.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contracts/bindings/ContractsRegistry/binding.go

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

2 changes: 1 addition & 1 deletion contracts/bindings/DelegationManager/binding.go

Large diffs are not rendered by default.

Loading

0 comments on commit 5a62887

Please sign in to comment.