From 725e2dc2b45ca3f8dba51f305837836147371f10 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 2 Mar 2020 12:44:55 -0500 Subject: [PATCH] Update gov codec interface --- codec/std/std.pb.go | 1015 -------------------------------------- codec/std/std.proto | 28 -- simapp/codec/codec.go | 36 +- simapp/codec/codec.pb.go | 946 +++++++++++++++++++++++++++++++++-- simapp/codec/codec.proto | 25 + x/gov/alias.go | 1 + x/gov/types/codec.go | 4 +- x/gov/types/proposal.go | 18 +- x/gov/types/types.proto | 14 - 9 files changed, 960 insertions(+), 1127 deletions(-) delete mode 100644 codec/std/std.pb.go delete mode 100644 codec/std/std.proto diff --git a/codec/std/std.pb.go b/codec/std/std.pb.go deleted file mode 100644 index 985a5f8b5..000000000 --- a/codec/std/std.pb.go +++ /dev/null @@ -1,1015 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: codec/std/std.proto - -package std - -import ( - fmt "fmt" - types2 "github.com/cosmos/cosmos-sdk/x/distribution/types" - github_com_cosmos_cosmos_sdk_x_gov_types "github.com/cosmos/cosmos-sdk/x/gov/types" - types "github.com/cosmos/cosmos-sdk/x/gov/types" - proposal "github.com/cosmos/cosmos-sdk/x/params/types/proposal" - types1 "github.com/cosmos/cosmos-sdk/x/upgrade/types" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" - _ "github.com/regen-network/cosmos-proto" - 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 - -type StdProposal struct { - types.ProposalBase `protobuf:"bytes,1,opt,name=base,proto3,embedded=base" json:"base"` - Content StdProposal_Content `protobuf:"bytes,2,opt,name=content,proto3" json:"content"` -} - -func (m *StdProposal) Reset() { *m = StdProposal{} } -func (m *StdProposal) String() string { return proto.CompactTextString(m) } -func (*StdProposal) ProtoMessage() {} -func (*StdProposal) Descriptor() ([]byte, []int) { - return fileDescriptor_bfdf2c6f71a73b14, []int{0} -} -func (m *StdProposal) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *StdProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_StdProposal.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 *StdProposal) XXX_Merge(src proto.Message) { - xxx_messageInfo_StdProposal.Merge(m, src) -} -func (m *StdProposal) XXX_Size() int { - return m.Size() -} -func (m *StdProposal) XXX_DiscardUnknown() { - xxx_messageInfo_StdProposal.DiscardUnknown(m) -} - -var xxx_messageInfo_StdProposal proto.InternalMessageInfo - -func (m *StdProposal) GetContent() StdProposal_Content { - if m != nil { - return m.Content - } - return StdProposal_Content{} -} - -type StdProposal_Content struct { - // Types that are valid to be assigned to Sum: - // *StdProposal_Content_Text - // *StdProposal_Content_ParameterChange - // *StdProposal_Content_SoftwareUpgrade - // *StdProposal_Content_CancelSoftwareUpgrade - // *StdProposal_Content_CommunityPoolSpend - Sum isStdProposal_Content_Sum `protobuf_oneof:"sum"` -} - -func (m *StdProposal_Content) Reset() { *m = StdProposal_Content{} } -func (m *StdProposal_Content) String() string { return proto.CompactTextString(m) } -func (*StdProposal_Content) ProtoMessage() {} -func (*StdProposal_Content) Descriptor() ([]byte, []int) { - return fileDescriptor_bfdf2c6f71a73b14, []int{0, 0} -} -func (m *StdProposal_Content) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *StdProposal_Content) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_StdProposal_Content.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 *StdProposal_Content) XXX_Merge(src proto.Message) { - xxx_messageInfo_StdProposal_Content.Merge(m, src) -} -func (m *StdProposal_Content) XXX_Size() int { - return m.Size() -} -func (m *StdProposal_Content) XXX_DiscardUnknown() { - xxx_messageInfo_StdProposal_Content.DiscardUnknown(m) -} - -var xxx_messageInfo_StdProposal_Content proto.InternalMessageInfo - -type isStdProposal_Content_Sum interface { - isStdProposal_Content_Sum() - MarshalTo([]byte) (int, error) - Size() int -} - -type StdProposal_Content_Text struct { - Text *types.TextProposal `protobuf:"bytes,1,opt,name=text,proto3,oneof" json:"text,omitempty"` -} -type StdProposal_Content_ParameterChange struct { - ParameterChange *proposal.ParameterChangeProposal `protobuf:"bytes,2,opt,name=parameter_change,json=parameterChange,proto3,oneof" json:"parameter_change,omitempty"` -} -type StdProposal_Content_SoftwareUpgrade struct { - SoftwareUpgrade *types1.SoftwareUpgradeProposal `protobuf:"bytes,3,opt,name=software_upgrade,json=softwareUpgrade,proto3,oneof" json:"software_upgrade,omitempty"` -} -type StdProposal_Content_CancelSoftwareUpgrade struct { - CancelSoftwareUpgrade *types1.CancelSoftwareUpgradeProposal `protobuf:"bytes,4,opt,name=cancel_software_upgrade,json=cancelSoftwareUpgrade,proto3,oneof" json:"cancel_software_upgrade,omitempty"` -} -type StdProposal_Content_CommunityPoolSpend struct { - CommunityPoolSpend *types2.CommunityPoolSpendProposal `protobuf:"bytes,5,opt,name=community_pool_spend,json=communityPoolSpend,proto3,oneof" json:"community_pool_spend,omitempty"` -} - -func (*StdProposal_Content_Text) isStdProposal_Content_Sum() {} -func (*StdProposal_Content_ParameterChange) isStdProposal_Content_Sum() {} -func (*StdProposal_Content_SoftwareUpgrade) isStdProposal_Content_Sum() {} -func (*StdProposal_Content_CancelSoftwareUpgrade) isStdProposal_Content_Sum() {} -func (*StdProposal_Content_CommunityPoolSpend) isStdProposal_Content_Sum() {} - -func (m *StdProposal_Content) GetSum() isStdProposal_Content_Sum { - if m != nil { - return m.Sum - } - return nil -} - -func (m *StdProposal_Content) GetText() *types.TextProposal { - if x, ok := m.GetSum().(*StdProposal_Content_Text); ok { - return x.Text - } - return nil -} - -func (m *StdProposal_Content) GetParameterChange() *proposal.ParameterChangeProposal { - if x, ok := m.GetSum().(*StdProposal_Content_ParameterChange); ok { - return x.ParameterChange - } - return nil -} - -func (m *StdProposal_Content) GetSoftwareUpgrade() *types1.SoftwareUpgradeProposal { - if x, ok := m.GetSum().(*StdProposal_Content_SoftwareUpgrade); ok { - return x.SoftwareUpgrade - } - return nil -} - -func (m *StdProposal_Content) GetCancelSoftwareUpgrade() *types1.CancelSoftwareUpgradeProposal { - if x, ok := m.GetSum().(*StdProposal_Content_CancelSoftwareUpgrade); ok { - return x.CancelSoftwareUpgrade - } - return nil -} - -func (m *StdProposal_Content) GetCommunityPoolSpend() *types2.CommunityPoolSpendProposal { - if x, ok := m.GetSum().(*StdProposal_Content_CommunityPoolSpend); ok { - return x.CommunityPoolSpend - } - return nil -} - -// XXX_OneofWrappers is for the internal use of the proto package. -func (*StdProposal_Content) XXX_OneofWrappers() []interface{} { - return []interface{}{ - (*StdProposal_Content_Text)(nil), - (*StdProposal_Content_ParameterChange)(nil), - (*StdProposal_Content_SoftwareUpgrade)(nil), - (*StdProposal_Content_CancelSoftwareUpgrade)(nil), - (*StdProposal_Content_CommunityPoolSpend)(nil), - } -} - -func init() { - proto.RegisterType((*StdProposal)(nil), "cosmos_sdk.x.v1.StdProposal") - proto.RegisterType((*StdProposal_Content)(nil), "cosmos_sdk.x.v1.StdProposal.Content") -} - -func init() { proto.RegisterFile("codec/std/std.proto", fileDescriptor_bfdf2c6f71a73b14) } - -var fileDescriptor_bfdf2c6f71a73b14 = []byte{ - // 492 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x93, 0x4f, 0x6f, 0xd3, 0x30,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ac, 0xa7, 0xa1, - 0x04, 0x48, 0x42, 0x25, 0x45, 0xc6, 0xbb, 0x1d, 0x13, 0xf7, 0xaa, 0x1d, 0xd7, 0xbc, 0x56, 0x26, - 0xb3, 0x76, 0x1e, 0x01, 0x24, 0xc7, 0x4b, 0x5f, 0x23, 0xd0, 0x67, 0x2b, 0xd5, 0xd7, 0xcf, 0x7f, - 0xff, 0xda, 0x3f, 0x88, 0x62, 0x3d, 0x2e, 0x46, 0x98, 0x41, 0x6a, 0x47, 0xa7, 0x1e, 0x27, 0xc5, - 0x4f, 0x48, 0x63, 0x2c, 0xce, 0xaf, 0x49, 0x07, 0xad, 0xa9, 0x22, 0xed, 0xbf, 0x3d, 0x9d, 0x07, - 0xee, 0x6c, 0x1e, 0xb8, 0x7f, 0xe7, 0x81, 0xfb, 0x7d, 0x11, 0x38, 0xb3, 0x45, 0xe0, 0xfc, 0x59, - 0x04, 0xce, 0xa7, 0xbd, 0x6b, 0x91, 0xe7, 0x43, 0x3e, 0xba, 0x69, 0xae, 0xff, 0xb3, 0x7f, 0x01, - 0x00, 0x00, 0xff, 0xff, 0x30, 0x48, 0xf7, 0x0e, 0xf8, 0x03, 0x00, 0x00, -} - -func (this *StdProposal_Content) GetContent() github_com_cosmos_cosmos_sdk_x_gov_types.Content { - if x := this.GetText(); x != nil { - return x - } - if x := this.GetParameterChange(); x != nil { - return x - } - if x := this.GetSoftwareUpgrade(); x != nil { - return x - } - if x := this.GetCancelSoftwareUpgrade(); x != nil { - return x - } - if x := this.GetCommunityPoolSpend(); x != nil { - return x - } - return nil -} - -func (this *StdProposal_Content) SetContent(value github_com_cosmos_cosmos_sdk_x_gov_types.Content) error { - if value == nil { - this.Sum = nil - return nil - } - switch vt := value.(type) { - case *types.TextProposal: - this.Sum = &StdProposal_Content_Text{vt} - return nil - case types.TextProposal: - this.Sum = &StdProposal_Content_Text{&vt} - return nil - case *proposal.ParameterChangeProposal: - this.Sum = &StdProposal_Content_ParameterChange{vt} - return nil - case proposal.ParameterChangeProposal: - this.Sum = &StdProposal_Content_ParameterChange{&vt} - return nil - case *types1.SoftwareUpgradeProposal: - this.Sum = &StdProposal_Content_SoftwareUpgrade{vt} - return nil - case types1.SoftwareUpgradeProposal: - this.Sum = &StdProposal_Content_SoftwareUpgrade{&vt} - return nil - case *types1.CancelSoftwareUpgradeProposal: - this.Sum = &StdProposal_Content_CancelSoftwareUpgrade{vt} - return nil - case types1.CancelSoftwareUpgradeProposal: - this.Sum = &StdProposal_Content_CancelSoftwareUpgrade{&vt} - return nil - case *types2.CommunityPoolSpendProposal: - this.Sum = &StdProposal_Content_CommunityPoolSpend{vt} - return nil - case types2.CommunityPoolSpendProposal: - this.Sum = &StdProposal_Content_CommunityPoolSpend{&vt} - return nil - } - return fmt.Errorf("can't encode value of type %T as message StdProposal_Content", value) -} - -func (m *StdProposal) 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 *StdProposal) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *StdProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Content.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintStd(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - { - size, err := m.ProposalBase.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintStd(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *StdProposal_Content) 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 *StdProposal_Content) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *StdProposal_Content) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Sum != nil { - { - size := m.Sum.Size() - i -= size - if _, err := m.Sum.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - } - } - return len(dAtA) - i, nil -} - -func (m *StdProposal_Content_Text) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *StdProposal_Content_Text) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.Text != nil { - { - size, err := m.Text.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintStd(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} -func (m *StdProposal_Content_ParameterChange) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *StdProposal_Content_ParameterChange) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.ParameterChange != nil { - { - size, err := m.ParameterChange.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintStd(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - return len(dAtA) - i, nil -} -func (m *StdProposal_Content_SoftwareUpgrade) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *StdProposal_Content_SoftwareUpgrade) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.SoftwareUpgrade != nil { - { - size, err := m.SoftwareUpgrade.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintStd(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - return len(dAtA) - i, nil -} -func (m *StdProposal_Content_CancelSoftwareUpgrade) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *StdProposal_Content_CancelSoftwareUpgrade) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.CancelSoftwareUpgrade != nil { - { - size, err := m.CancelSoftwareUpgrade.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintStd(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - return len(dAtA) - i, nil -} -func (m *StdProposal_Content_CommunityPoolSpend) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *StdProposal_Content_CommunityPoolSpend) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.CommunityPoolSpend != nil { - { - size, err := m.CommunityPoolSpend.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintStd(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - } - return len(dAtA) - i, nil -} -func encodeVarintStd(dAtA []byte, offset int, v uint64) int { - offset -= sovStd(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *StdProposal) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.ProposalBase.Size() - n += 1 + l + sovStd(uint64(l)) - l = m.Content.Size() - n += 1 + l + sovStd(uint64(l)) - return n -} - -func (m *StdProposal_Content) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Sum != nil { - n += m.Sum.Size() - } - return n -} - -func (m *StdProposal_Content_Text) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Text != nil { - l = m.Text.Size() - n += 1 + l + sovStd(uint64(l)) - } - return n -} -func (m *StdProposal_Content_ParameterChange) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.ParameterChange != nil { - l = m.ParameterChange.Size() - n += 1 + l + sovStd(uint64(l)) - } - return n -} -func (m *StdProposal_Content_SoftwareUpgrade) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.SoftwareUpgrade != nil { - l = m.SoftwareUpgrade.Size() - n += 1 + l + sovStd(uint64(l)) - } - return n -} -func (m *StdProposal_Content_CancelSoftwareUpgrade) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.CancelSoftwareUpgrade != nil { - l = m.CancelSoftwareUpgrade.Size() - n += 1 + l + sovStd(uint64(l)) - } - return n -} -func (m *StdProposal_Content_CommunityPoolSpend) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.CommunityPoolSpend != nil { - l = m.CommunityPoolSpend.Size() - n += 1 + l + sovStd(uint64(l)) - } - return n -} - -func sovStd(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozStd(x uint64) (n int) { - return sovStd(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *StdProposal) 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 ErrIntOverflowStd - } - 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: StdProposal: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: StdProposal: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProposalBase", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStd - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthStd - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthStd - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ProposalBase.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Content", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStd - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthStd - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthStd - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Content.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipStd(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthStd - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthStd - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *StdProposal_Content) 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 ErrIntOverflowStd - } - 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: Content: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Content: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Text", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStd - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthStd - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthStd - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &types.TextProposal{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Sum = &StdProposal_Content_Text{v} - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ParameterChange", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStd - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthStd - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthStd - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &proposal.ParameterChangeProposal{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Sum = &StdProposal_Content_ParameterChange{v} - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SoftwareUpgrade", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStd - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthStd - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthStd - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &types1.SoftwareUpgradeProposal{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Sum = &StdProposal_Content_SoftwareUpgrade{v} - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CancelSoftwareUpgrade", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStd - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthStd - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthStd - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &types1.CancelSoftwareUpgradeProposal{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Sum = &StdProposal_Content_CancelSoftwareUpgrade{v} - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CommunityPoolSpend", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStd - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthStd - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthStd - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &types2.CommunityPoolSpendProposal{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Sum = &StdProposal_Content_CommunityPoolSpend{v} - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipStd(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthStd - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthStd - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipStd(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, ErrIntOverflowStd - } - 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, ErrIntOverflowStd - } - 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, ErrIntOverflowStd - } - 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, ErrInvalidLengthStd - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupStd - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthStd - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthStd = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowStd = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupStd = fmt.Errorf("proto: unexpected end of group") -) diff --git a/codec/std/std.proto b/codec/std/std.proto deleted file mode 100644 index a99d35fb4..000000000 --- a/codec/std/std.proto +++ /dev/null @@ -1,28 +0,0 @@ -syntax = "proto3"; -package cosmos_sdk.x.v1; - -import "third_party/proto/cosmos-proto/cosmos.proto"; -import "third_party/proto/gogoproto/gogo.proto"; -import "x/gov/types/types.proto"; -import "x/params/types/proposal/types.proto"; -import "x/upgrade/types/types.proto"; -import "x/distribution/types/types.proto"; - -option go_package = "github.com/cosmos/cosmos-sdk/codec/std"; - -message StdProposal { - cosmos_sdk.x.gov.v1.ProposalBase base = 1 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; - Content content = 2 [(gogoproto.nullable) = false]; - - message Content { - option (cosmos_proto.interface_type) = "github.com/cosmos/cosmos-sdk/x/gov/types.Content"; - oneof sum { - cosmos_sdk.x.gov.v1.TextProposal text = 1; - cosmos_sdk.x.params.v1.ParameterChangeProposal parameter_change = 2; - cosmos_sdk.x.upgrade.v1.SoftwareUpgradeProposal software_upgrade = 3; - cosmos_sdk.x.upgrade.v1.CancelSoftwareUpgradeProposal cancel_software_upgrade = 4; - cosmos_sdk.x.distribution.v1.CommunityPoolSpendProposal community_pool_spend = 5; - } - } -} - diff --git a/simapp/codec/codec.go b/simapp/codec/codec.go index 284e934e9..75dd59fb3 100644 --- a/simapp/codec/codec.go +++ b/simapp/codec/codec.go @@ -2,7 +2,6 @@ package codec import ( "github.com/cosmos/cosmos-sdk/codec" - cosmos_sdk_x_v1 "github.com/cosmos/cosmos-sdk/codec/std" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/x/auth" @@ -10,7 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/auth/vesting" "github.com/cosmos/cosmos-sdk/x/evidence" eviexported "github.com/cosmos/cosmos-sdk/x/evidence/exported" - "github.com/cosmos/cosmos-sdk/x/gov/types" + "github.com/cosmos/cosmos-sdk/x/gov" "github.com/cosmos/cosmos-sdk/x/supply" supplyexported "github.com/cosmos/cosmos-sdk/x/supply/exported" ) @@ -19,6 +18,7 @@ var ( _ auth.Codec = (*Codec)(nil) _ supply.Codec = (*Codec)(nil) _ evidence.Codec = (*Codec)(nil) + _ gov.Codec = (*Codec)(nil) ) // Codec defines the application-level codec. This codec contains all the @@ -153,25 +153,31 @@ func (c *Codec) UnmarshalEvidenceJSON(bz []byte) (eviexported.Evidence, error) { return evidence.GetEvidence(), nil } -func (c *Codec) MarshalProposal(p types.Proposal) ([]byte, error) { - stdProposal := &cosmos_sdk_x_v1.StdProposal{ProposalBase: p.ProposalBase} - if err := stdProposal.Content.SetContent(p.Content); err != nil { +// MarshalProposal marshals a Proposal. It accepts a Proposal defined by the x/gov +// module and uses the application-level Proposal type which has the concrete +// Content implementation to serialize. +func (c *Codec) MarshalProposal(p gov.Proposal) ([]byte, error) { + proposal := &Proposal{ProposalBase: p.ProposalBase} + if err := proposal.Content.SetContent(p.Content); err != nil { return nil, err } - return c.Marshaler.MarshalBinaryBare(stdProposal) + + return c.Marshaler.MarshalBinaryLengthPrefixed(proposal) } -func (c *Codec) UnmarshalProposal(bz []byte, p *types.Proposal) error { - stdProposal := &cosmos_sdk_x_v1.StdProposal{} - if err := c.Marshaler.UnmarshalBinaryLengthPrefixed(bz, stdProposal); err != nil { - return err +// UnmarshalProposal decodes a Proposal defined by the x/gov module and uses the +// application-level Proposal type which has the concrete Content implementation +// to deserialize. +func (c *Codec) UnmarshalProposal(bz []byte) (gov.Proposal, error) { + proposal := &Proposal{} + if err := c.Marshaler.UnmarshalBinaryLengthPrefixed(bz, proposal); err != nil { + return gov.Proposal{}, err } - *p = types.Proposal{ - Content: stdProposal.Content.GetContent(), - ProposalBase: stdProposal.ProposalBase, - } - return nil + return gov.Proposal{ + Content: proposal.Content.GetContent(), + ProposalBase: proposal.ProposalBase, + }, nil } // ---------------------------------------------------------------------------- diff --git a/simapp/codec/codec.pb.go b/simapp/codec/codec.pb.go index b222403b4..d58635ad8 100644 --- a/simapp/codec/codec.pb.go +++ b/simapp/codec/codec.pb.go @@ -8,10 +8,15 @@ import ( github_com_cosmos_cosmos_sdk_x_auth_exported "github.com/cosmos/cosmos-sdk/x/auth/exported" types "github.com/cosmos/cosmos-sdk/x/auth/types" types1 "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" + types6 "github.com/cosmos/cosmos-sdk/x/distribution/types" github_com_cosmos_cosmos_sdk_x_evidence_exported "github.com/cosmos/cosmos-sdk/x/evidence/exported" types3 "github.com/cosmos/cosmos-sdk/x/evidence/types" + github_com_cosmos_cosmos_sdk_x_gov_types "github.com/cosmos/cosmos-sdk/x/gov/types" + types4 "github.com/cosmos/cosmos-sdk/x/gov/types" + proposal "github.com/cosmos/cosmos-sdk/x/params/types/proposal" github_com_cosmos_cosmos_sdk_x_supply_exported "github.com/cosmos/cosmos-sdk/x/supply/exported" types2 "github.com/cosmos/cosmos-sdk/x/supply/types" + types5 "github.com/cosmos/cosmos-sdk/x/upgrade/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" _ "github.com/regen-network/cosmos-proto" @@ -351,55 +356,246 @@ func (m *MsgSubmitEvidence) XXX_DiscardUnknown() { var xxx_messageInfo_MsgSubmitEvidence proto.InternalMessageInfo +// Proposal defines the application-level concrete proposal type used in governance +// proposals. +type Proposal struct { + types4.ProposalBase `protobuf:"bytes,1,opt,name=base,proto3,embedded=base" json:"base"` + Content Content `protobuf:"bytes,2,opt,name=content,proto3" json:"content"` +} + +func (m *Proposal) Reset() { *m = Proposal{} } +func (m *Proposal) String() string { return proto.CompactTextString(m) } +func (*Proposal) ProtoMessage() {} +func (*Proposal) Descriptor() ([]byte, []int) { + return fileDescriptor_3c6d4085e4065f5a, []int{4} +} +func (m *Proposal) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Proposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Proposal.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 *Proposal) XXX_Merge(src proto.Message) { + xxx_messageInfo_Proposal.Merge(m, src) +} +func (m *Proposal) XXX_Size() int { + return m.Size() +} +func (m *Proposal) XXX_DiscardUnknown() { + xxx_messageInfo_Proposal.DiscardUnknown(m) +} + +var xxx_messageInfo_Proposal proto.InternalMessageInfo + +func (m *Proposal) GetContent() Content { + if m != nil { + return m.Content + } + return Content{} +} + +// Content defines the application-level allowed Content to be included in a +// governance proposal. +type Content struct { + // Types that are valid to be assigned to Sum: + // *Content_Text + // *Content_ParameterChange + // *Content_SoftwareUpgrade + // *Content_CancelSoftwareUpgrade + // *Content_CommunityPoolSpend + Sum isContent_Sum `protobuf_oneof:"sum"` +} + +func (m *Content) Reset() { *m = Content{} } +func (m *Content) String() string { return proto.CompactTextString(m) } +func (*Content) ProtoMessage() {} +func (*Content) Descriptor() ([]byte, []int) { + return fileDescriptor_3c6d4085e4065f5a, []int{5} +} +func (m *Content) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Content) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Content.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 *Content) XXX_Merge(src proto.Message) { + xxx_messageInfo_Content.Merge(m, src) +} +func (m *Content) XXX_Size() int { + return m.Size() +} +func (m *Content) XXX_DiscardUnknown() { + xxx_messageInfo_Content.DiscardUnknown(m) +} + +var xxx_messageInfo_Content proto.InternalMessageInfo + +type isContent_Sum interface { + isContent_Sum() + MarshalTo([]byte) (int, error) + Size() int +} + +type Content_Text struct { + Text *types4.TextProposal `protobuf:"bytes,1,opt,name=text,proto3,oneof" json:"text,omitempty"` +} +type Content_ParameterChange struct { + ParameterChange *proposal.ParameterChangeProposal `protobuf:"bytes,2,opt,name=parameter_change,json=parameterChange,proto3,oneof" json:"parameter_change,omitempty"` +} +type Content_SoftwareUpgrade struct { + SoftwareUpgrade *types5.SoftwareUpgradeProposal `protobuf:"bytes,3,opt,name=software_upgrade,json=softwareUpgrade,proto3,oneof" json:"software_upgrade,omitempty"` +} +type Content_CancelSoftwareUpgrade struct { + CancelSoftwareUpgrade *types5.CancelSoftwareUpgradeProposal `protobuf:"bytes,4,opt,name=cancel_software_upgrade,json=cancelSoftwareUpgrade,proto3,oneof" json:"cancel_software_upgrade,omitempty"` +} +type Content_CommunityPoolSpend struct { + CommunityPoolSpend *types6.CommunityPoolSpendProposal `protobuf:"bytes,5,opt,name=community_pool_spend,json=communityPoolSpend,proto3,oneof" json:"community_pool_spend,omitempty"` +} + +func (*Content_Text) isContent_Sum() {} +func (*Content_ParameterChange) isContent_Sum() {} +func (*Content_SoftwareUpgrade) isContent_Sum() {} +func (*Content_CancelSoftwareUpgrade) isContent_Sum() {} +func (*Content_CommunityPoolSpend) isContent_Sum() {} + +func (m *Content) GetSum() isContent_Sum { + if m != nil { + return m.Sum + } + return nil +} + +func (m *Content) GetText() *types4.TextProposal { + if x, ok := m.GetSum().(*Content_Text); ok { + return x.Text + } + return nil +} + +func (m *Content) GetParameterChange() *proposal.ParameterChangeProposal { + if x, ok := m.GetSum().(*Content_ParameterChange); ok { + return x.ParameterChange + } + return nil +} + +func (m *Content) GetSoftwareUpgrade() *types5.SoftwareUpgradeProposal { + if x, ok := m.GetSum().(*Content_SoftwareUpgrade); ok { + return x.SoftwareUpgrade + } + return nil +} + +func (m *Content) GetCancelSoftwareUpgrade() *types5.CancelSoftwareUpgradeProposal { + if x, ok := m.GetSum().(*Content_CancelSoftwareUpgrade); ok { + return x.CancelSoftwareUpgrade + } + return nil +} + +func (m *Content) GetCommunityPoolSpend() *types6.CommunityPoolSpendProposal { + if x, ok := m.GetSum().(*Content_CommunityPoolSpend); ok { + return x.CommunityPoolSpend + } + return nil +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*Content) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*Content_Text)(nil), + (*Content_ParameterChange)(nil), + (*Content_SoftwareUpgrade)(nil), + (*Content_CancelSoftwareUpgrade)(nil), + (*Content_CommunityPoolSpend)(nil), + } +} + func init() { proto.RegisterType((*Account)(nil), "cosmos_sdk.simapp.codec.v1.Account") proto.RegisterType((*Supply)(nil), "cosmos_sdk.simapp.codec.v1.Supply") proto.RegisterType((*Evidence)(nil), "cosmos_sdk.simapp.codec.v1.Evidence") proto.RegisterType((*MsgSubmitEvidence)(nil), "cosmos_sdk.simapp.codec.v1.MsgSubmitEvidence") + proto.RegisterType((*Proposal)(nil), "cosmos_sdk.simapp.codec.v1.Proposal") + proto.RegisterType((*Content)(nil), "cosmos_sdk.simapp.codec.v1.Content") } func init() { proto.RegisterFile("simapp/codec/codec.proto", fileDescriptor_3c6d4085e4065f5a) } var fileDescriptor_3c6d4085e4065f5a = []byte{ - // 593 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x54, 0x4d, 0x6f, 0xd3, 0x3e, - 0x18, 0x4f, 0xfe, 0xeb, 0xfa, 0xaf, 0xbc, 0x81, 0x44, 0x24, 0xa0, 0xaa, 0x50, 0x3a, 0x26, 0x98, - 0x78, 0x51, 0x13, 0x8d, 0xf1, 0xb6, 0x5e, 0x60, 0x1d, 0x43, 0x45, 0xa2, 0x08, 0x75, 0x12, 0x07, - 0x2e, 0x55, 0x6a, 0x5b, 0xad, 0xb5, 0x26, 0x36, 0xb5, 0x1d, 0xb5, 0xdf, 0x00, 0x71, 0xe2, 0x23, - 0x4c, 0x7c, 0x00, 0x4e, 0x3b, 0xf2, 0x01, 0xa6, 0x9d, 0x7a, 0xe4, 0x34, 0xa1, 0xf6, 0xc2, 0xc7, - 0x40, 0x89, 0x9d, 0xb4, 0x55, 0xda, 0xee, 0x12, 0xd5, 0x7e, 0x7e, 0x6f, 0x76, 0x9f, 0xc7, 0xa0, - 0xc8, 0x89, 0xef, 0x31, 0xe6, 0x42, 0x8a, 0x30, 0x54, 0x5f, 0x87, 0xf5, 0xa9, 0xa0, 0x56, 0x09, - 0x52, 0xee, 0x53, 0xde, 0xe2, 0xe8, 0xc4, 0x51, 0x20, 0x47, 0x95, 0xc3, 0xdd, 0xd2, 0x63, 0xd1, - 0x25, 0x7d, 0xd4, 0x62, 0x5e, 0x5f, 0x0c, 0xdd, 0x18, 0xee, 0x2a, 0x74, 0x65, 0x76, 0xa1, 0x84, - 0x4a, 0x3b, 0x59, 0x70, 0x87, 0x76, 0xe8, 0xf4, 0x97, 0xc6, 0x15, 0x07, 0xae, 0x27, 0x45, 0xd7, - 0x15, 0x43, 0x86, 0xb9, 0xfa, 0xea, 0xca, 0x96, 0xae, 0x84, 0x98, 0x0b, 0x12, 0x74, 0x16, 0x20, - 0x4a, 0x03, 0x97, 0x4b, 0xc6, 0x7a, 0xc3, 0x05, 0xb5, 0x3b, 0x03, 0x17, 0x87, 0x04, 0xe1, 0x00, - 0xe2, 0x6c, 0x75, 0xfb, 0x57, 0x0e, 0xfc, 0x7f, 0x00, 0x21, 0x95, 0x81, 0xb0, 0xde, 0x82, 0xcd, - 0xb6, 0xc7, 0x71, 0xcb, 0x53, 0xeb, 0xa2, 0xb9, 0x65, 0x3e, 0xd8, 0x78, 0x72, 0xd7, 0x99, 0xb9, - 0x89, 0x81, 0x13, 0x25, 0x71, 0xc2, 0x5d, 0xa7, 0xe6, 0x71, 0xac, 0x89, 0x75, 0xa3, 0xb9, 0xd1, - 0x9e, 0x2e, 0xad, 0x10, 0x94, 0x20, 0x0d, 0x04, 0x09, 0x24, 0x95, 0xbc, 0xa5, 0x53, 0xa7, 0xaa, - 0xff, 0xc5, 0xaa, 0xcf, 0x17, 0xa9, 0x2a, 0x64, 0xa4, 0x7e, 0x98, 0xf2, 0x3f, 0xa9, 0xcd, 0xa9, - 0x55, 0x11, 0x2e, 0xa9, 0x59, 0x3e, 0xb8, 0x8d, 0x70, 0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d, 0xa0, 0xeb, - 0x46, 0x73, 0x8e, 0x5d, 0x3d, 0xd0, 0x11, 0xf7, 0xaf, 0x48, 0x98, 0x4e, 0x5a, 0x9a, 0x31, 0x09, - 0x94, 0x84, 0xfc, 0x69, 0x82, 0x1b, 0x0d, 0xde, 0x39, 0x96, 0x6d, 0x9f, 0x88, 0x34, 0xed, 0x6b, - 0x50, 0x48, 0xa8, 0x3a, 0xe9, 0x3d, 0x67, 0xf9, 0x03, 0x94, 0x8a, 0x36, 0x53, 0x96, 0xd5, 0x00, - 0xb9, 0x68, 0x06, 0xf5, 0x78, 0xb9, 0xcb, 0xcf, 0x99, 0x31, 0x8f, 0x26, 0xb9, 0x56, 0x38, 0xbf, - 0x2c, 0x1b, 0xa3, 0xcb, 0xb2, 0xd9, 0x8c, 0x65, 0xaa, 0x85, 0xaf, 0xa7, 0x65, 0x23, 0x3a, 0x74, - 0xed, 0xf0, 0x7c, 0x6c, 0x9b, 0xa3, 0xb1, 0x6d, 0xfe, 0x19, 0xdb, 0xe6, 0xf7, 0x89, 0x6d, 0x8c, - 0x26, 0xb6, 0xf1, 0x7b, 0x62, 0x1b, 0x9f, 0x1f, 0xae, 0xbc, 0x8c, 0xd9, 0x97, 0xb5, 0x9d, 0x8f, - 0x5f, 0x9b, 0xbd, 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x57, 0xb9, 0x47, 0x37, 0x70, 0x05, 0x00, - 0x00, + // 850 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x56, 0xcf, 0x8e, 0xdb, 0x44, + 0x18, 0xb7, 0x69, 0xba, 0x1b, 0x4d, 0x0b, 0x94, 0x11, 0x65, 0xa3, 0x80, 0x92, 0x92, 0x42, 0xc5, + 0x1f, 0xc5, 0x6e, 0x69, 0xa1, 0x6d, 0x2e, 0xa5, 0x09, 0x8b, 0x82, 0xc4, 0xa2, 0x55, 0x16, 0x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, 0xc4, 0x3f, 0xc8, 0x78, 0x25, 0x43, 0x88, 0x6a, 0xd5, 0xd1, + 0x93, 0xb3, 0x93, 0xe1, 0xc3, 0x6b, 0x7a, 0xad, 0xf8, 0x68, 0x16, 0xc7, 0x44, 0xb6, 0xd8, 0x78, + 0x72, 0x7a, 0xd9, 0xd3, 0xcf, 0x2f, 0x7b, 0xfa, 0xbf, 0x97, 0x3d, 0xfd, 0xe8, 0xaa, 0xa7, 0x9d, + 0x5f, 0xf5, 0xb4, 0x7f, 0xae, 0x7a, 0xda, 0x0f, 0x1f, 0x6e, 0x94, 0x2c, 0xff, 0x11, 0x99, 0x6f, + 0x89, 0xef, 0xe3, 0xe3, 0xff, 0x03, 0x00, 0x00, 0xff, 0xff, 0x17, 0x2b, 0x3f, 0x40, 0x9f, 0x08, + 0x00, 0x00, } func (this *Supply) Equal(that interface{}) bool { @@ -624,6 +820,65 @@ func (this *Evidence) SetEvidence(value github_com_cosmos_cosmos_sdk_x_evidence_ return fmt.Errorf("can't encode value of type %T as message Evidence", value) } +func (this *Content) GetContent() github_com_cosmos_cosmos_sdk_x_gov_types.Content { + if x := this.GetText(); x != nil { + return x + } + if x := this.GetParameterChange(); x != nil { + return x + } + if x := this.GetSoftwareUpgrade(); x != nil { + return x + } + if x := this.GetCancelSoftwareUpgrade(); x != nil { + return x + } + if x := this.GetCommunityPoolSpend(); x != nil { + return x + } + return nil +} + +func (this *Content) SetContent(value github_com_cosmos_cosmos_sdk_x_gov_types.Content) error { + if value == nil { + this.Sum = nil + return nil + } + switch vt := value.(type) { + case *types4.TextProposal: + this.Sum = &Content_Text{vt} + return nil + case types4.TextProposal: + this.Sum = &Content_Text{&vt} + return nil + case *proposal.ParameterChangeProposal: + this.Sum = &Content_ParameterChange{vt} + return nil + case proposal.ParameterChangeProposal: + this.Sum = &Content_ParameterChange{&vt} + return nil + case *types5.SoftwareUpgradeProposal: + this.Sum = &Content_SoftwareUpgrade{vt} + return nil + case types5.SoftwareUpgradeProposal: + this.Sum = &Content_SoftwareUpgrade{&vt} + return nil + case *types5.CancelSoftwareUpgradeProposal: + this.Sum = &Content_CancelSoftwareUpgrade{vt} + return nil + case types5.CancelSoftwareUpgradeProposal: + this.Sum = &Content_CancelSoftwareUpgrade{&vt} + return nil + case *types6.CommunityPoolSpendProposal: + this.Sum = &Content_CommunityPoolSpend{vt} + return nil + case types6.CommunityPoolSpendProposal: + this.Sum = &Content_CommunityPoolSpend{&vt} + return nil + } + return fmt.Errorf("can't encode value of type %T as message Content", value) +} + func (m *Account) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -912,6 +1167,186 @@ func (m *MsgSubmitEvidence) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *Proposal) 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 *Proposal) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Proposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Content.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintCodec(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size, err := m.ProposalBase.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintCodec(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *Content) 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 *Content) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Content) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Sum != nil { + { + size := m.Sum.Size() + i -= size + if _, err := m.Sum.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + } + } + return len(dAtA) - i, nil +} + +func (m *Content_Text) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Content_Text) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.Text != nil { + { + size, err := m.Text.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintCodec(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} +func (m *Content_ParameterChange) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Content_ParameterChange) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.ParameterChange != nil { + { + size, err := m.ParameterChange.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintCodec(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + return len(dAtA) - i, nil +} +func (m *Content_SoftwareUpgrade) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Content_SoftwareUpgrade) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.SoftwareUpgrade != nil { + { + size, err := m.SoftwareUpgrade.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintCodec(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + return len(dAtA) - i, nil +} +func (m *Content_CancelSoftwareUpgrade) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Content_CancelSoftwareUpgrade) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.CancelSoftwareUpgrade != nil { + { + size, err := m.CancelSoftwareUpgrade.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintCodec(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + return len(dAtA) - i, nil +} +func (m *Content_CommunityPoolSpend) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Content_CommunityPoolSpend) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.CommunityPoolSpend != nil { + { + size, err := m.CommunityPoolSpend.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintCodec(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + return len(dAtA) - i, nil +} func encodeVarintCodec(dAtA []byte, offset int, v uint64) int { offset -= sovCodec(v) base := offset @@ -1058,6 +1493,92 @@ func (m *MsgSubmitEvidence) Size() (n int) { return n } +func (m *Proposal) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.ProposalBase.Size() + n += 1 + l + sovCodec(uint64(l)) + l = m.Content.Size() + n += 1 + l + sovCodec(uint64(l)) + return n +} + +func (m *Content) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Sum != nil { + n += m.Sum.Size() + } + return n +} + +func (m *Content_Text) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Text != nil { + l = m.Text.Size() + n += 1 + l + sovCodec(uint64(l)) + } + return n +} +func (m *Content_ParameterChange) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ParameterChange != nil { + l = m.ParameterChange.Size() + n += 1 + l + sovCodec(uint64(l)) + } + return n +} +func (m *Content_SoftwareUpgrade) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.SoftwareUpgrade != nil { + l = m.SoftwareUpgrade.Size() + n += 1 + l + sovCodec(uint64(l)) + } + return n +} +func (m *Content_CancelSoftwareUpgrade) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.CancelSoftwareUpgrade != nil { + l = m.CancelSoftwareUpgrade.Size() + n += 1 + l + sovCodec(uint64(l)) + } + return n +} +func (m *Content_CommunityPoolSpend) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.CommunityPoolSpend != nil { + l = m.CommunityPoolSpend.Size() + n += 1 + l + sovCodec(uint64(l)) + } + return n +} + func sovCodec(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1590,6 +2111,353 @@ func (m *MsgSubmitEvidence) Unmarshal(dAtA []byte) error { } return nil } +func (m *Proposal) 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 ErrIntOverflowCodec + } + 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: Proposal: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Proposal: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProposalBase", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCodec + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthCodec + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthCodec + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ProposalBase.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Content", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCodec + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthCodec + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthCodec + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Content.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipCodec(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthCodec + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthCodec + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Content) 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 ErrIntOverflowCodec + } + 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: Content: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Content: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Text", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCodec + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthCodec + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthCodec + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &types4.TextProposal{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Sum = &Content_Text{v} + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ParameterChange", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCodec + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthCodec + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthCodec + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &proposal.ParameterChangeProposal{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Sum = &Content_ParameterChange{v} + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SoftwareUpgrade", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCodec + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthCodec + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthCodec + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &types5.SoftwareUpgradeProposal{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Sum = &Content_SoftwareUpgrade{v} + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CancelSoftwareUpgrade", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCodec + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthCodec + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthCodec + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &types5.CancelSoftwareUpgradeProposal{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Sum = &Content_CancelSoftwareUpgrade{v} + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CommunityPoolSpend", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCodec + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthCodec + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthCodec + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &types6.CommunityPoolSpendProposal{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Sum = &Content_CommunityPoolSpend{v} + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipCodec(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthCodec + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthCodec + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipCodec(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/simapp/codec/codec.proto b/simapp/codec/codec.proto index 2b68c487a..bfa556004 100644 --- a/simapp/codec/codec.proto +++ b/simapp/codec/codec.proto @@ -7,6 +7,10 @@ import "x/auth/types/types.proto"; import "x/auth/vesting/types/types.proto"; import "x/supply/types/types.proto"; import "x/evidence/types/types.proto"; +import "x/gov/types/types.proto"; +import "x/params/types/proposal/types.proto"; +import "x/upgrade/types/types.proto"; +import "x/distribution/types/types.proto"; option go_package = "github.com/cosmos/cosmos-sdk/simapp/codec"; @@ -56,3 +60,24 @@ message MsgSubmitEvidence { Evidence evidence = 1; cosmos_sdk.x.evidence.v1.MsgSubmitEvidenceBase base = 2 [(gogoproto.nullable) = false, (gogoproto.embed) = true]; } + +// Proposal defines the application-level concrete proposal type used in governance +// proposals. +message Proposal { + cosmos_sdk.x.gov.v1.ProposalBase base = 1 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; + Content content = 2 [(gogoproto.nullable) = false]; +} + +// Content defines the application-level allowed Content to be included in a +// governance proposal. +message Content { + option (cosmos_proto.interface_type) = "github.com/cosmos/cosmos-sdk/x/gov/types.Content"; + + oneof sum { + cosmos_sdk.x.gov.v1.TextProposal text = 1; + cosmos_sdk.x.params.v1.ParameterChangeProposal parameter_change = 2; + cosmos_sdk.x.upgrade.v1.SoftwareUpgradeProposal software_upgrade = 3; + cosmos_sdk.x.upgrade.v1.CancelSoftwareUpgradeProposal cancel_software_upgrade = 4; + cosmos_sdk.x.distribution.v1.CommunityPoolSpendProposal community_pool_spend = 5; + } +} diff --git a/x/gov/alias.go b/x/gov/alias.go index df5f2cb9c..c1f0a9808 100644 --- a/x/gov/alias.go +++ b/x/gov/alias.go @@ -152,4 +152,5 @@ type ( Vote = types.Vote Votes = types.Votes VoteOption = types.VoteOption + Codec = types.Codec ) diff --git a/x/gov/types/codec.go b/x/gov/types/codec.go index a02491a12..a892ddecd 100644 --- a/x/gov/types/codec.go +++ b/x/gov/types/codec.go @@ -8,8 +8,8 @@ import ( type Codec interface { codec.Marshaler - MarshalProposal(p Proposal) ([]byte, error) - UnmarshalProposal(bz []byte, ptr *Proposal) error + MarshalProposal(Proposal) ([]byte, error) + UnmarshalProposal([]byte) (Proposal, error) } // RegisterCodec registers all the necessary types and interfaces for the diff --git a/x/gov/types/proposal.go b/x/gov/types/proposal.go index 15d23ddf7..c67363f93 100644 --- a/x/gov/types/proposal.go +++ b/x/gov/types/proposal.go @@ -6,6 +6,8 @@ import ( "strings" "time" + "gopkg.in/yaml.v2" + sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) @@ -37,20 +39,8 @@ func NewProposal(content Content, id uint64, submitTime, depositEndTime time.Tim // String implements stringer interface func (p Proposal) String() string { - return fmt.Sprintf(`Proposal %d: - Title: %s - Type: %s - Status: %s - Submit Time: %s - Deposit End Time: %s - Total Deposit: %s - Voting Start Time: %s - Voting End Time: %s - Description: %s`, - p.ProposalID, p.GetTitle(), p.ProposalType(), - p.Status, p.SubmitTime, p.DepositEndTime, - p.TotalDeposit, p.VotingStartTime, p.VotingEndTime, p.GetDescription(), - ) + out, _ := yaml.Marshal(p) + return string(out) } // Proposals is an array of proposal diff --git a/x/gov/types/types.proto b/x/gov/types/types.proto index d590397ca..b22abea1e 100644 --- a/x/gov/types/types.proto +++ b/x/gov/types/types.proto @@ -3,7 +3,6 @@ package cosmos_sdk.x.gov.v1; import "types/types.proto"; import "third_party/proto/gogoproto/gogo.proto"; -// import "third_party/proto/cosmos-proto/cosmos.proto"; import "google/protobuf/timestamp.proto"; option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types"; @@ -133,16 +132,3 @@ message Vote { bytes voter = 2 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; VoteOption option = 3; } - -// message BasicProposal { -// ProposalBase base = 1 [(gogoproto.embed) = true]; -// BasicContent content = 2; -// } - -// message BasicContent { -// option (cosmos_proto.interface_type) = "Content"; -// option (gogoproto.stringer) = true; -// oneof sum { -// TextProposal text = 1; -// } -// }