Skip to content

Commit

Permalink
modified simapp
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan.balea committed Aug 19, 2024
1 parent 61af6f9 commit 80e965e
Showing 1 changed file with 11 additions and 36 deletions.
47 changes: 11 additions & 36 deletions testutil/simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ package simapp

import (
"github.com/bze-alphateam/bze/app/openapi"
v600 "github.com/bze-alphateam/bze/app/upgrades/v600"
v700 "github.com/bze-alphateam/bze/app/upgrades/v700"
v710 "github.com/bze-alphateam/bze/app/upgrades/v710"
"github.com/bze-alphateam/bze/x/epochs"
epochskeeper "github.com/bze-alphateam/bze/x/epochs/keeper"
epochstypes "github.com/bze-alphateam/bze/x/epochs/types"
Expand Down Expand Up @@ -33,7 +32,6 @@ import (
"github.com/cosmos/cosmos-sdk/server/api"
"github.com/cosmos/cosmos-sdk/server/config"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/version"
Expand Down Expand Up @@ -212,6 +210,7 @@ var (
// this list will be excluded from bank/distribution modules blocked addresses
allowedModules = map[string]struct{}{
burnermoduletypes.ModuleName: {},
tradebintypes.ModuleName: {},
}
)

Expand Down Expand Up @@ -492,6 +491,9 @@ func New(
[]epochstypes.EpochHook{
app.RewardsKeeper.GetDistributeAllStakingRewardsHook(),
app.RewardsKeeper.GetUnlockPendingUnlockParticipantsHook(),
app.RewardsKeeper.GetRemoveExpiredPendingTradingRewardsHook(),
app.RewardsKeeper.GetTradingRewardsDistributionHook(),
app.BurnerKeeper.GetBurnerRaffleCleanupHook(),
},
)

Expand Down Expand Up @@ -664,7 +666,8 @@ func New(

app.mm.RegisterInvariants(&app.CrisisKeeper)
app.mm.RegisterRoutes(app.Router(), app.QueryRouter(), encodingConfig.Amino)
app.mm.RegisterServices(module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter()))
cfg := module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter())
app.mm.RegisterServices(cfg)

// initialize stores
app.MountKVStores(keys)
Expand All @@ -690,7 +693,7 @@ func New(

app.SetAnteHandler(anteHandler)
app.SetEndBlocker(app.EndBlocker)
app.setupUpgradeHandlers()
app.setupUpgradeHandlers(cfg)

if loadLatest {
if err := app.LoadLatestVersion(); err != nil {
Expand All @@ -705,39 +708,11 @@ func New(
return app
}

func (app *SimApp) setupUpgradeHandlers() {
cfg := module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter())
func (app *App) setupUpgradeHandlers(cfg module.Configurator) {
app.UpgradeKeeper.SetUpgradeHandler(
v700.UpgradeName,
v700.CreateUpgradeHandler(cfg, app.mm),
v710.UpgradeName,
v710.CreateUpgradeHandler(cfg, app.mm),
)

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

if app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
return
}

if upgradeInfo.Name == v600.UpgradeName {
storeUpgrades := storetypes.StoreUpgrades{
Added: []string{burnermoduletypes.StoreKey, cointrunkmoduletypes.StoreKey, authzkeeper.StoreKey},
}

// configure store loader that checks if version == upgradeHeight and applies store upgrades
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
}

if upgradeInfo.Name == v700.UpgradeName {
storeUpgrades := storetypes.StoreUpgrades{
Added: []string{tokenfactorytypes.StoreKey, tradebintypes.StoreKey, epochstypes.StoreKey, rewardstypes.StoreKey},
}

// configure store loader that checks if version == upgradeHeight and applies store upgrades
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
}
}

// Name returns the name of the SimApp
Expand Down

0 comments on commit 80e965e

Please sign in to comment.