laconicd/x/registry/module/depinject.go

86 lines
2.2 KiB
Go
Raw Permalink Normal View History

package module
import (
"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/store"
"cosmossdk.io/depinject"
"github.com/cosmos/cosmos-sdk/codec"
auth "github.com/cosmos/cosmos-sdk/x/auth/keeper"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
bank "github.com/cosmos/cosmos-sdk/x/bank/keeper"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
modulev1 "git.vdb.to/cerc-io/laconicd/api/cerc/registry/module/v1"
"git.vdb.to/cerc-io/laconicd/x/auction"
auctionkeeper "git.vdb.to/cerc-io/laconicd/x/auction/keeper"
"git.vdb.to/cerc-io/laconicd/x/bond"
bondkeeper "git.vdb.to/cerc-io/laconicd/x/bond/keeper"
"git.vdb.to/cerc-io/laconicd/x/registry/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
Config *modulev1.Module
Cdc codec.Codec
StoreService store.KVStoreService
AccountKeeper auth.AccountKeeper
BankKeeper bank.Keeper
BondKeeper *bondkeeper.Keeper
AuctionKeeper *auctionkeeper.Keeper
}
type ModuleOutputs struct {
depinject.Out
Keeper keeper.Keeper
Module appmodule.AppModule
AuctionHooks auction.AuctionHooksWrapper
BondHooks bond.BondHooksWrapper
}
func ProvideModule(in ModuleInputs) ModuleOutputs {
// default to governance authority if not provided
authority := authtypes.NewModuleAddress(govtypes.ModuleName)
if in.Config.Authority != "" {
authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority)
}
k := keeper.NewKeeper(
in.Cdc,
in.StoreService,
in.AccountKeeper,
in.BankKeeper,
in.BondKeeper,
in.AuctionKeeper,
authority.String(),
)
m := NewAppModule(in.Cdc, k)
recordKeeper := keeper.NewRecordKeeper(in.Cdc, &k, in.AuctionKeeper)
return ModuleOutputs{
Module: m, Keeper: k,
AuctionHooks: auction.AuctionHooksWrapper{AuctionUsageKeeper: recordKeeper},
BondHooks: bond.BondHooksWrapper{BondUsageKeeper: recordKeeper},
}
}