diff --git a/modules/apps/27-interchain-accounts/controller/keeper/account.go b/modules/apps/27-interchain-accounts/controller/keeper/account.go index 9ed66f6b3b1..bf0135d63d6 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/account.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/account.go @@ -76,7 +76,7 @@ func (k Keeper) registerInterchainAccount(ctx context.Context, connectionID, por } } - sdkCtx := sdk.UnwrapSDKContext(ctx) //TODO: remove when Upgrading to 52 + sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: remove when Upgrading to 52 msg := channeltypes.NewMsgChannelOpenInit(portID, version, ordering, []string{connectionID}, icatypes.HostPortID, authtypes.NewModuleAddress(icatypes.ModuleName).String()) handler := k.msgRouter.Handler(msg) res, err := handler(sdkCtx, msg) diff --git a/modules/apps/29-fee/keeper/escrow.go b/modules/apps/29-fee/keeper/escrow.go index a982e85960a..d91eeb0f756 100644 --- a/modules/apps/29-fee/keeper/escrow.go +++ b/modules/apps/29-fee/keeper/escrow.go @@ -154,7 +154,7 @@ func (k Keeper) distributePacketFeeOnTimeout(ctx context.Context, refundAddr, ti // the state changes will be discarded. func (k Keeper) distributeFee(ctx context.Context, receiver, refundAccAddress sdk.AccAddress, fee sdk.Coins) { // cache context before trying to distribute fees - sdkCtx := sdk.UnwrapSDKContext(ctx) //TODO: remove when Upgrading to 52 + sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: remove when Upgrading to 52 cacheCtx, writeFn := sdkCtx.CacheContext() err := k.bankKeeper.SendCoinsFromModuleToAccount(cacheCtx, types.ModuleName, receiver, fee) diff --git a/modules/apps/29-fee/keeper/events.go b/modules/apps/29-fee/keeper/events.go index 92ea87f757c..7a93f8bb00c 100644 --- a/modules/apps/29-fee/keeper/events.go +++ b/modules/apps/29-fee/keeper/events.go @@ -27,7 +27,7 @@ func emitIncentivizedPacketEvent(ctx context.Context, packetID channeltypes.Pack totalTimeoutFees = totalTimeoutFees.Add(fee.Fee.TimeoutFee...) } } - sdkCtx := sdk.UnwrapSDKContext(ctx) //TODO: remove when Upgrading to 52 + sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: remove when Upgrading to 52 sdkCtx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeIncentivizedPacket, @@ -47,7 +47,7 @@ func emitIncentivizedPacketEvent(ctx context.Context, packetID channeltypes.Pack // emitRegisterPayeeEvent emits an event containing information of a registered payee for a relayer on a particular channel func emitRegisterPayeeEvent(ctx context.Context, relayer, payee, channelID string) { - sdkCtx := sdk.UnwrapSDKContext(ctx) //TODO: remove when Upgrading to 52 + sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: remove when Upgrading to 52 sdkCtx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeRegisterPayee, @@ -64,7 +64,7 @@ func emitRegisterPayeeEvent(ctx context.Context, relayer, payee, channelID strin // emitRegisterCounterpartyPayeeEvent emits an event containing information of a registered counterparty payee for a relayer on a particular channel func emitRegisterCounterpartyPayeeEvent(ctx context.Context, relayer, counterpartyPayee, channelID string) { - sdkCtx := sdk.UnwrapSDKContext(ctx) //TODO: remove when Upgrading to 52 + sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: remove when Upgrading to 52 sdkCtx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeRegisterCounterpartyPayee, @@ -81,7 +81,7 @@ func emitRegisterCounterpartyPayeeEvent(ctx context.Context, relayer, counterpar // emitDistributeFeeEvent emits an event containing a distribution fee and receiver address func emitDistributeFeeEvent(ctx context.Context, receiver string, fee sdk.Coins) { - sdkCtx := sdk.UnwrapSDKContext(ctx) //TODO: remove when Upgrading to 52 + sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: remove when Upgrading to 52 sdkCtx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeDistributeFee, diff --git a/modules/apps/callbacks/testing/simapp/app.go b/modules/apps/callbacks/testing/simapp/app.go index aa361c81263..b2efd323b6d 100644 --- a/modules/apps/callbacks/testing/simapp/app.go +++ b/modules/apps/callbacks/testing/simapp/app.go @@ -329,7 +329,7 @@ func NewSimApp( bApp.SetParamStore(app.ConsensusParamsKeeper.ParamsStore) // add capability keeper and ScopeToModule for ibc module - app.CapabilityKeeper = capabilitykeeper.NewKeeper(appCodec, keys[capabilitytypes.StoreKey], memKeys[capabilitytypes.MemStoreKey]) + app.CapabilityKeeper = capabilitykeeper.NewKeeper(appCodec, runtime.NewKVStoreService(keys[capabilitytypes.StoreKey]), runtime.NewMemStoreService(memKeys[capabilitytypes.MemStoreKey])) scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibcexported.ModuleName) scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName) diff --git a/modules/capability/keeper/keeper.go b/modules/capability/keeper/keeper.go index e779b071f83..90fca39b99b 100644 --- a/modules/capability/keeper/keeper.go +++ b/modules/capability/keeper/keeper.go @@ -123,7 +123,7 @@ func (k *Keeper) IsSealed() bool { // can't initialize it in a constructor. func (k *Keeper) InitMemStore(ctx context.Context) { // create context with no block gas meter to ensure we do not consume gas during local initialization logic. - sdkCtx := sdk.UnwrapSDKContext(ctx) //TODO: remove after 52 upgrade + sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: remove after 52 upgrade noGasCtx := sdkCtx.WithBlockGasMeter(storetypes.NewInfiniteGasMeter()).WithGasMeter(storetypes.NewInfiniteGasMeter()) // check if memory store has not been initialized yet by checking if initialized flag is nil. @@ -146,7 +146,9 @@ func (k *Keeper) InitMemStore(ctx context.Context) { // set the initialized flag so we don't rerun initialization logic memStore := k.memService.OpenMemoryStore(noGasCtx) - memStore.Set(types.KeyMemInitialized, []byte{1}) + if err := memStore.Set(types.KeyMemInitialized, []byte{1}); err != nil { + panic(err) + } } } @@ -174,7 +176,9 @@ func (k Keeper) InitializeIndex(ctx context.Context, index uint64) error { // set the global index to the passed index store := k.storeService.OpenKVStore(ctx) - store.Set(types.KeyIndex, types.IndexToKey(index)) + if err := store.Set(types.KeyIndex, types.IndexToKey(index)); err != nil { + panic(err) + } return nil } @@ -224,13 +228,17 @@ func (k Keeper) InitializeCapability(ctx context.Context, index uint64, owners t for _, owner := range owners.Owners { // Set the forward mapping between the module and capability tuple and the // capability name in the memKVStore - memStore.Set(types.FwdCapabilityKey(owner.Module, capability), []byte(owner.Name)) + if err := memStore.Set(types.FwdCapabilityKey(owner.Module, capability), []byte(owner.Name)); err != nil { + panic(err) + } // Set the reverse mapping between the module and capability name and the // index in the in-memory store. Since marshalling and unmarshalling into a store // will change memory address of capability, we simply store index as value here // and retrieve the in-memory pointer to the capability from our map - memStore.Set(types.RevCapabilityKey(owner.Module, owner.Name), sdk.Uint64ToBigEndian(index)) + if err := memStore.Set(types.RevCapabilityKey(owner.Module, owner.Name), sdk.Uint64ToBigEndian(index)); err != nil { + panic(err) + } // Set the mapping from index to in-memory capability in the go map k.capMap[index] = capability @@ -253,7 +261,7 @@ func (sk ScopedKeeper) NewCapability(ctx context.Context, name string) (*types.C store := sk.storeService.OpenKVStore(ctx) if _, ok := sk.GetCapability(ctx, name); ok { - return nil, errorsmod.Wrapf(types.ErrCapabilityTaken, fmt.Sprintf("module: %s, name: %s", sk.module, name)) + return nil, errorsmod.Wrapf(types.ErrCapabilityTaken, "module: %s, name: %s", sk.module, name) } // create new capability with the current global index @@ -270,19 +278,25 @@ func (sk ScopedKeeper) NewCapability(ctx context.Context, name string) (*types.C } // increment global index - store.Set(types.KeyIndex, types.IndexToKey(index+1)) + if err := store.Set(types.KeyIndex, types.IndexToKey(index+1)); err != nil { + panic(err) + } memStore := sk.memService.OpenMemoryStore(ctx) // Set the forward mapping between the module and capability tuple and the // capability name in the memKVStore - memStore.Set(types.FwdCapabilityKey(sk.module, capability), []byte(name)) + if err := memStore.Set(types.FwdCapabilityKey(sk.module, capability), []byte(name)); err != nil { + panic(err) + } // Set the reverse mapping between the module and capability name and the // index in the in-memory store. Since marshalling and unmarshalling into a store // will change memory address of capability, we simply store index as value here // and retrieve the in-memory pointer to the capability from our map - memStore.Set(types.RevCapabilityKey(sk.module, name), sdk.Uint64ToBigEndian(index)) + if err := memStore.Set(types.RevCapabilityKey(sk.module, name), sdk.Uint64ToBigEndian(index)); err != nil { + panic(err) + } // Set the mapping from index to in-memory capability in the go map sk.capMap[index] = capability @@ -328,13 +342,17 @@ func (sk ScopedKeeper) ClaimCapability(ctx context.Context, cap *types.Capabilit // Set the forward mapping between the module and capability tuple and the // capability name in the memKVStore - memStore.Set(types.FwdCapabilityKey(sk.module, cap), []byte(name)) + if err := memStore.Set(types.FwdCapabilityKey(sk.module, cap), []byte(name)); err != nil { + panic(err) + } // Set the reverse mapping between the module and capability name and the // index in the in-memory store. Since marshalling and unmarshalling into a store // will change memory address of capability, we simply store index as value here // and retrieve the in-memory pointer to the capability from our map - memStore.Set(types.RevCapabilityKey(sk.module, name), sdk.Uint64ToBigEndian(cap.GetIndex())) + if err := memStore.Set(types.RevCapabilityKey(sk.module, name), sdk.Uint64ToBigEndian(cap.GetIndex())); err != nil { + panic(err) + } logger(ctx).Info("claimed capability", "module", sk.module, "name", name, "capability", cap.GetIndex()) @@ -357,11 +375,15 @@ func (sk ScopedKeeper) ReleaseCapability(ctx context.Context, cap *types.Capabil // Delete the forward mapping between the module and capability tuple and the // capability name in the memKVStore - memStore.Delete(types.FwdCapabilityKey(sk.module, cap)) + if err := memStore.Delete(types.FwdCapabilityKey(sk.module, cap)); err != nil { + panic(err) + } // Delete the reverse mapping between the module and capability name and the // index in the in-memory store. - memStore.Delete(types.RevCapabilityKey(sk.module, name)) + if err := memStore.Delete(types.RevCapabilityKey(sk.module, name)); err != nil { + panic(err) + } // remove owner capOwners := sk.getOwners(ctx, cap) @@ -522,6 +544,6 @@ func (sk ScopedKeeper) getOwners(ctx context.Context, cap *types.Capability) *ty } func logger(ctx context.Context) log.Logger { - sdkCtx := sdk.UnwrapSDKContext(ctx) //TODO: remove after 52 upgrade + sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: remove after 52 upgrade return sdkCtx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } diff --git a/modules/light-clients/08-wasm/testing/simapp/app.go b/modules/light-clients/08-wasm/testing/simapp/app.go index d7b4f88fe69..f925bf18a9a 100644 --- a/modules/light-clients/08-wasm/testing/simapp/app.go +++ b/modules/light-clients/08-wasm/testing/simapp/app.go @@ -336,7 +336,7 @@ func NewSimApp( bApp.SetParamStore(app.ConsensusParamsKeeper.ParamsStore) // add capability keeper and ScopeToModule for ibc module - app.CapabilityKeeper = capabilitykeeper.NewKeeper(appCodec, keys[capabilitytypes.StoreKey], memKeys[capabilitytypes.MemStoreKey]) + app.CapabilityKeeper = capabilitykeeper.NewKeeper(appCodec, runtime.NewKVStoreService(keys[capabilitytypes.StoreKey]), runtime.NewMemStoreService(memKeys[capabilitytypes.MemStoreKey])) scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibcexported.ModuleName) scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName) diff --git a/testing/simapp/app.go b/testing/simapp/app.go index be93c95ce9e..dd96cb9f53d 100644 --- a/testing/simapp/app.go +++ b/testing/simapp/app.go @@ -306,7 +306,7 @@ func NewSimApp( bApp.SetParamStore(app.ConsensusParamsKeeper.ParamsStore) // add capability keeper and ScopeToModule for ibc module - app.CapabilityKeeper = capabilitykeeper.NewKeeper(appCodec, runtime.NewKVStoreService(keys[capabilitytypes.StoreKey]), memKeys[capabilitytypes.MemStoreKey]) + app.CapabilityKeeper = capabilitykeeper.NewKeeper(appCodec, runtime.NewKVStoreService(keys[capabilitytypes.StoreKey]), runtime.NewMemStoreService(memKeys[capabilitytypes.MemStoreKey])) scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibcexported.ModuleName) scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName)