mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-11-13 03:25:20 +00:00
replace some errors with panics
This commit is contained in:
parent
976f8f632d
commit
8899a7ff04
@ -1,109 +1,105 @@
|
|||||||
package auction
|
package auction
|
||||||
|
|
||||||
|
// DO NOT EDIT - generated by aliasgen tool (github.com/rhuairahrighairidh/aliasgen)
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/kava-labs/kava/x/auction/keeper"
|
"github.com/kava-labs/kava/x/auction/keeper"
|
||||||
"github.com/kava-labs/kava/x/auction/types"
|
"github.com/kava-labs/kava/x/auction/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
// nolint
|
|
||||||
// autogenerated code using github.com/rigelrozanski/multitool
|
|
||||||
// aliases generated for the following subdirectories:
|
|
||||||
// ALIASGEN: github.com/kava-labs/kava/x/auction/keeper
|
|
||||||
// ALIASGEN: github.com/kava-labs/kava/x/auction/types
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
EventTypeAuctionStart = types.EventTypeAuctionStart
|
|
||||||
EventTypeAuctionBid = types.EventTypeAuctionBid
|
|
||||||
EventTypeAuctionClose = types.EventTypeAuctionClose
|
|
||||||
AttributeValueCategory = types.AttributeValueCategory
|
|
||||||
AttributeKeyAuctionID = types.AttributeKeyAuctionID
|
AttributeKeyAuctionID = types.AttributeKeyAuctionID
|
||||||
AttributeKeyAuctionType = types.AttributeKeyAuctionType
|
AttributeKeyAuctionType = types.AttributeKeyAuctionType
|
||||||
|
AttributeKeyBid = types.AttributeKeyBid
|
||||||
AttributeKeyBidder = types.AttributeKeyBidder
|
AttributeKeyBidder = types.AttributeKeyBidder
|
||||||
AttributeKeyBidDenom = types.AttributeKeyBidDenom
|
AttributeKeyCloseBlock = types.AttributeKeyCloseBlock
|
||||||
AttributeKeyLotDenom = types.AttributeKeyLotDenom
|
|
||||||
AttributeKeyBidAmount = types.AttributeKeyBidAmount
|
|
||||||
AttributeKeyLotAmount = types.AttributeKeyLotAmount
|
|
||||||
AttributeKeyEndTime = types.AttributeKeyEndTime
|
AttributeKeyEndTime = types.AttributeKeyEndTime
|
||||||
DefaultNextAuctionID = types.DefaultNextAuctionID
|
AttributeKeyLot = types.AttributeKeyLot
|
||||||
ModuleName = types.ModuleName
|
AttributeKeyMaxBid = types.AttributeKeyMaxBid
|
||||||
StoreKey = types.StoreKey
|
AttributeValueCategory = types.AttributeValueCategory
|
||||||
RouterKey = types.RouterKey
|
|
||||||
DefaultParamspace = types.DefaultParamspace
|
|
||||||
QuerierRoute = types.QuerierRoute
|
|
||||||
DefaultMaxAuctionDuration = types.DefaultMaxAuctionDuration
|
|
||||||
DefaultBidDuration = types.DefaultBidDuration
|
DefaultBidDuration = types.DefaultBidDuration
|
||||||
|
DefaultMaxAuctionDuration = types.DefaultMaxAuctionDuration
|
||||||
|
DefaultNextAuctionID = types.DefaultNextAuctionID
|
||||||
|
DefaultParamspace = types.DefaultParamspace
|
||||||
|
EventTypeAuctionBid = types.EventTypeAuctionBid
|
||||||
|
EventTypeAuctionClose = types.EventTypeAuctionClose
|
||||||
|
EventTypeAuctionStart = types.EventTypeAuctionStart
|
||||||
|
ModuleName = types.ModuleName
|
||||||
|
QuerierRoute = types.QuerierRoute
|
||||||
QueryGetAuction = types.QueryGetAuction
|
QueryGetAuction = types.QueryGetAuction
|
||||||
QueryGetAuctions = types.QueryGetAuctions
|
QueryGetAuctions = types.QueryGetAuctions
|
||||||
QueryGetParams = types.QueryGetParams
|
QueryGetParams = types.QueryGetParams
|
||||||
|
RouterKey = types.RouterKey
|
||||||
|
StoreKey = types.StoreKey
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// functions aliases
|
// function aliases
|
||||||
NewKeeper = keeper.NewKeeper
|
ModuleAccountInvariants = keeper.ModuleAccountInvariants
|
||||||
NewQuerier = keeper.NewQuerier
|
NewKeeper = keeper.NewKeeper
|
||||||
RegisterInvariants = keeper.RegisterInvariants
|
NewQuerier = keeper.NewQuerier
|
||||||
NewSurplusAuction = types.NewSurplusAuction
|
RegisterInvariants = keeper.RegisterInvariants
|
||||||
NewDebtAuction = types.NewDebtAuction
|
ValidAuctionInvariant = keeper.ValidAuctionInvariant
|
||||||
NewCollateralAuction = types.NewCollateralAuction
|
ValidIndexInvariant = keeper.ValidIndexInvariant
|
||||||
NewWeightedAddresses = types.NewWeightedAddresses
|
DefaultGenesisState = types.DefaultGenesisState
|
||||||
RegisterCodec = types.RegisterCodec
|
DefaultParams = types.DefaultParams
|
||||||
ErrInvalidInitialAuctionID = types.ErrInvalidInitialAuctionID
|
GetAuctionByTimeKey = types.GetAuctionByTimeKey
|
||||||
ErrInvalidModulePermissions = types.ErrInvalidModulePermissions
|
GetAuctionKey = types.GetAuctionKey
|
||||||
ErrUnrecognizedAuctionType = types.ErrUnrecognizedAuctionType
|
NewAuctionWithPhase = types.NewAuctionWithPhase
|
||||||
ErrAuctionNotFound = types.ErrAuctionNotFound
|
NewCollateralAuction = types.NewCollateralAuction
|
||||||
ErrAuctionHasNotExpired = types.ErrAuctionHasNotExpired
|
NewDebtAuction = types.NewDebtAuction
|
||||||
ErrAuctionHasExpired = types.ErrAuctionHasExpired
|
NewGenesisState = types.NewGenesisState
|
||||||
ErrInvalidBidDenom = types.ErrInvalidBidDenom
|
NewMsgPlaceBid = types.NewMsgPlaceBid
|
||||||
ErrInvalidLotDenom = types.ErrInvalidLotDenom
|
NewParams = types.NewParams
|
||||||
ErrBidTooSmall = types.ErrBidTooSmall
|
NewQueryAllAuctionParams = types.NewQueryAllAuctionParams
|
||||||
ErrBidTooLarge = types.ErrBidTooLarge
|
NewSurplusAuction = types.NewSurplusAuction
|
||||||
ErrLotTooSmall = types.ErrLotTooSmall
|
NewWeightedAddresses = types.NewWeightedAddresses
|
||||||
ErrLotTooLarge = types.ErrLotTooLarge
|
ParamKeyTable = types.ParamKeyTable
|
||||||
ErrCollateralAuctionIsInReversePhase = types.ErrCollateralAuctionIsInReversePhase
|
RegisterCodec = types.RegisterCodec
|
||||||
ErrCollateralAuctionIsInForwardPhase = types.ErrCollateralAuctionIsInForwardPhase
|
Uint64FromBytes = types.Uint64FromBytes
|
||||||
NewGenesisState = types.NewGenesisState
|
Uint64ToBytes = types.Uint64ToBytes
|
||||||
DefaultGenesisState = types.DefaultGenesisState
|
|
||||||
GetAuctionKey = types.GetAuctionKey
|
|
||||||
GetAuctionByTimeKey = types.GetAuctionByTimeKey
|
|
||||||
Uint64ToBytes = types.Uint64ToBytes
|
|
||||||
Uint64FromBytes = types.Uint64FromBytes
|
|
||||||
NewMsgPlaceBid = types.NewMsgPlaceBid
|
|
||||||
NewParams = types.NewParams
|
|
||||||
DefaultParams = types.DefaultParams
|
|
||||||
ParamKeyTable = types.ParamKeyTable
|
|
||||||
NewQueryAllAuctionParams = types.NewQueryAllAuctionParams
|
|
||||||
NewAuctionWithPhase = types.NewAuctionWithPhase
|
|
||||||
|
|
||||||
// variable aliases
|
// variable aliases
|
||||||
DistantFuture = types.DistantFuture
|
AuctionByTimeKeyPrefix = types.AuctionByTimeKeyPrefix
|
||||||
ModuleCdc = types.ModuleCdc
|
AuctionKeyPrefix = types.AuctionKeyPrefix
|
||||||
AuctionKeyPrefix = types.AuctionKeyPrefix
|
DefaultIncrement = types.DefaultIncrement
|
||||||
AuctionByTimeKeyPrefix = types.AuctionByTimeKeyPrefix
|
DistantFuture = types.DistantFuture
|
||||||
NextAuctionIDKey = types.NextAuctionIDKey
|
ErrAuctionHasExpired = types.ErrAuctionHasExpired
|
||||||
DefaultIncrement = types.DefaultIncrement
|
ErrAuctionHasNotExpired = types.ErrAuctionHasNotExpired
|
||||||
KeyBidDuration = types.KeyBidDuration
|
ErrAuctionNotFound = types.ErrAuctionNotFound
|
||||||
KeyMaxAuctionDuration = types.KeyMaxAuctionDuration
|
ErrBidTooLarge = types.ErrBidTooLarge
|
||||||
KeyIncrementSurplus = types.KeyIncrementSurplus
|
ErrBidTooSmall = types.ErrBidTooSmall
|
||||||
KeyIncrementDebt = types.KeyIncrementDebt
|
ErrInvalidBidDenom = types.ErrInvalidBidDenom
|
||||||
KeyIncrementCollateral = types.KeyIncrementCollateral
|
ErrInvalidInitialAuctionID = types.ErrInvalidInitialAuctionID
|
||||||
|
ErrInvalidLotDenom = types.ErrInvalidLotDenom
|
||||||
|
ErrLotTooLarge = types.ErrLotTooLarge
|
||||||
|
ErrLotTooSmall = types.ErrLotTooSmall
|
||||||
|
ErrUnrecognizedAuctionType = types.ErrUnrecognizedAuctionType
|
||||||
|
KeyBidDuration = types.KeyBidDuration
|
||||||
|
KeyIncrementCollateral = types.KeyIncrementCollateral
|
||||||
|
KeyIncrementDebt = types.KeyIncrementDebt
|
||||||
|
KeyIncrementSurplus = types.KeyIncrementSurplus
|
||||||
|
KeyMaxAuctionDuration = types.KeyMaxAuctionDuration
|
||||||
|
ModuleCdc = types.ModuleCdc
|
||||||
|
NextAuctionIDKey = types.NextAuctionIDKey
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
Keeper = keeper.Keeper
|
Keeper = keeper.Keeper
|
||||||
Auction = types.Auction
|
Auction = types.Auction
|
||||||
|
AuctionWithPhase = types.AuctionWithPhase
|
||||||
Auctions = types.Auctions
|
Auctions = types.Auctions
|
||||||
BaseAuction = types.BaseAuction
|
BaseAuction = types.BaseAuction
|
||||||
SurplusAuction = types.SurplusAuction
|
|
||||||
DebtAuction = types.DebtAuction
|
|
||||||
CollateralAuction = types.CollateralAuction
|
CollateralAuction = types.CollateralAuction
|
||||||
WeightedAddresses = types.WeightedAddresses
|
DebtAuction = types.DebtAuction
|
||||||
SupplyKeeper = types.SupplyKeeper
|
|
||||||
GenesisAuction = types.GenesisAuction
|
GenesisAuction = types.GenesisAuction
|
||||||
GenesisAuctions = types.GenesisAuctions
|
GenesisAuctions = types.GenesisAuctions
|
||||||
GenesisState = types.GenesisState
|
GenesisState = types.GenesisState
|
||||||
MsgPlaceBid = types.MsgPlaceBid
|
MsgPlaceBid = types.MsgPlaceBid
|
||||||
Params = types.Params
|
Params = types.Params
|
||||||
QueryAuctionParams = types.QueryAuctionParams
|
|
||||||
QueryAllAuctionParams = types.QueryAllAuctionParams
|
QueryAllAuctionParams = types.QueryAllAuctionParams
|
||||||
AuctionWithPhase = types.AuctionWithPhase
|
QueryAuctionParams = types.QueryAuctionParams
|
||||||
|
SupplyKeeper = types.SupplyKeeper
|
||||||
|
SurplusAuction = types.SurplusAuction
|
||||||
|
WeightedAddresses = types.WeightedAddresses
|
||||||
)
|
)
|
||||||
|
@ -57,8 +57,7 @@ func (k Keeper) StartDebtAuction(ctx sdk.Context, buyer string, bid sdk.Coin, in
|
|||||||
// This auction type mints coins at close. Need to check module account has minting privileges to avoid potential err in endblocker.
|
// This auction type mints coins at close. Need to check module account has minting privileges to avoid potential err in endblocker.
|
||||||
macc := k.supplyKeeper.GetModuleAccount(ctx, buyer)
|
macc := k.supplyKeeper.GetModuleAccount(ctx, buyer)
|
||||||
if !macc.HasPermission(supply.Minter) {
|
if !macc.HasPermission(supply.Minter) {
|
||||||
// TODO: this should panic?
|
panic(fmt.Errorf("module '%s' does not have '%s' permission", buyer, supply.Minter))
|
||||||
return 0, sdkerrors.Wrap(types.ErrInvalidModulePermissions, supply.Minter)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: for the duration of the auction the auction module account holds the debt
|
// NOTE: for the duration of the auction the auction module account holds the debt
|
||||||
@ -239,8 +238,7 @@ func (k Keeper) PlaceForwardBidCollateral(ctx sdk.Context, a types.CollateralAuc
|
|||||||
return a, sdkerrors.Wrapf(types.ErrInvalidBidDenom, "%s ≠ %s", bid.Denom, a.Bid.Denom)
|
return a, sdkerrors.Wrapf(types.ErrInvalidBidDenom, "%s ≠ %s", bid.Denom, a.Bid.Denom)
|
||||||
}
|
}
|
||||||
if a.IsReversePhase() {
|
if a.IsReversePhase() {
|
||||||
// TODO: panic maybe?
|
panic("cannot place forward bid on auction in reverse phase")
|
||||||
return a, sdkerrors.Wrapf(types.ErrCollateralAuctionIsInReversePhase, "%d", a.ID)
|
|
||||||
}
|
}
|
||||||
minNewBidAmt := a.Bid.Amount.Add( // new bids must be some % greater than old bid, and at least 1 larger to avoid replacing an old bid at no cost
|
minNewBidAmt := a.Bid.Amount.Add( // new bids must be some % greater than old bid, and at least 1 larger to avoid replacing an old bid at no cost
|
||||||
sdk.MaxInt(
|
sdk.MaxInt(
|
||||||
@ -316,8 +314,7 @@ func (k Keeper) PlaceReverseBidCollateral(ctx sdk.Context, a types.CollateralAuc
|
|||||||
return a, sdkerrors.Wrapf(types.ErrInvalidLotDenom, lot.Denom, a.Lot.Denom)
|
return a, sdkerrors.Wrapf(types.ErrInvalidLotDenom, lot.Denom, a.Lot.Denom)
|
||||||
}
|
}
|
||||||
if !a.IsReversePhase() {
|
if !a.IsReversePhase() {
|
||||||
// TODO: Panic here?
|
panic("cannot place reverse bid on auction in forward phase")
|
||||||
return a, sdkerrors.Wrapf(types.ErrCollateralAuctionIsInForwardPhase, "%d", a.ID)
|
|
||||||
}
|
}
|
||||||
maxNewLotAmt := a.Lot.Amount.Sub( // new lot must be some % less than old lot, and at least 1 smaller to avoid replacing an old bid at no cost
|
maxNewLotAmt := a.Lot.Amount.Sub( // new lot must be some % less than old lot, and at least 1 smaller to avoid replacing an old bid at no cost
|
||||||
sdk.MaxInt(
|
sdk.MaxInt(
|
||||||
@ -454,13 +451,10 @@ func (k Keeper) CloseAuction(ctx sdk.Context, auctionID uint64) error {
|
|||||||
|
|
||||||
auction, found := k.GetAuction(ctx, auctionID)
|
auction, found := k.GetAuction(ctx, auctionID)
|
||||||
if !found {
|
if !found {
|
||||||
// TODO: panic if we are closing an auction in BB that isn't in the store?
|
|
||||||
// how else would we get here?
|
|
||||||
return sdkerrors.Wrapf(types.ErrAuctionNotFound, "%d", auctionID)
|
return sdkerrors.Wrapf(types.ErrAuctionNotFound, "%d", auctionID)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ctx.BlockTime().Before(auction.GetEndTime()) {
|
if ctx.BlockTime().Before(auction.GetEndTime()) {
|
||||||
// TODO: Do we check this upstream? should this be a panic
|
|
||||||
return sdkerrors.Wrapf(types.ErrAuctionHasNotExpired, "block time %s, auction end time %s", ctx.BlockTime().UTC(), auction.GetEndTime().UTC())
|
return sdkerrors.Wrapf(types.ErrAuctionHasNotExpired, "block time %s, auction end time %s", ctx.BlockTime().UTC(), auction.GetEndTime().UTC())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -488,7 +482,7 @@ func (k Keeper) CloseAuction(ctx sdk.Context, auctionID uint64) error {
|
|||||||
sdk.NewEvent(
|
sdk.NewEvent(
|
||||||
types.EventTypeAuctionClose,
|
types.EventTypeAuctionClose,
|
||||||
sdk.NewAttribute(types.AttributeKeyAuctionID, fmt.Sprintf("%d", auction.GetID())),
|
sdk.NewAttribute(types.AttributeKeyAuctionID, fmt.Sprintf("%d", auction.GetID())),
|
||||||
sdk.NewAttribute(types.AttributeKeyCloseBlock, fmt.Sprintf("%d", ctx.BlockHeight()))
|
sdk.NewAttribute(types.AttributeKeyCloseBlock, fmt.Sprintf("%d", ctx.BlockHeight())),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
return nil
|
return nil
|
||||||
@ -499,20 +493,17 @@ func (k Keeper) PayoutDebtAuction(ctx sdk.Context, a types.DebtAuction) error {
|
|||||||
// create the coins that are needed to pay off the debt
|
// create the coins that are needed to pay off the debt
|
||||||
err := k.supplyKeeper.MintCoins(ctx, a.Initiator, sdk.NewCoins(a.Lot))
|
err := k.supplyKeeper.MintCoins(ctx, a.Initiator, sdk.NewCoins(a.Lot))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// TODO: how would we get here? should this be a panic?
|
panic(fmt.Errorf("could not mint coins: %w", err))
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
// send the new coins from the initiator module to the bidder
|
// send the new coins from the initiator module to the bidder
|
||||||
err = k.supplyKeeper.SendCoinsFromModuleToAccount(ctx, a.Initiator, a.Bidder, sdk.NewCoins(a.Lot))
|
err = k.supplyKeeper.SendCoinsFromModuleToAccount(ctx, a.Initiator, a.Bidder, sdk.NewCoins(a.Lot))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// TODO: how would we get here? should this be a panic?
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// if there is remaining debt, return it to the calling module to manage
|
// if there is remaining debt, return it to the calling module to manage
|
||||||
if a.CorrespondingDebt.IsPositive() {
|
if a.CorrespondingDebt.IsPositive() {
|
||||||
err = k.supplyKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, a.Initiator, sdk.NewCoins(a.CorrespondingDebt))
|
err = k.supplyKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, a.Initiator, sdk.NewCoins(a.CorrespondingDebt))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// TODO: how would we get here? should this be a panic?
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -524,7 +515,6 @@ func (k Keeper) PayoutSurplusAuction(ctx sdk.Context, a types.SurplusAuction) er
|
|||||||
// Send the tokens from the auction module account where they are being managed to the bidder who won the auction
|
// Send the tokens from the auction module account where they are being managed to the bidder who won the auction
|
||||||
err := k.supplyKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, a.Bidder, sdk.NewCoins(a.Lot))
|
err := k.supplyKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, a.Bidder, sdk.NewCoins(a.Lot))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// TODO: how would we get here? should this be a panic?
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -535,7 +525,6 @@ func (k Keeper) PayoutCollateralAuction(ctx sdk.Context, a types.CollateralAucti
|
|||||||
// Send the tokens from the auction module account where they are being managed to the bidder who won the auction
|
// Send the tokens from the auction module account where they are being managed to the bidder who won the auction
|
||||||
err := k.supplyKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, a.Bidder, sdk.NewCoins(a.Lot))
|
err := k.supplyKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, a.Bidder, sdk.NewCoins(a.Lot))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// TODO: how would we get here? should this be a panic?
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -543,7 +532,6 @@ func (k Keeper) PayoutCollateralAuction(ctx sdk.Context, a types.CollateralAucti
|
|||||||
if a.CorrespondingDebt.IsPositive() {
|
if a.CorrespondingDebt.IsPositive() {
|
||||||
err = k.supplyKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, a.Initiator, sdk.NewCoins(a.CorrespondingDebt))
|
err = k.supplyKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, a.Initiator, sdk.NewCoins(a.CorrespondingDebt))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// TODO: how would we get here? should this be a panic?
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -576,12 +564,6 @@ func earliestTime(t1, t2 time.Time) time.Time {
|
|||||||
|
|
||||||
// splitCoinIntoWeightedBuckets divides up some amount of coins according to some weights.
|
// splitCoinIntoWeightedBuckets divides up some amount of coins according to some weights.
|
||||||
func splitCoinIntoWeightedBuckets(coin sdk.Coin, buckets []sdk.Int) ([]sdk.Coin, error) {
|
func splitCoinIntoWeightedBuckets(coin sdk.Coin, buckets []sdk.Int) ([]sdk.Coin, error) {
|
||||||
for _, bucket := range buckets {
|
|
||||||
if bucket.IsNegative() {
|
|
||||||
// TODO: Panic here? How would the code get here (should catch at validation)
|
|
||||||
return nil, fmt.Errorf("cannot split %s into bucket with negative weight (%s)", coin.String(), bucket.String())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
amounts := splitIntIntoWeightedBuckets(coin.Amount, buckets)
|
amounts := splitIntIntoWeightedBuckets(coin.Amount, buckets)
|
||||||
result := make([]sdk.Coin, len(amounts))
|
result := make([]sdk.Coin, len(amounts))
|
||||||
for i, a := range amounts {
|
for i, a := range amounts {
|
||||||
|
@ -7,30 +7,24 @@ import sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
|||||||
var (
|
var (
|
||||||
// ErrInvalidInitialAuctionID error for when the initial auction ID hasn't been set
|
// ErrInvalidInitialAuctionID error for when the initial auction ID hasn't been set
|
||||||
ErrInvalidInitialAuctionID = sdkerrors.Register(ModuleName, 2, "initial auction ID hasn't been set")
|
ErrInvalidInitialAuctionID = sdkerrors.Register(ModuleName, 2, "initial auction ID hasn't been set")
|
||||||
// ErrInvalidModulePermissions error for when module doesn't have valid permissions
|
|
||||||
ErrInvalidModulePermissions = sdkerrors.Register(ModuleName, 3, "module does not have required permission")
|
|
||||||
// ErrUnrecognizedAuctionType error for unrecognized auction type
|
// ErrUnrecognizedAuctionType error for unrecognized auction type
|
||||||
ErrUnrecognizedAuctionType = sdkerrors.Register(ModuleName, 4, "unrecognized auction type")
|
ErrUnrecognizedAuctionType = sdkerrors.Register(ModuleName, 3, "unrecognized auction type")
|
||||||
// ErrAuctionNotFound error for when an auction is not found
|
// ErrAuctionNotFound error for when an auction is not found
|
||||||
ErrAuctionNotFound = sdkerrors.Register(ModuleName, 5, "auction not found")
|
ErrAuctionNotFound = sdkerrors.Register(ModuleName, 4, "auction not found")
|
||||||
// ErrAuctionHasNotExpired error for attempting to close an auction that has not passed its end time
|
// ErrAuctionHasNotExpired error for attempting to close an auction that has not passed its end time
|
||||||
ErrAuctionHasNotExpired = sdkerrors.Register(ModuleName, 6, "auction can't be closed as curent block time has not passed auction end time")
|
ErrAuctionHasNotExpired = sdkerrors.Register(ModuleName, 5, "auction can't be closed as curent block time has not passed auction end time")
|
||||||
// ErrAuctionHasExpired error for when an auction is closed and unavailable for bidding
|
// ErrAuctionHasExpired error for when an auction is closed and unavailable for bidding
|
||||||
ErrAuctionHasExpired = sdkerrors.Register(ModuleName, 7, "auction has closed")
|
ErrAuctionHasExpired = sdkerrors.Register(ModuleName, 6, "auction has closed")
|
||||||
// ErrInvalidBidDenom error for when bid denom doesn't match auction bid denom
|
// ErrInvalidBidDenom error for when bid denom doesn't match auction bid denom
|
||||||
ErrInvalidBidDenom = sdkerrors.Register(ModuleName, 8, "bid denom doesn't match auction bid denom")
|
ErrInvalidBidDenom = sdkerrors.Register(ModuleName, 7, "bid denom doesn't match auction bid denom")
|
||||||
// ErrInvalidLotDenom error for when lot denom doesn't match auction lot denom
|
// ErrInvalidLotDenom error for when lot denom doesn't match auction lot denom
|
||||||
ErrInvalidLotDenom = sdkerrors.Register(ModuleName, 9, "lot denom doesn't match auction lot denom")
|
ErrInvalidLotDenom = sdkerrors.Register(ModuleName, 8, "lot denom doesn't match auction lot denom")
|
||||||
// ErrBidTooSmall error for when bid is not greater than auction's min bid amount
|
// ErrBidTooSmall error for when bid is not greater than auction's min bid amount
|
||||||
ErrBidTooSmall = sdkerrors.Register(ModuleName, 10, "bid is not greater than auction's min new bid amount")
|
ErrBidTooSmall = sdkerrors.Register(ModuleName, 9, "bid is not greater than auction's min new bid amount")
|
||||||
// ErrBidTooLarge error for when bid is larger than auction's maximum allowed bid
|
// ErrBidTooLarge error for when bid is larger than auction's maximum allowed bid
|
||||||
ErrBidTooLarge = sdkerrors.Register(ModuleName, 11, "bid is greater than auction's max bid")
|
ErrBidTooLarge = sdkerrors.Register(ModuleName, 10, "bid is greater than auction's max bid")
|
||||||
// ErrLotTooSmall error for when lot is less than zero
|
// ErrLotTooSmall error for when lot is less than zero
|
||||||
ErrLotTooSmall = sdkerrors.Register(ModuleName, 12, "lot is not greater than auction's min new lot amount")
|
ErrLotTooSmall = sdkerrors.Register(ModuleName, 11, "lot is not greater than auction's min new lot amount")
|
||||||
// ErrLotTooLarge error for when lot is not smaller than auction's max new lot amount
|
// ErrLotTooLarge error for when lot is not smaller than auction's max new lot amount
|
||||||
ErrLotTooLarge = sdkerrors.Register(ModuleName, 13, "lot is greater than auction's max new lot amount")
|
ErrLotTooLarge = sdkerrors.Register(ModuleName, 12, "lot is greater than auction's max new lot amount")
|
||||||
// ErrCollateralAuctionIsInReversePhase error for when attempting to place a forward bid on a collateral auction in reverse phase
|
|
||||||
ErrCollateralAuctionIsInReversePhase = sdkerrors.Register(ModuleName, 14, "invalid bid: auction is in reverse phase")
|
|
||||||
// ErrCollateralAuctionIsInForwardPhase error for when attempting to place a reverse bid on a collateral auction in forward phase
|
|
||||||
ErrCollateralAuctionIsInForwardPhase = sdkerrors.Register(ModuleName, 15, "invalid bid: auction is in forward phase")
|
|
||||||
)
|
)
|
||||||
|
@ -76,7 +76,7 @@ func (gs GenesisState) Validate() error {
|
|||||||
ids[a.GetID()] = true
|
ids[a.GetID()] = true
|
||||||
|
|
||||||
if a.GetID() >= gs.NextAuctionID {
|
if a.GetID() >= gs.NextAuctionID {
|
||||||
return fmt.Errorf("found auction ID >= the nextAuctionID (%d >= %d)", a.GetID(), gs.NextAuctionID)
|
return fmt.Errorf("found auction ID ≥ the nextAuctionID (%d ≥ %d)", a.GetID(), gs.NextAuctionID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user