gpu-compute-chain/x/colinear-core/genesis.go

40 lines
1.1 KiB
Go

package colinearcore
import (
"colinear/x/colinear-core/keeper"
"colinear/x/colinear-core/types"
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) {
// 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)
}
// 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)
// Get all nextAuction
nextAuction, found := k.GetNextAuction(ctx)
if found {
genesis.NextAuction = &nextAuction
}
genesis.AuctionList = k.GetAllAuction(ctx)
// this line is used by starport scaffolding # genesis/module/export
return genesis
}