forked from osmosis-labs/osmosis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
genesis.go
51 lines (38 loc) · 1.7 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
48
49
50
51
package keeper
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/Anmol1696/osmosis/v11/x/mint/types"
)
const developerVestingAmount = 225_000_000_000_000
// InitGenesis new mint genesis.
func (k Keeper) InitGenesis(ctx sdk.Context, data *types.GenesisState) {
if data == nil {
panic("nil mint genesis state")
}
data.Minter.EpochProvisions = data.Params.GenesisEpochProvisions
k.SetMinter(ctx, data.Minter)
k.SetParams(ctx, data.Params)
// The call to GetModuleAccount creates a module account if it does not exist.
k.accountKeeper.GetModuleAccount(ctx, types.ModuleName)
// The account should be exported in the ExportGenesis of the
// x/auth SDK module. Therefore, we check for existence here
// to avoid overwriting pre-existing genesis account data.
if !k.accountKeeper.HasAccount(ctx, k.accountKeeper.GetModuleAddress(types.DeveloperVestingModuleAcctName)) {
totalDeveloperVestingCoins := sdk.NewCoin(data.Params.MintDenom, sdk.NewInt(developerVestingAmount))
if err := k.createDeveloperVestingModuleAccount(ctx, totalDeveloperVestingCoins); err != nil {
panic(err)
}
k.bankKeeper.AddSupplyOffset(ctx, data.Params.MintDenom, sdk.NewInt(developerVestingAmount).Neg())
}
k.setLastReductionEpochNum(ctx, data.ReductionStartedEpoch)
}
// ExportGenesis returns a GenesisState for a given context and keeper.
func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState {
minter := k.GetMinter(ctx)
params := k.GetParams(ctx)
if params.WeightedDeveloperRewardsReceivers == nil {
params.WeightedDeveloperRewardsReceivers = make([]types.WeightedAddress, 0)
}
lastHalvenEpoch := k.getLastReductionEpochNum(ctx)
return types.NewGenesisState(minter, params, lastHalvenEpoch)
}