Skip to content

Commit 6d49de2

Browse files
committed
appmodule & simapp cleanup
1 parent 5a331ed commit 6d49de2

File tree

19 files changed

+538
-746
lines changed

19 files changed

+538
-746
lines changed

modules/apps/27-interchain-accounts/module.go

+15-22
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import (
3232

3333
var (
3434
_ module.AppModule = (*AppModule)(nil)
35-
_ module.AppModuleBasic = (*AppModuleBasic)(nil)
35+
_ module.AppModuleBasic = (*AppModule)(nil)
3636
_ module.AppModuleSimulation = (*AppModule)(nil)
3737
_ module.HasGenesis = (*AppModule)(nil)
3838
_ module.HasServices = (*AppModule)(nil)
@@ -42,13 +42,8 @@ var (
4242
_ porttypes.IBCModule = (*host.IBCModule)(nil)
4343
)
4444

45-
// AppModuleBasic is the IBC interchain accounts AppModuleBasic
46-
type AppModuleBasic struct {
47-
cdc codec.Codec
48-
}
49-
5045
// Name implements AppModuleBasic interface
51-
func (AppModuleBasic) Name() string {
46+
func (AppModule) Name() string {
5247
return types.ModuleName
5348
}
5449

@@ -58,24 +53,24 @@ func (AppModule) IsOnePerModuleType() {}
5853
// IsAppModule implements the appmodule.AppModule interface.
5954
func (AppModule) IsAppModule() {}
6055

61-
// RegisterLegacyAminoCodec implements AppModuleBasic.
62-
func (AppModuleBasic) RegisterLegacyAminoCodec(cdc registry.AminoRegistrar) {}
56+
// RegisterLegacyAminoCodec implements AppModule.
57+
func (AppModule) RegisterLegacyAminoCodec(cdc registry.AminoRegistrar) {}
6358

6459
// RegisterInterfaces registers module concrete types into protobuf Any
65-
func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) {
60+
func (AppModule) RegisterInterfaces(registry codectypes.InterfaceRegistry) {
6661
controllertypes.RegisterInterfaces(registry)
6762
hosttypes.RegisterInterfaces(registry)
6863
types.RegisterInterfaces(registry)
6964
}
7065

7166
// DefaultGenesis returns default genesis state as raw bytes for the IBC
7267
// interchain accounts module
73-
func (am AppModuleBasic) DefaultGenesis() json.RawMessage {
68+
func (am AppModule) DefaultGenesis() json.RawMessage {
7469
return am.cdc.MustMarshalJSON(genesistypes.DefaultGenesis())
7570
}
7671

7772
// ValidateGenesis performs genesis state validation for the IBC interchain accounts module
78-
func (am AppModuleBasic) ValidateGenesis(bz json.RawMessage) error {
73+
func (am AppModule) ValidateGenesis(bz json.RawMessage) error {
7974
var gs genesistypes.GenesisState
8075
if err := am.cdc.UnmarshalJSON(bz, &gs); err != nil {
8176
return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err)
@@ -85,7 +80,7 @@ func (am AppModuleBasic) ValidateGenesis(bz json.RawMessage) error {
8580
}
8681

8782
// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the interchain accounts module.
88-
func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
83+
func (AppModule) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
8984
err := controllertypes.RegisterQueryHandlerClient(context.Background(), mux, controllertypes.NewQueryClient(clientCtx))
9085
if err != nil {
9186
panic(err)
@@ -97,29 +92,27 @@ func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *r
9792
}
9893
}
9994

100-
// GetTxCmd implements AppModuleBasic interface
101-
func (AppModuleBasic) GetTxCmd() *cobra.Command {
95+
// GetTxCmd implements AppModule interface
96+
func (AppModule) GetTxCmd() *cobra.Command {
10297
return cli.NewTxCmd()
10398
}
10499

105-
// GetQueryCmd implements AppModuleBasic interface
106-
func (AppModuleBasic) GetQueryCmd() *cobra.Command {
100+
// GetQueryCmd implements AppModule interface
101+
func (AppModule) GetQueryCmd() *cobra.Command {
107102
return cli.GetQueryCmd()
108103
}
109104

110105
// AppModule is the application module for the IBC interchain accounts module
111106
type AppModule struct {
112-
AppModuleBasic
107+
cdc codec.Codec
113108
controllerKeeper *controllerkeeper.Keeper
114109
hostKeeper *hostkeeper.Keeper
115110
}
116111

117112
// NewAppModule creates a new IBC interchain accounts module
118-
func NewAppModule(controllerKeeper *controllerkeeper.Keeper, hostKeeper *hostkeeper.Keeper) AppModule {
113+
func NewAppModule(cdc codec.Codec, controllerKeeper *controllerkeeper.Keeper, hostKeeper *hostkeeper.Keeper) AppModule {
119114
return AppModule{
120-
AppModuleBasic: AppModuleBasic{
121-
cdc: nil,
122-
},
115+
cdc: cdc,
123116
controllerKeeper: controllerKeeper,
124117
hostKeeper: hostKeeper,
125118
}

modules/apps/29-fee/module.go

+14-18
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,8 @@ var (
3030
_ appmodule.AppModule = (*AppModule)(nil)
3131
)
3232

33-
// AppModuleBasic is the 29-fee AppModuleBasic
34-
type AppModuleBasic struct {
35-
cdc codec.Codec
36-
}
37-
3833
// Name implements AppModuleBasic interface
39-
func (AppModuleBasic) Name() string {
34+
func (AppModule) Name() string {
4035
return types.ModuleName
4136
}
4237

@@ -46,24 +41,24 @@ func (AppModule) IsOnePerModuleType() {}
4641
// IsAppModule implements the appmodule.AppModule interface.
4742
func (AppModule) IsAppModule() {}
4843

49-
// RegisterLegacyAminoCodec implements AppModuleBasic interface
50-
func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
44+
// RegisterLegacyAminoCodec implements AppModule interface
45+
func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
5146
types.RegisterLegacyAminoCodec(cdc)
5247
}
5348

5449
// RegisterInterfaces registers module concrete types into protobuf Any.
55-
func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) {
50+
func (AppModule) RegisterInterfaces(registry codectypes.InterfaceRegistry) {
5651
types.RegisterInterfaces(registry)
5752
}
5853

5954
// DefaultGenesis returns default genesis state as raw bytes for the ibc
6055
// 29-fee module.
61-
func (am AppModuleBasic) DefaultGenesis() json.RawMessage {
56+
func (am AppModule) DefaultGenesis() json.RawMessage {
6257
return am.cdc.MustMarshalJSON(types.DefaultGenesisState())
6358
}
6459

6560
// ValidateGenesis performs genesis state validation for the 29-fee module.
66-
func (am AppModuleBasic) ValidateGenesis(bz json.RawMessage) error {
61+
func (am AppModule) ValidateGenesis(bz json.RawMessage) error {
6762
var gs types.GenesisState
6863
if err := am.cdc.UnmarshalJSON(bz, &gs); err != nil {
6964
return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err)
@@ -73,32 +68,33 @@ func (am AppModuleBasic) ValidateGenesis(bz json.RawMessage) error {
7368
}
7469

7570
// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for ics29 fee module.
76-
func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
71+
func (AppModule) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
7772
err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx))
7873
if err != nil {
7974
panic(err)
8075
}
8176
}
8277

83-
// GetTxCmd implements AppModuleBasic interface
84-
func (AppModuleBasic) GetTxCmd() *cobra.Command {
78+
// GetTxCmd implements AppModule interface
79+
func (AppModule) GetTxCmd() *cobra.Command {
8580
return cli.NewTxCmd()
8681
}
8782

88-
// GetQueryCmd implements AppModuleBasic interface
89-
func (AppModuleBasic) GetQueryCmd() *cobra.Command {
83+
// GetQueryCmd implements AppModule interface
84+
func (AppModule) GetQueryCmd() *cobra.Command {
9085
return cli.GetQueryCmd()
9186
}
9287

9388
// AppModule represents the AppModule for this module
9489
type AppModule struct {
95-
AppModuleBasic
90+
cdc codec.Codec
9691
keeper keeper.Keeper
9792
}
9893

9994
// NewAppModule creates a new 29-fee module
100-
func NewAppModule(k keeper.Keeper) AppModule {
95+
func NewAppModule(cdc codec.Codec, k keeper.Keeper) AppModule {
10196
return AppModule{
97+
cdc: cdc,
10298
keeper: k,
10399
}
104100
}

modules/apps/callbacks/testing/simapp/app.go

+2-18
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,6 @@ import (
9393
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
9494
"github.com/cosmos/cosmos-sdk/x/auth/vesting"
9595
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
96-
"github.com/cosmos/cosmos-sdk/x/crisis"
97-
crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper"
98-
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
9996
"github.com/cosmos/cosmos-sdk/x/genutil"
10097
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
10198

@@ -184,7 +181,6 @@ type SimApp struct {
184181
MintKeeper mintkeeper.Keeper
185182
DistrKeeper distrkeeper.Keeper
186183
GovKeeper govkeeper.Keeper
187-
CrisisKeeper *crisiskeeper.Keeper
188184
UpgradeKeeper *upgradekeeper.Keeper
189185
ParamsKeeper paramskeeper.Keeper
190186
AuthzKeeper authzkeeper.Keeper
@@ -296,7 +292,7 @@ func NewSimApp(
296292
bApp.SetTxEncoder(txConfig.TxEncoder())
297293

298294
keys := storetypes.NewKVStoreKeys(
299-
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, crisistypes.StoreKey,
295+
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey,
300296
minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
301297
govtypes.StoreKey, group.StoreKey, paramstypes.StoreKey, ibcexported.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey,
302298
evidencetypes.StoreKey, ibctransfertypes.StoreKey, icacontrollertypes.StoreKey, icahosttypes.StoreKey, capabilitytypes.StoreKey,
@@ -371,10 +367,6 @@ func NewSimApp(
371367
appCodec, legacyAmino, runtime.NewKVStoreService(keys[slashingtypes.StoreKey]), app.StakingKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(),
372368
)
373369

374-
invCheckPeriod := cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod))
375-
app.CrisisKeeper = crisiskeeper.NewKeeper(appCodec, runtime.NewKVStoreService(keys[crisistypes.StoreKey]), invCheckPeriod,
376-
app.BankKeeper, authtypes.FeeCollectorName, authtypes.NewModuleAddress(govtypes.ModuleName).String(), app.AccountKeeper.AddressCodec())
377-
378370
app.FeeGrantKeeper = feegrantkeeper.NewKeeper(appCodec, runtime.NewKVStoreService(keys[feegrant.StoreKey]), app.AccountKeeper)
379371

380372
// register the staking hooks
@@ -586,10 +578,6 @@ func NewSimApp(
586578

587579
// **** Module Options ****
588580

589-
// NOTE: we may consider parsing `appOpts` inside module constructors. For the moment
590-
// we prefer to be more strict in what arguments the modules expect.
591-
skipGenesisInvariants := cast.ToBool(appOpts.Get(crisis.FlagSkipGenesisInvariants))
592-
593581
// NOTE: Any module instantiated in the module manager that is later modified
594582
// must be passed by reference here.
595583
app.ModuleManager = module.NewManager(
@@ -601,7 +589,6 @@ func NewSimApp(
601589
vesting.NewAppModule(app.AccountKeeper, app.BankKeeper),
602590
bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper, app.GetSubspace(banktypes.ModuleName)),
603591
capability.NewAppModule(appCodec, *app.CapabilityKeeper, false),
604-
crisis.NewAppModule(app.CrisisKeeper, skipGenesisInvariants, app.GetSubspace(crisistypes.ModuleName)),
605592
feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry),
606593
gov.NewAppModule(appCodec, &app.GovKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(govtypes.ModuleName)),
607594
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, nil, app.GetSubspace(minttypes.ModuleName)),
@@ -671,7 +658,6 @@ func NewSimApp(
671658
ibcmock.ModuleName,
672659
)
673660
app.ModuleManager.SetOrderEndBlockers(
674-
crisistypes.ModuleName,
675661
govtypes.ModuleName,
676662
stakingtypes.ModuleName,
677663
ibcexported.ModuleName,
@@ -695,7 +681,7 @@ func NewSimApp(
695681
capabilitytypes.ModuleName,
696682
authtypes.ModuleName,
697683
banktypes.ModuleName, distrtypes.ModuleName, stakingtypes.ModuleName,
698-
slashingtypes.ModuleName, govtypes.ModuleName, minttypes.ModuleName, crisistypes.ModuleName,
684+
slashingtypes.ModuleName, govtypes.ModuleName, minttypes.ModuleName,
699685
ibcexported.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, authz.ModuleName, ibctransfertypes.ModuleName,
700686
icatypes.ModuleName, ibcfeetypes.ModuleName, ibcmock.ModuleName, feegrant.ModuleName, paramstypes.ModuleName, upgradetypes.ModuleName,
701687
vestingtypes.ModuleName, group.ModuleName, consensusparamtypes.ModuleName, circuittypes.ModuleName,
@@ -705,8 +691,6 @@ func NewSimApp(
705691

706692
// Uncomment if you want to set a custom migration order here.
707693
// app.ModuleManager.SetOrderMigrations(custom order)
708-
709-
app.ModuleManager.RegisterInvariants(app.CrisisKeeper)
710694
app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter())
711695
err := app.ModuleManager.RegisterServices(app.configurator)
712696
if err != nil {

modules/apps/callbacks/testing/simapp/simd/cmd/root.go

-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import (
3232
"github.com/cosmos/cosmos-sdk/x/auth/tx"
3333
txmodule "github.com/cosmos/cosmos-sdk/x/auth/tx/config"
3434
"github.com/cosmos/cosmos-sdk/x/auth/types"
35-
"github.com/cosmos/cosmos-sdk/x/crisis"
3635
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
3736

3837
cmtcfg "github.com/cometbft/cometbft/config"
@@ -214,7 +213,6 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig, b
214213
}
215214

216215
func addModuleInitFlags(startCmd *cobra.Command) {
217-
crisis.AddModuleInitFlags(startCmd)
218216
}
219217

220218
func queryCommand() *cobra.Command {

modules/apps/transfer/module.go

+15-19
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727

2828
var (
2929
_ module.AppModule = (*AppModule)(nil)
30-
_ module.AppModuleBasic = (*AppModuleBasic)(nil)
30+
_ module.AppModuleBasic = (*AppModule)(nil)
3131
_ module.AppModuleSimulation = (*AppModule)(nil)
3232
_ module.HasGenesis = (*AppModule)(nil)
3333
_ appmodule.HasConsensusVersion = (*AppModule)(nil)
@@ -39,13 +39,8 @@ var (
3939
_ porttypes.IBCModule = (*IBCModule)(nil)
4040
)
4141

42-
// AppModuleBasic is the IBC Transfer AppModuleBasic
43-
type AppModuleBasic struct {
44-
cdc codec.Codec
45-
}
46-
4742
// Name implements AppModuleBasic interface
48-
func (AppModuleBasic) Name() string {
43+
func (AppModule) Name() string {
4944
return types.ModuleName
5045
}
5146

@@ -55,24 +50,24 @@ func (AppModule) IsOnePerModuleType() {}
5550
// IsAppModule implements the appmodule.AppModule interface.
5651
func (AppModule) IsAppModule() {}
5752

58-
// RegisterLegacyAminoCodec implements AppModuleBasic interface
59-
func (AppModuleBasic) RegisterLegacyAminoCodec(cdc registry.AminoRegistrar) {
53+
// RegisterLegacyAminoCodec implements AppModule interface
54+
func (AppModule) RegisterLegacyAminoCodec(cdc registry.AminoRegistrar) {
6055
types.RegisterLegacyAminoCodec(cdc)
6156
}
6257

6358
// RegisterInterfaces registers module concrete types into protobuf Any.
64-
func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) {
59+
func (AppModule) RegisterInterfaces(registry codectypes.InterfaceRegistry) {
6560
types.RegisterInterfaces(registry)
6661
}
6762

6863
// DefaultGenesis returns default genesis state as raw bytes for the ibc
6964
// transfer module.
70-
func (am AppModuleBasic) DefaultGenesis() json.RawMessage {
65+
func (am AppModule) DefaultGenesis() json.RawMessage {
7166
return am.cdc.MustMarshalJSON(types.DefaultGenesisState())
7267
}
7368

7469
// ValidateGenesis performs genesis state validation for the ibc transfer module.
75-
func (am AppModuleBasic) ValidateGenesis(bz json.RawMessage) error {
70+
func (am AppModule) ValidateGenesis(bz json.RawMessage) error {
7671
var gs types.GenesisState
7772
if err := am.cdc.UnmarshalJSON(bz, &gs); err != nil {
7873
return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err)
@@ -82,7 +77,7 @@ func (am AppModuleBasic) ValidateGenesis(bz json.RawMessage) error {
8277
}
8378

8479
// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the ibc-transfer module.
85-
func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
80+
func (AppModule) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
8681
if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil {
8782
panic(err)
8883
}
@@ -92,25 +87,26 @@ func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *r
9287
}
9388
}
9489

95-
// GetTxCmd implements AppModuleBasic interface
96-
func (AppModuleBasic) GetTxCmd() *cobra.Command {
90+
// GetTxCmd implements AppModule interface
91+
func (AppModule) GetTxCmd() *cobra.Command {
9792
return cli.NewTxCmd()
9893
}
9994

100-
// GetQueryCmd implements AppModuleBasic interface
101-
func (AppModuleBasic) GetQueryCmd() *cobra.Command {
95+
// GetQueryCmd implements AppModule interface
96+
func (AppModule) GetQueryCmd() *cobra.Command {
10297
return cli.GetQueryCmd()
10398
}
10499

105100
// AppModule represents the AppModule for this module
106101
type AppModule struct {
107-
AppModuleBasic
102+
cdc codec.Codec
108103
keeper keeper.Keeper
109104
}
110105

111106
// NewAppModule creates a new 20-transfer module
112-
func NewAppModule(k keeper.Keeper) AppModule {
107+
func NewAppModule(cdc codec.Codec, k keeper.Keeper) AppModule {
113108
return AppModule{
109+
cdc: cdc,
114110
keeper: k,
115111
}
116112
}

modules/light-clients/07-tendermint/codec_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func TestCodecTypeRegistration(t *testing.T) {
4949
tc := tc
5050

5151
t.Run(tc.name, func(t *testing.T) {
52-
encodingCfg := moduletestutil.MakeTestEncodingConfig(testutil.CodecOptions{}, tendermint.AppModuleBasic{})
52+
encodingCfg := moduletestutil.MakeTestEncodingConfig(testutil.CodecOptions{}, tendermint.AppModule{})
5353
msg, err := encodingCfg.Codec.InterfaceRegistry().Resolve(tc.typeURL)
5454

5555
if tc.expPass {

0 commit comments

Comments
 (0)