Skip to content

Commit

Permalink
fix legacy app
Browse files Browse the repository at this point in the history
  • Loading branch information
facundomedica committed Oct 25, 2024
1 parent c60f066 commit 8a6e0cb
Showing 1 changed file with 27 additions and 12 deletions.
39 changes: 27 additions & 12 deletions simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,19 @@ var (
govtypes.ModuleName: {authtypes.Burner},
nft.ModuleName: nil,
}

maccs = runtime.NewModuleAccountsService(
runtime.NewModuleAccount(authtypes.FeeCollectorName),
runtime.NewModuleAccount(distrtypes.ModuleName),
runtime.NewModuleAccount(pooltypes.ModuleName),
runtime.NewModuleAccount(pooltypes.StreamAccount),
runtime.NewModuleAccount(pooltypes.ProtocolPoolDistrAccount),
runtime.NewModuleAccount(minttypes.ModuleName, authtypes.Minter),
runtime.NewModuleAccount(stakingtypes.BondedPoolName, authtypes.Burner, authtypes.Staking),
runtime.NewModuleAccount(stakingtypes.NotBondedPoolName, authtypes.Burner, authtypes.Staking),
runtime.NewModuleAccount(govtypes.ModuleName, authtypes.Burner),
runtime.NewModuleAccount(nft.ModuleName),
)
)

var (
Expand Down Expand Up @@ -346,6 +359,7 @@ func NewSimApp(
app.AuthKeeper,
blockedAddrs,
govModuleAddr,
maccs,
)

// optional: enable sign mode textual by overwriting the default tx config (after setting the bank keeper)
Expand Down Expand Up @@ -374,23 +388,24 @@ func NewSimApp(
logger.With(log.ModuleKey, "x/staking"),
runtime.EnvWithMsgRouterService(app.MsgServiceRouter()),
runtime.EnvWithQueryRouterService(app.GRPCQueryRouter())),
app.AuthKeeper,
app.BankKeeper,
app.ConsensusParamsKeeper,
govModuleAddr,
signingCtx.AddressCodec(),
signingCtx.ValidatorAddressCodec(),
authcodec.NewBech32Codec(sdk.Bech32PrefixConsAddr),
cometService,
maccs,
)

app.MintKeeper = mintkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[minttypes.StoreKey]), logger.With(log.ModuleKey, "x/mint")), app.AuthKeeper, app.BankKeeper, authtypes.FeeCollectorName, govModuleAddr)
app.MintKeeper = mintkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[minttypes.StoreKey]), logger.With(log.ModuleKey, "x/mint")), app.BankKeeper, authtypes.FeeCollectorName, govModuleAddr, maccs)
if err := app.MintKeeper.SetMintFn(mintkeeper.DefaultMintFn(minttypes.DefaultInflationCalculationFn, app.StakingKeeper, app.MintKeeper)); err != nil {
panic(err)
}

app.PoolKeeper = poolkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[pooltypes.StoreKey]), logger.With(log.ModuleKey, "x/protocolpool")), app.AuthKeeper, app.BankKeeper, app.StakingKeeper, govModuleAddr)
app.PoolKeeper = poolkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[pooltypes.StoreKey]), logger.With(log.ModuleKey, "x/protocolpool")), app.BankKeeper, app.StakingKeeper, govModuleAddr, signingCtx.AddressCodec(), maccs)

app.DistrKeeper = distrkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[distrtypes.StoreKey]), logger.With(log.ModuleKey, "x/distribution")), app.AuthKeeper, app.BankKeeper, app.StakingKeeper, cometService, authtypes.FeeCollectorName, govModuleAddr)
app.DistrKeeper = distrkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[distrtypes.StoreKey]), logger.With(log.ModuleKey, "x/distribution")), app.BankKeeper, app.StakingKeeper, cometService, signingCtx.AddressCodec(), maccs, authtypes.FeeCollectorName, govModuleAddr)

