Skip to content

Commit

Permalink
update eigenpod bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasArrachea committed Dec 11, 2024
1 parent 50d0f08 commit 7d1fd72
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 73 deletions.
36 changes: 18 additions & 18 deletions chainio/clients/eigenpod/bindings.go
Original file line number Diff line number Diff line change
@@ -1,84 +1,84 @@
package eigenpod

import (
"github.com/Layr-Labs/eigensdk-go/chainio/clients/eigenpod/bindings"
"github.com/Layr-Labs/eigensdk-go/chainio/clients/eth"

ieigenpod "github.com/Layr-Labs/eigensdk-go/contracts/bindings/IEigenPod"
ieigenpodmanager "github.com/Layr-Labs/eigensdk-go/contracts/bindings/IEigenPodManager"
"github.com/ethereum/go-ethereum/common"
)

type ContractBindings struct {
Address common.Address
*bindings.IEigenPod
*ieigenpod.ContractIEigenPod
}

type ContractCallerBindings struct {
Address common.Address
*bindings.IEigenPodCaller
*ieigenpod.ContractIEigenPodCaller
}

type ManagerContractBindings struct {
Address common.Address
*bindings.IEigenPodManager
*ieigenpodmanager.ContractIEigenPodManager
}

type ManagerContractCallerBindings struct {
Address common.Address
*bindings.IEigenPodManagerCaller
*ieigenpodmanager.ContractIEigenPodManagerCaller
}

func NewContractBindings(
address common.Address,
ethClient eth.HttpBackend,
) (*ContractBindings, error) {
pod, err := bindings.NewIEigenPod(address, ethClient)
pod, err := ieigenpod.NewContractIEigenPod(address, ethClient)
if err != nil {
return nil, err
}
return &ContractBindings{
Address: address,
IEigenPod: pod,
Address: address,
ContractIEigenPod: pod,
}, nil
}

func NewContractCallerBindings(
address common.Address,
ethClient eth.HttpBackend,
) (*ContractCallerBindings, error) {
pod, err := bindings.NewIEigenPodCaller(address, ethClient)
pod, err := ieigenpod.NewContractIEigenPodCaller(address, ethClient)
if err != nil {
return nil, err
}
return &ContractCallerBindings{
Address: address,
IEigenPodCaller: pod,
Address: address,
ContractIEigenPodCaller: pod,
}, nil
}

func NewManagerContractBindings(
address common.Address,
ethClient eth.HttpBackend,
) (*ManagerContractBindings, error) {
manager, err := bindings.NewIEigenPodManager(address, ethClient)
manager, err := ieigenpodmanager.NewContractIEigenPodManager(address, ethClient)
if err != nil {
return nil, err
}
return &ManagerContractBindings{
Address: address,
IEigenPodManager: manager,
Address: address,
ContractIEigenPodManager: manager,
}, nil
}

func NewManagerContractCallerBindings(
address common.Address,
ethClient eth.HttpBackend,
) (*ManagerContractCallerBindings, error) {
manager, err := bindings.NewIEigenPodManagerCaller(address, ethClient)
manager, err := ieigenpodmanager.NewContractIEigenPodManagerCaller(address, ethClient)
if err != nil {
return nil, err
}
return &ManagerContractCallerBindings{
Address: address,
IEigenPodManagerCaller: manager,
Address: address,
ContractIEigenPodManagerCaller: manager,
}, nil
}
8 changes: 4 additions & 4 deletions chainio/clients/eigenpod/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ func BuildEigenPodClients(
}

eigenPodChainReader := newChainReader(
&eigenPodBindings.IEigenPodCaller,
&eigenPodBindings.ContractIEigenPodCaller,
client,
logger,
)

eigenPodChainWriter := newChainWriter(
eigenPodBindings.IEigenPod,
eigenPodBindings.ContractIEigenPod,
client,
logger,
txMgr,
Expand All @@ -48,13 +48,13 @@ func BuildEigenPodManagerClients(
}

eigenPodManagerChainReader := newManagerChainReader(
&eigenPodManagerBindings.IEigenPodManagerCaller,
&eigenPodManagerBindings.ContractIEigenPodManagerCaller,
client,
logger,
)

eigenPodManagerChainWriter := newManagerChainWriter(
eigenPodManagerBindings.IEigenPodManager,
eigenPodManagerBindings.ContractIEigenPodManager,
client,
logger,
txMgr,
Expand Down
27 changes: 14 additions & 13 deletions chainio/clients/eigenpod/reader.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package eigenpod

import (
"github.com/Layr-Labs/eigensdk-go/chainio/clients/eigenpod/bindings"
"github.com/Layr-Labs/eigensdk-go/chainio/clients/eth"
ieigenpod "github.com/Layr-Labs/eigensdk-go/contracts/bindings/IEigenPod"
ieigenpodmanager "github.com/Layr-Labs/eigensdk-go/contracts/bindings/IEigenPodManager"
"github.com/Layr-Labs/eigensdk-go/logging"
"github.com/Layr-Labs/eigensdk-go/utils"

Expand All @@ -15,7 +16,7 @@ import (
type ChainReader struct {
logger logging.Logger
ethClient eth.HttpBackend
*bindings.IEigenPodCaller
*ieigenpod.ContractIEigenPodCaller
}

// ManagerChainReader is a reader for the EigenPodManager contract.
Expand All @@ -24,34 +25,34 @@ type ChainReader struct {
type ManagerChainReader struct {
logger logging.Logger
ethClient eth.HttpBackend
*bindings.IEigenPodManagerCaller
*ieigenpodmanager.ContractIEigenPodManagerCaller
}

func newChainReader(
eigenPod *bindings.IEigenPodCaller,
eigenPod *ieigenpod.ContractIEigenPodCaller,
ethClient eth.HttpBackend,
logger logging.Logger,
) *ChainReader {
logger = logger.With(logging.ComponentKey, "eigenpod/reader")

return &ChainReader{
logger: logger,
ethClient: ethClient,
IEigenPodCaller: eigenPod,
logger: logger,
ethClient: ethClient,
ContractIEigenPodCaller: eigenPod,
}
}

func newManagerChainReader(
manager *bindings.IEigenPodManagerCaller,
manager *ieigenpodmanager.ContractIEigenPodManagerCaller,
ethClient eth.HttpBackend,
logger logging.Logger,
) *ManagerChainReader {
logger = logger.With(logging.ComponentKey, "eigenpodmanager/reader")

return &ManagerChainReader{
logger: logger,
ethClient: ethClient,
IEigenPodManagerCaller: manager,
logger: logger,
ethClient: ethClient,
ContractIEigenPodManagerCaller: manager,
}
}

Expand All @@ -65,7 +66,7 @@ func NewReader(
return nil, utils.WrapError("Failed to create EigenPod contract", err)
}

return newChainReader(pod.IEigenPodCaller, ethClient, logger), nil
return newChainReader(pod.ContractIEigenPodCaller, ethClient, logger), nil
}

func NewManagerReader(
Expand All @@ -78,5 +79,5 @@ func NewManagerReader(
return nil, utils.WrapError("Failed to create EigenPodManager contract", err)
}

return newManagerChainReader(manager.IEigenPodManagerCaller, ethClient, logger), nil
return newManagerChainReader(manager.ContractIEigenPodManagerCaller, ethClient, logger), nil
}
15 changes: 8 additions & 7 deletions chainio/clients/eigenpod/writer.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package eigenpod

import (
"github.com/Layr-Labs/eigensdk-go/chainio/clients/eigenpod/bindings"
"github.com/Layr-Labs/eigensdk-go/chainio/clients/eth"
"github.com/Layr-Labs/eigensdk-go/chainio/txmgr"
ieigenpod "github.com/Layr-Labs/eigensdk-go/contracts/bindings/IEigenPod"
ieigenpodmanager "github.com/Layr-Labs/eigensdk-go/contracts/bindings/IEigenPodManager"
"github.com/Layr-Labs/eigensdk-go/logging"
"github.com/Layr-Labs/eigensdk-go/utils"

Expand All @@ -13,19 +14,19 @@ import (
type ChainWriter struct {
logger logging.Logger
ethClient eth.HttpBackend
eigenPod *bindings.IEigenPod
eigenPod *ieigenpod.ContractIEigenPod
txMgr txmgr.TxManager
}

type ManagerChainWriter struct {
logger logging.Logger
ethClient eth.HttpBackend
manager *bindings.IEigenPodManager
manager *ieigenpodmanager.ContractIEigenPodManager
txMgr txmgr.TxManager
}

func newChainWriter(
eigenPod *bindings.IEigenPod,
eigenPod *ieigenpod.ContractIEigenPod,
ethClient eth.HttpBackend,
logger logging.Logger,
txMgr txmgr.TxManager,
Expand All @@ -41,7 +42,7 @@ func newChainWriter(
}

func newManagerChainWriter(
manager *bindings.IEigenPodManager,
manager *ieigenpodmanager.ContractIEigenPodManager,
ethClient eth.HttpBackend,
logger logging.Logger,
txMgr txmgr.TxManager,
Expand All @@ -62,7 +63,7 @@ func NewWriter(
txMgr txmgr.TxManager,
logger logging.Logger,
) (*ChainWriter, error) {
pod, err := bindings.NewIEigenPod(eigenPodAddress, ethClient)
pod, err := ieigenpod.NewContractIEigenPod(eigenPodAddress, ethClient)
if err != nil {
return nil, utils.WrapError("Failed to create EigenPod contract", err)
}
Expand All @@ -76,7 +77,7 @@ func NewManagerWriter(
txMgr txmgr.TxManager,
logger logging.Logger,
) (*ManagerChainWriter, error) {
manager, err := bindings.NewIEigenPodManager(eigenPodManagerAddress, ethClient)
manager, err := ieigenpodmanager.NewContractIEigenPodManager(eigenPodManagerAddress, ethClient)
if err != nil {
return nil, utils.WrapError("Failed to create EigenPodManager contract", err)
}
Expand Down
31 changes: 0 additions & 31 deletions chainio/clients/elcontracts/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,34 +356,3 @@ func (w *ChainWriter) ProcessClaim(

return receipt, nil
}

func (w *ChainWriter) ProcessClaims(
ctx context.Context,
claims []rewardscoordinator.IRewardsCoordinatorRewardsMerkleClaim,
earnerAddress gethcommon.Address,
waitForReceipt bool,
) (*gethtypes.Receipt, error) {
if w.rewardsCoordinator == nil {
return nil, errors.New("RewardsCoordinator contract not provided")
}

if len(claims) == 0 {
return nil, errors.New("claims is empty, at least one claim must be provided")
}

noSendTxOpts, err := w.txMgr.GetNoSendTxOpts()
if err != nil {
return nil, utils.WrapError("failed to get no send tx opts", err)
}

tx, err := w.rewardsCoordinator.ProcessClaims(noSendTxOpts, claims, earnerAddress)
if err != nil {
return nil, utils.WrapError("failed to create ProcessClaims tx", err)
}
receipt, err := w.txMgr.Send(ctx, tx, waitForReceipt)
if err != nil {
return nil, utils.WrapError("failed to send tx", err)
}

return receipt, nil
}

0 comments on commit 7d1fd72

Please sign in to comment.