Refactor x/{gov, crisis} according to ADR 031 (#7533)
* Refactor x/gov according to ADR 31 * fix tests * Refactor x/crisis according to ADR 031 * fix lint * lint * lint * review changes * lint * review change * fic doc Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
parent
69e2b7df16
commit
6e569e1255
@ -5,6 +5,12 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/crisis/types";
|
||||
|
||||
import "gogoproto/gogo.proto";
|
||||
|
||||
// Msg defines the bank Msg service.
|
||||
service Msg {
|
||||
// VerifyInvariant defines a method to verify a particular invariance.
|
||||
rpc VerifyInvariant(MsgVerifyInvariant) returns (MsgVerifyInvariantResponse);
|
||||
}
|
||||
|
||||
// MsgVerifyInvariant represents a message to verify a particular invariance.
|
||||
message MsgVerifyInvariant {
|
||||
option (gogoproto.equal) = false;
|
||||
@ -14,3 +20,6 @@ message MsgVerifyInvariant {
|
||||
string invariant_module_name = 2 [(gogoproto.moretags) = "yaml:\"invariant_module_name\""];
|
||||
string invariant_route = 3 [(gogoproto.moretags) = "yaml:\"invariant_route\""];
|
||||
}
|
||||
|
||||
// MsgVerifyInvariantResponse defines the Msg/VerifyInvariant response type.
|
||||
message MsgVerifyInvariantResponse { }
|
||||
|
||||
@ -8,14 +8,26 @@ import "gogoproto/gogo.proto";
|
||||
import "google/protobuf/any.proto";
|
||||
|
||||
option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types";
|
||||
option (gogoproto.goproto_stringer_all) = false;
|
||||
option (gogoproto.stringer_all) = false;
|
||||
option (gogoproto.goproto_getters_all) = false;
|
||||
|
||||
// Msg defines the bank Msg service.
|
||||
service Msg {
|
||||
// SubmitProposal defines a method to create new proposal given a content.
|
||||
rpc SubmitProposal(MsgSubmitProposal) returns (MsgSubmitProposalResponse);
|
||||
|
||||
// Vote defines a method to add a vote on a specific proposal.
|
||||
rpc Vote(MsgVote) returns (MsgVoteResponse);
|
||||
|
||||
// Deposit defines a method to add deposit on a specific proposal.
|
||||
rpc Deposit(MsgDeposit) returns (MsgDepositResponse);
|
||||
}
|
||||
|
||||
// MsgSubmitProposal defines an sdk.Msg type that supports submitting arbitrary
|
||||
// proposal Content.
|
||||
message MsgSubmitProposal {
|
||||
option (gogoproto.equal) = false;
|
||||
option (gogoproto.goproto_stringer) = false;
|
||||
option (gogoproto.stringer) = false;
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
|
||||
google.protobuf.Any content = 1 [(cosmos_proto.accepts_interface) = "Content"];
|
||||
repeated cosmos.base.v1beta1.Coin initial_deposit = 2 [
|
||||
@ -26,21 +38,38 @@ message MsgSubmitProposal {
|
||||
string proposer = 3;
|
||||
}
|
||||
|
||||
// MsgSubmitProposalResponse defines the Msg/SubmitProposal response type.
|
||||
message MsgSubmitProposalResponse {
|
||||
uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (gogoproto.moretags) = "yaml:\"proposal_id\""];
|
||||
}
|
||||
|
||||
// MsgVote defines a message to cast a vote.
|
||||
message MsgVote {
|
||||
option (gogoproto.equal) = false;
|
||||
option (gogoproto.goproto_stringer) = false;
|
||||
option (gogoproto.stringer) = false;
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
|
||||
uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (gogoproto.moretags) = "yaml:\"proposal_id\""];
|
||||
string voter = 2;
|
||||
VoteOption option = 3;
|
||||
}
|
||||
|
||||
// MsgVoteResponse defines the Msg/Vote response type.
|
||||
message MsgVoteResponse {}
|
||||
|
||||
// MsgDeposit defines a message to submit a deposit to an existing proposal.
|
||||
message MsgDeposit {
|
||||
option (gogoproto.equal) = false;
|
||||
option (gogoproto.goproto_stringer) = false;
|
||||
option (gogoproto.stringer) = false;
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
|
||||
uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (gogoproto.moretags) = "yaml:\"proposal_id\""];
|
||||
string depositor = 2;
|
||||
repeated cosmos.base.v1beta1.Coin amount = 3
|
||||
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
|
||||
}
|
||||
}
|
||||
|
||||
// MsgDepositResponse defines the Msg/Deposit response type.
|
||||
message MsgDepositResponse {}
|
||||
|
||||
@ -3,90 +3,23 @@ package crisis
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/cosmos/cosmos-sdk/x/crisis/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/crisis/types"
|
||||
)
|
||||
|
||||
// RouterKey
|
||||
const RouterKey = types.ModuleName
|
||||
|
||||
func NewHandler(k keeper.Keeper) sdk.Handler {
|
||||
func NewHandler(k types.MsgServer) sdk.Handler {
|
||||
return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) {
|
||||
ctx = ctx.WithEventManager(sdk.NewEventManager())
|
||||
|
||||
switch msg := msg.(type) {
|
||||
case *types.MsgVerifyInvariant:
|
||||
return handleMsgVerifyInvariant(ctx, msg, k)
|
||||
res, err := k.VerifyInvariant(sdk.WrapSDKContext(ctx), msg)
|
||||
return sdk.WrapServiceResult(ctx, res, err)
|
||||
|
||||
default:
|
||||
return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized crisis message type: %T", msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func handleMsgVerifyInvariant(ctx sdk.Context, msg *types.MsgVerifyInvariant, k keeper.Keeper) (*sdk.Result, error) {
|
||||
constantFee := sdk.NewCoins(k.GetConstantFee(ctx))
|
||||
|
||||
sender, err := sdk.AccAddressFromBech32(msg.Sender)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := k.SendCoinsFromAccountToFeeCollector(ctx, sender, constantFee); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// use a cached context to avoid gas costs during invariants
|
||||
cacheCtx, _ := ctx.CacheContext()
|
||||
|
||||
found := false
|
||||
msgFullRoute := msg.FullInvariantRoute()
|
||||
|
||||
var res string
|
||||
var stop bool
|
||||
for _, invarRoute := range k.Routes() {
|
||||
if invarRoute.FullRoute() == msgFullRoute {
|
||||
res, stop = invarRoute.Invar(cacheCtx)
|
||||
found = true
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if !found {
|
||||
return nil, types.ErrUnknownInvariant
|
||||
}
|
||||
|
||||
if stop {
|
||||
// NOTE currently, because the chain halts here, this transaction will never be included
|
||||
// in the blockchain thus the constant fee will have never been deducted. Thus no
|
||||
// refund is required.
|
||||
|
||||
// TODO uncomment the following code block with implementation of the circuit breaker
|
||||
//// refund constant fee
|
||||
//err := k.distrKeeper.DistributeFromFeePool(ctx, constantFee, msg.Sender)
|
||||
//if err != nil {
|
||||
//// if there are insufficient coins to refund, log the error,
|
||||
//// but still halt the chain.
|
||||
//logger := ctx.Logger().With("module", "x/crisis")
|
||||
//logger.Error(fmt.Sprintf(
|
||||
//"WARNING: insufficient funds to allocate to sender from fee pool, err: %s", err))
|
||||
//}
|
||||
|
||||
// TODO replace with circuit breaker
|
||||
panic(res)
|
||||
}
|
||||
|
||||
ctx.EventManager().EmitEvents(sdk.Events{
|
||||
sdk.NewEvent(
|
||||
types.EventTypeInvariant,
|
||||
sdk.NewAttribute(types.AttributeKeyRoute, msg.InvariantRoute),
|
||||
),
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCrisis),
|
||||
sdk.NewAttribute(sdk.AttributeKeySender, msg.Sender),
|
||||
),
|
||||
})
|
||||
|
||||
return &sdk.Result{Events: ctx.EventManager().ABCIEvents()}, nil
|
||||
}
|
||||
|
||||
78
x/crisis/keeper/msg_server.go
Normal file
78
x/crisis/keeper/msg_server.go
Normal file
@ -0,0 +1,78 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/crisis/types"
|
||||
)
|
||||
|
||||
var _ types.MsgServer = Keeper{}
|
||||
|
||||
func (k Keeper) VerifyInvariant(goCtx context.Context, msg *types.MsgVerifyInvariant) (*types.MsgVerifyInvariantResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
constantFee := sdk.NewCoins(k.GetConstantFee(ctx))
|
||||
|
||||
sender, err := sdk.AccAddressFromBech32(msg.Sender)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := k.SendCoinsFromAccountToFeeCollector(ctx, sender, constantFee); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// use a cached context to avoid gas costs during invariants
|
||||
cacheCtx, _ := ctx.CacheContext()
|
||||
|
||||
found := false
|
||||
msgFullRoute := msg.FullInvariantRoute()
|
||||
|
||||
var res string
|
||||
var stop bool
|
||||
for _, invarRoute := range k.Routes() {
|
||||
if invarRoute.FullRoute() == msgFullRoute {
|
||||
res, stop = invarRoute.Invar(cacheCtx)
|
||||
found = true
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if !found {
|
||||
return nil, types.ErrUnknownInvariant
|
||||
}
|
||||
|
||||
if stop {
|
||||
// NOTE currently, because the chain halts here, this transaction will never be included
|
||||
// in the blockchain thus the constant fee will have never been deducted. Thus no
|
||||
// refund is required.
|
||||
|
||||
// TODO uncomment the following code block with implementation of the circuit breaker
|
||||
//// refund constant fee
|
||||
//err := k.distrKeeper.DistributeFromFeePool(ctx, constantFee, msg.Sender)
|
||||
//if err != nil {
|
||||
//// if there are insufficient coins to refund, log the error,
|
||||
//// but still halt the chain.
|
||||
//logger := ctx.Logger().With("module", "x/crisis")
|
||||
//logger.Error(fmt.Sprintf(
|
||||
//"WARNING: insufficient funds to allocate to sender from fee pool, err: %s", err))
|
||||
//}
|
||||
|
||||
// TODO replace with circuit breaker
|
||||
panic(res)
|
||||
}
|
||||
|
||||
ctx.EventManager().EmitEvents(sdk.Events{
|
||||
sdk.NewEvent(
|
||||
types.EventTypeInvariant,
|
||||
sdk.NewAttribute(types.AttributeKeyRoute, msg.InvariantRoute),
|
||||
),
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCrisis),
|
||||
sdk.NewAttribute(sdk.AttributeKeySender, msg.Sender),
|
||||
),
|
||||
})
|
||||
|
||||
return &types.MsgVerifyInvariantResponse{}, nil
|
||||
}
|
||||
@ -4,9 +4,14 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
context "context"
|
||||
fmt "fmt"
|
||||
_ "github.com/gogo/protobuf/gogoproto"
|
||||
grpc1 "github.com/gogo/protobuf/grpc"
|
||||
proto "github.com/gogo/protobuf/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"
|
||||
@ -63,14 +68,52 @@ func (m *MsgVerifyInvariant) XXX_DiscardUnknown() {
|
||||
|
||||
var xxx_messageInfo_MsgVerifyInvariant proto.InternalMessageInfo
|
||||
|
||||
// MsgVerifyInvariantResponse defines the Msg/VerifyInvariant response type.
|
||||
type MsgVerifyInvariantResponse struct {
|
||||
}
|
||||
|
||||
func (m *MsgVerifyInvariantResponse) Reset() { *m = MsgVerifyInvariantResponse{} }
|
||||
func (m *MsgVerifyInvariantResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*MsgVerifyInvariantResponse) ProtoMessage() {}
|
||||
func (*MsgVerifyInvariantResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_61276163172fe867, []int{1}
|
||||
}
|
||||
func (m *MsgVerifyInvariantResponse) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *MsgVerifyInvariantResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_MsgVerifyInvariantResponse.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 *MsgVerifyInvariantResponse) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_MsgVerifyInvariantResponse.Merge(m, src)
|
||||
}
|
||||
func (m *MsgVerifyInvariantResponse) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *MsgVerifyInvariantResponse) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_MsgVerifyInvariantResponse.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_MsgVerifyInvariantResponse proto.InternalMessageInfo
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*MsgVerifyInvariant)(nil), "cosmos.crisis.v1beta1.MsgVerifyInvariant")
|
||||
proto.RegisterType((*MsgVerifyInvariantResponse)(nil), "cosmos.crisis.v1beta1.MsgVerifyInvariantResponse")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("cosmos/crisis/v1beta1/tx.proto", fileDescriptor_61276163172fe867) }
|
||||
|
||||
var fileDescriptor_61276163172fe867 = []byte{
|
||||
// 276 bytes of a gzipped FileDescriptorProto
|
||||
// 318 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4b, 0xce, 0x2f, 0xce,
|
||||
0xcd, 0x2f, 0xd6, 0x4f, 0x2e, 0xca, 0x2c, 0xce, 0x2c, 0xd6, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49,
|
||||
0x34, 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x85, 0xc8, 0xeb, 0x41,
|
||||
@ -83,12 +126,96 @@ var fileDescriptor_61276163172fe867 = []byte{
|
||||
0x94, 0x82, 0x84, 0xe1, 0xe2, 0xbe, 0x60, 0x61, 0xbf, 0xc4, 0xdc, 0x54, 0x21, 0x67, 0x2e, 0x7e,
|
||||
0x84, 0xf2, 0xa2, 0xfc, 0xd2, 0x92, 0x54, 0x09, 0x66, 0xb0, 0x79, 0x52, 0x9f, 0xee, 0xc9, 0x8b,
|
||||
0xa1, 0x9b, 0x07, 0x56, 0xa0, 0x14, 0xc4, 0x07, 0x17, 0x09, 0x02, 0x09, 0x58, 0x71, 0x74, 0x2c,
|
||||
0x90, 0x67, 0x78, 0xb1, 0x40, 0x9e, 0xc1, 0xc9, 0xf5, 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, 0xb4, 0xd3, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x61,
|
||||
0xa1, 0x08, 0xa6, 0x74, 0x8b, 0x53, 0xb2, 0xf5, 0x2b, 0x60, 0x41, 0x5a, 0x52, 0x59, 0x90, 0x5a,
|
||||
0x9c, 0xc4, 0x06, 0x0e, 0x21, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x29, 0x57, 0x7a, 0x12,
|
||||
0x70, 0x01, 0x00, 0x00,
|
||||
0x90, 0x67, 0x78, 0xb1, 0x40, 0x9e, 0x41, 0x49, 0x86, 0x4b, 0x0a, 0xd3, 0x4b, 0x41, 0xa9, 0xc5,
|
||||
0x05, 0xf9, 0x79, 0xc5, 0xa9, 0x46, 0x65, 0x5c, 0xcc, 0xbe, 0xc5, 0xe9, 0x42, 0xf9, 0x5c, 0xfc,
|
||||
0xe8, 0x9e, 0xd6, 0xd4, 0xc3, 0x1a, 0x72, 0x7a, 0x98, 0x86, 0x49, 0x19, 0x12, 0xad, 0x14, 0x66,
|
||||
0xaf, 0x93, 0xeb, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38,
|
||||
0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x69, 0xa7, 0x67,
|
||||
0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0xc3, 0xe2, 0x16, 0x4c, 0xe9, 0x16, 0xa7,
|
||||
0x64, 0xeb, 0x57, 0xc0, 0x22, 0xba, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0x1c, 0x6f, 0xc6,
|
||||
0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x9c, 0x60, 0x68, 0x5a, 0x06, 0x02, 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 {
|
||||
// VerifyInvariant defines a method to verify a particular invariance.
|
||||
VerifyInvariant(ctx context.Context, in *MsgVerifyInvariant, opts ...grpc.CallOption) (*MsgVerifyInvariantResponse, error)
|
||||
}
|
||||
|
||||
type msgClient struct {
|
||||
cc grpc1.ClientConn
|
||||
}
|
||||
|
||||
func NewMsgClient(cc grpc1.ClientConn) MsgClient {
|
||||
return &msgClient{cc}
|
||||
}
|
||||
|
||||
func (c *msgClient) VerifyInvariant(ctx context.Context, in *MsgVerifyInvariant, opts ...grpc.CallOption) (*MsgVerifyInvariantResponse, error) {
|
||||
out := new(MsgVerifyInvariantResponse)
|
||||
err := c.cc.Invoke(ctx, "/cosmos.crisis.v1beta1.Msg/VerifyInvariant", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// MsgServer is the server API for Msg service.
|
||||
type MsgServer interface {
|
||||
// VerifyInvariant defines a method to verify a particular invariance.
|
||||
VerifyInvariant(context.Context, *MsgVerifyInvariant) (*MsgVerifyInvariantResponse, error)
|
||||
}
|
||||
|
||||
// UnimplementedMsgServer can be embedded to have forward compatible implementations.
|
||||
type UnimplementedMsgServer struct {
|
||||
}
|
||||
|
||||
func (*UnimplementedMsgServer) VerifyInvariant(ctx context.Context, req *MsgVerifyInvariant) (*MsgVerifyInvariantResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method VerifyInvariant not implemented")
|
||||
}
|
||||
|
||||
func RegisterMsgServer(s grpc1.Server, srv MsgServer) {
|
||||
s.RegisterService(&_Msg_serviceDesc, srv)
|
||||
}
|
||||
|
||||
func _Msg_VerifyInvariant_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(MsgVerifyInvariant)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(MsgServer).VerifyInvariant(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/cosmos.crisis.v1beta1.Msg/VerifyInvariant",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MsgServer).VerifyInvariant(ctx, req.(*MsgVerifyInvariant))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
var _Msg_serviceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "cosmos.crisis.v1beta1.Msg",
|
||||
HandlerType: (*MsgServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "VerifyInvariant",
|
||||
Handler: _Msg_VerifyInvariant_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "cosmos/crisis/v1beta1/tx.proto",
|
||||
}
|
||||
|
||||
func (m *MsgVerifyInvariant) Marshal() (dAtA []byte, err error) {
|
||||
@ -135,6 +262,29 @@ func (m *MsgVerifyInvariant) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *MsgVerifyInvariantResponse) 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 *MsgVerifyInvariantResponse) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *MsgVerifyInvariantResponse) 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
|
||||
@ -167,6 +317,15 @@ func (m *MsgVerifyInvariant) Size() (n int) {
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *MsgVerifyInvariantResponse) 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
|
||||
}
|
||||
@ -322,6 +481,59 @@ func (m *MsgVerifyInvariant) Unmarshal(dAtA []byte) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *MsgVerifyInvariantResponse) 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: MsgVerifyInvariantResponse: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: MsgVerifyInvariantResponse: 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 {
|
||||
return ErrInvalidLengthTx
|
||||
}
|
||||
if (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
|
||||
|
||||
@ -4,6 +4,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/stretchr/testify/require"
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||
@ -172,7 +173,11 @@ func TestTickPassedDepositPeriod(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, res)
|
||||
|
||||
proposalID := types.GetProposalIDFromBytes(res.Data)
|
||||
var proposalData types.MsgSubmitProposalResponse
|
||||
err = proto.Unmarshal(res.Data, &proposalData)
|
||||
require.NoError(t, err)
|
||||
|
||||
proposalID := proposalData.ProposalId
|
||||
|
||||
inactiveQueue = app.GovKeeper.InactiveProposalQueueIterator(ctx, ctx.BlockHeader().Time)
|
||||
require.False(t, inactiveQueue.Valid())
|
||||
@ -224,7 +229,11 @@ func TestTickPassedVotingPeriod(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, res)
|
||||
|
||||
proposalID := types.GetProposalIDFromBytes(res.Data)
|
||||
var proposalData types.MsgSubmitProposalResponse
|
||||
err = proto.Unmarshal(res.Data, &proposalData)
|
||||
require.NoError(t, err)
|
||||
|
||||
proposalID := proposalData.ProposalId
|
||||
|
||||
newHeader := ctx.BlockHeader()
|
||||
newHeader.Time = ctx.BlockHeader().Time.Add(time.Duration(1) * time.Second)
|
||||
|
||||
124
x/gov/handler.go
124
x/gov/handler.go
@ -1,12 +1,6 @@
|
||||
package gov
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
metrics "github.com/armon/go-metrics"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/telemetry"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov/keeper"
|
||||
@ -14,125 +8,27 @@ import (
|
||||
)
|
||||
|
||||
// NewHandler creates an sdk.Handler for all the gov type messages
|
||||
func NewHandler(keeper keeper.Keeper) sdk.Handler {
|
||||
func NewHandler(k keeper.Keeper) sdk.Handler {
|
||||
msgServer := keeper.NewMsgServerImpl(k)
|
||||
|
||||
return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) {
|
||||
ctx = ctx.WithEventManager(sdk.NewEventManager())
|
||||
|
||||
switch msg := msg.(type) {
|
||||
case *types.MsgDeposit:
|
||||
return handleMsgDeposit(ctx, keeper, msg)
|
||||
res, err := msgServer.Deposit(sdk.WrapSDKContext(ctx), msg)
|
||||
return sdk.WrapServiceResult(ctx, res, err)
|
||||
|
||||
case types.MsgSubmitProposalI:
|
||||
return handleMsgSubmitProposal(ctx, keeper, msg)
|
||||
case *types.MsgSubmitProposal:
|
||||
res, err := msgServer.SubmitProposal(sdk.WrapSDKContext(ctx), msg)
|
||||
return sdk.WrapServiceResult(ctx, res, err)
|
||||
|
||||
case *types.MsgVote:
|
||||
return handleMsgVote(ctx, keeper, msg)
|
||||
res, err := msgServer.Vote(sdk.WrapSDKContext(ctx), msg)
|
||||
return sdk.WrapServiceResult(ctx, res, err)
|
||||
|
||||
default:
|
||||
return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized %s message type: %T", types.ModuleName, msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func handleMsgSubmitProposal(ctx sdk.Context, keeper keeper.Keeper, msg types.MsgSubmitProposalI) (*sdk.Result, error) {
|
||||
proposal, err := keeper.SubmitProposal(ctx, msg.GetContent())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
defer telemetry.IncrCounter(1, types.ModuleName, "proposal")
|
||||
|
||||
votingStarted, err := keeper.AddDeposit(ctx, proposal.ProposalId, msg.GetProposer(), msg.GetInitialDeposit())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ctx.EventManager().EmitEvent(
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
sdk.NewAttribute(sdk.AttributeKeySender, msg.GetProposer().String()),
|
||||
),
|
||||
)
|
||||
|
||||
submitEvent := sdk.NewEvent(types.EventTypeSubmitProposal, sdk.NewAttribute(types.AttributeKeyProposalType, msg.GetContent().ProposalType()))
|
||||
if votingStarted {
|
||||
submitEvent = submitEvent.AppendAttributes(
|
||||
sdk.NewAttribute(types.AttributeKeyVotingPeriodStart, fmt.Sprintf("%d", proposal.ProposalId)),
|
||||
)
|
||||
}
|
||||
|
||||
ctx.EventManager().EmitEvent(submitEvent)
|
||||
|
||||
return &sdk.Result{
|
||||
Data: types.GetProposalIDBytes(proposal.ProposalId),
|
||||
Events: ctx.EventManager().ABCIEvents(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func handleMsgDeposit(ctx sdk.Context, keeper keeper.Keeper, msg *types.MsgDeposit) (*sdk.Result, error) {
|
||||
accAddr, err := sdk.AccAddressFromBech32(msg.Depositor)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
votingStarted, err := keeper.AddDeposit(ctx, msg.ProposalId, accAddr, msg.Amount)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
defer telemetry.IncrCounterWithLabels(
|
||||
[]string{types.ModuleName, "deposit"},
|
||||
1,
|
||||
[]metrics.Label{
|
||||
telemetry.NewLabel("proposal_id", strconv.Itoa(int(msg.ProposalId))),
|
||||
},
|
||||
)
|
||||
|
||||
ctx.EventManager().EmitEvent(
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
sdk.NewAttribute(sdk.AttributeKeySender, msg.Depositor),
|
||||
),
|
||||
)
|
||||
|
||||
if votingStarted {
|
||||
ctx.EventManager().EmitEvent(
|
||||
sdk.NewEvent(
|
||||
types.EventTypeProposalDeposit,
|
||||
sdk.NewAttribute(types.AttributeKeyVotingPeriodStart, fmt.Sprintf("%d", msg.ProposalId)),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
return &sdk.Result{Events: ctx.EventManager().ABCIEvents()}, nil
|
||||
}
|
||||
|
||||
func handleMsgVote(ctx sdk.Context, keeper keeper.Keeper, msg *types.MsgVote) (*sdk.Result, error) {
|
||||
accAddr, accErr := sdk.AccAddressFromBech32(msg.Voter)
|
||||
if accErr != nil {
|
||||
return nil, accErr
|
||||
}
|
||||
err := keeper.AddVote(ctx, msg.ProposalId, accAddr, msg.Option)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
defer telemetry.IncrCounterWithLabels(
|
||||
[]string{types.ModuleName, "vote"},
|
||||
1,
|
||||
[]metrics.Label{
|
||||
telemetry.NewLabel("proposal_id", strconv.Itoa(int(msg.ProposalId))),
|
||||
},
|
||||
)
|
||||
|
||||
ctx.EventManager().EmitEvent(
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
sdk.NewAttribute(sdk.AttributeKeySender, msg.Voter),
|
||||
),
|
||||
)
|
||||
|
||||
return &sdk.Result{Events: ctx.EventManager().ABCIEvents()}, nil
|
||||
}
|
||||
|
||||
128
x/gov/keeper/msg_server.go
Normal file
128
x/gov/keeper/msg_server.go
Normal file
@ -0,0 +1,128 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/armon/go-metrics"
|
||||
"github.com/cosmos/cosmos-sdk/telemetry"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
)
|
||||
|
||||
type msgServer struct {
|
||||
Keeper
|
||||
}
|
||||
|
||||
// NewMsgServerImpl returns an implementation of the gov MsgServer interface
|
||||
// for the provided Keeper.
|
||||
func NewMsgServerImpl(keeper Keeper) types.MsgServer {
|
||||
return &msgServer{Keeper: keeper}
|
||||
}
|
||||
|
||||
var _ types.MsgServer = msgServer{}
|
||||
|
||||
func (k msgServer) SubmitProposal(goCtx context.Context, msg *types.MsgSubmitProposal) (*types.MsgSubmitProposalResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
proposal, err := k.Keeper.SubmitProposal(ctx, msg.GetContent())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
defer telemetry.IncrCounter(1, types.ModuleName, "proposal")
|
||||
|
||||
votingStarted, err := k.Keeper.AddDeposit(ctx, proposal.ProposalId, msg.GetProposer(), msg.GetInitialDeposit())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ctx.EventManager().EmitEvent(
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
sdk.NewAttribute(sdk.AttributeKeySender, msg.GetProposer().String()),
|
||||
),
|
||||
)
|
||||
|
||||
submitEvent := sdk.NewEvent(types.EventTypeSubmitProposal, sdk.NewAttribute(types.AttributeKeyProposalType, msg.GetContent().ProposalType()))
|
||||
if votingStarted {
|
||||
submitEvent = submitEvent.AppendAttributes(
|
||||
sdk.NewAttribute(types.AttributeKeyVotingPeriodStart, fmt.Sprintf("%d", proposal.ProposalId)),
|
||||
)
|
||||
}
|
||||
|
||||
ctx.EventManager().EmitEvent(submitEvent)
|
||||
return &types.MsgSubmitProposalResponse{
|
||||
ProposalId: proposal.ProposalId,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (k msgServer) Vote(goCtx context.Context, msg *types.MsgVote) (*types.MsgVoteResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
accAddr, accErr := sdk.AccAddressFromBech32(msg.Voter)
|
||||
if accErr != nil {
|
||||
return nil, accErr
|
||||
}
|
||||
err := k.Keeper.AddVote(ctx, msg.ProposalId, accAddr, msg.Option)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
defer telemetry.IncrCounterWithLabels(
|
||||
[]string{types.ModuleName, "vote"},
|
||||
1,
|
||||
[]metrics.Label{
|
||||
telemetry.NewLabel("proposal_id", strconv.Itoa(int(msg.ProposalId))),
|
||||
},
|
||||
)
|
||||
|
||||
ctx.EventManager().EmitEvent(
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
sdk.NewAttribute(sdk.AttributeKeySender, msg.Voter),
|
||||
),
|
||||
)
|
||||
|
||||
return &types.MsgVoteResponse{}, nil
|
||||
}
|
||||
|
||||
func (k msgServer) Deposit(goCtx context.Context, msg *types.MsgDeposit) (*types.MsgDepositResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
accAddr, err := sdk.AccAddressFromBech32(msg.Depositor)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
votingStarted, err := k.Keeper.AddDeposit(ctx, msg.ProposalId, accAddr, msg.Amount)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
defer telemetry.IncrCounterWithLabels(
|
||||
[]string{types.ModuleName, "deposit"},
|
||||
1,
|
||||
[]metrics.Label{
|
||||
telemetry.NewLabel("proposal_id", strconv.Itoa(int(msg.ProposalId))),
|
||||
},
|
||||
)
|
||||
|
||||
ctx.EventManager().EmitEvent(
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
sdk.NewAttribute(sdk.AttributeKeySender, msg.Depositor),
|
||||
),
|
||||
)
|
||||
|
||||
if votingStarted {
|
||||
ctx.EventManager().EmitEvent(
|
||||
sdk.NewEvent(
|
||||
types.EventTypeProposalDeposit,
|
||||
sdk.NewAttribute(types.AttributeKeyVotingPeriodStart, fmt.Sprintf("%d", msg.ProposalId)),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
return &types.MsgDepositResponse{}, nil
|
||||
}
|
||||
@ -21,26 +21,9 @@ const (
|
||||
|
||||
var (
|
||||
_, _, _ sdk.Msg = &MsgSubmitProposal{}, &MsgDeposit{}, &MsgVote{}
|
||||
_ MsgSubmitProposalI = &MsgSubmitProposal{}
|
||||
_ types.UnpackInterfacesMessage = &MsgSubmitProposal{}
|
||||
)
|
||||
|
||||
// MsgSubmitProposalI defines the specific interface a concrete message must
|
||||
// implement in order to process governance proposals. The concrete MsgSubmitProposal
|
||||
// must be defined at the application-level.
|
||||
type MsgSubmitProposalI interface {
|
||||
sdk.Msg
|
||||
|
||||
GetContent() Content
|
||||
SetContent(Content) error
|
||||
|
||||
GetInitialDeposit() sdk.Coins
|
||||
SetInitialDeposit(sdk.Coins)
|
||||
|
||||
GetProposer() sdk.AccAddress
|
||||
SetProposer(sdk.AccAddress)
|
||||
}
|
||||
|
||||
// NewMsgSubmitProposal creates a new MsgSubmitProposal.
|
||||
//nolint:interfacer
|
||||
func NewMsgSubmitProposal(content Content, initialDeposit sdk.Coins, proposer sdk.AccAddress) (*MsgSubmitProposal, error) {
|
||||
@ -74,7 +57,7 @@ func (m *MsgSubmitProposal) SetInitialDeposit(coins sdk.Coins) {
|
||||
m.InitialDeposit = coins
|
||||
}
|
||||
|
||||
func (m *MsgSubmitProposal) SetProposer(address sdk.AccAddress) {
|
||||
func (m *MsgSubmitProposal) SetProposer(address fmt.Stringer) {
|
||||
m.Proposer = address.String()
|
||||
}
|
||||
|
||||
|
||||
@ -4,13 +4,18 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
context "context"
|
||||
fmt "fmt"
|
||||
types "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
grpc1 "github.com/gogo/protobuf/grpc"
|
||||
github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types"
|
||||
types1 "github.com/cosmos/cosmos-sdk/types"
|
||||
_ "github.com/gogo/protobuf/gogoproto"
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
_ "github.com/regen-network/cosmos-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"
|
||||
@ -67,6 +72,51 @@ func (m *MsgSubmitProposal) XXX_DiscardUnknown() {
|
||||
|
||||
var xxx_messageInfo_MsgSubmitProposal proto.InternalMessageInfo
|
||||
|
||||
// MsgSubmitProposalResponse defines the Msg/SubmitProposal response type.
|
||||
type MsgSubmitProposalResponse struct {
|
||||
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id" yaml:"proposal_id"`
|
||||
}
|
||||
|
||||
func (m *MsgSubmitProposalResponse) Reset() { *m = MsgSubmitProposalResponse{} }
|
||||
func (m *MsgSubmitProposalResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*MsgSubmitProposalResponse) ProtoMessage() {}
|
||||
func (*MsgSubmitProposalResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_3c053992595e3dce, []int{1}
|
||||
}
|
||||
func (m *MsgSubmitProposalResponse) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *MsgSubmitProposalResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_MsgSubmitProposalResponse.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 *MsgSubmitProposalResponse) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_MsgSubmitProposalResponse.Merge(m, src)
|
||||
}
|
||||
func (m *MsgSubmitProposalResponse) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *MsgSubmitProposalResponse) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_MsgSubmitProposalResponse.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_MsgSubmitProposalResponse proto.InternalMessageInfo
|
||||
|
||||
func (m *MsgSubmitProposalResponse) GetProposalId() uint64 {
|
||||
if m != nil {
|
||||
return m.ProposalId
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// MsgVote defines a message to cast a vote.
|
||||
type MsgVote struct {
|
||||
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id" yaml:"proposal_id"`
|
||||
@ -77,7 +127,7 @@ type MsgVote struct {
|
||||
func (m *MsgVote) Reset() { *m = MsgVote{} }
|
||||
func (*MsgVote) ProtoMessage() {}
|
||||
func (*MsgVote) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_3c053992595e3dce, []int{1}
|
||||
return fileDescriptor_3c053992595e3dce, []int{2}
|
||||
}
|
||||
func (m *MsgVote) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
@ -106,6 +156,43 @@ func (m *MsgVote) XXX_DiscardUnknown() {
|
||||
|
||||
var xxx_messageInfo_MsgVote proto.InternalMessageInfo
|
||||
|
||||
// MsgVoteResponse defines the Msg/Vote response type.
|
||||
type MsgVoteResponse struct {
|
||||
}
|
||||
|
||||
func (m *MsgVoteResponse) Reset() { *m = MsgVoteResponse{} }
|
||||
func (m *MsgVoteResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*MsgVoteResponse) ProtoMessage() {}
|
||||
func (*MsgVoteResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_3c053992595e3dce, []int{3}
|
||||
}
|
||||
func (m *MsgVoteResponse) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *MsgVoteResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_MsgVoteResponse.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 *MsgVoteResponse) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_MsgVoteResponse.Merge(m, src)
|
||||
}
|
||||
func (m *MsgVoteResponse) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *MsgVoteResponse) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_MsgVoteResponse.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_MsgVoteResponse proto.InternalMessageInfo
|
||||
|
||||
// MsgDeposit defines a message to submit a deposit to an existing proposal.
|
||||
type MsgDeposit struct {
|
||||
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id" yaml:"proposal_id"`
|
||||
@ -116,7 +203,7 @@ type MsgDeposit struct {
|
||||
func (m *MsgDeposit) Reset() { *m = MsgDeposit{} }
|
||||
func (*MsgDeposit) ProtoMessage() {}
|
||||
func (*MsgDeposit) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_3c053992595e3dce, []int{2}
|
||||
return fileDescriptor_3c053992595e3dce, []int{4}
|
||||
}
|
||||
func (m *MsgDeposit) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
@ -145,48 +232,251 @@ func (m *MsgDeposit) XXX_DiscardUnknown() {
|
||||
|
||||
var xxx_messageInfo_MsgDeposit proto.InternalMessageInfo
|
||||
|
||||
// MsgDepositResponse defines the Msg/Deposit response type.
|
||||
type MsgDepositResponse struct {
|
||||
}
|
||||
|
||||
func (m *MsgDepositResponse) Reset() { *m = MsgDepositResponse{} }
|
||||
func (m *MsgDepositResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*MsgDepositResponse) ProtoMessage() {}
|
||||
func (*MsgDepositResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_3c053992595e3dce, []int{5}
|
||||
}
|
||||
func (m *MsgDepositResponse) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *MsgDepositResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_MsgDepositResponse.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 *MsgDepositResponse) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_MsgDepositResponse.Merge(m, src)
|
||||
}
|
||||
func (m *MsgDepositResponse) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *MsgDepositResponse) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_MsgDepositResponse.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_MsgDepositResponse proto.InternalMessageInfo
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*MsgSubmitProposal)(nil), "cosmos.gov.v1beta1.MsgSubmitProposal")
|
||||
proto.RegisterType((*MsgSubmitProposalResponse)(nil), "cosmos.gov.v1beta1.MsgSubmitProposalResponse")
|
||||
proto.RegisterType((*MsgVote)(nil), "cosmos.gov.v1beta1.MsgVote")
|
||||
proto.RegisterType((*MsgVoteResponse)(nil), "cosmos.gov.v1beta1.MsgVoteResponse")
|
||||
proto.RegisterType((*MsgDeposit)(nil), "cosmos.gov.v1beta1.MsgDeposit")
|
||||
proto.RegisterType((*MsgDepositResponse)(nil), "cosmos.gov.v1beta1.MsgDepositResponse")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("cosmos/gov/v1beta1/tx.proto", fileDescriptor_3c053992595e3dce) }
|
||||
|
||||
var fileDescriptor_3c053992595e3dce = []byte{
|
||||
// 498 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x53, 0x31, 0x8b, 0x13, 0x41,
|
||||
0x14, 0xde, 0x4d, 0xce, 0xc4, 0x9b, 0xc0, 0x89, 0x43, 0x90, 0x5c, 0x3c, 0x66, 0xc3, 0x82, 0x90,
|
||||
0xe6, 0x66, 0xbd, 0x08, 0x16, 0x67, 0x65, 0x4e, 0x04, 0x85, 0xa8, 0xac, 0x60, 0x61, 0x13, 0x76,
|
||||
0x37, 0xeb, 0x38, 0x98, 0x9d, 0xb7, 0x64, 0x26, 0xe1, 0xd2, 0x09, 0xf6, 0xe2, 0x4f, 0xb0, 0xb1,
|
||||
0xb1, 0xf6, 0x47, 0x04, 0xab, 0x2b, 0xaf, 0x31, 0x7a, 0x49, 0x23, 0x96, 0xf7, 0x0b, 0x64, 0x67,
|
||||
0x66, 0xcf, 0x43, 0x45, 0x11, 0xac, 0x92, 0xf7, 0xbe, 0xf9, 0xbe, 0xf9, 0xbe, 0xf7, 0x66, 0xd1,
|
||||
0xd5, 0x04, 0x64, 0x06, 0x32, 0x60, 0x30, 0x0b, 0x66, 0x7b, 0x71, 0xaa, 0xa2, 0xbd, 0x40, 0x1d,
|
||||
0xd2, 0x7c, 0x02, 0x0a, 0x30, 0x36, 0x20, 0x65, 0x30, 0xa3, 0x16, 0x6c, 0x13, 0x4b, 0x88, 0x23,
|
||||
0x99, 0x9e, 0x31, 0x12, 0xe0, 0xc2, 0x70, 0xda, 0x3b, 0xbf, 0x11, 0x2c, 0xf8, 0x06, 0xdd, 0x36,
|
||||
0xe8, 0x50, 0x57, 0x81, 0x95, 0x37, 0x50, 0x93, 0x01, 0x03, 0xd3, 0x2f, 0xfe, 0x95, 0x04, 0x06,
|
||||
0xc0, 0xc6, 0x69, 0xa0, 0xab, 0x78, 0xfa, 0x2c, 0x88, 0xc4, 0xdc, 0x40, 0xfe, 0xab, 0x0a, 0xba,
|
||||
0x3c, 0x90, 0xec, 0xf1, 0x34, 0xce, 0xb8, 0x7a, 0x34, 0x81, 0x1c, 0x64, 0x34, 0xc6, 0xb7, 0x50,
|
||||
0x3d, 0x01, 0xa1, 0x52, 0xa1, 0x5a, 0x6e, 0xc7, 0xed, 0x36, 0x7a, 0x4d, 0x6a, 0x24, 0x68, 0x29,
|
||||
0x41, 0x6f, 0x8b, 0x79, 0xbf, 0xf1, 0xf1, 0xc3, 0x6e, 0xfd, 0xc0, 0x1c, 0x0c, 0x4b, 0x06, 0x7e,
|
||||
0xed, 0xa2, 0x4b, 0x5c, 0x70, 0xc5, 0xa3, 0xf1, 0x70, 0x94, 0xe6, 0x20, 0xb9, 0x6a, 0x55, 0x3a,
|
||||
0xd5, 0x6e, 0xa3, 0xb7, 0x4d, 0xad, 0xd9, 0x22, 0x77, 0x39, 0x0c, 0x7a, 0x00, 0x5c, 0xf4, 0xef,
|
||||
0x2f, 0x96, 0x9e, 0x73, 0xba, 0xf4, 0xae, 0xcc, 0xa3, 0x6c, 0xbc, 0xef, 0xff, 0xc4, 0xf7, 0xdf,
|
||||
0x7f, 0xf6, 0xba, 0x8c, 0xab, 0xe7, 0xd3, 0x98, 0x26, 0x90, 0xd9, 0xcc, 0xf6, 0x67, 0x57, 0x8e,
|
||||
0x5e, 0x04, 0x6a, 0x9e, 0xa7, 0x52, 0x4b, 0xc9, 0x70, 0xcb, 0xb2, 0xef, 0x18, 0x32, 0x6e, 0xa3,
|
||||
0x8b, 0xb9, 0x4e, 0x96, 0x4e, 0x5a, 0xd5, 0x8e, 0xdb, 0xdd, 0x0c, 0xcf, 0xea, 0xfd, 0x8d, 0xaf,
|
||||
0x6f, 0x3d, 0xc7, 0x7f, 0xe7, 0xa2, 0xfa, 0x40, 0xb2, 0x27, 0xa0, 0x52, 0x7c, 0x17, 0x35, 0x72,
|
||||
0x3b, 0x87, 0x21, 0x1f, 0xe9, 0xfc, 0x1b, 0xfd, 0x6b, 0xdf, 0x96, 0xde, 0xf9, 0xf6, 0xe9, 0xd2,
|
||||
0xc3, 0xc6, 0xe9, 0xb9, 0xa6, 0x1f, 0xa2, 0xb2, 0xba, 0x37, 0xc2, 0x4d, 0x74, 0x61, 0x06, 0x2a,
|
||||
0x9d, 0xb4, 0x2a, 0xfa, 0x4a, 0x53, 0xe0, 0x9b, 0xa8, 0x06, 0xb9, 0xe2, 0x20, 0xb4, 0x93, 0xad,
|
||||
0x1e, 0xa1, 0xbf, 0x3e, 0x0f, 0x5a, 0xf8, 0x78, 0xa8, 0x4f, 0x85, 0xf6, 0xb4, 0xf5, 0xf9, 0xc9,
|
||||
0x45, 0x68, 0x20, 0x59, 0x19, 0xec, 0x7f, 0x59, 0xdd, 0x41, 0x9b, 0x76, 0xd0, 0x50, 0xda, 0xfd,
|
||||
0xd1, 0xc0, 0x09, 0xaa, 0x45, 0x19, 0x4c, 0x85, 0x6a, 0x55, 0xff, 0xb6, 0xc5, 0xeb, 0xc5, 0x16,
|
||||
0xff, 0x69, 0x57, 0x56, 0xda, 0xe4, 0xeb, 0x3f, 0x58, 0x9c, 0x10, 0xe7, 0xf8, 0x84, 0x38, 0x2f,
|
||||
0x57, 0xc4, 0x59, 0xac, 0x88, 0x7b, 0xb4, 0x22, 0xee, 0x97, 0x15, 0x71, 0xdf, 0xac, 0x89, 0x73,
|
||||
0xb4, 0x26, 0xce, 0xf1, 0x9a, 0x38, 0x4f, 0xff, 0xac, 0x7e, 0xa8, 0xbf, 0x1a, 0x7d, 0x47, 0x5c,
|
||||
0xd3, 0xcf, 0xf5, 0xc6, 0xf7, 0x00, 0x00, 0x00, 0xff, 0xff, 0x2f, 0x32, 0xb4, 0xbb, 0xa1, 0x03,
|
||||
0x00, 0x00,
|
||||
// 586 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xbf, 0x6f, 0xd3, 0x40,
|
||||
0x14, 0xb6, 0x93, 0xd2, 0xd0, 0x8b, 0x94, 0xd2, 0x53, 0x84, 0x12, 0xb7, 0xb2, 0x23, 0xa3, 0xa2,
|
||||
0x2c, 0xb1, 0x69, 0x90, 0x18, 0xca, 0x44, 0x8a, 0x10, 0x20, 0x45, 0x80, 0x91, 0x18, 0x58, 0x22,
|
||||
0xdb, 0x71, 0x8d, 0x45, 0xe2, 0x67, 0xe5, 0x2e, 0x51, 0xb3, 0x31, 0x22, 0x06, 0x60, 0x64, 0xcc,
|
||||
0xcc, 0x86, 0xc4, 0x1f, 0x51, 0x31, 0x75, 0x64, 0x40, 0x01, 0x25, 0x0b, 0x30, 0xf6, 0x2f, 0x40,
|
||||
0xbe, 0x1f, 0x69, 0xd5, 0xa4, 0x01, 0xa4, 0x4e, 0xc9, 0x7b, 0xdf, 0xfb, 0x3e, 0xdd, 0xf7, 0xdd,
|
||||
0xf3, 0xa1, 0x4d, 0x1f, 0x48, 0x17, 0x88, 0x1d, 0xc2, 0xc0, 0x1e, 0xec, 0x78, 0x01, 0x75, 0x77,
|
||||
0x6c, 0x7a, 0x60, 0x25, 0x3d, 0xa0, 0x80, 0x31, 0x07, 0xad, 0x10, 0x06, 0x96, 0x00, 0x35, 0x5d,
|
||||
0x10, 0x3c, 0x97, 0x04, 0x33, 0x86, 0x0f, 0x51, 0xcc, 0x39, 0xda, 0xd6, 0x02, 0xc1, 0x94, 0xcf,
|
||||
0xd1, 0x32, 0x47, 0x5b, 0xac, 0xb2, 0x85, 0x3c, 0x87, 0x8a, 0x21, 0x84, 0xc0, 0xfb, 0xe9, 0x3f,
|
||||
0x49, 0x08, 0x01, 0xc2, 0x4e, 0x60, 0xb3, 0xca, 0xeb, 0xef, 0xdb, 0x6e, 0x3c, 0xe4, 0x90, 0xf9,
|
||||
0x2e, 0x83, 0x36, 0x9a, 0x24, 0x7c, 0xda, 0xf7, 0xba, 0x11, 0x7d, 0xdc, 0x83, 0x04, 0x88, 0xdb,
|
||||
0xc1, 0xb7, 0x51, 0xce, 0x87, 0x98, 0x06, 0x31, 0x2d, 0xa9, 0x15, 0xb5, 0x9a, 0xaf, 0x17, 0x2d,
|
||||
0x2e, 0x61, 0x49, 0x09, 0xeb, 0x4e, 0x3c, 0x6c, 0xe4, 0xbf, 0x7c, 0xae, 0xe5, 0xf6, 0xf8, 0xa0,
|
||||
0x23, 0x19, 0xf8, 0xad, 0x8a, 0xd6, 0xa3, 0x38, 0xa2, 0x91, 0xdb, 0x69, 0xb5, 0x83, 0x04, 0x48,
|
||||
0x44, 0x4b, 0x99, 0x4a, 0xb6, 0x9a, 0xaf, 0x97, 0x2d, 0x71, 0xd8, 0xd4, 0xb7, 0x0c, 0xc3, 0xda,
|
||||
0x83, 0x28, 0x6e, 0x3c, 0x3c, 0x1c, 0x1b, 0xca, 0xf1, 0xd8, 0xb8, 0x3a, 0x74, 0xbb, 0x9d, 0x5d,
|
||||
0xf3, 0x0c, 0xdf, 0xfc, 0xf8, 0xdd, 0xa8, 0x86, 0x11, 0x7d, 0xd1, 0xf7, 0x2c, 0x1f, 0xba, 0xc2,
|
||||
0xb3, 0xf8, 0xa9, 0x91, 0xf6, 0x4b, 0x9b, 0x0e, 0x93, 0x80, 0x30, 0x29, 0xe2, 0x14, 0x04, 0xfb,
|
||||
0x2e, 0x27, 0x63, 0x0d, 0x5d, 0x4e, 0x98, 0xb3, 0xa0, 0x57, 0xca, 0x56, 0xd4, 0xea, 0x9a, 0x33,
|
||||
0xab, 0x77, 0xaf, 0xbc, 0x1e, 0x19, 0xca, 0x87, 0x91, 0xa1, 0xfc, 0x1c, 0x19, 0xca, 0xab, 0x6f,
|
||||
0x15, 0xc5, 0xf4, 0x51, 0x79, 0x2e, 0x10, 0x27, 0x20, 0x09, 0xc4, 0x24, 0xc0, 0xf7, 0x50, 0x3e,
|
||||
0x11, 0xbd, 0x56, 0xd4, 0x66, 0xe1, 0xac, 0x34, 0xb6, 0x7f, 0x8f, 0x8d, 0xd3, 0xed, 0xe3, 0xb1,
|
||||
0x81, 0xb9, 0x8d, 0x53, 0x4d, 0xd3, 0x41, 0xb2, 0x7a, 0xd0, 0x36, 0x3f, 0xa9, 0x28, 0xd7, 0x24,
|
||||
0xe1, 0x33, 0xa0, 0x17, 0xa6, 0x89, 0x8b, 0xe8, 0xd2, 0x00, 0x68, 0xd0, 0x2b, 0x65, 0x98, 0x47,
|
||||
0x5e, 0xe0, 0x5b, 0x68, 0x15, 0x12, 0x1a, 0x41, 0xcc, 0xac, 0x17, 0xea, 0xba, 0x35, 0xbf, 0x8f,
|
||||
0x56, 0x7a, 0x8e, 0x47, 0x6c, 0xca, 0x11, 0xd3, 0x0b, 0x82, 0xd9, 0x40, 0xeb, 0xe2, 0xc8, 0x32,
|
||||
0x0e, 0xf3, 0x97, 0x8a, 0x50, 0x93, 0x84, 0x32, 0xe8, 0x8b, 0x72, 0xb2, 0x85, 0xd6, 0xc4, 0xc5,
|
||||
0x83, 0x74, 0x73, 0xd2, 0xc0, 0x3e, 0x5a, 0x75, 0xbb, 0xd0, 0x8f, 0x69, 0x29, 0xfb, 0xb7, 0xad,
|
||||
0xba, 0x91, 0x6e, 0xd5, 0x7f, 0xed, 0x8e, 0x90, 0x5e, 0x60, 0xbf, 0x88, 0xf0, 0x89, 0x55, 0x99,
|
||||
0x40, 0xfd, 0x4d, 0x06, 0x65, 0x9b, 0x24, 0xc4, 0xfb, 0xa8, 0x70, 0xe6, 0x1b, 0xda, 0x5e, 0x14,
|
||||
0xf4, 0xdc, 0x66, 0x69, 0xb5, 0x7f, 0x1a, 0x9b, 0x2d, 0xe0, 0x7d, 0xb4, 0xc2, 0x96, 0x66, 0xf3,
|
||||
0x1c, 0x5a, 0x0a, 0x6a, 0xd7, 0x96, 0x80, 0x33, 0xa5, 0x27, 0x28, 0x27, 0xef, 0x4d, 0x3f, 0x67,
|
||||
0x5e, 0xe0, 0xda, 0xf5, 0xe5, 0xb8, 0x94, 0x6c, 0x34, 0x0e, 0x27, 0xba, 0x7a, 0x34, 0xd1, 0xd5,
|
||||
0x1f, 0x13, 0x5d, 0x7d, 0x3f, 0xd5, 0x95, 0xa3, 0xa9, 0xae, 0x7c, 0x9d, 0xea, 0xca, 0xf3, 0xe5,
|
||||
0x17, 0x70, 0xc0, 0x1e, 0x3a, 0x76, 0x0d, 0xde, 0x2a, 0x7b, 0x61, 0x6e, 0xfe, 0x09, 0x00, 0x00,
|
||||
0xff, 0xff, 0x7f, 0x09, 0x3f, 0x57, 0x54, 0x05, 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 {
|
||||
// SubmitProposal defines a method to create new proposal given a content.
|
||||
SubmitProposal(ctx context.Context, in *MsgSubmitProposal, opts ...grpc.CallOption) (*MsgSubmitProposalResponse, error)
|
||||
// Vote defines a method to add a vote on a specific proposal.
|
||||
Vote(ctx context.Context, in *MsgVote, opts ...grpc.CallOption) (*MsgVoteResponse, error)
|
||||
// Deposit defines a method to add deposit on a specific proposal.
|
||||
Deposit(ctx context.Context, in *MsgDeposit, opts ...grpc.CallOption) (*MsgDepositResponse, error)
|
||||
}
|
||||
|
||||
type msgClient struct {
|
||||
cc grpc1.ClientConn
|
||||
}
|
||||
|
||||
func NewMsgClient(cc grpc1.ClientConn) MsgClient {
|
||||
return &msgClient{cc}
|
||||
}
|
||||
|
||||
func (c *msgClient) SubmitProposal(ctx context.Context, in *MsgSubmitProposal, opts ...grpc.CallOption) (*MsgSubmitProposalResponse, error) {
|
||||
out := new(MsgSubmitProposalResponse)
|
||||
err := c.cc.Invoke(ctx, "/cosmos.gov.v1beta1.Msg/SubmitProposal", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *msgClient) Vote(ctx context.Context, in *MsgVote, opts ...grpc.CallOption) (*MsgVoteResponse, error) {
|
||||
out := new(MsgVoteResponse)
|
||||
err := c.cc.Invoke(ctx, "/cosmos.gov.v1beta1.Msg/Vote", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *msgClient) Deposit(ctx context.Context, in *MsgDeposit, opts ...grpc.CallOption) (*MsgDepositResponse, error) {
|
||||
out := new(MsgDepositResponse)
|
||||
err := c.cc.Invoke(ctx, "/cosmos.gov.v1beta1.Msg/Deposit", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// MsgServer is the server API for Msg service.
|
||||
type MsgServer interface {
|
||||
// SubmitProposal defines a method to create new proposal given a content.
|
||||
SubmitProposal(context.Context, *MsgSubmitProposal) (*MsgSubmitProposalResponse, error)
|
||||
// Vote defines a method to add a vote on a specific proposal.
|
||||
Vote(context.Context, *MsgVote) (*MsgVoteResponse, error)
|
||||
// Deposit defines a method to add deposit on a specific proposal.
|
||||
Deposit(context.Context, *MsgDeposit) (*MsgDepositResponse, error)
|
||||
}
|
||||
|
||||
// UnimplementedMsgServer can be embedded to have forward compatible implementations.
|
||||
type UnimplementedMsgServer struct {
|
||||
}
|
||||
|
||||
func (*UnimplementedMsgServer) SubmitProposal(ctx context.Context, req *MsgSubmitProposal) (*MsgSubmitProposalResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method SubmitProposal not implemented")
|
||||
}
|
||||
func (*UnimplementedMsgServer) Vote(ctx context.Context, req *MsgVote) (*MsgVoteResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Vote not implemented")
|
||||
}
|
||||
func (*UnimplementedMsgServer) Deposit(ctx context.Context, req *MsgDeposit) (*MsgDepositResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Deposit not implemented")
|
||||
}
|
||||
|
||||
func RegisterMsgServer(s grpc1.Server, srv MsgServer) {
|
||||
s.RegisterService(&_Msg_serviceDesc, srv)
|
||||
}
|
||||
|
||||
func _Msg_SubmitProposal_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(MsgSubmitProposal)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(MsgServer).SubmitProposal(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/cosmos.gov.v1beta1.Msg/SubmitProposal",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MsgServer).SubmitProposal(ctx, req.(*MsgSubmitProposal))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Msg_Vote_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(MsgVote)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(MsgServer).Vote(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/cosmos.gov.v1beta1.Msg/Vote",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MsgServer).Vote(ctx, req.(*MsgVote))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Msg_Deposit_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(MsgDeposit)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(MsgServer).Deposit(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/cosmos.gov.v1beta1.Msg/Deposit",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MsgServer).Deposit(ctx, req.(*MsgDeposit))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
var _Msg_serviceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "cosmos.gov.v1beta1.Msg",
|
||||
HandlerType: (*MsgServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "SubmitProposal",
|
||||
Handler: _Msg_SubmitProposal_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "Vote",
|
||||
Handler: _Msg_Vote_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "Deposit",
|
||||
Handler: _Msg_Deposit_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "cosmos/gov/v1beta1/tx.proto",
|
||||
}
|
||||
|
||||
func (m *MsgSubmitProposal) Marshal() (dAtA []byte, err error) {
|
||||
@ -245,6 +535,34 @@ func (m *MsgSubmitProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *MsgSubmitProposalResponse) 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 *MsgSubmitProposalResponse) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *MsgSubmitProposalResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if m.ProposalId != 0 {
|
||||
i = encodeVarintTx(dAtA, i, uint64(m.ProposalId))
|
||||
i--
|
||||
dAtA[i] = 0x8
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *MsgVote) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
@ -285,6 +603,29 @@ func (m *MsgVote) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *MsgVoteResponse) 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 *MsgVoteResponse) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *MsgVoteResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *MsgDeposit) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
@ -334,6 +675,29 @@ func (m *MsgDeposit) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *MsgDepositResponse) 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 *MsgDepositResponse) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *MsgDepositResponse) 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
|
||||
@ -368,6 +732,18 @@ func (m *MsgSubmitProposal) Size() (n int) {
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *MsgSubmitProposalResponse) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
if m.ProposalId != 0 {
|
||||
n += 1 + sovTx(uint64(m.ProposalId))
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *MsgVote) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
@ -387,6 +763,15 @@ func (m *MsgVote) Size() (n int) {
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *MsgVoteResponse) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *MsgDeposit) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
@ -409,6 +794,15 @@ func (m *MsgDeposit) Size() (n int) {
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *MsgDepositResponse) 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
|
||||
}
|
||||
@ -570,6 +964,78 @@ func (m *MsgSubmitProposal) Unmarshal(dAtA []byte) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *MsgSubmitProposalResponse) 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: MsgSubmitProposalResponse: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: MsgSubmitProposalResponse: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 0 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field ProposalId", wireType)
|
||||
}
|
||||
m.ProposalId = 0
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTx
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
m.ProposalId |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipTx(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if skippy < 0 {
|
||||
return ErrInvalidLengthTx
|
||||
}
|
||||
if (iNdEx + skippy) < 0 {
|
||||
return ErrInvalidLengthTx
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *MsgVote) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
@ -693,6 +1159,59 @@ func (m *MsgVote) Unmarshal(dAtA []byte) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *MsgVoteResponse) 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: MsgVoteResponse: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: MsgVoteResponse: 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 {
|
||||
return ErrInvalidLengthTx
|
||||
}
|
||||
if (iNdEx + skippy) < 0 {
|
||||
return ErrInvalidLengthTx
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *MsgDeposit) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
@ -831,6 +1350,59 @@ func (m *MsgDeposit) Unmarshal(dAtA []byte) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *MsgDepositResponse) 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: MsgDepositResponse: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: MsgDepositResponse: 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 {
|
||||
return ErrInvalidLengthTx
|
||||
}
|
||||
if (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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user