From 1cb7b2347ace0e965a19e73353a376fe5bedf503 Mon Sep 17 00:00:00 2001 From: Mikhail Wall Date: Thu, 27 Jun 2024 15:43:40 +0200 Subject: [PATCH] fix: fixed response --- p2p/pkg/rpc/bidder/service.go | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/p2p/pkg/rpc/bidder/service.go b/p2p/pkg/rpc/bidder/service.go index a9a3298dc..79071eb3c 100644 --- a/p2p/pkg/rpc/bidder/service.go +++ b/p2p/pkg/rpc/bidder/service.go @@ -381,22 +381,23 @@ func (s *Service) AutoDeposit( var ads []*bidderapiv1.AutoDeposit for _, log := range receipt.Logs { - registration, err := s.registryContract.ParseBidderRegistered(*log) - if err != nil { - s.logger.Error("failed to parse BidderRegistered event", "error", err, "log", log) - continue + if registration, err := s.registryContract.ParseBidderRegistered(*log); err == nil { + s.logger.Info("deposit successful", "amount", registration.DepositedAmount, "window", registration.WindowNumber) + ads = append(ads, &bidderapiv1.AutoDeposit{ + Amount: registration.DepositedAmount.String(), + WindowNumber: wrapperspb.UInt64(registration.WindowNumber.Uint64()), + }) } - s.logger.Info("deposit successful", "amount", registration.DepositedAmount, "window", registration.WindowNumber) - ads = append(ads, &bidderapiv1.AutoDeposit{ - Amount: registration.DepositedAmount.String(), - WindowNumber: wrapperspb.UInt64(registration.WindowNumber.Uint64()), - }) } + if len(ads) > 0 { err := s.autoDepositTracker.DoAutoMoveToAnotherWindow(ctx, ads) if err != nil { return nil, status.Errorf(codes.Internal, "auto deposit: %v", err) } + return &bidderapiv1.AutoDepositResponse{ + AmountsAndWindowNumbers: ads, + }, nil } s.logger.Error(