From 3708b33b7cfd285f59ab8b58c10e41870347e9c3 Mon Sep 17 00:00:00 2001 From: rustdev Date: Sat, 16 Dec 2023 20:31:09 +0000 Subject: [PATCH] introduce staking middleware prototype. --- .../stakingmiddleware/v1beta1/genesis.proto | 1 + .../stakingmiddleware/v1beta1/query.proto | 22 + .../stakingmiddleware/v1beta1/tx.proto | 28 + x/mint/keeper/keeper.go | 14 + x/stakingmiddleware/client/cli/query.go | 60 +++ x/stakingmiddleware/client/cli/tx.go | 23 + x/stakingmiddleware/keeper/genesis.go | 17 + x/stakingmiddleware/keeper/keeper.go | 101 ++++ x/stakingmiddleware/keeper/msg_server.go | 27 + x/stakingmiddleware/module.go | 161 ++++++ x/stakingmiddleware/types/genesis.go | 26 + x/stakingmiddleware/types/keys.go | 2 +- x/stakingmiddleware/types/query.pb.go | 481 +++++++++++++++++ x/stakingmiddleware/types/query.pb.gw.go | 153 ++++++ x/stakingmiddleware/types/tx.pb.go | 485 ++++++++++++++++++ 15 files changed, 1600 insertions(+), 1 deletion(-) create mode 100644 proto/centauri/stakingmiddleware/v1beta1/query.proto create mode 100644 proto/centauri/stakingmiddleware/v1beta1/tx.proto create mode 100644 x/stakingmiddleware/client/cli/query.go create mode 100644 x/stakingmiddleware/client/cli/tx.go create mode 100644 x/stakingmiddleware/keeper/genesis.go create mode 100644 x/stakingmiddleware/keeper/keeper.go create mode 100644 x/stakingmiddleware/keeper/msg_server.go create mode 100644 x/stakingmiddleware/module.go create mode 100644 x/stakingmiddleware/types/genesis.go create mode 100644 x/stakingmiddleware/types/query.pb.go create mode 100644 x/stakingmiddleware/types/query.pb.gw.go create mode 100644 x/stakingmiddleware/types/tx.pb.go diff --git a/proto/centauri/stakingmiddleware/v1beta1/genesis.proto b/proto/centauri/stakingmiddleware/v1beta1/genesis.proto index 84ddb87a0..2a5012761 100644 --- a/proto/centauri/stakingmiddleware/v1beta1/genesis.proto +++ b/proto/centauri/stakingmiddleware/v1beta1/genesis.proto @@ -3,6 +3,7 @@ package centauri.stakingmiddleware.v1beta1; import "gogoproto/gogo.proto"; + option go_package = "x/stakingmiddleware/types"; // GenesisState defines the stakingmiddleware module's genesis state. diff --git a/proto/centauri/stakingmiddleware/v1beta1/query.proto b/proto/centauri/stakingmiddleware/v1beta1/query.proto new file mode 100644 index 000000000..4c592f4b4 --- /dev/null +++ b/proto/centauri/stakingmiddleware/v1beta1/query.proto @@ -0,0 +1,22 @@ +syntax = "proto3"; +package centauri.stakingmiddleware.v1beta1; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; + +option go_package = "x/stakingmiddleware/types"; + +// Query provides defines the gRPC querier service. +service Query { + // Params returns the total set of minting parameters. + rpc Power(QueryPowerRequest) returns (QueryPowerResponse) { + option (google.api.http).get = "/cosmos/stakingmiddleware/v1beta1/params"; + } +} + +// QueryParamsRequest is the request type for the Query/Params RPC method. +message QueryPowerRequest {} + +// QueryParamsResponse is the response type for the Query/Params RPC method. +message QueryPowerResponse { +} diff --git a/proto/centauri/stakingmiddleware/v1beta1/tx.proto b/proto/centauri/stakingmiddleware/v1beta1/tx.proto new file mode 100644 index 000000000..e786842d5 --- /dev/null +++ b/proto/centauri/stakingmiddleware/v1beta1/tx.proto @@ -0,0 +1,28 @@ +syntax = "proto3"; +package centauri.stakingmiddleware.v1beta1; + +import "cosmos/msg/v1/msg.proto"; +import "amino/amino.proto"; +import "gogoproto/gogo.proto"; +import "cosmos_proto/cosmos.proto"; + +option go_package = "x/stakingmiddleware/types"; + +// Msg defines the x/stakingmiddleware Msg service. +service Msg { + option (cosmos.msg.v1.service) = true; + + rpc SetPower(MsgSetPower) returns (MsgSetPowerResponse); +} + +// MsgSetPower is the Msg/SetPower request type. +// +// Since: cosmos-sdk 0.47 +message MsgSetPower { +} + +// MsgSetPowerResponse defines the response structure for executing a +// MsgSetPower message. +// +// Since: cosmos-sdk 0.47 +message MsgSetPowerResponse {} diff --git a/x/mint/keeper/keeper.go b/x/mint/keeper/keeper.go index 0b9d0fa65..92cd73623 100644 --- a/x/mint/keeper/keeper.go +++ b/x/mint/keeper/keeper.go @@ -172,3 +172,17 @@ func (k Keeper) SetLastTotalPower(ctx sdk.Context, power math.Int) { bz := k.cdc.MustMarshal(&sdk.IntProto{Int: power}) store.Set(types.DelegationKey, bz) } + +func (k Keeper) GetLastTotalPower(ctx sdk.Context) math.Int { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.DelegationKey) + + if bz == nil { + return math.ZeroInt() + } + + ip := sdk.IntProto{} + k.cdc.MustUnmarshal(bz, &ip) + + return ip.Int +} diff --git a/x/stakingmiddleware/client/cli/query.go b/x/stakingmiddleware/client/cli/query.go new file mode 100644 index 000000000..a28e31fae --- /dev/null +++ b/x/stakingmiddleware/client/cli/query.go @@ -0,0 +1,60 @@ +package cli + +import ( + "fmt" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/notional-labs/composable/v6/x/stakingmiddleware/types" +) + +// GetQueryCmd returns the cli query commands for the staking middleware module. +func GetQueryCmd() *cobra.Command { + mintingQueryCmd := &cobra.Command{ + Use: types.ModuleName, + Short: "Querying commands for the minting module", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + mintingQueryCmd.AddCommand( + GetCmdQueryParams(), + ) + + return mintingQueryCmd +} + +// GetCmdQueryParams implements a command to return the current minting +// parameters. +func GetCmdQueryParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "params", + Short: "Query the current minting parameters", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryPowerRequest{} + res, err := queryClient.Power(cmd.Context(), params) + if err != nil { + return err + } + _ = res + + // return nil + return clientCtx.PrintString(fmt.Sprintf("%s\n", "hello world")) + // return clientCtx.PrintProto(&res.Power) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/stakingmiddleware/client/cli/tx.go b/x/stakingmiddleware/client/cli/tx.go new file mode 100644 index 000000000..caece5ee5 --- /dev/null +++ b/x/stakingmiddleware/client/cli/tx.go @@ -0,0 +1,23 @@ +package cli + +import ( + "github.com/cosmos/cosmos-sdk/client" + "github.com/spf13/cobra" + + "github.com/notional-labs/composable/v6/x/mint/types" +) + +// GetTxCmd returns the tx commands for mint +func GetTxCmd() *cobra.Command { + txCmd := &cobra.Command{ + Use: types.ModuleName, + Short: "Exp transaction subcommands", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + txCmd.AddCommand() + + return txCmd +} diff --git a/x/stakingmiddleware/keeper/genesis.go b/x/stakingmiddleware/keeper/genesis.go new file mode 100644 index 000000000..418884413 --- /dev/null +++ b/x/stakingmiddleware/keeper/genesis.go @@ -0,0 +1,17 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/notional-labs/composable/v6/x/stakingmiddleware/types" +) + +// InitGenesis new mint genesis +func (keeper Keeper) InitGenesis(ctx sdk.Context, data *types.GenesisState) { + keeper.SetLastTotalPower(ctx, data.LastTotalPower) +} + +// ExportGenesis returns a GenesisState for a given context and keeper. +func (keeper Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { + minter := keeper.GetLastTotalPower(ctx) + return types.NewGenesisState(minter) +} diff --git a/x/stakingmiddleware/keeper/keeper.go b/x/stakingmiddleware/keeper/keeper.go new file mode 100644 index 000000000..a1f1bb960 --- /dev/null +++ b/x/stakingmiddleware/keeper/keeper.go @@ -0,0 +1,101 @@ +package keeper + +import ( + "cosmossdk.io/math" + "github.com/cometbft/cometbft/libs/log" + "github.com/notional-labs/composable/v6/x/mint/types" + + "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + // "github.com/notional-labs/composable/v6/x/mint/types" +) + +// Keeper of the staking middleware store +type Keeper struct { + cdc codec.BinaryCodec + storeKey storetypes.StoreKey + // the address capable of executing a MsgUpdateParams message. Typically, this + // should be the x/gov module account. + authority string +} + +// NewKeeper creates a new middleware Keeper instance +func NewKeeper( + cdc codec.BinaryCodec, + key storetypes.StoreKey, + authority string, +) Keeper { + return Keeper{ + cdc: cdc, + storeKey: key, + authority: authority, + } +} + +// GetAuthority returns the x/mint module's authority. +func (k Keeper) GetAuthority() string { + return k.authority +} + +// Logger returns a module-specific logger. +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", "x/"+types.ModuleName) +} + +// // SetParams sets the x/mint module parameters. +// func (k Keeper) SetParams(ctx sdk.Context, p types.Params) error { +// if err := p.Validate(); err != nil { +// return err +// } + +// store := ctx.KVStore(k.storeKey) +// bz := k.cdc.MustMarshal(&p) +// store.Set(types.ParamsKey, bz) + +// return nil +// } + +// // GetParams returns the current x/mint module parameters. +// func (k Keeper) GetParams(ctx sdk.Context) (p types.Params) { +// store := ctx.KVStore(k.storeKey) +// bz := store.Get(types.ParamsKey) +// if bz == nil { +// return p +// } + +// k.cdc.MustUnmarshal(bz, &p) +// return p +// } + +// func (k Keeper) StoreDelegation(ctx sdk.Context, delegation stakingtypes.Delegation) { +// delegatorAddress := sdk.MustAccAddressFromBech32(delegation.DelegatorAddress) +// log := k.Logger(ctx) +// log.Info("StoreDelegation", "delegatorAddress", delegatorAddress, "validatorAddress", delegation.GetValidatorAddr()) +// store := ctx.KVStore(k.storeKey) +// b := stakingtypes.MustMarshalDelegation(k.cdc, delegation) +// kkk := types.GetDelegationKey(delegatorAddress, delegation.GetValidatorAddr()) +// // log.Info() +// store.Set(kkk, b) +// } + +// SetLastTotalPower Set the last total validator power. +func (k Keeper) SetLastTotalPower(ctx sdk.Context, power math.Int) { + store := ctx.KVStore(k.storeKey) + bz := k.cdc.MustMarshal(&sdk.IntProto{Int: power}) + store.Set(types.DelegationKey, bz) +} + +func (k Keeper) GetLastTotalPower(ctx sdk.Context) math.Int { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.DelegationKey) + + if bz == nil { + return math.ZeroInt() + } + + ip := sdk.IntProto{} + k.cdc.MustUnmarshal(bz, &ip) + + return ip.Int +} diff --git a/x/stakingmiddleware/keeper/msg_server.go b/x/stakingmiddleware/keeper/msg_server.go new file mode 100644 index 000000000..ba9dd395e --- /dev/null +++ b/x/stakingmiddleware/keeper/msg_server.go @@ -0,0 +1,27 @@ +package keeper + +import ( + "context" + + "github.com/notional-labs/composable/v6/x/stakingmiddleware/types" +) + +var _ types.MsgServer = msgServer{} + +// msgServer is a wrapper of Keeper. +type msgServer struct { + Keeper +} + +// NewMsgServerImpl returns an implementation of the x/mint MsgServer interface. +func NewMsgServerImpl(k Keeper) types.MsgServer { + return &msgServer{ + Keeper: k, + } +} + +// UpdateParams updates the params. +func (ms msgServer) SetPower(goCtx context.Context, req *types.MsgSetPower) (*types.MsgUpdateParamsResponse, error) { + + return &types.MsgSetPowerResponse{}, nil +} diff --git a/x/stakingmiddleware/module.go b/x/stakingmiddleware/module.go new file mode 100644 index 000000000..338f41f97 --- /dev/null +++ b/x/stakingmiddleware/module.go @@ -0,0 +1,161 @@ +package stakingmiddleware + +import ( + "encoding/json" + "fmt" + + abci "github.com/cometbft/cometbft/abci/types" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + + "github.com/notional-labs/composable/v6/x/mint/simulation" + "github.com/notional-labs/composable/v6/x/stakingmiddleware/client/cli" + "github.com/notional-labs/composable/v6/x/stakingmiddleware/keeper" + "github.com/notional-labs/composable/v6/x/stakingmiddleware/types" + middlewarestaking "github.com/notional-labs/composable/v6/x/stakingmiddleware/types" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} + _ module.AppModuleSimulation = AppModule{} +) + +// AppModuleBasic defines the basic application module used by the mint module. +type AppModuleBasic struct { + cdc codec.Codec +} + +var _ module.AppModuleBasic = AppModuleBasic{} + +// Name returns the mint module's name. +func (AppModuleBasic) Name() string { + return middlewarestaking.ModuleName +} + +// RegisterLegacyAminoCodec registers the mint module's types on the given LegacyAmino codec. +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + // types.RegisterLegacyAminoCodec(cdc) +} + +// RegisterInterfaces registers the module interface +func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { + // types.RegisterInterfaces(reg) +} + +// DefaultGenesis returns default genesis state as raw bytes for the mint +// module. +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesisState()) +} + +// ValidateGenesis performs genesis state validation for the mint module. +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage) error { + var data types.GenesisState + if err := cdc.UnmarshalJSON(bz, &data); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + + return types.ValidateGenesis(data) +} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the mint module. +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + // if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { + // panic(err) + // } +} + +// GetTxCmd returns no root tx command for the mint module. +func (AppModuleBasic) GetTxCmd() *cobra.Command { + return cli.GetTxCmd() +} + +// GetQueryCmd returns the root query command for the mint module. +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd() +} + +// AppModule implements an application module for the mint module. +type AppModule struct { + AppModuleBasic + + keeper keeper.Keeper +} + +// NewAppModule creates a new AppModule object. If the InflationCalculationFn +// argument is nil, then the SDK's default inflation function will be used. +func NewAppModule(cdc codec.Codec, keeper keeper.Keeper) AppModule { + return AppModule{ + AppModuleBasic: AppModuleBasic{cdc: cdc}, + keeper: keeper, + } +} + +// Name returns the mint module's name. +func (AppModule) Name() string { + return types.ModuleName +} + +// RegisterInvariants registers the mint module invariants. +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +// RegisterServices registers a gRPC query service to respond to the +// module-specific gRPC queries. +func (am AppModule) RegisterServices(cfg module.Configurator) { + // types.RegisterQueryServer(cfg.QueryServer(), am.keeper) + types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) +} + +// InitGenesis performs genesis initialization for the mint module. It returns +// no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { + var genesisState types.GenesisState + cdc.MustUnmarshalJSON(data, &genesisState) + + am.keeper.InitGenesis(ctx, &genesisState) + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the exported genesis state as raw bytes for the mint +// module. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + gs := am.keeper.ExportGenesis(ctx) + return cdc.MustMarshalJSON(gs) +} + +// ConsensusVersion implements AppModule/ConsensusVersion. +func (AppModule) ConsensusVersion() uint64 { return 1 } + +// BeginBlock returns the begin blocker for the mint module. +func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { + // BeginBlocker(ctx, am.keeper) ??? +} + +// AppModuleSimulation functions +// GenerateGenesisState creates a randomized GenState of the mint module. +func (AppModule) GenerateGenesisState(simState *module.SimulationState) { + simulation.RandomizedGenState(simState) +} + +// ProposalContents doesn't return any content functions for governance proposals. +func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalMsg { + return nil +} + +// RegisterStoreDecoder registers a decoder for mint module's types. +func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { + sdr[types.StoreKey] = simulation.NewDecodeStore(am.cdc) +} + +// WeightedOperations doesn't return any mint module operation. +func (AppModule) WeightedOperations(_ module.SimulationState) []simtypes.WeightedOperation { + return nil +} diff --git a/x/stakingmiddleware/types/genesis.go b/x/stakingmiddleware/types/genesis.go new file mode 100644 index 000000000..3830da245 --- /dev/null +++ b/x/stakingmiddleware/types/genesis.go @@ -0,0 +1,26 @@ +package types + +import ( + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// NewGenesisState creates a new GenesisState object +func NewGenesisState(m math.Int) *GenesisState { + return &GenesisState{ + LastTotalPower: m, + } +} + +// DefaultGenesisState creates a default GenesisState object +func DefaultGenesisState() *GenesisState { + return &GenesisState{ + LastTotalPower: sdk.ZeroInt(), + } +} + +// ValidateGenesis validates the provided genesis state to ensure the +// expected invariants holds. +func ValidateGenesis(data GenesisState) error { + return nil +} diff --git a/x/stakingmiddleware/types/keys.go b/x/stakingmiddleware/types/keys.go index 9f760fcf5..52c0cfd8b 100644 --- a/x/stakingmiddleware/types/keys.go +++ b/x/stakingmiddleware/types/keys.go @@ -12,7 +12,7 @@ var ( const ( // module name - ModuleName = "mint" + ModuleName = "customstaking" // StoreKey is the default store key for mint StoreKey = ModuleName diff --git a/x/stakingmiddleware/types/query.pb.go b/x/stakingmiddleware/types/query.pb.go new file mode 100644 index 000000000..4314b7bbe --- /dev/null +++ b/x/stakingmiddleware/types/query.pb.go @@ -0,0 +1,481 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: centauri/stakingmiddleware/v1beta1/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// QueryParamsRequest is the request type for the Query/Params RPC method. +type QueryPowerRequest struct { +} + +func (m *QueryPowerRequest) Reset() { *m = QueryPowerRequest{} } +func (m *QueryPowerRequest) String() string { return proto.CompactTextString(m) } +func (*QueryPowerRequest) ProtoMessage() {} +func (*QueryPowerRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_81a7c3c637f3f95a, []int{0} +} +func (m *QueryPowerRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryPowerRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPowerRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryPowerRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPowerRequest.Merge(m, src) +} +func (m *QueryPowerRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryPowerRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPowerRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryPowerRequest proto.InternalMessageInfo + +// QueryParamsResponse is the response type for the Query/Params RPC method. +type QueryPowerResponse struct { +} + +func (m *QueryPowerResponse) Reset() { *m = QueryPowerResponse{} } +func (m *QueryPowerResponse) String() string { return proto.CompactTextString(m) } +func (*QueryPowerResponse) ProtoMessage() {} +func (*QueryPowerResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_81a7c3c637f3f95a, []int{1} +} +func (m *QueryPowerResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryPowerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPowerResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryPowerResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPowerResponse.Merge(m, src) +} +func (m *QueryPowerResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryPowerResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPowerResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryPowerResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*QueryPowerRequest)(nil), "centauri.stakingmiddleware.v1beta1.QueryPowerRequest") + proto.RegisterType((*QueryPowerResponse)(nil), "centauri.stakingmiddleware.v1beta1.QueryPowerResponse") +} + +func init() { + proto.RegisterFile("centauri/stakingmiddleware/v1beta1/query.proto", fileDescriptor_81a7c3c637f3f95a) +} + +var fileDescriptor_81a7c3c637f3f95a = []byte{ + // 250 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x4b, 0x4e, 0xcd, 0x2b, + 0x49, 0x2c, 0x2d, 0xca, 0xd4, 0x2f, 0x2e, 0x49, 0xcc, 0xce, 0xcc, 0x4b, 0xcf, 0xcd, 0x4c, 0x49, + 0xc9, 0x49, 0x2d, 0x4f, 0x2c, 0x4a, 0xd5, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x2f, + 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x52, 0x82, 0xa9, 0xd7, 0xc3, + 0x50, 0xaf, 0x07, 0x55, 0x2f, 0x25, 0x92, 0x9e, 0x9f, 0x9e, 0x0f, 0x56, 0xae, 0x0f, 0x62, 0x41, + 0x74, 0x4a, 0xc9, 0xa4, 0xe7, 0xe7, 0xa7, 0xe7, 0xa4, 0xea, 0x27, 0x16, 0x64, 0xea, 0x27, 0xe6, + 0xe5, 0xe5, 0x97, 0x24, 0x96, 0x64, 0xe6, 0xe7, 0x15, 0x43, 0x64, 0x95, 0x84, 0xb9, 0x04, 0x03, + 0x41, 0xd6, 0x04, 0xe4, 0x97, 0xa7, 0x16, 0x05, 0xa5, 0x16, 0x96, 0xa6, 0x16, 0x97, 0x28, 0x89, + 0x70, 0x09, 0x21, 0x0b, 0x16, 0x17, 0xe4, 0xe7, 0x15, 0xa7, 0x1a, 0x6d, 0x62, 0xe4, 0x62, 0x05, + 0x0b, 0x0b, 0xad, 0x60, 0xe4, 0x62, 0x05, 0xcb, 0x09, 0x99, 0xea, 0x11, 0x76, 0x97, 0x1e, 0x86, + 0x05, 0x52, 0x66, 0xa4, 0x6a, 0x83, 0x38, 0x41, 0xc9, 0xa0, 0xe9, 0xf2, 0x93, 0xc9, 0x4c, 0x5a, + 0x42, 0x1a, 0xfa, 0xc9, 0xf9, 0xc5, 0xb9, 0xf9, 0xc5, 0x78, 0x02, 0xaf, 0x20, 0xb1, 0x28, 0x31, + 0xb7, 0xd8, 0xc9, 0xf8, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, + 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x24, 0x2b, + 0xb0, 0xe8, 0x2e, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, 0x62, 0x03, 0x87, 0x8d, 0x31, 0x20, 0x00, 0x00, + 0xff, 0xff, 0x00, 0x00, 0x72, 0xbe, 0xa5, 0x01, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // Params returns the total set of minting parameters. + Power(ctx context.Context, in *QueryPowerRequest, opts ...grpc.CallOption) (*QueryPowerResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Power(ctx context.Context, in *QueryPowerRequest, opts ...grpc.CallOption) (*QueryPowerResponse, error) { + out := new(QueryPowerResponse) + err := c.cc.Invoke(ctx, "/centauri.stakingmiddleware.v1beta1.Query/Power", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // Params returns the total set of minting parameters. + Power(context.Context, *QueryPowerRequest) (*QueryPowerResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Power(ctx context.Context, req *QueryPowerRequest) (*QueryPowerResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Power not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_Power_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryPowerRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Power(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/centauri.stakingmiddleware.v1beta1.Query/Power", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Power(ctx, req.(*QueryPowerRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "centauri.stakingmiddleware.v1beta1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Power", + Handler: _Query_Power_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "centauri/stakingmiddleware/v1beta1/query.proto", +} + +func (m *QueryPowerRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryPowerRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryPowerRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryPowerResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryPowerResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryPowerResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryPowerRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryPowerResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryPowerRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryPowerRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPowerRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryPowerResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryPowerResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPowerResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/stakingmiddleware/types/query.pb.gw.go b/x/stakingmiddleware/types/query.pb.gw.go new file mode 100644 index 000000000..fdb182ad2 --- /dev/null +++ b/x/stakingmiddleware/types/query.pb.gw.go @@ -0,0 +1,153 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: centauri/stakingmiddleware/v1beta1/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +func request_Query_Power_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPowerRequest + var metadata runtime.ServerMetadata + + msg, err := client.Power(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Power_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPowerRequest + var metadata runtime.ServerMetadata + + msg, err := server.Power(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_Power_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Power_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Power_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_Power_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Power_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Power_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_Power_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmos", "stakingmiddleware", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_Power_0 = runtime.ForwardResponseMessage +) diff --git a/x/stakingmiddleware/types/tx.pb.go b/x/stakingmiddleware/types/tx.pb.go new file mode 100644 index 000000000..946e01caf --- /dev/null +++ b/x/stakingmiddleware/types/tx.pb.go @@ -0,0 +1,485 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: centauri/stakingmiddleware/v1beta1/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// MsgSetPower is the Msg/SetPower request type. +// +// Since: cosmos-sdk 0.47 +type MsgSetPower struct { +} + +func (m *MsgSetPower) Reset() { *m = MsgSetPower{} } +func (m *MsgSetPower) String() string { return proto.CompactTextString(m) } +func (*MsgSetPower) ProtoMessage() {} +func (*MsgSetPower) Descriptor() ([]byte, []int) { + return fileDescriptor_d15665ac9877b062, []int{0} +} +func (m *MsgSetPower) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSetPower) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSetPower.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgSetPower) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetPower.Merge(m, src) +} +func (m *MsgSetPower) XXX_Size() int { + return m.Size() +} +func (m *MsgSetPower) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetPower.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSetPower proto.InternalMessageInfo + +// MsgSetPowerResponse defines the response structure for executing a +// MsgSetPower message. +// +// Since: cosmos-sdk 0.47 +type MsgSetPowerResponse struct { +} + +func (m *MsgSetPowerResponse) Reset() { *m = MsgSetPowerResponse{} } +func (m *MsgSetPowerResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSetPowerResponse) ProtoMessage() {} +func (*MsgSetPowerResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d15665ac9877b062, []int{1} +} +func (m *MsgSetPowerResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSetPowerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSetPowerResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgSetPowerResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetPowerResponse.Merge(m, src) +} +func (m *MsgSetPowerResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgSetPowerResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetPowerResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSetPowerResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgSetPower)(nil), "centauri.stakingmiddleware.v1beta1.MsgSetPower") + proto.RegisterType((*MsgSetPowerResponse)(nil), "centauri.stakingmiddleware.v1beta1.MsgSetPowerResponse") +} + +func init() { + proto.RegisterFile("centauri/stakingmiddleware/v1beta1/tx.proto", fileDescriptor_d15665ac9877b062) +} + +var fileDescriptor_d15665ac9877b062 = []byte{ + // 239 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x4e, 0x4e, 0xcd, 0x2b, + 0x49, 0x2c, 0x2d, 0xca, 0xd4, 0x2f, 0x2e, 0x49, 0xcc, 0xce, 0xcc, 0x4b, 0xcf, 0xcd, 0x4c, 0x49, + 0xc9, 0x49, 0x2d, 0x4f, 0x2c, 0x4a, 0xd5, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x2f, + 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x52, 0x82, 0x29, 0xd6, 0xc3, 0x50, 0xac, 0x07, + 0x55, 0x2c, 0x25, 0x9e, 0x9c, 0x5f, 0x9c, 0x9b, 0x5f, 0xac, 0x9f, 0x5b, 0x9c, 0xae, 0x5f, 0x66, + 0x08, 0xa2, 0x20, 0x9a, 0xa5, 0x04, 0x13, 0x73, 0x33, 0xf3, 0xf2, 0xf5, 0xc1, 0x24, 0x54, 0x48, + 0x24, 0x3d, 0x3f, 0x3d, 0x1f, 0xcc, 0xd4, 0x07, 0xb1, 0xa0, 0xa2, 0x92, 0x10, 0x13, 0xe2, 0x21, + 0x12, 0x10, 0x0e, 0x44, 0x4a, 0x89, 0x97, 0x8b, 0xdb, 0xb7, 0x38, 0x3d, 0x38, 0xb5, 0x24, 0x20, + 0xbf, 0x3c, 0xb5, 0x48, 0x49, 0x94, 0x4b, 0x18, 0x89, 0x1b, 0x94, 0x5a, 0x5c, 0x90, 0x9f, 0x57, + 0x9c, 0x6a, 0xd4, 0xc4, 0xc8, 0xc5, 0xec, 0x5b, 0x9c, 0x2e, 0x54, 0xc2, 0xc5, 0x01, 0x93, 0x13, + 0xd2, 0xd7, 0x23, 0xec, 0x76, 0x3d, 0x24, 0xc3, 0xa4, 0xcc, 0x49, 0xd4, 0x00, 0xb3, 0x5d, 0x8a, + 0xb5, 0xe1, 0xf9, 0x06, 0x2d, 0x46, 0x27, 0xe3, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, + 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, + 0x63, 0x88, 0x92, 0xac, 0xc0, 0x12, 0xd6, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0x60, 0x6f, + 0x1a, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0xc3, 0x77, 0x72, 0xdb, 0x96, 0x01, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { + SetPower(ctx context.Context, in *MsgSetPower, opts ...grpc.CallOption) (*MsgSetPowerResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) SetPower(ctx context.Context, in *MsgSetPower, opts ...grpc.CallOption) (*MsgSetPowerResponse, error) { + out := new(MsgSetPowerResponse) + err := c.cc.Invoke(ctx, "/centauri.stakingmiddleware.v1beta1.Msg/SetPower", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + SetPower(context.Context, *MsgSetPower) (*MsgSetPowerResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) SetPower(ctx context.Context, req *MsgSetPower) (*MsgSetPowerResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SetPower not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_SetPower_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSetPower) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).SetPower(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/centauri.stakingmiddleware.v1beta1.Msg/SetPower", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).SetPower(ctx, req.(*MsgSetPower)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "centauri.stakingmiddleware.v1beta1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "SetPower", + Handler: _Msg_SetPower_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "centauri/stakingmiddleware/v1beta1/tx.proto", +} + +func (m *MsgSetPower) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgSetPower) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSetPower) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgSetPowerResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgSetPowerResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSetPowerResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgSetPower) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgSetPowerResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgSetPower) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgSetPower: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSetPower: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgSetPowerResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgSetPowerResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSetPowerResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTx(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +)