Skip to content

Commit

Permalink
feat: eigenpod write methods
Browse files Browse the repository at this point in the history
  • Loading branch information
shrimalmadhur committed Aug 5, 2024
1 parent f2cf5d5 commit 6201b30
Showing 1 changed file with 53 additions and 2 deletions.
55 changes: 53 additions & 2 deletions chainio/clients/eigenpod/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package eigenpod

import (
"context"
"errors"
"math/big"

"github.com/Layr-Labs/eigensdk-go/chainio/clients/eigenpod/bindings"
Expand Down Expand Up @@ -110,13 +109,65 @@ func (w *ChainWriter) VerifyWithdrawalCredentials(
validatorFieldsProofs,
validatorFields,
)
if err != nil {
return nil, utils.WrapError("failed to create tx", err)
}

receipt, err := w.txMgr.Send(ctx, tx)
if err != nil {
return nil, utils.WrapError("failed to send tx", err)
}

return receipt, nil
}

func (w *ChainWriter) VerifyCheckpointProofs(
ctx context.Context,
balanceContainerProof bindings.BeaconChainProofsBalanceContainerProof,
balanceProof []bindings.BeaconChainProofsBalanceProof,
) (*types.Receipt, error) {
noSendTxOpts, err := w.txMgr.GetNoSendTxOpts()
if err != nil {
return nil, err
}

tx, err := w.eigenPod.VerifyCheckpointProofs(
noSendTxOpts,
balanceContainerProof,
balanceProof,
)
if err != nil {
return nil, utils.WrapError("failed to create tx", err)
}

receipt, err := w.txMgr.Send(ctx, tx)
if err != nil {
return nil, utils.WrapError("failed to send tx", err)
}

return receipt, nil
}

func (w *ChainWriter) StartCheckpoint(
ctx context.Context,
revertIfNoBalance bool,
) (*types.Receipt, error) {
noSendTxOpts, err := w.txMgr.GetNoSendTxOpts()
if err != nil {
return nil, err
}

tx, err := w.eigenPod.StartCheckpoint(
noSendTxOpts,
revertIfNoBalance,
)
if err != nil {
return nil, utils.WrapError("failed to create tx", err)
}

receipt, err := w.txMgr.Send(ctx, tx)
if err != nil {
return nil, errors.New("failed to send tx with err: " + err.Error())
return nil, utils.WrapError("failed to send tx", err)
}

return receipt, nil
Expand Down

0 comments on commit 6201b30

Please sign in to comment.