zeta-chain / node

ZetaChain’s blockchain node and an observer validator client
https://zetachain.com
MIT License
169 stars 109 forks source link

`zetacore` : Create Basic manager from Module manager #3021

Open kingpinXD opened 1 month ago

kingpinXD commented 1 month ago

Currently, we create the Basic manager separately

https://github.com/zeta-chain/zeta-node/blob/74b0ad7c2e62aa94826cebaaf1421e83523f15fb/app/modules.go#L61-L90

This should be refactored to create the Basic Manager from the Module manager , so that we only define the list of modules once

We should use the function provided by the cosmos SDK for this

// NewBasicManagerFromManager creates a new BasicManager from a Manager
// The BasicManager will contain all AppModuleBasic from the AppModule Manager
// Module's AppModuleBasic can be overridden by passing a custom AppModuleBasic map
func NewBasicManagerFromManager(manager *Manager, customModuleBasics map[string]AppModuleBasic) BasicManager {
    moduleMap := make(map[string]AppModuleBasic)
    for name, module := range manager.Modules {
        if customBasicMod, ok := customModuleBasics[name]; ok {
            moduleMap[name] = customBasicMod
            continue
        }

        if appModule, ok := module.(appmodule.AppModule); ok {
            moduleMap[name] = CoreAppModuleBasicAdaptor(name, appModule)
            continue
        }

        if basicMod, ok := module.(AppModuleBasic); ok {
            moduleMap[name] = basicMod
        }
    }

    return moduleMap
}
UniDrills commented 4 weeks ago

to fix your trouble check this solution click maybe this will solve your problem.