laconicd/x/onboarding/module/depinject.go

60 lines
1.4 KiB
Go
Raw Permalink Normal View History

package module
import (
"cosmossdk.io/core/address"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/store"
"cosmossdk.io/depinject"
"github.com/cosmos/cosmos-sdk/codec"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
modulev1 "git.vdb.to/cerc-io/laconicd/api/cerc/onboarding/module/v1"
"git.vdb.to/cerc-io/laconicd/x/onboarding/keeper"
)
var _ appmodule.AppModule = AppModule{}
// IsOnePerModuleType implements the depinject.OnePerModuleType interface.
func (am AppModule) IsOnePerModuleType() {}
// IsAppModule implements the appmodule.AppModule interface.
func (am AppModule) IsAppModule() {}
func init() {
appmodule.Register(
&modulev1.Module{},
appmodule.Provide(ProvideModule),
)
}
type ModuleInputs struct {
depinject.In
Cdc codec.Codec
StoreService store.KVStoreService
AddressCodec address.Codec
Config *modulev1.Module
}
type ModuleOutputs struct {
depinject.Out
Module appmodule.AppModule
Keeper *keeper.Keeper
}
func ProvideModule(in ModuleInputs) ModuleOutputs {
// default to governance as authority if not provided
authority := authtypes.NewModuleAddress("gov")
if in.Config.Authority != "" {
authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority)
}
k := keeper.NewKeeper(in.Cdc, in.AddressCodec, in.StoreService, authority.String())
m := NewAppModule(in.Cdc, k)
return ModuleOutputs{Module: m, Keeper: k}
}