cosmos-sdk/x/auth/genesis.go
SaReN bf8809ef98
Update x/auth to use Any (#6165)
* Migrate keeper codec to use marshaler

* Migrate AccountI to types

* Did go imports

* Fix tests for x/auth

* Cleanup std/codec

* Sort imports

* Fix legacy codec

* Add godoc for RegisterInterfaces

* Add RegisterInterfaces to std

* Fix typo

* Fixed merge changes

* Eliminate vesting import in auth

* Fix lint issues

* Fix tests

* Addressed comments

* Rename interfaces in RegisterInterfaces

* Removed codec.proto from std

* Minor code cleanup

Co-authored-by: Aaron Craelius <aaron@regen.network>
2020-05-20 19:21:00 +00:00

37 lines
1.0 KiB
Go

package auth
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/types"
)
// InitGenesis - Init store state from genesis data
//
// CONTRACT: old coins from the FeeCollectionKeeper need to be transferred through
// a genesis port script to the new fee collector account
func InitGenesis(ctx sdk.Context, ak AccountKeeper, data GenesisState) {
ak.SetParams(ctx, data.Params)
data.Accounts = SanitizeGenesisAccounts(data.Accounts)
for _, a := range data.Accounts {
acc := ak.NewAccount(ctx, a)
ak.SetAccount(ctx, acc)
}
ak.GetModuleAccount(ctx, FeeCollectorName)
}
// ExportGenesis returns a GenesisState for a given context and keeper
func ExportGenesis(ctx sdk.Context, ak AccountKeeper) GenesisState {
params := ak.GetParams(ctx)
var genAccounts types.GenesisAccounts
ak.IterateAccounts(ctx, func(account types.AccountI) bool {
genAccount := account.(types.GenesisAccount)
genAccounts = append(genAccounts, genAccount)
return false
})
return NewGenesisState(params, genAccounts)
}