-
Notifications
You must be signed in to change notification settings - Fork 44
/
genesis.go
32 lines (27 loc) · 894 Bytes
/
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
package profiles
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/desmos-labs/desmos/x/profiles/keeper"
"github.com/desmos-labs/desmos/x/profiles/types"
abci "github.com/tendermint/tendermint/abci/types"
)
// ExportGenesis returns the GenesisState associated with the given context
func ExportGenesis(ctx sdk.Context, k keeper.Keeper) types.GenesisState {
return types.GenesisState{
Profiles: k.GetProfiles(ctx),
Params: k.GetParams(ctx),
}
}
// InitGenesis initializes the chain state based on the given GenesisState
func InitGenesis(ctx sdk.Context, k keeper.Keeper, data types.GenesisState) []abci.ValidatorUpdate {
k.SetParams(ctx, data.Params)
for _, profile := range data.Profiles {
if err := keeper.ValidateProfile(ctx, k, profile); err != nil {
panic(err)
}
if err := k.SaveProfile(ctx, profile); err != nil {
panic(err)
}
}
return nil
}