From 86f33d8c7daf0067fb7d028d4429871e27efc477 Mon Sep 17 00:00:00 2001 From: Tuan Tran Date: Wed, 10 Apr 2024 13:32:26 +0700 Subject: [PATCH] add async-icq module --- app/app.go | 36 ++++++++++++++++++++++++++++++------ go.mod | 1 + go.sum | 2 ++ 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/app/app.go b/app/app.go index 7d7ede8a..c6fb1890 100644 --- a/app/app.go +++ b/app/app.go @@ -14,6 +14,9 @@ import ( tmproto "github.com/cometbft/cometbft/proto/tendermint/types" dbm "github.com/cosmos/cosmos-db" "github.com/cosmos/gogoproto/proto" + icq "github.com/cosmos/ibc-apps/modules/async-icq/v8" + icqkeeper "github.com/cosmos/ibc-apps/modules/async-icq/v8/keeper" + icqtypes "github.com/cosmos/ibc-apps/modules/async-icq/v8/types" ibchooks "github.com/cosmos/ibc-apps/modules/ibc-hooks/v8" ibchookskeeper "github.com/cosmos/ibc-apps/modules/ibc-hooks/v8/keeper" ibchookstypes "github.com/cosmos/ibc-apps/modules/ibc-hooks/v8/types" @@ -202,6 +205,7 @@ var maccPerms = map[string][]string{ tokenfactorytypes.ModuleName: {authtypes.Minter, authtypes.Burner}, alliancemoduletypes.ModuleName: {authtypes.Minter, authtypes.Burner}, alliancemoduletypes.RewardsPoolName: nil, + icqtypes.ModuleName: nil, } var ( @@ -250,6 +254,7 @@ type EveApp struct { Wasm08Keeper wasm08keeper.Keeper WasmKeeper wasmkeeper.Keeper AllianceKeeper alliancemodulekeeper.Keeper + ICQKeeper icqkeeper.Keeper IBCHooksKeeper ibchookskeeper.Keeper @@ -259,6 +264,7 @@ type EveApp struct { ScopedTransferKeeper capabilitykeeper.ScopedKeeper ScopedIBCFeeKeeper capabilitykeeper.ScopedKeeper ScopedWasmKeeper capabilitykeeper.ScopedKeeper + ScopedICQKeeper capabilitykeeper.ScopedKeeper TokenFactoryKeeper tokenfactorykeeper.Keeper @@ -325,7 +331,7 @@ func NewEveApp( wasm08types.StoreKey, wasmtypes.StoreKey, icahosttypes.StoreKey, icacontrollertypes.StoreKey, tokenfactorytypes.StoreKey, ibchookstypes.StoreKey, - alliancemoduletypes.StoreKey, + alliancemoduletypes.StoreKey, icqtypes.StoreKey, ) tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey) @@ -371,7 +377,7 @@ func NewEveApp( keys[capabilitytypes.StoreKey], memKeys[capabilitytypes.MemStoreKey], ) - + scopedICQKeeper := app.CapabilityKeeper.ScopeToModule(icqtypes.ModuleName) scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibcexported.ModuleName) scopedICAHostKeeper := app.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName) scopedICAControllerKeeper := app.CapabilityKeeper.ScopeToModule(icacontrollertypes.SubModuleName) @@ -532,7 +538,17 @@ func NewEveApp( scopedIBCKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) - + // ICQ Keeper + app.ICQKeeper = icqkeeper.NewKeeper( + appCodec, + keys[icqtypes.StoreKey], + app.IBCKeeper.ChannelKeeper, // may be replaced with middleware + app.IBCKeeper.ChannelKeeper, + app.IBCKeeper.PortKeeper, + scopedICQKeeper, + app.BaseApp.GRPCQueryRouter(), + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ) app.Wasm08Keeper = wasm08keeper.NewKeeperWithVM( appCodec, runtime.NewKVStoreService(keys[wasmtypes.StoreKey]), @@ -630,13 +646,16 @@ func NewEveApp( var wasmStack porttypes.IBCModule wasmStack = wasm.NewIBCHandler(app.WasmKeeper, app.IBCKeeper.ChannelKeeper, app.IBCFeeKeeper) wasmStack = ibcfee.NewIBCMiddleware(wasmStack, app.IBCFeeKeeper) - + // initialize ICQ module with mock module + // var icqStack porttypes.IBCModule + icqStack := icq.NewIBCModule(app.ICQKeeper) // Create static IBC router, add app routes, then set and seal it ibcRouter := porttypes.NewRouter(). AddRoute(ibctransfertypes.ModuleName, transferStack). AddRoute(wasmtypes.ModuleName, wasmStack). AddRoute(icacontrollertypes.SubModuleName, icaControllerStack). - AddRoute(icahosttypes.SubModuleName, icaHostStack) + AddRoute(icahosttypes.SubModuleName, icaHostStack). + AddRoute(icqtypes.ModuleName, icqStack) app.IBCKeeper.SetRouter(ibcRouter) app.IBCHooksKeeper = ibchookskeeper.NewKeeper( @@ -760,6 +779,7 @@ func NewEveApp( ica.NewAppModule(&app.ICAControllerKeeper, &app.ICAHostKeeper), ibctm.AppModule{}, alliancemodule.NewAppModule(appCodec, app.AllianceKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry, app.GetSubspace(alliancemoduletypes.ModuleName)), + icq.NewAppModule(app.ICQKeeper, app.GetSubspace(icqtypes.ModuleName)), // sdk crisis.NewAppModule(app.CrisisKeeper, skipGenesisInvariants, app.GetSubspace(crisistypes.ModuleName)), // always be last to make sure that it checks for all invariants and not only part of them, @@ -816,6 +836,7 @@ func NewEveApp( wasmtypes.ModuleName, tokenfactorytypes.ModuleName, alliancemoduletypes.ModuleName, + icqtypes.ModuleName, ) app.ModuleManager.SetOrderEndBlockers( @@ -835,6 +856,7 @@ func NewEveApp( wasm08types.ModuleName, wasmtypes.ModuleName, tokenfactorytypes.ModuleName, alliancemoduletypes.ModuleName, + icqtypes.ModuleName, ) // NOTE: The genutils module must occur after staking so that pools are @@ -875,6 +897,7 @@ func NewEveApp( ibchookstypes.ModuleName, wasm08types.ModuleName, + icqtypes.ModuleName, // wasm after ibc transfer wasmtypes.ModuleName, @@ -944,7 +967,7 @@ func NewEveApp( panic(fmt.Errorf("failed to register snapshot extension: %s", err)) } } - + app.ScopedICQKeeper = scopedICQKeeper app.ScopedIBCKeeper = scopedIBCKeeper app.ScopedTransferKeeper = scopedTransferKeeper app.ScopedWasmKeeper = scopedWasmKeeper @@ -1272,6 +1295,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(tokenfactorytypes.ModuleName).WithKeyTable(tokenfactorytypes.ParamKeyTable()) paramsKeeper.Subspace(wasmtypes.ModuleName) paramsKeeper.Subspace(alliancemoduletypes.ModuleName) + paramsKeeper.Subspace(icqtypes.ModuleName) return paramsKeeper } diff --git a/go.mod b/go.mod index 552aa65a..ec62f51a 100644 --- a/go.mod +++ b/go.mod @@ -44,6 +44,7 @@ require ( cosmossdk.io/x/upgrade v0.1.1 github.com/cometbft/cometbft v0.38.6 github.com/cosmos/cosmos-db v1.0.2 + github.com/cosmos/ibc-apps/modules/async-icq/v8 v8.0.0 github.com/cosmos/ibc-apps/modules/ibc-hooks/v8 v8.0.0-00010101000000-000000000000 github.com/cosmos/ibc-go/modules/capability v1.0.0 github.com/cosmos/ibc-go/modules/light-clients/08-wasm v0.0.0-20240314094315-e89424c5bf2e diff --git a/go.sum b/go.sum index 75f1073a..1e53fdce 100644 --- a/go.sum +++ b/go.sum @@ -370,6 +370,8 @@ github.com/cosmos/gogoproto v1.4.11 h1:LZcMHrx4FjUgrqQSWeaGC1v/TeuVFqSLa43CC6aWR github.com/cosmos/gogoproto v1.4.11/go.mod h1:/g39Mh8m17X8Q/GDEs5zYTSNaNnInBSohtaxzQnYq1Y= github.com/cosmos/iavl v1.0.1 h1:D+mYbcRO2wptYzOM1Hxl9cpmmHU1ZEt9T2Wv5nZTeUw= github.com/cosmos/iavl v1.0.1/go.mod h1:8xIUkgVvwvVrBu81scdPty+/Dx9GqwHnAvXz4cwF7RY= +github.com/cosmos/ibc-apps/modules/async-icq/v8 v8.0.0 h1:nKP2+Rzlz2iyvTosY5mvP+aEBPe06oaDl3G7xLGBpNI= +github.com/cosmos/ibc-apps/modules/async-icq/v8 v8.0.0/go.mod h1:D3Q380FpWRFtmUQWLosPxachi6w24Og2t5u/Tww5wtY= github.com/cosmos/ibc-go/modules/capability v1.0.0 h1:r/l++byFtn7jHYa09zlAdSeevo8ci1mVZNO9+V0xsLE= github.com/cosmos/ibc-go/modules/capability v1.0.0/go.mod h1:D81ZxzjZAe0ZO5ambnvn1qedsFQ8lOwtqicG6liLBco= github.com/cosmos/ibc-go/v8 v8.1.1 h1:N2+GA86yACcXnKWCKtqdbCwP0/Eo8pH79+6e7TicULU=