diff --git a/x/cosmostest/keeper/msg_server_new_bid.go b/x/cosmostest/keeper/msg_server_new_bid.go index a0d80f1..b86aa26 100644 --- a/x/cosmostest/keeper/msg_server_new_bid.go +++ b/x/cosmostest/keeper/msg_server_new_bid.go @@ -15,7 +15,7 @@ import ( func (k msgServer) NewBid(goCtx context.Context, msg *types.MsgNewBid) (*types.MsgNewBidResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - _, found := k.Keeper.GetAuction(ctx, msg.AuctionIndex) + auction, found := k.Keeper.GetAuction(ctx, msg.AuctionIndex) if !found { return nil, fmt.Errorf("didn't find auction of index %s", msg.AuctionIndex) } @@ -38,6 +38,12 @@ func (k msgServer) NewBid(goCtx context.Context, msg *types.MsgNewBid) (*types.M return nil, fmt.Errorf("bid amount must be greater than 0") } + ceiling := new(big.Int) + ceiling.SetString(auction.Ceiling, 10) + if amt.Cmp(ceiling) == 1 { + return nil, fmt.Errorf("bid amount cannot be greater than auction price ceiling (%s)", auction.Ceiling) + } + lowestBid, err := memdb.BidDB.GetLowestBid(msg.AuctionIndex) // we manually handle KeyNotFound in GetHighestBid, so should return (nil, nil) if not found if err != nil {