From 106bcd5e13e8d18f9659643d560fff1e0b9c6036 Mon Sep 17 00:00:00 2001 From: Federico Kunze <31522760+fedekunze@users.noreply.github.com> Date: Mon, 4 May 2020 18:00:17 -0400 Subject: [PATCH] default gen state (#6139) --- x/ibc/module.go | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/x/ibc/module.go b/x/ibc/module.go index f25955182..de0237ea6 100644 --- a/x/ibc/module.go +++ b/x/ibc/module.go @@ -52,28 +52,18 @@ func (AppModuleBasic) RegisterCodec(cdc *codec.Codec) { // DefaultGenesis returns default genesis state as raw bytes for the ibc // module. -func (AppModuleBasic) DefaultGenesis(_ codec.JSONMarshaler) json.RawMessage { - return nil +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONMarshaler) json.RawMessage { + return cdc.MustMarshalJSON(DefaultGenesisState()) } // ValidateGenesis performs genesis state validation for the ibc module. func (AppModuleBasic) ValidateGenesis(cdc codec.JSONMarshaler, bz json.RawMessage) error { + var gs GenesisState + if err := cdc.UnmarshalJSON(bz, &gs); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", ModuleName, err) + } - // TODO: UNDO this when DefaultGenesis() is implemented - // This validation is breaking the state as it is trying to - // validate nil. DefaultGenesis is not implemented and it just returns nil - // This is a quick fix to make the cli-tests work and - // SHOULD BE reverted when #5948 is addressed - // To UNDO this, just uncomment the code below - - // var gs GenesisState - // if err := cdc.UnmarshalJSON(bz, &gs); err != nil { - // return fmt.Errorf("failed to unmarshal %s genesis state: %w", ModuleName, err) - // } - - // return gs.Validate() - - return nil + return gs.Validate() } // RegisterRESTRoutes registers the REST routes for the ibc module.