1
1
package app
2
2
3
3
import (
4
+ "errors"
4
5
"fmt"
5
6
"io"
6
7
"net/http"
@@ -102,6 +103,9 @@ import (
102
103
upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client"
103
104
upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
104
105
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"
105
109
ica "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts"
106
110
icacontroller "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller"
107
111
icacontrollerkeeper "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/keeper"
@@ -175,6 +179,7 @@ var (
175
179
transfer.AppModuleBasic {},
176
180
ica.AppModuleBasic {},
177
181
upgrade.AppModuleBasic {},
182
+ icq.AppModuleBasic {},
178
183
evidence.AppModuleBasic {},
179
184
vesting.AppModuleBasic {},
180
185
feegrantmodule.AppModuleBasic {},
@@ -193,6 +198,7 @@ var (
193
198
authtypes .FeeCollectorName : nil ,
194
199
distrtypes .ModuleName : nil ,
195
200
icatypes .ModuleName : nil ,
201
+ icqtypes .ModuleName : nil ,
196
202
minttypes .ModuleName : {authtypes .Minter },
197
203
stakingtypes .BondedPoolName : {authtypes .Burner , authtypes .Staking },
198
204
stakingtypes .NotBondedPoolName : {authtypes .Burner , authtypes .Staking },
@@ -243,6 +249,7 @@ type App struct {
243
249
IBCFeeKeeper ibcfeekeeper.Keeper
244
250
ICAControllerKeeper icacontrollerkeeper.Keeper
245
251
ICAHostKeeper icahostkeeper.Keeper
252
+ ICQKeeper * icqkeeper.Keeper
246
253
EvidenceKeeper evidencekeeper.Keeper
247
254
TransferKeeper ibctransferkeeper.Keeper
248
255
FeeGrantKeeper feegrantkeeper.Keeper
@@ -325,6 +332,7 @@ func New(
325
332
ibctransfertypes .StoreKey ,
326
333
icacontrollertypes .StoreKey ,
327
334
icahosttypes .StoreKey ,
335
+ icqtypes .StoreKey ,
328
336
capabilitytypes .StoreKey ,
329
337
authzkeeper .StoreKey ,
330
338
group .StoreKey ,
@@ -362,6 +370,7 @@ func New(
362
370
scopedTransferKeeper := app .CapabilityKeeper .ScopeToModule (ibctransfertypes .ModuleName )
363
371
scopedICAControllerKeeper := app .CapabilityKeeper .ScopeToModule (icacontrollertypes .SubModuleName )
364
372
scopedICAHostKeeper := app .CapabilityKeeper .ScopeToModule (icahosttypes .SubModuleName )
373
+ scopedICQKeeper := app .CapabilityKeeper .ScopeToModule (icqtypes .ModuleName )
365
374
scopedResourceKeeper := app .CapabilityKeeper .ScopeToModule (resourcetypes .ModuleName )
366
375
scopedFeeabsKeeper := app .CapabilityKeeper .ScopeToModule (feeabstypes .ModuleName )
367
376
@@ -527,6 +536,25 @@ func New(
527
536
// Create IBC Router
528
537
ibcRouter := porttypes .NewRouter ()
529
538
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
+
530
558
// Middleware Stacks
531
559
532
560
// Create Transfer Keeper and pass IBCFeeKeeper as expected Channel and PortKeeper
@@ -728,6 +756,7 @@ func New(
728
756
didtypes .ModuleName ,
729
757
resourcetypes .ModuleName ,
730
758
consensusparamtypes .ModuleName ,
759
+ icqtypes .ModuleName ,
731
760
feemarkettypes .ModuleName ,
732
761
)
733
762
@@ -758,6 +787,7 @@ func New(
758
787
ibcfeetypes .ModuleName ,
759
788
consensusparamtypes .ModuleName ,
760
789
feemarkettypes .ModuleName ,
790
+ icqtypes .ModuleName ,
761
791
)
762
792
763
793
// NOTE: The genutils module must occur after staking so that pools are
@@ -782,6 +812,7 @@ func New(
782
812
ibctransfertypes .ModuleName ,
783
813
feeabstypes .ModuleName ,
784
814
icatypes .ModuleName ,
815
+ icqtypes .ModuleName ,
785
816
ibcfeetypes .ModuleName ,
786
817
feegrant .ModuleName ,
787
818
group .ModuleName ,
@@ -874,6 +905,7 @@ func New(
874
905
app .ScopedTransferKeeper = scopedTransferKeeper
875
906
app .ScopedICAControllerKeeper = scopedICAControllerKeeper
876
907
app .ScopedICAHostKeeper = scopedICAHostKeeper
908
+ app .ScopedICQKeeper = scopedICQKeeper
877
909
app .ScopedResourceKeeper = scopedResourceKeeper
878
910
app .ScopedFeeAbsKeeper = scopedFeeabsKeeper
879
911
@@ -1154,6 +1186,11 @@ func (app *App) RegisterUpgradeHandlers() {
1154
1186
if err != nil {
1155
1187
return migrations , err
1156
1188
}
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
+ }
1157
1194
return migrations , nil
1158
1195
},
1159
1196
)
@@ -1231,3 +1268,26 @@ func SetExplicitModuleAccountPermissions(ctx sdk.Context, accountKeeper authkeep
1231
1268
panic ("failed to cast module account to *ModuleAccount" )
1232
1269
}
1233
1270
}
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