Skip to content

Commit

Permalink
chore: clean up module impls (#7865)
Browse files Browse the repository at this point in the history
* cleanup modules in modules/apps

* wait, we actually need that.

* cleanup core and light-client modules

* add HasRegisterInterfaces guard

---------

Co-authored-by: Gjermund Garaba <[email protected]>
  • Loading branch information
technicallyty and gjermundgaraba authored Jan 22, 2025
1 parent 8ca3628 commit d91eb00
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 268 deletions.
30 changes: 16 additions & 14 deletions modules/apps/27-interchain-accounts/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"

"cosmossdk.io/client/v2/autocli"
"cosmossdk.io/core/appmodule"
coreregistry "cosmossdk.io/core/registry"

Expand All @@ -30,12 +31,21 @@ import (
)

var (
_ module.AppModule = (*AppModule)(nil)
_ module.AppModuleBasic = (*AppModule)(nil)
_ module.AppModuleSimulation = (*AppModule)(nil)
_ module.HasGenesis = (*AppModule)(nil)
_ module.HasServices = (*AppModule)(nil)
_ appmodule.AppModule = (*AppModule)(nil)
_ appmodule.AppModule = (*AppModule)(nil)
_ appmodule.HasConsensusVersion = (*AppModule)(nil)
_ appmodule.HasRegisterInterfaces = (*AppModule)(nil)

_ module.AppModule = (*AppModule)(nil)
_ module.HasGenesis = (*AppModule)(nil)
_ module.HasServices = (*AppModule)(nil)
_ module.HasGRPCGateway = (*AppModule)(nil)

// Sims
_ module.AppModuleSimulation = (*AppModule)(nil)
_ module.HasLegacyProposalMsgs = (*AppModule)(nil)

_ autocli.HasCustomTxCommand = (*AppModule)(nil)
_ autocli.HasCustomQueryCommand = (*AppModule)(nil)

_ porttypes.IBCModule = (*host.IBCModule)(nil)
)
Expand Down Expand Up @@ -67,9 +77,6 @@ func (AppModule) IsOnePerModuleType() {}
// IsAppModule implements the appmodule.AppModule interface.
func (AppModule) IsAppModule() {}

// RegisterLegacyAminoCodec implements AppModule.
func (AppModule) RegisterLegacyAminoCodec(cdc coreregistry.AminoRegistrar) {}

// RegisterInterfaces registers module concrete types into protobuf Any
func (AppModule) RegisterInterfaces(registry coreregistry.InterfaceRegistrar) {
controllertypes.RegisterInterfaces(registry)
Expand Down Expand Up @@ -193,11 +200,6 @@ func (am AppModule) ProposalMsgs(simState module.SimulationState) []simtypes.Wei
return simulation.ProposalMsgs(am.controllerKeeper, am.hostKeeper)
}

// WeightedOperations is unimplemented.
func (AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation {
return nil
}

// RegisterStoreDecoder registers a decoder for interchain accounts module's types
func (AppModule) RegisterStoreDecoder(sdr simtypes.StoreDecoderRegistry) {
sdr[controllertypes.StoreKey] = simulation.NewDecodeStore()
Expand Down
36 changes: 12 additions & 24 deletions modules/apps/29-fee/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,30 @@ import (
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"

"cosmossdk.io/client/v2/autocli"
"cosmossdk.io/core/appmodule"
coreregistry "cosmossdk.io/core/registry"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/types/module"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"

"github.com/cosmos/ibc-go/v9/modules/apps/29-fee/client/cli"
"github.com/cosmos/ibc-go/v9/modules/apps/29-fee/keeper"
"github.com/cosmos/ibc-go/v9/modules/apps/29-fee/types"
)

var (
_ module.AppModule = (*AppModule)(nil)
_ module.HasAminoCodec = AppModule{}
_ module.AppModuleSimulation = (*AppModule)(nil)
_ module.HasGenesis = (*AppModule)(nil)
_ appmodule.HasConsensusVersion = (*AppModule)(nil)
_ module.HasServices = (*AppModule)(nil)
_ appmodule.AppModule = (*AppModule)(nil)
_ appmodule.AppModule = (*AppModule)(nil)
_ appmodule.HasConsensusVersion = (*AppModule)(nil)
_ appmodule.HasAminoCodec = (*AppModule)(nil)
_ appmodule.HasRegisterInterfaces = (*AppModule)(nil)

_ module.AppModule = (*AppModule)(nil)
_ module.HasGenesis = (*AppModule)(nil)
_ module.HasServices = (*AppModule)(nil)

_ autocli.HasCustomTxCommand = (*AppModule)(nil)
_ autocli.HasCustomQueryCommand = (*AppModule)(nil)
)

// AppModule represents the AppModule for this module
Expand Down Expand Up @@ -129,18 +132,3 @@ func (am AppModule) ExportGenesis(ctx context.Context) (json.RawMessage, error)

// ConsensusVersion implements AppModule/ConsensusVersion.
func (AppModule) ConsensusVersion() uint64 { return 2 }

// AppModuleSimulation functions

// GenerateGenesisState creates a randomized GenState of the 29-fee module.
func (AppModule) GenerateGenesisState(_ *module.SimulationState) {
}

// RegisterStoreDecoder registers a decoder for 29-fee module's types
func (AppModule) RegisterStoreDecoder(_ simtypes.StoreDecoderRegistry) {
}

// WeightedOperations returns the all the 29-fee module operations with their respective weights.
func (AppModule) WeightedOperations(_ module.SimulationState) []simtypes.WeightedOperation {
return nil
}
51 changes: 0 additions & 51 deletions modules/apps/transfer/keeper/invariants.go

This file was deleted.

79 changes: 0 additions & 79 deletions modules/apps/transfer/keeper/invariants_test.go

This file was deleted.

31 changes: 17 additions & 14 deletions modules/apps/transfer/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"

"cosmossdk.io/client/v2/autocli"
"cosmossdk.io/core/appmodule"
coreregistry "cosmossdk.io/core/registry"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"

Expand All @@ -25,14 +25,22 @@ import (
)

var (
_ module.AppModule = (*AppModule)(nil)
_ module.AppModuleBasic = (*AppModule)(nil)
_ module.AppModuleSimulation = (*AppModule)(nil)
_ module.HasGenesis = (*AppModule)(nil)
_ appmodule.HasConsensusVersion = (*AppModule)(nil)
_ module.HasInvariants = (*AppModule)(nil)
_ module.HasServices = (*AppModule)(nil)
_ appmodule.AppModule = (*AppModule)(nil)
_ appmodule.AppModule = (*AppModule)(nil)
_ appmodule.HasConsensusVersion = (*AppModule)(nil)
_ appmodule.HasRegisterInterfaces = (*AppModule)(nil)

_ module.AppModule = (*AppModule)(nil)
_ module.HasGRPCGateway = (*AppModule)(nil)
_ module.HasGenesis = (*AppModule)(nil)
_ module.HasServices = (*AppModule)(nil)

// Sims
_ module.AppModuleSimulation = (*AppModule)(nil)
_ module.HasLegacyProposalMsgs = (*AppModule)(nil)
_ module.HasLegacyWeightedOperations = (*AppModule)(nil)

_ autocli.HasCustomTxCommand = (*AppModule)(nil)
_ autocli.HasCustomQueryCommand = (*AppModule)(nil)

_ porttypes.IBCModule = (*IBCModule)(nil)
)
Expand Down Expand Up @@ -109,11 +117,6 @@ func (AppModule) GetQueryCmd() *cobra.Command {
return cli.GetQueryCmd()
}

// RegisterInvariants implements the AppModule interface
func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {
keeper.RegisterInvariants(ir, &am.keeper)
}

// RegisterServices registers module services.
func (am AppModule) RegisterServices(cfg module.Configurator) {
types.RegisterMsgServer(cfg.MsgServer(), am.keeper)
Expand Down
32 changes: 16 additions & 16 deletions modules/core/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"

"cosmossdk.io/client/v2/autocli"
"cosmossdk.io/core/appmodule"
coreregistry "cosmossdk.io/core/registry"

Expand All @@ -32,14 +33,21 @@ import (
)

var (
_ module.AppModule = (*AppModule)(nil)
_ module.AppModuleBasic = (*AppModule)(nil)
_ module.AppModuleSimulation = (*AppModule)(nil)
_ module.HasGenesis = (*AppModule)(nil)
_ appmodule.HasConsensusVersion = (*AppModule)(nil)
_ module.HasServices = (*AppModule)(nil)
_ appmodule.AppModule = (*AppModule)(nil)
_ appmodule.HasBeginBlocker = (*AppModule)(nil)
_ appmodule.AppModule = (*AppModule)(nil)
_ appmodule.HasBeginBlocker = (*AppModule)(nil)
_ appmodule.HasConsensusVersion = (*AppModule)(nil)
_ appmodule.HasRegisterInterfaces = (*AppModule)(nil)

_ module.AppModule = (*AppModule)(nil)
_ module.HasGRPCGateway = (*AppModule)(nil)
_ module.HasGenesis = (*AppModule)(nil)
_ module.HasServices = (*AppModule)(nil)

_ module.HasLegacyProposalMsgs = (*AppModule)(nil)
_ module.AppModuleSimulation = (*AppModule)(nil)

_ autocli.HasCustomTxCommand = (*AppModule)(nil)
_ autocli.HasCustomQueryCommand = (*AppModule)(nil)
)

// AppModule implements an application module for the ibc module.
Expand Down Expand Up @@ -67,9 +75,6 @@ func (AppModule) IsOnePerModuleType() {}
// IsAppModule implements the appmodule.AppModule interface.
func (AppModule) IsAppModule() {}

// RegisterLegacyAminoCodec does nothing. IBC does not support amino.
func (AppModule) RegisterLegacyAminoCodec(coreregistry.AminoRegistrar) {}

// DefaultGenesis returns default genesis state as raw bytes for the ibc
// module.
func (am AppModule) DefaultGenesis() json.RawMessage {
Expand Down Expand Up @@ -202,8 +207,3 @@ func (AppModule) ProposalMsgs(simState module.SimulationState) []simtypes.Weight
func (am AppModule) RegisterStoreDecoder(sdr simtypes.StoreDecoderRegistry) {
sdr[exported.StoreKey] = simulation.NewDecodeStore(*am.keeper)
}

// WeightedOperations returns the all the ibc module operations with their respective weights.
func (AppModule) WeightedOperations(_ module.SimulationState) []simtypes.WeightedOperation {
return nil
}
Loading

0 comments on commit d91eb00

Please sign in to comment.