enforce min & max lease period
parent
f1ea4edca8
commit
8711758f20
|
@ -4,13 +4,17 @@
|
|||
HERE=$(cd $(dirname $BASH_SOURCE) && pwd)
|
||||
source $HERE/testutil.sh
|
||||
|
||||
# echo $BOB
|
||||
# cosmos-testd q cosmostest show-auction $(get_last_auction_index) | jq
|
||||
# exit 0
|
||||
cosmos-testd tx cosmostest new-auction asdf asdf 200 token $(now + 3500) \
|
||||
-y --from bob \
|
||||
| expect_fail "Can't create auction below min lease period"
|
||||
|
||||
cosmos-testd tx cosmostest new-auction asdf asdf 200 token $(now + 8200000) \
|
||||
-y --from bob \
|
||||
| expect_fail "Can't create auction above max lease period"
|
||||
|
||||
before=$(get_balance $BOB token)
|
||||
|
||||
cosmos-testd tx cosmostest new-auction asdf asdf 200 token $(now + 100) \
|
||||
cosmos-testd tx cosmostest new-auction asdf asdf 200 token $(now + 3700) \
|
||||
-y --from bob \
|
||||
| expect_success "New auction is created"
|
||||
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
package auctionconfig
|
||||
|
||||
// Length of the auction in blocks-- currently 10.
|
||||
// Assuming a block time of 3sec, this should be ~30sec.
|
||||
const (
|
||||
// Times
|
||||
AuctionTime = 10
|
||||
AuctionTime = 10 // 10 blocks = ~10-30 seconds
|
||||
|
||||
// Lease Period Requirements (seconds)
|
||||
MinLeasePeriod = 3_600 // 1 hour
|
||||
MaxLeasePeriod = 8_035_200 // 3 months
|
||||
|
||||
// Gas Fees
|
||||
AuctionGas = 10
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue