Skip to content

Commit

Permalink
fix: fix begin blocker (#112)
Browse files Browse the repository at this point in the history
<!-- πŸŽ‰ Thank you for the PR!!! πŸŽ‰ -->

Closes #<issue number>. _in case of a bug fix, this should point to a
bug or any other related issue(s)_

### What does this PR do?

<!-- Describe your changes here - ideally you can get that description
straight from
your descriptive commit message(s)! -->

### How to test?

<!-- What steps in order should someone run to test -->

## Checklist

These are the criteria that every PR should meet, please check them off
as you
review them:

- [ ] Include tests
- [ ] Respect code style and lint
- [ ] Update documentation (*.md) (if needed)
  • Loading branch information
Pantani authored Oct 24, 2024
1 parent b6343db commit 6c96918
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion docs/static/openapi.yml

Large diffs are not rendered by default.

17 changes: 10 additions & 7 deletions x/fundraising/keeper/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package keeper

import (
"context"
"fmt"
"time"

"github.com/cosmos/cosmos-sdk/telemetry"
Expand All @@ -21,14 +20,18 @@ func (k Keeper) BeginBlocker(ctx context.Context) error {
for _, auction := range auctions {
switch auction.GetStatus() {
case types.AuctionStatusStandBy:
err = k.ExecuteStandByStatus(ctx, auction)
if err := k.ExecuteStandByStatus(ctx, auction); err != nil {
return err
}
case types.AuctionStatusStarted:
err = k.ExecuteStartedStatus(ctx, auction)
if err := k.ExecuteStartedStatus(ctx, auction); err != nil {
return err
}
case types.AuctionStatusVesting:
err = k.ExecuteVestingStatus(ctx, auction)
default:
err = fmt.Errorf("invalid auction status %s", auction.GetStatus())
if err := k.ExecuteVestingStatus(ctx, auction); err != nil {
return err
}
}
}
return err
return nil
}
4 changes: 2 additions & 2 deletions x/fundraising/keeper/bid.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ func (k Keeper) PlaceBid(ctx context.Context, msg *types.MsgPlaceBid) (types.Bid
}

if auction.GetStatus() != types.AuctionStatusStarted {
return types.Bid{}, types.ErrInvalidAuctionStatus
return types.Bid{}, sdkerrors.Wrap(types.ErrInvalidAuctionStatus, auction.GetStatus().String())
}

if auction.GetType() == types.AuctionTypeBatch {
if msg.Price.LT(auction.(*types.BatchAuction).MinBidPrice) {
return types.Bid{}, types.ErrInsufficientMinBidPrice
return types.Bid{}, sdkerrors.Wrap(types.ErrInsufficientMinBidPrice, msg.Price.String())
}
}

Expand Down
2 changes: 1 addition & 1 deletion x/fundraising/keeper/query_auction.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (q queryServer) ListAuction(ctx context.Context, req *types.QueryAllAuction
if req.Status != "" && !(req.Status == types.AuctionStatusStandBy.String() || req.Status == types.AuctionStatusStarted.String() ||
req.Status == types.AuctionStatusVesting.String() || req.Status == types.AuctionStatusFinished.String() ||
req.Status == types.AuctionStatusCancelled.String()) {
return nil, status.Errorf(codes.InvalidArgument, "invalid auction status %s", req.Status)
return nil, status.Errorf(codes.InvalidArgument, "invalid auction status field %s", req.Status)
}

auctions, pageRes, err := query.CollectionFilteredPaginate(
Expand Down

0 comments on commit 6c96918

Please sign in to comment.