Skip to content

Commit

Permalink
fix: do not loop enum in x/collection (#961)
Browse files Browse the repository at this point in the history
* Do not loop enum

* Fix comments

* Update CHANGELOG.md

* Update CHANGELOG.md

* Remove unused logics in comments

* Update x/collection/keeper/supply.go
  • Loading branch information
0Tech authored Apr 12, 2023
1 parent 0afcc7d commit 8792d89
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 38 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 4 additions & 6 deletions x/collection/keeper/supply.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 0 additions & 8 deletions x/collection/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 0 additions & 8 deletions x/foundation/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 0 additions & 8 deletions x/stakingplus/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 0 additions & 8 deletions x/token/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8792d89

Please sign in to comment.