57 lines
1.3 KiB
Go
57 lines
1.3 KiB
Go
package mint
|
|
|
|
import (
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
)
|
|
|
|
// GenesisState - minter state
|
|
type GenesisState struct {
|
|
Minter Minter `json:"minter"` // minter object
|
|
Params Params `json:"params"` // inflation params
|
|
}
|
|
|
|
// NewGenesisState creates a new GenesisState object
|
|
func NewGenesisState(minter Minter, params Params) GenesisState {
|
|
return GenesisState{
|
|
Minter: minter,
|
|
Params: params,
|
|
}
|
|
}
|
|
|
|
// DefaultGenesisState creates a default GenesisState object
|
|
func DefaultGenesisState() GenesisState {
|
|
return GenesisState{
|
|
Minter: DefaultInitialMinter(),
|
|
Params: DefaultParams(),
|
|
}
|
|
}
|
|
|
|
// new mint genesis
|
|
func InitGenesis(ctx sdk.Context, keeper Keeper, data GenesisState) {
|
|
keeper.SetMinter(ctx, data.Minter)
|
|
keeper.SetParams(ctx, data.Params)
|
|
}
|
|
|
|
// ExportGenesis returns a GenesisState for a given context and keeper.
|
|
func ExportGenesis(ctx sdk.Context, keeper Keeper) GenesisState {
|
|
minter := keeper.GetMinter(ctx)
|
|
params := keeper.GetParams(ctx)
|
|
return NewGenesisState(minter, params)
|
|
}
|
|
|
|
// ValidateGenesis validates the provided genesis state to ensure the
|
|
// expected invariants holds.
|
|
func ValidateGenesis(data GenesisState) error {
|
|
err := ValidateParams(data.Params)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
err = ValidateMinter(data.Minter)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|