refactor: modules should implement appmodule.AppModule (#18252)

This commit is contained in:
Julien Robert
2023-10-25 12:31:37 +00:00
committed by GitHub
parent 139a29e7e2
commit 797ae0fe99
7 changed files with 137 additions and 12 deletions
+13 -3
View File
@@ -19,20 +19,26 @@ import (
)
var (
_ appmodule.AppModule = coreAppModuleBasicAdaptor{}
_ AppModuleBasic = coreAppModuleBasicAdaptor{}
_ HasABCIGenesis = coreAppModuleBasicAdaptor{}
_ HasServices = coreAppModuleBasicAdaptor{}
)
// CoreAppModuleBasicAdaptor wraps the core API module as an AppModule that this version
// of the SDK can use.
func CoreAppModuleBasicAdaptor(name string, module appmodule.AppModule) AppModuleBasic {
// CoreAppModuleAdaptor wraps the core API module as an AppModule that this version of the SDK can use.
func CoreAppModuleAdaptor(name string, module appmodule.AppModule) AppModule {
return coreAppModuleBasicAdaptor{
name: name,
module: module,
}
}
// CoreAppModuleBasicAdaptor wraps the core API module as an AppModule that this version of the SDK can use.
func CoreAppModuleBasicAdaptor(name string, module appmodule.AppModule) AppModule {
return CoreAppModuleAdaptor(name, module)
}
type coreAppModuleBasicAdaptor struct {
name string
module appmodule.AppModule
@@ -195,3 +201,7 @@ func (c coreAppModuleBasicAdaptor) RegisterServices(cfg Configurator) {
}
}
}
func (c coreAppModuleBasicAdaptor) IsOnePerModuleType() {}
func (c coreAppModuleBasicAdaptor) IsAppModule() {}
+6
View File
@@ -199,6 +199,8 @@ type HasABCIGenesis interface {
// its functionality has been moved to extension interfaces.
// Deprecated: use appmodule.AppModule with a combination of extension interfaes interfaces instead.
type AppModule interface {
appmodule.AppModule
AppModuleBasic
}
@@ -288,6 +290,10 @@ func NewManager(modules ...AppModule) *Manager {
modulesStr := make([]string, 0, len(modules))
preBlockModulesStr := make([]string, 0)
for _, module := range modules {
if _, ok := module.(appmodule.AppModule); !ok {
panic(fmt.Sprintf("module %s does not implement appmodule.AppModule", module.Name()))
}
moduleMap[module.Name()] = module
modulesStr = append(modulesStr, module.Name())
if _, ok := module.(appmodule.HasPreBlocker); ok {