diff --git a/ignite/templates/typed/map/files/component/x/{{moduleName}}/keeper/query_{{typeName}}.go.plush b/ignite/templates/typed/map/files/component/x/{{moduleName}}/keeper/query_{{typeName}}.go.plush index 0047994c08..437bf3a53c 100644 --- a/ignite/templates/typed/map/files/component/x/{{moduleName}}/keeper/query_{{typeName}}.go.plush +++ b/ignite/templates/typed/map/files/component/x/{{moduleName}}/keeper/query_{{typeName}}.go.plush @@ -11,21 +11,19 @@ import ( "google.golang.org/grpc/status" ) -func (q queryServer) List<%= TypeName.UpperCamel %>(ctx context.Context, req *types.QueryAll<%= TypeName.UpperCamel %>Request) (*types.QueryAll<%= TypeName.UpperCamel %>Response, error) { +func (s queryServer) List<%= TypeName.UpperCamel %>(ctx context.Context, req *types.QueryAll<%= TypeName.UpperCamel %>Request) (*types.QueryAll<%= TypeName.UpperCamel %>Response, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") } var <%= TypeName.LowerCamel %>s []types.<%= TypeName.UpperCamel %> - // TODO use collections - - store := runtime.KVStoreAdapter(q.k.storeService.OpenKVStore(ctx)) + store := runtime.KVStoreAdapter(s.k.storeService.OpenKVStore(ctx)) <%= TypeName.LowerCamel %>Store := prefix.NewStore(store, types.KeyPrefix(types.<%= TypeName.UpperCamel %>KeyPrefix)) pageRes, err := query.Paginate(<%= TypeName.LowerCamel %>Store, req.Pagination, func(key []byte, value []byte) error { var <%= TypeName.LowerCamel %> types.<%= TypeName.UpperCamel %> - if err := q.k.cdc.Unmarshal(value, &<%= TypeName.LowerCamel %>); err != nil { + if err := s.k.cdc.Unmarshal(value, &<%= TypeName.LowerCamel %>); err != nil { return err } @@ -40,16 +38,16 @@ func (q queryServer) List<%= TypeName.UpperCamel %>(ctx context.Context, req *ty return &types.QueryAll<%= TypeName.UpperCamel %>Response{<%= TypeName.UpperCamel %>: <%= TypeName.LowerCamel %>s, Pagination: pageRes}, nil } -func (q queryServer) Get<%= TypeName.UpperCamel %>(ctx context.Context, req *types.QueryGet<%= TypeName.UpperCamel %>Request) (*types.QueryGet<%= TypeName.UpperCamel %>Response, error) { +func (s queryServer) Get<%= TypeName.UpperCamel %>(ctx context.Context, req *types.QueryGet<%= TypeName.UpperCamel %>Request) (*types.QueryGet<%= TypeName.UpperCamel %>Response, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") } - val, err := q.k.<%= TypeName.UpperCamel %>.Get( + val, found := s.k.Get<%= TypeName.UpperCamel %>( ctx, <%= for (i, index) in Indexes { %>req.<%= index.Name.UpperCamel %>, <% } %>) - if err != nil { + if !found { return nil, status.Error(codes.NotFound, "not found") } diff --git a/ignite/templates/typed/map/files/component/x/{{moduleName}}/keeper/{{typeName}}.go.plush b/ignite/templates/typed/map/files/component/x/{{moduleName}}/keeper/{{typeName}}.go.plush new file mode 100644 index 0000000000..a0c681ce6a --- /dev/null +++ b/ignite/templates/typed/map/files/component/x/{{moduleName}}/keeper/{{typeName}}.go.plush @@ -0,0 +1,70 @@ +package keeper + +import ( + "context" + + "cosmossdk.io/store/prefix" + storetypes "cosmossdk.io/store/types" + "github.com/cosmos/cosmos-sdk/runtime" + "<%= ModulePath %>/x/<%= ModuleName %>/types" +) + +// Set<%= TypeName.UpperCamel %> set a specific <%= TypeName.LowerCamel %> in the store from its index +func (k Keeper) Set<%= TypeName.UpperCamel %>(ctx context.Context, <%= TypeName.LowerCamel %> types.<%= TypeName.UpperCamel %>) { + storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + store := prefix.NewStore(storeAdapter, types.KeyPrefix(types.<%= TypeName.UpperCamel %>KeyPrefix)) + b := k.cdc.MustMarshal(&<%= TypeName.LowerCamel %>) + store.Set(types.<%= TypeName.UpperCamel %>Key( + <%= for (i, index) in Indexes { %><%= TypeName.LowerCamel %>.<%= index.Name.UpperCamel %>, + <% } %>), b) +} + +// Get<%= TypeName.UpperCamel %> returns a <%= TypeName.LowerCamel %> from its index +func (k Keeper) Get<%= TypeName.UpperCamel %>( + ctx context.Context, + <%= for (i, index) in Indexes { %><%= index.Name.LowerCamel %> <%= index.DataType() %>, + <% } %> +) (val types.<%= TypeName.UpperCamel %>, found bool) { + storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + store := prefix.NewStore(storeAdapter, types.KeyPrefix(types.<%= TypeName.UpperCamel %>KeyPrefix)) + + b := store.Get(types.<%= TypeName.UpperCamel %>Key( + <%= for (i, index) in Indexes { %><%= index.Name.LowerCamel %>, + <% } %>)) + if b == nil { + return val, false + } + + k.cdc.MustUnmarshal(b, &val) + return val, true +} + +// Remove<%= TypeName.UpperCamel %> removes a <%= TypeName.LowerCamel %> from the store +func (k Keeper) Remove<%= TypeName.UpperCamel %>( + ctx context.Context, + <%= for (i, index) in Indexes { %><%= index.Name.LowerCamel %> <%= index.DataType() %>, + <% } %> +) { + storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + store := prefix.NewStore(storeAdapter, types.KeyPrefix(types.<%= TypeName.UpperCamel %>KeyPrefix)) + store.Delete(types.<%= TypeName.UpperCamel %>Key( + <%= for (i, index) in Indexes { %><%= index.Name.LowerCamel %>, + <% } %>)) +} + +// GetAll<%= TypeName.UpperCamel %> returns all <%= TypeName.LowerCamel %> +func (k Keeper) GetAll<%= TypeName.UpperCamel %>(ctx context.Context) (list []types.<%= TypeName.UpperCamel %>) { + storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + store := prefix.NewStore(storeAdapter, types.KeyPrefix(types.<%= TypeName.UpperCamel %>KeyPrefix)) + iterator := storetypes.KVStorePrefixIterator(store, []byte{}) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val types.<%= TypeName.UpperCamel %> + k.cdc.MustUnmarshal(iterator.Value(), &val) + list = append(list, val) + } + + return +} diff --git a/ignite/templates/typed/map/files/messages/x/{{moduleName}}/keeper/msg_server_{{typeName}}.go.plush b/ignite/templates/typed/map/files/messages/x/{{moduleName}}/keeper/msg_server_{{typeName}}.go.plush index 4544bee01a..7de02e781f 100644 --- a/ignite/templates/typed/map/files/messages/x/{{moduleName}}/keeper/msg_server_{{typeName}}.go.plush +++ b/ignite/templates/typed/map/files/messages/x/{{moduleName}}/keeper/msg_server_{{typeName}}.go.plush @@ -4,60 +4,47 @@ import ( "context" "<%= ModulePath %>/x/<%= ModuleName %>/types" - "cosmossdk.io/collections" - errorsmod "cosmossdk.io/errors" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + errorsmod "cosmossdk.io/errors" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) func (k msgServer) Create<%= TypeName.UpperCamel %>(ctx context.Context, msg *types.MsgCreate<%= TypeName.UpperCamel %>) (*types.MsgCreate<%= TypeName.UpperCamel %>Response, error) { // Check if the value already exists - // TODO need to limit max nb of indexes - ok, err := k.<%= TypeName.UpperCamel %>.Has( + _, isFound := k.Get<%= TypeName.UpperCamel %>( ctx, <%= for (i, index) in Indexes { %>msg.<%= index.Name.UpperCamel %>, <% } %>) - if err != nil { - return nil, errorsmod.Wrap(sdkerrors.ErrLogic, err.Error()) - } else if ok { + if isFound { return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "index already set") } var <%= TypeName.LowerCamel %> = types.<%= TypeName.UpperCamel %>{ - <%= MsgSigner.UpperCamel %>: msg.<%= MsgSigner.UpperCamel %>, - <%= for (i, index) in Indexes { %><%= index.Name.UpperCamel %>: msg.<%= index.Name.UpperCamel %>, + <%= MsgSigner.UpperCamel %>: msg.<%= MsgSigner.UpperCamel %>, + <%= for (i, index) in Indexes { %><%= index.Name.UpperCamel %>: msg.<%= index.Name.UpperCamel %>, <% } %><%= for (field) in Fields { %><%= field.Name.UpperCamel %>: msg.<%= field.Name.UpperCamel %>, - <% } %> - } + <% } %> + } - if err := k.<%= TypeName.UpperCamel %>.Set( + k.Set<%= TypeName.UpperCamel %>( ctx, - <%= for (i, index) in Indexes { %>msg.<%= index.Name.UpperCamel %>, - <% } %> <%= TypeName.LowerCamel %>, - ); err != nil { - return nil, errorsmod.Wrap(sdkerrors.ErrLogic, err.Error()) - } - - return &types.MsgCreate<%= TypeName.UpperCamel %>Response{}, nil + ) + return &types.MsgCreate<%= TypeName.UpperCamel %>Response{}, nil } func (k msgServer) Update<%= TypeName.UpperCamel %>(ctx context.Context, msg *types.MsgUpdate<%= TypeName.UpperCamel %>) (*types.MsgUpdate<%= TypeName.UpperCamel %>Response, error) { // Check if the value exists - val, err := k.<%= TypeName.UpperCamel %>.Get( + valFound, isFound := k.Get<%= TypeName.UpperCamel %>( ctx, <%= for (i, index) in Indexes { %>msg.<%= index.Name.UpperCamel %>, <% } %>) - if err != nil { - if errors.Is(err, collections.ErrNotFound) { - return nil, errorsmod.Wrap(sdkerrors.ErrKeyNotFound, "index not set") - } - - return nil, errorsmod.Wrap(sdkerrors.ErrLogic, err.Error()) + if !isFound { + return nil, errorsmod.Wrap(sdkerrors.ErrKeyNotFound, "index not set") } // Checks if the msg <%= MsgSigner.LowerCamel %> is the same as the current owner - if msg.<%= MsgSigner.UpperCamel %> != val.<%= MsgSigner.UpperCamel %> { + if msg.<%= MsgSigner.UpperCamel %> != valFound.<%= MsgSigner.UpperCamel %> { return nil, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "incorrect owner") } @@ -68,33 +55,27 @@ func (k msgServer) Update<%= TypeName.UpperCamel %>(ctx context.Context, msg *t <% } %> } - if err := k.<%= TypeName.UpperCamel %>.Set(ctx, <%= TypeName.LowerCamel %>.Index, <%= TypeName.LowerCamel %>); err != nil { - return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "failed to set <%= TypeName.LowerCamel %>") - } + k.Set<%= TypeName.UpperCamel %>(ctx, <%= TypeName.LowerCamel %>) return &types.MsgUpdate<%= TypeName.UpperCamel %>Response{}, nil } func (k msgServer) Delete<%= TypeName.UpperCamel %>(ctx context.Context, msg *types.MsgDelete<%= TypeName.UpperCamel %>) (*types.MsgDelete<%= TypeName.UpperCamel %>Response, error) { // Check if the value exists - val, err := k.<%= TypeName.UpperCamel %>.Get( + valFound, isFound := k.Get<%= TypeName.UpperCamel %>( ctx, <%= for (i, index) in Indexes { %>msg.<%= index.Name.UpperCamel %>, <% } %>) - if err != nil { - if errors.Is(err, collections.ErrNotFound) { - return nil, errorsmod.Wrap(sdkerrors.ErrKeyNotFound, "index not set") - } - - return nil, errorsmod.Wrap(sdkerrors.ErrLogic, err.Error()) + if !isFound { + return nil, errorsmod.Wrap(sdkerrors.ErrKeyNotFound, "index not set") } // Checks if the msg <%= MsgSigner.LowerCamel %> is the same as the current owner - if msg.<%= MsgSigner.UpperCamel %> != val.<%= MsgSigner.UpperCamel %> { + if msg.<%= MsgSigner.UpperCamel %> != valFound.<%= MsgSigner.UpperCamel %> { return nil, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "incorrect owner") } - k.<%= TypeName.UpperCamel %>.Remove( + k.Remove<%= TypeName.UpperCamel %>( ctx, <%= for (i, index) in Indexes { %>msg.<%= index.Name.UpperCamel %>, <% } %>) 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 fd132c3f54..fb2392f0d4 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 @@ -31,8 +31,8 @@ func SimulateMsgCreate<%= TypeName.UpperCamel %>( <%= index.Name.UpperCamel %>: <%= index.ValueLoop() %>,<% } %> } - found, err := k.<%= TypeName.UpperCamel %>.Has(ctx <%= for (index) in Indexes { %>, msg.<%= index.Name.UpperCamel %><% } %>) - if err == nil && found { + _, found := k.Get<%= TypeName.UpperCamel %>(ctx <%= for (index) in Indexes { %>, msg.<%= index.Name.UpperCamel %><% } %>) + if found { return simtypes.NoOpMsg(types.ModuleName, sdk.MsgTypeURL(msg), "<%= TypeName.UpperCamel %> already exist"), nil, nil } @@ -64,18 +64,9 @@ func SimulateMsgUpdate<%= TypeName.UpperCamel %>( simAccount = simtypes.Account{} <%= TypeName.LowerCamel %> = types.<%= TypeName.UpperCamel %>{} msg = &types.MsgUpdate<%= TypeName.UpperCamel %>{} + all<%= TypeName.UpperCamel %> = k.GetAll<%= TypeName.UpperCamel %>(ctx) found = false ) - - var all<%= TypeName.UpperCamel %> []types.<%= TypeName.UpperCamel %> - err := k.<%= TypeName.UpperCamel %>.Walk(ctx, nil, func(key string, value types.<%= TypeName.UpperCamel %>) (stop bool, err error) { - all<%= TypeName.UpperCamel %> = append(all<%= TypeName.UpperCamel %>, value) - return false, nil - }) - if err != nil { - panic(err) - } - for _, obj := range all<%= TypeName.UpperCamel %> { simAccount, found = FindAccount(accs, obj.<%= MsgSigner.UpperCamel %>) if found { @@ -118,18 +109,9 @@ func SimulateMsgDelete<%= TypeName.UpperCamel %>( simAccount = simtypes.Account{} <%= TypeName.LowerCamel %> = types.<%= TypeName.UpperCamel %>{} msg = &types.MsgUpdate<%= TypeName.UpperCamel %>{} + all<%= TypeName.UpperCamel %> = k.GetAll<%= TypeName.UpperCamel %>(ctx) found = false ) - - var all<%= TypeName.UpperCamel %> []types.<%= TypeName.UpperCamel %> - err := k.<%= TypeName.UpperCamel %>.Walk(ctx, nil, func(key string, value types.<%= TypeName.UpperCamel %>) (stop bool, err error) { - all<%= TypeName.UpperCamel %> = append(all<%= TypeName.UpperCamel %>, value) - return false, nil - }) - if err != nil { - panic(err) - } - for _, obj := range all<%= TypeName.UpperCamel %> { simAccount, found = FindAccount(accs, obj.<%= MsgSigner.UpperCamel %>) if found { diff --git a/ignite/templates/typed/map/files/tests/component/x/{{moduleName}}/keeper/{{typeName}}_test.go.plush b/ignite/templates/typed/map/files/tests/component/x/{{moduleName}}/keeper/{{typeName}}_test.go.plush new file mode 100644 index 0000000000..13f9c5e404 --- /dev/null +++ b/ignite/templates/typed/map/files/tests/component/x/{{moduleName}}/keeper/{{typeName}}_test.go.plush @@ -0,0 +1,66 @@ +package keeper_test + +import ( + "context" + "strconv" + "testing" + + "<%= ModulePath %>/x/<%= ModuleName %>/keeper" + "<%= ModulePath %>/x/<%= ModuleName %>/types" + keepertest "<%= ModulePath %>/testutil/keeper" + "<%= ModulePath %>/testutil/nullify" + "github.com/stretchr/testify/require" +) + +// 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 { + <%= for (i, index) in Indexes { %>items[i].<%= index.Name.UpperCamel %> = <%= index.ValueLoop() %> + <% } %> + keeper.Set<%= TypeName.UpperCamel %>(ctx, items[i]) + } + return items +} + +func Test<%= TypeName.UpperCamel %>Get(t *testing.T) { + keeper, ctx := keepertest.<%= title(ModuleName) %>Keeper(t) + items := createN<%= TypeName.UpperCamel %>(keeper, ctx, 10) + for _, item := range items { + rst, found := keeper.Get<%= TypeName.UpperCamel %>(ctx, + <%= for (i, index) in Indexes { %>item.<%= index.Name.UpperCamel %>, + <% } %> + ) + require.True(t, found) + require.Equal(t, + nullify.Fill(&item), + nullify.Fill(&rst), + ) + } +} +func Test<%= TypeName.UpperCamel %>Remove(t *testing.T) { + keeper, ctx := keepertest.<%= title(ModuleName) %>Keeper(t) + items := createN<%= TypeName.UpperCamel %>(keeper, ctx, 10) + for _, item := range items { + keeper.Remove<%= TypeName.UpperCamel %>(ctx, + <%= for (i, index) in Indexes { %>item.<%= index.Name.UpperCamel %>, + <% } %> + ) + _, found := keeper.Get<%= TypeName.UpperCamel %>(ctx, + <%= for (i, index) in Indexes { %>item.<%= index.Name.UpperCamel %>, + <% } %> + ) + require.False(t, found) + } +} + +func Test<%= TypeName.UpperCamel %>GetAll(t *testing.T) { + keeper, ctx := keepertest.<%= title(ModuleName) %>Keeper(t) + items := createN<%= TypeName.UpperCamel %>(keeper, ctx, 10) + require.ElementsMatch(t, + nullify.Fill(items), + nullify.Fill(keeper.GetAll<%= TypeName.UpperCamel %>(ctx)), + ) +} 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 8131a4e41e..d7160bc455 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 @@ -26,11 +26,11 @@ func Test<%= TypeName.UpperCamel %>MsgServerCreate(t *testing.T) { } _, err := srv.Create<%= TypeName.UpperCamel %>(ctx, expected) require.NoError(t, err) - rst, err := k.<%= TypeName.UpperCamel %>.Get(ctx, + rst, found := k.Get<%= TypeName.UpperCamel %>(ctx, <%= for (i, index) in Indexes { %>expected.<%= index.Name.UpperCamel %>, <% } %> ) - require.NoError(t, err) + require.True(t, found) require.Equal(t, expected.<%= MsgSigner.UpperCamel %>, rst.<%= MsgSigner.UpperCamel %>) } } @@ -83,11 +83,11 @@ func Test<%= TypeName.UpperCamel %>MsgServerUpdate(t *testing.T) { require.ErrorIs(t, err, tc.err) } else { require.NoError(t, err) - rst, err := k.<%= TypeName.UpperCamel %>.Get(ctx, + rst, found := k.Get<%= TypeName.UpperCamel %>(ctx, <%= for (i, index) in Indexes { %>expected.<%= index.Name.UpperCamel %>, <% } %> ) - require.NoError(t, err) + require.True(t, found) require.Equal(t, expected.<%= MsgSigner.UpperCamel %>, rst.<%= MsgSigner.UpperCamel %>) } }) @@ -141,11 +141,10 @@ func Test<%= TypeName.UpperCamel %>MsgServerDelete(t *testing.T) { require.ErrorIs(t, err, tc.err) } else { require.NoError(t, err) - found, err := k.<%= TypeName.UpperCamel %>.Has(ctx, + _, found := k.Get<%= TypeName.UpperCamel %>(ctx, <%= for (i, index) in Indexes { %>tc.request.<%= index.Name.UpperCamel %>, <% } %> ) - require.NoError(t, err) require.False(t, found) } }) diff --git a/ignite/templates/typed/map/map.go b/ignite/templates/typed/map/map.go index 0ebc2598be..a578299ba0 100644 --- a/ignite/templates/typed/map/map.go +++ b/ignite/templates/typed/map/map.go @@ -79,7 +79,6 @@ func NewGenerator(replacer placeholder.Replacer, opts *typed.Options) (*genny.Ge ) g.RunFn(protoRPCModify(opts)) - g.RunFn(keeperModify(replacer, opts)) g.RunFn(clientCliQueryModify(replacer, opts)) g.RunFn(genesisProtoModify(opts)) g.RunFn(genesisTypesModify(replacer, opts)) @@ -118,39 +117,6 @@ func NewGenerator(replacer placeholder.Replacer, opts *typed.Options) (*genny.Ge return g, typed.Box(componentTemplate, opts, g) } -// keeperModify modifies the keeper to add a new collections map type -func keeperModify(replacer placeholder.Replacer, opts *typed.Options) genny.RunFn { - return func(r *genny.Runner) error { - path := filepath.Join(opts.AppPath, "x", opts.ModuleName, "keeper/keeper.go") - f, err := r.Disk.Find(path) - if err != nil { - return err - } - - templateKeeperType := `%[2]v collections.Map[string, types.%[2]v] - %[1]v` - replacementModuleType := fmt.Sprintf( - templateKeeperType, - typed.PlaceholderCollectionType, - opts.TypeName.UpperCamel, - ) - content := replacer.Replace(f.String(), typed.PlaceholderCollectionType, replacementModuleType) - - templateKeeperInstantiate := `%[2]v: collections.NewMap(sb, types.%[2]vKey, "%[3]v", collections.StringKey, codec.CollValue[types.%[2]v](cdc)), - %[1]v` - replacementInstantiate := fmt.Sprintf( - templateKeeperInstantiate, - typed.PlaceholderCollectionInstantiate, - opts.TypeName.UpperCamel, - opts.TypeName.LowerCamel, - ) - content = replacer.Replace(content, typed.PlaceholderCollectionInstantiate, replacementInstantiate) - - newFile := genny.NewFileS(path, content) - return r.File(newFile) - } -} - // Modifies query.proto to add the required RPCs and Messages. // // What it depends on: @@ -419,9 +385,7 @@ func genesisModuleModify(replacer placeholder.Replacer, opts *typed.Options) gen templateModuleInit := `// Set all the %[2]v for _, elem := range genState.%[3]vList { - if err := k.%[3]v.Set(ctx, elem.Index, elem); err != nil { - panic(err) - } + k.Set%[3]v(ctx, elem) } %[1]v` replacementModuleInit := fmt.Sprintf( @@ -433,7 +397,7 @@ for _, elem := range genState.%[3]vList { content := replacer.Replace(f.String(), typed.PlaceholderGenesisModuleInit, replacementModuleInit) templateModuleExport := `genesis.%[3]vList = k.GetAll%[3]v(ctx) -%[1]v` // TODO(@julienrbrt) change GetAll to iterator +%[1]v` replacementModuleExport := fmt.Sprintf( templateModuleExport, typed.PlaceholderGenesisModuleExport,