-
Notifications
You must be signed in to change notification settings - Fork 206
/
genesis.go
40 lines (33 loc) · 1.01 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
package inflation
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/NibiruChain/nibiru/x/inflation/keeper"
"github.com/NibiruChain/nibiru/x/inflation/types"
)
// InitGenesis import module genesis
func InitGenesis(
ctx sdk.Context,
k keeper.Keeper,
ak types.AccountKeeper,
_ types.StakingKeeper,
data types.GenesisState,
) {
// Ensure inflation module account is set on genesis
if acc := ak.GetModuleAccount(ctx, types.ModuleName); acc == nil {
panic("the inflation module account has not been set")
}
// Set genesis state
k.Params.Set(ctx, data.Params)
period := data.Period
k.CurrentPeriod.Set(ctx, period)
skippedEpochs := data.SkippedEpochs
k.NumSkippedEpochs.Set(ctx, skippedEpochs)
}
// ExportGenesis returns a GenesisState for a given context and keeper.
func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState {
return &types.GenesisState{
Params: k.GetParams(ctx),
Period: k.CurrentPeriod.Peek(ctx),
SkippedEpochs: k.NumSkippedEpochs.Peek(ctx),
}
}