From 1f38669993f81d79821bdf7162b99528b2a7978f Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Fri, 13 Sep 2024 17:20:16 +0200 Subject: [PATCH] refactor(simapp): simplify simapp di --- simapp/app_di.go | 30 ++----------------------- simapp/v2/app_di.go | 54 ++------------------------------------------- 2 files changed, 4 insertions(+), 80 deletions(-) diff --git a/simapp/app_di.go b/simapp/app_di.go index 543655c02b87..32046a59b7e0 100644 --- a/simapp/app_di.go +++ b/simapp/app_di.go @@ -15,21 +15,12 @@ import ( "cosmossdk.io/depinject" "cosmossdk.io/log" "cosmossdk.io/x/accounts" - authzkeeper "cosmossdk.io/x/authz/keeper" bankkeeper "cosmossdk.io/x/bank/keeper" - bankv2keeper "cosmossdk.io/x/bank/v2/keeper" circuitkeeper "cosmossdk.io/x/circuit/keeper" consensuskeeper "cosmossdk.io/x/consensus/keeper" distrkeeper "cosmossdk.io/x/distribution/keeper" - epochskeeper "cosmossdk.io/x/epochs/keeper" - evidencekeeper "cosmossdk.io/x/evidence/keeper" feegrantkeeper "cosmossdk.io/x/feegrant/keeper" - govkeeper "cosmossdk.io/x/gov/keeper" - groupkeeper "cosmossdk.io/x/group/keeper" - mintkeeper "cosmossdk.io/x/mint/keeper" - nftkeeper "cosmossdk.io/x/nft/keeper" _ "cosmossdk.io/x/protocolpool" - poolkeeper "cosmossdk.io/x/protocolpool/keeper" slashingkeeper "cosmossdk.io/x/slashing/keeper" stakingkeeper "cosmossdk.io/x/staking/keeper" upgradekeeper "cosmossdk.io/x/upgrade/keeper" @@ -71,26 +62,18 @@ type SimApp struct { txConfig client.TxConfig interfaceRegistry codectypes.InterfaceRegistry - // keepers + // required keepers during wiring + // others keepers are all in the app AccountsKeeper accounts.Keeper AuthKeeper authkeeper.AccountKeeper BankKeeper bankkeeper.Keeper - BankV2Keeper *bankv2keeper.Keeper StakingKeeper *stakingkeeper.Keeper SlashingKeeper slashingkeeper.Keeper - MintKeeper mintkeeper.Keeper DistrKeeper distrkeeper.Keeper - GovKeeper *govkeeper.Keeper UpgradeKeeper *upgradekeeper.Keeper - AuthzKeeper authzkeeper.Keeper - EvidenceKeeper evidencekeeper.Keeper FeeGrantKeeper feegrantkeeper.Keeper - GroupKeeper groupkeeper.Keeper - NFTKeeper nftkeeper.Keeper ConsensusParamsKeeper consensuskeeper.Keeper CircuitBreakerKeeper circuitkeeper.Keeper - PoolKeeper poolkeeper.Keeper - EpochsKeeper *epochskeeper.Keeper // simulation manager sm *module.SimulationManager @@ -186,22 +169,13 @@ func NewSimApp( &app.AuthKeeper, &app.AccountsKeeper, &app.BankKeeper, - &app.BankV2Keeper, &app.StakingKeeper, &app.SlashingKeeper, - &app.MintKeeper, &app.DistrKeeper, - &app.GovKeeper, &app.UpgradeKeeper, - &app.AuthzKeeper, - &app.EvidenceKeeper, &app.FeeGrantKeeper, - &app.GroupKeeper, - &app.NFTKeeper, &app.ConsensusParamsKeeper, &app.CircuitBreakerKeeper, - &app.PoolKeeper, - &app.EpochsKeeper, ); err != nil { panic(err) } diff --git a/simapp/v2/app_di.go b/simapp/v2/app_di.go index a41a6addafea..733ab1ffc829 100644 --- a/simapp/v2/app_di.go +++ b/simapp/v2/app_di.go @@ -13,31 +13,13 @@ import ( "cosmossdk.io/log" "cosmossdk.io/runtime/v2" "cosmossdk.io/store/v2/root" - "cosmossdk.io/x/accounts" - authzkeeper "cosmossdk.io/x/authz/keeper" - bankkeeper "cosmossdk.io/x/bank/keeper" - bankv2keeper "cosmossdk.io/x/bank/v2/keeper" - circuitkeeper "cosmossdk.io/x/circuit/keeper" consensuskeeper "cosmossdk.io/x/consensus/keeper" - distrkeeper "cosmossdk.io/x/distribution/keeper" - epochskeeper "cosmossdk.io/x/epochs/keeper" - evidencekeeper "cosmossdk.io/x/evidence/keeper" - feegrantkeeper "cosmossdk.io/x/feegrant/keeper" - govkeeper "cosmossdk.io/x/gov/keeper" - groupkeeper "cosmossdk.io/x/group/keeper" - mintkeeper "cosmossdk.io/x/mint/keeper" - nftkeeper "cosmossdk.io/x/nft/keeper" - _ "cosmossdk.io/x/protocolpool" - poolkeeper "cosmossdk.io/x/protocolpool/keeper" - slashingkeeper "cosmossdk.io/x/slashing/keeper" - stakingkeeper "cosmossdk.io/x/staking/keeper" upgradekeeper "cosmossdk.io/x/upgrade/keeper" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/std" - authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" _ "github.com/cosmos/cosmos-sdk/x/genutil" ) @@ -54,26 +36,10 @@ type SimApp[T transaction.Tx] struct { txConfig client.TxConfig interfaceRegistry codectypes.InterfaceRegistry - // keepers - AccountsKeeper accounts.Keeper - AuthKeeper authkeeper.AccountKeeper - BankKeeper bankkeeper.Keeper - BankV2Keeper *bankv2keeper.Keeper - StakingKeeper *stakingkeeper.Keeper - SlashingKeeper slashingkeeper.Keeper - MintKeeper mintkeeper.Keeper - DistrKeeper distrkeeper.Keeper - GovKeeper *govkeeper.Keeper + // required keepers during wiring + // others keepers are all in the app UpgradeKeeper *upgradekeeper.Keeper - AuthzKeeper authzkeeper.Keeper - EvidenceKeeper evidencekeeper.Keeper - FeeGrantKeeper feegrantkeeper.Keeper - GroupKeeper groupkeeper.Keeper - NFTKeeper nftkeeper.Keeper ConsensusParamsKeeper consensuskeeper.Keeper - CircuitBreakerKeeper circuitkeeper.Keeper - PoolKeeper poolkeeper.Keeper - EpochsKeeper *epochskeeper.Keeper } func init() { @@ -168,24 +134,8 @@ func NewSimApp[T transaction.Tx]( &app.legacyAmino, &app.txConfig, &app.interfaceRegistry, - &app.AuthKeeper, - &app.BankKeeper, - &app.BankV2Keeper, - &app.StakingKeeper, - &app.SlashingKeeper, - &app.MintKeeper, - &app.DistrKeeper, - &app.GovKeeper, &app.UpgradeKeeper, - &app.AuthzKeeper, - &app.EvidenceKeeper, - &app.FeeGrantKeeper, - &app.GroupKeeper, - &app.NFTKeeper, &app.ConsensusParamsKeeper, - &app.CircuitBreakerKeeper, - &app.PoolKeeper, - &app.EpochsKeeper, ); err != nil { panic(err) }