Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt committed Dec 1, 2024
1 parent be099a5 commit 3ea1a8a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ func MsgUpdate<%= TypeName.UpperCamel %>Factory(k keeper.Keeper) simsx.SimMsgFac
var (
<%= TypeName.LowerCamel %> = types.<%= TypeName.UpperCamel %>{}
msg = &types.MsgUpdate<%= 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package simulation

import (
"math/rand"
"strconv"

"github.com/cosmos/cosmos-sdk/simsx"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand All @@ -10,11 +11,14 @@ import (
"<%= ModulePath %>/x/<%= ModuleName %>/types"
)

// prevent strconv unused error
var _ = strconv.IntSize

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)

i := r.Int()
i := testData.Rand().Int()
msg := &types.MsgCreate<%= TypeName.UpperCamel %>{
<%= MsgSigner.UpperCamel %>: from.AddressBech32,
<%= Index.Name.UpperCamel %>: <%= Index.ValueLoop() %>,
Expand All @@ -34,7 +38,6 @@ func MsgUpdate<%= TypeName.UpperCamel %>Factory(k keeper.Keeper) simsx.SimMsgFac
var (
<%= TypeName.LowerCamel %> = types.<%= TypeName.UpperCamel %>{}
msg = &types.MsgUpdate<%= TypeName.UpperCamel %>{}
found = false
)

var all<%= TypeName.UpperCamel %> []types.<%= TypeName.UpperCamel %>
Expand Down
4 changes: 2 additions & 2 deletions ignite/templates/typed/simulation.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ func ModuleSimulationMsgModify(
// simulation operations
templateOp := `reg.Add(weights.Get("msg_%[4]v", 100 /* determine the simulation weight value */), simulation.Msg%[2]v%[3]vFactory(am.keeper))
%[1]v`
replacementOp := fmt.Sprintf(templateOp, PlaceholderSimappOperation, msg, typeName.UpperCamel, typeName.Snake)
replacementOp := fmt.Sprintf(templateOp, PlaceholderSimappOperation, msg, typeName.UpperCamel, fmt.Sprintf("%s_%s", strings.ToLower(msg), typeName.Snake))
content = replacer.Replace(content, PlaceholderSimappOperation, replacementOp)

if strings.Contains(content, PlaceholderSimappOperationMsg) { // TODO: We need to check if the message has an authority or not
templateOpMsg := `reg.Add(weights.Get("msg_%[4]v", 100), simulation.Msg%[2]v%[3]vFactory(am.keeper))
%[1]v`
replacementOpMsg := fmt.Sprintf(templateOpMsg, PlaceholderSimappOperationMsg, msg, typeName.UpperCamel, typeName.Snake)
replacementOpMsg := fmt.Sprintf(templateOpMsg, PlaceholderSimappOperationMsg, msg, typeName.UpperCamel, fmt.Sprintf("%s_%s", strings.ToLower(msg), typeName.Snake))
content = replacer.Replace(content, PlaceholderSimappOperationMsg, replacementOpMsg)
}
}
Expand Down

0 comments on commit 3ea1a8a

Please sign in to comment.