diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a6d4ada40..fe5450b6e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,6 +56,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (x/collection) [\#955](https://github.com/line/lbm-sdk/pull/955) Return nil where the parent not exists in x/collection Query/Parent * (x/collection) [\#959](https://github.com/line/lbm-sdk/pull/959) Revert #955 and add Query/HasParent into x/collection * (x/collection) [\#960](https://github.com/line/lbm-sdk/pull/960) Fix default next class ids of x/collection +* (x/collection) [\#961](https://github.com/line/lbm-sdk/pull/961) Do not loop enum in x/collection ### Removed diff --git a/x/collection/keeper/supply.go b/x/collection/keeper/supply.go index bc7f9f8a62..bedd0332ca 100644 --- a/x/collection/keeper/supply.go +++ b/x/collection/keeper/supply.go @@ -26,15 +26,13 @@ func (k Keeper) CreateContract(ctx sdk.Context, creator sdk.AccAddress, contract Grantee: creator.String(), } ctx.EventManager().EmitEvent(collection.NewEventGrantPermTokenHead(eventGrant)) - for _, permission := range collection.Permission_value { - p := collection.Permission(permission) - if p == collection.PermissionUnspecified { - continue - } + // 0 is "unspecified" + for i := 1; i < len(collection.Permission_value); i++ { + p := collection.Permission(i) eventGrant.Permission = p ctx.EventManager().EmitEvent(collection.NewEventGrantPermTokenBody(eventGrant)) - k.Grant(ctx, contractID, []byte{}, creator, collection.Permission(permission)) + k.Grant(ctx, contractID, []byte{}, creator, p) } return contractID diff --git a/x/collection/module/module.go b/x/collection/module/module.go index e2bb57dcf7..4c3892108e 100644 --- a/x/collection/module/module.go +++ b/x/collection/module/module.go @@ -109,14 +109,6 @@ func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sd func (am AppModule) RegisterServices(cfg module.Configurator) { collection.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServer(am.keeper)) collection.RegisterQueryServer(cfg.QueryServer(), keeper.NewQueryServer(am.keeper, am.authKeeper)) - - // m := keeper.NewMigrator(am.keeper) - // migrations := map[uint64]func(sdk.Context) error{} - // for ver, handler := range migrations { - // if err := cfg.RegisterMigration(collection.ModuleName, ver, handler); err != nil { - // panic(fmt.Sprintf("failed to migrate x/%s from version %d to %d: %v", collection.ModuleName, ver, ver+1, err)) - // } - // } } // InitGenesis performs genesis initialization for the collection module. It returns diff --git a/x/foundation/module/module.go b/x/foundation/module/module.go index f4dbf3a438..ac3de5db88 100644 --- a/x/foundation/module/module.go +++ b/x/foundation/module/module.go @@ -112,14 +112,6 @@ func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sd func (am AppModule) RegisterServices(cfg module.Configurator) { foundation.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServer(am.keeper)) foundation.RegisterQueryServer(cfg.QueryServer(), keeper.NewQueryServer(am.keeper)) - - // m := keeper.NewMigrator(am.keeper) - // migrations := map[uint64]func(sdk.Context) error{} - // for ver, handler := range migrations { - // if err := cfg.RegisterMigration(foundation.ModuleName, ver, handler); err != nil { - // panic(fmt.Sprintf("failed to migrate x/%s from version %d to %d: %v", foundation.ModuleName, ver, ver+1, err)) - // } - // } } // InitGenesis performs genesis initialization for the foundation module. It returns diff --git a/x/stakingplus/module/module.go b/x/stakingplus/module/module.go index 3529b32241..bc8d6a446d 100644 --- a/x/stakingplus/module/module.go +++ b/x/stakingplus/module/module.go @@ -90,14 +90,6 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { stakingtypes.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper, am.fk)) querier := stakingkeeper.Querier{Keeper: am.keeper} stakingtypes.RegisterQueryServer(cfg.QueryServer(), querier) - - // m := keeper.NewMigrator(am.keeper) - // migrations := map[uint64]func(sdk.Context) error{} - // for ver, handler := range migrations { - // if err := cfg.RegisterMigration(foundation.ModuleName, ver, handler); err != nil { - // panic(fmt.Sprintf("failed to migrate x/%s from version %d to %d: %v", stakingplus.ModuleName, ver, ver+1, err)) - // } - // } } // InitGenesis performs genesis initialization for the stakingplus module. It returns diff --git a/x/token/module/module.go b/x/token/module/module.go index daf0346e1c..e3b01d9eee 100644 --- a/x/token/module/module.go +++ b/x/token/module/module.go @@ -109,14 +109,6 @@ func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sd func (am AppModule) RegisterServices(cfg module.Configurator) { token.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServer(am.keeper)) token.RegisterQueryServer(cfg.QueryServer(), keeper.NewQueryServer(am.keeper, am.authKeeper)) - - // m := keeper.NewMigrator(am.keeper) - // migrations := map[uint64]func(sdk.Context) error{} - // for ver, handler := range migrations { - // if err := cfg.RegisterMigration(token.ModuleName, ver, handler); err != nil { - // panic(fmt.Sprintf("failed to migrate x/%s from version %d to %d: %v", token.ModuleName, ver, ver+1, err)) - // } - // } } // InitGenesis performs genesis initialization for the token module. It returns