app.SlashingKeeper = slashingkeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[slashingtypes.StoreKey]), logger.With(log.ModuleKey, "x/slashing")),
appCodec, legacyAmino, app.StakingKeeper, govModuleAddr,
Expand Down Expand Up @@ -438,7 +453,7 @@ func NewSimApp(
Example of setting gov params:
govConfig.MaxMetadataLen = 10000
*/
govKeeper := govkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[govtypes.StoreKey]), logger.With(log.ModuleKey, "x/gov"), runtime.EnvWithMsgRouterService(app.MsgServiceRouter()), runtime.EnvWithQueryRouterService(app.GRPCQueryRouter())), app.AuthKeeper, app.BankKeeper, app.StakingKeeper, app.PoolKeeper, govConfig, govModuleAddr)
govKeeper := govkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[govtypes.StoreKey]), logger.With(log.ModuleKey, "x/gov"), runtime.EnvWithMsgRouterService(app.MsgServiceRouter()), runtime.EnvWithQueryRouterService(app.GRPCQueryRouter())), signingCtx.AddressCodec(), app.BankKeeper, app.StakingKeeper, app.PoolKeeper, govConfig, govModuleAddr, maccs)

// Set legacy router for backwards compatibility with gov v1beta1
govKeeper.SetLegacyRouter(govRouter)
Expand All @@ -449,7 +464,7 @@ func NewSimApp(
),
)

app.NFTKeeper = nftkeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[nftkeeper.StoreKey]), logger.With(log.ModuleKey, "x/nft")), appCodec, app.AuthKeeper, app.BankKeeper)
app.NFTKeeper = nftkeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[nftkeeper.StoreKey]), logger.With(log.ModuleKey, "x/nft")), appCodec, app.BankKeeper, signingCtx.AddressCodec())

// create evidence keeper with router
evidenceKeeper := evidencekeeper.NewKeeper(
Expand Down Expand Up @@ -480,25 +495,25 @@ func NewSimApp(
// NOTE: Any module instantiated in the module manager that is later modified
// must be passed by reference here.
app.ModuleManager = module.NewManager(
genutil.NewAppModule(appCodec, app.AuthKeeper, app.StakingKeeper, app, txConfig, genutiltypes.DefaultMessageValidator),
genutil.NewAppModule(appCodec, app.StakingKeeper, app, txConfig, genutiltypes.DefaultMessageValidator),
accounts.NewAppModule(appCodec, app.AccountsKeeper),
auth.NewAppModule(appCodec, app.AuthKeeper, app.AccountsKeeper, authsims.RandomGenesisAccounts, nil),
vesting.NewAppModule(app.AuthKeeper, app.BankKeeper),
bank.NewAppModule(appCodec, app.BankKeeper, app.AuthKeeper),
feegrantmodule.NewAppModule(appCodec, app.FeeGrantKeeper, app.interfaceRegistry),
gov.NewAppModule(appCodec, &app.GovKeeper, app.AuthKeeper, app.BankKeeper, app.PoolKeeper),
mint.NewAppModule(appCodec, app.MintKeeper, app.AuthKeeper),
slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AuthKeeper, app.BankKeeper, app.StakingKeeper, app.interfaceRegistry, cometService),
gov.NewAppModule(appCodec, &app.GovKeeper, signingCtx.AddressCodec(), app.BankKeeper, app.PoolKeeper, maccs),
mint.NewAppModule(appCodec, app.MintKeeper),
slashing.NewAppModule(appCodec, app.SlashingKeeper, app.BankKeeper, app.StakingKeeper, app.interfaceRegistry, cometService),
distr.NewAppModule(appCodec, app.DistrKeeper, app.StakingKeeper),
staking.NewAppModule(appCodec, app.StakingKeeper),
upgrade.NewAppModule(app.UpgradeKeeper),
evidence.NewAppModule(appCodec, app.EvidenceKeeper, cometService),
authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.interfaceRegistry),
groupmodule.NewAppModule(appCodec, app.GroupKeeper, app.AuthKeeper, app.BankKeeper, app.interfaceRegistry),
nftmodule.NewAppModule(appCodec, app.NFTKeeper, app.AuthKeeper, app.BankKeeper, app.interfaceRegistry),
nftmodule.NewAppModule(appCodec, app.NFTKeeper, app.BankKeeper, app.interfaceRegistry, signingCtx.AddressCodec()),
consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper),
circuit.NewAppModule(appCodec, app.CircuitKeeper),
protocolpool.NewAppModule(appCodec, app.PoolKeeper, app.AuthKeeper, app.BankKeeper),
protocolpool.NewAppModule(appCodec, app.PoolKeeper, app.BankKeeper),
epochs.NewAppModule(appCodec, app.EpochsKeeper),
)

Expand Down

0 comments on commit 8a6e0cb

Please sign in to comment.