From 2b49a0ee022b4e6f3a7a4165c9c1077c8acfea39 Mon Sep 17 00:00:00 2001 From: Khanh Hoa Date: Thu, 18 Apr 2024 16:49:32 +0700 Subject: [PATCH] refactor: using transfer stack --- app/keepers/keepers.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index faf05ef9..dea6296a 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -368,7 +368,6 @@ func (appKeepers *AppKeepers) InitNormalKeepers( authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) - transferIBCModule := transfer.NewIBCModule(appKeepers.TransferKeeper.Keeper) scopedICQKeeper := appKeepers.CapabilityKeeper.ScopeToModule(icqtypes.ModuleName) appKeepers.ICQKeeper = icqkeeper.NewKeeper( @@ -378,20 +377,25 @@ func (appKeepers *AppKeepers) InitNormalKeepers( ) icqIBCModule := icq.NewIBCModule(appKeepers.ICQKeeper) - transfermiddlewareStack := transfermiddleware.NewIBCMiddleware( - transferIBCModule, + + // Create transfer stack + var transferStack porttypes.IBCModule + transferStack = transfer.NewIBCModule(appKeepers.TransferKeeper.Keeper) + + transferStack = transfermiddleware.NewIBCMiddleware( + transferStack, appKeepers.TransferMiddlewareKeeper, ) - ibcMiddlewareStack := pfm.NewIBCMiddleware( - transfermiddlewareStack, + transferStack = pfm.NewIBCMiddleware( + transferStack, appKeepers.PfmKeeper, 0, pfmkeeper.DefaultForwardTransferPacketTimeoutTimestamp, pfmkeeper.DefaultRefundTransferPacketTimeoutTimestamp, ) - ratelimitMiddlewareStack := ratelimitmodule.NewIBCMiddleware(appKeepers.RatelimitKeeper, ibcMiddlewareStack) - hooksTransferMiddleware := ibc_hooks.NewIBCMiddleware(ratelimitMiddlewareStack, &appKeepers.HooksICS4Wrapper) + transferStack = ratelimitmodule.NewIBCMiddleware(appKeepers.RatelimitKeeper, transferStack) + transferStack = ibc_hooks.NewIBCMiddleware(transferStack, &appKeepers.HooksICS4Wrapper) // Create evidence Keeper for to register the IBC light client misbehaviour evidence route evidenceKeeper := evidencekeeper.NewKeeper( @@ -494,7 +498,7 @@ func (appKeepers *AppKeepers) InitNormalKeepers( ) ibcRouter := porttypes.NewRouter() - ibcRouter.AddRoute(ibctransfertypes.ModuleName, hooksTransferMiddleware) + ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferStack) ibcRouter.AddRoute(icqtypes.ModuleName, icqIBCModule) ibcRouter.AddRoute(wasmtypes.ModuleName, wasm.NewIBCHandler(appKeepers.WasmKeeper, appKeepers.IBCKeeper.ChannelKeeper, appKeepers.IBCKeeper.ChannelKeeper)) ibcRouter.AddRoute(icahosttypes.SubModuleName, icaHostStack)