Skip to content

Commit

Permalink
add genesis verification in init genesis
Browse files Browse the repository at this point in the history
  • Loading branch information
kiragpg committed May 27, 2024
1 parent dd1aa75 commit fe445d6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions x/upgrade/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ func (am AppModule) InitGenesis(
var genesisState types.GenesisState
cdc.MustUnmarshalJSON(data, &genesisState)

if genesisState.Version != sekaitypes.SekaiVersion {
panic(types.ErrInvalidGenesisVersion)
}

if genesisState.CurrentPlan != nil {
am.upgradeKeeper.SaveCurrentPlan(ctx, *genesisState.CurrentPlan)
}
Expand Down
5 changes: 5 additions & 0 deletions x/upgrade/types/genesis.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
package types

import (
sekaitypes "github.com/KiraCore/sekai/types"
)

// DefaultGenesis returns the default CustomGo genesis state
func DefaultGenesis() *GenesisState {
return &GenesisState{
Version: sekaitypes.SekaiVersion,
CurrentPlan: nil,
NextPlan: nil,
}
Expand Down

0 comments on commit fe445d6

Please sign in to comment.