/
genesis.go
44 lines (37 loc) · 1.34 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
package vesting
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/elysium-station/blackfury/x/vesting/keeper"
"github.com/elysium-station/blackfury/x/vesting/types"
)
// InitGenesis initializes the vesting module's state from a provided genesis
// state.
func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) {
k.SetParams(ctx, genState.Params)
allocAddresses := k.GetAllocationAddresses(ctx)
if len(genState.AllocationAddresses.StrategicReserveCustodianAddr) != 0 {
newSrca, err := sdk.AccAddressFromBech32(genState.AllocationAddresses.StrategicReserveCustodianAddr)
if err != nil {
panic(err)
}
allocAddresses.StrategicReserveCustodianAddr = newSrca.String()
}
if len(genState.AllocationAddresses.TeamVestingAddr) != 0 {
newTva, err := sdk.AccAddressFromBech32(genState.AllocationAddresses.TeamVestingAddr)
if err != nil {
panic(err)
}
allocAddresses.TeamVestingAddr = newTva.String()
}
k.SetAllocationAddresses(ctx, allocAddresses)
if ctx.BlockHeight() <= 1 {
k.AllocateAtGenesis(ctx, genState)
}
}
// ExportGenesis returns the vesting module's exported genesis.
func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState {
genesis := types.DefaultGenesis()
genesis.Params = k.GetParams(ctx)
genesis.AllocationAddresses = k.GetAllocationAddresses(ctx)
return genesis
}