enforce min & max lease period

This commit is contained in:
2022-09-05 22:17:55 +00:00
parent f1ea4edca8
commit 8711758f20
4 changed files with 33 additions and 9 deletions

View File

@@ -38,7 +38,7 @@ func (k Keeper) FinalizeExpiredAuctions(ctx sdk.Context) {
return errors.Errorf("could not get highest bid for auction %s: %s", auctionId, err)
}
// Remainig Unpaid: Full bid amount
// Remaining Unpaid: Full bid amount
auction.Remaining = auction.Best.Amount
// clear auction

View File

@@ -18,10 +18,28 @@ func (k msgServer) NewAuction(goCtx context.Context, msg *types.MsgNewAuction) (
next, found := k.Keeper.GetNextAuction(ctx)
if !found {
return nil, errors.New("Auction not found")
return nil, errors.New("unable to get next auction index")
}
index := strconv.FormatUint(next.AuctionId, 10)
auctionLen := msg.LeaseEnd - uint64(ctx.BlockTime().Unix())
if auctionLen < auctionconfig.MinLeasePeriod {
return nil, fmt.Errorf(
"Auction length %d is below min lease period of %d",
auctionLen,
auctionconfig.MinLeasePeriod,
)
}
if auctionLen > auctionconfig.MaxLeasePeriod {
return nil, fmt.Errorf(
"Auction length %d is above max lease period of %d",
auctionLen,
auctionconfig.MaxLeasePeriod,
)
}
auction := types.Auction{
Index: index,
Name: msg.Name,