2022-09-05 16:03:12 -07:00
|
|
|
package colinearcore
|
2022-08-25 16:51:14 -07:00
|
|
|
|
|
|
|
import (
|
2022-09-06 15:18:09 -07:00
|
|
|
"colinear/x/colinearcore/keeper"
|
|
|
|
"colinear/x/colinearcore/types"
|
2022-09-05 16:03:12 -07:00
|
|
|
|
2022-08-25 16:51:14 -07:00
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
|
|
)
|
|
|
|
|
|
|
|
// InitGenesis initializes the capability module's state from a provided genesis
|
|
|
|
// state.
|
|
|
|
func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) {
|
2022-08-25 18:49:35 -07:00
|
|
|
// Set if defined
|
|
|
|
if genState.NextAuction != nil {
|
|
|
|
k.SetNextAuction(ctx, *genState.NextAuction)
|
|
|
|
}
|
|
|
|
// Set all the auction
|
|
|
|
for _, elem := range genState.AuctionList {
|
|
|
|
k.SetAuction(ctx, elem)
|
|
|
|
}
|
2022-09-07 13:25:57 -07:00
|
|
|
// Set if defined
|
|
|
|
if genState.LockedUsers != nil {
|
|
|
|
k.SetLockedUsers(ctx, *genState.LockedUsers)
|
|
|
|
}
|
2022-08-25 16:51:14 -07:00
|
|
|
// this line is used by starport scaffolding # genesis/module/init
|
|
|
|
k.SetParams(ctx, genState.Params)
|
|
|
|
}
|
|
|
|
|
|
|
|
// ExportGenesis returns the capability module's exported genesis.
|
|
|
|
func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState {
|
|
|
|
genesis := types.DefaultGenesis()
|
|
|
|
genesis.Params = k.GetParams(ctx)
|
|
|
|
|
2022-08-25 18:49:35 -07:00
|
|
|
// Get all nextAuction
|
|
|
|
nextAuction, found := k.GetNextAuction(ctx)
|
|
|
|
if found {
|
|
|
|
genesis.NextAuction = &nextAuction
|
|
|
|
}
|
|
|
|
genesis.AuctionList = k.GetAllAuction(ctx)
|
2022-09-07 13:25:57 -07:00
|
|
|
// Get all lockedUsers
|
|
|
|
lockedUsers, found := k.GetLockedUsers(ctx)
|
|
|
|
if found {
|
|
|
|
genesis.LockedUsers = &lockedUsers
|
|
|
|
}
|
2022-08-25 16:51:14 -07:00
|
|
|
// this line is used by starport scaffolding # genesis/module/export
|
|
|
|
|
|
|
|
return genesis
|
|
|
|
}
|