91 lines
2.8 KiB
Go
91 lines
2.8 KiB
Go
package params
|
|
|
|
import (
|
|
"context"
|
|
|
|
gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime"
|
|
|
|
"cosmossdk.io/core/appmodule"
|
|
"cosmossdk.io/x/params/keeper"
|
|
"cosmossdk.io/x/params/types/proposal"
|
|
|
|
"github.com/cosmos/cosmos-sdk/client"
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
|
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
|
"github.com/cosmos/cosmos-sdk/types/module"
|
|
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
|
|
)
|
|
|
|
var (
|
|
_ module.AppModuleBasic = AppModule{}
|
|
_ module.AppModuleSimulation = AppModule{}
|
|
_ module.HasServices = AppModule{}
|
|
|
|
_ appmodule.AppModule = AppModule{}
|
|
)
|
|
|
|
// ConsensusVersion defines the current x/params module consensus version.
|
|
const ConsensusVersion = 1
|
|
|
|
// AppModuleBasic defines the basic application module used by the params module.
|
|
type AppModuleBasic struct{}
|
|
|
|
// Name returns the params module's name.
|
|
func (AppModuleBasic) Name() string {
|
|
return proposal.ModuleName
|
|
}
|
|
|
|
// RegisterLegacyAminoCodec registers the params module's types on the given LegacyAmino codec.
|
|
func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
|
|
proposal.RegisterLegacyAminoCodec(cdc)
|
|
}
|
|
|
|
// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the params module.
|
|
func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwruntime.ServeMux) {
|
|
if err := proposal.RegisterQueryHandlerClient(context.Background(), mux, proposal.NewQueryClient(clientCtx)); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
func (am AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) {
|
|
proposal.RegisterInterfaces(registry)
|
|
}
|
|
|
|
// AppModule implements an application module for the distribution module.
|
|
type AppModule struct {
|
|
AppModuleBasic
|
|
|
|
keeper keeper.Keeper
|
|
}
|
|
|
|
// NewAppModule creates a new AppModule object
|
|
func NewAppModule(k keeper.Keeper) AppModule {
|
|
return AppModule{
|
|
AppModuleBasic: AppModuleBasic{},
|
|
keeper: k,
|
|
}
|
|
}
|
|
|
|
// IsAppModule implements the appmodule.AppModule interface.
|
|
func (am AppModule) IsAppModule() {}
|
|
|
|
// GenerateGenesisState performs a no-op.
|
|
func (AppModule) GenerateGenesisState(simState *module.SimulationState) {}
|
|
|
|
// RegisterServices registers a gRPC query service to respond to the
|
|
// module-specific gRPC queries.
|
|
func (am AppModule) RegisterServices(cfg module.Configurator) {
|
|
proposal.RegisterQueryServer(cfg.QueryServer(), am.keeper)
|
|
}
|
|
|
|
// RegisterStoreDecoder doesn't register any type.
|
|
func (AppModule) RegisterStoreDecoder(sdr simtypes.StoreDecoderRegistry) {}
|
|
|
|
// WeightedOperations returns the all the gov module operations with their respective weights.
|
|
func (am AppModule) WeightedOperations(_ module.SimulationState) []simtypes.WeightedOperation {
|
|
return nil
|
|
}
|
|
|
|
// ConsensusVersion implements AppModule/ConsensusVersion.
|
|
func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion }
|