diff --git a/core/eth/reader.go b/core/eth/reader.go index caaca5dec..5b937a871 100644 --- a/core/eth/reader.go +++ b/core/eth/reader.go @@ -210,16 +210,19 @@ func (t *Reader) updateContractBindings(blsOperatorStateRetrieverAddr, eigenDASe } } + var contractPaymentVault *paymentvault.ContractPaymentVault paymentVaultAddr, err := contractEigenDAServiceManager.PaymentVault(&bind.CallOpts{}) if err != nil { t.logger.Error("Failed to fetch PaymentVault address", "err", err) - return err - } + //TODO(hopeyen): return err when the contract is deployed + // return err + } else { + contractPaymentVault, err = paymentvault.NewContractPaymentVault(paymentVaultAddr, t.ethClient) + if err != nil { + t.logger.Error("Failed to fetch PaymentVault contract", "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{ @@ -703,6 +706,9 @@ func (t *Reader) GetAllVersionedBlobParams(ctx context.Context) (map[uint16]*cor } func (t *Reader) GetReservedPayments(ctx context.Context, accountIDs []gethcommon.Address) (map[gethcommon.Address]*core.ReservedPayment, error) { + if t.bindings.PaymentVault == nil { + return nil, errors.New("payment vault not deployed") + } reservationsMap := make(map[gethcommon.Address]*core.ReservedPayment) reservations, err := t.bindings.PaymentVault.GetReservations(&bind.CallOpts{ Context: ctx, @@ -726,6 +732,9 @@ func (t *Reader) GetReservedPayments(ctx context.Context, accountIDs []gethcommo } func (t *Reader) GetReservedPaymentByAccount(ctx context.Context, accountID gethcommon.Address) (*core.ReservedPayment, 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) @@ -736,6 +745,9 @@ func (t *Reader) GetReservedPaymentByAccount(ctx context.Context, accountID geth } 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) @@ -758,6 +770,9 @@ 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) @@ -773,6 +788,9 @@ 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, }) @@ -783,6 +801,9 @@ 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, }) @@ -792,6 +813,9 @@ 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, }) @@ -802,6 +826,9 @@ 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, }) @@ -812,6 +839,9 @@ 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}) if err != nil {