diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index 6e6139da3..ff1e3f8b2 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -141,7 +141,11 @@ type AppKeepers struct { TransferKeeper ibctransferkeeper.Keeper WasmKeeper wasm.Keeper // IBC hooks - IBCHooksKeeper ibchookskeeper.Keeper + IBCHooksKeeper ibchookskeeper.Keeper + Ics20WasmHooks ibchooks.WasmHooks + ContractKeeper *wasmkeeper.PermissionedKeeper + HooksTransferIBCModule ibchooks.IBCMiddleware + HooksICS4Wrapper ibchooks.ICS4Middleware NftbackedloanKeeper nftbackedloankeeper.Keeper NftfactoryKeeper nftfactorykeeper.Keeper @@ -377,18 +381,14 @@ func NewAppKeeper( appKeepers.IBCHooksKeeper = ibchookskeeper.NewKeeper( appKeepers.keys[ibchookstypes.StoreKey], ) - ics20WasmHooks := ibchooks.NewWasmHooks(&appKeepers.IBCHooksKeeper, nil, accountAddressPrefix) // The contract keeper needs to be set later - hooksICS4Wrapper := ibchooks.NewICS4Middleware( - appKeepers.IBCKeeper.ChannelKeeper, - ics20WasmHooks, - ) + appKeepers.Ics20WasmHooks = ibchooks.NewWasmHooks(&appKeepers.IBCHooksKeeper, nil, accountAddressPrefix) // The contract keeper needs to be set later // Create Transfer Keepers appKeepers.TransferKeeper = ibctransferkeeper.NewKeeper( appCodec, appKeepers.keys[ibctransfertypes.StoreKey], appKeepers.GetSubspace(ibctransfertypes.ModuleName), - hooksICS4Wrapper, + appKeepers.HooksICS4Wrapper, // essentially still app.IBCKeeper.ChannelKeeper under the hood because no hook overrides appKeepers.IBCKeeper.ChannelKeeper, &appKeepers.IBCKeeper.PortKeeper, appKeepers.AccountKeeper, @@ -451,6 +451,17 @@ func NewAppKeeper( wasmOpts..., ) + // Pass the contract keeper to all the structs (generally ICS4Wrappers for ibc middlewares) that need it + appKeepers.ContractKeeper = wasmkeeper.NewDefaultPermissionKeeper(appKeepers.WasmKeeper) + appKeepers.Ics20WasmHooks.ContractKeeper = &appKeepers.WasmKeeper + appKeepers.HooksICS4Wrapper = ibchooks.NewICS4Middleware( + appKeepers.IBCKeeper.ChannelKeeper, + appKeepers.Ics20WasmHooks, + ) + // Hooks Middleware + transferIBCModule := transfer.NewIBCModule(appKeepers.TransferKeeper) + appKeepers.HooksTransferIBCModule = ibchooks.NewIBCMiddleware(&transferIBCModule, &appKeepers.HooksICS4Wrapper) + // Instantiate the builder keeper, store keys, and module manager appKeepers.BuilderKeeper = builderkeeper.NewKeeper( appCodec, @@ -635,8 +646,6 @@ func NewAppKeeper( transferStack = transfer.NewIBCModule(appKeepers.TransferKeeper) transferStack = records.NewIBCModule(appKeepers.RecordsKeeper, transferStack) transferStack = ibcfee.NewIBCMiddleware(transferStack, appKeepers.IBCFeeKeeper) - // Hooks Middleware - transferStack = ibchooks.NewIBCMiddleware(transferStack, &hooksICS4Wrapper) // RecvPacket, message that originates from core IBC and goes down to app, the flow is: // channel.RecvPacket -> fee.OnRecvPacket -> icaHost.OnRecvPacket