2024-02-09 08:44:45 +00:00
|
|
|
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"
|
2024-09-05 07:07:54 +00:00
|
|
|
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
2024-02-09 08:44:45 +00:00
|
|
|
bank "github.com/cosmos/cosmos-sdk/x/bank/keeper"
|
2024-09-05 07:07:54 +00:00
|
|
|
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
2024-02-09 08:44:45 +00:00
|
|
|
|
2024-04-01 09:57:26 +00:00
|
|
|
modulev1 "git.vdb.to/cerc-io/laconicd/api/cerc/auction/module/v1"
|
|
|
|
"git.vdb.to/cerc-io/laconicd/x/auction"
|
|
|
|
"git.vdb.to/cerc-io/laconicd/x/auction/keeper"
|
2024-02-09 08:44:45 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
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),
|
2024-02-28 04:34:58 +00:00
|
|
|
appmodule.Invoke(InvokeSetAuctionHooks),
|
2024-02-09 08:44:45 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
type ModuleInputs struct {
|
|
|
|
depinject.In
|
|
|
|
|
2024-09-05 07:07:54 +00:00
|
|
|
Config *modulev1.Module
|
2024-02-09 08:44:45 +00:00
|
|
|
Cdc codec.Codec
|
|
|
|
StoreService store.KVStoreService
|
|
|
|
|
|
|
|
AccountKeeper auth.AccountKeeper
|
|
|
|
BankKeeper bank.Keeper
|
|
|
|
}
|
|
|
|
|
|
|
|
type ModuleOutputs struct {
|
|
|
|
depinject.Out
|
|
|
|
|
2024-02-28 04:34:58 +00:00
|
|
|
// Use * as required by InvokeSetAuctionHooks
|
|
|
|
// https://github.com/cosmos/cosmos-sdk/tree/v0.50.3/core/appmodule#invoker-invocation-details
|
|
|
|
// https://github.com/cosmos/cosmos-sdk/tree/v0.50.3/core/appmodule#regular-golang-types
|
|
|
|
Keeper *keeper.Keeper
|
|
|
|
|
2024-02-09 08:44:45 +00:00
|
|
|
Module appmodule.AppModule
|
|
|
|
}
|
|
|
|
|
|
|
|
func ProvideModule(in ModuleInputs) ModuleOutputs {
|
2024-09-05 07:07:54 +00:00
|
|
|
// 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, authority.String())
|
2024-02-09 08:44:45 +00:00
|
|
|
m := NewAppModule(in.Cdc, k)
|
|
|
|
|
|
|
|
return ModuleOutputs{Module: m, Keeper: k}
|
|
|
|
}
|
2024-02-28 04:34:58 +00:00
|
|
|
|
|
|
|
func InvokeSetAuctionHooks(
|
|
|
|
config *modulev1.Module,
|
|
|
|
keeper *keeper.Keeper,
|
|
|
|
auctionHooks map[string]auction.AuctionHooksWrapper,
|
|
|
|
) error {
|
2024-07-11 05:16:31 +00:00
|
|
|
// All arguments to invokers are optional
|
2024-02-28 04:34:58 +00:00
|
|
|
if keeper == nil || config == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2024-07-11 05:16:31 +00:00
|
|
|
usageKeepers := make([]auction.AuctionUsageKeeper, 0, len(auctionHooks))
|
2024-02-28 04:34:58 +00:00
|
|
|
|
2024-07-11 05:16:31 +00:00
|
|
|
for _, hook := range auctionHooks {
|
2024-02-28 04:34:58 +00:00
|
|
|
usageKeepers = append(usageKeepers, hook)
|
|
|
|
}
|
|
|
|
|
|
|
|
keeper.SetUsageKeepers(usageKeepers)
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|