Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,15 @@ clean:
tmp-swagger-gen/

.PHONY: distclean clean

###############################################################################
### Linting ###
###############################################################################

lint:
@echo "--> Running linter"
@go run github.com/golangci/golangci-lint/cmd/golangci-lint run --timeout=10m

format:
@go run github.com/golangci/golangci-lint/cmd/golangci-lint run ./... --fix
@go run mvdan.cc/gofumpt -l -w x/ app/
68 changes: 45 additions & 23 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ import (
mandeante "github.com/mande-labs/mande/v1/ante"
mandeappparams "github.com/mande-labs/mande/v1/app/params"

"github.com/mande-labs/mande/v1/x/voting"
votingkeeper "github.com/mande-labs/mande/v1/x/voting/keeper"
votingtypes "github.com/mande-labs/mande/v1/x/voting/types"

// unnamed import of statik for swagger UI support
_ "github.com/cosmos/cosmos-sdk/client/docs/statik"
)
Expand Down Expand Up @@ -152,6 +156,7 @@ var (
vesting.AppModuleBasic{},
router.AppModuleBasic{},
ica.AppModuleBasic{},
voting.AppModuleBasic{},
)

// module account permissions
Expand All @@ -164,6 +169,7 @@ var (
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
govtypes.ModuleName: {authtypes.Burner},
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
votingtypes.ModuleName: {authtypes.Minter, authtypes.Burner, authtypes.Staking},
}
)

Expand Down Expand Up @@ -200,15 +206,17 @@ type MandeApp struct { //nolint: revive
UpgradeKeeper upgradekeeper.Keeper
ParamsKeeper paramskeeper.Keeper
// IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
IBCKeeper *ibckeeper.Keeper
ICAHostKeeper icahostkeeper.Keeper
EvidenceKeeper evidencekeeper.Keeper
TransferKeeper ibctransferkeeper.Keeper
FeeGrantKeeper feegrantkeeper.Keeper
GroupKeeper groupkeeper.Keeper
IBCKeeper *ibckeeper.Keeper
ICAHostKeeper icahostkeeper.Keeper
EvidenceKeeper evidencekeeper.Keeper
TransferKeeper ibctransferkeeper.Keeper
FeeGrantKeeper feegrantkeeper.Keeper
GroupKeeper groupkeeper.Keeper

RouterKeeper routerkeeper.Keeper

VotingKeeper votingkeeper.Keeper

// make scoped keepers public for test purposes
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
ScopedTransferKeeper capabilitykeeper.ScopedKeeper
Expand Down Expand Up @@ -262,7 +270,7 @@ func NewMandeApp(
minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey,
evidencetypes.StoreKey, ibctransfertypes.StoreKey,
capabilitytypes.StoreKey, feegrant.StoreKey, routertypes.StoreKey, icahosttypes.StoreKey, group.StoreKey,
capabilitytypes.StoreKey, feegrant.StoreKey, routertypes.StoreKey, icahosttypes.StoreKey, group.StoreKey, votingtypes.StoreKey,
)
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
Expand Down Expand Up @@ -328,7 +336,7 @@ func NewMandeApp(
app.GroupKeeper = groupkeeper.NewKeeper(
keys[group.StoreKey],
appCodec,
app.MsgServiceRouter(),
app.BaseApp.MsgServiceRouter(),
app.AccountKeeper,
groupConfig,
)
Expand Down Expand Up @@ -424,7 +432,7 @@ func NewMandeApp(
app.BankKeeper,
app.StakingKeeper,
govRouter,
app.MsgServiceRouter(),
app.BaseApp.MsgServiceRouter(),
govConfig,
)

Expand All @@ -437,6 +445,16 @@ func NewMandeApp(
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

app.VotingKeeper = *votingkeeper.NewKeeper(
appCodec,
keys[votingtypes.StoreKey],
keys[votingtypes.MemStoreKey],
app.GetSubspace(votingtypes.ModuleName),
app.AccountKeeper,
app.BankKeeper,
)
votingModule := voting.NewAppModule(appCodec, app.VotingKeeper, app.AccountKeeper, app.BankKeeper)

app.TransferKeeper = ibctransferkeeper.NewKeeper(
appCodec,
keys[ibctransfertypes.StoreKey],
Expand All @@ -459,7 +477,7 @@ func NewMandeApp(
&app.IBCKeeper.PortKeeper,
app.AccountKeeper,
scopedICAHostKeeper,
app.MsgServiceRouter(),
app.BaseApp.MsgServiceRouter(),
)
icaModule := ica.NewAppModule(nil, &app.ICAHostKeeper)
icaHostIBCModule := icahost.NewIBCModule(app.ICAHostKeeper)
Expand Down Expand Up @@ -515,6 +533,7 @@ func NewMandeApp(
icaModule,
routerModule,
routerModule,
votingModule,
)

// During begin block slashing happens after distr.BeginBlocker so that
Expand Down Expand Up @@ -544,6 +563,7 @@ func NewMandeApp(
group.ModuleName,
paramstypes.ModuleName,
vestingtypes.ModuleName,
votingtypes.ModuleName,
)
app.mm.SetOrderEndBlockers(
crisistypes.ModuleName,
Expand All @@ -566,6 +586,7 @@ func NewMandeApp(
paramstypes.ModuleName,
upgradetypes.ModuleName,
vestingtypes.ModuleName,
votingtypes.ModuleName,
)

// NOTE: The genutils module must occur after staking so that pools are
Expand Down Expand Up @@ -595,15 +616,16 @@ func NewMandeApp(
paramstypes.ModuleName,
upgradetypes.ModuleName,
vestingtypes.ModuleName,
votingtypes.ModuleName,
)

// Uncomment if you want to set a custom migration order here.
// app.mm.SetOrderMigrations(custom order)

app.mm.RegisterInvariants(&app.CrisisKeeper)
app.mm.RegisterRoutes(app.Router(), app.QueryRouter(), encodingConfig.Amino)
app.mm.RegisterRoutes(app.BaseApp.Router(), app.BaseApp.QueryRouter(), encodingConfig.Amino)

app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter())
app.configurator = module.NewConfigurator(app.appCodec, app.BaseApp.MsgServiceRouter(), app.BaseApp.GRPCQueryRouter())
app.mm.RegisterServices(app.configurator)

// create the simulation manager and define the order of the modules for deterministic simulations
Expand All @@ -630,9 +652,9 @@ func NewMandeApp(
app.sm.RegisterStoreDecoders()

// initialize stores
app.MountKVStores(keys)
app.MountTransientStores(tkeys)
app.MountMemoryStores(memKeys)
app.BaseApp.MountKVStores(keys)
app.BaseApp.MountTransientStores(tkeys)
app.BaseApp.MountMemoryStores(memKeys)

anteHandler, err := mandeante.NewAnteHandler(
mandeante.HandlerOptions{
Expand All @@ -655,17 +677,17 @@ func NewMandeApp(
return feeCoins, priority, nil
},
},
IBCkeeper: app.IBCKeeper,
IBCkeeper: app.IBCKeeper,
},
)
if err != nil {
panic(fmt.Errorf("failed to create AnteHandler: %s", err))
}

app.SetAnteHandler(anteHandler)
app.SetInitChainer(app.InitChainer)
app.SetBeginBlocker(app.BeginBlocker)
app.SetEndBlocker(app.EndBlocker)
app.BaseApp.SetAnteHandler(anteHandler)
app.BaseApp.SetInitChainer(app.InitChainer)
app.BaseApp.SetBeginBlocker(app.BeginBlocker)
app.BaseApp.SetEndBlocker(app.EndBlocker)

app.UpgradeKeeper.SetUpgradeHandler(
upgradeName,
Expand Down Expand Up @@ -719,11 +741,11 @@ func NewMandeApp(
}

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

if loadLatest {
if err := app.LoadLatestVersion(); err != nil {
if err := app.BaseApp.LoadLatestVersion(); err != nil {
tmos.Exit(fmt.Sprintf("failed to load latest version: %s", err))
}
}
Expand Down Expand Up @@ -769,7 +791,7 @@ func (app *MandeApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abc

// LoadHeight loads a particular height
func (app *MandeApp) LoadHeight(height int64) error {
return app.LoadVersion(height)
return app.BaseApp.LoadVersion(height)
}

// ModuleAccountAddrs returns all the app's module account addresses.
Expand Down
4 changes: 2 additions & 2 deletions app/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ func (app *MandeApp) ExportAppStateAndValidators(
forZeroHeight bool, jailAllowedAddrs []string,
) (servertypes.ExportedApp, error) {
// as if they could withdraw from the start of the next block
ctx := app.NewContext(true, tmproto.Header{Height: app.LastBlockHeight()})
ctx := app.BaseApp.NewContext(true, tmproto.Header{Height: app.BaseApp.LastBlockHeight()})

// We export at last height + 1, because that's the height at which
// Tendermint will start InitChain.
height := app.LastBlockHeight() + 1
height := app.BaseApp.LastBlockHeight() + 1
if forZeroHeight {
height = 0
app.prepForZeroHeightGenesis(ctx, jailAllowedAddrs)
Expand Down
Loading