forked from tendermint/spn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
genesis.go
47 lines (37 loc) · 1.43 KB
/
genesis.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package profile
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/tendermint/spn/x/profile/keeper"
"github.com/tendermint/spn/x/profile/types"
)
// InitGenesis initializes the capability module's state from a provided genesis
// state.
func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) {
// this line is used by starport scaffolding # genesis/module/init
// Set all the validator
for _, elem := range genState.ValidatorList {
k.SetValidator(ctx, elem)
}
// Set all the coordinatorByAddress
for _, elem := range genState.CoordinatorByAddressList {
k.SetCoordinatorByAddress(ctx, elem)
}
// Set all the coordinator
for _, elem := range genState.CoordinatorList {
k.SetCoordinator(ctx, elem)
}
// Set coordinator count
k.SetCoordinatorCount(ctx, genState.CoordinatorCount)
// this line is used by starport scaffolding # ibc/genesis/init
}
// ExportGenesis returns the capability module's exported genesis.
func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState {
genesis := types.DefaultGenesis()
genesis.ValidatorList = k.GetAllValidator(ctx)
genesis.CoordinatorByAddressList = k.GetAllCoordinatorByAddress(ctx)
genesis.CoordinatorList = k.GetAllCoordinator(ctx)
genesis.CoordinatorCount = k.GetCoordinatorCount(ctx)
// this line is used by starport scaffolding # genesis/module/export
// this line is used by starport scaffolding # ibc/genesis/export
return genesis
}