Skip to content

Commit

Permalink
Merge branch 'dev' into wrap_errors
Browse files Browse the repository at this point in the history
  • Loading branch information
pablodeymo committed Dec 16, 2024
2 parents f9167a9 + 7211728 commit ca35c94
Show file tree
Hide file tree
Showing 12 changed files with 1,777 additions and 1,448 deletions.
35 changes: 35 additions & 0 deletions chainio/clients/elcontracts/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,3 +336,38 @@ func (r *ChainReader) CheckClaim(

return r.rewardsCoordinator.CheckClaim(&bind.CallOpts{Context: ctx}, claim)
}

func (r *ChainReader) GetOperatorAVSSplit(
ctx context.Context,
operator gethcommon.Address,
avs gethcommon.Address,
) (uint16, error) {
if r.rewardsCoordinator == nil {
return 0, errors.New("RewardsCoordinator contract not provided")
}

split, err := r.rewardsCoordinator.GetOperatorAVSSplit(&bind.CallOpts{Context: ctx}, operator, avs)

if err != nil {
return 0, err
}

return split, nil
}

func (r *ChainReader) GetOperatorPISplit(
ctx context.Context,
operator gethcommon.Address,
) (uint16, error) {
if r.rewardsCoordinator == nil {
return 0, errors.New("RewardsCoordinator contract not provided")
}

split, err := r.rewardsCoordinator.GetOperatorPISplit(&bind.CallOpts{Context: ctx}, operator)

if err != nil {
return 0, err
}

return split, nil
}
60 changes: 40 additions & 20 deletions chainio/clients/elcontracts/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,35 +357,53 @@ func (w *ChainWriter) ProcessClaim(
return receipt, nil
}

func (w *ChainWriter) ForceDeregisterFromOperatorSets(
func (w *ChainWriter) SetOperatorAVSSplit(
ctx context.Context,
operator gethcommon.Address,
avs gethcommon.Address,
operatorSetIds []uint32,
operatorSignature avsdirectory.ISignatureUtilsSignatureWithSaltAndExpiry,
split uint16,
waitForReceipt bool,
) (*gethtypes.Receipt, error) {
if w.avsDirectory == nil {
return nil, errors.New("AVSDirectory contract not provided")
if w.rewardsCoordinator == nil {
return nil, errors.New("RewardsCoordinator contract not provided")
}

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

tx, err := w.avsDirectory.ForceDeregisterFromOperatorSets(
noSendTxOpts,
operator,
avs,
operatorSetIds,
operatorSignature,
)
tx, err := w.rewardsCoordinator.SetOperatorAVSSplit(noSendTxOpts, operator, avs, split)
if err != nil {
return nil, utils.WrapError("failed to create SetOperatorAVSSplit 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
}

func (w *ChainWriter) SetOperatorPISplit(
ctx context.Context,
operator gethcommon.Address,
split uint16,
waitForReceipt bool,
) (*gethtypes.Receipt, error) {
if w.rewardsCoordinator == nil {
return nil, errors.New("RewardsCoordinator contract not provided")
}

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

tx, err := w.rewardsCoordinator.SetOperatorPISplit(noSendTxOpts, operator, split)
if err != nil {
return nil, utils.WrapError("failed to create SetOperatorAVSSplit tx", err)
}
receipt, err := w.txMgr.Send(ctx, tx, waitForReceipt)
if err != nil {
return nil, utils.WrapError("failed to send tx", err)
Expand All @@ -394,27 +412,29 @@ func (w *ChainWriter) ForceDeregisterFromOperatorSets(
return receipt, nil
}

func (w *ChainWriter) SetOperatorCommissionBips(
func (w *ChainWriter) ProcessClaims(
ctx context.Context,
operatorSet rewardscoordinator.IAVSDirectoryOperatorSet,
rewardType uint8,
commissionBips uint16,
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.SetOperatorCommissionBips(noSendTxOpts, operatorSet, rewardType, commissionBips)
tx, err := w.rewardsCoordinator.ProcessClaims(noSendTxOpts, claims, earnerAddress)
if err != nil {
return nil, utils.WrapError("failed to create SetOperatorCommissionBips tx", err)
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)
Expand Down
Loading

0 comments on commit ca35c94

Please sign in to comment.