11package app
22
33import (
4+ "errors"
45 "fmt"
56 "io"
67 "net/http"
@@ -102,6 +103,9 @@ import (
102103 upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client"
103104 upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
104105 upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
106+ icq "github.com/cosmos/ibc-apps/modules/async-icq/v7"
107+ icqkeeper "github.com/cosmos/ibc-apps/modules/async-icq/v7/keeper"
108+ icqtypes "github.com/cosmos/ibc-apps/modules/async-icq/v7/types"
105109 ica "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts"
106110 icacontroller "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller"
107111 icacontrollerkeeper "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/keeper"
@@ -175,6 +179,7 @@ var (
175179 transfer.AppModuleBasic {},
176180 ica.AppModuleBasic {},
177181 upgrade.AppModuleBasic {},
182+ icq.AppModuleBasic {},
178183 evidence.AppModuleBasic {},
179184 vesting.AppModuleBasic {},
180185 feegrantmodule.AppModuleBasic {},
@@ -193,6 +198,7 @@ var (
193198 authtypes .FeeCollectorName : nil ,
194199 distrtypes .ModuleName : nil ,
195200 icatypes .ModuleName : nil ,
201+ icqtypes .ModuleName : nil ,
196202 minttypes .ModuleName : {authtypes .Minter },
197203 stakingtypes .BondedPoolName : {authtypes .Burner , authtypes .Staking },
198204 stakingtypes .NotBondedPoolName : {authtypes .Burner , authtypes .Staking },
@@ -243,6 +249,7 @@ type App struct {
243249 IBCFeeKeeper ibcfeekeeper.Keeper
244250 ICAControllerKeeper icacontrollerkeeper.Keeper
245251 ICAHostKeeper icahostkeeper.Keeper
252+ ICQKeeper * icqkeeper.Keeper
246253 EvidenceKeeper evidencekeeper.Keeper
247254 TransferKeeper ibctransferkeeper.Keeper
248255 FeeGrantKeeper feegrantkeeper.Keeper
@@ -325,6 +332,7 @@ func New(
325332 ibctransfertypes .StoreKey ,
326333 icacontrollertypes .StoreKey ,
327334 icahosttypes .StoreKey ,
335+ icqtypes .StoreKey ,
328336 capabilitytypes .StoreKey ,
329337 authzkeeper .StoreKey ,
330338 group .StoreKey ,
@@ -362,6 +370,7 @@ func New(
362370 scopedTransferKeeper := app .CapabilityKeeper .ScopeToModule (ibctransfertypes .ModuleName )
363371 scopedICAControllerKeeper := app .CapabilityKeeper .ScopeToModule (icacontrollertypes .SubModuleName )
364372 scopedICAHostKeeper := app .CapabilityKeeper .ScopeToModule (icahosttypes .SubModuleName )
373+ scopedICQKeeper := app .CapabilityKeeper .ScopeToModule (icqtypes .ModuleName )
365374 scopedResourceKeeper := app .CapabilityKeeper .ScopeToModule (resourcetypes .ModuleName )
366375 scopedFeeabsKeeper := app .CapabilityKeeper .ScopeToModule (feeabstypes .ModuleName )
367376
@@ -527,6 +536,25 @@ func New(
527536 // Create IBC Router
528537 ibcRouter := porttypes .NewRouter ()
529538
539+ // ICQ Keeper
540+ icqKeeper := icqkeeper .NewKeeper (
541+ appCodec ,
542+ app .keys [icqtypes .StoreKey ],
543+ app .IBCKeeper .ChannelKeeper ,
544+ app .IBCKeeper .ChannelKeeper ,
545+ & app .IBCKeeper .PortKeeper ,
546+ app .ScopedICQKeeper ,
547+ bApp .GRPCQueryRouter (),
548+ authtypes .NewModuleAddress (govtypes .ModuleName ).String (),
549+ )
550+ app .ICQKeeper = & icqKeeper
551+
552+ // Create Async ICQ module
553+ icqModule := icq .NewIBCModule (* app .ICQKeeper )
554+
555+ // Add icq modules to IBC router
556+ ibcRouter .AddRoute (icqtypes .ModuleName , icqModule )
557+
530558 // Middleware Stacks
531559
532560 // Create Transfer Keeper and pass IBCFeeKeeper as expected Channel and PortKeeper
@@ -728,6 +756,7 @@ func New(
728756 didtypes .ModuleName ,
729757 resourcetypes .ModuleName ,
730758 consensusparamtypes .ModuleName ,
759+ icqtypes .ModuleName ,
731760 feemarkettypes .ModuleName ,
732761 )
733762
@@ -758,6 +787,7 @@ func New(
758787 ibcfeetypes .ModuleName ,
759788 consensusparamtypes .ModuleName ,
760789 feemarkettypes .ModuleName ,
790+ icqtypes .ModuleName ,
761791 )
762792
763793 // NOTE: The genutils module must occur after staking so that pools are
@@ -782,6 +812,7 @@ func New(
782812 ibctransfertypes .ModuleName ,
783813 feeabstypes .ModuleName ,
784814 icatypes .ModuleName ,
815+ icqtypes .ModuleName ,
785816 ibcfeetypes .ModuleName ,
786817 feegrant .ModuleName ,
787818 group .ModuleName ,
@@ -874,6 +905,7 @@ func New(
874905 app .ScopedTransferKeeper = scopedTransferKeeper
875906 app .ScopedICAControllerKeeper = scopedICAControllerKeeper
876907 app .ScopedICAHostKeeper = scopedICAHostKeeper
908+ app .ScopedICQKeeper = scopedICQKeeper
877909 app .ScopedResourceKeeper = scopedResourceKeeper
878910 app .ScopedFeeAbsKeeper = scopedFeeabsKeeper
879911
@@ -1154,6 +1186,11 @@ func (app *App) RegisterUpgradeHandlers() {
11541186 if err != nil {
11551187 return migrations , err
11561188 }
1189+ // remove the old host zone config and add the new one
1190+ err = ReplaceHostZoneConfig (ctx , & app .FeeabsKeeper )
1191+ if err != nil {
1192+ return migrations , err
1193+ }
11571194 return migrations , nil
11581195 },
11591196 )
@@ -1231,3 +1268,26 @@ func SetExplicitModuleAccountPermissions(ctx sdk.Context, accountKeeper authkeep
12311268 panic ("failed to cast module account to *ModuleAccount" )
12321269 }
12331270}
1271+
1272+ func ReplaceHostZoneConfig (ctx sdk.Context , feeAbsKeeper * feeabskeeper.Keeper ) error {
1273+ // disregard, if not mainnet
1274+ if ctx .ChainID () != "cheqd-mainnet-1" {
1275+ return nil
1276+ }
1277+ // remove the old host zone config and add the new one
1278+ err := feeAbsKeeper .DeleteHostZoneConfig (ctx , "ibc/498A0751C798A0D9A389AA3691123DADA57DAA4FE165D5C75894505B876BA6E4" )
1279+ // ignore error if not found
1280+ if err != nil && ! errors .Is (err , feeabstypes .ErrHostZoneConfigNotFound ) {
1281+ return err
1282+ }
1283+ err = feeAbsKeeper .SetHostZoneConfig (ctx , feeabstypes.HostChainFeeAbsConfig {
1284+ IbcDenom : "ibc/F5FABF52B54E65064B57BF6DBD8E5FAD22CEE9F4B8A57ADBB20CCD0173AA72A4" ,
1285+ OsmosisPoolTokenDenomIn : "ibc/498A0751C798A0D9A389AA3691123DADA57DAA4FE165D5C75894505B876BA6E4" ,
1286+ PoolId : 1273 ,
1287+ MinSwapAmount : 0 ,
1288+ })
1289+ if err != nil {
1290+ return err
1291+ }
1292+ return nil
1293+ }
0 commit comments