implement locking requirement to bid
parent
c85bbaca1f
commit
5158b96c96
|
@ -59,5 +59,7 @@ func (k msgServer) LockFunds(goCtx context.Context, msg *types.MsgLockFunds) (*t
|
|||
|
||||
lockedUsers.Users[msg.Creator] = totalAfterPay.String()
|
||||
|
||||
k.Keeper.SetLockedUsers(ctx, lockedUsers)
|
||||
|
||||
return &types.MsgLockFundsResponse{}, nil
|
||||
}
|
||||
|
|
|
@ -2,10 +2,12 @@ package keeper
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/big"
|
||||
"reflect"
|
||||
|
||||
"colinear/x/colinearcore/auctionconfig"
|
||||
"colinear/x/colinearcore/memdb"
|
||||
"colinear/x/colinearcore/types"
|
||||
|
||||
|
@ -15,6 +17,21 @@ import (
|
|||
func (k msgServer) NewBid(goCtx context.Context, msg *types.MsgNewBid) (*types.MsgNewBidResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
|
||||
lockedUsers, ok := k.Keeper.GetLockedUsers(ctx)
|
||||
if !ok {
|
||||
return nil, errors.New("unable to read locked providers (uninitialized)")
|
||||
}
|
||||
if lockedAmtStr, ok := lockedUsers.Users[msg.Creator]; !ok {
|
||||
return nil, fmt.Errorf("provider has not locked CLR tokens (min: %d uCLR)", auctionconfig.ProviderMinLockedUClr)
|
||||
} else {
|
||||
lockedAmt := new(big.Int)
|
||||
lockedAmt.SetString(lockedAmtStr, 10)
|
||||
required := big.NewInt(auctionconfig.ProviderMinLockedUClr)
|
||||
if lockedAmt.Cmp(required) == -1 {
|
||||
return nil, fmt.Errorf("provider has not locked enough CLR tokens (min: %d uCLR, locked: %s)", auctionconfig.ProviderMinLockedUClr, lockedAmt.String())
|
||||
}
|
||||
}
|
||||
|
||||
auction, found := k.Keeper.GetAuction(ctx, msg.AuctionIndex)
|
||||
if !found {
|
||||
return nil, fmt.Errorf("didn't find auction of index %s", msg.AuctionIndex)
|
||||
|
@ -28,7 +45,6 @@ func (k msgServer) NewBid(goCtx context.Context, msg *types.MsgNewBid) (*types.M
|
|||
return nil, fmt.Errorf("auction %s is expired", msg.AuctionIndex)
|
||||
}
|
||||
|
||||
ok := false
|
||||
amt := new(big.Int)
|
||||
amt, ok = amt.SetString(msg.Amount, 10)
|
||||
if !ok {
|
||||
|
|
Loading…
Reference in New Issue