Skip to content

Commit 7211728

Browse files
authored
feat: convenience methods to get/set operator PI split (#406)
1 parent 79336bf commit 7211728

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

chainio/clients/elcontracts/reader.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,3 +354,20 @@ func (r *ChainReader) GetOperatorAVSSplit(
354354

355355
return split, nil
356356
}
357+
358+
func (r *ChainReader) GetOperatorPISplit(
359+
ctx context.Context,
360+
operator gethcommon.Address,
361+
) (uint16, error) {
362+
if r.rewardsCoordinator == nil {
363+
return 0, errors.New("RewardsCoordinator contract not provided")
364+
}
365+
366+
split, err := r.rewardsCoordinator.GetOperatorPISplit(&bind.CallOpts{Context: ctx}, operator)
367+
368+
if err != nil {
369+
return 0, err
370+
}
371+
372+
return split, nil
373+
}

chainio/clients/elcontracts/writer.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,33 @@ func (w *ChainWriter) SetOperatorAVSSplit(
385385
return receipt, nil
386386
}
387387

388+
func (w *ChainWriter) SetOperatorPISplit(
389+
ctx context.Context,
390+
operator gethcommon.Address,
391+
split uint16,
392+
waitForReceipt bool,
393+
) (*gethtypes.Receipt, error) {
394+
if w.rewardsCoordinator == nil {
395+
return nil, errors.New("RewardsCoordinator contract not provided")
396+
}
397+
398+
noSendTxOpts, err := w.txMgr.GetNoSendTxOpts()
399+
if err != nil {
400+
return nil, utils.WrapError("failed to get no send tx opts", err)
401+
}
402+
403+
tx, err := w.rewardsCoordinator.SetOperatorPISplit(noSendTxOpts, operator, split)
404+
if err != nil {
405+
return nil, utils.WrapError("failed to create SetOperatorAVSSplit tx", err)
406+
}
407+
receipt, err := w.txMgr.Send(ctx, tx, waitForReceipt)
408+
if err != nil {
409+
return nil, utils.WrapError("failed to send tx", err)
410+
}
411+
412+
return receipt, nil
413+
}
414+
388415
func (w *ChainWriter) ProcessClaims(
389416
ctx context.Context,
390417
claims []rewardscoordinator.IRewardsCoordinatorRewardsMerkleClaim,

0 commit comments

Comments
 (0)