Skip to content

Commit

Permalink
feat: import and bind payment vault contract
Browse files Browse the repository at this point in the history
  • Loading branch information
hopeyen committed Dec 12, 2024
1 parent 70085a9 commit e849753
Showing 1 changed file with 18 additions and 39 deletions.
57 changes: 18 additions & 39 deletions core/eth/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
}
Expand Down Expand Up @@ -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,
Expand All @@ -717,26 +726,17 @@ 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
}
return ConvertToActiveReservation(reservation)
}

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
}
Expand All @@ -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)
Expand All @@ -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,
})
Expand All @@ -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,
})
Expand All @@ -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,
})
Expand All @@ -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,
})
Expand All @@ -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
}
Expand All @@ -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
}
Expand Down

0 comments on commit e849753

Please sign in to comment.