From f71b41e24868add3cd33de91eb6f2e1036e5e5e6 Mon Sep 17 00:00:00 2001 From: chatton Date: Wed, 8 Oct 2025 16:02:58 +0100 Subject: [PATCH 1/5] chore: added start flag to optionally disable addition of the start command --- evolve/cmd/add.go | 8 +++++++- evolve/cmd/cmd.go | 6 ++++++ evolve/template/generator.go | 11 +++++++---- evolve/template/init.go | 34 ++++++++++++++++++++++++++++++---- 4 files changed, 50 insertions(+), 9 deletions(-) diff --git a/evolve/cmd/add.go b/evolve/cmd/add.go index 7317f3c9..832c0859 100644 --- a/evolve/cmd/add.go +++ b/evolve/cmd/add.go @@ -18,6 +18,7 @@ const ( statusScaffolding = "Scaffolding..." flagPath = "path" + flagStart = "start" flagMigrate = "migrate" ) @@ -32,6 +33,11 @@ func AddHandler(ctx context.Context, cmd *plugin.ExecutedCommand) error { return err } + withStartCmd, err := flags.GetBool(flagStart) + if err != nil { + return err + } + migrateCometBFT, err := flags.GetBool(flagMigrate) if err != nil { return err @@ -52,7 +58,7 @@ func AddHandler(ctx context.Context, cmd *plugin.ExecutedCommand) error { return err } - g, err := template.NewEvolveGenerator(c, migrateCometBFT) + g, err := template.NewEvolveGenerator(c, migrateCometBFT, withStartCmd) if err != nil { return err } diff --git a/evolve/cmd/cmd.go b/evolve/cmd/cmd.go index 82c9a6d7..9449aba6 100644 --- a/evolve/cmd/cmd.go +++ b/evolve/cmd/cmd.go @@ -23,6 +23,12 @@ func GetCommands() []*plugin.Command { Shorthand: "p", Type: plugin.FlagTypeString, }, + { + Name: flagStart, + Usage: "modify start command to use ev-abci (set to false to only add migrate command)", + Type: plugin.FlagTypeBool, + DefaultValue: "true", + }, { Name: flagMigrate, Usage: "scaffolds the migrations helpers and modules (to use when migrating from CometBFT)", diff --git a/evolve/template/generator.go b/evolve/template/generator.go index 8094d129..6e449037 100644 --- a/evolve/template/generator.go +++ b/evolve/template/generator.go @@ -11,7 +11,7 @@ import ( ) // NewEvolveGenerator returns the generator to scaffold a evolve integration inside an app. -func NewEvolveGenerator(chain *chain.Chain, withCometMigration bool) (*genny.Generator, error) { +func NewEvolveGenerator(chain *chain.Chain, withCometMigration, withStartCmd bool) (*genny.Generator, error) { g := genny.New() ctx := plush.NewContext() plushhelpers.ExtendPlushContext(ctx) @@ -28,9 +28,12 @@ func NewEvolveGenerator(chain *chain.Chain, withCometMigration bool) (*genny.Gen return nil, errors.Errorf("failed to update go.mod: %w", err) } - g.RunFn(commandsStartModify(appPath, binaryName, chain.Version)) - g.RunFn(commandsGenesisModify(appPath, binaryName)) - g.RunFn(commandsRollbackModify(appPath, binaryName)) + if withStartCmd { + g.RunFn(commandsStartModify(appPath, binaryName, chain.Version)) + g.RunFn(commandsGenesisInitModify(appPath, binaryName)) + g.RunFn(commandsRollbackModify(appPath, binaryName)) + } + g.RunFn(commandsMigrateModify(appPath, binaryName)) if withCometMigration { g.RunFn(migrateFromCometModify(appPath)) } diff --git a/evolve/template/init.go b/evolve/template/init.go index 140246b5..f412bb0c 100644 --- a/evolve/template/init.go +++ b/evolve/template/init.go @@ -71,8 +71,9 @@ func commandsStartModify(appPath, binaryName string, version cosmosver.Version) } } -// commandsGenesisModify modifies the application genesis command to use evolve. -func commandsGenesisModify(appPath, binaryName string) genny.RunFn { +// commandsGenesisInitModify modifies the application genesis init command to use evolve. +// this is only needed when the start command is also modified. +func commandsGenesisInitModify(appPath, binaryName string) genny.RunFn { return func(r *genny.Runner) error { cmdPath := filepath.Join(appPath, "cmd", binaryName, "cmd/commands.go") f, err := r.Disk.Find(cmdPath) @@ -109,13 +110,38 @@ func commandsGenesisModify(appPath, binaryName string) genny.RunFn { } // modify the add commands arguments using xast. - alreadyAdded := false // to avoid adding the migrate command multiple times as there are multiple calls to `rootCmd.AddCommand` content, err = xast.ModifyCaller(content, "rootCmd.AddCommand", func(args []string) ([]string, error) { if strings.Contains(args[0], "InitCmd") { args[0] = "genesisCmd" } - // add migrate command + return args, nil + }) + + return r.File(genny.NewFileS(cmdPath, content)) + } +} + +// commandsMigrateModify adds the evolve migrate command to the application. +func commandsMigrateModify(appPath, binaryName string) genny.RunFn { + return func(r *genny.Runner) error { + cmdPath := filepath.Join(appPath, "cmd", binaryName, "cmd/commands.go") + f, err := r.Disk.Find(cmdPath) + if err != nil { + return err + } + + content, err := xast.AppendImports( + f.String(), + xast.WithNamedImport("abciserver", "github.com/evstack/ev-abci/server"), + ) + if err != nil { + return err + } + + // add migrate command + alreadyAdded := false // to avoid adding the migrate command multiple times as there are multiple calls to `rootCmd.AddCommand` + content, err = xast.ModifyCaller(content, "rootCmd.AddCommand", func(args []string) ([]string, error) { if !alreadyAdded { args = append(args, evolveV1MigrateCmd) alreadyAdded = true From 84496e39a93ae657965d0a80c04d2e5ac6111946 Mon Sep 17 00:00:00 2001 From: chatton Date: Thu, 9 Oct 2025 08:41:32 +0100 Subject: [PATCH 2/5] chore: attempt to register types chore: change abci version chore: corrected pseudo version chore: bump abci version chore: bump abci version chore: bump abci version chore: bump abci version chore: bump abci version chore: bump abci version chore: bump abci version chore: bump abci version chore: bump abci version chore: bump abci version chore: bump abci version chore: bump abci version --- evolve/template/constants.go | 2 +- evolve/template/migrate.go | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/evolve/template/constants.go b/evolve/template/constants.go index 53ddfe0f..b264a23d 100644 --- a/evolve/template/constants.go +++ b/evolve/template/constants.go @@ -10,7 +10,7 @@ const ( const ( EvABCIPackage = "github.com/evstack/ev-abci" - EvABCIVersion = "v1.0.0-beta.2" + EvABCIVersion = "v0.0.0-20251009142256-589880bc8fb9" EvNodePackage = "github.com/evstack/ev-node" EvNodeVersion = "v1.0.0-beta.5" diff --git a/evolve/template/migrate.go b/evolve/template/migrate.go index ff677d7e..a4dd64cb 100644 --- a/evolve/template/migrate.go +++ b/evolve/template/migrate.go @@ -33,11 +33,20 @@ func migrateFromCometModify(appPath string) genny.RunFn { return err } + // add migrationmngr module config for depinject + moduleConfigTemplate := `{ + Name: migrationmngrtypes.ModuleName, + Config: appconfig.WrapAny(&migrationmngrmodule.Module{}), + }, + %[1]v` + moduleConfigReplacement := fmt.Sprintf(moduleConfigTemplate, module.PlaceholderSgAppModuleConfig) + content = replacer.Replace(content, module.PlaceholderSgAppModuleConfig, moduleConfigReplacement) + // end block for migrationmngr - template := `migrationmngrtypes.ModuleName, + endBlockerTemplate := `migrationmngrtypes.ModuleName, %[1]v` - replacement := fmt.Sprintf(template, module.PlaceholderSgAppEndBlockers) - content = replacer.Replace(content, module.PlaceholderSgAppEndBlockers, replacement) + endBlockerReplacement := fmt.Sprintf(endBlockerTemplate, module.PlaceholderSgAppEndBlockers) + content = replacer.Replace(content, module.PlaceholderSgAppEndBlockers, endBlockerReplacement) // replace staking blank import content = strings.Replace(content, "github.com/cosmos/cosmos-sdk/x/staking", "github.com/evstack/ev-abci/modules/staking", 1) From c6515f73327df2c968148c5cf5e92ce3afa1f8a9 Mon Sep 17 00:00:00 2001 From: chatton Date: Thu, 9 Oct 2025 15:29:43 +0100 Subject: [PATCH 3/5] chore: add pre-blocker to template chore: bump version chore: bump version chore: bump version chore: bump version chore: bump version chore: bump version chore: bump version chore: bump version chore: bump version chore: bump version chore: bump version --- evolve/template/constants.go | 2 +- evolve/template/migrate.go | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/evolve/template/constants.go b/evolve/template/constants.go index b264a23d..92f459a5 100644 --- a/evolve/template/constants.go +++ b/evolve/template/constants.go @@ -10,7 +10,7 @@ const ( const ( EvABCIPackage = "github.com/evstack/ev-abci" - EvABCIVersion = "v0.0.0-20251009142256-589880bc8fb9" + EvABCIVersion = "v0.0.0-20251014085911-149fda81aa98" EvNodePackage = "github.com/evstack/ev-node" EvNodeVersion = "v1.0.0-beta.5" diff --git a/evolve/template/migrate.go b/evolve/template/migrate.go index a4dd64cb..fc44bdca 100644 --- a/evolve/template/migrate.go +++ b/evolve/template/migrate.go @@ -42,6 +42,12 @@ func migrateFromCometModify(appPath string) genny.RunFn { moduleConfigReplacement := fmt.Sprintf(moduleConfigTemplate, module.PlaceholderSgAppModuleConfig) content = replacer.Replace(content, module.PlaceholderSgAppModuleConfig, moduleConfigReplacement) + // preblocker for migrationmngr + preBlockerTemplate := `migrationmngrtypes.ModuleName, + %[1]v` + preBlockerReplacement := fmt.Sprintf(preBlockerTemplate, "// this line is used by starport scaffolding # stargate/app/preBlockers") + content = replacer.Replace(content, "// this line is used by starport scaffolding # stargate/app/preBlockers", preBlockerReplacement) + // end block for migrationmngr endBlockerTemplate := `migrationmngrtypes.ModuleName, %[1]v` From d375d249f70cbe8350e148675a9b05378bbb4d85 Mon Sep 17 00:00:00 2001 From: chatton Date: Tue, 14 Oct 2025 15:22:48 +0100 Subject: [PATCH 4/5] chore: reverted version change --- evolve/template/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/evolve/template/constants.go b/evolve/template/constants.go index 92f459a5..53ddfe0f 100644 --- a/evolve/template/constants.go +++ b/evolve/template/constants.go @@ -10,7 +10,7 @@ const ( const ( EvABCIPackage = "github.com/evstack/ev-abci" - EvABCIVersion = "v0.0.0-20251014085911-149fda81aa98" + EvABCIVersion = "v1.0.0-beta.2" EvNodePackage = "github.com/evstack/ev-node" EvNodeVersion = "v1.0.0-beta.5" From 2c4cd8801c260c2daf62299ddc1de05683a3b48f Mon Sep 17 00:00:00 2001 From: chatton Date: Wed, 15 Oct 2025 08:45:45 +0100 Subject: [PATCH 5/5] chore: added changelog entry --- evolve/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/evolve/CHANGELOG.md b/evolve/CHANGELOG.md index 927b02f3..0653ae88 100644 --- a/evolve/CHANGELOG.md +++ b/evolve/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- [#236](https://github.com/ignite/apps/pull/236) Add `--start` flag to `evolve add` command to optionally disable addition of the start command. + ## [`v0.4.3`](https://github.com/ignite/apps/releases/tag/evolve/v0.4.3) - [#233](https://github.com/ignite/apps/pull/233) Bump dependencies.