diff --git a/ignite/templates/typed/list/files/simapp/x/{{moduleName}}/simulation/{{typeName}}.go.plush b/ignite/templates/typed/list/files/simapp/x/{{moduleName}}/simulation/{{typeName}}.go.plush index cb4b927337..b539ddfcf4 100644 --- a/ignite/templates/typed/list/files/simapp/x/{{moduleName}}/simulation/{{typeName}}.go.plush +++ b/ignite/templates/typed/list/files/simapp/x/{{moduleName}}/simulation/{{typeName}}.go.plush @@ -25,7 +25,6 @@ func MsgCreate<%= TypeName.UpperCamel %>Factory(k keeper.Keeper) simsx.SimMsgFac func MsgUpdate<%= TypeName.UpperCamel %>Factory(k keeper.Keeper) simsx.SimMsgFactoryFn[*types.MsgUpdate<%= TypeName.UpperCamel %>] { return func(ctx context.Context, testData *simsx.ChainDataSource, reporter simsx.SimulationReporter) ([]simsx.SimAccount, *types.MsgUpdate<%= TypeName.UpperCamel %>) { var ( - simAccount = simtypes.Account{} <%= TypeName.LowerCamel %> = types.<%= TypeName.UpperCamel %>{} msg = &types.MsgUpdate<%= TypeName.UpperCamel %>{} found = false @@ -40,32 +39,32 @@ func MsgUpdate<%= TypeName.UpperCamel %>Factory(k keeper.Keeper) simsx.SimMsgFac return nil, nil } + simAccount := simsx.SimAccount{} for _, obj := range all<%= TypeName.UpperCamel %> { - simAccount, found = FindAccount(accs, obj.<%= MsgSigner.UpperCamel %>) - if found { - <%= TypeName.LowerCamel %> = obj + if ok := testData.HasAccount(obj.<%= MsgSigner.UpperCamel %>); ok { + simAccount = testData.GetAccount(reporter, obj.<%= MsgSigner.UpperCamel %>) break } } - if !found { + if simAccount.Address.Empty() { reporter.Skip("<%= TypeName.LowerCamel %> <%= MsgSigner.LowerCamel %> not found") return nil, nil } - msg.<%= MsgSigner.UpperCamel %> = simAccount.Address.String() + + msg.<%= MsgSigner.UpperCamel %> = simAccount.AddressBech32 msg.Id = <%= TypeName.LowerCamel %>.Id - return []simsx.SimAccount{}, msg + return []simsx.SimAccount{simAccount}, msg } } func MsgDelete<%= TypeName.UpperCamel %>Factory(k keeper.Keeper) simsx.SimMsgFactoryFn[*types.MsgDelete<%= TypeName.UpperCamel %>] { return func(ctx context.Context, testData *simsx.ChainDataSource, reporter simsx.SimulationReporter) ([]simsx.SimAccount, *types.MsgDelete<%= TypeName.UpperCamel %>) { var ( - simAccount = simtypes.Account{} <%= TypeName.LowerCamel %> = types.<%= TypeName.UpperCamel %>{} msg = &types.MsgDelete<%= TypeName.UpperCamel %>{} - found = false ) + var all<%= TypeName.UpperCamel %> []types.<%= TypeName.UpperCamel %> err := k.<%= TypeName.UpperCamel %>.Walk(ctx, nil, func(key uint64, value types.<%= TypeName.UpperCamel %>) (stop bool, err error) { all<%= TypeName.UpperCamel %> = append(all<%= TypeName.UpperCamel %>, value) @@ -75,20 +74,22 @@ func MsgDelete<%= TypeName.UpperCamel %>Factory(k keeper.Keeper) simsx.SimMsgFac reporter.Skip(err.Error()) return nil, nil } + + simAccount := simsx.SimAccount{} for _, obj := range all<%= TypeName.UpperCamel %> { - simAccount, found = FindAccount(accs, obj.<%= MsgSigner.UpperCamel %>) - if found { - <%= TypeName.LowerCamel %> = obj + if ok := testData.HasAccount(obj.<%= MsgSigner.UpperCamel %>); ok { + simAccount = testData.GetAccount(reporter, obj.<%= MsgSigner.UpperCamel %>) break } } - if !found { + if simAccount.Address.Empty() { reporter.Skip("<%= TypeName.LowerCamel %> <%= MsgSigner.LowerCamel %> not found") return nil, nil } - msg.<%= MsgSigner.UpperCamel %> = simAccount.Address.String() + + msg.<%= MsgSigner.UpperCamel %> = simAccount.AddressBech32 msg.Id = <%= TypeName.LowerCamel %>.Id - return []simsx.SimAccount{}, msg + return []simsx.SimAccount{simAccount}, msg } } 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 02af59d508..b5a1380200 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 @@ -32,7 +32,6 @@ func MsgCreate<%= TypeName.UpperCamel %>Factory(k keeper.Keeper) simsx.SimMsgFac func MsgUpdate<%= TypeName.UpperCamel %>Factory(k keeper.Keeper) simsx.SimMsgFactoryFn[*types.MsgUpdate<%= TypeName.UpperCamel %>] { return func(ctx context.Context, testData *simsx.ChainDataSource, reporter simsx.SimulationReporter) ([]simsx.SimAccount, *types.MsgUpdate<%= TypeName.UpperCamel %>) { var ( - simAccount = simtypes.Account{} <%= TypeName.LowerCamel %> = types.<%= TypeName.UpperCamel %>{} msg = &types.MsgUpdate<%= TypeName.UpperCamel %>{} found = false @@ -47,32 +46,33 @@ func MsgUpdate<%= TypeName.UpperCamel %>Factory(k keeper.Keeper) simsx.SimMsgFac reporter.Skip(err.Error()) return nil, nil } + + simAccount := simsx.SimAccount{} for _, obj := range all<%= TypeName.UpperCamel %> { - simAccount, found = FindAccount(accs, obj.<%= MsgSigner.UpperCamel %>) - if found { - <%= TypeName.LowerCamel %> = obj + if ok := testData.HasAccount(obj.<%= MsgSigner.UpperCamel %>); ok { + simAccount = testData.GetAccount(reporter, obj.<%= MsgSigner.UpperCamel %>) break } } - if !found { + if simAccount.Address.Empty() { reporter.Skip("<%= TypeName.LowerCamel %> <%= MsgSigner.LowerCamel %> not found") return nil, nil } - msg.<%= MsgSigner.UpperCamel %> = simAccount.Address.String() + + msg.<%= MsgSigner.UpperCamel %> = simAccount.AddressBech32 msg.<%= Index.Name.UpperCamel %> = <%= TypeName.LowerCamel %>.<%= Index.Name.UpperCamel %> - return []simsx.SimAccount{}, msg + return []simsx.SimAccount{simAccount}, msg } } func MsgDelete<%= TypeName.UpperCamel %>Factory(k keeper.Keeper) simsx.SimMsgFactoryFn[*types.MsgDelete<%= TypeName.UpperCamel %>] { return func(ctx context.Context, testData *simsx.ChainDataSource, reporter simsx.SimulationReporter) ([]simsx.SimAccount, *types.MsgDelete<%= TypeName.UpperCamel %>) { var ( - simAccount = simtypes.Account{} <%= TypeName.LowerCamel %> = types.<%= TypeName.UpperCamel %>{} - msg = &types.MsgUpdate<%= TypeName.UpperCamel %>{} - found = false + msg = &types.MsgDelete<%= TypeName.UpperCamel %>{} ) + var all<%= TypeName.UpperCamel %> []types.<%= TypeName.UpperCamel %> err := k.<%= TypeName.UpperCamel %>.Walk(ctx, nil, func(key <%= Index.DataType() %>, value types.<%= TypeName.UpperCamel %>) (stop bool, err error) { all<%= TypeName.UpperCamel %> = append(all<%= TypeName.UpperCamel %>, value) @@ -82,20 +82,22 @@ func MsgDelete<%= TypeName.UpperCamel %>Factory(k keeper.Keeper) simsx.SimMsgFac reporter.Skip(err.Error()) return nil, nil } + + simAccount := simsx.SimAccount{} for _, obj := range all<%= TypeName.UpperCamel %> { - simAccount, found = FindAccount(accs, obj.<%= MsgSigner.UpperCamel %>) - if found { - <%= TypeName.LowerCamel %> = obj + if ok := testData.HasAccount(obj.<%= MsgSigner.UpperCamel %>); ok { + simAccount = testData.GetAccount(reporter, obj.<%= MsgSigner.UpperCamel %>) break } } - if !found { + if simAccount.Address.Empty() { reporter.Skip("<%= TypeName.LowerCamel %> <%= MsgSigner.LowerCamel %> not found") return nil, nil } - msg.<%= MsgSigner.UpperCamel %> = simAccount.Address.String() + + msg.<%= MsgSigner.UpperCamel %> = simAccount.AddressBech32 msg.<%= Index.Name.UpperCamel %> = <%= TypeName.LowerCamel %>.<%= Index.Name.UpperCamel %> - return []simsx.SimAccount{}, msg + return []simsx.SimAccount{simAccount}, msg } } diff --git a/ignite/templates/typed/singleton/files/simapp/x/{{moduleName}}/simulation/{{typeName}}.go.plush b/ignite/templates/typed/singleton/files/simapp/x/{{moduleName}}/simulation/{{typeName}}.go.plush index e0230c2ecc..6da0850a6e 100644 --- a/ignite/templates/typed/singleton/files/simapp/x/{{moduleName}}/simulation/{{typeName}}.go.plush +++ b/ignite/templates/typed/singleton/files/simapp/x/{{moduleName}}/simulation/{{typeName}}.go.plush @@ -13,10 +13,10 @@ import ( func MsgCreate<%= TypeName.UpperCamel %>Factory(k keeper.Keeper) simsx.SimMsgFactoryFn[*types.MsgCreate<%= TypeName.UpperCamel %>] { return func(ctx context.Context, testData *simsx.ChainDataSource, reporter simsx.SimulationReporter) ([]simsx.SimAccount, *types.MsgCreate<%= TypeName.UpperCamel %>) { from := testData.AnyAccount(reporter) - msg := &types.MsgCreate<%= TypeName.UpperCamel %>{ <%= MsgSigner.UpperCamel %>: from.AddressBech32, } + found, err := k.<%= TypeName.UpperCamel %>.Has(ctx) if err == nil && found { reporter.Skip("<%= TypeName.UpperCamel %> already exist") @@ -30,43 +30,37 @@ func MsgCreate<%= TypeName.UpperCamel %>Factory(k keeper.Keeper) simsx.SimMsgFac func MsgUpdate<%= TypeName.UpperCamel %>Factory(k keeper.Keeper) simsx.SimMsgFactoryFn[*types.MsgUpdate<%= TypeName.UpperCamel %>] { return func(ctx context.Context, testData *simsx.ChainDataSource, reporter simsx.SimulationReporter) ([]simsx.SimAccount, *types.MsgUpdate<%= TypeName.UpperCamel %>) { var ( - simAccount = simtypes.Account{} msg = &types.MsgUpdate<%= TypeName.UpperCamel %>{} - <%= TypeName.LowerCamel %>, err = k.<%= TypeName.UpperCamel %>.Get(ctx) ) + + <%= TypeName.LowerCamel %>, err := k.<%= TypeName.UpperCamel %>.Get(ctx) if err != nil { reporter.Skip("<%= TypeName.LowerCamel %> store is empty") return nil, nil } - simAccount, found := FindAccount(accs, <%= TypeName.LowerCamel %>.<%= MsgSigner.UpperCamel %>) - if !found { - reporter.Skip("<%= TypeName.LowerCamel %> <%= MsgSigner.LowerCamel %> not found") - return nil, nil - } - msg.<%= MsgSigner.UpperCamel %> = simAccount.Address.String() - return []simsx.SimAccount{}, msg + simAccount := testData.GetAccount(reporter, <%= TypeName.LowerCamel %>.<%= MsgSigner.UpperCamel %>) + msg.<%= MsgSigner.UpperCamel %> = simAccount.AddressBech32 + + return []simsx.SimAccount{simAccount}, msg } } func MsgDelete<%= TypeName.UpperCamel %>Factory(k keeper.Keeper) simsx.SimMsgFactoryFn[*types.MsgDelete<%= TypeName.UpperCamel %>] { return func(ctx context.Context, testData *simsx.ChainDataSource, reporter simsx.SimulationReporter) ([]simsx.SimAccount, *types.MsgDelete<%= TypeName.UpperCamel %>) { var ( - simAccount = simtypes.Account{} - msg = &types.MsgUpdate<%= TypeName.UpperCamel %>{} - <%= TypeName.LowerCamel %>, err = k.<%= TypeName.UpperCamel %>.Get(ctx) + msg = &types.MsgDelete<%= TypeName.UpperCamel %>{} ) + + <%= TypeName.LowerCamel %>, err := k.<%= TypeName.UpperCamel %>.Get(ctx) if err != nil { reporter.Skip("<%= TypeName.LowerCamel %> store is empty") return nil, nil } - simAccount, found := FindAccount(accs, <%= TypeName.LowerCamel %>.<%= MsgSigner.UpperCamel %>) - if !found { - reporter.Skip("<%= TypeName.LowerCamel %> <%= MsgSigner.LowerCamel %> not found") - return nil, nil - } - msg.<%= MsgSigner.UpperCamel %> = simAccount.Address.String() - return []simsx.SimAccount{}, msg + simAccount := testData.GetAccount(reporter, <%= TypeName.LowerCamel %>.<%= MsgSigner.UpperCamel %>) + msg.<%= MsgSigner.UpperCamel %> = simAccount.AddressBech32 + + return []simsx.SimAccount{simAccount}, msg } }