Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Add interchain query module #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 30 additions & 6 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 (
Expand Down Expand Up @@ -250,6 +254,7 @@ type EveApp struct {
Wasm08Keeper wasm08keeper.Keeper
WasmKeeper wasmkeeper.Keeper
AllianceKeeper alliancemodulekeeper.Keeper
ICQKeeper icqkeeper.Keeper

IBCHooksKeeper ibchookskeeper.Keeper

Expand All @@ -259,6 +264,7 @@ type EveApp struct {
ScopedTransferKeeper capabilitykeeper.ScopedKeeper
ScopedIBCFeeKeeper capabilitykeeper.ScopedKeeper
ScopedWasmKeeper capabilitykeeper.ScopedKeeper
ScopedICQKeeper capabilitykeeper.ScopedKeeper

TokenFactoryKeeper tokenfactorykeeper.Keeper

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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]),
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -816,6 +836,7 @@ func NewEveApp(
wasmtypes.ModuleName,
tokenfactorytypes.ModuleName,
alliancemoduletypes.ModuleName,
icqtypes.ModuleName,
)

app.ModuleManager.SetOrderEndBlockers(
Expand All @@ -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
Expand Down Expand Up @@ -875,6 +897,7 @@ func NewEveApp(

ibchookstypes.ModuleName,
wasm08types.ModuleName,
icqtypes.ModuleName,
// wasm after ibc transfer

wasmtypes.ModuleName,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down