2019-05-16 08:25:32 -07:00
|
|
|
package params
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
2019-12-05 01:29:54 -08:00
|
|
|
"math/rand"
|
2019-05-16 08:25:32 -07:00
|
|
|
|
2020-06-06 00:59:57 -07:00
|
|
|
"github.com/gogo/protobuf/grpc"
|
|
|
|
|
2019-06-05 16:26:17 -07:00
|
|
|
"github.com/gorilla/mux"
|
|
|
|
"github.com/spf13/cobra"
|
2020-04-16 09:22:58 -07:00
|
|
|
abci "github.com/tendermint/tendermint/abci/types"
|
2019-06-05 16:26:17 -07:00
|
|
|
|
2020-06-01 05:46:03 -07:00
|
|
|
"github.com/cosmos/cosmos-sdk/client"
|
2019-05-16 08:25:32 -07:00
|
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
2020-06-01 05:46:03 -07:00
|
|
|
"github.com/cosmos/cosmos-sdk/codec/types"
|
2019-12-05 01:29:54 -08:00
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
2019-06-05 16:26:17 -07:00
|
|
|
"github.com/cosmos/cosmos-sdk/types/module"
|
2020-03-23 04:55:44 -07:00
|
|
|
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
|
2019-12-05 01:29:54 -08:00
|
|
|
"github.com/cosmos/cosmos-sdk/x/params/simulation"
|
2020-02-19 03:52:20 -08:00
|
|
|
"github.com/cosmos/cosmos-sdk/x/params/types/proposal"
|
2019-05-16 08:25:32 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2020-04-16 09:22:58 -07:00
|
|
|
_ module.AppModule = AppModule{}
|
2019-12-05 01:29:54 -08:00
|
|
|
_ module.AppModuleBasic = AppModuleBasic{}
|
|
|
|
_ module.AppModuleSimulation = AppModule{}
|
2020-05-19 13:17:29 -07:00
|
|
|
_ module.InterfaceModule = AppModuleBasic{}
|
2019-05-16 08:25:32 -07:00
|
|
|
)
|
|
|
|
|
2019-08-13 15:16:03 -07:00
|
|
|
// AppModuleBasic defines the basic application module used by the params module.
|
2019-05-16 08:25:32 -07:00
|
|
|
type AppModuleBasic struct{}
|
|
|
|
|
2019-08-13 15:16:03 -07:00
|
|
|
// Name returns the params module's name.
|
2019-05-16 08:25:32 -07:00
|
|
|
func (AppModuleBasic) Name() string {
|
2020-02-19 03:52:20 -08:00
|
|
|
return proposal.ModuleName
|
2019-05-16 08:25:32 -07:00
|
|
|
}
|
|
|
|
|
2019-08-13 15:16:03 -07:00
|
|
|
// RegisterCodec registers the params module's types for the given codec.
|
2019-05-16 08:25:32 -07:00
|
|
|
func (AppModuleBasic) RegisterCodec(cdc *codec.Codec) {
|
2020-02-19 03:52:20 -08:00
|
|
|
proposal.RegisterCodec(cdc)
|
2019-05-16 08:25:32 -07:00
|
|
|
}
|
|
|
|
|
2019-08-13 15:16:03 -07:00
|
|
|
// DefaultGenesis returns default genesis state as raw bytes for the params
|
|
|
|
// module.
|
2020-02-18 04:50:13 -08:00
|
|
|
func (AppModuleBasic) DefaultGenesis(_ codec.JSONMarshaler) json.RawMessage { return nil }
|
2019-05-16 08:25:32 -07:00
|
|
|
|
2019-08-13 15:16:03 -07:00
|
|
|
// ValidateGenesis performs genesis state validation for the params module.
|
2020-02-18 04:50:13 -08:00
|
|
|
func (AppModuleBasic) ValidateGenesis(_ codec.JSONMarshaler, _ json.RawMessage) error { return nil }
|
2019-06-05 16:26:17 -07:00
|
|
|
|
2019-08-13 15:16:03 -07:00
|
|
|
// RegisterRESTRoutes registers the REST routes for the params module.
|
2020-06-01 05:46:03 -07:00
|
|
|
func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {}
|
2019-06-05 16:26:17 -07:00
|
|
|
|
2019-08-13 15:16:03 -07:00
|
|
|
// GetTxCmd returns no root tx command for the params module.
|
2020-06-01 05:46:03 -07:00
|
|
|
func (AppModuleBasic) GetTxCmd(_ client.Context) *cobra.Command { return nil }
|
2019-06-05 16:26:17 -07:00
|
|
|
|
2019-08-13 15:16:03 -07:00
|
|
|
// GetQueryCmd returns no root query command for the params module.
|
2020-06-03 13:15:11 -07:00
|
|
|
func (AppModuleBasic) GetQueryCmd(clientCtx client.Context) *cobra.Command { return nil }
|
2019-12-05 01:29:54 -08:00
|
|
|
|
2020-05-19 13:17:29 -07:00
|
|
|
func (am AppModuleBasic) RegisterInterfaceTypes(registry types.InterfaceRegistry) {
|
|
|
|
proposal.RegisterInterfaces(registry)
|
|
|
|
}
|
|
|
|
|
2019-12-05 01:29:54 -08:00
|
|
|
//____________________________________________________________________________
|
|
|
|
|
|
|
|
// AppModule implements an application module for the distribution module.
|
|
|
|
type AppModule struct {
|
|
|
|
AppModuleBasic
|
2020-04-16 09:22:58 -07:00
|
|
|
|
|
|
|
keeper Keeper
|
2019-12-05 01:29:54 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewAppModule creates a new AppModule object
|
2020-04-16 09:22:58 -07:00
|
|
|
func NewAppModule(k Keeper) AppModule {
|
2019-12-05 01:29:54 -08:00
|
|
|
return AppModule{
|
|
|
|
AppModuleBasic: AppModuleBasic{},
|
2020-04-16 09:22:58 -07:00
|
|
|
keeper: k,
|
2019-12-05 01:29:54 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-16 09:22:58 -07:00
|
|
|
func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {}
|
2019-12-05 01:29:54 -08:00
|
|
|
|
2020-04-16 09:22:58 -07:00
|
|
|
// InitGenesis performs a no-op.
|
|
|
|
func (am AppModule) InitGenesis(_ sdk.Context, _ codec.JSONMarshaler, _ json.RawMessage) []abci.ValidatorUpdate {
|
|
|
|
return []abci.ValidatorUpdate{}
|
|
|
|
}
|
|
|
|
|
2020-06-11 08:37:23 -07:00
|
|
|
func (AppModule) Route() sdk.Route { return sdk.Route{} }
|
2019-12-05 01:29:54 -08:00
|
|
|
|
|
|
|
// GenerateGenesisState performs a no-op.
|
2020-04-16 09:22:58 -07:00
|
|
|
func (AppModule) GenerateGenesisState(simState *module.SimulationState) {}
|
|
|
|
|
|
|
|
// QuerierRoute returns the x/param module's querier route name.
|
|
|
|
func (AppModule) QuerierRoute() string { return QuerierRoute }
|
|
|
|
|
|
|
|
// NewQuerierHandler returns the x/params querier handler.
|
|
|
|
func (am AppModule) NewQuerierHandler() sdk.Querier {
|
|
|
|
return NewQuerier(am.keeper)
|
2019-12-05 01:29:54 -08:00
|
|
|
}
|
|
|
|
|
2020-06-06 00:59:57 -07:00
|
|
|
func (am AppModule) RegisterQueryService(grpc.Server) {}
|
|
|
|
|
2019-12-05 01:29:54 -08:00
|
|
|
// ProposalContents returns all the params content functions used to
|
|
|
|
// simulate governance proposals.
|
2020-03-23 04:55:44 -07:00
|
|
|
func (am AppModule) ProposalContents(simState module.SimulationState) []simtypes.WeightedProposalContent {
|
2019-12-05 01:29:54 -08:00
|
|
|
return simulation.ProposalContents(simState.ParamChanges)
|
|
|
|
}
|
|
|
|
|
|
|
|
// RandomizedParams creates randomized distribution param changes for the simulator.
|
2020-03-23 04:55:44 -07:00
|
|
|
func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange {
|
2019-12-05 01:29:54 -08:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// RegisterStoreDecoder doesn't register any type.
|
|
|
|
func (AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) {}
|
|
|
|
|
|
|
|
// WeightedOperations returns the all the gov module operations with their respective weights.
|
2020-03-23 04:55:44 -07:00
|
|
|
func (am AppModule) WeightedOperations(_ module.SimulationState) []simtypes.WeightedOperation {
|
2019-12-05 01:29:54 -08:00
|
|
|
return nil
|
|
|
|
}
|
2020-04-16 09:22:58 -07:00
|
|
|
|
|
|
|
// ExportGenesis performs a no-op.
|
|
|
|
func (am AppModule) ExportGenesis(_ sdk.Context, _ codec.JSONMarshaler) json.RawMessage {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// BeginBlock performs a no-op.
|
|
|
|
func (AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {}
|
|
|
|
|
|
|
|
// EndBlock performs a no-op.
|
|
|
|
func (AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate {
|
|
|
|
return []abci.ValidatorUpdate{}
|
|
|
|
}
|