Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions baseapp/testutil/mock/mocks.go

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

48 changes: 48 additions & 0 deletions testutil/mock/types_mock_appmodule.go

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

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

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

16 changes: 13 additions & 3 deletions types/module/core_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,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
Expand Down Expand Up @@ -194,3 +200,7 @@ func (c coreAppModuleBasicAdaptor) RegisterServices(cfg Configurator) {
}
}
}

func (c coreAppModuleBasicAdaptor) IsOnePerModuleType() {}

func (c coreAppModuleBasicAdaptor) IsAppModule() {}
6 changes: 6 additions & 0 deletions types/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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 {
Expand Down
Loading