Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianElvis committed Aug 2, 2024
1 parent f207819 commit d82966b
Showing 1 changed file with 12 additions and 76 deletions.
88 changes: 12 additions & 76 deletions demo/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ import (
"github.com/cosmos/cosmos-sdk/std"
simsutils "github.com/cosmos/cosmos-sdk/testutil/sims"
authcodec "github.com/cosmos/cosmos-sdk/x/auth/codec"
ica "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts"
icacontroller "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller"
icacontrollerkeeper "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/keeper"
icacontrollertypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types"
icahost "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host"
icahostkeeper "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/keeper"
icahosttypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/types"
icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types"
ibcfee "github.com/cosmos/ibc-go/v8/modules/apps/29-fee"
ibcfeekeeper "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/keeper"
ibcfeetypes "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types"
Expand Down Expand Up @@ -148,7 +140,6 @@ var maccPerms = map[string][]string{
govtypes.ModuleName: {authtypes.Burner},
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
ibcfeetypes.ModuleName: nil,
icatypes.ModuleName: nil,
wasmtypes.ModuleName: {authtypes.Burner},
bbntypes.ModuleName: {authtypes.Minter, authtypes.Burner},
}
Expand Down Expand Up @@ -188,20 +179,16 @@ type ConsumerApp struct {
FeeGrantKeeper feegrantkeeper.Keeper
ConsensusParamsKeeper consensusparamkeeper.Keeper

IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
IBCFeeKeeper ibcfeekeeper.Keeper
ICAControllerKeeper icacontrollerkeeper.Keeper
ICAHostKeeper icahostkeeper.Keeper
TransferKeeper ibctransferkeeper.Keeper
WasmKeeper wasmkeeper.Keeper
BabylonKeeper *bbnkeeper.Keeper

ScopedIBCKeeper capabilitykeeper.ScopedKeeper
ScopedICAHostKeeper capabilitykeeper.ScopedKeeper
ScopedICAControllerKeeper capabilitykeeper.ScopedKeeper
ScopedTransferKeeper capabilitykeeper.ScopedKeeper
ScopedIBCFeeKeeper capabilitykeeper.ScopedKeeper
ScopedWasmKeeper capabilitykeeper.ScopedKeeper
IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
IBCFeeKeeper ibcfeekeeper.Keeper
TransferKeeper ibctransferkeeper.Keeper
WasmKeeper wasmkeeper.Keeper
BabylonKeeper *bbnkeeper.Keeper

ScopedIBCKeeper capabilitykeeper.ScopedKeeper
ScopedTransferKeeper capabilitykeeper.ScopedKeeper
ScopedIBCFeeKeeper capabilitykeeper.ScopedKeeper
ScopedWasmKeeper capabilitykeeper.ScopedKeeper

// the module manager
ModuleManager *module.Manager
Expand Down Expand Up @@ -240,8 +227,7 @@ func NewConsumerApp(
authzkeeper.StoreKey,
// non sdk store keys
ibcexported.StoreKey, ibctransfertypes.StoreKey, ibcfeetypes.StoreKey,
wasmtypes.StoreKey, icahosttypes.StoreKey,
icacontrollertypes.StoreKey,
wasmtypes.StoreKey,
bbntypes.StoreKey,
)

Expand Down Expand Up @@ -294,8 +280,6 @@ func NewConsumerApp(
)

scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibcexported.ModuleName)
scopedICAHostKeeper := app.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName)
scopedICAControllerKeeper := app.CapabilityKeeper.ScopeToModule(icacontrollertypes.SubModuleName)
scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName)
scopedWasmKeeper := app.CapabilityKeeper.ScopeToModule(wasmtypes.ModuleName)
app.CapabilityKeeper.Seal()
Expand Down Expand Up @@ -489,30 +473,6 @@ func NewConsumerApp(
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

app.ICAHostKeeper = icahostkeeper.NewKeeper(
appCodec,
keys[icahosttypes.StoreKey],
app.GetSubspace(icahosttypes.SubModuleName),
app.IBCFeeKeeper, // use ics29 fee as ics4Wrapper in middleware stack
app.IBCKeeper.ChannelKeeper,
app.IBCKeeper.PortKeeper,
app.AccountKeeper,
scopedICAHostKeeper,
app.MsgServiceRouter(),
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)
app.ICAControllerKeeper = icacontrollerkeeper.NewKeeper(
appCodec,
keys[icacontrollertypes.StoreKey],
app.GetSubspace(icacontrollertypes.SubModuleName),
app.IBCFeeKeeper, // use ics29 fee as ics4Wrapper in middleware stack
app.IBCKeeper.ChannelKeeper,
app.IBCKeeper.PortKeeper,
scopedICAControllerKeeper,
app.MsgServiceRouter(),
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

wasmDir := filepath.Join(homePath, "wasm")
wasmConfig, err := wasm.ReadWasmConfig(appOpts)
if err != nil {
Expand Down Expand Up @@ -564,22 +524,6 @@ func NewConsumerApp(
transferStack = transfer.NewIBCModule(app.TransferKeeper)
transferStack = ibcfee.NewIBCMiddleware(transferStack, app.IBCFeeKeeper)

// Create Interchain Accounts Stack
// SendPacket, since it is originating from the application to core IBC:
// icaAuthModuleKeeper.SendTx -> icaController.SendPacket -> fee.SendPacket -> channel.SendPacket
var icaControllerStack porttypes.IBCModule
// integration point for custom authentication modules
// see https://medium.com/the-interchain-foundation/ibc-go-v6-changes-to-interchain-accounts-and-how-it-impacts-your-chain-806c185300d7
var noAuthzModule porttypes.IBCModule
icaControllerStack = icacontroller.NewIBCMiddleware(noAuthzModule, app.ICAControllerKeeper)
icaControllerStack = ibcfee.NewIBCMiddleware(icaControllerStack, app.IBCFeeKeeper)

// RecvPacket, message that originates from core IBC and goes down to app, the flow is:
// channel.RecvPacket -> fee.OnRecvPacket -> icaHost.OnRecvPacket
var icaHostStack porttypes.IBCModule
icaHostStack = icahost.NewIBCModule(app.ICAHostKeeper)
icaHostStack = ibcfee.NewIBCMiddleware(icaHostStack, app.IBCFeeKeeper)

// Create fee enabled wasm ibc Stack
var wasmStack porttypes.IBCModule
wasmStack = wasm.NewIBCHandler(app.WasmKeeper, app.IBCKeeper.ChannelKeeper, app.IBCFeeKeeper)
Expand All @@ -588,9 +532,7 @@ func NewConsumerApp(
// 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(wasmtypes.ModuleName, wasmStack)
app.IBCKeeper.SetRouter(ibcRouter)

/**** Module Options ****/
Expand Down Expand Up @@ -628,7 +570,6 @@ func NewConsumerApp(
transfer.NewAppModule(app.TransferKeeper),
ibcfee.NewAppModule(app.IBCFeeKeeper),
ibctm.AppModule{},
ica.NewAppModule(&app.ICAControllerKeeper, &app.ICAHostKeeper),
babylon.NewAppModule(appCodec, app.BabylonKeeper),
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 @@ -669,7 +610,6 @@ func NewConsumerApp(
// additional non simd modules
ibctransfertypes.ModuleName,
ibcexported.ModuleName,
icatypes.ModuleName,
ibcfeetypes.ModuleName,
wasmtypes.ModuleName,
bbntypes.ModuleName,
Expand All @@ -685,7 +625,6 @@ func NewConsumerApp(
// additional non simd modules
ibctransfertypes.ModuleName,
ibcexported.ModuleName,
icatypes.ModuleName,
ibcfeetypes.ModuleName,
wasmtypes.ModuleName,
bbntypes.ModuleName, // last to capture all chain events
Expand All @@ -708,7 +647,6 @@ func NewConsumerApp(
// additional non simd modules
ibctransfertypes.ModuleName,
ibcexported.ModuleName,
icatypes.ModuleName,
ibcfeetypes.ModuleName,
// wasm after ibc transfer
wasmtypes.ModuleName,
Expand Down Expand Up @@ -775,8 +713,6 @@ func NewConsumerApp(
app.ScopedIBCKeeper = scopedIBCKeeper
app.ScopedTransferKeeper = scopedTransferKeeper
app.ScopedWasmKeeper = scopedWasmKeeper
app.ScopedICAHostKeeper = scopedICAHostKeeper
app.ScopedICAControllerKeeper = scopedICAControllerKeeper

// In v0.46, the SDK introduces _postHandlers_. PostHandlers are like
// antehandlers, but are run _after_ the `runMsgs` execution. They are also
Expand Down

0 comments on commit d82966b

Please sign in to comment.