94 lines
2.6 KiB
Go
94 lines
2.6 KiB
Go
package protocolpool
|
|
|
|
import (
|
|
modulev1 "cosmossdk.io/api/cosmos/protocolpool/module/v1"
|
|
"cosmossdk.io/core/appmodule"
|
|
"cosmossdk.io/depinject"
|
|
"cosmossdk.io/depinject/appconfig"
|
|
authtypes "cosmossdk.io/x/auth/types"
|
|
"cosmossdk.io/x/protocolpool/keeper"
|
|
"cosmossdk.io/x/protocolpool/simulation"
|
|
"cosmossdk.io/x/protocolpool/types"
|
|
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
|
"github.com/cosmos/cosmos-sdk/types/module"
|
|
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
|
|
)
|
|
|
|
var _ depinject.OnePerModuleType = AppModule{}
|
|
|
|
// IsOnePerModuleType implements the depinject.OnePerModuleType interface.
|
|
func (am AppModule) IsOnePerModuleType() {}
|
|
|
|
func init() {
|
|
appconfig.RegisterModule(
|
|
&modulev1.Module{},
|
|
appconfig.Provide(ProvideModule),
|
|
)
|
|
}
|
|
|
|
type ModuleInputs struct {
|
|
depinject.In
|
|
|
|
Config *modulev1.Module
|
|
Codec codec.Codec
|
|
Environment appmodule.Environment
|
|
|
|
AccountKeeper types.AccountKeeper
|
|
BankKeeper types.BankKeeper
|
|
StakingKeeper types.StakingKeeper
|
|
}
|
|
|
|
type ModuleOutputs struct {
|
|
depinject.Out
|
|
|
|
Keeper keeper.Keeper
|
|
Module appmodule.AppModule
|
|
}
|
|
|
|
func ProvideModule(in ModuleInputs) ModuleOutputs {
|
|
// default to governance authority if not provided
|
|
authority := authtypes.NewModuleAddress("gov")
|
|
if in.Config.Authority != "" {
|
|
authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority)
|
|
}
|
|
|
|
authorityAddr, err := in.AccountKeeper.AddressCodec().BytesToString(authority)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
k := keeper.NewKeeper(in.Codec, in.Environment, in.AccountKeeper, in.BankKeeper, in.StakingKeeper, authorityAddr)
|
|
m := NewAppModule(in.Codec, k, in.AccountKeeper, in.BankKeeper)
|
|
|
|
return ModuleOutputs{
|
|
Keeper: k,
|
|
Module: m,
|
|
}
|
|
}
|
|
|
|
// ____________________________________________________________________________
|
|
|
|
// AppModuleSimulation functions
|
|
|
|
// GenerateGenesisState creates a randomized GenState of the protocolpool module.
|
|
func (AppModule) GenerateGenesisState(simState *module.SimulationState) {
|
|
}
|
|
|
|
// RegisterStoreDecoder registers a decoder for protocolpool module's types
|
|
func (am AppModule) RegisterStoreDecoder(sdr simtypes.StoreDecoderRegistry) {
|
|
}
|
|
|
|
// ProposalMsgs returns all the protocolpool msgs used to simulate governance proposals.
|
|
func (AppModule) ProposalMsgs(simState module.SimulationState) []simtypes.WeightedProposalMsg {
|
|
return simulation.ProposalMsgs()
|
|
}
|
|
|
|
// WeightedOperations returns the all the protocolpool module operations with their respective weights.
|
|
func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation {
|
|
return simulation.WeightedOperations(
|
|
simState.AppParams, simState.Cdc, simState.TxConfig,
|
|
am.accountKeeper, am.bankKeeper, am.keeper,
|
|
)
|
|
}
|