refactor(types): loosen module.AppModule interface (#19951)

This commit is contained in:
Julien Robert 2024-04-04 16:21:02 +02:00 committed by GitHub
parent edd1c71072
commit 649dfaa8c5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 5 additions and 75 deletions

View File

@ -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)

View File

@ -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
@ -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

View File

@ -10,7 +10,6 @@ import (
reflect "reflect"
appmodule "cosmossdk.io/core/appmodule"
registry "cosmossdk.io/core/registry"
types "github.com/cosmos/cosmos-sdk/types"
module "github.com/cosmos/cosmos-sdk/types/module"
gomock "github.com/golang/mock/gomock"
@ -149,18 +148,6 @@ func (mr *MockAppModuleWithAllExtensionsMockRecorder) Name() *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Name", reflect.TypeOf((*MockAppModuleWithAllExtensions)(nil).Name))
}
// RegisterInterfaces mocks base method.
func (m *MockAppModuleWithAllExtensions) RegisterInterfaces(arg0 registry.InterfaceRegistrar) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "RegisterInterfaces", arg0)
}
// RegisterInterfaces indicates an expected call of RegisterInterfaces.
func (mr *MockAppModuleWithAllExtensionsMockRecorder) RegisterInterfaces(arg0 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegisterInterfaces", reflect.TypeOf((*MockAppModuleWithAllExtensions)(nil).RegisterInterfaces), arg0)
}
// RegisterInvariants mocks base method.
func (m *MockAppModuleWithAllExtensions) RegisterInvariants(arg0 types.InvariantRegistry) {
m.ctrl.T.Helper()
@ -333,18 +320,6 @@ func (mr *MockAppModuleWithAllExtensionsABCIMockRecorder) Name() *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Name", reflect.TypeOf((*MockAppModuleWithAllExtensionsABCI)(nil).Name))
}
// RegisterInterfaces mocks base method.
func (m *MockAppModuleWithAllExtensionsABCI) RegisterInterfaces(arg0 registry.InterfaceRegistrar) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "RegisterInterfaces", arg0)
}
// RegisterInterfaces indicates an expected call of RegisterInterfaces.
func (mr *MockAppModuleWithAllExtensionsABCIMockRecorder) RegisterInterfaces(arg0 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegisterInterfaces", reflect.TypeOf((*MockAppModuleWithAllExtensionsABCI)(nil).RegisterInterfaces), arg0)
}
// RegisterInvariants mocks base method.
func (m *MockAppModuleWithAllExtensionsABCI) RegisterInvariants(arg0 types.InvariantRegistry) {
m.ctrl.T.Helper()

View File

@ -9,7 +9,6 @@ import (
json "encoding/json"
reflect "reflect"
registry "cosmossdk.io/core/registry"
client "github.com/cosmos/cosmos-sdk/client"
codec "github.com/cosmos/cosmos-sdk/codec"
types "github.com/cosmos/cosmos-sdk/types"
@ -67,18 +66,6 @@ func (mr *MockAppModuleBasicMockRecorder) RegisterGRPCGatewayRoutes(arg0, arg1 i
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegisterGRPCGatewayRoutes", reflect.TypeOf((*MockAppModuleBasic)(nil).RegisterGRPCGatewayRoutes), arg0, arg1)
}
// RegisterInterfaces mocks base method.
func (m *MockAppModuleBasic) RegisterInterfaces(arg0 registry.InterfaceRegistrar) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "RegisterInterfaces", arg0)
}
// RegisterInterfaces indicates an expected call of RegisterInterfaces.
func (mr *MockAppModuleBasicMockRecorder) RegisterInterfaces(arg0 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegisterInterfaces", reflect.TypeOf((*MockAppModuleBasic)(nil).RegisterInterfaces), arg0)
}
// RegisterLegacyAminoCodec mocks base method.
func (m *MockAppModuleBasic) RegisterLegacyAminoCodec(arg0 *codec.LegacyAmino) {
m.ctrl.T.Helper()
@ -152,18 +139,6 @@ func (mr *MockAppModuleMockRecorder) Name() *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Name", reflect.TypeOf((*MockAppModule)(nil).Name))
}
// RegisterInterfaces mocks base method.
func (m *MockAppModule) RegisterInterfaces(arg0 registry.InterfaceRegistrar) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "RegisterInterfaces", arg0)
}
// RegisterInterfaces indicates an expected call of RegisterInterfaces.
func (mr *MockAppModuleMockRecorder) RegisterInterfaces(arg0 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegisterInterfaces", reflect.TypeOf((*MockAppModule)(nil).RegisterInterfaces), arg0)
}
// MockHasName is a mock of HasName interface.
type MockHasName struct {
ctrl *gomock.Controller
@ -576,15 +551,3 @@ func (mr *MockHasABCIEndBlockMockRecorder) Name() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Name", reflect.TypeOf((*MockHasABCIEndBlock)(nil).Name))
}
// RegisterInterfaces mocks base method.
func (m *MockHasABCIEndBlock) RegisterInterfaces(arg0 registry.InterfaceRegistrar) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "RegisterInterfaces", arg0)
}
// RegisterInterfaces indicates an expected call of RegisterInterfaces.
func (mr *MockHasABCIEndBlockMockRecorder) RegisterInterfaces(arg0 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegisterInterfaces", reflect.TypeOf((*MockHasABCIEndBlock)(nil).RegisterInterfaces), arg0)
}

View File

@ -50,8 +50,6 @@ type AppModuleBasic interface {
HasName
HasGRPCGateway
HasAminoCodec
appmodulev2.HasRegisterInterfaces
}
// AppModule is the form for an application module. Most of
@ -61,7 +59,6 @@ type AppModule interface {
HasName
appmodulev2.AppModule
appmodulev2.HasRegisterInterfaces
}
// HasName allows the module to provide its own name for legacy purposes.

View File

@ -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"
@ -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

View File

@ -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"
@ -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) {}