2022-08-25 16:51:14 -07:00
|
|
|
package types
|
|
|
|
|
|
|
|
import (
|
2022-08-25 18:49:35 -07:00
|
|
|
"fmt"
|
2022-08-25 16:51:14 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
// DefaultIndex is the default capability global index
|
|
|
|
const DefaultIndex uint64 = 1
|
|
|
|
|
|
|
|
// DefaultGenesis returns the default Capability genesis state
|
|
|
|
func DefaultGenesis() *GenesisState {
|
|
|
|
return &GenesisState{
|
2022-08-27 16:29:39 -07:00
|
|
|
NextAuction: &NextAuction{AuctionId: 0},
|
2022-08-25 18:49:35 -07:00
|
|
|
AuctionList: []Auction{},
|
2022-08-25 16:51:14 -07:00
|
|
|
// this line is used by starport scaffolding # genesis/types/default
|
|
|
|
Params: DefaultParams(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Validate performs basic genesis state validation returning an error upon any
|
|
|
|
// failure.
|
|
|
|
func (gs GenesisState) Validate() error {
|
2022-08-25 18:49:35 -07:00
|
|
|
// Check for duplicated index in auction
|
|
|
|
auctionIndexMap := make(map[string]struct{})
|
|
|
|
|
|
|
|
for _, elem := range gs.AuctionList {
|
|
|
|
index := string(AuctionKey(elem.Index))
|
|
|
|
if _, ok := auctionIndexMap[index]; ok {
|
|
|
|
return fmt.Errorf("duplicated index for auction")
|
|
|
|
}
|
|
|
|
auctionIndexMap[index] = struct{}{}
|
|
|
|
}
|
2022-08-25 16:51:14 -07:00
|
|
|
// this line is used by starport scaffolding # genesis/types/validate
|
|
|
|
|
|
|
|
return gs.Params.Validate()
|
|
|
|
}
|