From 4ad6733a796d13d68cd17e878fe79c840ba3b15c Mon Sep 17 00:00:00 2001 From: Danilo Pantani Date: Sun, 2 Mar 2025 18:39:23 -0300 Subject: [PATCH 1/4] fix: remove unused placeholder vars --- .../client/cli/tx_{{packetName}}.go.plush | 3 --- .../x/{{moduleName}}/module/simulation.go.plush | 16 ---------------- .../simulation/{{typeName}}.go.plush | 4 ---- .../keeper/query_{{typeName}}_test.go.plush | 5 ----- .../keeper/msg_server_{{typeName}}_test.go.plush | 4 ---- 5 files changed, 32 deletions(-) diff --git a/ignite/templates/ibc/files/packet/messages/x/{{moduleName}}/client/cli/tx_{{packetName}}.go.plush b/ignite/templates/ibc/files/packet/messages/x/{{moduleName}}/client/cli/tx_{{packetName}}.go.plush index 2928e91079..85b887a8e1 100644 --- a/ignite/templates/ibc/files/packet/messages/x/{{moduleName}}/client/cli/tx_{{packetName}}.go.plush +++ b/ignite/templates/ibc/files/packet/messages/x/{{moduleName}}/client/cli/tx_{{packetName}}.go.plush @@ -1,7 +1,6 @@ package cli import ( - "strconv" <%= for (goImport) in mergeGoImports(fields) { %> <%= goImport.Alias %> "<%= goImport.Name %>"<% } %> "github.com/spf13/cobra" @@ -15,8 +14,6 @@ import ( "<%= ModulePath %>/x/<%= moduleName %>/types" ) -var _ = strconv.Itoa(0) - // CmdSend<%= packetName.UpperCamel %>() returns the <%= packetName.UpperCamel %> send packet command. // This command does not use AutoCLI because it gives a better UX to do not. func CmdSend<%= packetName.UpperCamel %>() *cobra.Command { diff --git a/ignite/templates/module/create/files/base/x/{{moduleName}}/module/simulation.go.plush b/ignite/templates/module/create/files/base/x/{{moduleName}}/module/simulation.go.plush index 11ecc6abc4..f9c138eb4b 100644 --- a/ignite/templates/module/create/files/base/x/{{moduleName}}/module/simulation.go.plush +++ b/ignite/templates/module/create/files/base/x/{{moduleName}}/module/simulation.go.plush @@ -1,30 +1,14 @@ package <%= moduleName %> import ( - "math/rand" - "cosmossdk.io/core/address" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/cosmos/cosmos-sdk/x/simulation" - "<%= modulePath %>/testutil/sample" "<%= modulePath %>/x/<%= moduleName %>/types" ) -// avoid unused import issue -var ( - _ = rand.Rand{} - _ = sample.AccAddress - _ = sdk.AccAddress{} - _ = simulation.MsgEntryKind -) - -const ( - // this line is used by starport scaffolding # simapp/module/const -) - // GenerateGenesisState creates a randomized GenState of the module. func (AppModule) GenerateGenesisState(simState *module.SimulationState) { accs := make([]string, len(simState.Accounts)) diff --git a/ignite/templates/typed/map/files/simapp/x/{{moduleName}}/simulation/{{typeName}}.go.plush b/ignite/templates/typed/map/files/simapp/x/{{moduleName}}/simulation/{{typeName}}.go.plush index d8403d6a23..4e27b71f62 100644 --- a/ignite/templates/typed/map/files/simapp/x/{{moduleName}}/simulation/{{typeName}}.go.plush +++ b/ignite/templates/typed/map/files/simapp/x/{{moduleName}}/simulation/{{typeName}}.go.plush @@ -2,7 +2,6 @@ package simulation import ( "math/rand" - "strconv" "github.com/cosmos/cosmos-sdk/baseapp" sdk "github.com/cosmos/cosmos-sdk/types" @@ -14,9 +13,6 @@ import ( "<%= ModulePath %>/x/<%= ModuleName %>/types" ) -// Prevent strconv unused error -var _ = strconv.IntSize - func SimulateMsgCreate<%= TypeName.UpperCamel %>( ak types.AuthKeeper, bk types.BankKeeper, diff --git a/ignite/templates/typed/map/files/tests/component/x/{{moduleName}}/keeper/query_{{typeName}}_test.go.plush b/ignite/templates/typed/map/files/tests/component/x/{{moduleName}}/keeper/query_{{typeName}}_test.go.plush index 2559260b0d..1a913cf6f7 100644 --- a/ignite/templates/typed/map/files/tests/component/x/{{moduleName}}/keeper/query_{{typeName}}_test.go.plush +++ b/ignite/templates/typed/map/files/tests/component/x/{{moduleName}}/keeper/query_{{typeName}}_test.go.plush @@ -1,7 +1,6 @@ package keeper_test import ( - "strconv" "testing" "github.com/cosmos/cosmos-sdk/types/query" @@ -14,14 +13,10 @@ import ( "<%= ModulePath %>/x/<%= ModuleName %>/keeper" ) -// Prevent strconv unused error -var _ = strconv.IntSize - func createN<%= TypeName.UpperCamel %>(keeper keeper.Keeper, ctx context.Context, n int) []types.<%= TypeName.UpperCamel %> { items := make([]types.<%= TypeName.UpperCamel %>, n) for i := range items { items[i].<%= Index.Name.UpperCamel %> = <%= Index.ValueLoop() %> - _ = keeper.<%= TypeName.UpperCamel %>.Set(ctx, items[i].<%= Index.Name.UpperCamel %>, items[i]) } return items diff --git a/ignite/templates/typed/map/files/tests/messages/x/{{moduleName}}/keeper/msg_server_{{typeName}}_test.go.plush b/ignite/templates/typed/map/files/tests/messages/x/{{moduleName}}/keeper/msg_server_{{typeName}}_test.go.plush index 9dc1367e3f..4c33658868 100644 --- a/ignite/templates/typed/map/files/tests/messages/x/{{moduleName}}/keeper/msg_server_{{typeName}}_test.go.plush +++ b/ignite/templates/typed/map/files/tests/messages/x/{{moduleName}}/keeper/msg_server_{{typeName}}_test.go.plush @@ -1,7 +1,6 @@ package keeper_test import ( - "strconv" "testing" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -11,9 +10,6 @@ import ( "<%= ModulePath %>/x/<%= ModuleName %>/types" ) -// Prevent strconv unused error -var _ = strconv.IntSize - func Test<%= TypeName.UpperCamel %>MsgServerCreate(t *testing.T) { f := initFixture(t) srv := keeper.NewMsgServerImpl(f.keeper) From fb7ab1de0d32f8eca95e777647e31b42a99e32b0 Mon Sep 17 00:00:00 2001 From: Danilo Pantani Date: Sun, 2 Mar 2025 18:40:35 -0300 Subject: [PATCH 2/4] add changelog --- changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.md b/changelog.md index f500473a7c..61d453d1e7 100644 --- a/changelog.md +++ b/changelog.md @@ -58,6 +58,7 @@ - [#4091](https://github.com/ignite/cli/pull/4091) Fix race conditions in the plugin logic - [#4128](https://github.com/ignite/cli/pull/4128) Check for duplicate proto fields in config - [#4402](https://github.com/ignite/cli/pull/4402) Fix gentx parser into the cosmosutil package +- [#4549](https://github.com/ignite/cli/pull/4549) Remove unused placeholder vars ## [`v28.8.1`](https://github.com/ignite/cli/releases/tag/v28.8.1) From 547005fe3af8be40e3ccf7e63a9308263e20af1e Mon Sep 17 00:00:00 2001 From: Danilo Pantani Date: Sun, 2 Mar 2025 18:56:25 -0300 Subject: [PATCH 3/4] remove unnecessary simulation var placeholder --- ignite/templates/message/message.go | 1 + .../x/{{moduleName}}/module/simulation.go.plush | 5 ----- .../simulation/placeholder.go.plush | 3 --- ignite/templates/typed/list/simulation.go | 1 + ignite/templates/typed/map/simulation.go | 1 + ignite/templates/typed/simulation.go | 17 +++++++++++++++-- ignite/templates/typed/singleton/simulation.go | 1 + 7 files changed, 19 insertions(+), 10 deletions(-) delete mode 100644 ignite/templates/module/create/files/base/x/{{moduleName}}/simulation/placeholder.go.plush diff --git a/ignite/templates/message/message.go b/ignite/templates/message/message.go index 2078b20d79..6c9da3f0af 100644 --- a/ignite/templates/message/message.go +++ b/ignite/templates/message/message.go @@ -252,6 +252,7 @@ func moduleSimulationModify(opts *Options) genny.RunFn { content, err := typed.ModuleSimulationMsgModify( f.String(), + opts.AppPath, opts.ModuleName, opts.MsgName, opts.MsgSigner, diff --git a/ignite/templates/module/create/files/base/x/{{moduleName}}/module/simulation.go.plush b/ignite/templates/module/create/files/base/x/{{moduleName}}/module/simulation.go.plush index 507beaeba9..8b084eea78 100644 --- a/ignite/templates/module/create/files/base/x/{{moduleName}}/module/simulation.go.plush +++ b/ignite/templates/module/create/files/base/x/{{moduleName}}/module/simulation.go.plush @@ -10,11 +10,6 @@ import ( "<%= modulePath %>/x/<%= moduleName %>/types" ) -// avoid unused import issue -var ( - _ = <%= moduleName %>simulation.PlaceHolder -) - // GenerateGenesisState creates a randomized GenState of the module. func (AppModule) GenerateGenesisState(simState *module.SimulationState) { accs := make([]string, len(simState.Accounts)) diff --git a/ignite/templates/module/create/files/base/x/{{moduleName}}/simulation/placeholder.go.plush b/ignite/templates/module/create/files/base/x/{{moduleName}}/simulation/placeholder.go.plush deleted file mode 100644 index 7635d20049..0000000000 --- a/ignite/templates/module/create/files/base/x/{{moduleName}}/simulation/placeholder.go.plush +++ /dev/null @@ -1,3 +0,0 @@ -package simulation - -const PlaceHolder = "placeholder" \ No newline at end of file diff --git a/ignite/templates/typed/list/simulation.go b/ignite/templates/typed/list/simulation.go index 061c8763b3..ceadbfbf78 100644 --- a/ignite/templates/typed/list/simulation.go +++ b/ignite/templates/typed/list/simulation.go @@ -48,6 +48,7 @@ func moduleSimulationModify(opts *typed.Options) genny.RunFn { content, err = typed.ModuleSimulationMsgModify( content, + opts.AppPath, opts.ModuleName, opts.TypeName, opts.MsgSigner, diff --git a/ignite/templates/typed/map/simulation.go b/ignite/templates/typed/map/simulation.go index c970f63d97..a2d2f1ad22 100644 --- a/ignite/templates/typed/map/simulation.go +++ b/ignite/templates/typed/map/simulation.go @@ -47,6 +47,7 @@ func moduleSimulationModify(opts *typed.Options) genny.RunFn { content, err = typed.ModuleSimulationMsgModify( content, + opts.AppPath, opts.ModuleName, opts.TypeName, opts.MsgSigner, diff --git a/ignite/templates/typed/simulation.go b/ignite/templates/typed/simulation.go index 55849e766c..f1efcbd977 100644 --- a/ignite/templates/typed/simulation.go +++ b/ignite/templates/typed/simulation.go @@ -9,7 +9,8 @@ import ( ) func ModuleSimulationMsgModify( - content string, + content, + appPath, moduleName string, typeName, msgSigner multiformatname.Name, msgs ...string, @@ -18,7 +19,19 @@ func ModuleSimulationMsgModify( msgs = append(msgs, "") } - var err error + //<%= moduleName %>simulation "" + // Import + content, err := xast.AppendImports( + content, + xast.WithLastNamedImport( + fmt.Sprintf("%[1]vsimulation", moduleName), + fmt.Sprintf("%[1]v/x/%[2]v/simulation", appPath, moduleName), + ), + ) + if err != nil { + return "", err + } + for _, msg := range msgs { // simulation operations replacementOp := fmt.Sprintf(` diff --git a/ignite/templates/typed/singleton/simulation.go b/ignite/templates/typed/singleton/simulation.go index b39f6d5704..296eab1e25 100644 --- a/ignite/templates/typed/singleton/simulation.go +++ b/ignite/templates/typed/singleton/simulation.go @@ -18,6 +18,7 @@ func moduleSimulationModify(opts *typed.Options) genny.RunFn { content, err := typed.ModuleSimulationMsgModify( f.String(), + opts.AppPath, opts.ModuleName, opts.TypeName, opts.MsgSigner, From 9c6a62c71f0e2ccb617f65b49a45f81b0b968886 Mon Sep 17 00:00:00 2001 From: Danilo Pantani Date: Sun, 2 Mar 2025 19:10:03 -0300 Subject: [PATCH 4/4] fix module import --- ignite/templates/message/message.go | 2 +- .../files/base/x/{{moduleName}}/module/simulation.go.plush | 1 - ignite/templates/typed/list/simulation.go | 2 +- ignite/templates/typed/map/simulation.go | 2 +- ignite/templates/typed/simulation.go | 6 +++--- ignite/templates/typed/singleton/simulation.go | 2 +- 6 files changed, 7 insertions(+), 8 deletions(-) diff --git a/ignite/templates/message/message.go b/ignite/templates/message/message.go index 6c9da3f0af..09828f4e85 100644 --- a/ignite/templates/message/message.go +++ b/ignite/templates/message/message.go @@ -252,7 +252,7 @@ func moduleSimulationModify(opts *Options) genny.RunFn { content, err := typed.ModuleSimulationMsgModify( f.String(), - opts.AppPath, + opts.ModulePath, opts.ModuleName, opts.MsgName, opts.MsgSigner, diff --git a/ignite/templates/module/create/files/base/x/{{moduleName}}/module/simulation.go.plush b/ignite/templates/module/create/files/base/x/{{moduleName}}/module/simulation.go.plush index 8b084eea78..9e2212ee8a 100644 --- a/ignite/templates/module/create/files/base/x/{{moduleName}}/module/simulation.go.plush +++ b/ignite/templates/module/create/files/base/x/{{moduleName}}/module/simulation.go.plush @@ -6,7 +6,6 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - <%= moduleName %>simulation "<%= modulePath %>/x/<%= moduleName %>/simulation" "<%= modulePath %>/x/<%= moduleName %>/types" ) diff --git a/ignite/templates/typed/list/simulation.go b/ignite/templates/typed/list/simulation.go index ceadbfbf78..5358ca0f3e 100644 --- a/ignite/templates/typed/list/simulation.go +++ b/ignite/templates/typed/list/simulation.go @@ -48,7 +48,7 @@ func moduleSimulationModify(opts *typed.Options) genny.RunFn { content, err = typed.ModuleSimulationMsgModify( content, - opts.AppPath, + opts.ModulePath, opts.ModuleName, opts.TypeName, opts.MsgSigner, diff --git a/ignite/templates/typed/map/simulation.go b/ignite/templates/typed/map/simulation.go index a2d2f1ad22..85e70049fa 100644 --- a/ignite/templates/typed/map/simulation.go +++ b/ignite/templates/typed/map/simulation.go @@ -47,7 +47,7 @@ func moduleSimulationModify(opts *typed.Options) genny.RunFn { content, err = typed.ModuleSimulationMsgModify( content, - opts.AppPath, + opts.ModulePath, opts.ModuleName, opts.TypeName, opts.MsgSigner, diff --git a/ignite/templates/typed/simulation.go b/ignite/templates/typed/simulation.go index f1efcbd977..e2d5bf2fa4 100644 --- a/ignite/templates/typed/simulation.go +++ b/ignite/templates/typed/simulation.go @@ -10,7 +10,7 @@ import ( func ModuleSimulationMsgModify( content, - appPath, + modulePath, moduleName string, typeName, msgSigner multiformatname.Name, msgs ...string, @@ -19,14 +19,14 @@ func ModuleSimulationMsgModify( msgs = append(msgs, "") } - //<%= moduleName %>simulation "" // Import content, err := xast.AppendImports( content, xast.WithLastNamedImport( fmt.Sprintf("%[1]vsimulation", moduleName), - fmt.Sprintf("%[1]v/x/%[2]v/simulation", appPath, moduleName), + fmt.Sprintf("%[1]v/x/%[2]v/simulation", modulePath, moduleName), ), + xast.WithImport("math/rand", 0), ) if err != nil { return "", err diff --git a/ignite/templates/typed/singleton/simulation.go b/ignite/templates/typed/singleton/simulation.go index 296eab1e25..1152f8721a 100644 --- a/ignite/templates/typed/singleton/simulation.go +++ b/ignite/templates/typed/singleton/simulation.go @@ -18,7 +18,7 @@ func moduleSimulationModify(opts *typed.Options) genny.RunFn { content, err := typed.ModuleSimulationMsgModify( f.String(), - opts.AppPath, + opts.ModulePath, opts.ModuleName, opts.TypeName, opts.MsgSigner,