From 0ee0f87bf11e38ae6ec2ae0bb809590765d52825 Mon Sep 17 00:00:00 2001 From: scorpioborn <97235353+scorpioborn@users.noreply.github.com> Date: Thu, 2 Nov 2023 11:22:24 +0300 Subject: [PATCH] feat: add context property to wager ticket --- proto/sge/bet/ticket.proto | 2 + x/bet/types/ticket.pb.go | 97 +++++++++++++++++++++++++++++--------- 2 files changed, 77 insertions(+), 22 deletions(-) diff --git a/proto/sge/bet/ticket.proto b/proto/sge/bet/ticket.proto index 805004ab..b6248b4f 100644 --- a/proto/sge/bet/ticket.proto +++ b/proto/sge/bet/ticket.proto @@ -20,4 +20,6 @@ message WagerTicketPayload { repeated BetOddsCompact all_odds = 3; // meta is metadata for bet placement MetaData meta = 4 [ (gogoproto.nullable) = false ]; + // context contains the data from services and just for processing purpose. + string context = 5; } diff --git a/x/bet/types/ticket.pb.go b/x/bet/types/ticket.pb.go index 65c6dd6a..2f8899a2 100644 --- a/x/bet/types/ticket.pb.go +++ b/x/bet/types/ticket.pb.go @@ -34,6 +34,8 @@ type WagerTicketPayload struct { AllOdds []*BetOddsCompact `protobuf:"bytes,3,rep,name=all_odds,json=allOdds,proto3" json:"all_odds,omitempty"` // meta is metadata for bet placement Meta MetaData `protobuf:"bytes,4,opt,name=meta,proto3" json:"meta"` + // context contains the data from services and just for processing purpose. + Context string `protobuf:"bytes,5,opt,name=context,proto3" json:"context,omitempty"` } func (m *WagerTicketPayload) Reset() { *m = WagerTicketPayload{} } @@ -97,6 +99,13 @@ func (m *WagerTicketPayload) GetMeta() MetaData { return MetaData{} } +func (m *WagerTicketPayload) GetContext() string { + if m != nil { + return m.Context + } + return "" +} + func init() { proto.RegisterType((*WagerTicketPayload)(nil), "sgenetwork.sge.bet.WagerTicketPayload") } @@ -104,28 +113,29 @@ func init() { func init() { proto.RegisterFile("sge/bet/ticket.proto", fileDescriptor_cf6959e7db451613) } var fileDescriptor_cf6959e7db451613 = []byte{ - // 323 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 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, 0x44, 0xa9, 0x98, 0x4a, 0x20, 0x68, - 0x57, 0xac, 0xf9, 0xe8, 0xa7, 0x39, 0xa7, 0x66, 0x97, 0xa9, 0x18, 0x03, 0x41, 0x59, 0x3c, 0xaa, - 0x2d, 0x3f, 0x0e, 0x9d, 0x49, 0x3d, 0x2a, 0x54, 0xff, 0xdc, 0x6b, 0x40, 0x1c, 0x17, 0x08, 0xd5, - 0x6e, 0xb5, 0xdf, 0x1c, 0xf4, 0xfe, 0x41, 0xb8, 0xd0, 0xf3, 0x04, 0x04, 0x4d, 0xea, 0x10, 0xc7, - 0x16, 0xe2, 0xcc, 0xab, 0xcd, 0x91, 0xa0, 0x5d, 0xb3, 0x00, 0x07, 0x7f, 0x59, 0xaf, 0x90, 0x20, - 0xaf, 0x2a, 0x9b, 0xed, 0xfe, 0x68, 0xb8, 0x5c, 0x07, 0xee, 0x6a, 0x1d, 0xb8, 0x9f, 0xeb, 0xc0, - 0x7d, 0xcd, 0x02, 0x67, 0x95, 0x05, 0xce, 0x7b, 0x16, 0x38, 0xf7, 0xc7, 0x6a, 0x46, 0x0f, 0x4f, - 0x21, 0x13, 0x7a, 0xce, 0x8d, 0xc2, 0x93, 0x32, 0x2e, 0x9f, 0xf9, 0x4b, 0xf1, 0x8f, 0x69, 0x82, - 0x26, 0xdc, 0xb2, 0xcf, 0x7b, 0xfa, 0x15, 0x00, 0x00, 0xff, 0xff, 0xd3, 0x0b, 0xeb, 0xe7, 0xdf, - 0x01, 0x00, 0x00, + // 342 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x91, 0xc1, 0x4a, 0xeb, 0x40, + 0x14, 0x86, 0x93, 0xb6, 0xf7, 0xb6, 0x37, 0xbd, 0x2e, 0x1c, 0x8a, 0x84, 0x2a, 0xb1, 0x54, 0x90, + 0x6e, 0x9c, 0x81, 0x0a, 0xee, 0x84, 0x52, 0xbb, 0x13, 0x51, 0x82, 0x20, 0xb8, 0x29, 0x93, 0x99, + 0xc3, 0x58, 0x92, 0x76, 0x42, 0xe7, 0x88, 0xcd, 0x5b, 0xf8, 0x22, 0xbe, 0x47, 0x97, 0x5d, 0xba, + 0x12, 0x69, 0x5f, 0x44, 0x32, 0x49, 0x41, 0x54, 0xdc, 0x9d, 0xf3, 0xe7, 0xff, 0xcf, 0xff, 0x91, + 0xf1, 0x5a, 0x46, 0x01, 0x8b, 0x00, 0x19, 0x4e, 0x44, 0x0c, 0x48, 0xd3, 0xb9, 0x46, 0x4d, 0x88, + 0x51, 0x30, 0x03, 0x7c, 0xd2, 0xf3, 0x98, 0x1a, 0x05, 0x34, 0x02, 0x6c, 0xb7, 0x94, 0x56, 0xda, + 0x7e, 0x66, 0xf9, 0x54, 0x38, 0xdb, 0xb9, 0x93, 0x61, 0x96, 0x02, 0x8b, 0x33, 0x51, 0x6a, 0x7b, + 0xdb, 0x9b, 0x11, 0xe0, 0x58, 0x4b, 0x69, 0x4a, 0x7d, 0xf7, 0x93, 0x5e, 0x48, 0xdd, 0x97, 0x8a, + 0x47, 0xee, 0xb8, 0x82, 0xf9, 0xad, 0xad, 0xbf, 0xe1, 0x59, 0xa2, 0xb9, 0x24, 0x03, 0x6f, 0xc7, + 0x40, 0x02, 0x02, 0x41, 0xda, 0x03, 0xbe, 0xdb, 0x71, 0x7b, 0xcd, 0xfe, 0x3e, 0xfd, 0xce, 0x45, + 0x87, 0x80, 0xd7, 0x52, 0x9a, 0xf0, 0xff, 0x36, 0x91, 0x6f, 0x64, 0xe4, 0x35, 0xe2, 0x4c, 0x8c, + 0x25, 0x47, 0xee, 0x57, 0x6c, 0xf8, 0xe8, 0x6b, 0x38, 0xa7, 0xa6, 0x97, 0x99, 0x18, 0x71, 0xe4, + 0x65, 0xf1, 0xb0, 0xb6, 0x7c, 0x3b, 0x74, 0xc2, 0x7a, 0x5c, 0xa8, 0xe4, 0xdc, 0x6b, 0xf0, 0x24, + 0x29, 0x10, 0xaa, 0x9d, 0x6a, 0xaf, 0xd9, 0xef, 0xfe, 0x82, 0x70, 0xa1, 0xa7, 0x29, 0x17, 0x18, + 0xd6, 0x79, 0x92, 0x58, 0x88, 0x33, 0xaf, 0x36, 0x05, 0xe4, 0x7e, 0xcd, 0x02, 0x1c, 0xfc, 0x14, + 0xbd, 0x02, 0xe4, 0x79, 0x55, 0xd9, 0x6c, 0xfd, 0xc4, 0xf7, 0xea, 0x42, 0xcf, 0x10, 0x16, 0xe8, + 0xff, 0xe9, 0xb8, 0xbd, 0x7f, 0xe1, 0x76, 0x1d, 0x0e, 0x96, 0xeb, 0xc0, 0x5d, 0xad, 0x03, 0xf7, + 0x7d, 0x1d, 0xb8, 0xcf, 0x9b, 0xc0, 0x59, 0x6d, 0x02, 0xe7, 0x75, 0x13, 0x38, 0xf7, 0xc7, 0x6a, + 0x82, 0x0f, 0x8f, 0x11, 0x15, 0x7a, 0xca, 0x8c, 0x82, 0x93, 0xb2, 0x28, 0x9f, 0xd9, 0xa2, 0x78, + 0xe1, 0x2c, 0x05, 0x13, 0xfd, 0xb5, 0x3f, 0xfe, 0xf4, 0x23, 0x00, 0x00, 0xff, 0xff, 0xc2, 0xdc, + 0x4c, 0xef, 0xf9, 0x01, 0x00, 0x00, } func (m *WagerTicketPayload) Marshal() (dAtA []byte, err error) { @@ -148,6 +158,13 @@ func (m *WagerTicketPayload) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.Context) > 0 { + i -= len(m.Context) + copy(dAtA[i:], m.Context) + i = encodeVarintTicket(dAtA, i, uint64(len(m.Context))) + i-- + dAtA[i] = 0x2a + } { size, err := m.Meta.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -228,6 +245,10 @@ func (m *WagerTicketPayload) Size() (n int) { } l = m.Meta.Size() n += 1 + l + sovTicket(uint64(l)) + l = len(m.Context) + if l > 0 { + n += 1 + l + sovTicket(uint64(l)) + } return n } @@ -402,6 +423,38 @@ func (m *WagerTicketPayload) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Context", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTicket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTicket + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTicket + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Context = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTicket(dAtA[iNdEx:])