0g-chain/x/validator-vesting/genesis.go

27 lines
988 B
Go
Raw Normal View History

2019-09-23 18:23:00 +00:00
package validatorvesting
import (
sdk "github.com/cosmos/cosmos-sdk/types"
2019-10-02 13:10:28 +00:00
"github.com/kava-labs/kava/x/validator-vesting/internal/types"
2019-09-23 18:23:00 +00:00
)
// InitGenesis stores the account address of each ValidatorVestingAccount in the validator vesting keeper, for faster lookup.
2019-10-02 13:10:28 +00:00
// CONTRACT: Accounts must have already been initialized/created by AccountKeeper
func InitGenesis(ctx sdk.Context, keeper Keeper, accountKeeper types.AccountKeeper, data GenesisState) {
accounts := accountKeeper.GetAllAccounts(ctx)
for _, a := range accounts {
2019-10-03 19:13:38 +00:00
vv, ok := a.(*ValidatorVestingAccount)
2019-09-23 18:23:00 +00:00
if ok {
keeper.SetValidatorVestingAccountKey(ctx, vv.Address)
}
}
2019-10-02 13:10:28 +00:00
keeper.SetPreviousBlockTime(ctx, data.PreviousBlockTime)
2019-09-23 18:23:00 +00:00
}
2019-10-01 02:53:14 +00:00
// ExportGenesis returns empty genesis state because auth exports all the genesis state we need.
func ExportGenesis(ctx sdk.Context, keeper Keeper) types.GenesisState {
2019-10-02 13:10:28 +00:00
prevBlockTime := keeper.GetPreviousBlockTime(ctx)
return GenesisState{PreviousBlockTime: prevBlockTime}
2019-10-01 02:53:14 +00:00
}