Skip to content

Commit

Permalink
refactor(types): loosen module.AppModule interface (#19951)
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt authored Apr 4, 2024
1 parent edd1c71 commit 649dfaa
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 75 deletions.
4 changes: 3 additions & 1 deletion runtime/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ func (a *App) RegisterModules(modules ...module.AppModule) error {
}

a.ModuleManager.Modules[name] = appModule
appModule.RegisterInterfaces(a.interfaceRegistry)
if mod, ok := appModule.(appmodule.HasRegisterInterfaces); ok {
mod.RegisterInterfaces(a.interfaceRegistry)
}

if mod, ok := appModule.(module.HasAminoCodec); ok {
mod.RegisterLegacyAminoCodec(a.amino)
Expand Down
2 changes: 2 additions & 0 deletions tests/starship/tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ replace (
cosmossdk.io/x/bank => ../../../x/bank
cosmossdk.io/x/circuit => ../../../x/circuit
cosmossdk.io/x/distribution => ../../../x/distribution
cosmossdk.io/x/epochs => ../../../x/epochs
cosmossdk.io/x/evidence => ../../../x/evidence
cosmossdk.io/x/feegrant => ../../../x/feegrant
cosmossdk.io/x/gov => ../../../x/gov
Expand Down Expand Up @@ -71,6 +72,7 @@ require (
cosmossdk.io/x/authz v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/circuit v0.0.0-20230613133644-0a778132a60f // indirect
cosmossdk.io/x/distribution v0.0.0-20240227221813-a248d05f70f4 // indirect
cosmossdk.io/x/epochs v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/evidence v0.0.0-20230613133644-0a778132a60f // indirect
cosmossdk.io/x/feegrant v0.0.0-20230613133644-0a778132a60f // indirect
cosmossdk.io/x/gov v0.0.0-20231113122742-912390d5fc4a // indirect
Expand Down
25 changes: 0 additions & 25 deletions testutil/mock/types_mock_appmodule.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 0 additions & 37 deletions testutil/mock/types_module_module.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions types/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ type AppModuleBasic interface {
HasName
HasGRPCGateway
HasAminoCodec

appmodulev2.HasRegisterInterfaces
}

// AppModule is the form for an application module. Most of
Expand All @@ -61,7 +59,6 @@ type AppModule interface {
HasName

appmodulev2.AppModule
appmodulev2.HasRegisterInterfaces
}

// HasName allows the module to provide its own name for legacy purposes.
Expand Down
5 changes: 0 additions & 5 deletions x/epochs/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"google.golang.org/grpc"

"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/registry"
"cosmossdk.io/x/epochs/keeper"
"cosmossdk.io/x/epochs/simulation"
"cosmossdk.io/x/epochs/types"
Expand Down Expand Up @@ -77,10 +76,6 @@ func (am AppModule) DefaultGenesis() json.RawMessage {
return am.cdc.MustMarshalJSON(types.DefaultGenesis())
}

// RegisterInterfaces implements InterfaceModule.RegisterInterfaces
func (AppModule) RegisterInterfaces(registrar registry.InterfaceRegistrar) {
}

// ValidateGenesis performs genesis state validation for the epochs module.
func (am AppModule) ValidateGenesis(bz json.RawMessage) error {
var gs types.GenesisState
Expand Down
4 changes: 0 additions & 4 deletions x/genutil/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (

"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/genesis"
"cosmossdk.io/core/registry"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
Expand Down Expand Up @@ -93,6 +92,3 @@ func (am AppModule) GenTxValidator() types.MessageValidator {

// ConsensusVersion implements HasConsensusVersion
func (AppModule) ConsensusVersion() uint64 { return 1 }

// RegisterInterfaces implements module.AppModule.
func (AppModule) RegisterInterfaces(registry.InterfaceRegistrar) {}

0 comments on commit 649dfaa

Please sign in to comment.