Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
shifty11 committed Sep 18, 2023
1 parent 675ecc6 commit da3bbcc
Show file tree
Hide file tree
Showing 11 changed files with 219 additions and 352 deletions.
10 changes: 4 additions & 6 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package app

import (
_ "embed"
v1p4 "github.com/KYVENetwork/chain/app/upgrades/v1_4"
"io"
"os"
"path/filepath"

v1p4 "github.com/KYVENetwork/chain/app/upgrades/v1_4"
bundlesKeeper "github.com/KYVENetwork/chain/x/bundles/keeper"
delegationKeeper "github.com/KYVENetwork/chain/x/delegation/keeper"
globalKeeper "github.com/KYVENetwork/chain/x/global/keeper"
Expand Down Expand Up @@ -255,7 +255,7 @@ func NewKyveApp(
app.App = appBuilder.Build(logger, db, traceStore, baseAppOptions...)

// Register legacy modules
// app.registerIBCModules()
app.registerIBCModules()

// load state streaming if enabled
if _, _, err := streaming.LoadStreamingServices(app.App.BaseApp, appOpts, app.appCodec, logger, app.kvStoreKeys()); err != nil {
Expand All @@ -265,8 +265,6 @@ func NewKyveApp(

/**** Module Options ****/

// app.RegisterLegacyModules()

app.ModuleManager.RegisterInvariants(app.CrisisKeeper)

// add test gRPC service for testing gRPC queries in isolation
Expand Down Expand Up @@ -301,8 +299,8 @@ func NewKyveApp(
// app.ModuleManager,
// app.Configurator(),
// app.AppCodec(),
// app.ConsensusKeeper,
// app.GlobalKeeper,
// app.ConsensusParamsKeeper,
// *app.GlobalKeeper,
// *app.GovKeeper,
// *app.IBCKeeper,
// app.ParamsKeeper,
Expand Down
164 changes: 164 additions & 0 deletions app/ibc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
package app

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
"github.com/cosmos/cosmos-sdk/x/upgrade"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
ica "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts"
icacontroller "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller"
icacontrollerkeeper "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/keeper"
icacontrollertypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/types"
icahost "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host"
icahostkeeper "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/keeper"
icahosttypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/types"
ibcfee "github.com/cosmos/ibc-go/v7/modules/apps/29-fee"
ibcfeekeeper "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/keeper"
ibcfeetypes "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/types"
ibctransfer "github.com/cosmos/ibc-go/v7/modules/apps/transfer"
ibctransferkeeper "github.com/cosmos/ibc-go/v7/modules/apps/transfer/keeper"
ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
ibc "github.com/cosmos/ibc-go/v7/modules/core"
ibcclient "github.com/cosmos/ibc-go/v7/modules/core/02-client"
ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types"
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"
solomachine "github.com/cosmos/ibc-go/v7/modules/light-clients/06-solomachine"
ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"
// this line is used by starport scaffolding # ibc/app/import
)

func (app *App) registerIBCModules() {
// set up non depinject support modules store keys
app.keys = sdk.NewKVStoreKeys(
ibcexported.StoreKey,
ibctransfertypes.StoreKey,
ibcfeetypes.StoreKey,
icahosttypes.StoreKey,
icacontrollertypes.StoreKey,
)
app.MountKVStores(app.keys)

// set params subspaces
for _, m := range []string{ibctransfertypes.ModuleName, ibcexported.ModuleName, icahosttypes.SubModuleName, icacontrollertypes.SubModuleName} {
app.ParamsKeeper.Subspace(m)
}

// add capability keeper and ScopeToModule for ibc module
scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibcexported.ModuleName)
scopedIBCTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName)
scopedICAControllerKeeper := app.CapabilityKeeper.ScopeToModule(icacontrollertypes.SubModuleName)
scopedICAHostKeeper := app.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName)

// Create IBC keeper
app.IBCKeeper = ibckeeper.NewKeeper(
app.appCodec, app.GetKey(ibcexported.StoreKey), app.GetSubspace(ibcexported.ModuleName), app.StakingKeeper, app.UpgradeKeeper, scopedIBCKeeper,
)

// Register the proposal types
// Deprecated: Avoid adding new handlers, instead use the new proposal flow
// by granting the governance module the right to execute the message.
// See: https://docs.cosmos.network/main/modules/gov#proposal-messages
govRouter := govv1beta1.NewRouter()
govRouter.AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler).
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)).
AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper))

