Skip to content

Commit

Permalink
alternative for experimental build
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-zaremba committed Nov 4, 2022
1 parent 7c29e21 commit 009f87d
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 86 deletions.
104 changes: 54 additions & 50 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,59 +132,63 @@ var (
// 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(
append([]module.AppModuleBasic{
auth.AppModuleBasic{},
genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator),
BankModule{},
capability.AppModuleBasic{},
StakingModule{},
MintModule{},
distr.AppModuleBasic{},
GovModule{AppModuleBasic: gov.NewAppModuleBasic(getGovProposalHandlers())},
params.AppModuleBasic{},
CrisisModule{},
SlashingModule{},
feegrantmodule.AppModuleBasic{},
upgrade.AppModuleBasic{},
evidence.AppModuleBasic{},
authzmodule.AppModuleBasic{},
groupmodule.AppModuleBasic{},
vesting.AppModuleBasic{},
nftmodule.AppModuleBasic{},
ibc.AppModuleBasic{},
ibctransfer.AppModuleBasic{},
gravity.AppModuleBasic{},
leverage.AppModuleBasic{},
oracle.AppModuleBasic{},
bech32ibc.AppModuleBasic{},
}, setCustomModuleBasics()...)...,
)
ModuleBasics module.BasicManager

// module account permissions
maccPerms = func() map[string][]string {
perms := 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},
nft.ModuleName: nil,

ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
gravitytypes.ModuleName: {authtypes.Minter, authtypes.Burner},
leveragetypes.ModuleName: {authtypes.Minter, authtypes.Burner},
oracletypes.ModuleName: nil,
}

for k, v := range setCustomMaccPerms() {
perms[k] = v
}
return perms
}()
maccPerms map[string][]string
)

func init() {
moduleBasics := []module.AppModuleBasic{
auth.AppModuleBasic{},
genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator),
BankModule{},
capability.AppModuleBasic{},
StakingModule{},
MintModule{},
distr.AppModuleBasic{},
GovModule{AppModuleBasic: gov.NewAppModuleBasic(getGovProposalHandlers())},
params.AppModuleBasic{},
CrisisModule{},
SlashingModule{},
feegrantmodule.AppModuleBasic{},
upgrade.AppModuleBasic{},
evidence.AppModuleBasic{},
authzmodule.AppModuleBasic{},
groupmodule.AppModuleBasic{},
vesting.AppModuleBasic{},
nftmodule.AppModuleBasic{},
ibc.AppModuleBasic{},
ibctransfer.AppModuleBasic{},
gravity.AppModuleBasic{},
leverage.AppModuleBasic{},
oracle.AppModuleBasic{},
bech32ibc.AppModuleBasic{},
}
if Experimental {
moduleBasics = append(moduleBasics, wasm.AppModuleBasic{})
}
ModuleBasics = module.NewBasicManager(moduleBasics...)

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},
nft.ModuleName: nil,

ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
gravitytypes.ModuleName: {authtypes.Minter, authtypes.Burner},
leveragetypes.ModuleName: {authtypes.Minter, authtypes.Burner},
oracletypes.ModuleName: nil,
}
if Experimental {
maccPerms[wasm.ModuleName] = []string{authtypes.Burner}
}
}

// UmeeApp defines the ABCI application for the Umee network as an extension of
// the Cosmos SDK's BaseApp.
type UmeeApp struct {
Expand Down Expand Up @@ -670,7 +674,7 @@ func New(

// RegisterUpgradeHandlers is used for registering any on-chain upgrades.
// Make sure it's called after `app.mm` and `app.configurator` are set.
app.registerUpgradeHandlers()
app.RegisterUpgradeHandlers(Experimental)

// add test gRPC service for testing gRPC queries in isolation
testdata.RegisterQueryServer(app.GRPCQueryRouter(), testdata.QueryImpl{})
Expand Down
22 changes: 4 additions & 18 deletions app/experimental_appconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@ import (
leverageclient "github.com/umee-network/umee/v3/x/leverage/client"
)

var (
// Experimental is a flag which determines expermiental features.
// It's set via build flag.
const Experimental = false

var (
// WasmProposalsEnabled enables all x/wasm proposals when it's value is "true"
// and EnableSpecificWasmProposals is empty. Otherwise, all x/wasm proposals
// are disabled.
Expand Down Expand Up @@ -74,16 +77,6 @@ func GetWasmEnabledProposals() []wasm.ProposalType {
return proposals
}

func setCustomModuleBasics() []module.AppModuleBasic {
return []module.AppModuleBasic{wasm.AppModuleBasic{}}
}

func setCustomMaccPerms() map[string][]string {
return map[string][]string{
wasm.ModuleName: {authtypes.Burner},
}
}

func setCustomKVStoreKeys() []string {
return []string{wasm.StoreKey}
}
Expand Down Expand Up @@ -211,10 +204,3 @@ func initCustomParamsKeeper(paramsKeeper *paramskeeper.Keeper) {
func (app *UmeeApp) initializeCustomScopedKeepers() {
app.ScopedWasmKeeper = app.CapabilityKeeper.ScopeToModule(wasm.ModuleName)
}

func (app *UmeeApp) registerUpgradeHandlers() {
_, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
if err != nil {
panic(err)
}
}
22 changes: 4 additions & 18 deletions app/stable_appconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ import (
leverageclient "github.com/umee-network/umee/v3/x/leverage/client"
)

// Experimental is a flag which determines expermiental features.
// It's set via build flag.
const Experimental = false

var (
WasmProposalsEnabled = "false"
EnableSpecificWasmProposals = ""
Expand All @@ -40,14 +44,6 @@ func GetWasmEnabledProposals() []wasm.ProposalType {
return []wasm.ProposalType{}
}

func setCustomModuleBasics() []module.AppModuleBasic {
return []module.AppModuleBasic{}
}

func setCustomMaccPerms() map[string][]string {
return map[string][]string{}
}

func setCustomKVStoreKeys() []string {
return []string{}
}
Expand Down Expand Up @@ -119,13 +115,3 @@ func (app *UmeeApp) setCustomKeepers(
}

func (app *UmeeApp) initializeCustomScopedKeepers() {}

func (app *UmeeApp) registerUpgradeHandlers() {
upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
if err != nil {
panic(err)
}

app.registerV3_0Upgrade(upgradeInfo)
app.registerV3_1Upgrade(upgradeInfo)
}
10 changes: 10 additions & 0 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ import (
oracletypes "github.com/umee-network/umee/v3/x/oracle/types"
)

func (app UmeeApp) RegisterUpgradeHandlers(experimental bool) {
upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
if err != nil {
panic(err)
}

app.registerV3_0Upgrade(upgradeInfo)
app.registerV3_1Upgrade(upgradeInfo)
}

// performs upgrade from v3.0 -> v3.1
func (app *UmeeApp) registerV3_1Upgrade(_ upgradetypes.Plan) {
const UpgradeV3_1Plan = "v3.1.0"
Expand Down

0 comments on commit 009f87d

Please sign in to comment.