diff --git a/app/app.go b/app/app.go index 7ab83707..ac922c36 100644 --- a/app/app.go +++ b/app/app.go @@ -25,90 +25,28 @@ import ( "github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth/ante" - authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" "github.com/cosmos/cosmos-sdk/x/auth/posthandler" authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation" authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/cosmos/cosmos-sdk/x/auth/vesting" - vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" - "github.com/cosmos/cosmos-sdk/x/authz" - authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper" - authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - "github.com/cosmos/cosmos-sdk/x/capability" - capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" - capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" - "github.com/cosmos/cosmos-sdk/x/consensus" - consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper" - consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types" "github.com/cosmos/cosmos-sdk/x/crisis" - crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper" - crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" - distr "github.com/cosmos/cosmos-sdk/x/distribution" - distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" - distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" - "github.com/cosmos/cosmos-sdk/x/evidence" - evidencekeeper "github.com/cosmos/cosmos-sdk/x/evidence/keeper" - evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" - "github.com/cosmos/cosmos-sdk/x/feegrant" - feegrantkeeper "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" - feegrantmodule "github.com/cosmos/cosmos-sdk/x/feegrant/module" - "github.com/cosmos/cosmos-sdk/x/genutil" - genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" - "github.com/cosmos/cosmos-sdk/x/gov" govclient "github.com/cosmos/cosmos-sdk/x/gov/client" - govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - govtypesv1beta1 "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" - minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" - "github.com/cosmos/cosmos-sdk/x/params" paramsclient "github.com/cosmos/cosmos-sdk/x/params/client" - paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper" - paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" - paramproposal "github.com/cosmos/cosmos-sdk/x/params/types/proposal" - "github.com/cosmos/cosmos-sdk/x/slashing" - slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper" - slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" - "github.com/cosmos/cosmos-sdk/x/staking" - stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - bank "github.com/terra-money/alliance/custom/bank" - bankkeeper "github.com/terra-money/alliance/custom/bank/keeper" - alliancemodule "github.com/terra-money/alliance/x/alliance" alliancemoduleclient "github.com/terra-money/alliance/x/alliance/client" - alliancemodulekeeper "github.com/terra-money/alliance/x/alliance/keeper" alliancemoduletypes "github.com/terra-money/alliance/x/alliance/types" - "github.com/cosmos/cosmos-sdk/x/upgrade" upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client" - upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" - 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" - icatypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/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" transfer "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" ibcclientclient "github.com/cosmos/ibc-go/v7/modules/core/02-client/client" - ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" ibcporttypes "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" - ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" dbm "github.com/cometbft/cometbft-db" abci "github.com/cometbft/cometbft/abci/types" @@ -121,24 +59,12 @@ import ( wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + "github.com/Team-Kujira/core/app/keepers" "github.com/Team-Kujira/core/app/openapiconsole" appparams "github.com/Team-Kujira/core/app/params" - "github.com/Team-Kujira/core/wasmbinding" - "github.com/Team-Kujira/core/x/denom" - denomkeeper "github.com/Team-Kujira/core/x/denom/keeper" - denomtypes "github.com/Team-Kujira/core/x/denom/types" "github.com/Team-Kujira/core/docs" - scheduler "github.com/Team-Kujira/core/x/scheduler" schedulerclient "github.com/Team-Kujira/core/x/scheduler/client" - schedulerkeeper "github.com/Team-Kujira/core/x/scheduler/keeper" - schedulertypes "github.com/Team-Kujira/core/x/scheduler/types" - - "github.com/Team-Kujira/core/x/oracle" - oraclekeeper "github.com/Team-Kujira/core/x/oracle/keeper" - oracletypes "github.com/Team-Kujira/core/x/oracle/types" - - storetypes "github.com/cosmos/cosmos-sdk/store/types" ) const ( @@ -177,59 +103,6 @@ func getGovProposalHandlers() []govclient.ProposalHandler { var ( // DefaultNodeHome default home directories for the application daemon DefaultNodeHome string - - // ModuleBasics defines the module BasicManager is in charge of setting up basic, - // non-dependant module elements, such as codec registration - // and genesis verification. - ModuleBasics = module.NewBasicManager( - auth.AppModuleBasic{}, - genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator), - authzmodule.AppModuleBasic{}, - bank.AppModule{}, - capability.AppModuleBasic{}, - staking.AppModuleBasic{}, - mint.AppModuleBasic{}, - distr.AppModuleBasic{}, - gov.NewAppModuleBasic(getGovProposalHandlers()), - params.AppModuleBasic{}, - consensus.AppModuleBasic{}, - crisis.AppModuleBasic{}, - slashing.AppModuleBasic{}, - feegrantmodule.AppModuleBasic{}, - ibc.AppModuleBasic{}, - ibctm.AppModuleBasic{}, - - upgrade.AppModuleBasic{}, - evidence.AppModuleBasic{}, - transfer.AppModuleBasic{}, - vesting.AppModuleBasic{}, - wasm.AppModuleBasic{}, - ica.AppModuleBasic{}, - ibcfee.AppModuleBasic{}, - denom.AppModuleBasic{}, - scheduler.AppModuleBasic{}, - oracle.AppModuleBasic{}, - alliancemodule.AppModuleBasic{}, - ) - - // module account permissions - maccPerms = map[string][]string{ - authtypes.FeeCollectorName: nil, - distrtypes.ModuleName: nil, - minttypes.ModuleName: {authtypes.Minter}, - stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, - stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, - govtypes.ModuleName: {authtypes.Burner}, - ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, - ibcfeetypes.ModuleName: nil, - icatypes.ModuleName: nil, - wasmtypes.ModuleName: {authtypes.Burner}, - denomtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, - schedulertypes.ModuleName: nil, - oracletypes.ModuleName: nil, - alliancemoduletypes.ModuleName: {authtypes.Minter, authtypes.Burner}, - alliancemoduletypes.RewardsPoolName: nil, - } ) var ( @@ -251,53 +124,13 @@ func init() { // capabilities aren't needed for testing. type App struct { *baseapp.BaseApp + keepers.AppKeepers cdc *codec.LegacyAmino appCodec codec.Codec txConfig client.TxConfig interfaceRegistry types.InterfaceRegistry - // keys to access the substores - keys map[string]*storetypes.KVStoreKey - tkeys map[string]*storetypes.TransientStoreKey - memKeys map[string]*storetypes.MemoryStoreKey - - // keepers - AccountKeeper authkeeper.AccountKeeper - AuthzKeeper authzkeeper.Keeper - BankKeeper bankkeeper.Keeper - CapabilityKeeper *capabilitykeeper.Keeper - StakingKeeper *stakingkeeper.Keeper - SlashingKeeper slashingkeeper.Keeper - MintKeeper mintkeeper.Keeper - DistrKeeper distrkeeper.Keeper - GovKeeper govkeeper.Keeper - CrisisKeeper *crisiskeeper.Keeper - UpgradeKeeper *upgradekeeper.Keeper - ConsensusParamsKeeper consensusparamkeeper.Keeper - ParamsKeeper paramskeeper.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 - - EvidenceKeeper evidencekeeper.Keeper - TransferKeeper ibctransferkeeper.Keeper - FeeGrantKeeper feegrantkeeper.Keeper - WasmKeeper wasmkeeper.Keeper - DenomKeeper *denomkeeper.Keeper - SchedulerKeeper schedulerkeeper.Keeper - OracleKeeper oraclekeeper.Keeper - AllianceKeeper alliancemodulekeeper.Keeper - - // make scoped keepers public for test purposes - ScopedIBCKeeper capabilitykeeper.ScopedKeeper - ScopedTransferKeeper capabilitykeeper.ScopedKeeper - ScopedWasmKeeper capabilitykeeper.ScopedKeeper - ScopedIBCFeeKeeper capabilitykeeper.ScopedKeeper - ScopedICAHostKeeper capabilitykeeper.ScopedKeeper - ScopedICAControllerKeeper capabilitykeeper.ScopedKeeper - // ModuleManager is the module manager ModuleManager *module.Manager @@ -322,7 +155,6 @@ func New( appCodec := encodingConfig.Codec cdc := encodingConfig.Amino interfaceRegistry := encodingConfig.InterfaceRegistry - authority := authtypes.NewModuleAddress(govtypes.ModuleName).String() txConfig := encodingConfig.TxConfig bApp := baseapp.NewBaseApp(Name, logger, db, txConfig.TxDecoder(), baseAppOptions...) @@ -331,357 +163,40 @@ func New( bApp.SetInterfaceRegistry(interfaceRegistry) bApp.SetTxEncoder(txConfig.TxEncoder()) - keys := sdk.NewKVStoreKeys( - authtypes.StoreKey, - banktypes.StoreKey, - stakingtypes.StoreKey, - crisistypes.StoreKey, - minttypes.StoreKey, - distrtypes.StoreKey, - slashingtypes.StoreKey, - govtypes.StoreKey, - paramstypes.StoreKey, - consensusparamtypes.StoreKey, - upgradetypes.StoreKey, - feegrant.StoreKey, - evidencetypes.StoreKey, - capabilitytypes.StoreKey, - authzkeeper.StoreKey, - ibcexported.StoreKey, - ibctransfertypes.StoreKey, - ibcfeetypes.StoreKey, - - wasmtypes.StoreKey, - icahosttypes.StoreKey, - icacontrollertypes.StoreKey, - denomtypes.StoreKey, - schedulertypes.StoreKey, - oracletypes.StoreKey, - AllianceStoreKey, - ) - - tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) - memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) - app := &App{ BaseApp: bApp, cdc: cdc, appCodec: appCodec, txConfig: txConfig, interfaceRegistry: interfaceRegistry, - keys: keys, - tkeys: tkeys, - memKeys: memKeys, } - app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter()) - - app.ParamsKeeper = initParamsKeeper(appCodec, cdc, keys[paramstypes.StoreKey], tkeys[paramstypes.TStoreKey]) - - // set the BaseApp's parameter store - app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper( - appCodec, - keys[consensusparamtypes.StoreKey], - authority, - ) - - bApp.SetParamStore(&app.ConsensusParamsKeeper) - - // add capability keeper and ScopeToModule for ibc module - app.CapabilityKeeper = capabilitykeeper.NewKeeper( - appCodec, - keys[capabilitytypes.StoreKey], - memKeys[capabilitytypes.MemStoreKey], - ) - - // grant capabilities for the ibc and ibc-transfer modules - scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibcexported.ModuleName) - scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName) - - // add keepers - app.AccountKeeper = authkeeper.NewAccountKeeper( - appCodec, - keys[authtypes.StoreKey], - authtypes.ProtoBaseAccount, - maccPerms, - AccountAddressPrefix, - authority, - ) - - app.AuthzKeeper = authzkeeper.NewKeeper( - keys[authzkeeper.StoreKey], - appCodec, - app.MsgServiceRouter(), - app.AccountKeeper, - ) - - app.BankKeeper = bankkeeper.NewBaseKeeper( - appCodec, - keys[banktypes.StoreKey], - app.AccountKeeper, - BlockedAddresses(), - authority, - ) - - app.StakingKeeper = stakingkeeper.NewKeeper( - appCodec, - keys[stakingtypes.StoreKey], - app.AccountKeeper, - app.BankKeeper, - authority, - ) - - app.MintKeeper = mintkeeper.NewKeeper( - appCodec, - keys[minttypes.StoreKey], - app.StakingKeeper, - app.AccountKeeper, - app.BankKeeper, - authtypes.FeeCollectorName, - authority, - ) - - app.DistrKeeper = distrkeeper.NewKeeper( - appCodec, - keys[distrtypes.StoreKey], - app.AccountKeeper, - app.BankKeeper, - app.StakingKeeper, - authtypes.FeeCollectorName, - authority, - ) - - app.AllianceKeeper = alliancemodulekeeper.NewKeeper( - appCodec, - keys[AllianceStoreKey], - app.AccountKeeper, - app.BankKeeper, - app.StakingKeeper, - app.DistrKeeper, - authtypes.FeeCollectorName, - authority, - ) - - app.BankKeeper.RegisterKeepers(app.AllianceKeeper, app.StakingKeeper) - - app.SlashingKeeper = slashingkeeper.NewKeeper( - appCodec, - cdc, - keys[slashingtypes.StoreKey], - app.StakingKeeper, - authority, - ) - - invCheckPeriod := cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)) - app.CrisisKeeper = crisiskeeper.NewKeeper( - appCodec, - keys[crisistypes.StoreKey], - invCheckPeriod, - app.BankKeeper, - authtypes.FeeCollectorName, - authority, - ) - - app.FeeGrantKeeper = feegrantkeeper.NewKeeper( - appCodec, - keys[feegrant.StoreKey], - app.AccountKeeper, - ) - + // TODO: should this go in `keepers/keepers.go`? skipUpgradeHeights := map[int64]bool{} for _, h := range cast.ToIntSlice(appOpts.Get(server.FlagUnsafeSkipUpgrades)) { skipUpgradeHeights[int64(h)] = true } - homePath := cast.ToString(appOpts.Get(flags.FlagHome)) - app.UpgradeKeeper = upgradekeeper.NewKeeper( - skipUpgradeHeights, - keys[upgradetypes.StoreKey], - appCodec, - homePath, - app.BaseApp, - authority, - ) - - // register the staking hooks - app.StakingKeeper.SetHooks( - stakingtypes.NewMultiStakingHooks(app.DistrKeeper.Hooks(), app.SlashingKeeper.Hooks(), - app.AllianceKeeper.StakingHooks()), - ) - - // ... other modules keepers - - // Create IBC Keeper - app.IBCKeeper = ibckeeper.NewKeeper( - appCodec, - keys[ibcexported.StoreKey], - app.GetSubspace(ibcexported.ModuleName), - app.StakingKeeper, - app.UpgradeKeeper, - scopedIBCKeeper, - ) - - // IBC Fee Module keeper - - app.IBCFeeKeeper = ibcfeekeeper.NewKeeper( - appCodec, - keys[ibcfeetypes.StoreKey], - app.IBCKeeper.ChannelKeeper, - app.IBCKeeper.ChannelKeeper, - &app.IBCKeeper.PortKeeper, - app.AccountKeeper, - app.BankKeeper, - ) - - scopedICAHostKeeper := app.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName) - _ = app.GetSubspace(icahosttypes.SubModuleName) - - app.ICAHostKeeper = icahostkeeper.NewKeeper( - appCodec, - keys[icahosttypes.StoreKey], - app.GetSubspace(icahosttypes.SubModuleName), - app.IBCFeeKeeper, - app.IBCKeeper.ChannelKeeper, - &app.IBCKeeper.PortKeeper, - app.AccountKeeper, - scopedICAHostKeeper, - app.MsgServiceRouter(), - ) - - scopedICAControllerKeeper := app.CapabilityKeeper.ScopeToModule(icacontrollertypes.SubModuleName) - app.ICAControllerKeeper = icacontrollerkeeper.NewKeeper( - appCodec, - keys[icacontrollertypes.StoreKey], - app.GetSubspace(icacontrollertypes.SubModuleName), - app.IBCFeeKeeper, - app.IBCKeeper.ChannelKeeper, - &app.IBCKeeper.PortKeeper, - scopedICAControllerKeeper, - app.MsgServiceRouter(), - ) - icaModule := ica.NewAppModule(&app.ICAControllerKeeper, &app.ICAHostKeeper) - - // Create Transfer Keepers - app.TransferKeeper = ibctransferkeeper.NewKeeper( - appCodec, - keys[ibctransfertypes.StoreKey], - app.GetSubspace(ibctransfertypes.ModuleName), - app.IBCFeeKeeper, - app.IBCKeeper.ChannelKeeper, - &app.IBCKeeper.PortKeeper, - app.AccountKeeper, - app.BankKeeper, - scopedTransferKeeper, - ) - - transferModule := transfer.NewAppModule(app.TransferKeeper) - - app.SchedulerKeeper = schedulerkeeper.NewKeeper( - appCodec, - keys[denomtypes.StoreKey], - app.GetSubspace(schedulertypes.ModuleName), - ) - - app.OracleKeeper = oraclekeeper.NewKeeper( - appCodec, - keys[oracletypes.StoreKey], - app.GetSubspace(oracletypes.ModuleName), - app.AccountKeeper, - app.BankKeeper, - app.DistrKeeper, - app.SlashingKeeper, - app.StakingKeeper, - distrtypes.ModuleName, - ) - - denomKeeper := denomkeeper.NewKeeper( - appCodec, - app.keys[denomtypes.StoreKey], - app.GetSubspace(denomtypes.ModuleName), - app.AccountKeeper, - app.BankKeeper.WithMintCoinsRestriction(denomtypes.NewdenomDenomMintCoinsRestriction()), - app.DistrKeeper, - ) - - app.DenomKeeper = &denomKeeper - - scopedWasmKeeper := app.CapabilityKeeper.ScopeToModule(wasmtypes.ModuleName) - wasmDir := filepath.Join(homePath, "wasm") - wasmConfig, err := wasm.ReadWasmConfig(appOpts) - if err != nil { - panic(fmt.Sprintf("error while reading wasm config: %s", err)) - } - - // The last arguments can contain custom message handlers, and custom query handlers, - // if we want to allow any custom callbacks - availableCapabilities := "iterator,staking,stargate,cosmwasm_1_1,cosmwasm_1_2" - wasmOpts = append(wasmbinding.RegisterCustomPlugins( - app.BankKeeper, - app.OracleKeeper, - *app.DenomKeeper, - ), wasmOpts...) - - app.WasmKeeper = wasmkeeper.NewKeeper( - appCodec, - keys[wasmtypes.StoreKey], - app.AccountKeeper, - app.BankKeeper, - app.StakingKeeper, - distrkeeper.NewQuerier(app.DistrKeeper), - app.IBCFeeKeeper, - app.IBCKeeper.ChannelKeeper, - &app.IBCKeeper.PortKeeper, - scopedWasmKeeper, - app.TransferKeeper, - app.MsgServiceRouter(), - app.GRPCQueryRouter(), - wasmDir, - wasmConfig, - availableCapabilities, - authority, - wasmOpts..., - ) - - // 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 := govtypesv1beta1.NewRouter() - govRouter.AddRoute(govtypes.RouterKey, govtypesv1beta1.ProposalHandler). - AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)). - AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)). - AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper)). - AddRoute(schedulertypes.RouterKey, schedulerkeeper.NewSchedulerProposalHandler(app.SchedulerKeeper)). - AddRoute(alliancemoduletypes.RouterKey, alliancemodule.NewAllianceProposalHandler(app.AllianceKeeper)) - - // Create evidence Keeper for to register the IBC light client misbehaviour evidence route - evidenceKeeper := evidencekeeper.NewKeeper( - appCodec, - keys[evidencetypes.StoreKey], - app.StakingKeeper, - app.SlashingKeeper, - ) - // If evidence needs to be handled for the app, set routes in router here and seal - app.EvidenceKeeper = *evidenceKeeper + invCheckPeriod := cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)) - govKeeper := govkeeper.NewKeeper( + // Setup keepers + app.AppKeepers = keepers.NewAppKeepers( appCodec, - keys[govtypes.StoreKey], - app.AccountKeeper, - app.BankKeeper, - app.StakingKeeper, - app.MsgServiceRouter(), - govtypes.DefaultConfig(), - authority, + bApp, + cdc, + maccPerms, + BlockedAddresses(), + skipUpgradeHeights, + homePath, + invCheckPeriod, + // enabledProposals, + AccountAddressPrefix, + AllianceStoreKey, + appOpts, + wasmOpts, ) - govKeeper.SetLegacyRouter(govRouter) - - app.GovKeeper = *govKeeper.SetHooks( - govtypes.NewMultiGovHooks( - // register the governance hooks - ), - ) + app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter()) // Create Transfer Stack var transferStack ibcporttypes.IBCModule @@ -727,221 +242,16 @@ func New( // NOTE: Any module instantiated in the module manager that is later modified // must be passed by reference here. - app.ModuleManager = module.NewManager( - genutil.NewAppModule( - app.AccountKeeper, - app.StakingKeeper, - app.BaseApp.DeliverTx, - encodingConfig.TxConfig, - ), - - auth.NewAppModule( - appCodec, - app.AccountKeeper, - authsims.RandomGenesisAccounts, - app.GetSubspace(authtypes.ModuleName), - ), - - authzmodule.NewAppModule( - appCodec, - app.AuthzKeeper, - app.AccountKeeper, - app.BankKeeper, - app.interfaceRegistry, - ), - - vesting.NewAppModule( - app.AccountKeeper, - app.BankKeeper, - ), - - bank.NewAppModule( - appCodec, - app.BankKeeper, - app.AccountKeeper, - app.GetSubspace(banktypes.ModuleName), - ), - - capability.NewAppModule( - appCodec, - *app.CapabilityKeeper, - false, - ), - - feegrantmodule.NewAppModule( - appCodec, - app.AccountKeeper, - app.BankKeeper, - app.FeeGrantKeeper, - app.interfaceRegistry, - ), - - gov.NewAppModule( - appCodec, - &app.GovKeeper, - app.AccountKeeper, - app.BankKeeper, - app.GetSubspace(govtypes.ModuleName), - ), - - mint.NewAppModule( - appCodec, - app.MintKeeper, - app.AccountKeeper, - nil, - app.GetSubspace(minttypes.ModuleName), - ), - - slashing.NewAppModule( - appCodec, - app.SlashingKeeper, - app.AccountKeeper, - app.BankKeeper, - app.StakingKeeper, - app.GetSubspace(slashingtypes.ModuleName), - ), - - distr.NewAppModule( - appCodec, - app.DistrKeeper, - app.AccountKeeper, - app.BankKeeper, - app.StakingKeeper, - app.GetSubspace(distrtypes.ModuleName), - ), - - staking.NewAppModule( - appCodec, - app.StakingKeeper, - app.AccountKeeper, - app.BankKeeper, - app.GetSubspace(stakingtypes.ModuleName), - ), - - upgrade.NewAppModule(app.UpgradeKeeper), - evidence.NewAppModule(app.EvidenceKeeper), - ibc.NewAppModule(app.IBCKeeper), - params.NewAppModule(app.ParamsKeeper), - transferModule, - - ibcfee.NewAppModule(app.IBCFeeKeeper), - - consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper), - - wasm.NewAppModule( - appCodec, - &app.WasmKeeper, - app.StakingKeeper, - app.AccountKeeper, - app.BankKeeper, - app.MsgServiceRouter(), - app.GetSubspace(wasmtypes.ModuleName), - ), - - denom.NewAppModule( - appCodec, - *app.DenomKeeper, - app.AccountKeeper, - app.BankKeeper, - ), - - icaModule, - - scheduler.NewAppModule( - appCodec, - app.SchedulerKeeper, - app.AccountKeeper, - app.BankKeeper, - wasmkeeper.NewDefaultPermissionKeeper(app.WasmKeeper), - ), - - oracle.NewAppModule( - appCodec, - app.OracleKeeper, - app.AccountKeeper, - app.BankKeeper, - ), - - alliancemodule.NewAppModule( - appCodec, - app.AllianceKeeper, - app.StakingKeeper, - app.AccountKeeper, - app.BankKeeper, - app.interfaceRegistry, - app.GetSubspace(alliancemoduletypes.ModuleName), - ), - - crisis.NewAppModule( - app.CrisisKeeper, - skipGenesisInvariants, - app.GetSubspace(crisistypes.ModuleName), - ), - ) + app.ModuleManager = module.NewManager(appModules(app, encodingConfig, skipGenesisInvariants)...) // During begin block slashing happens after distr.BeginBlocker so that // there is nothing left over in the validator fee pool, so as to keep the // CanWithdrawInvariant invariant. // NOTE: staking module is required if HistoricalEntries param > 0 - app.ModuleManager.SetOrderBeginBlockers( - upgradetypes.ModuleName, - capabilitytypes.ModuleName, - minttypes.ModuleName, - distrtypes.ModuleName, - slashingtypes.ModuleName, - evidencetypes.ModuleName, - stakingtypes.ModuleName, - vestingtypes.ModuleName, - ibcexported.ModuleName, - ibctransfertypes.ModuleName, - authtypes.ModuleName, - authz.ModuleName, - banktypes.ModuleName, - govtypes.ModuleName, - crisistypes.ModuleName, - genutiltypes.ModuleName, - feegrant.ModuleName, - paramstypes.ModuleName, - consensusparamtypes.ModuleName, - icatypes.ModuleName, - ibcfeetypes.ModuleName, - - wasmtypes.ModuleName, - denomtypes.ModuleName, - schedulertypes.ModuleName, - oracletypes.ModuleName, - alliancemoduletypes.ModuleName, - ) - app.ModuleManager.SetOrderEndBlockers( - crisistypes.ModuleName, - govtypes.ModuleName, - stakingtypes.ModuleName, - capabilitytypes.ModuleName, - authtypes.ModuleName, - authz.ModuleName, - banktypes.ModuleName, - distrtypes.ModuleName, - slashingtypes.ModuleName, - vestingtypes.ModuleName, - minttypes.ModuleName, - genutiltypes.ModuleName, - evidencetypes.ModuleName, - feegrant.ModuleName, - paramstypes.ModuleName, - upgradetypes.ModuleName, - ibcexported.ModuleName, - ibctransfertypes.ModuleName, - consensusparamtypes.ModuleName, - icatypes.ModuleName, - ibcfeetypes.ModuleName, - - wasmtypes.ModuleName, - denomtypes.ModuleName, - schedulertypes.ModuleName, - oracletypes.ModuleName, - alliancemoduletypes.ModuleName, - ) + app.ModuleManager.SetOrderBeginBlockers(orderBeginBlockers()...) + + app.ModuleManager.SetOrderEndBlockers(orderEndBlockers()...) // NOTE: The genutils module must occur after staking so that pools are // properly initialized with tokens from genesis accounts. @@ -951,35 +261,7 @@ func New( // can do so safely. // NOTE: wasm module should be at the end as it can call other module functionality direct or via message dispatching during // genesis phase. For example bank transfer, auth account check, staking, ... - app.ModuleManager.SetOrderInitGenesis( - capabilitytypes.ModuleName, - authtypes.ModuleName, - authz.ModuleName, - banktypes.ModuleName, - distrtypes.ModuleName, - stakingtypes.ModuleName, - vestingtypes.ModuleName, - slashingtypes.ModuleName, - govtypes.ModuleName, - minttypes.ModuleName, - crisistypes.ModuleName, - ibcexported.ModuleName, - genutiltypes.ModuleName, - evidencetypes.ModuleName, - paramstypes.ModuleName, - upgradetypes.ModuleName, - feegrant.ModuleName, - ibctransfertypes.ModuleName, - consensusparamtypes.ModuleName, - icatypes.ModuleName, - ibcfeetypes.ModuleName, - - denomtypes.ModuleName, - schedulertypes.ModuleName, - oracletypes.ModuleName, - alliancemoduletypes.ModuleName, - wasmtypes.ModuleName, - ) + app.ModuleManager.SetOrderInitGenesis(orderInitBlockers()...) app.ModuleManager.RegisterInvariants(app.CrisisKeeper) app.ModuleManager.RegisterServices(app.configurator) @@ -1001,9 +283,14 @@ func New( app.sm.RegisterStoreDecoders() // initialize stores - app.MountKVStores(keys) - app.MountTransientStores(tkeys) - app.MountMemoryStores(memKeys) + app.MountKVStores(app.GetKVStoreKey()) + app.MountTransientStores(app.GetTransientStoreKey()) + app.MountMemoryStores(app.GetMemoryStoreKey()) + + wasmConfig, err := wasm.ReadWasmConfig(appOpts) + if err != nil { + panic("error while reading wasm config: " + err.Error()) + } anteHandler, err := NewAnteHandler( HandlerOptions{ @@ -1016,7 +303,7 @@ func New( }, IBCKeeper: app.IBCKeeper, WasmConfig: &wasmConfig, - TXCounterStoreKey: keys[wasmtypes.StoreKey], + TXCounterStoreKey: app.GetKey(wasmtypes.StoreKey), }, ) if err != nil { @@ -1066,12 +353,6 @@ func New( } } - app.ScopedIBCKeeper = scopedIBCKeeper - app.ScopedTransferKeeper = scopedTransferKeeper - app.ScopedWasmKeeper = scopedWasmKeeper - app.ScopedICAHostKeeper = scopedICAHostKeeper - app.ScopedICAControllerKeeper = scopedICAControllerKeeper - return app } @@ -1177,35 +458,6 @@ func (app *App) DefaultGenesis() map[string]json.RawMessage { return ModuleBasics.DefaultGenesis(app.appCodec) } -// GetKey returns the KVStoreKey for the provided store key. -// -// NOTE: This is solely to be used for testing purposes. -func (app *App) GetKey(storeKey string) *storetypes.KVStoreKey { - return app.keys[storeKey] -} - -// GetTKey returns the TransientStoreKey for the provided store key. -// -// NOTE: This is solely to be used for testing purposes. -func (app *App) GetTKey(storeKey string) *storetypes.TransientStoreKey { - return app.tkeys[storeKey] -} - -// GetMemKey returns the MemStoreKey for the provided mem key. -// -// NOTE: This is solely used for testing purposes. -func (app *App) GetMemKey(storeKey string) *storetypes.MemoryStoreKey { - return app.memKeys[storeKey] -} - -// GetSubspace returns a param subspace for a given module name. -// -// NOTE: This is solely to be used for testing purposes. -func (app *App) GetSubspace(moduleName string) paramstypes.Subspace { - subspace, _ := app.ParamsKeeper.GetSubspace(moduleName) - return subspace -} - // RegisterAPIRoutes registers all application module routes with the provided // API server. func (app *App) RegisterAPIRoutes(apiSvr *api.Server, _ config.APIConfig) { @@ -1246,31 +498,6 @@ func GetMaccPerms() map[string][]string { return dupMaccPerms } -// initParamsKeeper init params keeper and its subspaces -func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey storetypes.StoreKey) paramskeeper.Keeper { - paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, key, tkey) - - paramsKeeper.Subspace(authtypes.ModuleName) - paramsKeeper.Subspace(banktypes.ModuleName) - paramsKeeper.Subspace(stakingtypes.ModuleName) - paramsKeeper.Subspace(minttypes.ModuleName) - paramsKeeper.Subspace(distrtypes.ModuleName) - paramsKeeper.Subspace(slashingtypes.ModuleName) - paramsKeeper.Subspace(govtypes.ModuleName) - paramsKeeper.Subspace(crisistypes.ModuleName) - paramsKeeper.Subspace(ibctransfertypes.ModuleName) - paramsKeeper.Subspace(ibcexported.ModuleName) - paramsKeeper.Subspace(icahosttypes.SubModuleName) - paramsKeeper.Subspace(icacontrollertypes.SubModuleName) - paramsKeeper.Subspace(denomtypes.ModuleName) - paramsKeeper.Subspace(wasmtypes.ModuleName) - paramsKeeper.Subspace(schedulertypes.ModuleName) - paramsKeeper.Subspace(oracletypes.ModuleName) - paramsKeeper.Subspace(alliancemoduletypes.ModuleName) - - return paramsKeeper -} - // SimulationManager implements the SimulationApp interface func (app *App) SimulationManager() *module.SimulationManager { return app.sm diff --git a/app/export.go b/app/export.go index a6513819..53f2b87e 100644 --- a/app/export.go +++ b/app/export.go @@ -156,7 +156,7 @@ func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []str // Iterate through validators by power descending, reset bond heights, and // update bond intra-tx counters. - store := ctx.KVStore(app.keys[stakingtypes.StoreKey]) + store := ctx.KVStore(app.GetKey(stakingtypes.StoreKey)) iter := sdk.KVStoreReversePrefixIterator(store, stakingtypes.ValidatorsKey) counter := int16(0) diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go new file mode 100644 index 00000000..fa3a4100 --- /dev/null +++ b/app/keepers/keepers.go @@ -0,0 +1,500 @@ +package keepers + +import ( + "fmt" + "path/filepath" + + "github.com/Team-Kujira/core/wasmbinding" + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/codec" + servertypes "github.com/cosmos/cosmos-sdk/server/types" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/cosmos/cosmos-sdk/x/feegrant" + feegrantkeeper "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + "github.com/cosmos/cosmos-sdk/x/params" + paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" + "github.com/cosmos/cosmos-sdk/x/upgrade" + ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper" + alliancemoduletypes "github.com/terra-money/alliance/x/alliance/types" + + icacontrollertypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/types" + icahosttypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/types" + ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" + + "github.com/CosmWasm/wasmd/x/wasm" + wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" + authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" + capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper" + consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types" + crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper" + crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" + distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" + distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + evidencekeeper "github.com/cosmos/cosmos-sdk/x/evidence/keeper" + evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" + govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper" + govtypesv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" + mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" + paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper" + paramproposal "github.com/cosmos/cosmos-sdk/x/params/types/proposal" + slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper" + slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" + stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + bankkeeper "github.com/terra-money/alliance/custom/bank/keeper" + alliancemodule "github.com/terra-money/alliance/x/alliance" + alliancemodulekeeper "github.com/terra-money/alliance/x/alliance/keeper" + + upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + + icacontrollerkeeper "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/keeper" + icahostkeeper "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/keeper" + ibcfeekeeper "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/keeper" + ibcfeetypes "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/types" + ibctransferkeeper "github.com/cosmos/ibc-go/v7/modules/apps/transfer/keeper" + ibcclient "github.com/cosmos/ibc-go/v7/modules/core/02-client" + ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" + ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" + + denomkeeper "github.com/Team-Kujira/core/x/denom/keeper" + denomtypes "github.com/Team-Kujira/core/x/denom/types" + + schedulerkeeper "github.com/Team-Kujira/core/x/scheduler/keeper" + schedulertypes "github.com/Team-Kujira/core/x/scheduler/types" + + oraclekeeper "github.com/Team-Kujira/core/x/oracle/keeper" + oracletypes "github.com/Team-Kujira/core/x/oracle/types" +) + +type AppKeepers struct { + // keys to access the substores + keys map[string]*storetypes.KVStoreKey + tkeys map[string]*storetypes.TransientStoreKey + memKeys map[string]*storetypes.MemoryStoreKey + + // keepers + AccountKeeper authkeeper.AccountKeeper + AuthzKeeper authzkeeper.Keeper + BankKeeper bankkeeper.Keeper + CapabilityKeeper *capabilitykeeper.Keeper + StakingKeeper *stakingkeeper.Keeper + SlashingKeeper slashingkeeper.Keeper + MintKeeper mintkeeper.Keeper + DistrKeeper distrkeeper.Keeper + GovKeeper govkeeper.Keeper + CrisisKeeper *crisiskeeper.Keeper + UpgradeKeeper *upgradekeeper.Keeper + ConsensusParamsKeeper consensusparamkeeper.Keeper + ParamsKeeper paramskeeper.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 + + EvidenceKeeper evidencekeeper.Keeper + TransferKeeper ibctransferkeeper.Keeper + FeeGrantKeeper feegrantkeeper.Keeper + WasmKeeper wasmkeeper.Keeper + DenomKeeper *denomkeeper.Keeper + SchedulerKeeper schedulerkeeper.Keeper + OracleKeeper oraclekeeper.Keeper + AllianceKeeper alliancemodulekeeper.Keeper + + // make scoped keepers public for test purposes + ScopedIBCKeeper capabilitykeeper.ScopedKeeper + ScopedTransferKeeper capabilitykeeper.ScopedKeeper + ScopedWasmKeeper capabilitykeeper.ScopedKeeper + ScopedIBCFeeKeeper capabilitykeeper.ScopedKeeper + ScopedICAHostKeeper capabilitykeeper.ScopedKeeper + ScopedICAControllerKeeper capabilitykeeper.ScopedKeeper +} + +func NewAppKeepers( + appCodec codec.Codec, + bApp *baseapp.BaseApp, + cdc *codec.LegacyAmino, + maccPerms map[string][]string, + blockedAddresses map[string]bool, + skipUpgradeHeights map[int64]bool, + homePath string, + invCheckPeriod uint, + // enabledProposals []wasm.ProposalType, + AccountAddressPrefix string, + AllianceStoreKey string, + appOpts servertypes.AppOptions, + wasmOpts []wasm.Option, +) AppKeepers { + appKeepers := AppKeepers{} + + // Set keys KVStoreKey, TransientStoreKey, MemoryStoreKey + appKeepers.GenerateKeys(AllianceStoreKey) + + authority := authtypes.NewModuleAddress(govtypes.ModuleName).String() + + appKeepers.ParamsKeeper = initParamsKeeper(appCodec, cdc, appKeepers.keys[paramstypes.StoreKey], appKeepers.tkeys[paramstypes.TStoreKey]) + + // set the BaseApp's parameter store + appKeepers.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper( + appCodec, + appKeepers.keys[consensusparamtypes.StoreKey], + authority, + ) + + bApp.SetParamStore(&appKeepers.ConsensusParamsKeeper) + + // add capability keeper and ScopeToModule for ibc module + appKeepers.CapabilityKeeper = capabilitykeeper.NewKeeper( + appCodec, + appKeepers.keys[capabilitytypes.StoreKey], + appKeepers.memKeys[capabilitytypes.MemStoreKey], + ) + + // grant capabilities for the ibc and ibc-transfer modules + scopedIBCKeeper := appKeepers.CapabilityKeeper.ScopeToModule(ibcexported.ModuleName) + scopedTransferKeeper := appKeepers.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName) + + // add keepers + appKeepers.AccountKeeper = authkeeper.NewAccountKeeper( + appCodec, + appKeepers.keys[authtypes.StoreKey], + authtypes.ProtoBaseAccount, + maccPerms, + AccountAddressPrefix, + authority, + ) + + appKeepers.AuthzKeeper = authzkeeper.NewKeeper( + appKeepers.keys[authzkeeper.StoreKey], + appCodec, + bApp.MsgServiceRouter(), + appKeepers.AccountKeeper, + ) + + appKeepers.BankKeeper = bankkeeper.NewBaseKeeper( + appCodec, + appKeepers.keys[banktypes.StoreKey], + appKeepers.AccountKeeper, + blockedAddresses, + authority, + ) + + appKeepers.StakingKeeper = stakingkeeper.NewKeeper( + appCodec, + appKeepers.keys[stakingtypes.StoreKey], + appKeepers.AccountKeeper, + appKeepers.BankKeeper, + authority, + ) + + appKeepers.MintKeeper = mintkeeper.NewKeeper( + appCodec, + appKeepers.keys[minttypes.StoreKey], + appKeepers.StakingKeeper, + appKeepers.AccountKeeper, + appKeepers.BankKeeper, + authtypes.FeeCollectorName, + authority, + ) + + appKeepers.DistrKeeper = distrkeeper.NewKeeper( + appCodec, + appKeepers.keys[distrtypes.StoreKey], + appKeepers.AccountKeeper, + appKeepers.BankKeeper, + appKeepers.StakingKeeper, + authtypes.FeeCollectorName, + authority, + ) + + appKeepers.AllianceKeeper = alliancemodulekeeper.NewKeeper( + appCodec, + appKeepers.keys[AllianceStoreKey], + appKeepers.AccountKeeper, + appKeepers.BankKeeper, + appKeepers.StakingKeeper, + appKeepers.DistrKeeper, + authtypes.FeeCollectorName, + authority, + ) + + appKeepers.BankKeeper.RegisterKeepers(appKeepers.AllianceKeeper, appKeepers.StakingKeeper) + + appKeepers.SlashingKeeper = slashingkeeper.NewKeeper( + appCodec, + cdc, + appKeepers.keys[slashingtypes.StoreKey], + appKeepers.StakingKeeper, + authority, + ) + + appKeepers.CrisisKeeper = crisiskeeper.NewKeeper( + appCodec, + appKeepers.keys[crisistypes.StoreKey], + invCheckPeriod, + appKeepers.BankKeeper, + authtypes.FeeCollectorName, + authority, + ) + + appKeepers.FeeGrantKeeper = feegrantkeeper.NewKeeper( + appCodec, + appKeepers.keys[feegrant.StoreKey], + appKeepers.AccountKeeper, + ) + + appKeepers.UpgradeKeeper = upgradekeeper.NewKeeper( + skipUpgradeHeights, + appKeepers.keys[upgradetypes.StoreKey], + appCodec, + homePath, + bApp, + authority, + ) + + // register the staking hooks + appKeepers.StakingKeeper.SetHooks( + stakingtypes.NewMultiStakingHooks(appKeepers.DistrKeeper.Hooks(), appKeepers.SlashingKeeper.Hooks(), + appKeepers.AllianceKeeper.StakingHooks()), + ) + + // ... other modules keepers + + // Create IBC Keeper + appKeepers.IBCKeeper = ibckeeper.NewKeeper( + appCodec, + appKeepers.keys[ibcexported.StoreKey], + appKeepers.GetSubspace(ibcexported.ModuleName), + appKeepers.StakingKeeper, + appKeepers.UpgradeKeeper, + scopedIBCKeeper, + ) + + // IBC Fee Module keeper + + appKeepers.IBCFeeKeeper = ibcfeekeeper.NewKeeper( + appCodec, + appKeepers.keys[ibcfeetypes.StoreKey], + appKeepers.IBCKeeper.ChannelKeeper, + appKeepers.IBCKeeper.ChannelKeeper, + &appKeepers.IBCKeeper.PortKeeper, + appKeepers.AccountKeeper, + appKeepers.BankKeeper, + ) + + scopedICAHostKeeper := appKeepers.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName) + _ = appKeepers.GetSubspace(icahosttypes.SubModuleName) + + appKeepers.ICAHostKeeper = icahostkeeper.NewKeeper( + appCodec, + appKeepers.keys[icahosttypes.StoreKey], + appKeepers.GetSubspace(icahosttypes.SubModuleName), + appKeepers.IBCFeeKeeper, + appKeepers.IBCKeeper.ChannelKeeper, + &appKeepers.IBCKeeper.PortKeeper, + appKeepers.AccountKeeper, + scopedICAHostKeeper, + bApp.MsgServiceRouter(), + ) + + scopedICAControllerKeeper := appKeepers.CapabilityKeeper.ScopeToModule(icacontrollertypes.SubModuleName) + appKeepers.ICAControllerKeeper = icacontrollerkeeper.NewKeeper( + appCodec, + appKeepers.keys[icacontrollertypes.StoreKey], + appKeepers.GetSubspace(icacontrollertypes.SubModuleName), + appKeepers.IBCFeeKeeper, + appKeepers.IBCKeeper.ChannelKeeper, + &appKeepers.IBCKeeper.PortKeeper, + scopedICAControllerKeeper, + bApp.MsgServiceRouter(), + ) + + // Create Transfer Keepers + appKeepers.TransferKeeper = ibctransferkeeper.NewKeeper( + appCodec, + appKeepers.keys[ibctransfertypes.StoreKey], + appKeepers.GetSubspace(ibctransfertypes.ModuleName), + appKeepers.IBCFeeKeeper, + appKeepers.IBCKeeper.ChannelKeeper, + &appKeepers.IBCKeeper.PortKeeper, + appKeepers.AccountKeeper, + appKeepers.BankKeeper, + scopedTransferKeeper, + ) + + appKeepers.SchedulerKeeper = schedulerkeeper.NewKeeper( + appCodec, + appKeepers.keys[denomtypes.StoreKey], + appKeepers.GetSubspace(schedulertypes.ModuleName), + ) + + appKeepers.OracleKeeper = oraclekeeper.NewKeeper( + appCodec, + appKeepers.keys[oracletypes.StoreKey], + appKeepers.GetSubspace(oracletypes.ModuleName), + appKeepers.AccountKeeper, + appKeepers.BankKeeper, + appKeepers.DistrKeeper, + appKeepers.SlashingKeeper, + appKeepers.StakingKeeper, + distrtypes.ModuleName, + ) + + denomKeeper := denomkeeper.NewKeeper( + appCodec, + appKeepers.keys[denomtypes.StoreKey], + appKeepers.GetSubspace(denomtypes.ModuleName), + appKeepers.AccountKeeper, + appKeepers.BankKeeper.WithMintCoinsRestriction(denomtypes.NewdenomDenomMintCoinsRestriction()), + appKeepers.DistrKeeper, + ) + + appKeepers.DenomKeeper = &denomKeeper + + scopedWasmKeeper := appKeepers.CapabilityKeeper.ScopeToModule(wasmtypes.ModuleName) + wasmDir := filepath.Join(homePath, "wasm") + wasmConfig, err := wasm.ReadWasmConfig(appOpts) + if err != nil { + panic(fmt.Sprintf("error while reading wasm config: %s", err)) + } + + // The last arguments can contain custom message handlers, and custom query handlers, + // if we want to allow any custom callbacks + availableCapabilities := "iterator,staking,stargate,cosmwasm_1_1,cosmwasm_1_2" + wasmOpts = append(wasmbinding.RegisterCustomPlugins( + appKeepers.BankKeeper, + appKeepers.OracleKeeper, + *appKeepers.DenomKeeper, + ), wasmOpts...) + + appKeepers.WasmKeeper = wasmkeeper.NewKeeper( + appCodec, + appKeepers.keys[wasmtypes.StoreKey], + appKeepers.AccountKeeper, + appKeepers.BankKeeper, + appKeepers.StakingKeeper, + distrkeeper.NewQuerier(appKeepers.DistrKeeper), + appKeepers.IBCFeeKeeper, + appKeepers.IBCKeeper.ChannelKeeper, + &appKeepers.IBCKeeper.PortKeeper, + scopedWasmKeeper, + appKeepers.TransferKeeper, + bApp.MsgServiceRouter(), + bApp.GRPCQueryRouter(), + wasmDir, + wasmConfig, + availableCapabilities, + authority, + wasmOpts..., + ) + + // 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 := govtypesv1beta1.NewRouter() + govRouter.AddRoute(govtypes.RouterKey, govtypesv1beta1.ProposalHandler). + AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(appKeepers.ParamsKeeper)). + AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(appKeepers.UpgradeKeeper)). + AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(appKeepers.IBCKeeper.ClientKeeper)). + AddRoute(schedulertypes.RouterKey, schedulerkeeper.NewSchedulerProposalHandler(appKeepers.SchedulerKeeper)). + AddRoute(alliancemoduletypes.RouterKey, alliancemodule.NewAllianceProposalHandler(appKeepers.AllianceKeeper)) + + // Create evidence Keeper for to register the IBC light client misbehaviour evidence route + evidenceKeeper := evidencekeeper.NewKeeper( + appCodec, + appKeepers.keys[evidencetypes.StoreKey], + appKeepers.StakingKeeper, + appKeepers.SlashingKeeper, + ) + // If evidence needs to be handled for the app, set routes in router here and seal + appKeepers.EvidenceKeeper = *evidenceKeeper + + govKeeper := govkeeper.NewKeeper( + appCodec, + appKeepers.keys[govtypes.StoreKey], + appKeepers.AccountKeeper, + appKeepers.BankKeeper, + appKeepers.StakingKeeper, + bApp.MsgServiceRouter(), + govtypes.DefaultConfig(), + authority, + ) + + govKeeper.SetLegacyRouter(govRouter) + + appKeepers.GovKeeper = *govKeeper.SetHooks( + govtypes.NewMultiGovHooks( + // register the governance hooks + ), + ) + + appKeepers.ScopedIBCKeeper = scopedIBCKeeper + appKeepers.ScopedTransferKeeper = scopedTransferKeeper + appKeepers.ScopedWasmKeeper = scopedWasmKeeper + appKeepers.ScopedICAHostKeeper = scopedICAHostKeeper + appKeepers.ScopedICAControllerKeeper = scopedICAControllerKeeper + + return appKeepers +} + +// initParamsKeeper init params keeper and its subspaces +func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey storetypes.StoreKey) paramskeeper.Keeper { + paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, key, tkey) + + paramsKeeper.Subspace(authtypes.ModuleName) + paramsKeeper.Subspace(banktypes.ModuleName) + paramsKeeper.Subspace(stakingtypes.ModuleName) + paramsKeeper.Subspace(minttypes.ModuleName) + paramsKeeper.Subspace(distrtypes.ModuleName) + paramsKeeper.Subspace(slashingtypes.ModuleName) + paramsKeeper.Subspace(govtypes.ModuleName) + paramsKeeper.Subspace(crisistypes.ModuleName) + paramsKeeper.Subspace(ibctransfertypes.ModuleName) + paramsKeeper.Subspace(ibcexported.ModuleName) + paramsKeeper.Subspace(icahosttypes.SubModuleName) + paramsKeeper.Subspace(icacontrollertypes.SubModuleName) + paramsKeeper.Subspace(denomtypes.ModuleName) + paramsKeeper.Subspace(wasmtypes.ModuleName) + paramsKeeper.Subspace(schedulertypes.ModuleName) + paramsKeeper.Subspace(oracletypes.ModuleName) + paramsKeeper.Subspace(alliancemoduletypes.ModuleName) + + return paramsKeeper +} + +// GetSubspace returns a param subspace for a given module name. +// +// NOTE: This is solely to be used for testing purposes. +func (appKeepers *AppKeepers) GetSubspace(moduleName string) paramstypes.Subspace { + subspace, _ := appKeepers.ParamsKeeper.GetSubspace(moduleName) + return subspace +} + +// GetStakingKeeper implements the TestingApp interface. +func (appKeepers *AppKeepers) GetStakingKeeper() *stakingkeeper.Keeper { + return appKeepers.StakingKeeper +} + +// GetIBCKeeper implements the TestingApp interface. +func (appKeepers *AppKeepers) GetIBCKeeper() *ibckeeper.Keeper { + return appKeepers.IBCKeeper +} + +// GetScopedIBCKeeper implements the TestingApp interface. +func (appKeepers *AppKeepers) GetScopedIBCKeeper() capabilitykeeper.ScopedKeeper { + return appKeepers.ScopedIBCKeeper +} + +// GetWasmKeeper implements the TestingApp interface. +func (appKeepers *AppKeepers) GetWasmKeeper() wasm.Keeper { + return appKeepers.WasmKeeper +} diff --git a/app/keepers/keys.go b/app/keepers/keys.go new file mode 100644 index 00000000..69af8651 --- /dev/null +++ b/app/keepers/keys.go @@ -0,0 +1,99 @@ +package keepers + +import ( + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + denomtypes "github.com/Team-Kujira/core/x/denom/types" + oracletypes "github.com/Team-Kujira/core/x/oracle/types" + schedulertypes "github.com/Team-Kujira/core/x/scheduler/types" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types" + crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" + distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" + "github.com/cosmos/cosmos-sdk/x/feegrant" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" + paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" + slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + icacontrollertypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/types" + icahosttypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/types" + ibcfeetypes "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/types" + ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" + ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" +) + +func (appKeepers *AppKeepers) GenerateKeys( + AllianceStoreKey string, +) { + appKeepers.keys = sdk.NewKVStoreKeys( + authtypes.StoreKey, + banktypes.StoreKey, + stakingtypes.StoreKey, + crisistypes.StoreKey, + minttypes.StoreKey, + distrtypes.StoreKey, + slashingtypes.StoreKey, + govtypes.StoreKey, + paramstypes.StoreKey, + consensusparamtypes.StoreKey, + upgradetypes.StoreKey, + feegrant.StoreKey, + evidencetypes.StoreKey, + capabilitytypes.StoreKey, + authzkeeper.StoreKey, + ibcexported.StoreKey, + ibctransfertypes.StoreKey, + ibcfeetypes.StoreKey, + + wasmtypes.StoreKey, + icahosttypes.StoreKey, + icacontrollertypes.StoreKey, + denomtypes.StoreKey, + schedulertypes.StoreKey, + oracletypes.StoreKey, + AllianceStoreKey, + ) + + appKeepers.tkeys = sdk.NewTransientStoreKeys(paramstypes.TStoreKey) + appKeepers.memKeys = sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) +} + +func (appKeepers *AppKeepers) GetKVStoreKey() map[string]*storetypes.KVStoreKey { + return appKeepers.keys +} + +func (appKeepers *AppKeepers) GetTransientStoreKey() map[string]*storetypes.TransientStoreKey { + return appKeepers.tkeys +} + +func (appKeepers *AppKeepers) GetMemoryStoreKey() map[string]*storetypes.MemoryStoreKey { + return appKeepers.memKeys +} + +// GetKey returns the KVStoreKey for the provided store key. +// +// NOTE: This is solely to be used for testing purposes. +func (appKeepers *AppKeepers) GetKey(storeKey string) *storetypes.KVStoreKey { + return appKeepers.keys[storeKey] +} + +// GetTKey returns the TransientStoreKey for the provided store key. +// +// NOTE: This is solely to be used for testing purposes. +func (appKeepers *AppKeepers) GetTKey(storeKey string) *storetypes.TransientStoreKey { + return appKeepers.tkeys[storeKey] +} + +// GetMemKey returns the MemStoreKey for the provided mem key. +// +// NOTE: This is solely used for testing purposes. +func (appKeepers *AppKeepers) GetMemKey(storeKey string) *storetypes.MemoryStoreKey { + return appKeepers.memKeys[storeKey] +} diff --git a/app/modules.go b/app/modules.go new file mode 100644 index 00000000..9264d269 --- /dev/null +++ b/app/modules.go @@ -0,0 +1,372 @@ +package app + +import ( + "github.com/CosmWasm/wasmd/x/wasm" + wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + appparams "github.com/Team-Kujira/core/app/params" + "github.com/Team-Kujira/core/x/denom" + denomtypes "github.com/Team-Kujira/core/x/denom/types" + "github.com/Team-Kujira/core/x/oracle" + oracletypes "github.com/Team-Kujira/core/x/oracle/types" + scheduler "github.com/Team-Kujira/core/x/scheduler" + schedulertypes "github.com/Team-Kujira/core/x/scheduler/types" + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/cosmos/cosmos-sdk/x/auth" + authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/cosmos/cosmos-sdk/x/auth/vesting" + vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" + "github.com/cosmos/cosmos-sdk/x/authz" + authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/cosmos/cosmos-sdk/x/capability" + capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + "github.com/cosmos/cosmos-sdk/x/consensus" + consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types" + "github.com/cosmos/cosmos-sdk/x/crisis" + crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" + distr "github.com/cosmos/cosmos-sdk/x/distribution" + distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + "github.com/cosmos/cosmos-sdk/x/evidence" + evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" + "github.com/cosmos/cosmos-sdk/x/feegrant" + feegrantmodule "github.com/cosmos/cosmos-sdk/x/feegrant/module" + "github.com/cosmos/cosmos-sdk/x/genutil" + genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" + "github.com/cosmos/cosmos-sdk/x/gov" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + "github.com/cosmos/cosmos-sdk/x/mint" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" + "github.com/cosmos/cosmos-sdk/x/params" + paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" + "github.com/cosmos/cosmos-sdk/x/slashing" + slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" + "github.com/cosmos/cosmos-sdk/x/staking" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "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" + icatypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/types" + ibcfee "github.com/cosmos/ibc-go/v7/modules/apps/29-fee" + ibcfeetypes "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/types" + transfer "github.com/cosmos/ibc-go/v7/modules/apps/transfer" + ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" + ibc "github.com/cosmos/ibc-go/v7/modules/core" + ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" + ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" + bank "github.com/terra-money/alliance/custom/bank" + alliancemodule "github.com/terra-money/alliance/x/alliance" + alliancemoduletypes "github.com/terra-money/alliance/x/alliance/types" +) + +// module account permissions +var maccPerms = map[string][]string{ + authtypes.FeeCollectorName: nil, + distrtypes.ModuleName: nil, + minttypes.ModuleName: {authtypes.Minter}, + stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, + stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, + govtypes.ModuleName: {authtypes.Burner}, + ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + ibcfeetypes.ModuleName: nil, + icatypes.ModuleName: nil, + wasmtypes.ModuleName: {authtypes.Burner}, + denomtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + schedulertypes.ModuleName: nil, + oracletypes.ModuleName: nil, + alliancemoduletypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + alliancemoduletypes.RewardsPoolName: nil, +} + +// ModuleBasics defines the module BasicManager is in charge of setting up basic, +// non-dependant module elements, such as codec registration +// and genesis verification. +var ModuleBasics = module.NewBasicManager( + auth.AppModuleBasic{}, + genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator), + authzmodule.AppModuleBasic{}, + bank.AppModule{}, + capability.AppModuleBasic{}, + staking.AppModuleBasic{}, + mint.AppModuleBasic{}, + distr.AppModuleBasic{}, + gov.NewAppModuleBasic(getGovProposalHandlers()), + params.AppModuleBasic{}, + consensus.AppModuleBasic{}, + crisis.AppModuleBasic{}, + slashing.AppModuleBasic{}, + feegrantmodule.AppModuleBasic{}, + ibc.AppModuleBasic{}, + ibctm.AppModuleBasic{}, + + upgrade.AppModuleBasic{}, + evidence.AppModuleBasic{}, + transfer.AppModuleBasic{}, + vesting.AppModuleBasic{}, + wasm.AppModuleBasic{}, + ica.AppModuleBasic{}, + ibcfee.AppModuleBasic{}, + denom.AppModuleBasic{}, + scheduler.AppModuleBasic{}, + oracle.AppModuleBasic{}, + alliancemodule.AppModuleBasic{}, +) + +func appModules( + app *App, + encodingConfig appparams.EncodingConfig, + skipGenesisInvariants bool, +) []module.AppModule { + appCodec := encodingConfig.Codec + + return []module.AppModule{ + genutil.NewAppModule( + app.AccountKeeper, + app.StakingKeeper, + app.BaseApp.DeliverTx, + encodingConfig.TxConfig, + ), + + auth.NewAppModule( + appCodec, + app.AccountKeeper, + authsims.RandomGenesisAccounts, + app.GetSubspace(authtypes.ModuleName), + ), + + authzmodule.NewAppModule( + appCodec, + app.AuthzKeeper, + app.AccountKeeper, + app.BankKeeper, + app.interfaceRegistry, + ), + + vesting.NewAppModule( + app.AccountKeeper, + app.BankKeeper, + ), + + bank.NewAppModule( + appCodec, + app.BankKeeper, + app.AccountKeeper, + app.GetSubspace(banktypes.ModuleName), + ), + + capability.NewAppModule( + appCodec, + *app.CapabilityKeeper, + false, + ), + + feegrantmodule.NewAppModule( + appCodec, + app.AccountKeeper, + app.BankKeeper, + app.FeeGrantKeeper, + app.interfaceRegistry, + ), + + gov.NewAppModule( + appCodec, + &app.GovKeeper, + app.AccountKeeper, + app.BankKeeper, + app.GetSubspace(govtypes.ModuleName), + ), + + mint.NewAppModule( + appCodec, + app.MintKeeper, + app.AccountKeeper, + nil, + app.GetSubspace(minttypes.ModuleName), + ), + + slashing.NewAppModule( + appCodec, + app.SlashingKeeper, + app.AccountKeeper, + app.BankKeeper, + app.StakingKeeper, + app.GetSubspace(slashingtypes.ModuleName), + ), + + distr.NewAppModule( + appCodec, + app.DistrKeeper, + app.AccountKeeper, + app.BankKeeper, + app.StakingKeeper, + app.GetSubspace(distrtypes.ModuleName), + ), + + staking.NewAppModule( + appCodec, + app.StakingKeeper, + app.AccountKeeper, + app.BankKeeper, + app.GetSubspace(stakingtypes.ModuleName), + ), + + upgrade.NewAppModule(app.UpgradeKeeper), + evidence.NewAppModule(app.EvidenceKeeper), + ibc.NewAppModule(app.IBCKeeper), + params.NewAppModule(app.ParamsKeeper), + transfer.NewAppModule(app.TransferKeeper), + + ibcfee.NewAppModule(app.IBCFeeKeeper), + + consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper), + + wasm.NewAppModule( + appCodec, + &app.WasmKeeper, + app.StakingKeeper, + app.AccountKeeper, + app.BankKeeper, + app.MsgServiceRouter(), + app.GetSubspace(wasmtypes.ModuleName), + ), + + denom.NewAppModule( + appCodec, + *app.DenomKeeper, + app.AccountKeeper, + app.BankKeeper, + ), + + ica.NewAppModule(&app.ICAControllerKeeper, &app.ICAHostKeeper), + + scheduler.NewAppModule( + appCodec, + app.SchedulerKeeper, + app.AccountKeeper, + app.BankKeeper, + wasmkeeper.NewDefaultPermissionKeeper(app.WasmKeeper), + ), + + oracle.NewAppModule( + appCodec, + app.OracleKeeper, + app.AccountKeeper, + app.BankKeeper, + ), + + alliancemodule.NewAppModule( + appCodec, + app.AllianceKeeper, + app.StakingKeeper, + app.AccountKeeper, + app.BankKeeper, + app.interfaceRegistry, + app.GetSubspace(alliancemoduletypes.ModuleName), + ), + + crisis.NewAppModule( + app.CrisisKeeper, + skipGenesisInvariants, + app.GetSubspace(crisistypes.ModuleName), + ), + } +} + +// orderBeginBlockers tell the app's module manager how to set the order of +// BeginBlockers, which are run at the beginning of every block. +func orderBeginBlockers() []string { + return []string{ + upgradetypes.ModuleName, + capabilitytypes.ModuleName, + minttypes.ModuleName, + distrtypes.ModuleName, + slashingtypes.ModuleName, + evidencetypes.ModuleName, + stakingtypes.ModuleName, + vestingtypes.ModuleName, + ibcexported.ModuleName, + ibctransfertypes.ModuleName, + authtypes.ModuleName, + authz.ModuleName, + banktypes.ModuleName, + govtypes.ModuleName, + crisistypes.ModuleName, + genutiltypes.ModuleName, + feegrant.ModuleName, + paramstypes.ModuleName, + consensusparamtypes.ModuleName, + icatypes.ModuleName, + ibcfeetypes.ModuleName, + + wasmtypes.ModuleName, + denomtypes.ModuleName, + schedulertypes.ModuleName, + oracletypes.ModuleName, + alliancemoduletypes.ModuleName, + } +} + +func orderEndBlockers() []string { + return []string{ + crisistypes.ModuleName, + govtypes.ModuleName, + stakingtypes.ModuleName, + capabilitytypes.ModuleName, + authtypes.ModuleName, + authz.ModuleName, + banktypes.ModuleName, + distrtypes.ModuleName, + slashingtypes.ModuleName, + vestingtypes.ModuleName, + minttypes.ModuleName, + genutiltypes.ModuleName, + evidencetypes.ModuleName, + feegrant.ModuleName, + paramstypes.ModuleName, + upgradetypes.ModuleName, + ibcexported.ModuleName, + ibctransfertypes.ModuleName, + consensusparamtypes.ModuleName, + icatypes.ModuleName, + ibcfeetypes.ModuleName, + + wasmtypes.ModuleName, + denomtypes.ModuleName, + schedulertypes.ModuleName, + oracletypes.ModuleName, + alliancemoduletypes.ModuleName, + } +} + +func orderInitBlockers() []string { + return []string{ + capabilitytypes.ModuleName, + authtypes.ModuleName, + authz.ModuleName, + banktypes.ModuleName, + distrtypes.ModuleName, + stakingtypes.ModuleName, + vestingtypes.ModuleName, + slashingtypes.ModuleName, + govtypes.ModuleName, + minttypes.ModuleName, + crisistypes.ModuleName, + ibcexported.ModuleName, + genutiltypes.ModuleName, + evidencetypes.ModuleName, + paramstypes.ModuleName, + upgradetypes.ModuleName, + feegrant.ModuleName, + ibctransfertypes.ModuleName, + consensusparamtypes.ModuleName, + icatypes.ModuleName, + ibcfeetypes.ModuleName, + + denomtypes.ModuleName, + schedulertypes.ModuleName, + oracletypes.ModuleName, + alliancemoduletypes.ModuleName, + wasmtypes.ModuleName, + } +}