Skip to content

Commit

Permalink
Merge pull request #140 from White-Whale-Defi-Platform/async-icq
Browse files Browse the repository at this point in the history
async-icq
  • Loading branch information
faddat authored Apr 18, 2023
2 parents bb83030 + 0f7bdf7 commit c6537b1
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 5 deletions.
48 changes: 43 additions & 5 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/gov"
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
"github.com/cosmos/cosmos-sdk/x/mint"
mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper"
Expand Down Expand Up @@ -144,6 +143,10 @@ import (
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
wasmappparams "github.com/White-Whale-Defi-Platform/migaloo-chain/v3/app/params"

icq "github.com/strangelove-ventures/async-icq/v7"
icqkeeper "github.com/strangelove-ventures/async-icq/v7/keeper"
icqtypes "github.com/strangelove-ventures/async-icq/v7/types"

// unnamed import of statik for swagger UI support
_ "github.com/cosmos/cosmos-sdk/client/docs/statik"

Expand Down Expand Up @@ -228,6 +231,7 @@ var (
authzmodule.AppModuleBasic{},
ibc.AppModuleBasic{},
ibctm.AppModuleBasic{},
icq.AppModuleBasic{},
solomachine.AppModuleBasic{},
upgrade.AppModuleBasic{},
evidence.AppModuleBasic{},
Expand All @@ -252,6 +256,7 @@ var (
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
ibcfeetypes.ModuleName: nil,
icatypes.ModuleName: nil,
icqtypes.ModuleName: nil,
wasm.ModuleName: {authtypes.Burner},
tokenfactorytypes.ModuleName: {authtypes.Minter, authtypes.Burner},
alliancemoduletypes.ModuleName: {authtypes.Minter, authtypes.Burner},
Expand Down Expand Up @@ -295,6 +300,7 @@ type MigalooApp struct {
EvidenceKeeper evidencekeeper.Keeper
IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
IBCFeeKeeper ibcfeekeeper.Keeper
ICQKeeper icqkeeper.Keeper
ICAControllerKeeper icacontrollerkeeper.Keeper
ICAHostKeeper icahostkeeper.Keeper
InterTxKeeper intertxkeeper.Keeper
Expand All @@ -309,6 +315,7 @@ type MigalooApp struct {
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
ScopedICAHostKeeper capabilitykeeper.ScopedKeeper
ScopedICAControllerKeeper capabilitykeeper.ScopedKeeper
ScopedICQKeeper capabilitykeeper.ScopedKeeper
ScopedInterTxKeeper capabilitykeeper.ScopedKeeper
ScopedTransferKeeper capabilitykeeper.ScopedKeeper
ScopedIBCFeeKeeper capabilitykeeper.ScopedKeeper
Expand Down Expand Up @@ -351,7 +358,7 @@ func NewMigalooApp(
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey,
minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
govtypes.StoreKey, paramstypes.StoreKey, ibcexported.StoreKey, upgradetypes.StoreKey, routertypes.StoreKey,
evidencetypes.StoreKey, ibctransfertypes.StoreKey, capabilitytypes.StoreKey,
evidencetypes.StoreKey, icqtypes.StoreKey, ibctransfertypes.StoreKey, capabilitytypes.StoreKey,
feegrant.StoreKey, authzkeeper.StoreKey, wasm.StoreKey, icahosttypes.StoreKey,
icacontrollertypes.StoreKey, intertxtypes.StoreKey, ibcfeetypes.StoreKey, tokenfactorytypes.StoreKey,
alliancemoduletypes.StoreKey, consensusparamtypes.StoreKey, crisistypes.StoreKey,
Expand Down Expand Up @@ -389,6 +396,7 @@ func NewMigalooApp(
memKeys[capabilitytypes.MemStoreKey],
)
scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibcexported.ModuleName)
scopedICQKeeper := app.CapabilityKeeper.ScopeToModule(icqtypes.ModuleName)
scopedICAHostKeeper := app.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName)
scopedICAControllerKeeper := app.CapabilityKeeper.ScopeToModule(icacontrollertypes.SubModuleName)
scopedInterTxKeeper := app.CapabilityKeeper.ScopeToModule(intertxtypes.ModuleName)
Expand Down Expand Up @@ -618,11 +626,23 @@ func NewMigalooApp(
wasmOpts...,
)

// The gov proposal types can be individually enabled
// WASM gov proposal types can be individually enabled
if len(enabledProposals) != 0 {
govRouter.AddRoute(wasm.RouterKey, wasm.NewWasmProposalHandler(app.WasmKeeper, enabledProposals))
}

// ICQ Keeper
app.ICQKeeper = icqkeeper.NewKeeper(
appCodec,
keys[icqtypes.StoreKey],
app.GetSubspace(icqtypes.ModuleName),
app.IBCKeeper.ChannelKeeper, // may be replaced with middleware
app.IBCKeeper.ChannelKeeper,
&app.IBCKeeper.PortKeeper,
scopedICQKeeper,
app.BaseApp, // may be replaced
)

// Create Transfer Stack
var transferStack ibcporttypes.IBCModule
transferStack = transfer.NewIBCModule(app.TransferKeeper)
Expand All @@ -646,6 +666,14 @@ func NewMigalooApp(
icaHostStack = icahost.NewIBCModule(app.ICAHostKeeper)
icaHostStack = ibcfee.NewIBCMiddleware(icaHostStack, app.IBCFeeKeeper)

// Create Interchain Query Stack
// SendQuery, since it is originating from the application to core IBC:
// icqKeeper.SendQuery -> icqKeeper.SendPacket -> channel.SendPacket

// initialize ICQ module with mock module
// var icqStack porttypes.IBCModule
icqStack := icq.NewIBCModule(app.ICQKeeper)

// Create fee enabled wasm ibc Stack
var wasmStack ibcporttypes.IBCModule
wasmStack = wasm.NewIBCHandler(app.WasmKeeper, app.IBCKeeper.ChannelKeeper, app.IBCFeeKeeper)
Expand All @@ -657,7 +685,9 @@ func NewMigalooApp(
AddRoute(wasm.ModuleName, wasmStack).
AddRoute(intertxtypes.ModuleName, icaControllerStack).
AddRoute(icacontrollertypes.SubModuleName, icaControllerStack).
AddRoute(icahosttypes.SubModuleName, icaHostStack)
AddRoute(icahosttypes.SubModuleName, icaHostStack).
AddRoute(icqtypes.ModuleName, icqStack)

app.IBCKeeper.SetRouter(ibcRouter)

govConfig := govtypes.DefaultConfig()
Expand All @@ -683,6 +713,8 @@ func NewMigalooApp(
),
)

// TODO: add groups module, seems stable and provides another management option

// upgrade handlers
cfg := module.NewConfigurator(appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter())

Expand Down Expand Up @@ -719,6 +751,7 @@ func NewMigalooApp(
params.NewAppModule(app.ParamsKeeper),
transfer.NewAppModule(app.TransferKeeper),
icaModule,
icq.NewAppModule(app.ICQKeeper),
alliancemodule.NewAppModule(appCodec, app.AllianceKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
ibcfee.NewAppModule(app.IBCFeeKeeper),
ica.NewAppModule(&app.ICAControllerKeeper, &app.ICAHostKeeper),
Expand Down Expand Up @@ -749,6 +782,7 @@ func NewMigalooApp(
feegrant.ModuleName,
paramstypes.ModuleName,
vestingtypes.ModuleName,
icqtypes.ModuleName,
// additional non simd modules
routertypes.ModuleName,
ibctransfertypes.ModuleName,
Expand Down Expand Up @@ -779,6 +813,7 @@ func NewMigalooApp(
upgradetypes.ModuleName,
vestingtypes.ModuleName,
// additional non simd modules
icqtypes.ModuleName,
routertypes.ModuleName,
ibctransfertypes.ModuleName,
ibcexported.ModuleName,
Expand Down Expand Up @@ -810,6 +845,7 @@ func NewMigalooApp(
genutiltypes.ModuleName,
evidencetypes.ModuleName,
authz.ModuleName,
icqtypes.ModuleName,
feegrant.ModuleName,
paramstypes.ModuleName,
upgradetypes.ModuleName,
Expand Down Expand Up @@ -896,6 +932,7 @@ func NewMigalooApp(
app.ScopedICAHostKeeper = scopedICAHostKeeper
app.ScopedICAControllerKeeper = scopedICAControllerKeeper
app.ScopedInterTxKeeper = scopedInterTxKeeper
app.ScopedICQKeeper = scopedICQKeeper

if loadLatest {
if err := app.LoadLatestVersion(); err != nil {
Expand Down Expand Up @@ -1108,13 +1145,14 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(minttypes.ModuleName)
paramsKeeper.Subspace(distrtypes.ModuleName)
paramsKeeper.Subspace(slashingtypes.ModuleName)
paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govv1.ParamKeyTable()) //nolint:staticcheck
paramsKeeper.Subspace(govtypes.ModuleName)
paramsKeeper.Subspace(crisistypes.ModuleName)
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
paramsKeeper.Subspace(ibcexported.ModuleName)
paramsKeeper.Subspace(icahosttypes.SubModuleName)
paramsKeeper.Subspace(tokenfactorytypes.ModuleName)
paramsKeeper.Subspace(icacontrollertypes.SubModuleName)
paramsKeeper.Subspace(icqtypes.ModuleName)
paramsKeeper.Subspace(wasm.ModuleName)
paramsKeeper.Subspace(routertypes.ModuleName)
paramsKeeper.Subspace(alliancemoduletypes.ModuleName)
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ require (
github.com/spf13/cast v1.5.0
github.com/spf13/cobra v1.7.0
github.com/spf13/viper v1.15.0
github.com/strangelove-ventures/async-icq/v7 v7.0.0-20230410200408-3315fe3057aa
github.com/strangelove-ventures/packet-forward-middleware/v7 v7.0.0
github.com/stretchr/testify v1.8.2
github.com/terra-money/alliance v0.1.1-0.20230407062204-22bd3868e911
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,8 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM
github.com/spf13/viper v1.15.0 h1:js3yy885G8xwJa6iOISGFwd+qlUo5AvyXb7CiihdtiU=
github.com/spf13/viper v1.15.0/go.mod h1:fFcTBJxvhhzSJiZy8n+PeW6t8l+KeT/uTARa0jHOQLA=
github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4/go.mod h1:RZLeN1LMWmRsyYjvAu+I6Dm9QmlDaIIt+Y+4Kd7Tp+Q=
github.com/strangelove-ventures/async-icq/v7 v7.0.0-20230410200408-3315fe3057aa h1:WoB9ZXm6AJpbjADXk35J+H0ulsItw8ToTtsxVO3Hm3M=
github.com/strangelove-ventures/async-icq/v7 v7.0.0-20230410200408-3315fe3057aa/go.mod h1:nYiLAEamVVq+Y/6GVrm6YNC4KCPO5jg8R0iAuvdF3b0=
github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI=
Expand Down

0 comments on commit c6537b1

Please sign in to comment.