diff --git a/changelog.md b/changelog.md index bac116e528..5a06d92556 100644 --- a/changelog.md +++ b/changelog.md @@ -53,6 +53,7 @@ - [#4384](https://github.com/ignite/cli/pull/4384) Compare genesis params into chain genesis tests - [#4463](https://github.com/ignite/cli/pull/4463) Run `chain simulation` with any simulation test case - [#4533](https://github.com/ignite/cli/pull/4533) Promote GitHub codespace instead of Gitpod +- [#4549](https://github.com/ignite/cli/pull/4549) Remove unused placeholder vars ### Fixes 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/message/message.go b/ignite/templates/message/message.go index 2078b20d79..09828f4e85 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.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 6e99874dff..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 @@ -1,28 +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" - <%= moduleName %>simulation "<%= modulePath %>/x/<%= moduleName %>/simulation" "<%= modulePath %>/x/<%= moduleName %>/types" ) -// avoid unused import issue -var ( - _ = rand.Rand{} - _ = sample.AccAddress - _ = sdk.AccAddress{} - _ = simulation.MsgEntryKind - _ = <%= 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..5358ca0f3e 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.ModulePath, opts.ModuleName, opts.TypeName, opts.MsgSigner, 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) diff --git a/ignite/templates/typed/map/simulation.go b/ignite/templates/typed/map/simulation.go index c970f63d97..85e70049fa 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.ModulePath, opts.ModuleName, opts.TypeName, opts.MsgSigner, diff --git a/ignite/templates/typed/simulation.go b/ignite/templates/typed/simulation.go index 55849e766c..e2d5bf2fa4 100644 --- a/ignite/templates/typed/simulation.go +++ b/ignite/templates/typed/simulation.go @@ -9,7 +9,8 @@ import ( ) func ModuleSimulationMsgModify( - content string, + content, + modulePath, moduleName string, typeName, msgSigner multiformatname.Name, msgs ...string, @@ -18,7 +19,19 @@ func ModuleSimulationMsgModify( msgs = append(msgs, "") } - var err error + // Import + content, err := xast.AppendImports( + content, + xast.WithLastNamedImport( + fmt.Sprintf("%[1]vsimulation", moduleName), + fmt.Sprintf("%[1]v/x/%[2]v/simulation", modulePath, moduleName), + ), + xast.WithImport("math/rand", 0), + ) + 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..1152f8721a 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.ModulePath, opts.ModuleName, opts.TypeName, opts.MsgSigner,