Skip to content

Commit

Permalink
feat: convenience methods to get/set operator PI split
Browse files Browse the repository at this point in the history
  • Loading branch information
gpabst committed Dec 12, 2024
1 parent 79336bf commit 9985122
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
17 changes: 17 additions & 0 deletions chainio/clients/elcontracts/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,3 +354,20 @@ func (r *ChainReader) GetOperatorAVSSplit(

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
}
27 changes: 27 additions & 0 deletions chainio/clients/elcontracts/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,33 @@ func (w *ChainWriter) SetOperatorAVSSplit(
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 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)
}

return receipt, nil
}

func (w *ChainWriter) ProcessClaims(
ctx context.Context,
claims []rewardscoordinator.IRewardsCoordinatorRewardsMerkleClaim,
Expand Down

0 comments on commit 9985122

Please sign in to comment.