From bddf8e8289fe2bd5f1336e7d8fa4fc59e60a8b7a Mon Sep 17 00:00:00 2001 From: Pantani Date: Thu, 5 Oct 2023 02:11:58 +0200 Subject: [PATCH] remove old support methods and move module pkg to module folder --- ignite/services/scaffolder/message.go | 10 ----- ignite/services/scaffolder/patch.go | 44 ------------------- ignite/services/scaffolder/type.go | 22 ---------- ignite/templates/module/create/base.go | 16 +------ .../x/{{moduleName}}/genesis_test.go.plush | 0 .../{ => module}/module.go.plush | 0 .../module/simulation.go.plush} | 0 .../simulation/helpers.go.plush | 0 .../types/genesis_test.go.plush | 0 ignite/templates/module/create/genesistest.go | 36 --------------- ignite/templates/module/create/simulation.go | 33 -------------- ignite/templates/module/create/templates.go | 6 --- 12 files changed, 1 insertion(+), 166 deletions(-) rename ignite/templates/module/create/files/{genesistest => base}/x/{{moduleName}}/genesis_test.go.plush (100%) rename ignite/templates/module/create/files/base/x/{{moduleName}}/{ => module}/module.go.plush (100%) rename ignite/templates/module/create/files/{simapp/x/{{moduleName}}/module_simulation.go.plush => base/x/{{moduleName}}/module/simulation.go.plush} (100%) rename ignite/templates/module/create/files/{simapp => base}/x/{{moduleName}}/simulation/helpers.go.plush (100%) rename ignite/templates/module/create/files/{genesistest => base}/x/{{moduleName}}/types/genesis_test.go.plush (100%) delete mode 100644 ignite/templates/module/create/genesistest.go delete mode 100644 ignite/templates/module/create/simulation.go diff --git a/ignite/services/scaffolder/message.go b/ignite/services/scaffolder/message.go index cb32867f99..f475725dea 100644 --- a/ignite/services/scaffolder/message.go +++ b/ignite/services/scaffolder/message.go @@ -147,16 +147,6 @@ func (s Scaffolder) AddMessage( return sm, err } - gens, err = supportSimulation( - gens, - opts.AppPath, - opts.ModulePath, - opts.ModuleName, - ) - if err != nil { - return sm, err - } - // Scaffold g, err = message.NewGenerator(tracer, opts) if err != nil { diff --git a/ignite/services/scaffolder/patch.go b/ignite/services/scaffolder/patch.go index c8159145d9..b51d2c8e9c 100644 --- a/ignite/services/scaffolder/patch.go +++ b/ignite/services/scaffolder/patch.go @@ -10,50 +10,6 @@ import ( modulecreate "github.com/ignite/cli/ignite/templates/module/create" ) -// supportSimulation checks if module_simulation.go exists, -// appends the generator to create the file if it doesn't. -func supportSimulation( - gens []*genny.Generator, - appPath, - modulePath, - moduleName string, -) ([]*genny.Generator, error) { - simulation, err := modulecreate.AddSimulation( - appPath, - modulePath, - moduleName, - ) - if err != nil { - return gens, err - } - gens = append(gens, simulation) - return gens, nil -} - -// supportGenesisTests checks if types/genesis_test.go exists -// appends the generator to create the file if it doesn't. -func supportGenesisTests( - gens []*genny.Generator, - appPath, - appName, - modulePath, - moduleName string, - isIBC bool, -) ([]*genny.Generator, error) { - genesisTest, err := modulecreate.AddGenesisTest( - appPath, - appName, - modulePath, - moduleName, - isIBC, - ) - if err != nil { - return gens, err - } - gens = append(gens, genesisTest) - return gens, nil -} - // supportMsgServer checks if the module supports the MsgServer convention // appends the generator to support it if it doesn't // https://github.com/cosmos/cosmos-sdk/blob/main/docs/architecture/adr-031-msg-service.md diff --git a/ignite/services/scaffolder/type.go b/ignite/services/scaffolder/type.go index 686bbba689..472b790d98 100644 --- a/ignite/services/scaffolder/type.go +++ b/ignite/services/scaffolder/type.go @@ -197,28 +197,6 @@ func (s Scaffolder) AddType( return sm, err } - gens, err = supportGenesisTests( - gens, - opts.AppPath, - opts.AppName, - opts.ModulePath, - opts.ModuleName, - opts.IsIBC, - ) - if err != nil { - return sm, err - } - - gens, err = supportSimulation( - gens, - opts.AppPath, - opts.ModulePath, - opts.ModuleName, - ) - if err != nil { - return sm, err - } - // create the type generator depending on the model switch { case o.isList: diff --git a/ignite/templates/module/create/base.go b/ignite/templates/module/create/base.go index 1f8ea22145..fa10754043 100644 --- a/ignite/templates/module/create/base.go +++ b/ignite/templates/module/create/base.go @@ -26,11 +26,6 @@ func NewGenerator(opts *CreateOptions) (*genny.Generator, error) { "files/msgserver/", opts.AppPath, ) - genesisTestTemplate = xgenny.NewEmbedWalker( - fsGenesisTest, - "files/genesistest/", - opts.AppPath, - ) baseTemplate = xgenny.NewEmbedWalker( fsBase, "files/base/", @@ -41,9 +36,6 @@ func NewGenerator(opts *CreateOptions) (*genny.Generator, error) { if err := g.Box(msgServerTemplate); err != nil { return g, err } - if err := g.Box(genesisTestTemplate); err != nil { - return g, err - } if err := g.Box(baseTemplate); err != nil { return g, err } @@ -66,12 +58,6 @@ func NewGenerator(opts *CreateOptions) (*genny.Generator, error) { g.Transformer(genny.Replace("{{appName}}", opts.AppName)) g.Transformer(genny.Replace("{{moduleName}}", opts.ModuleName)) - gSimapp, err := AddSimulation(opts.AppPath, opts.ModulePath, opts.ModuleName, opts.Params...) - if err != nil { - return g, err - } - g.Merge(gSimapp) - return g, nil } @@ -96,7 +82,7 @@ func appConfigModify(replacer placeholder.Replacer, opts *CreateOptions) genny.R // Import template := `%[2]vmodulev1 "%[3]v/api/%[4]v/%[2]v/module" -_ "%[3]v/x/%[2]v" // import for side-effects +_ "%[3]v/x/%[2]v/module" // import for side-effects %[2]vmoduletypes "%[3]v/x/%[2]v/types" %[1]v` replacement := fmt.Sprintf(template, module.PlaceholderSgAppModuleImport, opts.ModuleName, opts.ModulePath, opts.AppName) diff --git a/ignite/templates/module/create/files/genesistest/x/{{moduleName}}/genesis_test.go.plush b/ignite/templates/module/create/files/base/x/{{moduleName}}/genesis_test.go.plush similarity index 100% rename from ignite/templates/module/create/files/genesistest/x/{{moduleName}}/genesis_test.go.plush rename to ignite/templates/module/create/files/base/x/{{moduleName}}/genesis_test.go.plush diff --git a/ignite/templates/module/create/files/base/x/{{moduleName}}/module.go.plush b/ignite/templates/module/create/files/base/x/{{moduleName}}/module/module.go.plush similarity index 100% rename from ignite/templates/module/create/files/base/x/{{moduleName}}/module.go.plush rename to ignite/templates/module/create/files/base/x/{{moduleName}}/module/module.go.plush diff --git a/ignite/templates/module/create/files/simapp/x/{{moduleName}}/module_simulation.go.plush b/ignite/templates/module/create/files/base/x/{{moduleName}}/module/simulation.go.plush similarity index 100% rename from ignite/templates/module/create/files/simapp/x/{{moduleName}}/module_simulation.go.plush rename to ignite/templates/module/create/files/base/x/{{moduleName}}/module/simulation.go.plush diff --git a/ignite/templates/module/create/files/simapp/x/{{moduleName}}/simulation/helpers.go.plush b/ignite/templates/module/create/files/base/x/{{moduleName}}/simulation/helpers.go.plush similarity index 100% rename from ignite/templates/module/create/files/simapp/x/{{moduleName}}/simulation/helpers.go.plush rename to ignite/templates/module/create/files/base/x/{{moduleName}}/simulation/helpers.go.plush diff --git a/ignite/templates/module/create/files/genesistest/x/{{moduleName}}/types/genesis_test.go.plush b/ignite/templates/module/create/files/base/x/{{moduleName}}/types/genesis_test.go.plush similarity index 100% rename from ignite/templates/module/create/files/genesistest/x/{{moduleName}}/types/genesis_test.go.plush rename to ignite/templates/module/create/files/base/x/{{moduleName}}/types/genesis_test.go.plush diff --git a/ignite/templates/module/create/genesistest.go b/ignite/templates/module/create/genesistest.go deleted file mode 100644 index c4deb06d9e..0000000000 --- a/ignite/templates/module/create/genesistest.go +++ /dev/null @@ -1,36 +0,0 @@ -package modulecreate - -import ( - "github.com/gobuffalo/genny/v2" - "github.com/gobuffalo/plush/v4" - - "github.com/ignite/cli/ignite/pkg/xgenny" - "github.com/ignite/cli/ignite/pkg/xstrings" - "github.com/ignite/cli/ignite/templates/field/plushhelpers" -) - -// AddGenesisTest returns the generator to generate genesis_test.go files. -func AddGenesisTest(appPath, appName, modulePath, moduleName string, isIBC bool) (*genny.Generator, error) { - var ( - g = genny.New() - template = xgenny.NewEmbedWalker(fsGenesisTest, "files/genesistest/", appPath) - ) - - ctx := plush.NewContext() - ctx.Set("moduleName", moduleName) - ctx.Set("modulePath", modulePath) - ctx.Set("appName", appName) - ctx.Set("isIBC", isIBC) - ctx.Set("title", xstrings.Title) - - plushhelpers.ExtendPlushContext(ctx) - g.Transformer(xgenny.Transformer(ctx)) - g.Transformer(genny.Replace("{{appName}}", appName)) - g.Transformer(genny.Replace("{{moduleName}}", moduleName)) - - if err := xgenny.Box(g, template); err != nil { - return nil, err - } - - return g, nil -} diff --git a/ignite/templates/module/create/simulation.go b/ignite/templates/module/create/simulation.go deleted file mode 100644 index 275245662e..0000000000 --- a/ignite/templates/module/create/simulation.go +++ /dev/null @@ -1,33 +0,0 @@ -package modulecreate - -import ( - "github.com/gobuffalo/genny/v2" - "github.com/gobuffalo/plush/v4" - - "github.com/ignite/cli/ignite/pkg/xgenny" - "github.com/ignite/cli/ignite/templates/field" - "github.com/ignite/cli/ignite/templates/field/plushhelpers" -) - -// AddSimulation returns the generator to generate module_simulation.go file. -func AddSimulation(appPath, modulePath, moduleName string, params ...field.Field) (*genny.Generator, error) { - var ( - g = genny.New() - template = xgenny.NewEmbedWalker(fsSimapp, "files/simapp/", appPath) - ) - - ctx := plush.NewContext() - ctx.Set("moduleName", moduleName) - ctx.Set("modulePath", modulePath) - ctx.Set("params", params) - - plushhelpers.ExtendPlushContext(ctx) - g.Transformer(genny.Replace("{{moduleName}}", moduleName)) - - if err := xgenny.Box(g, template); err != nil { - return nil, err - } - - g.Transformer(xgenny.Transformer(ctx)) - return g, nil -} diff --git a/ignite/templates/module/create/templates.go b/ignite/templates/module/create/templates.go index 10d837db97..f8b73ced50 100644 --- a/ignite/templates/module/create/templates.go +++ b/ignite/templates/module/create/templates.go @@ -13,10 +13,4 @@ var ( //go:embed files/msgserver/* files/msgserver/**/* fsMsgServer embed.FS - - //go:embed files/genesistest/* files/genesistest/**/* - fsGenesisTest embed.FS - - //go:embed files/simapp/* files/simapp/**/* - fsSimapp embed.FS )