Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderbez committed Mar 23, 2022
1 parent a8cbbec commit a6857d8
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 95 deletions.
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ var (
ModuleBasics = module.NewBasicManager(appModuleBasics...)

// module account permissions
maccPerms = moduleAaccountPermissions
maccPerms = moduleAccountPermissions

// module accounts that are allowed to receive tokens
allowedReceivingModAcc = map[string]bool{}
Expand Down
182 changes: 88 additions & 94 deletions app/modules.go
Original file line number Diff line number Diff line change
@@ -1,134 +1,72 @@
package app

import (
// Utilities from the Cosmos-SDK other than Cosmos modules
"github.com/CosmWasm/wasmd/x/wasm"
wasmclient "github.com/CosmWasm/wasmd/x/wasm/client"
"github.com/cosmos/cosmos-sdk/types/module"

// Cosmos-SDK Modules
// https://github.com/cosmos/cosmos-sdk/tree/master/x
// NB: Osmosis uses a fork of the cosmos-sdk which can be found at: https://github.com/osmosis-labs/cosmos-sdk

// Auth: Authentication of accounts and transactions for Cosmos SDK applications.
"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"

// Vesting: Allows the lock and periodic release of tokens
"github.com/cosmos/cosmos-sdk/x/auth/vesting"
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"

// Authz: Authorization for accounts to perform actions on behalf of other accounts.
"github.com/cosmos/cosmos-sdk/x/authz"
authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module"

// Bank: allows users to transfer tokens
"github.com/cosmos/cosmos-sdk/x/bank"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"

// Capability: allows developers to atomically define what a module can and cannot do
"github.com/cosmos/cosmos-sdk/x/capability"
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"

// Crisis: Halting the blockchain under certain circumstances (e.g. if an invariant is broken).
"github.com/cosmos/cosmos-sdk/x/crisis"
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"

// Distribution: Fee distribution, and staking token provision distribution.
distr "github.com/cosmos/cosmos-sdk/x/distribution"
distrclient "github.com/cosmos/cosmos-sdk/x/distribution/client"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"

// Evidence handling for double signing, misbehaviour, etc.
"github.com/cosmos/cosmos-sdk/x/evidence"
evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types"

// Genesis Utilities: Used for evertything to do with the very first block of a chain
"github.com/cosmos/cosmos-sdk/x/genutil"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"

// Governance: Allows stakeholders to make decisions concering a Cosmos-SDK blockchain's economy and development
"github.com/cosmos/cosmos-sdk/x/gov"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"

// Params: Parameters that are always available
"github.com/cosmos/cosmos-sdk/x/params"
paramsclient "github.com/cosmos/cosmos-sdk/x/params/client"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"

// Slashing:
"github.com/cosmos/cosmos-sdk/x/slashing"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"

// Staking: Allows the Tendermint validator set to be chosen based on bonded stake.
"github.com/cosmos/cosmos-sdk/x/staking"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

// Upgrade: Software upgrades handling and coordination.
"github.com/cosmos/cosmos-sdk/x/upgrade"
upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

// IBC Transfer: Defines the "transfer" IBC port
transfer "github.com/cosmos/ibc-go/v2/modules/apps/transfer"
ibctransfertypes "github.com/cosmos/ibc-go/v2/modules/apps/transfer/types"

// IBC: Inter-blockchain communication
ibc "github.com/cosmos/ibc-go/v2/modules/core"
ibcclientclient "github.com/cosmos/ibc-go/v2/modules/core/02-client/client"
ibchost "github.com/cosmos/ibc-go/v2/modules/core/24-host"
"github.com/osmosis-labs/bech32-ibc/x/bech32ibc"
bech32ibctypes "github.com/osmosis-labs/bech32-ibc/x/bech32ibc/types"
"github.com/osmosis-labs/bech32-ibc/x/bech32ics20"

// Osmosis application prarmeters
appparams "github.com/osmosis-labs/osmosis/v7/app/params"

// Upgrades from earlier versions of Osmosis
_ "github.com/osmosis-labs/osmosis/v7/client/docs/statik"

// Modules that live in the Osmosis repository and are specific to Osmosis
"github.com/osmosis-labs/osmosis/v7/x/claim"
claimtypes "github.com/osmosis-labs/osmosis/v7/x/claim/types"

// Epochs: gives Osmosis a sense of "clock time" so that events can be based on days instead of "number of blocks"
"github.com/osmosis-labs/osmosis/v7/x/epochs"
epochstypes "github.com/osmosis-labs/osmosis/v7/x/epochs/types"

// Generalized Automated Market Maker
"github.com/osmosis-labs/osmosis/v7/x/gamm"
gammtypes "github.com/osmosis-labs/osmosis/v7/x/gamm/types"

// Incentives: Allows Osmosis and foriegn chain communities to incentivize users to provide liquidity
"github.com/osmosis-labs/osmosis/v7/x/incentives"
incentivestypes "github.com/osmosis-labs/osmosis/v7/x/incentives/types"

// Lockup: allows tokens to be locked (made non-transferrable)
"github.com/osmosis-labs/osmosis/v7/x/lockup"
lockuptypes "github.com/osmosis-labs/osmosis/v7/x/lockup/types"

// Mint: Our modified version of github.com/cosmos/cosmos-sdk/x/mint
"github.com/osmosis-labs/osmosis/v7/x/mint"
minttypes "github.com/osmosis-labs/osmosis/v7/x/mint/types"

// Pool incentives:
poolincentives "github.com/osmosis-labs/osmosis/v7/x/pool-incentives"
poolincentivesclient "github.com/osmosis-labs/osmosis/v7/x/pool-incentives/client"
poolincentivestypes "github.com/osmosis-labs/osmosis/v7/x/pool-incentives/types"

// Superfluid: Allows users to stake gamm (bonded liquidity)
superfluid "github.com/osmosis-labs/osmosis/v7/x/superfluid"
superfluidclient "github.com/osmosis-labs/osmosis/v7/x/superfluid/client"
superfluidtypes "github.com/osmosis-labs/osmosis/v7/x/superfluid/types"

// txfees: Allows Osmosis to charge transaction fees without harming IBC user experience
"github.com/osmosis-labs/osmosis/v7/x/txfees"
txfeestypes "github.com/osmosis-labs/osmosis/v7/x/txfees/types"

// Wasm: Allows Osmosis to interact with web assembly smart contracts
"github.com/CosmWasm/wasmd/x/wasm"
wasmclient "github.com/CosmWasm/wasmd/x/wasm/client"

// Modules related to bech32-ibc, which allows new ibc funcationality based on the bech32 prefix of addresses
"github.com/osmosis-labs/bech32-ibc/x/bech32ibc"
bech32ibctypes "github.com/osmosis-labs/bech32-ibc/x/bech32ibc/types"
"github.com/osmosis-labs/bech32-ibc/x/bech32ics20"
)

// appModuleBasics returns ModuleBasics for the module BasicManager.
Expand All @@ -143,10 +81,16 @@ var appModuleBasics = []module.AppModuleBasic{
gov.NewAppModuleBasic(
append(
wasmclient.ProposalHandlers,
paramsclient.ProposalHandler, distrclient.ProposalHandler, upgradeclient.ProposalHandler, upgradeclient.CancelProposalHandler,
paramsclient.ProposalHandler,
distrclient.ProposalHandler,
upgradeclient.ProposalHandler,
upgradeclient.CancelProposalHandler,
poolincentivesclient.UpdatePoolIncentivesHandler,
ibcclientclient.UpdateClientProposalHandler, ibcclientclient.UpgradeProposalHandler,
superfluidclient.SetSuperfluidAssetsProposalHandler, superfluidclient.RemoveSuperfluidAssetsProposalHandler)...,
ibcclientclient.UpdateClientProposalHandler,
ibcclientclient.UpgradeProposalHandler,
superfluidclient.SetSuperfluidAssetsProposalHandler,
superfluidclient.RemoveSuperfluidAssetsProposalHandler,
)...,
),
params.AppModuleBasic{},
crisis.AppModuleBasic{},
Expand All @@ -169,8 +113,8 @@ var appModuleBasics = []module.AppModuleBasic{
wasm.AppModuleBasic{},
}

// module account permissions
var moduleAaccountPermissions = map[string][]string{
// moduleAccountPermissions defines module account permissions
var moduleAccountPermissions = map[string][]string{
authtypes.FeeCollectorName: nil,
distrtypes.ModuleName: nil,
minttypes.ModuleName: {authtypes.Minter, authtypes.Burner},
Expand All @@ -189,13 +133,19 @@ var moduleAaccountPermissions = map[string][]string{
wasm.ModuleName: {authtypes.Burner},
}

// appModules return modules to initlize module manager
func appModules(app *OsmosisApp, encodingConfig appparams.EncodingConfig, skipGenesisInvariants bool) []module.AppModule {
// appModules return modules to initialize module manager.
func appModules(
app *OsmosisApp,
encodingConfig appparams.EncodingConfig,
skipGenesisInvariants bool,
) []module.AppModule {
appCodec := encodingConfig.Marshaler

return []module.AppModule{
genutil.NewAppModule(
app.AccountKeeper, app.StakingKeeper, app.BaseApp.DeliverTx,
app.AccountKeeper,
app.StakingKeeper,
app.BaseApp.DeliverTx,
encodingConfig.TxConfig,
),
auth.NewAppModule(appCodec, *app.AccountKeeper, nil),
Expand All @@ -222,16 +172,25 @@ func appModules(app *OsmosisApp, encodingConfig appparams.EncodingConfig, skipGe
lockup.NewAppModule(appCodec, *app.LockupKeeper, app.AccountKeeper, app.BankKeeper),
poolincentives.NewAppModule(appCodec, *app.PoolIncentivesKeeper),
epochs.NewAppModule(appCodec, *app.EpochsKeeper),
superfluid.NewAppModule(appCodec, *app.SuperfluidKeeper, app.AccountKeeper, app.BankKeeper,
app.StakingKeeper, app.LockupKeeper, app.GAMMKeeper, app.EpochsKeeper),
superfluid.NewAppModule(
appCodec,
*app.SuperfluidKeeper,
app.AccountKeeper,
app.BankKeeper,
app.StakingKeeper,
app.LockupKeeper,
app.GAMMKeeper,
app.EpochsKeeper,
),
bech32ibc.NewAppModule(appCodec, *app.Bech32IBCKeeper),
}
}

// orderBeginBlockers Tell the app's module manager how to set the order of BeginBlockers, which are run at the beginning of every block.
// 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{
// Upgrades should be run _very_ first
// Upgrades should be run VERY first
upgradetypes.ModuleName,
// Note: epochs' begin should be "real" start of epochs, we keep epochs beginblock at the beginning
epochstypes.ModuleName,
Expand All @@ -250,27 +209,50 @@ func orderBeginBlockers() []string {
crisistypes.ModuleName,
genutiltypes.ModuleName,
authz.ModuleName,
paramstypes.ModuleName, vestingtypes.ModuleName,
gammtypes.ModuleName, incentivestypes.ModuleName, lockuptypes.ModuleName, claimtypes.ModuleName,
paramstypes.ModuleName,
vestingtypes.ModuleName,
gammtypes.ModuleName,
incentivestypes.ModuleName,
lockuptypes.ModuleName,
claimtypes.ModuleName,
poolincentivestypes.ModuleName,
// superfluid must come after distribution and epochs
superfluidtypes.ModuleName,
bech32ibctypes.ModuleName, txfeestypes.ModuleName,
bech32ibctypes.ModuleName,
txfeestypes.ModuleName,
wasm.ModuleName,
}
}

// orderEndBlockers Tell the app's module manager how to set the order of EndBlockers, which are run at the end of every block.
// orderEndBlockers Tell the app's module manager how to set the order of
// EndBlockers, which are run at the end of every block.
var orderEndBlockers = []string{
lockuptypes.ModuleName,
crisistypes.ModuleName, govtypes.ModuleName, stakingtypes.ModuleName, claimtypes.ModuleName,
capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, distrtypes.ModuleName,
slashingtypes.ModuleName, minttypes.ModuleName,
genutiltypes.ModuleName, evidencetypes.ModuleName, authz.ModuleName,
paramstypes.ModuleName, upgradetypes.ModuleName, vestingtypes.ModuleName,
ibchost.ModuleName, ibctransfertypes.ModuleName,
gammtypes.ModuleName, incentivestypes.ModuleName, lockuptypes.ModuleName,
poolincentivestypes.ModuleName, superfluidtypes.ModuleName, bech32ibctypes.ModuleName, txfeestypes.ModuleName,
crisistypes.ModuleName,
govtypes.ModuleName,
stakingtypes.ModuleName,
claimtypes.ModuleName,
capabilitytypes.ModuleName,
authtypes.ModuleName,
banktypes.ModuleName,
distrtypes.ModuleName,
slashingtypes.ModuleName,
minttypes.ModuleName,
genutiltypes.ModuleName,
evidencetypes.ModuleName,
authz.ModuleName,
paramstypes.ModuleName,
upgradetypes.ModuleName,
vestingtypes.ModuleName,
ibchost.ModuleName,
ibctransfertypes.ModuleName,
gammtypes.ModuleName,
incentivestypes.ModuleName,
lockuptypes.ModuleName,
poolincentivestypes.ModuleName,
superfluidtypes.ModuleName,
bech32ibctypes.ModuleName,
txfeestypes.ModuleName,
// Note: epochs' endblock should be "real" end of epochs, we keep epochs endblock at the end
epochstypes.ModuleName,
wasm.ModuleName,
Expand Down Expand Up @@ -309,7 +291,11 @@ var modulesOrderInitGenesis = []string{
}

// simulationModules returns modules for simulation manager
func simulationModules(app *OsmosisApp, encodingConfig appparams.EncodingConfig, skipGenesisInvariants bool) []module.AppModuleSimulation {
func simulationModules(
app *OsmosisApp,
encodingConfig appparams.EncodingConfig,
skipGenesisInvariants bool,
) []module.AppModuleSimulation {
appCodec := encodingConfig.Marshaler

return []module.AppModuleSimulation{
Expand All @@ -332,8 +318,16 @@ func simulationModules(app *OsmosisApp, encodingConfig appparams.EncodingConfig,
lockup.NewAppModule(appCodec, *app.LockupKeeper, app.AccountKeeper, app.BankKeeper),
poolincentives.NewAppModule(appCodec, *app.PoolIncentivesKeeper),
epochs.NewAppModule(appCodec, *app.EpochsKeeper),
superfluid.NewAppModule(appCodec, *app.SuperfluidKeeper, app.AccountKeeper, app.BankKeeper,
app.StakingKeeper, app.LockupKeeper, app.GAMMKeeper, app.EpochsKeeper),
superfluid.NewAppModule(
appCodec,
*app.SuperfluidKeeper,
app.AccountKeeper,
app.BankKeeper,
app.StakingKeeper,
app.LockupKeeper,
app.GAMMKeeper,
app.EpochsKeeper,
),
app.transferModule,
}
}
Expand Down

0 comments on commit a6857d8

Please sign in to comment.