From 96fce43ee24a4c82897d6a075798f65a0fb482b4 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Thu, 13 Jun 2024 15:39:47 +0200 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Danny Co-authored-by: Danilo Pantani --- ignite/templates/app/files-consumer/app/app.go.plush | 9 ++++++--- ignite/templates/app/files/app/app.go.plush | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/ignite/templates/app/files-consumer/app/app.go.plush b/ignite/templates/app/files-consumer/app/app.go.plush index 8ec88b1633..3fa6378731 100644 --- a/ignite/templates/app/files-consumer/app/app.go.plush +++ b/ignite/templates/app/files-consumer/app/app.go.plush @@ -334,10 +334,13 @@ func New( app.SetAnteHandler(anteHandler) // A custom InitChainer sets if extra pre-init-genesis logic is required. - // As we are registering modules manually (i.e. that does not support app wiring), - // the module version map must be set manually as follow. + // This is necessary for manually registered modules that do not support app wiring. + // Manually set the module version map as shown below. + // The upgrade module will automatically handle de-duplication of the module version map. app.SetInitChainer(func(ctx sdk.Context, req *abci.RequestInitChain) (*abci.ResponseInitChain, error) { - app.UpgradeKeeper.SetModuleVersionMap(ctx, app.ModuleManager.GetVersionMap()) + if err := app.UpgradeKeeper.SetModuleVersionMap(ctx, app.ModuleManager.GetVersionMap()); err != nil { + return nil, err + } return app.App.InitChainer(ctx, req) }) diff --git a/ignite/templates/app/files/app/app.go.plush b/ignite/templates/app/files/app/app.go.plush index 31f1fb806e..4f55168cd0 100644 --- a/ignite/templates/app/files/app/app.go.plush +++ b/ignite/templates/app/files/app/app.go.plush @@ -339,10 +339,13 @@ func New( app.sm.RegisterStoreDecoders() // A custom InitChainer sets if extra pre-init-genesis logic is required. - // As we are registering modules manually (i.e. that does not support app wiring), - // the module version map must be set manually as follow. + // This is necessary for manually registered modules that do not support app wiring. + // Manually set the module version map as shown below. + // The upgrade module will automatically handle de-duplication of the module version map. app.SetInitChainer(func(ctx sdk.Context, req *abci.RequestInitChain) (*abci.ResponseInitChain, error) { - app.UpgradeKeeper.SetModuleVersionMap(ctx, app.ModuleManager.GetVersionMap()) + if err := app.UpgradeKeeper.SetModuleVersionMap(ctx, app.ModuleManager.GetVersionMap()); err != nil { + return nil, err + } return app.App.InitChainer(ctx, req) })