From e849753990d3c20ef6414e3f49a597ecd7fb31cf Mon Sep 17 00:00:00 2001 From: hopeyen Date: Thu, 12 Dec 2024 12:30:23 -0800 Subject: [PATCH] feat: import and bind payment vault contract --- core/eth/reader.go | 57 +++++++++++++++------------------------------- 1 file changed, 18 insertions(+), 39 deletions(-) diff --git a/core/eth/reader.go b/core/eth/reader.go index 187c35eafb..999f6ea3aa 100644 --- a/core/eth/reader.go +++ b/core/eth/reader.go @@ -210,6 +210,18 @@ func (t *Reader) updateContractBindings(blsOperatorStateRetrieverAddr, eigenDASe } } + paymentVaultAddr, err := contractEigenDAServiceManager.PaymentVault(&bind.CallOpts{}) + if err != nil { + t.logger.Error("Failed to fetch PaymentVault address", "err", err) + return err + } + + contractPaymentVault, err := paymentvault.NewContractPaymentVault(paymentVaultAddr, t.ethClient) + if err != nil { + t.logger.Error("Failed to fetch PaymentVault contract", "err", err) + return err + } + t.bindings = &ContractBindings{ ServiceManagerAddr: eigenDAServiceManagerAddr, RegCoordinatorAddr: registryCoordinatorAddr, @@ -224,8 +236,8 @@ func (t *Reader) updateContractBindings(blsOperatorStateRetrieverAddr, eigenDASe EigenDAServiceManager: contractEigenDAServiceManager, DelegationManager: contractDelegationManager, RelayRegistry: contractRelayRegistry, - // PaymentVault: contractPaymentVault, - ThresholdRegistry: contractThresholdRegistry, + PaymentVault: contractPaymentVault, + ThresholdRegistry: contractThresholdRegistry, } return nil } @@ -691,9 +703,6 @@ func (t *Reader) GetAllVersionedBlobParams(ctx context.Context) (map[uint16]*cor } func (t *Reader) GetActiveReservations(ctx context.Context, accountIDs []gethcommon.Address) (map[gethcommon.Address]*core.ActiveReservation, error) { - if t.bindings.PaymentVault == nil { - return nil, errors.New("payment vault not deployed") - } reservationsMap := make(map[gethcommon.Address]*core.ActiveReservation) reservations, err := t.bindings.PaymentVault.GetReservations(&bind.CallOpts{ Context: ctx, @@ -717,12 +726,7 @@ func (t *Reader) GetActiveReservations(ctx context.Context, accountIDs []gethcom } func (t *Reader) GetActiveReservationByAccount(ctx context.Context, accountID gethcommon.Address) (*core.ActiveReservation, error) { - if t.bindings.PaymentVault == nil { - return nil, errors.New("payment vault not deployed") - } - reservation, err := t.bindings.PaymentVault.GetReservation(&bind.CallOpts{ - Context: ctx, - }, accountID) + reservation, err := t.bindings.PaymentVault.GetReservation(&bind.CallOpts{Context: ctx}, accountID) if err != nil { return nil, err } @@ -730,13 +734,9 @@ func (t *Reader) GetActiveReservationByAccount(ctx context.Context, accountID ge } func (t *Reader) GetOnDemandPayments(ctx context.Context, accountIDs []gethcommon.Address) (map[gethcommon.Address]*core.OnDemandPayment, error) { - if t.bindings.PaymentVault == nil { - return nil, errors.New("payment vault not deployed") - } paymentsMap := make(map[gethcommon.Address]*core.OnDemandPayment) payments, err := t.bindings.PaymentVault.GetOnDemandTotalDeposits(&bind.CallOpts{ - Context: ctx, - }, accountIDs) + Context: ctx}, accountIDs) if err != nil { return nil, err } @@ -756,9 +756,6 @@ func (t *Reader) GetOnDemandPayments(ctx context.Context, accountIDs []gethcommo } func (t *Reader) GetOnDemandPaymentByAccount(ctx context.Context, accountID gethcommon.Address) (*core.OnDemandPayment, error) { - if t.bindings.PaymentVault == nil { - return nil, errors.New("payment vault not deployed") - } onDemandPayment, err := t.bindings.PaymentVault.GetOnDemandTotalDeposit(&bind.CallOpts{ Context: ctx, }, accountID) @@ -774,9 +771,6 @@ func (t *Reader) GetOnDemandPaymentByAccount(ctx context.Context, accountID geth } func (t *Reader) GetGlobalSymbolsPerSecond(ctx context.Context) (uint64, error) { - if t.bindings.PaymentVault == nil { - return 0, errors.New("payment vault not deployed") - } globalSymbolsPerSecond, err := t.bindings.PaymentVault.GlobalRatePeriodInterval(&bind.CallOpts{ Context: ctx, }) @@ -787,9 +781,6 @@ func (t *Reader) GetGlobalSymbolsPerSecond(ctx context.Context) (uint64, error) } func (t *Reader) GetGlobalRatePeriodInterval(ctx context.Context) (uint32, error) { - if t.bindings.PaymentVault == nil { - return 0, errors.New("payment vault not deployed") - } globalRateBinInterval, err := t.bindings.PaymentVault.GlobalRatePeriodInterval(&bind.CallOpts{ Context: ctx, }) @@ -798,11 +789,7 @@ func (t *Reader) GetGlobalRatePeriodInterval(ctx context.Context) (uint32, error } return uint32(globalRateBinInterval), nil } - func (t *Reader) GetMinNumSymbols(ctx context.Context) (uint32, error) { - if t.bindings.PaymentVault == nil { - return 0, errors.New("payment vault not deployed") - } minNumSymbols, err := t.bindings.PaymentVault.MinNumSymbols(&bind.CallOpts{ Context: ctx, }) @@ -813,9 +800,6 @@ func (t *Reader) GetMinNumSymbols(ctx context.Context) (uint32, error) { } func (t *Reader) GetPricePerSymbol(ctx context.Context) (uint32, error) { - if t.bindings.PaymentVault == nil { - return 0, errors.New("payment vault not deployed") - } pricePerSymbol, err := t.bindings.PaymentVault.PricePerSymbol(&bind.CallOpts{ Context: ctx, }) @@ -826,12 +810,8 @@ func (t *Reader) GetPricePerSymbol(ctx context.Context) (uint32, error) { } func (t *Reader) GetReservationWindow(ctx context.Context) (uint32, error) { - if t.bindings.PaymentVault == nil { - return 0, errors.New("payment vault not deployed") - } reservationWindow, err := t.bindings.PaymentVault.ReservationPeriodInterval(&bind.CallOpts{ - Context: ctx, - }) + Context: ctx}) if err != nil { return 0, err } @@ -843,8 +823,7 @@ func (t *Reader) GetOperatorSocket(ctx context.Context, operatorId core.Operator return "", errors.New("socket registry not enabled") } socket, err := t.bindings.SocketRegistry.GetOperatorSocket(&bind.CallOpts{ - Context: ctx, - }, [32]byte(operatorId)) + Context: ctx}, [32]byte(operatorId)) if err != nil { return "", err }