From fe445d6ee05388a2740cd15d38410e1c6258f418 Mon Sep 17 00:00:00 2001 From: jgo121 Date: Tue, 28 May 2024 01:29:56 +0800 Subject: [PATCH] add genesis verification in init genesis --- x/upgrade/module.go | 4 ++++ x/upgrade/types/genesis.go | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/x/upgrade/module.go b/x/upgrade/module.go index 80b758fd..45c0b872 100644 --- a/x/upgrade/module.go +++ b/x/upgrade/module.go @@ -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) } diff --git a/x/upgrade/types/genesis.go b/x/upgrade/types/genesis.go index 48181e44..373c354d 100644 --- a/x/upgrade/types/genesis.go +++ b/x/upgrade/types/genesis.go @@ -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, }