mirror of
https://github.com/colinear-labs/chain.git
synced 2026-03-05 13:24:26 -08:00
check auction ceiling before placing bids
This commit is contained in:
@@ -15,7 +15,7 @@ import (
|
|||||||
func (k msgServer) NewBid(goCtx context.Context, msg *types.MsgNewBid) (*types.MsgNewBidResponse, error) {
|
func (k msgServer) NewBid(goCtx context.Context, msg *types.MsgNewBid) (*types.MsgNewBidResponse, error) {
|
||||||
ctx := sdk.UnwrapSDKContext(goCtx)
|
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||||
|
|
||||||
_, found := k.Keeper.GetAuction(ctx, msg.AuctionIndex)
|
auction, found := k.Keeper.GetAuction(ctx, msg.AuctionIndex)
|
||||||
if !found {
|
if !found {
|
||||||
return nil, fmt.Errorf("didn't find auction of index %s", msg.AuctionIndex)
|
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")
|
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)
|
lowestBid, err := memdb.BidDB.GetLowestBid(msg.AuctionIndex)
|
||||||
// we manually handle KeyNotFound in GetHighestBid, so should return (nil, nil) if not found
|
// we manually handle KeyNotFound in GetHighestBid, so should return (nil, nil) if not found
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user