Skip to content

Commit

Permalink
use a global for ModuleManager so we can access it
Browse files Browse the repository at this point in the history
  • Loading branch information
faddat committed Apr 24, 2023
1 parent 7ad4ec8 commit b58641e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
14 changes: 8 additions & 6 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,17 +188,19 @@ var (
// capabilities aren't needed for testing.
type App struct {
*baseapp.BaseApp
keepers.AppKeepers

cdc *codec.LegacyAmino
legacyAmino *codec.LegacyAmino
appCodec codec.Codec
txConfig client.TxConfig
interfaceRegistry types.InterfaceRegistry

invCheckPeriod uint

// the module manager
mm *module.Manager
ModuleManager *module.Manager

// simulation manager
sm *module.SimulationManager

// module configurator
configurator module.Configurator
}

// New returns a reference to an initialized Juno.
Expand Down
11 changes: 3 additions & 8 deletions app/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ import (

// ExportAppStateAndValidators exports the state of the application for a genesis
// file.
func (app *App) ExportAppStateAndValidators(
forZeroHeight bool, jailAllowedAddrs []string,
) (servertypes.ExportedApp, error) {
func (app *App) ExportAppStateAndValidators(forZeroHeight bool, jailAllowedAddrs []string, modulesToExport []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()})

Expand All @@ -29,22 +27,19 @@ func (app *App) ExportAppStateAndValidators(
app.prepForZeroHeightGenesis(ctx, jailAllowedAddrs)
}

genState := app.mm.ExportGenesis(ctx, app.appCodec)
genState := app.ModuleManager.ExportGenesisForModules(ctx, app.appCodec, modulesToExport)
appState, err := json.MarshalIndent(genState, "", " ")
if err != nil {
return servertypes.ExportedApp{}, err
}

validators, err := staking.WriteValidators(ctx, app.StakingKeeper)
if err != nil {
return servertypes.ExportedApp{}, err
}
return servertypes.ExportedApp{
AppState: appState,
Validators: validators,
Height: height,
ConsensusParams: app.BaseApp.GetConsensusParams(ctx),
}, nil
}, err
}

// prepare for fresh start at zero height
Expand Down

0 comments on commit b58641e

Please sign in to comment.