app.IBCFeeKeeper = ibcfeekeeper.NewKeeper(
app.appCodec, app.GetKey(ibcfeetypes.StoreKey),
app.IBCKeeper.ChannelKeeper, // may be replaced with IBC middleware
app.IBCKeeper.ChannelKeeper,
&app.IBCKeeper.PortKeeper, app.AccountKeeper, app.BankKeeper,
)

// Create IBC transfer keeper
app.IBCTransferKeeper = ibctransferkeeper.NewKeeper(
app.appCodec,
app.GetKey(ibctransfertypes.StoreKey),
app.GetSubspace(ibctransfertypes.ModuleName),
app.IBCKeeper.ChannelKeeper,
app.IBCKeeper.ChannelKeeper,
&app.IBCKeeper.PortKeeper,
app.AccountKeeper,
app.BankKeeper,
scopedIBCTransferKeeper,
)

// Create interchain account keepers
app.ICAHostKeeper = icahostkeeper.NewKeeper(
app.appCodec,
app.GetKey(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(),
)
app.ICAControllerKeeper = icacontrollerkeeper.NewKeeper(
app.appCodec,
app.GetKey(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(),
)
app.GovKeeper.SetLegacyRouter(govRouter)

// Create IBC modules with ibcfee middleware
transferIBCModule := ibcfee.NewIBCMiddleware(ibctransfer.NewIBCModule(app.IBCTransferKeeper), app.IBCFeeKeeper)

// integration point for custom authentication modules
var noAuthzModule porttypes.IBCModule
icaControllerIBCModule := ibcfee.NewIBCMiddleware(
icacontroller.NewIBCMiddleware(noAuthzModule, app.ICAControllerKeeper),
app.IBCFeeKeeper,
)

icaHostIBCModule := ibcfee.NewIBCMiddleware(icahost.NewIBCModule(app.ICAHostKeeper), app.IBCFeeKeeper)

// Create static IBC router, add transfer route, then set and seal it
ibcRouter := porttypes.NewRouter().
AddRoute(ibctransfertypes.ModuleName, transferIBCModule).
AddRoute(icacontrollertypes.SubModuleName, icaControllerIBCModule).
AddRoute(icahosttypes.SubModuleName, icaHostIBCModule)

// this line is used by starport scaffolding # ibc/app/module

app.IBCKeeper.SetRouter(ibcRouter)

// NOTE: Any module instantiated in the module manager that is later modified
// must be passed by reference here.
legacyModules := []module.AppModule{
ibc.NewAppModule(app.IBCKeeper),
ibctransfer.NewAppModule(app.IBCTransferKeeper),
ibcfee.NewAppModule(app.IBCFeeKeeper),
ica.NewAppModule(&app.ICAControllerKeeper, &app.ICAHostKeeper),
}
if err := app.RegisterModules(legacyModules...); err != nil {
panic(err)
}

// TODO: do we need this?
//cfg := app.Configurator()
//for _, m := range legacyModules {
// if s, ok := m.(module.HasServices); ok {
// s.RegisterServices(cfg)
// }
//}

// register additional types
ibctm.AppModuleBasic{}.RegisterInterfaces(app.interfaceRegistry)
solomachine.AppModuleBasic{}.RegisterInterfaces(app.interfaceRegistry)

app.ScopedIBCKeeper = scopedIBCKeeper
app.ScopedIBCTransferKeeper = scopedIBCTransferKeeper
app.ScopedICAHostKeeper = scopedICAHostKeeper
app.ScopedICAControllerKeeper = scopedICAControllerKeeper
}
144 changes: 0 additions & 144 deletions app/keepers.go

This file was deleted.

Loading

0 comments on commit da3bbcc

Please sign in to comment.