check auction ceiling before placing bids
parent
ffd2529ccb
commit
69f2fa82de
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue