diff --git a/x/auction/types/auctions.go b/x/auction/types/auctions.go index 203d9fec..3ef09f47 100644 --- a/x/auction/types/auctions.go +++ b/x/auction/types/auctions.go @@ -8,10 +8,10 @@ import ( "github.com/cosmos/cosmos-sdk/x/supply" ) -// distantFuture is a very large time value to use as initial the ending time for auctions. +// DistantFuture is a very large time value to use as initial the ending time for auctions. // It is not set to the max time supported. This can cause problems with time comparisons, see https://stackoverflow.com/a/32620397. // Also amino panics when encoding times ≥ the start of year 10000. -var DistantFuture time.Time = time.Date(9000, 1, 1, 0, 0, 0, 0, time.UTC) +var DistantFuture = time.Date(9000, 1, 1, 0, 0, 0, 0, time.UTC) // Auction is an interface for handling common actions on auctions. type Auction interface { @@ -57,6 +57,7 @@ func (a BaseAuction) GetBid() sdk.Coin { return a.Bid } // GetEndTime is a getter for auction end time. func (a BaseAuction) GetEndTime() time.Time { return a.EndTime } +// Validate verifies that the auction end time is before max end time func (a BaseAuction) Validate() error { if a.EndTime.After(a.MaxEndTime) { return fmt.Errorf("MaxEndTime < EndTime (%s < %s)", a.MaxEndTime, a.EndTime) diff --git a/x/auction/types/events.go b/x/auction/types/events.go index 032882c7..9d85743a 100644 --- a/x/auction/types/events.go +++ b/x/auction/types/events.go @@ -1,5 +1,6 @@ package types +// Events for auction module const ( EventTypeAuctionStart = "auction_start" EventTypeAuctionBid = "auction_bid" diff --git a/x/auction/types/keys.go b/x/auction/types/keys.go index 03c8cc29..b32188d0 100644 --- a/x/auction/types/keys.go +++ b/x/auction/types/keys.go @@ -20,9 +20,11 @@ const ( // DefaultParamspace default name for parameter store DefaultParamspace = ModuleName + // QuerierRoute route used for abci queries QuerierRoute = ModuleName ) +// Key prefixes var ( AuctionKeyPrefix = []byte{0x00} // prefix for keys that store auctions AuctionByTimeKeyPrefix = []byte{0x01} // prefix for keys that are part of the auctionsByTime index @@ -30,10 +32,12 @@ var ( NextAuctionIDKey = []byte{0x02} // key for the next auction id ) +// GetAuctionKey returns the bytes of an auction key func GetAuctionKey(auctionID uint64) []byte { return Uint64ToBytes(auctionID) } +// GetAuctionByTimeKey returns the key for iterating auctions by time func GetAuctionByTimeKey(endTime time.Time, auctionID uint64) []byte { return append(sdk.FormatTimeBytes(endTime), Uint64ToBytes(auctionID)...) } diff --git a/x/auction/types/params.go b/x/auction/types/params.go index 5f52f258..cbea5b11 100644 --- a/x/auction/types/params.go +++ b/x/auction/types/params.go @@ -54,11 +54,10 @@ func ParamKeyTable() subspace.KeyTable { } // ParamSetPairs implements the ParamSet interface and returns all the key/value pairs. -// nolint func (p *Params) ParamSetPairs() subspace.ParamSetPairs { return subspace.ParamSetPairs{ - {KeyAuctionBidDuration, &p.BidDuration}, - {KeyAuctionDuration, &p.MaxAuctionDuration}, + {Key: KeyAuctionBidDuration, Value: &p.BidDuration}, + {Key: KeyAuctionDuration, Value: &p.MaxAuctionDuration}, } } diff --git a/x/auction/types/querier.go b/x/auction/types/querier.go index 3b373317..34474b9a 100644 --- a/x/auction/types/querier.go +++ b/x/auction/types/querier.go @@ -19,8 +19,8 @@ func (n QueryResAuctions) String() string { // QueryAllAuctionParams is the params for an auctions query type QueryAllAuctionParams struct { - Page int `json"page:" yaml:"page"` - Limit int `json"limit:" yaml:"limit"` + Page int `json:"page" yaml:"page"` + Limit int `json:"limit" yaml:"limit"` } // NewQueryAllAuctionParams creates a new QueryAllAuctionParams