@@ -128,6 +128,35 @@ func commandsGenesisModify(appPath, binaryName string) genny.RunFn {
128128 }
129129}
130130
131+ // commandsRollbackModify modifies the application rollback command to use evolve.
132+ func commandsRollbackModify (appPath , binaryName string ) genny.RunFn {
133+ return func (r * genny.Runner ) error {
134+ cmdPath := filepath .Join (appPath , "cmd" , binaryName , "cmd/commands.go" )
135+ f , err := r .Disk .Find (cmdPath )
136+ if err != nil {
137+ return err
138+ }
139+
140+ // use ast to modify the function that initializes genesisCmd
141+ content , err := xast .ModifyFunction (f .String (), "initRootCmd" ,
142+ xast .AppendFuncCode (`
143+ // override rollback command
144+ evNodeRollbackCmd := abciserver.NewRollbackCmd(newApp, app.DefaultNodeHome)
145+ if currentRollbackCmd, _, err := rootCmd.Find([]string{evNodeRollbackCmd.Name()}); err == nil{
146+ rootCmd.RemoveCommand(currentRollbackCmd)
147+ }
148+ rootCmd.AddCommand(evNodeRollbackCmd)
149+ ` ,
150+ ),
151+ )
152+ if err != nil {
153+ return err
154+ }
155+
156+ return r .File (genny .NewFileS (cmdPath , content ))
157+ }
158+ }
159+
131160// updateDependencies makes sure the correct dependencies are added to the go.mod files.
132161// ev-abci expects evolve v1 to be used.
133162func updateDependencies (appPath string ) error {
@@ -144,6 +173,9 @@ func updateDependencies(appPath string) error {
144173 return errors .Errorf ("failed to add local-da tool: %w" , err )
145174 }
146175
176+ // add required replaces
177+ gomod .AddReplace (GoDataStorePackage , "" , GoDataStorePackageFork , GoDataStoreVersionFork )
178+
147179 // save go.mod
148180 data , err := gomod .Format ()
149181 if err != nil {
0 commit comments