Skip to content

Commit 79336bf

Browse files
authored
feat: methods to set and read operator avs split (#401)
1 parent 7d2cd16 commit 79336bf

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

chainio/clients/elcontracts/reader.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,3 +336,21 @@ func (r *ChainReader) CheckClaim(
336336

337337
return r.rewardsCoordinator.CheckClaim(&bind.CallOpts{Context: ctx}, claim)
338338
}
339+
340+
func (r *ChainReader) GetOperatorAVSSplit(
341+
ctx context.Context,
342+
operator gethcommon.Address,
343+
avs gethcommon.Address,
344+
) (uint16, error) {
345+
if r.rewardsCoordinator == nil {
346+
return 0, errors.New("RewardsCoordinator contract not provided")
347+
}
348+
349+
split, err := r.rewardsCoordinator.GetOperatorAVSSplit(&bind.CallOpts{Context: ctx}, operator, avs)
350+
351+
if err != nil {
352+
return 0, err
353+
}
354+
355+
return split, nil
356+
}

chainio/clients/elcontracts/writer.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,34 @@ func (w *ChainWriter) ProcessClaim(
357357
return receipt, nil
358358
}
359359

360+
func (w *ChainWriter) SetOperatorAVSSplit(
361+
ctx context.Context,
362+
operator gethcommon.Address,
363+
avs gethcommon.Address,
364+
split uint16,
365+
waitForReceipt bool,
366+
) (*gethtypes.Receipt, error) {
367+
if w.rewardsCoordinator == nil {
368+
return nil, errors.New("RewardsCoordinator contract not provided")
369+
}
370+
371+
noSendTxOpts, err := w.txMgr.GetNoSendTxOpts()
372+
if err != nil {
373+
return nil, utils.WrapError("failed to get no send tx opts", err)
374+
}
375+
376+
tx, err := w.rewardsCoordinator.SetOperatorAVSSplit(noSendTxOpts, operator, avs, split)
377+
if err != nil {
378+
return nil, utils.WrapError("failed to create SetOperatorAVSSplit tx", err)
379+
}
380+
receipt, err := w.txMgr.Send(ctx, tx, waitForReceipt)
381+
if err != nil {
382+
return nil, utils.WrapError("failed to send tx", err)
383+
}
384+
385+
return receipt, nil
386+
}
387+
360388
func (w *ChainWriter) ProcessClaims(
361389
ctx context.Context,
362390
claims []rewardscoordinator.IRewardsCoordinatorRewardsMerkleClaim,

0 commit comments

Comments
 (0)