From 14e4eb9347773a57d59e5ec89fc88bc07535dff9 Mon Sep 17 00:00:00 2001 From: waaiifu Date: Fri, 27 Oct 2023 18:29:55 +0530 Subject: [PATCH 01/17] Adds Selected Odds in Bet Meta --- proto/sge/bet/bet.proto | 8 + proto/sge/bet/ticket.proto | 3 + x/bet/types/bet.pb.go | 382 +++++++++++++++++++++++++++++++------ x/bet/types/ticket.pb.go | 107 ++++++++--- 4 files changed, 422 insertions(+), 78 deletions(-) diff --git a/proto/sge/bet/bet.proto b/proto/sge/bet/bet.proto index a5036f32..1b0fddaf 100644 --- a/proto/sge/bet/bet.proto +++ b/proto/sge/bet/bet.proto @@ -74,6 +74,9 @@ message Bet { // bet_fulfillment is the fulfillment data. repeated BetFulfillment bet_fulfillment = 14; + // meta is metadata for bet + MetaData meta = 15; + // Status of the Bet. enum Status { // the invalid or unknown @@ -174,3 +177,8 @@ message BetFulfillment { (gogoproto.moretags) = "yaml:\"payout_profit\"" ]; } + +message MetaData { + sgenetwork.sge.bet.OddsType selected_odds_type = 1; + string selected_odds_value = 2; +} diff --git a/proto/sge/bet/ticket.proto b/proto/sge/bet/ticket.proto index 8d2519de..b14809a9 100644 --- a/proto/sge/bet/ticket.proto +++ b/proto/sge/bet/ticket.proto @@ -5,6 +5,7 @@ package sgenetwork.sge.bet; import "gogoproto/gogo.proto"; import "sge/type/kyc.proto"; import "sge/bet/bet_odds.proto"; +import "sge/bet/bet.proto"; import "sge/bet/odds_type.proto"; option go_package = "github.com/sge-network/sge/x/bet/types"; @@ -21,4 +22,6 @@ message WagerTicketPayload { sgenetwork.sge.bet.OddsType odds_type = 3; // all odds for the selected market. repeated BetOddsCompact all_odds = 4; + // meta is metadata for bet placement + MetaData meta = 5; } diff --git a/x/bet/types/bet.pb.go b/x/bet/types/bet.pb.go index 32f77381..2be1106a 100644 --- a/x/bet/types/bet.pb.go +++ b/x/bet/types/bet.pb.go @@ -145,6 +145,8 @@ type Bet struct { MaxLossMultiplier github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,13,opt,name=max_loss_multiplier,json=maxLossMultiplier,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"max_loss_multiplier"` // bet_fulfillment is the fulfillment data. BetFulfillment []*BetFulfillment `protobuf:"bytes,14,rep,name=bet_fulfillment,json=betFulfillment,proto3" json:"bet_fulfillment,omitempty"` + // meta is metadata for bet + Meta *MetaData `protobuf:"bytes,15,opt,name=meta,proto3" json:"meta,omitempty"` } func (m *Bet) Reset() { *m = Bet{} } @@ -257,6 +259,13 @@ func (m *Bet) GetBetFulfillment() []*BetFulfillment { return nil } +func (m *Bet) GetMeta() *MetaData { + if m != nil { + return m.Meta + } + return nil +} + // UID2ID is the type for mapping UIDs and Sequential IDs of bets. type UID2ID struct { // uid is the universal unique identifier assigned to the bet. @@ -486,6 +495,58 @@ func (m *BetFulfillment) GetParticipationIndex() uint64 { return 0 } +type MetaData struct { + SelectedOddsType OddsType `protobuf:"varint,1,opt,name=selected_odds_type,json=selectedOddsType,proto3,enum=sgenetwork.sge.bet.OddsType" json:"selected_odds_type,omitempty"` + SelectedOddsValue string `protobuf:"bytes,2,opt,name=selected_odds_value,json=selectedOddsValue,proto3" json:"selected_odds_value,omitempty"` +} + +func (m *MetaData) Reset() { *m = MetaData{} } +func (m *MetaData) String() string { return proto.CompactTextString(m) } +func (*MetaData) ProtoMessage() {} +func (*MetaData) Descriptor() ([]byte, []int) { + return fileDescriptor_9bc076bb1a4d9f6e, []int{5} +} +func (m *MetaData) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MetaData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MetaData.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 *MetaData) XXX_Merge(src proto.Message) { + xxx_messageInfo_MetaData.Merge(m, src) +} +func (m *MetaData) XXX_Size() int { + return m.Size() +} +func (m *MetaData) XXX_DiscardUnknown() { + xxx_messageInfo_MetaData.DiscardUnknown(m) +} + +var xxx_messageInfo_MetaData proto.InternalMessageInfo + +func (m *MetaData) GetSelectedOddsType() OddsType { + if m != nil { + return m.SelectedOddsType + } + return OddsType_ODDS_TYPE_UNSPECIFIED +} + +func (m *MetaData) GetSelectedOddsValue() string { + if m != nil { + return m.SelectedOddsValue + } + return "" +} + func init() { proto.RegisterEnum("sgenetwork.sge.bet.Bet_Status", Bet_Status_name, Bet_Status_value) proto.RegisterEnum("sgenetwork.sge.bet.Bet_Result", Bet_Result_name, Bet_Result_value) @@ -494,67 +555,72 @@ func init() { proto.RegisterType((*PendingBet)(nil), "sgenetwork.sge.bet.PendingBet") proto.RegisterType((*SettledBet)(nil), "sgenetwork.sge.bet.SettledBet") proto.RegisterType((*BetFulfillment)(nil), "sgenetwork.sge.bet.BetFulfillment") + proto.RegisterType((*MetaData)(nil), "sgenetwork.sge.bet.MetaData") } func init() { proto.RegisterFile("sge/bet/bet.proto", fileDescriptor_9bc076bb1a4d9f6e) } var fileDescriptor_9bc076bb1a4d9f6e = []byte{ - // 879 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0x4f, 0x6f, 0xe2, 0x46, - 0x14, 0x8f, 0x71, 0x96, 0x84, 0x97, 0x84, 0x98, 0xc9, 0x6a, 0xd7, 0x4a, 0xb7, 0x80, 0x2c, 0xb5, - 0x8a, 0x54, 0x2d, 0x48, 0x59, 0xa9, 0x52, 0xdb, 0xcb, 0x02, 0x36, 0x0d, 0x2a, 0x0b, 0x68, 0x80, - 0x56, 0xea, 0xa1, 0x96, 0xc1, 0x13, 0xe2, 0xc6, 0x7f, 0x90, 0x67, 0xdc, 0x26, 0xe7, 0x7e, 0x80, - 0xf6, 0x23, 0xf4, 0xe3, 0xec, 0x71, 0x8f, 0x55, 0x0f, 0x56, 0x45, 0x6e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4, 0x2d, 0xb5, 0xbb, 0x8f, 0x4e, 0xf3, 0xf4, 0xf6, 0x72, 0x39, 0x33, 0x03, 0xef, 0x67, 0xeb, - 0x91, 0x58, 0xb6, 0x5f, 0xbf, 0x5d, 0x55, 0x95, 0x77, 0xab, 0xaa, 0xf2, 0xd7, 0xaa, 0xaa, 0xfc, - 0x76, 0x53, 0xdd, 0x7a, 0x77, 0x53, 0xdd, 0xfa, 0xe3, 0xa6, 0xba, 0xf5, 0x7d, 0x3e, 0x0f, 0x5d, - 0x90, 0x97, 0xf2, 0x8f, 0xcd, 0xe3, 0xe6, 0x95, 0x78, 0x9d, 0x89, 0x5c, 0xb3, 0xa2, 0x78, 0x97, - 0xbd, 0xfa, 0x27, 0x00, 0x00, 0xff, 0xff, 0xfa, 0xa0, 0x08, 0x67, 0x23, 0x07, 0x00, 0x00, + // 943 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0x41, 0x6f, 0xe2, 0x46, + 0x14, 0x8e, 0x71, 0x96, 0x84, 0x97, 0x84, 0x98, 0xc9, 0x6a, 0xd7, 0x4a, 0xb7, 0x80, 0x2c, 0xb5, + 0x42, 0xaa, 0xd6, 0x54, 0x59, 0xa9, 0x52, 0xdb, 0xcb, 0x02, 0x36, 0x0d, 0x2d, 0x01, 0x34, 0x40, + 0x2b, 0xf5, 0x50, 0xcb, 0xe0, 0x09, 0x71, 0x63, 0x63, 0xe4, 0x19, 0xda, 0xe4, 0x5c, 0xa9, 0xe7, + 0xfe, 0x84, 0xfe, 0x95, 0xde, 0xf6, 0xb8, 0xc7, 0xaa, 0x07, 0x54, 0x91, 0x5b, 0x8f, 0xfb, 0x0b, + 0xaa, 0x19, 0x0f, 0x60, 0xd4, 0xb4, 0x4a, 0x7a, 0x00, 0xcf, 0x7c, 0xf3, 0x7d, 0xdf, 0x9b, 0x37, + 0x7e, 0x7e, 0x03, 0x05, 0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, 0xf3, 0x74, + 0x95, 0x5c, 0xca, 0xcc, 0xc0, 0x87, 0xc9, 0xbc, 0x97, 0x4c, 0x7f, 0x56, 0x60, 0x7f, 0xf5, 0x49, + 0xa2, 0x2f, 0x01, 0x51, 0x12, 0x90, 0x31, 0x6f, 0x5c, 0x9b, 0xeb, 0x42, 0x79, 0xc0, 0x75, 0xa1, + 0xad, 0x74, 0x2b, 0x04, 0x99, 0x70, 0xb2, 0xed, 0x95, 0xdc, 0x1f, 0x49, 0x29, 0x14, 0xd2, 0x74, + 0x71, 0x8f, 0xd4, 0x5f, 0xbf, 0x59, 0x16, 0x95, 0xb7, 0xcb, 0xa2, 0xf2, 0xe7, 0xb2, 0xa8, 0xfc, + 0x72, 0x57, 0xdc, 0x79, 0x7b, 0x57, 0xdc, 0xf9, 0xfd, 0xae, 0xb8, 0xf3, 0x6d, 0x3a, 0x61, 0x3a, + 0x21, 0x2f, 0xe5, 0x26, 0xf8, 0xb8, 0x7a, 0x23, 0x6e, 0x62, 0x91, 0xf4, 0x28, 0x2b, 0xae, 0xe1, + 0x57, 0x7f, 0x07, 0x00, 0x00, 0xff, 0xff, 0x4c, 0x3e, 0x67, 0x68, 0xde, 0x07, 0x00, 0x00, } func (m *Bet) Marshal() (dAtA []byte, err error) { @@ -577,6 +643,18 @@ func (m *Bet) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.Meta != nil { + { + size, err := m.Meta.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintBet(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x7a + } if len(m.BetFulfillment) > 0 { for iNdEx := len(m.BetFulfillment) - 1; iNdEx >= 0; iNdEx-- { { @@ -848,6 +926,41 @@ func (m *BetFulfillment) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *MetaData) 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 *MetaData) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MetaData) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.SelectedOddsValue) > 0 { + i -= len(m.SelectedOddsValue) + copy(dAtA[i:], m.SelectedOddsValue) + i = encodeVarintBet(dAtA, i, uint64(len(m.SelectedOddsValue))) + i-- + dAtA[i] = 0x12 + } + if m.SelectedOddsType != 0 { + i = encodeVarintBet(dAtA, i, uint64(m.SelectedOddsType)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func encodeVarintBet(dAtA []byte, offset int, v uint64) int { offset -= sovBet(v) base := offset @@ -912,6 +1025,10 @@ func (m *Bet) Size() (n int) { n += 1 + l + sovBet(uint64(l)) } } + if m.Meta != nil { + l = m.Meta.Size() + n += 1 + l + sovBet(uint64(l)) + } return n } @@ -985,6 +1102,22 @@ func (m *BetFulfillment) Size() (n int) { return n } +func (m *MetaData) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.SelectedOddsType != 0 { + n += 1 + sovBet(uint64(m.SelectedOddsType)) + } + l = len(m.SelectedOddsValue) + if l > 0 { + n += 1 + l + sovBet(uint64(l)) + } + return n +} + func sovBet(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1411,6 +1544,42 @@ func (m *Bet) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 15: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Meta", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBet + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthBet + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthBet + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Meta == nil { + m.Meta = &MetaData{} + } + if err := m.Meta.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipBet(dAtA[iNdEx:]) @@ -1930,6 +2099,107 @@ func (m *BetFulfillment) Unmarshal(dAtA []byte) error { } return nil } +func (m *MetaData) 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 ErrIntOverflowBet + } + 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: MetaData: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MetaData: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SelectedOddsType", wireType) + } + m.SelectedOddsType = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBet + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SelectedOddsType |= OddsType(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SelectedOddsValue", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBet + } + 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 ErrInvalidLengthBet + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthBet + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SelectedOddsValue = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipBet(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthBet + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipBet(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/bet/types/ticket.pb.go b/x/bet/types/ticket.pb.go index 1cde4404..0e0145f0 100644 --- a/x/bet/types/ticket.pb.go +++ b/x/bet/types/ticket.pb.go @@ -35,6 +35,8 @@ type WagerTicketPayload struct { OddsType OddsType `protobuf:"varint,3,opt,name=odds_type,json=oddsType,proto3,enum=sgenetwork.sge.bet.OddsType" json:"odds_type,omitempty"` // all odds for the selected market. AllOdds []*BetOddsCompact `protobuf:"bytes,4,rep,name=all_odds,json=allOdds,proto3" json:"all_odds,omitempty"` + // meta is metadata for bet placement + Meta *MetaData `protobuf:"bytes,5,opt,name=meta,proto3" json:"meta,omitempty"` } func (m *WagerTicketPayload) Reset() { *m = WagerTicketPayload{} } @@ -98,6 +100,13 @@ func (m *WagerTicketPayload) GetAllOdds() []*BetOddsCompact { return nil } +func (m *WagerTicketPayload) GetMeta() *MetaData { + if m != nil { + return m.Meta + } + return nil +} + func init() { proto.RegisterType((*WagerTicketPayload)(nil), "sgenetwork.sge.bet.WagerTicketPayload") } @@ -105,28 +114,30 @@ func init() { func init() { proto.RegisterFile("sge/bet/ticket.proto", fileDescriptor_cf6959e7db451613) } var fileDescriptor_cf6959e7db451613 = []byte{ - // 331 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x91, 0xbf, 0x4a, 0x03, 0x41, - 0x10, 0xc6, 0xef, 0x92, 0x60, 0xe2, 0x45, 0x2d, 0x96, 0xa0, 0x21, 0xca, 0x19, 0x22, 0x48, 0x1a, - 0x6f, 0x21, 0x56, 0x16, 0x42, 0x88, 0xe9, 0x2c, 0x94, 0x23, 0x20, 0xd8, 0x84, 0xbd, 0xdd, 0x61, - 0x0d, 0x77, 0x71, 0x8f, 0xec, 0x88, 0xee, 0x5b, 0x58, 0xf9, 0x4c, 0x29, 0x53, 0x5a, 0x89, 0x24, - 0x2f, 0x22, 0x7b, 0x7f, 0x2c, 0x54, 0xec, 0x66, 0xbe, 0x99, 0xef, 0x9b, 0x1f, 0xbb, 0x5e, 0x4b, - 0x4b, 0xa0, 0x11, 0x20, 0xc5, 0x19, 0x8f, 0x01, 0x83, 0x74, 0xa1, 0x50, 0x11, 0xa2, 0x25, 0x3c, - 0x02, 0x3e, 0xab, 0x45, 0x1c, 0x68, 0x09, 0x41, 0x04, 0xd8, 0x69, 0x49, 0x25, 0x55, 0x36, 0xa6, - 0xb6, 0xca, 0x37, 0x3b, 0x76, 0x93, 0xa2, 0x49, 0x81, 0xc6, 0x86, 0x17, 0xda, 0x7e, 0x99, 0x19, - 0x01, 0x4e, 0x95, 0x10, 0xba, 0xd0, 0x0f, 0x4a, 0xdd, 0x6a, 0x53, 0x6b, 0xca, 0x07, 0xbd, 0xb7, - 0x8a, 0x47, 0xee, 0x98, 0x84, 0xc5, 0x24, 0x83, 0xb8, 0x65, 0x26, 0x51, 0x4c, 0x90, 0xa1, 0xb7, - 0xab, 0x21, 0x01, 0x8e, 0x20, 0xb2, 0x98, 0xb6, 0xdb, 0x75, 0xfb, 0xcd, 0xc1, 0x61, 0xf0, 0x9b, - 0x2e, 0x18, 0x01, 0xde, 0x08, 0xa1, 0xc3, 0x9d, 0xd2, 0x61, 0x3b, 0x32, 0xf6, 0x1a, 0xb1, 0xe1, - 0x53, 0xc1, 0x90, 0xb5, 0x2b, 0x99, 0xf9, 0xe4, 0xa7, 0x39, 0xc3, 0xb8, 0x36, 0x7c, 0xcc, 0x90, - 0x15, 0x87, 0x47, 0xb5, 0xe5, 0xc7, 0xb1, 0x13, 0xd6, 0xe3, 0x5c, 0x25, 0x17, 0xde, 0xf6, 0x37, - 0x71, 0xbb, 0xda, 0x75, 0xfb, 0x7b, 0x83, 0xa3, 0xbf, 0x18, 0xec, 0xc9, 0x89, 0x49, 0x21, 0x6c, - 0xa8, 0xa2, 0x22, 0x97, 0x5e, 0x83, 0x25, 0x49, 0x4e, 0x5f, 0xeb, 0x56, 0xfb, 0xcd, 0x41, 0xef, - 0x1f, 0xfa, 0x2b, 0x35, 0x4f, 0x19, 0xc7, 0xb0, 0xce, 0x92, 0xc4, 0xf6, 0xa3, 0xe1, 0x72, 0xed, - 0xbb, 0xab, 0xb5, 0xef, 0x7e, 0xae, 0x7d, 0xf7, 0x75, 0xe3, 0x3b, 0xab, 0x8d, 0xef, 0xbc, 0x6f, - 0x7c, 0xe7, 0xfe, 0x54, 0xce, 0xf0, 0xe1, 0x29, 0x0a, 0xb8, 0x9a, 0x53, 0x2d, 0xe1, 0xac, 0x48, - 0xb4, 0x35, 0x7d, 0xc9, 0x3f, 0xd4, 0xa4, 0xa0, 0xa3, 0xad, 0xec, 0x85, 0xcf, 0xbf, 0x02, 0x00, - 0x00, 0xff, 0xff, 0x2c, 0x82, 0x98, 0x8e, 0xe8, 0x01, 0x00, 0x00, + // 354 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x92, 0xc1, 0x4a, 0xf3, 0x40, + 0x14, 0x85, 0x93, 0xb6, 0xff, 0xdf, 0x9a, 0xaa, 0x60, 0x28, 0x1a, 0xaa, 0xc4, 0x52, 0x41, 0xba, + 0x31, 0x91, 0xba, 0x72, 0x21, 0x94, 0xda, 0x9d, 0x88, 0x12, 0x0a, 0x82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d9, 0xf8, 0x22, 0xf6, 0xca, 0x2d, 0xbb, 0xb3, 0xdd, 0x3d, 0x58, 0xc7, 0xa0, + 0x2b, 0x87, 0x2a, 0x83, 0xa8, 0x26, 0x8a, 0xc9, 0xbd, 0x70, 0x6a, 0x24, 0x4d, 0x73, 0xfa, 0x4a, + 0xab, 0xdc, 0xa9, 0x77, 0xdb, 0x7f, 0xd0, 0x5f, 0x8a, 0x49, 0x46, 0x28, 0x46, 0x55, 0x92, 0xa6, + 0x86, 0xff, 0xd4, 0xa9, 0x4c, 0x00, 0x89, 0xf7, 0xcf, 0xb0, 0xaf, 0x2d, 0xbd, 0x06, 0x24, 0x9a, + 0x32, 0x32, 0xce, 0x7e, 0x6f, 0xb6, 0xf0, 0xed, 0xf9, 0xc2, 0xb7, 0x3f, 0x16, 0xbe, 0xfd, 0xba, + 0xf4, 0xad, 0xf9, 0xd2, 0xb7, 0xde, 0x96, 0xbe, 0x75, 0x7f, 0xcc, 0xc7, 0xf8, 0xf0, 0x14, 0x07, + 0x54, 0x4c, 0x42, 0xc9, 0xe1, 0xa4, 0x08, 0xd2, 0x73, 0xf8, 0x92, 0xbf, 0x0a, 0x95, 0x81, 0x8c, + 0xff, 0x9b, 0x7f, 0x72, 0xf6, 0x19, 0x00, 0x00, 0xff, 0xff, 0x95, 0x0c, 0x75, 0x47, 0x2d, 0x02, + 0x00, 0x00, } func (m *WagerTicketPayload) Marshal() (dAtA []byte, err error) { @@ -149,6 +160,18 @@ func (m *WagerTicketPayload) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.Meta != nil { + { + size, err := m.Meta.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTicket(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } if len(m.AllOdds) > 0 { for iNdEx := len(m.AllOdds) - 1; iNdEx >= 0; iNdEx-- { { @@ -225,6 +248,10 @@ func (m *WagerTicketPayload) Size() (n int) { n += 1 + l + sovTicket(uint64(l)) } } + if m.Meta != nil { + l = m.Meta.Size() + n += 1 + l + sovTicket(uint64(l)) + } return n } @@ -385,6 +412,42 @@ 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 Meta", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTicket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTicket + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTicket + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Meta == nil { + m.Meta = &MetaData{} + } + if err := m.Meta.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTicket(dAtA[iNdEx:]) From b99bb47c0c1865ec6580e6a73ee958bda8e7aff2 Mon Sep 17 00:00:00 2001 From: waaiifu Date: Fri, 27 Oct 2023 18:34:53 +0530 Subject: [PATCH 02/17] Adds comments --- proto/sge/bet/bet.proto | 3 +++ x/bet/types/bet.pb.go | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/proto/sge/bet/bet.proto b/proto/sge/bet/bet.proto index 1b0fddaf..17913c77 100644 --- a/proto/sge/bet/bet.proto +++ b/proto/sge/bet/bet.proto @@ -178,7 +178,10 @@ message BetFulfillment { ]; } +// metadata for bet message MetaData { + // selected_odds_type is metadata for bet sgenetwork.sge.bet.OddsType selected_odds_type = 1; + // selected_odds_value is metadata for bet string selected_odds_value = 2; } diff --git a/x/bet/types/bet.pb.go b/x/bet/types/bet.pb.go index 2be1106a..c5180a96 100644 --- a/x/bet/types/bet.pb.go +++ b/x/bet/types/bet.pb.go @@ -495,9 +495,12 @@ func (m *BetFulfillment) GetParticipationIndex() uint64 { return 0 } +// metadata for bet type MetaData struct { - SelectedOddsType OddsType `protobuf:"varint,1,opt,name=selected_odds_type,json=selectedOddsType,proto3,enum=sgenetwork.sge.bet.OddsType" json:"selected_odds_type,omitempty"` - SelectedOddsValue string `protobuf:"bytes,2,opt,name=selected_odds_value,json=selectedOddsValue,proto3" json:"selected_odds_value,omitempty"` + // selected_odds_type is metadata for bet + SelectedOddsType OddsType `protobuf:"varint,1,opt,name=selected_odds_type,json=selectedOddsType,proto3,enum=sgenetwork.sge.bet.OddsType" json:"selected_odds_type,omitempty"` + // selected_odds_value is metadata for bet + SelectedOddsValue string `protobuf:"bytes,2,opt,name=selected_odds_value,json=selectedOddsValue,proto3" json:"selected_odds_value,omitempty"` } func (m *MetaData) Reset() { *m = MetaData{} } From 599c8b4face6f62019a14e2a36eb226f1092e355 Mon Sep 17 00:00:00 2001 From: waaiifu Date: Fri, 27 Oct 2023 18:53:58 +0530 Subject: [PATCH 03/17] Changes for selected odds --- x/bet/keeper/msg_server_bet.go | 2 +- x/bet/simulation/decoder_test.go | 7 ++++++- x/bet/types/messages_bet.go | 3 ++- x/bet/types/messages_bet_test.go | 10 +++++++++- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/x/bet/keeper/msg_server_bet.go b/x/bet/keeper/msg_server_bet.go index c1ecc66d..47d1aad1 100644 --- a/x/bet/keeper/msg_server_bet.go +++ b/x/bet/keeper/msg_server_bet.go @@ -30,7 +30,7 @@ func (k msgServer) Wager( return nil, sdkerrors.Wrapf(types.ErrInTicketValidation, "%s", err) } - bet := types.NewBet(msg.Creator, msg.Props, payload.OddsType, payload.SelectedOdds) + bet := types.NewBet(msg.Creator, msg.Props, payload.OddsType, payload.SelectedOdds, payload.Meta) if err := k.Keeper.Wager(ctx, bet, payload.OddsMap()); err != nil { return nil, sdkerrors.Wrapf(types.ErrInWager, "%s", err) diff --git a/x/bet/simulation/decoder_test.go b/x/bet/simulation/decoder_test.go index d77694a9..022352af 100644 --- a/x/bet/simulation/decoder_test.go +++ b/x/bet/simulation/decoder_test.go @@ -32,7 +32,12 @@ func TestDecodeStore(t *testing.T) { MarketUID: uuid.NewString(), Value: "100", MaxLossMultiplier: sdk.NewDec(1), - }) + }, + &types.MetaData{ + SelectedOddsType: types.OddsType_ODDS_TYPE_DECIMAL, + SelectedOddsValue: "1.5", + }, + ) betUID := types.UID2ID{ UID: bet.UID, diff --git a/x/bet/types/messages_bet.go b/x/bet/types/messages_bet.go index 9a684e1d..4a2994db 100644 --- a/x/bet/types/messages_bet.go +++ b/x/bet/types/messages_bet.go @@ -68,7 +68,7 @@ func (msg *MsgWager) EmitEvent(ctx *sdk.Context) { } // NewBet creates and returns a new bet from given message -func NewBet(creator string, props *WagerProps, oddsType OddsType, odds *BetOdds) *Bet { +func NewBet(creator string, props *WagerProps, oddsType OddsType, odds *BetOdds, meta *MetaData) *Bet { return &Bet{ Creator: creator, UID: props.UID, @@ -78,5 +78,6 @@ func NewBet(creator string, props *WagerProps, oddsType OddsType, odds *BetOdds) Amount: props.Amount, OddsType: oddsType, MaxLossMultiplier: odds.MaxLossMultiplier, + Meta: meta, } } diff --git a/x/bet/types/messages_bet_test.go b/x/bet/types/messages_bet_test.go index 8d9e45dd..82697b5a 100644 --- a/x/bet/types/messages_bet_test.go +++ b/x/bet/types/messages_bet_test.go @@ -80,7 +80,15 @@ func TestNewBet(t *testing.T) { Amount: inputBet.Amount, OddsType: types.OddsType_ODDS_TYPE_DECIMAL, } - res := types.NewBet(creator, inputBet, types.OddsType_ODDS_TYPE_DECIMAL, inputBetOdds) + res := types.NewBet(creator, + inputBet, + types.OddsType_ODDS_TYPE_DECIMAL, + inputBetOdds, + &types.MetaData{ + SelectedOddsType: types.OddsType_ODDS_TYPE_DECIMAL, + SelectedOddsValue: "1.5", + }, + ) require.Equal(t, expectedBet, res) }) } From 415e28c19b4d423d41fbe4226a892e5aa46de3ea Mon Sep 17 00:00:00 2001 From: waaiifu Date: Fri, 27 Oct 2023 19:04:19 +0530 Subject: [PATCH 04/17] Fixes bet tests --- x/bet/types/messages_bet_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/x/bet/types/messages_bet_test.go b/x/bet/types/messages_bet_test.go index 82697b5a..2b914378 100644 --- a/x/bet/types/messages_bet_test.go +++ b/x/bet/types/messages_bet_test.go @@ -79,6 +79,10 @@ func TestNewBet(t *testing.T) { OddsValue: inputBetOdds.Value, Amount: inputBet.Amount, OddsType: types.OddsType_ODDS_TYPE_DECIMAL, + Meta: &types.MetaData{ + SelectedOddsType: types.OddsType_ODDS_TYPE_DECIMAL, + SelectedOddsValue: "1.5", + }, } res := types.NewBet(creator, inputBet, From f77699627ec0bcfd1a262f4f3616e2faf72723e9 Mon Sep 17 00:00:00 2001 From: scorpioborn <97235353+scorpioborn@users.noreply.github.com> Date: Tue, 31 Oct 2023 17:49:59 +0300 Subject: [PATCH 05/17] fix: remove odds type other than decimal --- docs/specs/Bet/04_State.md | 27 ++- docs/specs/Bet/05_State_Transitions.md | 1 - docs/specs/Bet/06_Messages.md | 2 - proto/sge/bet/bet.proto | 26 +-- proto/sge/bet/ticket.proto | 8 +- x/bet/keeper/bet_test.go | 1 - x/bet/keeper/keeper_test.go | 1 - x/bet/keeper/msg_server_bet.go | 2 +- x/bet/keeper/msg_server_bet_test.go | 2 - x/bet/keeper/settle.go | 4 +- x/bet/keeper/settle_test.go | 5 - x/bet/keeper/wager.go | 4 +- x/bet/keeper/wager_test.go | 3 - x/bet/simulation/decoder_test.go | 1 - x/bet/types/bet.pb.go | 219 ++++++++----------- x/bet/types/errors.go | 17 +- x/bet/types/expected_keepers.go | 1 - x/bet/types/messages_bet.go | 3 +- x/bet/types/messages_bet_test.go | 2 - x/bet/types/odds_type.go | 180 +-------------- x/bet/types/payout.go | 53 +---- x/bet/types/payout_test.go | 292 ------------------------- x/bet/types/ticket.go | 5 - x/bet/types/ticket.pb.go | 91 +++----- x/bet/types/ticket_test.go | 26 +-- x/orderbook/keeper/bet_wager.go | 6 - x/orderbook/keeper/bet_wager_test.go | 10 +- 27 files changed, 181 insertions(+), 811 deletions(-) diff --git a/docs/specs/Bet/04_State.md b/docs/specs/Bet/04_State.md index b65621e8..ea8c5955 100644 --- a/docs/specs/Bet/04_State.md +++ b/docs/specs/Bet/04_State.md @@ -89,48 +89,47 @@ message Bet { json_name = "odds_uid" ]; - // odds_type is the type of odds that - // user choose such as decimal, fractional, etc - sgenetwork.sge.bet.OddsType odds_type = 4; - // odds_value is the odds on which the bet is placed. - string odds_value = 5; + string odds_value = 4; // amount is the wager amount. - string amount = 6 [ + string amount = 5 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; // fee is the betting fee user needs to pay for placing a bet - string fee = 7 [ + string fee = 6 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; // status is the status of the bet, such as `unspecified` or `settled`. - Status status = 8; + Status status = 7; // result is the result of the bet, such as `won` or `lost`. - Result result = 9; + Result result = 8; // creator is the bettor address. - string creator = 10; + string creator = 9; // created_at is the bet placement timestamp. - int64 created_at = 11; + int64 created_at = 10; // settlement_height is the block height at which the bet is settled. - int64 settlement_height = 12; + int64 settlement_height = 11; // max_loss_multiplier is the multiplier coefficient of max loss. - string max_loss_multiplier = 13 [ + string max_loss_multiplier = 12 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false ]; // bet_fulfillment is the fulfillment data. - repeated BetFulfillment bet_fulfillment = 14; + repeated BetFulfillment bet_fulfillment = 13; + + // meta is metadata for bet + MetaData meta = 14; // Status of the Bet. enum Status { diff --git a/docs/specs/Bet/05_State_Transitions.md b/docs/specs/Bet/05_State_Transitions.md index a649becf..23823371 100644 --- a/docs/specs/Bet/05_State_Transitions.md +++ b/docs/specs/Bet/05_State_Transitions.md @@ -16,7 +16,6 @@ newBet := &types.Bet{ UID: msg.UID, MarketUID: , OddsUID: , - OddsType: , OddsValue: , Amount: msg.Amount, BetFee: , diff --git a/docs/specs/Bet/06_Messages.md b/docs/specs/Bet/06_Messages.md index 8a56520a..22e1ff3b 100644 --- a/docs/specs/Bet/06_Messages.md +++ b/docs/specs/Bet/06_Messages.md @@ -64,7 +64,6 @@ message MsgWagerResponse { WagerProps props = 1; } "approved": true, "id": "sge1w77wnncp6w6llqt0ysgahpxjscg8wspw43jvtd" }, - "odds_type":1, "exp": 1667863498866062000, "iat": 1667827498, "iss": "Oracle", @@ -85,7 +84,6 @@ The transaction will fail if: - Provided bet UID is already set - Empty or invalid odds UID in ticket - Empty, negative or invalid odds value in ticket -- Invalid bet value according to the selected `OddsType` - There is no any market with the given marketUID - The market is not active for accepting bet (it's not active or status in not `PENDING`) - The market has expired diff --git a/proto/sge/bet/bet.proto b/proto/sge/bet/bet.proto index 17913c77..603641f2 100644 --- a/proto/sge/bet/bet.proto +++ b/proto/sge/bet/bet.proto @@ -31,51 +31,47 @@ message Bet { json_name = "odds_uid" ]; - // odds_type is the type of odds that - // user choose such as decimal, fractional, etc - sgenetwork.sge.bet.OddsType odds_type = 4; - // odds_value is the odds on which the bet is placed. - string odds_value = 5; + string odds_value = 4; // amount is the wager amount. - string amount = 6 [ + string amount = 5 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; // fee is the betting fee user needs to pay for placing a bet - string fee = 7 [ + string fee = 6 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; // status is the status of the bet, such as `unspecified` or `settled`. - Status status = 8; + Status status = 7; // result is the result of the bet, such as `won` or `lost`. - Result result = 9; + Result result = 8; // creator is the bettor address. - string creator = 10; + string creator = 9; // created_at is the bet placement timestamp. - int64 created_at = 11; + int64 created_at = 10; // settlement_height is the block height at which the bet is settled. - int64 settlement_height = 12; + int64 settlement_height = 11; // max_loss_multiplier is the multiplier coefficient of max loss. - string max_loss_multiplier = 13 [ + string max_loss_multiplier = 12 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false ]; // bet_fulfillment is the fulfillment data. - repeated BetFulfillment bet_fulfillment = 14; + repeated BetFulfillment bet_fulfillment = 13; // meta is metadata for bet - MetaData meta = 15; + MetaData meta = 14; // Status of the Bet. enum Status { diff --git a/proto/sge/bet/ticket.proto b/proto/sge/bet/ticket.proto index b14809a9..119b1dc5 100644 --- a/proto/sge/bet/ticket.proto +++ b/proto/sge/bet/ticket.proto @@ -6,7 +6,6 @@ import "gogoproto/gogo.proto"; import "sge/type/kyc.proto"; import "sge/bet/bet_odds.proto"; import "sge/bet/bet.proto"; -import "sge/bet/odds_type.proto"; option go_package = "github.com/sge-network/sge/x/bet/types"; @@ -17,11 +16,8 @@ message WagerTicketPayload { // kyc_data contains the details of user kyc. sgenetwork.sge.type.KycDataPayload kyc_data = 2 [ (gogoproto.nullable) = false ]; - // odds_type is the type of odds that are going to be placed - // such as decimal, fraction, moneyline. - sgenetwork.sge.bet.OddsType odds_type = 3; // all odds for the selected market. - repeated BetOddsCompact all_odds = 4; + repeated BetOddsCompact all_odds = 3; // meta is metadata for bet placement - MetaData meta = 5; + MetaData meta = 4; } diff --git a/x/bet/keeper/bet_test.go b/x/bet/keeper/bet_test.go index 6246bc63..63a4b4e1 100644 --- a/x/bet/keeper/bet_test.go +++ b/x/bet/keeper/bet_test.go @@ -27,7 +27,6 @@ func createNBet( items[i].UID = cast.ToString(i) items[i].Creator = testCreator items[i].OddsValue = "10" - items[i].OddsType = types.OddsType_ODDS_TYPE_DECIMAL items[i].Amount = sdk.NewInt(10) items[i].Fee = sdk.NewInt(1) items[i].MarketUID = testMarketUID diff --git a/x/bet/keeper/keeper_test.go b/x/bet/keeper/keeper_test.go index ba566c81..3ca48f7a 100644 --- a/x/bet/keeper/keeper_test.go +++ b/x/bet/keeper/keeper_test.go @@ -162,7 +162,6 @@ func placeTestBet( "iat": 7777777777, "selected_odds": selectedOdds, "kyc_data": testKyc, - "odds_type": 1, "all_odds": testBetOdds, } testWagerTicket, err := createJwtTicket(testWagerClaim) diff --git a/x/bet/keeper/msg_server_bet.go b/x/bet/keeper/msg_server_bet.go index 47d1aad1..04e4ec99 100644 --- a/x/bet/keeper/msg_server_bet.go +++ b/x/bet/keeper/msg_server_bet.go @@ -30,7 +30,7 @@ func (k msgServer) Wager( return nil, sdkerrors.Wrapf(types.ErrInTicketValidation, "%s", err) } - bet := types.NewBet(msg.Creator, msg.Props, payload.OddsType, payload.SelectedOdds, payload.Meta) + bet := types.NewBet(msg.Creator, msg.Props, payload.SelectedOdds, payload.Meta) if err := k.Keeper.Wager(ctx, bet, payload.OddsMap()); err != nil { return nil, sdkerrors.Wrapf(types.ErrInWager, "%s", err) diff --git a/x/bet/keeper/msg_server_bet_test.go b/x/bet/keeper/msg_server_bet_test.go index 4720f37d..e423b5ba 100644 --- a/x/bet/keeper/msg_server_bet_test.go +++ b/x/bet/keeper/msg_server_bet_test.go @@ -89,7 +89,6 @@ func TestBetMsgServerWager(t *testing.T) { "iat": 1111111111, "selected_odds": testSelectedBetOdds, "kyc_data": testKyc, - "odds_type": types.OddsType_ODDS_TYPE_DECIMAL, "all_odds": testBetOdds, } wagerTicket, err := createJwtTicket(wagerClaim) @@ -119,7 +118,6 @@ func TestBetMsgServerWager(t *testing.T) { "iat": 1111111111, "selected_odds": testSelectedBetOdds, "kyc_data": testKyc, - "odds_type": types.OddsType_ODDS_TYPE_DECIMAL, "all_odds": testBetOdds, } wagerTicket, err := createJwtTicket(wagerClaim) diff --git a/x/bet/keeper/settle.go b/x/bet/keeper/settle.go index d674f180..f8009c16 100644 --- a/x/bet/keeper/settle.go +++ b/x/bet/keeper/settle.go @@ -51,7 +51,7 @@ func (k Keeper) Settle(ctx sdk.Context, bettorAddressStr, betUID string) error { if market.Status == markettypes.MarketStatus_MARKET_STATUS_ABORTED || market.Status == markettypes.MarketStatus_MARKET_STATUS_CANCELED { - payoutProfit, err := types.CalculatePayoutProfit(bet.OddsType, bet.OddsValue, bet.Amount) + payoutProfit, err := types.CalculatePayoutProfit(bet.OddsValue, bet.Amount) if err != nil { return err } @@ -109,7 +109,7 @@ func (k Keeper) settleResolved(ctx sdk.Context, bet *types.Bet) error { return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "%s", err) } - payout, err := types.CalculatePayoutProfit(bet.OddsType, bet.OddsValue, bet.Amount) + payout, err := types.CalculatePayoutProfit(bet.OddsValue, bet.Amount) if err != nil { return err } diff --git a/x/bet/keeper/settle_test.go b/x/bet/keeper/settle_test.go index 67bf0b9a..9643aab1 100644 --- a/x/bet/keeper/settle_test.go +++ b/x/bet/keeper/settle_test.go @@ -49,7 +49,6 @@ func TestSettleBet(t *testing.T) { bet: &types.Bet{ MarketUID: testMarketUID, OddsValue: "10", - OddsType: types.OddsType_ODDS_TYPE_DECIMAL, Amount: sdk.NewInt(1000000), Creator: testCreator, OddsUID: testOddsUID1, @@ -71,7 +70,6 @@ func TestSettleBet(t *testing.T) { bet: &types.Bet{ MarketUID: testMarketUID, OddsValue: "10", - OddsType: types.OddsType_ODDS_TYPE_DECIMAL, Amount: sdk.NewInt(1000000), Creator: testCreator, OddsUID: testOddsUID1, @@ -91,7 +89,6 @@ func TestSettleBet(t *testing.T) { bet: &types.Bet{ MarketUID: testMarketUID, OddsValue: "10", - OddsType: types.OddsType_ODDS_TYPE_DECIMAL, Amount: sdk.NewInt(1000000), Creator: testCreator, OddsUID: testOddsUID1, @@ -111,7 +108,6 @@ func TestSettleBet(t *testing.T) { bet: &types.Bet{ MarketUID: testMarketUID, OddsValue: "10", - OddsType: types.OddsType_ODDS_TYPE_DECIMAL, Amount: sdk.NewInt(1000000), Creator: testCreator, OddsUID: testOddsUID1, @@ -132,7 +128,6 @@ func TestSettleBet(t *testing.T) { bet: &types.Bet{ MarketUID: testMarketUID, OddsValue: "10", - OddsType: types.OddsType_ODDS_TYPE_DECIMAL, Amount: sdk.NewInt(1000000), Creator: testCreator, OddsUID: testOddsUID1, diff --git a/x/bet/keeper/wager.go b/x/bet/keeper/wager.go index 934f36c1..1d18fe5a 100644 --- a/x/bet/keeper/wager.go +++ b/x/bet/keeper/wager.go @@ -46,7 +46,7 @@ func (k Keeper) Wager(ctx sdk.Context, bet *types.Bet, betOdds map[string]*types bet.SetFee(betConstraints.Fee) // calculate payoutProfit - payoutProfit, err := types.CalculatePayoutProfit(bet.OddsType, bet.OddsValue, bet.Amount) + payoutProfit, err := types.CalculatePayoutProfit(bet.OddsValue, bet.Amount) if err != nil { return err } @@ -57,7 +57,7 @@ func (k Keeper) Wager(ctx sdk.Context, bet *types.Bet, betOdds map[string]*types betFulfillment, err := k.orderbookKeeper.ProcessWager( ctx, bet.UID, bet.MarketUID, bet.OddsUID, bet.MaxLossMultiplier, bet.Amount, payoutProfit, - bettorAddress, bet.Fee, bet.OddsType, bet.OddsValue, betID, betOdds, market.OddsUIDS(), + bettorAddress, bet.Fee, bet.OddsValue, betID, betOdds, market.OddsUIDS(), ) if err != nil { return sdkerrors.Wrapf(types.ErrInOBWagerProcessing, "%s", err) diff --git a/x/bet/keeper/wager_test.go b/x/bet/keeper/wager_test.go index f4f0adab..c1e488a2 100644 --- a/x/bet/keeper/wager_test.go +++ b/x/bet/keeper/wager_test.go @@ -121,7 +121,6 @@ func TestWager(t *testing.T) { OddsUID: "notExistOdds", Amount: sdk.NewInt(1000), OddsValue: "5", - OddsType: types.OddsType_ODDS_TYPE_DECIMAL, Creator: simappUtil.TestParamUsers["user1"].Address.String(), }, betOdds: map[string]*types.BetOddsCompact{ @@ -151,7 +150,6 @@ func TestWager(t *testing.T) { OddsUID: "odds1", Amount: sdk.NewInt(100), OddsValue: "5", - OddsType: types.OddsType_ODDS_TYPE_DECIMAL, Creator: simappUtil.TestParamUsers["user1"].Address.String(), }, betOdds: map[string]*types.BetOddsCompact{ @@ -191,7 +189,6 @@ func TestWager(t *testing.T) { OddsUID: "odds1", Amount: sdk.NewInt(1000000), OddsValue: "5", - OddsType: types.OddsType_ODDS_TYPE_DECIMAL, Creator: simappUtil.TestParamUsers["user1"].Address.String(), MaxLossMultiplier: sdk.MustNewDecFromStr("0.1"), }, diff --git a/x/bet/simulation/decoder_test.go b/x/bet/simulation/decoder_test.go index 022352af..6c38904f 100644 --- a/x/bet/simulation/decoder_test.go +++ b/x/bet/simulation/decoder_test.go @@ -26,7 +26,6 @@ func TestDecodeStore(t *testing.T) { Amount: sdk.NewInt(10), Ticket: "", }, - types.OddsType_ODDS_TYPE_DECIMAL, &types.BetOdds{ UID: uuid.NewString(), MarketUID: uuid.NewString(), diff --git a/x/bet/types/bet.pb.go b/x/bet/types/bet.pb.go index c5180a96..8e286dc8 100644 --- a/x/bet/types/bet.pb.go +++ b/x/bet/types/bet.pb.go @@ -122,31 +122,28 @@ type Bet struct { // odds_uid is the universal unique identifier, // of the odds on which the bet is placed. OddsUID string `protobuf:"bytes,3,opt,name=odds_uid,proto3" json:"odds_uid"` - // odds_type is the type of odds that - // user choose such as decimal, fractional, etc - OddsType OddsType `protobuf:"varint,4,opt,name=odds_type,json=oddsType,proto3,enum=sgenetwork.sge.bet.OddsType" json:"odds_type,omitempty"` // odds_value is the odds on which the bet is placed. - OddsValue string `protobuf:"bytes,5,opt,name=odds_value,json=oddsValue,proto3" json:"odds_value,omitempty"` + OddsValue string `protobuf:"bytes,4,opt,name=odds_value,json=oddsValue,proto3" json:"odds_value,omitempty"` // amount is the wager amount. - Amount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,6,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount"` + Amount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount"` // fee is the betting fee user needs to pay for placing a bet - Fee github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,7,opt,name=fee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"fee"` + Fee github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,6,opt,name=fee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"fee"` // status is the status of the bet, such as `unspecified` or `settled`. - Status Bet_Status `protobuf:"varint,8,opt,name=status,proto3,enum=sgenetwork.sge.bet.Bet_Status" json:"status,omitempty"` + Status Bet_Status `protobuf:"varint,7,opt,name=status,proto3,enum=sgenetwork.sge.bet.Bet_Status" json:"status,omitempty"` // result is the result of the bet, such as `won` or `lost`. - Result Bet_Result `protobuf:"varint,9,opt,name=result,proto3,enum=sgenetwork.sge.bet.Bet_Result" json:"result,omitempty"` + Result Bet_Result `protobuf:"varint,8,opt,name=result,proto3,enum=sgenetwork.sge.bet.Bet_Result" json:"result,omitempty"` // creator is the bettor address. - Creator string `protobuf:"bytes,10,opt,name=creator,proto3" json:"creator,omitempty"` + Creator string `protobuf:"bytes,9,opt,name=creator,proto3" json:"creator,omitempty"` // created_at is the bet placement timestamp. - CreatedAt int64 `protobuf:"varint,11,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` + CreatedAt int64 `protobuf:"varint,10,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` // settlement_height is the block height at which the bet is settled. - SettlementHeight int64 `protobuf:"varint,12,opt,name=settlement_height,json=settlementHeight,proto3" json:"settlement_height,omitempty"` + SettlementHeight int64 `protobuf:"varint,11,opt,name=settlement_height,json=settlementHeight,proto3" json:"settlement_height,omitempty"` // max_loss_multiplier is the multiplier coefficient of max loss. - MaxLossMultiplier github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,13,opt,name=max_loss_multiplier,json=maxLossMultiplier,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"max_loss_multiplier"` + MaxLossMultiplier github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,12,opt,name=max_loss_multiplier,json=maxLossMultiplier,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"max_loss_multiplier"` // bet_fulfillment is the fulfillment data. - BetFulfillment []*BetFulfillment `protobuf:"bytes,14,rep,name=bet_fulfillment,json=betFulfillment,proto3" json:"bet_fulfillment,omitempty"` + BetFulfillment []*BetFulfillment `protobuf:"bytes,13,rep,name=bet_fulfillment,json=betFulfillment,proto3" json:"bet_fulfillment,omitempty"` // meta is metadata for bet - Meta *MetaData `protobuf:"bytes,15,opt,name=meta,proto3" json:"meta,omitempty"` + Meta *MetaData `protobuf:"bytes,14,opt,name=meta,proto3" json:"meta,omitempty"` } func (m *Bet) Reset() { *m = Bet{} } @@ -203,13 +200,6 @@ func (m *Bet) GetOddsUID() string { return "" } -func (m *Bet) GetOddsType() OddsType { - if m != nil { - return m.OddsType - } - return OddsType_ODDS_TYPE_UNSPECIFIED -} - func (m *Bet) GetOddsValue() string { if m != nil { return m.OddsValue @@ -564,66 +554,66 @@ func init() { func init() { proto.RegisterFile("sge/bet/bet.proto", fileDescriptor_9bc076bb1a4d9f6e) } var fileDescriptor_9bc076bb1a4d9f6e = []byte{ - // 943 bytes of a gzipped FileDescriptorProto + // 931 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0x41, 0x6f, 0xe2, 0x46, - 0x14, 0x8e, 0x71, 0x96, 0x84, 0x97, 0x84, 0x98, 0xc9, 0x6a, 0xd7, 0x4a, 0xb7, 0x80, 0x2c, 0xb5, - 0x42, 0xaa, 0xd6, 0x54, 0x59, 0xa9, 0x52, 0xdb, 0xcb, 0x02, 0x36, 0x0d, 0x2d, 0x01, 0x34, 0x40, - 0x2b, 0xf5, 0x50, 0xcb, 0xe0, 0x09, 0x71, 0x63, 0x63, 0xe4, 0x19, 0xda, 0xe4, 0x5c, 0xa9, 0xe7, - 0xfe, 0x84, 0xfe, 0x95, 0xde, 0xf6, 0xb8, 0xc7, 0xaa, 0x07, 0x54, 0x91, 0x5b, 0x8f, 0xfb, 0x0b, - 0xaa, 0x19, 0x0f, 0x60, 0xd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0x7b, 0xac, 0x7a, 0x40, 0x15, 0xb9, 0xf5, 0xb8, 0xbf, 0xa0, 0x9a, + 0xf1, 0x40, 0x8c, 0x9a, 0x56, 0xc9, 0x1e, 0x12, 0x66, 0xbe, 0xf9, 0xbe, 0xef, 0x79, 0x9e, 0x9f, + 0xdf, 0x83, 0x22, 0x9d, 0x92, 0xda, 0x98, 0x30, 0xfe, 0x67, 0xce, 0xe3, 0x88, 0x45, 0x08, 0xd1, + 0x29, 0x99, 0x11, 0xf6, 0x4b, 0x14, 0x5f, 0x99, 0x74, 0x4a, 0xcc, 0x31, 0x61, 0x27, 0x4f, 0xa7, + 0xd1, 0x34, 0x12, 0xc7, 0x35, 0xbe, 0x4a, 0x98, 0x27, 0xcf, 0xd7, 0xe2, 0xc8, 0xf3, 0xa8, 0xc3, + 0x6e, 0xe6, 0x24, 0x39, 0x30, 0xde, 0xec, 0x81, 0xda, 0x20, 0x0c, 0x55, 0x40, 0x5d, 0xf8, 0x9e, + 0xae, 0x54, 0x94, 0x6a, 0xbe, 0x51, 0x58, 0x2d, 0xcb, 0xea, 0xa8, 0x6d, 0xfd, 0xbd, 0x2c, 0x73, + 0x14, 0xf3, 0x7f, 0xe8, 0x2b, 0x80, 0xd0, 0x8d, 0xaf, 0x08, 0x73, 0x38, 0x31, 0x23, 0x88, 0x1f, + 0xad, 0x96, 0xe5, 0xfc, 0xb9, 0x40, 0x13, 0x7a, 0x8a, 0x82, 0x53, 0x6b, 0xf4, 0x0a, 0xf6, 0x44, + 0x64, 0x2e, 0x55, 0x85, 0xf4, 0xf9, 0x6a, 0x59, 0xde, 0xed, 0x79, 0x1e, 0x4d, 0x84, 0x9b, 0x63, + 0xbc, 0x59, 0xa1, 0x8f, 0x01, 0xc4, 0xfa, 0x67, 0x37, 0x58, 0x10, 0x3d, 0xcb, 0x65, 0x38, 0xcf, + 0x91, 0xef, 0x38, 0x80, 0x5a, 0x90, 0x73, 0xc3, 0x68, 0x31, 0x63, 0xfa, 0x13, 0x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, 0x73, 0xe6, 0x71, + 0x74, 0xe1, 0xb3, 0xa4, 0xe7, 0x36, 0x5a, 0x8f, 0x0e, 0xf3, 0x74, 0x7d, 0xb9, 0x94, 0x99, 0x81, + 0x0f, 0x92, 0x7d, 0x3f, 0xd9, 0xbe, 0x51, 0x60, 0x6f, 0xfd, 0x49, 0xa2, 0x6f, 0x00, 0x51, 0x12, + 0x90, 0x09, 0x6f, 0x5c, 0x9b, 0x11, 0x25, 0xd2, 0x5f, 0xb8, 0xff, 0x63, 0xe6, 0x93, 0x63, 0x78, + 0x33, 0x27, 0xbc, 0x6f, 0x25, 0xba, 0x35, 0x82, 0x4c, 0x38, 0xde, 0xf6, 0x4a, 0xe6, 0x47, 0x52, + 0x0a, 0xc5, 0x34, 0x5d, 0xcc, 0x91, 0xc6, 0xeb, 0xb7, 0xab, 0x92, 0xf2, 0x6e, 0x55, 0x52, 0xfe, + 0x5a, 0x95, 0x94, 0xdf, 0x6e, 0x4b, 0x3b, 0xef, 0x6e, 0x4b, 0x3b, 0x7f, 0xdc, 0x96, 0x76, 0x7e, + 0x48, 0x5f, 0x98, 0x4e, 0xc9, 0x4b, 0xf9, 0x10, 0x7c, 0x5d, 0xbb, 0x16, 0xe3, 0x54, 0x5c, 0x7a, + 0x9c, 0x13, 0xb3, 0xf4, 0xd5, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xc9, 0x53, 0x07, 0x3a, 0xa3, + 0x07, 0x00, 0x00, } func (m *Bet) Marshal() (dAtA []byte, err error) { @@ -656,7 +646,7 @@ func (m *Bet) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintBet(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x7a + dAtA[i] = 0x72 } if len(m.BetFulfillment) > 0 { for iNdEx := len(m.BetFulfillment) - 1; iNdEx >= 0; iNdEx-- { @@ -669,7 +659,7 @@ func (m *Bet) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintBet(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x72 + dAtA[i] = 0x6a } } { @@ -681,33 +671,33 @@ func (m *Bet) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintBet(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x6a + dAtA[i] = 0x62 if m.SettlementHeight != 0 { i = encodeVarintBet(dAtA, i, uint64(m.SettlementHeight)) i-- - dAtA[i] = 0x60 + dAtA[i] = 0x58 } if m.CreatedAt != 0 { i = encodeVarintBet(dAtA, i, uint64(m.CreatedAt)) i-- - dAtA[i] = 0x58 + dAtA[i] = 0x50 } if len(m.Creator) > 0 { i -= len(m.Creator) copy(dAtA[i:], m.Creator) i = encodeVarintBet(dAtA, i, uint64(len(m.Creator))) i-- - dAtA[i] = 0x52 + dAtA[i] = 0x4a } if m.Result != 0 { i = encodeVarintBet(dAtA, i, uint64(m.Result)) i-- - dAtA[i] = 0x48 + dAtA[i] = 0x40 } if m.Status != 0 { i = encodeVarintBet(dAtA, i, uint64(m.Status)) i-- - dAtA[i] = 0x40 + dAtA[i] = 0x38 } { size := m.Fee.Size() @@ -718,7 +708,7 @@ func (m *Bet) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintBet(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x3a + dAtA[i] = 0x32 { size := m.Amount.Size() i -= size @@ -728,18 +718,13 @@ func (m *Bet) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintBet(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x32 + dAtA[i] = 0x2a if len(m.OddsValue) > 0 { i -= len(m.OddsValue) copy(dAtA[i:], m.OddsValue) i = encodeVarintBet(dAtA, i, uint64(len(m.OddsValue))) i-- - dAtA[i] = 0x2a - } - if m.OddsType != 0 { - i = encodeVarintBet(dAtA, i, uint64(m.OddsType)) - i-- - dAtA[i] = 0x20 + dAtA[i] = 0x22 } if len(m.OddsUID) > 0 { i -= len(m.OddsUID) @@ -993,9 +978,6 @@ func (m *Bet) Size() (n int) { if l > 0 { n += 1 + l + sovBet(uint64(l)) } - if m.OddsType != 0 { - n += 1 + sovBet(uint64(m.OddsType)) - } l = len(m.OddsValue) if l > 0 { n += 1 + l + sovBet(uint64(l)) @@ -1253,25 +1235,6 @@ func (m *Bet) Unmarshal(dAtA []byte) error { m.OddsUID = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field OddsType", wireType) - } - m.OddsType = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowBet - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.OddsType |= OddsType(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field OddsValue", wireType) } @@ -1303,7 +1266,7 @@ func (m *Bet) Unmarshal(dAtA []byte) error { } m.OddsValue = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 6: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) } @@ -1337,7 +1300,7 @@ func (m *Bet) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 7: + case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Fee", wireType) } @@ -1371,7 +1334,7 @@ func (m *Bet) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 8: + case 7: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) } @@ -1390,7 +1353,7 @@ func (m *Bet) Unmarshal(dAtA []byte) error { break } } - case 9: + case 8: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Result", wireType) } @@ -1409,7 +1372,7 @@ func (m *Bet) Unmarshal(dAtA []byte) error { break } } - case 10: + case 9: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) } @@ -1441,7 +1404,7 @@ func (m *Bet) Unmarshal(dAtA []byte) error { } m.Creator = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 11: + case 10: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field CreatedAt", wireType) } @@ -1460,7 +1423,7 @@ func (m *Bet) Unmarshal(dAtA []byte) error { break } } - case 12: + case 11: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field SettlementHeight", wireType) } @@ -1479,7 +1442,7 @@ func (m *Bet) Unmarshal(dAtA []byte) error { break } } - case 13: + case 12: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field MaxLossMultiplier", wireType) } @@ -1513,7 +1476,7 @@ func (m *Bet) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 14: + case 13: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field BetFulfillment", wireType) } @@ -1547,7 +1510,7 @@ func (m *Bet) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 15: + case 14: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Meta", wireType) } diff --git a/x/bet/types/errors.go b/x/bet/types/errors.go index fc0762a9..86f7182b 100644 --- a/x/bet/types/errors.go +++ b/x/bet/types/errors.go @@ -35,17 +35,14 @@ var ( ErrFractionalOddsIncorrectFormat = sdkerrors.Register(ModuleName, 2025, "incorrect format of fractional odds value") ErrMoneylineOddsIncorrectFormat = sdkerrors.Register(ModuleName, 2026, "incorrect format of moneyline odds value") ErrOddsDataNotFound = sdkerrors.Register(ModuleName, 2027, "odds does not exist in ticket payload") - ErrInvalidOddsType = sdkerrors.Register(ModuleName, 2028, "valid odds type should be provided, 1: decimal, 2: fractional, 3: moneyline") - ErrUserKycFailed = sdkerrors.Register(ModuleName, 2029, "the bettor failed the KYC Validation") - ErrCanNotQueryLargeNumberOfBets = sdkerrors.Register(ModuleName, 2030, "large amount of bets requested") - ErrDecimalOddsShouldBePositive = sdkerrors.Register(ModuleName, 2031, "decimal odds value should be positive") + ErrUserKycFailed = sdkerrors.Register(ModuleName, 2028, "the bettor failed the KYC Validation") + ErrCanNotQueryLargeNumberOfBets = sdkerrors.Register(ModuleName, 2029, "large amount of bets requested") + ErrDecimalOddsShouldBePositive = sdkerrors.Register(ModuleName, 2030, "decimal odds value should be positive") ErrDecimalOddsCanNotBeLessThanOne = sdkerrors.Register(ModuleName, 2032, "decimal odds value can not less than or equal to 1") - ErrFractionalOddsCanNotBeNegativeOrZero = sdkerrors.Register(ModuleName, 2033, "fractional odds numbers can not be negative") - ErrMoneylineOddsCanNotBeZero = sdkerrors.Register(ModuleName, 2034, "moneyline odds can not be zero") - ErrBettorAddressNotEqualToCreator = sdkerrors.Register(ModuleName, 2035, "provided bettor address is not equal to bet owner") - ErrMaxLossMultiplierCanNotBeZero = sdkerrors.Register(ModuleName, 2036, "max loss multiplier cannot be nil or zero") - ErrMaxLossMultiplierCanNotBeMoreThanOne = sdkerrors.Register(ModuleName, 2037, "max loss multiplier cannot be more than one") - ErrInsufficientOdds = sdkerrors.Register(ModuleName, 2038, "market odds length not same as odds sent in wager") + ErrBettorAddressNotEqualToCreator = sdkerrors.Register(ModuleName, 2033, "provided bettor address is not equal to bet owner") + ErrMaxLossMultiplierCanNotBeZero = sdkerrors.Register(ModuleName, 2034, "max loss multiplier cannot be nil or zero") + ErrMaxLossMultiplierCanNotBeMoreThanOne = sdkerrors.Register(ModuleName, 2035, "max loss multiplier cannot be more than one") + ErrInsufficientOdds = sdkerrors.Register(ModuleName, 2036, "market odds length not same as odds sent in wager") ) // x/bet module sentinel error text diff --git a/x/bet/types/expected_keepers.go b/x/bet/types/expected_keepers.go index d4296dac..fa8aa361 100644 --- a/x/bet/types/expected_keepers.go +++ b/x/bet/types/expected_keepers.go @@ -43,7 +43,6 @@ type OrderbookKeeper interface { payoutProfit sdk.Dec, bettorAddress sdk.AccAddress, betFee sdkmath.Int, - oddsType OddsType, oddsVal string, betID uint64, odds map[string]*BetOddsCompact, diff --git a/x/bet/types/messages_bet.go b/x/bet/types/messages_bet.go index 4a2994db..f1c1f63a 100644 --- a/x/bet/types/messages_bet.go +++ b/x/bet/types/messages_bet.go @@ -68,7 +68,7 @@ func (msg *MsgWager) EmitEvent(ctx *sdk.Context) { } // NewBet creates and returns a new bet from given message -func NewBet(creator string, props *WagerProps, oddsType OddsType, odds *BetOdds, meta *MetaData) *Bet { +func NewBet(creator string, props *WagerProps, odds *BetOdds, meta *MetaData) *Bet { return &Bet{ Creator: creator, UID: props.UID, @@ -76,7 +76,6 @@ func NewBet(creator string, props *WagerProps, oddsType OddsType, odds *BetOdds, OddsUID: odds.UID, OddsValue: odds.Value, Amount: props.Amount, - OddsType: oddsType, MaxLossMultiplier: odds.MaxLossMultiplier, Meta: meta, } diff --git a/x/bet/types/messages_bet_test.go b/x/bet/types/messages_bet_test.go index 2b914378..0034bb81 100644 --- a/x/bet/types/messages_bet_test.go +++ b/x/bet/types/messages_bet_test.go @@ -78,7 +78,6 @@ func TestNewBet(t *testing.T) { OddsUID: inputBetOdds.UID, OddsValue: inputBetOdds.Value, Amount: inputBet.Amount, - OddsType: types.OddsType_ODDS_TYPE_DECIMAL, Meta: &types.MetaData{ SelectedOddsType: types.OddsType_ODDS_TYPE_DECIMAL, SelectedOddsValue: "1.5", @@ -86,7 +85,6 @@ func TestNewBet(t *testing.T) { } res := types.NewBet(creator, inputBet, - types.OddsType_ODDS_TYPE_DECIMAL, inputBetOdds, &types.MetaData{ SelectedOddsType: types.OddsType_ODDS_TYPE_DECIMAL, diff --git a/x/bet/types/odds_type.go b/x/bet/types/odds_type.go index 054bb016..f941dd11 100644 --- a/x/bet/types/odds_type.go +++ b/x/bet/types/odds_type.go @@ -1,27 +1,13 @@ package types import ( - "strings" - sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) -type OddsTypeI interface { - // CalculatePayout calculates total payout of a certain bet amount - CalculatePayout(oddsVal string, amount sdkmath.Int) (sdk.Dec, error) - - // CalculateBetAmount calculates bet amount - CalculateBetAmount(oddsVal string, payoutProfit sdk.Dec) (sdk.Dec, error) -} - -// decimalOdds is the type to define OddsTypeI interface -// for the decimal odds type -type decimalOdds struct{} - -// CalculatePayout calculates total payout of a certain bet amount by decimal odds calculations -func (*decimalOdds) CalculatePayout(oddsVal string, amount sdkmath.Int) (sdk.Dec, error) { +// CalculateDecimalPayout calculates total payout of a certain bet amount by decimal odds calculations +func CalculateDecimalPayout(oddsVal string, amount sdkmath.Int) (sdk.Dec, error) { // decimal odds value should be sdk.Dec, so convert it directly oddsDecVal, err := sdk.NewDecFromStr(oddsVal) if err != nil { @@ -49,7 +35,7 @@ func (*decimalOdds) CalculatePayout(oddsVal string, amount sdkmath.Int) (sdk.Dec } // CalculateBetAmount calculates bet amount -func (*decimalOdds) CalculateBetAmount(oddsVal string, payoutProfit sdk.Dec) (sdk.Dec, error) { +func CalculateDecimalBetAmount(oddsVal string, payoutProfit sdk.Dec) (sdk.Dec, error) { // decimal odds value should be sdk.Dec, so convert it directly oddsDecVal, err := sdk.NewDecFromStr(oddsVal) if err != nil { @@ -75,163 +61,3 @@ func (*decimalOdds) CalculateBetAmount(oddsVal string, payoutProfit sdk.Dec) (sd // get the integer part of the bet amount return betAmount, nil } - -// fractionalOdds is the type to define OddsTypeI interface -// for the fractional odds type -type fractionalOdds struct{} - -// CalculatePayout calculates total payout of a certain bet amount by fractional odds calculations -func (*fractionalOdds) CalculatePayout(oddsVal string, amount sdkmath.Int) (sdk.Dec, error) { - fraction := strings.Split(oddsVal, "/") - - // the fraction should contain two parts such as (first part)/secondary) - if len(fraction) != 2 { - return sdk.ZeroDec(), - ErrFractionalOddsIncorrectFormat - } - - // the fraction part should be an integer, values such as 1.5/2 is not accepted - firstPart, ok := sdk.NewIntFromString(fraction[0]) - if !ok { - return sdk.ZeroDec(), - sdkerrors.Wrapf(ErrFractionalOddsIncorrectFormat, "%s, invalid integer %s", oddsVal, fraction[0]) - } - - // the fraction part should be an integer, values such as 1/2.5 is not accepted - secondPart, ok := sdk.NewIntFromString(fraction[1]) - if !ok { - return sdk.ZeroDec(), - sdkerrors.Wrapf(ErrFractionalOddsIncorrectFormat, "%s, invalid integer %s", oddsVal, fraction[1]) - } - - // fraction parts should be positive - if !firstPart.IsPositive() || !secondPart.IsPositive() { - return sdk.ZeroDec(), ErrFractionalOddsCanNotBeNegativeOrZero - } - - // calculate the coefficient by dividing sdk.Dec values of fraction parts - // this helps not to lost precision in the division and calculate the payout - - profit := sdk.NewDecFromInt(amount). - // the coefficient - Mul(sdk.NewDecFromInt(firstPart)). - Quo(sdk.NewDecFromInt(secondPart)) - - payout := sdk.NewDecFromInt(amount).Add(profit) - - // get the integer part of the payout - return payout, nil -} - -// CalculateBetAmount calculates bet amount -func (*fractionalOdds) CalculateBetAmount(oddsVal string, payoutProfit sdk.Dec) (sdk.Dec, error) { - fraction := strings.Split(oddsVal, "/") - - // the fraction should contain two parts such as (firstpart)/secondpart) - if len(fraction) != 2 { - return sdk.ZeroDec(), - ErrFractionalOddsIncorrectFormat - } - - // the fraction part should be an integer, values such as 1.5/2 is not accepted - firstPart, ok := sdk.NewIntFromString(fraction[0]) - if !ok { - return sdk.ZeroDec(), - sdkerrors.Wrapf(ErrFractionalOddsIncorrectFormat, "%s, invalid integer %s", oddsVal, fraction[0]) - } - - // the fraction part should be an integer, values such as 1/2.5 is not accepted - secondPart, ok := sdk.NewIntFromString(fraction[1]) - if !ok { - return sdk.ZeroDec(), - sdkerrors.Wrapf(ErrFractionalOddsIncorrectFormat, "%s, invalid integer %s", oddsVal, fraction[1]) - } - - // fraction parts should be positive - if !firstPart.IsPositive() || !secondPart.IsPositive() { - return sdk.ZeroDec(), ErrFractionalOddsCanNotBeNegativeOrZero - } - - // calculate the coefficient by dividing sdk.Dec values of fraction parts - // this helps not to lost precision in the division and calculate the bet amount - betAmount := payoutProfit. - // the coefficient - Mul(sdk.NewDecFromInt(secondPart)). - Quo(sdk.NewDecFromInt(firstPart)) - - // get the integer part of the bet amount - return betAmount, nil -} - -// moneylineOdds is the type to define OddsTypeI interface -// for the moneyline odds type -type moneylineOdds struct{} - -// CalculatePayout calculates total payout of a certain bet amount by moneyline odds calculations -func (*moneylineOdds) CalculatePayout(oddsVal string, amount sdkmath.Int) (sdk.Dec, error) { - // moneyline odds value could be integer - oddsValue, ok := sdk.NewIntFromString(oddsVal) - if !ok { - return sdk.ZeroDec(), - sdkerrors.Wrapf(ErrMoneylineOddsIncorrectFormat, "%s", oddsVal) - } - - // moneyline values can be negative or positive, but zero is not acceptable - if oddsValue.IsZero() { - return sdk.ZeroDec(), ErrMoneylineOddsCanNotBeZero - } - - // calculate payout - var payout, profit sdk.Dec - // calculate coefficient of the payout calculations by using sdk.Dec values of odds value - // we should extract absolute number to prevent negative payout - if oddsValue.IsPositive() { - profit = sdk.NewDecFromInt(amount). - Mul(sdk.NewDecFromInt(oddsValue)). - Quo(sdk.NewDec(100)).Abs() - } else { - profit = sdk.NewDecFromInt(amount). - Mul(sdk.NewDec(100)). - QuoInt(oddsValue).Abs() - } - - // bet amount should be multiplied by the coefficient - payout = sdk.NewDecFromInt(amount).Add(profit) - - // get the integer part of the payout - return payout, nil -} - -// CalculateBetAmount calculates bet amount -func (*moneylineOdds) CalculateBetAmount(oddsVal string, payoutProfit sdk.Dec) (sdk.Dec, error) { - // moneyline odds value could be integer - oddsValue, ok := sdk.NewIntFromString(oddsVal) - if !ok { - return sdk.ZeroDec(), - sdkerrors.Wrapf(ErrMoneylineOddsIncorrectFormat, "%s", oddsVal) - } - - // moneyline values can be negative or positive, but zero is not acceptable - if oddsValue.IsZero() { - return sdk.ZeroDec(), ErrMoneylineOddsCanNotBeZero - } - - // calculate payout - var betAmount sdk.Dec - // calculate coefficient of the payout calculations by using sdk.Dec values of odds value - // we should extract absolute number to prevent negative payout - if oddsValue.IsPositive() { - betAmount = payoutProfit. - Mul(sdk.NewDec(100)). - Quo(sdk.NewDecFromInt(oddsValue)). - Abs() - } else { - betAmount = payoutProfit. - Mul(sdk.NewDecFromInt(oddsValue)). - Quo(sdk.NewDec(100)). - Abs() - } - - // get the integer part of the bet amount - return betAmount, nil -} diff --git a/x/bet/types/payout.go b/x/bet/types/payout.go index b2f3ae7d..99c69b47 100644 --- a/x/bet/types/payout.go +++ b/x/bet/types/payout.go @@ -6,8 +6,8 @@ import ( ) // CalculatePayoutProfit calculates the amount of payout profit portion according to bet odds value and amount -func CalculatePayoutProfit(oddsType OddsType, oddsVal string, amount sdkmath.Int) (sdk.Dec, error) { - payout, err := calculatePayout(oddsType, oddsVal, amount) +func CalculatePayoutProfit(oddsVal string, amount sdkmath.Int) (sdk.Dec, error) { + payout, err := calculatePayout(oddsVal, amount) if err != nil { return sdk.ZeroDec(), err } @@ -19,26 +19,9 @@ func CalculatePayoutProfit(oddsType OddsType, oddsVal string, amount sdkmath.Int } // calculatePayout calculates the amount of payout according to bet odds value and amount -func calculatePayout(oddsType OddsType, oddsVal string, amount sdkmath.Int) (sdk.Dec, error) { - var oType OddsTypeI - - // assign corresponding type to the interface instance - switch oddsType { - case OddsType_ODDS_TYPE_DECIMAL: - oType = new(decimalOdds) - - case OddsType_ODDS_TYPE_FRACTIONAL: - oType = new(fractionalOdds) - - case OddsType_ODDS_TYPE_MONEYLINE: - oType = new(moneylineOdds) - - default: - return sdk.ZeroDec(), ErrInvalidOddsType - } - +func calculatePayout(oddsVal string, amount sdkmath.Int) (sdk.Dec, error) { // total payout should be paid to bettor - payout, err := oType.CalculatePayout(oddsVal, amount) + payout, err := CalculateDecimalPayout(oddsVal, amount) if err != nil { return sdk.ZeroDec(), err } @@ -47,8 +30,8 @@ func calculatePayout(oddsType OddsType, oddsVal string, amount sdkmath.Int) (sdk } // CalculateBetAmount calculates the amount of bet according to bet odds value and payout profit -func CalculateBetAmount(oddsType OddsType, oddsVal string, payoutProfit sdk.Dec) (sdk.Dec, error) { - betAmount, err := calculateBetAmount(oddsType, oddsVal, payoutProfit) +func CalculateBetAmount(oddsVal string, payoutProfit sdk.Dec) (sdk.Dec, error) { + betAmount, err := calculateBetAmount(oddsVal, payoutProfit) if err != nil { return sdk.ZeroDec(), err } @@ -59,12 +42,11 @@ func CalculateBetAmount(oddsType OddsType, oddsVal string, payoutProfit sdk.Dec) // CalculateBetAmountInt calculates the amount of bet according to bet odds value and payout profit // and returns the int and the truncated decimal part. func CalculateBetAmountInt( - oddsType OddsType, oddsVal string, payoutProfit sdk.Dec, truncatedBetAmount sdk.Dec, ) (sdkmath.Int, sdk.Dec, error) { - expectedBetAmountDec, err := CalculateBetAmount(oddsType, oddsVal, payoutProfit) + expectedBetAmountDec, err := CalculateBetAmount(oddsVal, payoutProfit) if err != nil { return sdkmath.Int{}, sdk.Dec{}, err } @@ -82,26 +64,9 @@ func CalculateBetAmountInt( } // calculateBetAmount calculates the amount of bet according to bet odds value and payoutProfit -func calculateBetAmount(oddsType OddsType, oddsVal string, payoutProfit sdk.Dec) (sdk.Dec, error) { - var oType OddsTypeI - - // assign corresponding type to the interface instance - switch oddsType { - case OddsType_ODDS_TYPE_DECIMAL: - oType = new(decimalOdds) - - case OddsType_ODDS_TYPE_FRACTIONAL: - oType = new(fractionalOdds) - - case OddsType_ODDS_TYPE_MONEYLINE: - oType = new(moneylineOdds) - - default: - return sdk.ZeroDec(), ErrInvalidOddsType - } - +func calculateBetAmount(oddsVal string, payoutProfit sdk.Dec) (sdk.Dec, error) { // total payout should be paid to bettor - betAmount, err := oType.CalculateBetAmount(oddsVal, payoutProfit) + betAmount, err := CalculateDecimalBetAmount(oddsVal, payoutProfit) if err != nil { return sdk.ZeroDec(), err } diff --git a/x/bet/types/payout_test.go b/x/bet/types/payout_test.go index 29e85cd2..0a0d5c73 100644 --- a/x/bet/types/payout_test.go +++ b/x/bet/types/payout_test.go @@ -54,7 +54,6 @@ func TestCalculateDecimalPayout(t *testing.T) { for _, tc := range tcs { t.Run(tc.desc, func(t *testing.T) { payoutProfit, err := types.CalculatePayoutProfit( - types.OddsType_ODDS_TYPE_DECIMAL, tc.oddsValue, sdk.NewInt(tc.betAmount), ) @@ -66,7 +65,6 @@ func TestCalculateDecimalPayout(t *testing.T) { } calcBetAmount, err := types.CalculateBetAmount( - types.OddsType_ODDS_TYPE_DECIMAL, tc.oddsValue, payoutProfit, ) @@ -79,293 +77,3 @@ func TestCalculateDecimalPayout(t *testing.T) { }) } } - -func TestCalculateFractionalPayout(t *testing.T) { - tcs := []struct { - desc string - oddsValue string - betAmount int64 - - expVal int64 - err error - }{ - { - desc: "positive outcome", - oddsValue: "5/2", - betAmount: defaultBetAmount, - - expVal: 89064472, - }, - { - desc: "positive outcome 1", - oddsValue: "7/2", - betAmount: defaultBetAmount, - - expVal: 124690261, - }, - { - desc: "positive outcome 2", - oddsValue: "2/7", - betAmount: defaultBetAmount, - - expVal: 10178796, - }, - { - desc: "positive outcome 3", - oddsValue: "1/17", - betAmount: defaultBetAmount, - - expVal: 2095634, - }, - { - desc: "positive outcome 4", - oddsValue: "7/3", - betAmount: defaultBetAmount, - - expVal: 83126841, - }, - { - desc: "same", - oddsValue: "1/1", - betAmount: defaultBetAmount, - - expVal: defaultBetAmount, - }, - { - desc: "zero base", - oddsValue: "1/0", - betAmount: defaultBetAmount, - - err: types.ErrFractionalOddsCanNotBeNegativeOrZero, - }, - { - desc: "negative base", - oddsValue: "-5/2", - betAmount: defaultBetAmount, - - err: types.ErrFractionalOddsCanNotBeNegativeOrZero, - }, - { - desc: "zero top", - oddsValue: "0/1", - betAmount: defaultBetAmount, - - err: types.ErrFractionalOddsCanNotBeNegativeOrZero, - }, - { - desc: "negative top", - oddsValue: "5/-2", - betAmount: defaultBetAmount, - - err: types.ErrFractionalOddsCanNotBeNegativeOrZero, - }, - { - desc: "negative top", - oddsValue: "5//2", - betAmount: defaultBetAmount, - - err: types.ErrFractionalOddsIncorrectFormat, - }, - { - desc: "wrong type", - oddsValue: "5/s", - betAmount: defaultBetAmount, - - err: types.ErrFractionalOddsIncorrectFormat, - }, - { - desc: "incorrect format", - oddsValue: "5//2", - betAmount: defaultBetAmount, - - err: types.ErrFractionalOddsIncorrectFormat, - }, - } - - for _, tc := range tcs { - t.Run(tc.desc, func(t *testing.T) { - payoutProfit, err := types.CalculatePayoutProfit( - types.OddsType_ODDS_TYPE_FRACTIONAL, - tc.oddsValue, - sdk.NewInt(tc.betAmount), - ) - if tc.err != nil { - require.ErrorIs(t, tc.err, err) - } else { - require.NoError(t, err) - require.True(t, sdk.NewInt(tc.expVal).Equal(payoutProfit.TruncateInt()), "expected: %d, actual: %d", tc.expVal, payoutProfit) - } - - calcBetAmount, err := types.CalculateBetAmount( - types.OddsType_ODDS_TYPE_FRACTIONAL, - tc.oddsValue, - payoutProfit, - ) - if tc.err != nil { - require.ErrorIs(t, tc.err, err) - } else { - require.NoError(t, err) - require.True(t, sdk.NewInt(tc.betAmount).Sub(calcBetAmount.Ceil().RoundInt()).Abs().LTE(ecceptedTruncatedValue), "expected: %d, actual: %d", tc.betAmount, calcBetAmount) - } - }) - } -} - -func TestCalculateFractionalBetAmount(t *testing.T) { - tcs := []struct { - desc string - oddsValue string - payoutProfit sdk.Dec - - expVal sdk.Dec - err error - }{ - { - desc: "positive outcome", - oddsValue: "2/7", - payoutProfit: sdk.MustNewDecFromStr("5003"), - - expVal: sdk.MustNewDecFromStr("17510.5"), - }, - } - - for _, tc := range tcs { - t.Run(tc.desc, func(t *testing.T) { - calcBetAmount, err := types.CalculateBetAmount( - types.OddsType_ODDS_TYPE_FRACTIONAL, - tc.oddsValue, - tc.payoutProfit, - ) - if tc.err != nil { - require.ErrorIs(t, tc.err, err) - } else { - require.NoError(t, err) - require.Equal(t, tc.expVal, calcBetAmount, "expected: %d, actual: %d", tc.expVal, calcBetAmount) - } - }) - } -} - -func TestCalculateMoneylinePayout(t *testing.T) { - tcs := []struct { - desc string - oddsValue string - betAmount int64 - - expVal int64 - err error - }{ - { - desc: "upper", - oddsValue: "+150", - betAmount: defaultBetAmount, - - expVal: 53438683, - }, - { - desc: "lower", - oddsValue: "-450", - betAmount: defaultBetAmount, - - expVal: 7916842, - }, - { - desc: "lower", - oddsValue: "-426", - betAmount: defaultBetAmount, - - expVal: 8362861, - }, - { - desc: "lower", - oddsValue: "+450", - betAmount: defaultBetAmount, - - expVal: 160316050, - }, - { - desc: "lower", - oddsValue: "+426", - betAmount: defaultBetAmount, - - expVal: 151765861, - }, - { - desc: "same", - oddsValue: "0", - betAmount: defaultBetAmount, - - err: types.ErrMoneylineOddsCanNotBeZero, - }, - { - desc: "incorrect format", - oddsValue: "15.6", - betAmount: defaultBetAmount, - - err: types.ErrMoneylineOddsIncorrectFormat, - }, - } - - for _, tc := range tcs { - t.Run(tc.desc, func(t *testing.T) { - payoutProfit, err := types.CalculatePayoutProfit( - types.OddsType_ODDS_TYPE_MONEYLINE, - tc.oddsValue, - sdk.NewInt(tc.betAmount), - ) - if tc.err != nil { - require.ErrorIs(t, tc.err, err) - } else { - require.NoError(t, err) - require.True(t, sdk.NewInt(tc.expVal).Equal(payoutProfit.TruncateInt()), "expected: %d, actual: %d", tc.expVal, payoutProfit) - } - - calcBetAmount, err := types.CalculateBetAmount( - types.OddsType_ODDS_TYPE_MONEYLINE, - tc.oddsValue, - payoutProfit, - ) - if tc.err != nil { - require.ErrorIs(t, tc.err, err) - } else { - require.NoError(t, err) - require.True(t, sdk.NewInt(tc.betAmount).Sub(calcBetAmount.Ceil().TruncateInt()).Abs().LTE(ecceptedTruncatedValue), "expected: %d, actual: %d", tc.betAmount, calcBetAmount) - } - }) - } -} - -func TestCalculateMoneylineBetAmount(t *testing.T) { - tcs := []struct { - desc string - oddsValue string - payoutProfit sdk.Dec - - expVal sdk.Dec - err error - }{ - { - desc: "positive outcome", - oddsValue: "-450", - payoutProfit: sdk.MustNewDecFromStr("5003"), - - expVal: sdk.MustNewDecFromStr("22513.5"), - }, - } - - for _, tc := range tcs { - t.Run(tc.desc, func(t *testing.T) { - calcBetAmount, err := types.CalculateBetAmount( - types.OddsType_ODDS_TYPE_MONEYLINE, - tc.oddsValue, - tc.payoutProfit, - ) - if tc.err != nil { - require.ErrorIs(t, tc.err, err) - } else { - require.NoError(t, err) - require.Equal(t, tc.expVal, calcBetAmount, "expected: %d, actual: %d", tc.expVal, calcBetAmount) - } - }) - } -} diff --git a/x/bet/types/ticket.go b/x/bet/types/ticket.go index c6adee89..7bbc7c02 100644 --- a/x/bet/types/ticket.go +++ b/x/bet/types/ticket.go @@ -28,11 +28,6 @@ func (payload *WagerTicketPayload) Validate(creator string) error { return sdkerrors.Wrapf(ErrUserKycFailed, "%s", creator) } - if payload.OddsType < OddsType_ODDS_TYPE_DECIMAL || - payload.OddsType > OddsType_ODDS_TYPE_MONEYLINE { - return ErrInvalidOddsType - } - return nil } diff --git a/x/bet/types/ticket.pb.go b/x/bet/types/ticket.pb.go index 0e0145f0..29400727 100644 --- a/x/bet/types/ticket.pb.go +++ b/x/bet/types/ticket.pb.go @@ -30,13 +30,10 @@ type WagerTicketPayload struct { SelectedOdds *BetOdds `protobuf:"bytes,1,opt,name=selected_odds,json=selectedOdds,proto3" json:"selected_odds,omitempty"` // kyc_data contains the details of user kyc. KycData types.KycDataPayload `protobuf:"bytes,2,opt,name=kyc_data,json=kycData,proto3" json:"kyc_data"` - // odds_type is the type of odds that are going to be placed - // such as decimal, fraction, moneyline. - OddsType OddsType `protobuf:"varint,3,opt,name=odds_type,json=oddsType,proto3,enum=sgenetwork.sge.bet.OddsType" json:"odds_type,omitempty"` // all odds for the selected market. - AllOdds []*BetOddsCompact `protobuf:"bytes,4,rep,name=all_odds,json=allOdds,proto3" json:"all_odds,omitempty"` + 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,5,opt,name=meta,proto3" json:"meta,omitempty"` + Meta *MetaData `protobuf:"bytes,4,opt,name=meta,proto3" json:"meta,omitempty"` } func (m *WagerTicketPayload) Reset() { *m = WagerTicketPayload{} } @@ -86,13 +83,6 @@ func (m *WagerTicketPayload) GetKycData() types.KycDataPayload { return types.KycDataPayload{} } -func (m *WagerTicketPayload) GetOddsType() OddsType { - if m != nil { - return m.OddsType - } - return OddsType_ODDS_TYPE_UNSPECIFIED -} - func (m *WagerTicketPayload) GetAllOdds() []*BetOddsCompact { if m != nil { return m.AllOdds @@ -114,29 +104,27 @@ func init() { func init() { proto.RegisterFile("sge/bet/ticket.proto", fileDescriptor_cf6959e7db451613) } var fileDescriptor_cf6959e7db451613 = []byte{ - // 354 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x92, 0xc1, 0x4a, 0xf3, 0x40, - 0x14, 0x85, 0x93, 0xb6, 0xff, 0xdf, 0x9a, 0xaa, 0x60, 0x28, 0x1a, 0xaa, 0xc4, 0x52, 0x41, 0xba, - 0x31, 0x91, 0xba, 0x72, 0x21, 0x94, 0xda, 0x9d, 0x88, 0x12, 0x0a, 0x82, 0x9b, 0x32, 0x99, 0xb9, - 0x8c, 0x25, 0xa9, 0x13, 0x3a, 0x57, 0x74, 0xde, 0xc2, 0xc7, 0xea, 0xb2, 0x4b, 0x57, 0x22, 0xed, - 0x8b, 0xc8, 0x4c, 0x52, 0x11, 0x2d, 0xee, 0x6e, 0xce, 0x3d, 0xf7, 0x9c, 0x0f, 0x32, 0x4e, 0x43, - 0x72, 0x08, 0x63, 0xc0, 0x10, 0xc7, 0x34, 0x01, 0x0c, 0xb2, 0xa9, 0x40, 0xe1, 0xba, 0x92, 0xc3, - 0x23, 0xe0, 0xb3, 0x98, 0x26, 0x81, 0xe4, 0x10, 0xc4, 0x80, 0xcd, 0x06, 0x17, 0x5c, 0x98, 0x75, - 0xa8, 0xa7, 0xdc, 0xd9, 0xd4, 0xce, 0x10, 0x55, 0x06, 0x61, 0xa2, 0x68, 0xa1, 0xed, 0xae, 0x32, - 0x63, 0xc0, 0x91, 0x60, 0x4c, 0x16, 0xfa, 0xce, 0x37, 0xbd, 0x90, 0xf6, 0x56, 0x92, 0xb6, 0x8d,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, 0xa4, 0x08, 0xd2, 0x73, 0xf8, 0x92, 0xbf, 0x0a, 0x95, 0x81, 0x8c, - 0xff, 0x9b, 0x7f, 0x72, 0xf6, 0x19, 0x00, 0x00, 0xff, 0xff, 0x95, 0x0c, 0x75, 0x47, 0x2d, 0x02, + // 322 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x91, 0x41, 0x4b, 0xc3, 0x40, + 0x10, 0x85, 0x93, 0xb6, 0xd8, 0x92, 0xea, 0xc1, 0x50, 0xa4, 0x54, 0x89, 0xa5, 0x82, 0xf4, 0xe2, + 0xae, 0xd4, 0xb3, 0x50, 0x6a, 0x6f, 0x22, 0x4a, 0x10, 0x04, 0x2f, 0x65, 0xb2, 0x3b, 0xac, 0x25, + 0xa9, 0x1b, 0xba, 0x23, 0x9a, 0x1f, 0x21, 0xf8, 0xb3, 0x7a, 0xec, 0xd1, 0x93, 0x48, 0xfb, 0x47, + 0x24, 0x9b, 0x14, 0x44, 0xc5, 0xdb, 0xec, 0xdb, 0x79, 0xef, 0x7d, 0xec, 0x7a, 0x2d, 0xa3, 0x90, + 0x47, 0x48, 0x9c, 0xa6, 0x22, 0x46, 0x62, 0xe9, 0x5c, 0x93, 0xf6, 0x7d, 0xa3, 0xf0, 0x11, 0xe9, + 0x59, 0xcf, 0x63, 0x66, 0x14, 0xb2, 0x08, 0xa9, 0xd3, 0x52, 0x5a, 0x69, 0x7b, 0xcd, 0xf3, 0xa9, + 0xd8, 0xec, 0xe4, 0x9b, 0x9c, 0xb2, 0x14, 0x79, 0x9c, 0x89, 0x52, 0xdb, 0xdb, 0x64, 0x46, 0x48, + 0x13, 0x2d, 0xa5, 0x29, 0xf5, 0xdd, 0x6f, 0x7a, 0x21, 0xf5, 0x5e, 0x2b, 0x9e, 0x7f, 0x07, 0x0a, + 0xe7, 0xb7, 0xb6, 0xfe, 0x06, 0xb2, 0x44, 0x83, 0xf4, 0x87, 0xde, 0x8e, 0xc1, 0x04, 0x05, 0xa1, + 0xb4, 0x01, 0x6d, 0xb7, 0xeb, 0xf6, 0x9b, 0x83, 0x7d, 0xf6, 0x9b, 0x8b, 0x8d, 0x90, 0xae, 0xa5, + 0x34, 0xe1, 0xf6, 0xc6, 0x91, 0x9f, 0xfc, 0xb1, 0xd7, 0x88, 0x33, 0x31, 0x91, 0x40, 0xd0, 0xae, + 0x58, 0xf3, 0xd1, 0x4f, 0x73, 0x4e, 0xcd, 0x2e, 0x33, 0x31, 0x06, 0x82, 0xb2, 0x78, 0x54, 0x5b, + 0x7c, 0x1c, 0x3a, 0x61, 0x3d, 0x2e, 0x54, 0xff, 0xdc, 0x6b, 0x40, 0x92, 0x14, 0x08, 0xd5, 0x6e, + 0xb5, 0xdf, 0x1c, 0xf4, 0xfe, 0x41, 0xb8, 0xd0, 0xb3, 0x14, 0x04, 0x85, 0x75, 0x48, 0x12, 0x0b, + 0x71, 0xea, 0xd5, 0x66, 0x48, 0xd0, 0xae, 0x59, 0x80, 0x83, 0xbf, 0xac, 0x57, 0x48, 0x90, 0x57, + 0x85, 0x76, 0x73, 0x34, 0x5c, 0xac, 0x02, 0x77, 0xb9, 0x0a, 0xdc, 0xcf, 0x55, 0xe0, 0xbe, 0xad, + 0x03, 0x67, 0xb9, 0x0e, 0x9c, 0xf7, 0x75, 0xe0, 0xdc, 0x1f, 0xab, 0x29, 0x3d, 0x3c, 0x45, 0x4c, + 0xe8, 0x19, 0x37, 0x0a, 0x4f, 0xca, 0xa0, 0x7c, 0xe6, 0x2f, 0xc5, 0x0f, 0x66, 0x29, 0x9a, 0x68, + 0xcb, 0x3e, 0xec, 0xd9, 0x57, 0x00, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xe4, 0x73, 0x7d, 0xd9, 0x01, 0x00, 0x00, } @@ -170,7 +158,7 @@ func (m *WagerTicketPayload) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTicket(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x2a + dAtA[i] = 0x22 } if len(m.AllOdds) > 0 { for iNdEx := len(m.AllOdds) - 1; iNdEx >= 0; iNdEx-- { @@ -183,14 +171,9 @@ func (m *WagerTicketPayload) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTicket(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x22 + dAtA[i] = 0x1a } } - if m.OddsType != 0 { - i = encodeVarintTicket(dAtA, i, uint64(m.OddsType)) - i-- - dAtA[i] = 0x18 - } { size, err := m.KycData.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -239,9 +222,6 @@ func (m *WagerTicketPayload) Size() (n int) { } l = m.KycData.Size() n += 1 + l + sovTicket(uint64(l)) - if m.OddsType != 0 { - n += 1 + sovTicket(uint64(m.OddsType)) - } if len(m.AllOdds) > 0 { for _, e := range m.AllOdds { l = e.Size() @@ -360,25 +340,6 @@ func (m *WagerTicketPayload) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field OddsType", wireType) - } - m.OddsType = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTicket - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.OddsType |= OddsType(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field AllOdds", wireType) } @@ -412,7 +373,7 @@ func (m *WagerTicketPayload) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 5: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Meta", wireType) } diff --git a/x/bet/types/ticket_test.go b/x/bet/types/ticket_test.go index 4ca2618a..f0744e7f 100644 --- a/x/bet/types/ticket_test.go +++ b/x/bet/types/ticket_test.go @@ -11,11 +11,10 @@ import ( func TestTicketFieldsValidation(t *testing.T) { tcs := []struct { - desc string - betOdds *types.BetOdds - kyc sgetypes.KycDataPayload - oddsType types.OddsType - err error + desc string + betOdds *types.BetOdds + kyc sgetypes.KycDataPayload + err error }{ { desc: "space in odds UID", @@ -30,8 +29,7 @@ func TestTicketFieldsValidation(t *testing.T) { Approved: true, ID: testAddress, }, - oddsType: types.OddsType_ODDS_TYPE_DECIMAL, - err: types.ErrInvalidOddsUID, + err: types.ErrInvalidOddsUID, }, { desc: "space in market UID", @@ -45,8 +43,7 @@ func TestTicketFieldsValidation(t *testing.T) { Approved: true, ID: testAddress, }, - oddsType: types.OddsType_ODDS_TYPE_DECIMAL, - err: types.ErrInvalidMarketUID, + err: types.ErrInvalidMarketUID, }, { desc: "empty odds value", @@ -60,8 +57,7 @@ func TestTicketFieldsValidation(t *testing.T) { Approved: true, ID: testAddress, }, - oddsType: types.OddsType_ODDS_TYPE_DECIMAL, - err: types.ErrEmptyOddsValue, + err: types.ErrEmptyOddsValue, }, { desc: "no kyc", @@ -71,8 +67,7 @@ func TestTicketFieldsValidation(t *testing.T) { Value: "10", MaxLossMultiplier: sdk.MustNewDecFromStr("0.1"), }, - oddsType: types.OddsType_ODDS_TYPE_DECIMAL, - err: types.ErrUserKycFailed, + err: types.ErrUserKycFailed, }, { desc: "no kyc ID field", @@ -86,8 +81,7 @@ func TestTicketFieldsValidation(t *testing.T) { Approved: true, ID: "", }, - oddsType: types.OddsType_ODDS_TYPE_DECIMAL, - err: types.ErrUserKycFailed, + err: types.ErrUserKycFailed, }, { desc: "valid message", @@ -101,7 +95,6 @@ func TestTicketFieldsValidation(t *testing.T) { Approved: true, ID: testAddress, }, - oddsType: types.OddsType_ODDS_TYPE_DECIMAL, }, } for _, tc := range tcs { @@ -109,7 +102,6 @@ func TestTicketFieldsValidation(t *testing.T) { p := types.WagerTicketPayload{ SelectedOdds: tc.betOdds, KycData: tc.kyc, - OddsType: tc.oddsType, } err := p.Validate(testAddress) if tc.err != nil { diff --git a/x/orderbook/keeper/bet_wager.go b/x/orderbook/keeper/bet_wager.go index 33818a01..9e27e8a4 100644 --- a/x/orderbook/keeper/bet_wager.go +++ b/x/orderbook/keeper/bet_wager.go @@ -19,7 +19,6 @@ func (k Keeper) ProcessWager( payoutProfit sdk.Dec, bettorAddress sdk.AccAddress, betFee sdkmath.Int, - oddsType bettypes.OddsType, oddsVal string, betID uint64, odds map[string]*bettypes.BetOddsCompact, oddUIDS []string, @@ -42,7 +41,6 @@ func (k Keeper) ProcessWager( betUID, betID, oddsUID, - oddsType, oddsVal, maxLossMultiplier, &book, @@ -103,7 +101,6 @@ func (k Keeper) fulfillBetByParticipationQueue( case fInfo.notEnoughLiquidityAvailable(): var betAmountToFulfill sdkmath.Int betAmountToFulfill, truncatedBetAmount, err = bettypes.CalculateBetAmountInt( - fInfo.oddsType, fInfo.oddsVal, sdk.NewDecFromInt(fInfo.inProcessItem.availableLiquidity), truncatedBetAmount, @@ -172,7 +169,6 @@ func (k Keeper) initFulfillmentInfo( betUID string, betID uint64, oddsUID string, - oddsType bettypes.OddsType, oddsVal string, maxLossMultiplier sdk.Dec, book *types.OrderBook, @@ -189,7 +185,6 @@ func (k Keeper) initFulfillmentInfo( betUID: betUID, betID: betID, oddsUID: oddsUID, - oddsType: oddsType, oddsVal: oddsVal, maxLossMultiplier: maxLossMultiplier, @@ -420,7 +415,6 @@ type fulfillmentInfo struct { betUID string betID uint64 oddsUID string - oddsType bettypes.OddsType oddsVal string maxLossMultiplier sdk.Dec betAmount sdkmath.Int diff --git a/x/orderbook/keeper/bet_wager_test.go b/x/orderbook/keeper/bet_wager_test.go index 49e64a5c..88c40547 100644 --- a/x/orderbook/keeper/bet_wager_test.go +++ b/x/orderbook/keeper/bet_wager_test.go @@ -312,7 +312,6 @@ func (ts *testBetSuite) placeTestBet( UID: uuid.NewString(), MarketUID: marketUID, OddsUID: oddsUID, - OddsType: bettypes.OddsType_ODDS_TYPE_DECIMAL, OddsValue: "1.1", Amount: amount, Fee: fee, @@ -322,7 +321,7 @@ func (ts *testBetSuite) placeTestBet( MaxLossMultiplier: sdk.MustNewDecFromStr("0.1"), } - payoutProfit, err := bettypes.CalculatePayoutProfit(bet.OddsType, bet.OddsValue, bet.Amount) + payoutProfit, err := bettypes.CalculatePayoutProfit(bet.OddsValue, bet.Amount) require.NoError(ts.t, err) betFeeCollectorBalanceBeforeWager := ts.tApp.BankKeeper.GetBalance( @@ -338,7 +337,7 @@ func (ts *testBetSuite) placeTestBet( betFulfillment, err := ts.k.ProcessWager( ts.ctx, bet.UID, bet.MarketUID, bet.OddsUID, bet.MaxLossMultiplier, bet.Amount, payoutProfit, - bettorAddr, bet.Fee, bet.OddsType, bet.OddsValue, 1, odds, oddUIDS, + bettorAddr, bet.Fee, bet.OddsValue, 1, odds, oddUIDS, ) if expErr != nil { require.ErrorIs(ts.t, expErr, err) @@ -462,7 +461,6 @@ func (ts *testBetSuite) bulkDepositPlaceBetsAndTest() { UID: uuid.NewString(), MarketUID: ts.market.UID, OddsUID: ts.market.Odds[1].UID, - OddsType: bettypes.OddsType_ODDS_TYPE_DECIMAL, OddsValue: "4.415", Amount: betAmount, Fee: sdk.ZeroInt(), @@ -472,12 +470,12 @@ func (ts *testBetSuite) bulkDepositPlaceBetsAndTest() { MaxLossMultiplier: betOdds[ts.market.Odds[1].UID].MaxLossMultiplier, } - payoutProfit, err := bettypes.CalculatePayoutProfit(bet.OddsType, bet.OddsValue, bet.Amount) + payoutProfit, err := bettypes.CalculatePayoutProfit(bet.OddsValue, bet.Amount) require.NoError(ts.t, err) betFulfillment, err := ts.k.ProcessWager( ts.ctx, bet.UID, bet.MarketUID, bet.OddsUID, bet.MaxLossMultiplier, bet.Amount, payoutProfit, - bettorAddr, bet.Fee, bet.OddsType, bet.OddsValue, 1, betOdds, oddUIDS, + bettorAddr, bet.Fee, bet.OddsValue, 1, betOdds, oddUIDS, ) require.NoError(ts.t, err) From 7ed05d5a18f0839916112100a5d4b0412fcc8bf4 Mon Sep 17 00:00:00 2001 From: scorpioborn <97235353+scorpioborn@users.noreply.github.com> Date: Tue, 31 Oct 2023 18:06:04 +0300 Subject: [PATCH 06/17] feat: make bet meta not nullable --- proto/sge/bet/bet.proto | 2 +- proto/sge/bet/ticket.proto | 2 +- x/bet/simulation/decoder_test.go | 2 +- x/bet/types/bet.pb.go | 149 +++++++++++++++---------------- x/bet/types/messages_bet.go | 2 +- x/bet/types/messages_bet_test.go | 4 +- x/bet/types/ticket.pb.go | 73 +++++++-------- 7 files changed, 110 insertions(+), 124 deletions(-) diff --git a/proto/sge/bet/bet.proto b/proto/sge/bet/bet.proto index 603641f2..7e131b39 100644 --- a/proto/sge/bet/bet.proto +++ b/proto/sge/bet/bet.proto @@ -71,7 +71,7 @@ message Bet { repeated BetFulfillment bet_fulfillment = 13; // meta is metadata for bet - MetaData meta = 14; + MetaData meta = 14 [ (gogoproto.nullable) = false ]; // Status of the Bet. enum Status { diff --git a/proto/sge/bet/ticket.proto b/proto/sge/bet/ticket.proto index 119b1dc5..805004ab 100644 --- a/proto/sge/bet/ticket.proto +++ b/proto/sge/bet/ticket.proto @@ -19,5 +19,5 @@ message WagerTicketPayload { // all odds for the selected market. repeated BetOddsCompact all_odds = 3; // meta is metadata for bet placement - MetaData meta = 4; + MetaData meta = 4 [ (gogoproto.nullable) = false ]; } diff --git a/x/bet/simulation/decoder_test.go b/x/bet/simulation/decoder_test.go index 6c38904f..c41f81d8 100644 --- a/x/bet/simulation/decoder_test.go +++ b/x/bet/simulation/decoder_test.go @@ -32,7 +32,7 @@ func TestDecodeStore(t *testing.T) { Value: "100", MaxLossMultiplier: sdk.NewDec(1), }, - &types.MetaData{ + types.MetaData{ SelectedOddsType: types.OddsType_ODDS_TYPE_DECIMAL, SelectedOddsValue: "1.5", }, diff --git a/x/bet/types/bet.pb.go b/x/bet/types/bet.pb.go index 8e286dc8..b92ad640 100644 --- a/x/bet/types/bet.pb.go +++ b/x/bet/types/bet.pb.go @@ -143,7 +143,7 @@ type Bet struct { // bet_fulfillment is the fulfillment data. BetFulfillment []*BetFulfillment `protobuf:"bytes,13,rep,name=bet_fulfillment,json=betFulfillment,proto3" json:"bet_fulfillment,omitempty"` // meta is metadata for bet - Meta *MetaData `protobuf:"bytes,14,opt,name=meta,proto3" json:"meta,omitempty"` + Meta MetaData `protobuf:"bytes,14,opt,name=meta,proto3" json:"meta"` } func (m *Bet) Reset() { *m = Bet{} } @@ -249,11 +249,11 @@ func (m *Bet) GetBetFulfillment() []*BetFulfillment { return nil } -func (m *Bet) GetMeta() *MetaData { +func (m *Bet) GetMeta() MetaData { if m != nil { return m.Meta } - return nil + return MetaData{} } // UID2ID is the type for mapping UIDs and Sequential IDs of bets. @@ -554,66 +554,66 @@ func init() { func init() { proto.RegisterFile("sge/bet/bet.proto", fileDescriptor_9bc076bb1a4d9f6e) } var fileDescriptor_9bc076bb1a4d9f6e = []byte{ - // 931 bytes of a gzipped FileDescriptorProto + // 936 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0x41, 0x6f, 0xe2, 0x46, 0x14, 0x8e, 0x31, 0x4b, 0xc2, 0x4b, 0x42, 0xcc, 0x64, 0xb5, 0x6b, 0xa5, 0x5b, 0x40, 0x96, 0x5a, - 0x21, 0x55, 0x6b, 0xaa, 0xac, 0xd4, 0x43, 0x7b, 0x59, 0xc0, 0xa6, 0xa1, 0x25, 0x80, 0x06, 0x68, - 0xa5, 0x1e, 0x6a, 0x19, 0x3c, 0x21, 0x6e, 0x6c, 0x8c, 0x3c, 0x43, 0x9b, 0x9c, 0x2b, 0xed, 0xb9, - 0x3f, 0xa1, 0x3f, 0x67, 0x8f, 0x7b, 0xac, 0x7a, 0x40, 0x15, 0xb9, 0xf5, 0xb8, 0xbf, 0xa0, 0x9a, - 0xf1, 0x40, 0x8c, 0x9a, 0x56, 0xc9, 0x1e, 0x12, 0x66, 0xbe, 0xf9, 0xbe, 0xef, 0x79, 0x9e, 0x9f, - 0xdf, 0x83, 0x22, 0x9d, 0x92, 0xda, 0x98, 0x30, 0xfe, 0x67, 0xce, 0xe3, 0x88, 0x45, 0x08, 0xd1, - 0x29, 0x99, 0x11, 0xf6, 0x4b, 0x14, 0x5f, 0x99, 0x74, 0x4a, 0xcc, 0x31, 0x61, 0x27, 0x4f, 0xa7, - 0xd1, 0x34, 0x12, 0xc7, 0x35, 0xbe, 0x4a, 0x98, 0x27, 0xcf, 0xd7, 0xe2, 0xc8, 0xf3, 0xa8, 0xc3, - 0x6e, 0xe6, 0x24, 0x39, 0x30, 0xde, 0xec, 0x81, 0xda, 0x20, 0x0c, 0x55, 0x40, 0x5d, 0xf8, 0x9e, - 0xae, 0x54, 0x94, 0x6a, 0xbe, 0x51, 0x58, 0x2d, 0xcb, 0xea, 0xa8, 0x6d, 0xfd, 0xbd, 0x2c, 0x73, - 0x14, 0xf3, 0x7f, 0xe8, 0x2b, 0x80, 0xd0, 0x8d, 0xaf, 0x08, 0x73, 0x38, 0x31, 0x23, 0x88, 0x1f, - 0xad, 0x96, 0xe5, 0xfc, 0xb9, 0x40, 0x13, 0x7a, 0x8a, 0x82, 0x53, 0x6b, 0xf4, 0x0a, 0xf6, 0x44, - 0x64, 0x2e, 0x55, 0x85, 0xf4, 0xf9, 0x6a, 0x59, 0xde, 0xed, 0x79, 0x1e, 0x4d, 0x84, 0x9b, 0x63, - 0xbc, 0x59, 0xa1, 0x8f, 0x01, 0xc4, 0xfa, 0x67, 0x37, 0x58, 0x10, 0x3d, 0xcb, 0x65, 0x38, 0xcf, - 0x91, 0xef, 0x38, 0x80, 0x5a, 0x90, 0x73, 0xc3, 0x68, 0x31, 0x63, 0xfa, 0x13, 0xe1, 0x68, 0xbe, - 0x5d, 0x96, 0x77, 0xfe, 0x5c, 0x96, 0x3f, 0x9d, 0xfa, 0xec, 0x72, 0x31, 0x36, 0x27, 0x51, 0x58, - 0x9b, 0x44, 0x34, 0x8c, 0xa8, 0xfc, 0x79, 0x49, 0xbd, 0xab, 0x1a, 0xbf, 0x3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 0x50, 0x2f, 0x08, 0xd1, 0x73, 0x1f, 0x64, 0xc2, 0xa5, 0xe8, + 0x35, 0xe4, 0x28, 0x73, 0xd9, 0x82, 0xea, 0xbb, 0x15, 0xa5, 0x5a, 0x38, 0x2d, 0x99, 0xff, 0xfe, + 0x30, 0x66, 0x83, 0x30, 0x73, 0x20, 0x58, 0x58, 0xb2, 0xb9, 0x2e, 0x26, 0x74, 0x11, 0x30, 0x7d, + 0xef, 0xff, 0x75, 0x58, 0xb0, 0xb0, 0x64, 0x23, 0x1d, 0x76, 0x27, 0x31, 0x71, 0x59, 0x14, 0xeb, + 0x79, 0x71, 0x2b, 0xeb, 0x29, 0xbf, 0x32, 0x31, 0x24, 0x9e, 0xe3, 0x32, 0x1d, 0x2a, 0x4a, 0x55, + 0xc5, 0x79, 0x89, 0xd4, 0x19, 0xfa, 0x0c, 0x8a, 0x94, 0x30, 0x16, 0x90, 0x90, 0xcc, 0x98, 0x73, + 0x49, 0xfc, 0xe9, 0x25, 0xd3, 0xf7, 0x05, 0x4b, 0xbb, 0x5b, 0x38, 0x13, 0x38, 0xfa, 0x1e, 0x8e, + 0x43, 0xf7, 0xda, 0x09, 0x22, 0x4a, 0x9d, 0x70, 0x11, 0x30, 0x7f, 0x1e, 0xf8, 0x24, 0xd6, 0x0f, + 0x1e, 0x7d, 0x4f, 0x16, 0x99, 0xe0, 0x62, 0xe8, 0x5e, 0x77, 0x22, 0x4a, 0xcf, 0x37, 0x46, 0xe8, + 0x6b, 0x38, 0x1a, 0x13, 0xe6, 0x5c, 0x2c, 0x82, 0x0b, 0x3f, 0x08, 0x78, 0x60, 0xfd, 0xb0, 0xa2, + 0x56, 0xf7, 0x4f, 0x8d, 0xff, 0xb8, 0x86, 0xd6, 0x1d, 0x13, 0x17, 0xc6, 0x5b, 0x73, 0xf4, 0x1a, + 0xb2, 0x21, 0x61, 0xae, 0x5e, 0xa8, 0x28, 0xd5, 0xfd, 0xd3, 0x17, 0xf7, 0x39, 0x9c, 0x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x95, 0xb8, 0xfe, 0xc2, 0xfd, + 0x4f, 0x9a, 0xf7, 0x8f, 0xe1, 0xcd, 0x9c, 0xf0, 0xea, 0x95, 0xe8, 0xd6, 0x08, 0x32, 0xe1, 0x78, + 0xdb, 0x2b, 0xe9, 0x22, 0x49, 0x2a, 0x14, 0xd3, 0x74, 0xd1, 0x4d, 0x1a, 0x6f, 0xde, 0xae, 0x4a, + 0xca, 0xbb, 0x55, 0x49, 0xf9, 0x6b, 0x55, 0x52, 0x7e, 0xbb, 0x2d, 0xed, 0xbc, 0xbb, 0x2d, 0xed, + 0xfc, 0x71, 0x5b, 0xda, 0xf9, 0x2e, 0x7d, 0x60, 0x3a, 0x25, 0x2f, 0xe5, 0x26, 0xf8, 0xb8, 0x76, + 0x2d, 0x9a, 0xaa, 0x38, 0xf4, 0x38, 0x27, 0x3a, 0xea, 0xab, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, + 0x91, 0xdb, 0x86, 0x30, 0xa9, 0x07, 0x00, 0x00, } func (m *Bet) Marshal() (dAtA []byte, err error) { @@ -636,18 +636,16 @@ func (m *Bet) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.Meta != nil { - { - size, err := m.Meta.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintBet(dAtA, i, uint64(size)) + { + size, err := m.Meta.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } - i-- - dAtA[i] = 0x72 + i -= size + i = encodeVarintBet(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x72 if len(m.BetFulfillment) > 0 { for iNdEx := len(m.BetFulfillment) - 1; iNdEx >= 0; iNdEx-- { { @@ -1010,10 +1008,8 @@ func (m *Bet) Size() (n int) { n += 1 + l + sovBet(uint64(l)) } } - if m.Meta != nil { - l = m.Meta.Size() - n += 1 + l + sovBet(uint64(l)) - } + l = m.Meta.Size() + n += 1 + l + sovBet(uint64(l)) return n } @@ -1539,9 +1535,6 @@ func (m *Bet) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.Meta == nil { - m.Meta = &MetaData{} - } if err := m.Meta.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/x/bet/types/messages_bet.go b/x/bet/types/messages_bet.go index f1c1f63a..6a3b1b80 100644 --- a/x/bet/types/messages_bet.go +++ b/x/bet/types/messages_bet.go @@ -68,7 +68,7 @@ func (msg *MsgWager) EmitEvent(ctx *sdk.Context) { } // NewBet creates and returns a new bet from given message -func NewBet(creator string, props *WagerProps, odds *BetOdds, meta *MetaData) *Bet { +func NewBet(creator string, props *WagerProps, odds *BetOdds, meta MetaData) *Bet { return &Bet{ Creator: creator, UID: props.UID, diff --git a/x/bet/types/messages_bet_test.go b/x/bet/types/messages_bet_test.go index 0034bb81..19e2eae1 100644 --- a/x/bet/types/messages_bet_test.go +++ b/x/bet/types/messages_bet_test.go @@ -78,7 +78,7 @@ func TestNewBet(t *testing.T) { OddsUID: inputBetOdds.UID, OddsValue: inputBetOdds.Value, Amount: inputBet.Amount, - Meta: &types.MetaData{ + Meta: types.MetaData{ SelectedOddsType: types.OddsType_ODDS_TYPE_DECIMAL, SelectedOddsValue: "1.5", }, @@ -86,7 +86,7 @@ func TestNewBet(t *testing.T) { res := types.NewBet(creator, inputBet, inputBetOdds, - &types.MetaData{ + types.MetaData{ SelectedOddsType: types.OddsType_ODDS_TYPE_DECIMAL, SelectedOddsValue: "1.5", }, diff --git a/x/bet/types/ticket.pb.go b/x/bet/types/ticket.pb.go index 29400727..65c6dd6a 100644 --- a/x/bet/types/ticket.pb.go +++ b/x/bet/types/ticket.pb.go @@ -33,7 +33,7 @@ type WagerTicketPayload struct { // all odds for the selected market. 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,omitempty"` + Meta MetaData `protobuf:"bytes,4,opt,name=meta,proto3" json:"meta"` } func (m *WagerTicketPayload) Reset() { *m = WagerTicketPayload{} } @@ -90,11 +90,11 @@ func (m *WagerTicketPayload) GetAllOdds() []*BetOddsCompact { return nil } -func (m *WagerTicketPayload) GetMeta() *MetaData { +func (m *WagerTicketPayload) GetMeta() MetaData { if m != nil { return m.Meta } - return nil + return MetaData{} } func init() { @@ -104,28 +104,28 @@ func init() { func init() { proto.RegisterFile("sge/bet/ticket.proto", fileDescriptor_cf6959e7db451613) } var fileDescriptor_cf6959e7db451613 = []byte{ - // 322 bytes of a gzipped FileDescriptorProto + // 323 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x91, 0x41, 0x4b, 0xc3, 0x40, 0x10, 0x85, 0x93, 0xb6, 0xd8, 0x92, 0xea, 0xc1, 0x50, 0xa4, 0x54, 0x89, 0xa5, 0x82, 0xf4, 0xe2, - 0xae, 0xd4, 0xb3, 0x50, 0x6a, 0x6f, 0x22, 0x4a, 0x10, 0x04, 0x2f, 0x65, 0xb2, 0x3b, 0xac, 0x25, - 0xa9, 0x1b, 0xba, 0x23, 0x9a, 0x1f, 0x21, 0xf8, 0xb3, 0x7a, 0xec, 0xd1, 0x93, 0x48, 0xfb, 0x47, - 0x24, 0x9b, 0x14, 0x44, 0xc5, 0xdb, 0xec, 0xdb, 0x79, 0xef, 0x7d, 0xec, 0x7a, 0x2d, 0xa3, 0x90, - 0x47, 0x48, 0x9c, 0xa6, 0x22, 0x46, 0x62, 0xe9, 0x5c, 0x93, 0xf6, 0x7d, 0xa3, 0xf0, 0x11, 0xe9, - 0x59, 0xcf, 0x63, 0x66, 0x14, 0xb2, 0x08, 0xa9, 0xd3, 0x52, 0x5a, 0x69, 0x7b, 0xcd, 0xf3, 0xa9, - 0xd8, 0xec, 0xe4, 0x9b, 0x9c, 0xb2, 0x14, 0x79, 0x9c, 0x89,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39, 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, } func (m *WagerTicketPayload) Marshal() (dAtA []byte, err error) { @@ -148,18 +148,16 @@ func (m *WagerTicketPayload) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.Meta != nil { - { - size, err := m.Meta.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTicket(dAtA, i, uint64(size)) + { + size, err := m.Meta.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } - i-- - dAtA[i] = 0x22 + i -= size + i = encodeVarintTicket(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x22 if len(m.AllOdds) > 0 { for iNdEx := len(m.AllOdds) - 1; iNdEx >= 0; iNdEx-- { { @@ -228,10 +226,8 @@ func (m *WagerTicketPayload) Size() (n int) { n += 1 + l + sovTicket(uint64(l)) } } - if m.Meta != nil { - l = m.Meta.Size() - n += 1 + l + sovTicket(uint64(l)) - } + l = m.Meta.Size() + n += 1 + l + sovTicket(uint64(l)) return n } @@ -402,9 +398,6 @@ func (m *WagerTicketPayload) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.Meta == nil { - m.Meta = &MetaData{} - } if err := m.Meta.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } From 83a34ff8133707fd7976f4b2c599a02f999798d0 Mon Sep 17 00:00:00 2001 From: scorpioborn <97235353+scorpioborn@users.noreply.github.com> Date: Tue, 31 Oct 2023 18:23:37 +0300 Subject: [PATCH 07/17] feat: validate metadata odds type --- x/bet/types/errors.go | 1 + x/bet/types/messages_bet.go | 3 +++ x/bet/types/ticket.go | 5 +++++ 3 files changed, 9 insertions(+) diff --git a/x/bet/types/errors.go b/x/bet/types/errors.go index 86f7182b..4939ae00 100644 --- a/x/bet/types/errors.go +++ b/x/bet/types/errors.go @@ -43,6 +43,7 @@ var ( ErrMaxLossMultiplierCanNotBeZero = sdkerrors.Register(ModuleName, 2034, "max loss multiplier cannot be nil or zero") ErrMaxLossMultiplierCanNotBeMoreThanOne = sdkerrors.Register(ModuleName, 2035, "max loss multiplier cannot be more than one") ErrInsufficientOdds = sdkerrors.Register(ModuleName, 2036, "market odds length not same as odds sent in wager") + ErrMetaOddsType = sdkerrors.Register(ModuleName, 2037, "invalid odds type in meta") ) // x/bet module sentinel error text diff --git a/x/bet/types/messages_bet.go b/x/bet/types/messages_bet.go index 6a3b1b80..cfcf7ef3 100644 --- a/x/bet/types/messages_bet.go +++ b/x/bet/types/messages_bet.go @@ -5,6 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/mrz1836/go-sanitize" "github.com/sge-network/sge/utils" ) @@ -69,6 +70,8 @@ func (msg *MsgWager) EmitEvent(ctx *sdk.Context) { // NewBet creates and returns a new bet from given message func NewBet(creator string, props *WagerProps, odds *BetOdds, meta MetaData) *Bet { + meta.SelectedOddsValue = sanitize.XSS(meta.SelectedOddsValue) + return &Bet{ Creator: creator, UID: props.UID, diff --git a/x/bet/types/ticket.go b/x/bet/types/ticket.go index 7bbc7c02..4a335d0c 100644 --- a/x/bet/types/ticket.go +++ b/x/bet/types/ticket.go @@ -14,6 +14,11 @@ func (payload *WagerTicketPayload) Validate(creator string) error { return ErrOddsDataNotFound } + if OddsType_ODDS_TYPE_UNSPECIFIED > payload.Meta.SelectedOddsType || + OddsType_ODDS_TYPE_MONEYLINE < payload.Meta.SelectedOddsType { + return sdkerrors.Wrapf(ErrMetaOddsType, "%s", payload.Meta.SelectedOddsType) + } + if err := payload.ValidateOdds(); err != nil { return sdkerrors.Wrapf(err, "%s", payload.SelectedOdds.UID) } From c27c5da66e1791b255d4151ee8cd407c57d0306f Mon Sep 17 00:00:00 2001 From: scorpioborn <97235353+scorpioborn@users.noreply.github.com> Date: Tue, 31 Oct 2023 18:42:40 +0300 Subject: [PATCH 08/17] fix: insuf liquidity orderbook error unwrap --- x/orderbook/keeper/bet_wager.go | 2 +- x/orderbook/keeper/bet_wager_test.go | 2 +- x/orderbook/types/errors.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/x/orderbook/keeper/bet_wager.go b/x/orderbook/keeper/bet_wager.go index 9e27e8a4..86fd519a 100644 --- a/x/orderbook/keeper/bet_wager.go +++ b/x/orderbook/keeper/bet_wager.go @@ -155,7 +155,7 @@ func (k Keeper) fulfillBetByParticipationQueue( } if fInfo.NoMoreLiquidityAvailable() { - return sdkerrors.Wrapf(types.ErrInternalProcessingBet, "insufficient liquidity in order book") + return types.ErrInsufficientLiquidityInOrderBook } return nil diff --git a/x/orderbook/keeper/bet_wager_test.go b/x/orderbook/keeper/bet_wager_test.go index 88c40547..10625988 100644 --- a/x/orderbook/keeper/bet_wager_test.go +++ b/x/orderbook/keeper/bet_wager_test.go @@ -259,7 +259,7 @@ func (ts *testBetSuite) placeBetsAndTest() ([]bettypes.Bet, sdk.Dec, sdk.Dec) { failedWinnerBetID, sdkmath.NewInt(100000000000), ts.betFee, - types.ErrInternalProcessingBet, + types.ErrInsufficientLiquidityInOrderBook, betOdds, oddUIDS, ) diff --git a/x/orderbook/types/errors.go b/x/orderbook/types/errors.go index 750c791d..bc568071 100644 --- a/x/orderbook/types/errors.go +++ b/x/orderbook/types/errors.go @@ -24,7 +24,7 @@ var ( ErrOrderBookParticipationNotFound = sdkerrors.Register(ModuleName, 6014, "book participation not found") ErrParticipationExposureNotFound = sdkerrors.Register(ModuleName, 6015, "participation exposure not found") ErrParticipationExposureAlreadyFilled = sdkerrors.Register(ModuleName, 6016, "participation exposure already filled") - ErrInternalProcessingBet = sdkerrors.Register(ModuleName, 6017, "internal error in processing bet") + ErrInsufficientLiquidityInOrderBook = sdkerrors.Register(ModuleName, 6017, "insufficient liquidity in orderbook") ErrBookParticipationAlreadySettled = sdkerrors.Register(ModuleName, 6018, "book participation already settled") ErrMismatchInDepositorAddress = sdkerrors.Register(ModuleName, 6019, "mismatch in depositor address") ErrWithdrawalAmountIsTooLarge = sdkerrors.Register(ModuleName, 6020, "withdrawal amount more than available amount for withdrawal") From ec45289b7d959f47bb75e81051bc4bccb9f0fbd1 Mon Sep 17 00:00:00 2001 From: scorpioborn <97235353+scorpioborn@users.noreply.github.com> Date: Tue, 31 Oct 2023 18:47:32 +0300 Subject: [PATCH 09/17] fix: unwrap all bet wager errors --- x/bet/keeper/msg_server_bet.go | 2 +- x/bet/keeper/wager.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/x/bet/keeper/msg_server_bet.go b/x/bet/keeper/msg_server_bet.go index 04e4ec99..e73071b9 100644 --- a/x/bet/keeper/msg_server_bet.go +++ b/x/bet/keeper/msg_server_bet.go @@ -33,7 +33,7 @@ func (k msgServer) Wager( bet := types.NewBet(msg.Creator, msg.Props, payload.SelectedOdds, payload.Meta) if err := k.Keeper.Wager(ctx, bet, payload.OddsMap()); err != nil { - return nil, sdkerrors.Wrapf(types.ErrInWager, "%s", err) + return nil, err } msg.EmitEvent(&ctx) diff --git a/x/bet/keeper/wager.go b/x/bet/keeper/wager.go index 1d18fe5a..a01f6645 100644 --- a/x/bet/keeper/wager.go +++ b/x/bet/keeper/wager.go @@ -60,7 +60,7 @@ func (k Keeper) Wager(ctx sdk.Context, bet *types.Bet, betOdds map[string]*types bettorAddress, bet.Fee, bet.OddsValue, betID, betOdds, market.OddsUIDS(), ) if err != nil { - return sdkerrors.Wrapf(types.ErrInOBWagerProcessing, "%s", err) + return err } // set bet as placed From 6c234c069b03b31d8b902e115948f8103ea2cbd8 Mon Sep 17 00:00:00 2001 From: scorpioborn <97235353+scorpioborn@users.noreply.github.com> Date: Tue, 31 Oct 2023 19:06:00 +0300 Subject: [PATCH 10/17] test: fix no matching market error --- x/bet/keeper/msg_server_bet_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/bet/keeper/msg_server_bet_test.go b/x/bet/keeper/msg_server_bet_test.go index e423b5ba..a8ad0cf1 100644 --- a/x/bet/keeper/msg_server_bet_test.go +++ b/x/bet/keeper/msg_server_bet_test.go @@ -105,7 +105,7 @@ func TestBetMsgServerWager(t *testing.T) { } _, err = msgk.Wager(wctx, inputBet) - require.ErrorIs(t, types.ErrInWager, err) + require.ErrorIs(t, types.ErrNoMatchingMarket, err) }) t.Run("Success", func(t *testing.T) { 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 11/17] 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, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x91, 0x41, 0x4b, 0xc3, 0x40, - 0x10, 0x85, 0x93, 0xb6, 0xd8, 0x92, 0xea, 0xc1, 0x50, 0xa4, 0x54, 0x89, 0xa5, 0x82, 0xf4, 0xe2, - 0x2e,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, 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, 0x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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:]) From 26bc08da473d4f0bf1cbb211df8330e7eb9e45b3 Mon Sep 17 00:00:00 2001 From: P-U-D-G-E Date: Thu, 2 Nov 2023 14:17:02 +0530 Subject: [PATCH 12/17] empty commit From 3c12595d9da2d8c9d993c94e024139ab0541ddf9 Mon Sep 17 00:00:00 2001 From: P-U-D-G-E Date: Thu, 2 Nov 2023 15:32:07 +0530 Subject: [PATCH 13/17] changes fields numbering in bet.proto and ticket.proto --- proto/sge/bet/bet.proto | 22 +++--- proto/sge/bet/ticket.proto | 6 +- x/bet/types/bet.pb.go | 150 ++++++++++++++++++------------------- x/bet/types/ticket.pb.go | 38 +++++----- 4 files changed, 108 insertions(+), 108 deletions(-) diff --git a/proto/sge/bet/bet.proto b/proto/sge/bet/bet.proto index 7e131b39..8f718100 100644 --- a/proto/sge/bet/bet.proto +++ b/proto/sge/bet/bet.proto @@ -32,46 +32,46 @@ message Bet { ]; // odds_value is the odds on which the bet is placed. - string odds_value = 4; + string odds_value = 5; // amount is the wager amount. - string amount = 5 [ + string amount = 6 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; // fee is the betting fee user needs to pay for placing a bet - string fee = 6 [ + string fee = 7 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; // status is the status of the bet, such as `unspecified` or `settled`. - Status status = 7; + Status status = 8; // result is the result of the bet, such as `won` or `lost`. - Result result = 8; + Result result = 9; // creator is the bettor address. - string creator = 9; + string creator = 10; // created_at is the bet placement timestamp. - int64 created_at = 10; + int64 created_at = 11; // settlement_height is the block height at which the bet is settled. - int64 settlement_height = 11; + int64 settlement_height = 12; // max_loss_multiplier is the multiplier coefficient of max loss. - string max_loss_multiplier = 12 [ + string max_loss_multiplier = 13 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false ]; // bet_fulfillment is the fulfillment data. - repeated BetFulfillment bet_fulfillment = 13; + repeated BetFulfillment bet_fulfillment = 14; // meta is metadata for bet - MetaData meta = 14 [ (gogoproto.nullable) = false ]; + MetaData meta = 15 [ (gogoproto.nullable) = false ]; // Status of the Bet. enum Status { diff --git a/proto/sge/bet/ticket.proto b/proto/sge/bet/ticket.proto index b6248b4f..d9f7c157 100644 --- a/proto/sge/bet/ticket.proto +++ b/proto/sge/bet/ticket.proto @@ -17,9 +17,9 @@ message WagerTicketPayload { sgenetwork.sge.type.KycDataPayload kyc_data = 2 [ (gogoproto.nullable) = false ]; // all odds for the selected market. - repeated BetOddsCompact all_odds = 3; + repeated BetOddsCompact all_odds = 4; // meta is metadata for bet placement - MetaData meta = 4 [ (gogoproto.nullable) = false ]; + MetaData meta = 5 [ (gogoproto.nullable) = false ]; // context contains the data from services and just for processing purpose. - string context = 5; + string context = 6; } diff --git a/x/bet/types/bet.pb.go b/x/bet/types/bet.pb.go index b92ad640..0a235fc8 100644 --- a/x/bet/types/bet.pb.go +++ b/x/bet/types/bet.pb.go @@ -123,27 +123,27 @@ type Bet struct { // of the odds on which the bet is placed. OddsUID string `protobuf:"bytes,3,opt,name=odds_uid,proto3" json:"odds_uid"` // odds_value is the odds on which the bet is placed. - OddsValue string `protobuf:"bytes,4,opt,name=odds_value,json=oddsValue,proto3" json:"odds_value,omitempty"` + OddsValue string `protobuf:"bytes,5,opt,name=odds_value,json=oddsValue,proto3" json:"odds_value,omitempty"` // amount is the wager amount. - Amount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount"` + Amount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,6,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount"` // fee is the betting fee user needs to pay for placing a bet - Fee github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,6,opt,name=fee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"fee"` + Fee github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,7,opt,name=fee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"fee"` // status is the status of the bet, such as `unspecified` or `settled`. - Status Bet_Status `protobuf:"varint,7,opt,name=status,proto3,enum=sgenetwork.sge.bet.Bet_Status" json:"status,omitempty"` + Status Bet_Status `protobuf:"varint,8,opt,name=status,proto3,enum=sgenetwork.sge.bet.Bet_Status" json:"status,omitempty"` // result is the result of the bet, such as `won` or `lost`. - Result Bet_Result `protobuf:"varint,8,opt,name=result,proto3,enum=sgenetwork.sge.bet.Bet_Result" json:"result,omitempty"` + Result Bet_Result `protobuf:"varint,9,opt,name=result,proto3,enum=sgenetwork.sge.bet.Bet_Result" json:"result,omitempty"` // creator is the bettor address. - Creator string `protobuf:"bytes,9,opt,name=creator,proto3" json:"creator,omitempty"` + Creator string `protobuf:"bytes,10,opt,name=creator,proto3" json:"creator,omitempty"` // created_at is the bet placement timestamp. - CreatedAt int64 `protobuf:"varint,10,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` + CreatedAt int64 `protobuf:"varint,11,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` // settlement_height is the block height at which the bet is settled. - SettlementHeight int64 `protobuf:"varint,11,opt,name=settlement_height,json=settlementHeight,proto3" json:"settlement_height,omitempty"` + SettlementHeight int64 `protobuf:"varint,12,opt,name=settlement_height,json=settlementHeight,proto3" json:"settlement_height,omitempty"` // max_loss_multiplier is the multiplier coefficient of max loss. - MaxLossMultiplier github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,12,opt,name=max_loss_multiplier,json=maxLossMultiplier,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"max_loss_multiplier"` + MaxLossMultiplier github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,13,opt,name=max_loss_multiplier,json=maxLossMultiplier,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"max_loss_multiplier"` // bet_fulfillment is the fulfillment data. - BetFulfillment []*BetFulfillment `protobuf:"bytes,13,rep,name=bet_fulfillment,json=betFulfillment,proto3" json:"bet_fulfillment,omitempty"` + BetFulfillment []*BetFulfillment `protobuf:"bytes,14,rep,name=bet_fulfillment,json=betFulfillment,proto3" json:"bet_fulfillment,omitempty"` // meta is metadata for bet - Meta MetaData `protobuf:"bytes,14,opt,name=meta,proto3" json:"meta"` + Meta MetaData `protobuf:"bytes,15,opt,name=meta,proto3" json:"meta"` } func (m *Bet) Reset() { *m = Bet{} } @@ -569,51 +569,51 @@ var fileDescriptor_9bc076bb1a4d9f6e = []byte{ 0x32, 0x47, 0x31, 0xff, 0x87, 0xbe, 0x00, 0x08, 0xdd, 0xf8, 0x8a, 0x30, 0x87, 0x13, 0x33, 0x82, 0xf8, 0xd1, 0x6a, 0x59, 0xce, 0x9f, 0x0b, 0x34, 0xa1, 0xa7, 0x28, 0x38, 0x35, 0x46, 0xaf, 0x60, 0x4f, 0x44, 0xe6, 0x52, 0x55, 0x48, 0x9f, 0xaf, 0x96, 0xe5, 0xdd, 0x9e, 0xe7, 0xd1, 0x44, 0xb8, - 0x59, 0xc6, 0x9b, 0x11, 0xfa, 0x18, 0x40, 0x8c, 0x7f, 0x74, 0x83, 0x05, 0xd1, 0xb3, 0x5c, 0x86, - 0xf3, 0x1c, 0xf9, 0x86, 0x03, 0xa8, 0x05, 0x39, 0x37, 0x8c, 0x16, 0x33, 0xa6, 0x3f, 0x11, 0x8e, + 0x59, 0xc6, 0x9b, 0x11, 0xfa, 0x18, 0x40, 0x8c, 0x7f, 0x74, 0x83, 0x05, 0xd1, 0x9f, 0x70, 0x19, + 0xce, 0x73, 0xe4, 0x1b, 0x0e, 0xa0, 0x16, 0xe4, 0xdc, 0x30, 0x5a, 0xcc, 0x98, 0x9e, 0x13, 0x8e, 0xe6, 0xdb, 0x65, 0x79, 0xe7, 0xcf, 0x65, 0xf9, 0xd3, 0xa9, 0xcf, 0x2e, 0x17, 0x63, 0x73, 0x12, 0x85, 0xb5, 0x49, 0x44, 0xc3, 0x88, 0xca, 0x9f, 0x97, 0xd4, 0xbb, 0xaa, 0xf1, 0xb3, 0x53, 0xb3, - 0x3d, 0x63, 0x58, 0xaa, 0xd1, 0x1b, 0x50, 0x2f, 0x08, 0xd1, 0x73, 0x1f, 0x64, 0xc2, 0xa5, 0xe8, - 0x35, 0xe4, 0x28, 0x73, 0xd9, 0x82, 0xea, 0xbb, 0x15, 0xa5, 0x5a, 0x38, 0x2d, 0x99, 0xff, 0xfe, - 0x30, 0x66, 0x83, 0x30, 0x73, 0x20, 0x58, 0x58, 0xb2, 0xb9, 0x2e, 0x26, 0x74, 0x11, 0x30, 0x7d, - 0xef, 0xff, 0x75, 0x58, 0xb0, 0xb0, 0x64, 0x23, 0x1d, 0x76, 0x27, 0x31, 0x71, 0x59, 0x14, 0xeb, - 0x79, 0x71, 0x2b, 0xeb, 0x29, 0xbf, 0x32, 0x31, 0x24, 0x9e, 0xe3, 0x32, 0x1d, 0x2a, 0x4a, 0x55, - 0xc5, 0x79, 0x89, 0xd4, 0x19, 0xfa, 0x0c, 0x8a, 0x94, 0x30, 0x16, 0x90, 0x90, 0xcc, 0x98, 0x73, - 0x49, 0xfc, 0xe9, 0x25, 0xd3, 0xf7, 0x05, 0x4b, 0xbb, 0x5b, 0x38, 0x13, 0x38, 0xfa, 0x1e, 0x8e, - 0x43, 0xf7, 0xda, 0x09, 0x22, 0x4a, 0x9d, 0x70, 0x11, 0x30, 0x7f, 0x1e, 0xf8, 0x24, 0xd6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 0x79, 0xbb, 0x2a, + 0x29, 0xef, 0x56, 0x25, 0xe5, 0xaf, 0x55, 0x49, 0xf9, 0xed, 0xb6, 0xb4, 0xf3, 0xee, 0xb6, 0xb4, + 0xf3, 0xc7, 0x6d, 0x69, 0xe7, 0xbb, 0xf4, 0x81, 0xe9, 0x94, 0xbc, 0x94, 0x9b, 0xe0, 0xe3, 0xda, + 0xb5, 0x68, 0xaa, 0xe2, 0xd0, 0xe3, 0x9c, 0xe8, 0xa8, 0xaf, 0xfe, 0x09, 0x00, 0x00, 0xff, 0xff, + 0x87, 0x9e, 0x01, 0xc1, 0xa9, 0x07, 0x00, 0x00, } func (m *Bet) Marshal() (dAtA []byte, err error) { @@ -645,7 +645,7 @@ func (m *Bet) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintBet(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x72 + dAtA[i] = 0x7a if len(m.BetFulfillment) > 0 { for iNdEx := len(m.BetFulfillment) - 1; iNdEx >= 0; iNdEx-- { { @@ -657,7 +657,7 @@ func (m *Bet) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintBet(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x6a + dAtA[i] = 0x72 } } { @@ -669,33 +669,33 @@ func (m *Bet) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintBet(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x62 + dAtA[i] = 0x6a if m.SettlementHeight != 0 { i = encodeVarintBet(dAtA, i, uint64(m.SettlementHeight)) i-- - dAtA[i] = 0x58 + dAtA[i] = 0x60 } if m.CreatedAt != 0 { i = encodeVarintBet(dAtA, i, uint64(m.CreatedAt)) i-- - dAtA[i] = 0x50 + dAtA[i] = 0x58 } if len(m.Creator) > 0 { i -= len(m.Creator) copy(dAtA[i:], m.Creator) i = encodeVarintBet(dAtA, i, uint64(len(m.Creator))) i-- - dAtA[i] = 0x4a + dAtA[i] = 0x52 } if m.Result != 0 { i = encodeVarintBet(dAtA, i, uint64(m.Result)) i-- - dAtA[i] = 0x40 + dAtA[i] = 0x48 } if m.Status != 0 { i = encodeVarintBet(dAtA, i, uint64(m.Status)) i-- - dAtA[i] = 0x38 + dAtA[i] = 0x40 } { size := m.Fee.Size() @@ -706,7 +706,7 @@ func (m *Bet) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintBet(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x32 + dAtA[i] = 0x3a { size := m.Amount.Size() i -= size @@ -716,13 +716,13 @@ func (m *Bet) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintBet(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x2a + dAtA[i] = 0x32 if len(m.OddsValue) > 0 { i -= len(m.OddsValue) copy(dAtA[i:], m.OddsValue) i = encodeVarintBet(dAtA, i, uint64(len(m.OddsValue))) i-- - dAtA[i] = 0x22 + dAtA[i] = 0x2a } if len(m.OddsUID) > 0 { i -= len(m.OddsUID) @@ -1230,7 +1230,7 @@ func (m *Bet) Unmarshal(dAtA []byte) error { } m.OddsUID = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 4: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field OddsValue", wireType) } @@ -1262,7 +1262,7 @@ func (m *Bet) Unmarshal(dAtA []byte) error { } m.OddsValue = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 5: + case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) } @@ -1296,7 +1296,7 @@ func (m *Bet) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 6: + case 7: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Fee", wireType) } @@ -1330,7 +1330,7 @@ func (m *Bet) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 7: + case 8: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) } @@ -1349,7 +1349,7 @@ func (m *Bet) Unmarshal(dAtA []byte) error { break } } - case 8: + case 9: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Result", wireType) } @@ -1368,7 +1368,7 @@ func (m *Bet) Unmarshal(dAtA []byte) error { break } } - case 9: + case 10: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) } @@ -1400,7 +1400,7 @@ func (m *Bet) Unmarshal(dAtA []byte) error { } m.Creator = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 10: + case 11: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field CreatedAt", wireType) } @@ -1419,7 +1419,7 @@ func (m *Bet) Unmarshal(dAtA []byte) error { break } } - case 11: + case 12: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field SettlementHeight", wireType) } @@ -1438,7 +1438,7 @@ func (m *Bet) Unmarshal(dAtA []byte) error { break } } - case 12: + case 13: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field MaxLossMultiplier", wireType) } @@ -1472,7 +1472,7 @@ func (m *Bet) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 13: + case 14: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field BetFulfillment", wireType) } @@ -1506,7 +1506,7 @@ func (m *Bet) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 14: + case 15: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Meta", wireType) } diff --git a/x/bet/types/ticket.pb.go b/x/bet/types/ticket.pb.go index 2f8899a2..c93dab7f 100644 --- a/x/bet/types/ticket.pb.go +++ b/x/bet/types/ticket.pb.go @@ -31,11 +31,11 @@ type WagerTicketPayload struct { // kyc_data contains the details of user kyc. KycData types.KycDataPayload `protobuf:"bytes,2,opt,name=kyc_data,json=kycData,proto3" json:"kyc_data"` // all odds for the selected market. - AllOdds []*BetOddsCompact `protobuf:"bytes,3,rep,name=all_odds,json=allOdds,proto3" json:"all_odds,omitempty"` + AllOdds []*BetOddsCompact `protobuf:"bytes,4,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"` + Meta MetaData `protobuf:"bytes,5,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"` + Context string `protobuf:"bytes,6,opt,name=context,proto3" json:"context,omitempty"` } func (m *WagerTicketPayload) Reset() { *m = WagerTicketPayload{} } @@ -115,7 +115,7 @@ func init() { proto.RegisterFile("sge/bet/ticket.proto", fileDescriptor_cf6959e7 var fileDescriptor_cf6959e7db451613 = []byte{ // 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, + 0x14, 0x86, 0x93, 0xde, 0xde, 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, @@ -127,15 +127,15 @@ var fileDescriptor_cf6959e7db451613 = []byte{ 0x40, 0x02, 0x02, 0x41, 0xda, 0x03, 0xbe, 0xdb, 0x71, 0x7b, 0xcd, 0xfe, 0x3e, 0xfd, 0xce, 0x45, 0x87, 0x80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x10, 0xaa, 0x9d, 0x3f, 0xbd, 0x66, 0xbf, 0xfb, 0x0b, 0xc2, 0x85, 0x9e, 0xa6, 0x5c, 0x60, + 0x58, 0xe7, 0x49, 0x62, 0x21, 0xce, 0xbc, 0xea, 0x14, 0x90, 0xfb, 0x7f, 0x2d, 0xc0, 0xc1, 0x4f, + 0xd1, 0x2b, 0x40, 0x9e, 0x57, 0x95, 0xcd, 0xd6, 0x4f, 0x7c, 0xaf, 0x2e, 0xf4, 0x0c, 0x61, 0x81, + 0x7e, 0xad, 0xe3, 0xf6, 0xfe, 0x85, 0xdb, 0x75, 0x38, 0x58, 0xae, 0x03, 0x77, 0xb5, 0x0e, 0xdc, + 0xf7, 0x75, 0xe0, 0x3e, 0x6f, 0x02, 0x67, 0xb5, 0x09, 0x9c, 0xd7, 0x4d, 0xe0, 0xdc, 0x1f, 0xab, + 0x09, 0x3e, 0x3c, 0x46, 0x54, 0xe8, 0x29, 0x33, 0x0a, 0x4e, 0xca, 0xa2, 0x7c, 0x66, 0x8b, 0xe2, + 0x85, 0xb3, 0x14, 0x4c, 0x54, 0xb3, 0x3f, 0xfe, 0xf4, 0x23, 0x00, 0x00, 0xff, 0xff, 0xc7, 0xac, + 0x67, 0x89, 0xf9, 0x01, 0x00, 0x00, } func (m *WagerTicketPayload) Marshal() (dAtA []byte, err error) { @@ -163,7 +163,7 @@ func (m *WagerTicketPayload) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.Context) i = encodeVarintTicket(dAtA, i, uint64(len(m.Context))) i-- - dAtA[i] = 0x2a + dAtA[i] = 0x32 } { size, err := m.Meta.MarshalToSizedBuffer(dAtA[:i]) @@ -174,7 +174,7 @@ func (m *WagerTicketPayload) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTicket(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x22 + dAtA[i] = 0x2a if len(m.AllOdds) > 0 { for iNdEx := len(m.AllOdds) - 1; iNdEx >= 0; iNdEx-- { { @@ -186,7 +186,7 @@ func (m *WagerTicketPayload) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTicket(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x1a + dAtA[i] = 0x22 } } { @@ -356,7 +356,7 @@ func (m *WagerTicketPayload) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 3: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field AllOdds", wireType) } @@ -390,7 +390,7 @@ func (m *WagerTicketPayload) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 4: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Meta", wireType) } @@ -423,7 +423,7 @@ func (m *WagerTicketPayload) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 5: + case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Context", wireType) } From 11676f40df229c7812ccdd454aecd41c6920d954 Mon Sep 17 00:00:00 2001 From: P-U-D-G-E Date: Thu, 2 Nov 2023 15:34:59 +0530 Subject: [PATCH 14/17] modified bet_state.md --- docs/specs/Bet/04_State.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/specs/Bet/04_State.md b/docs/specs/Bet/04_State.md index ea8c5955..0110a758 100644 --- a/docs/specs/Bet/04_State.md +++ b/docs/specs/Bet/04_State.md @@ -90,46 +90,46 @@ message Bet { ]; // odds_value is the odds on which the bet is placed. - string odds_value = 4; + string odds_value = 5; // amount is the wager amount. - string amount = 5 [ + string amount = 6 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; // fee is the betting fee user needs to pay for placing a bet - string fee = 6 [ + string fee = 7 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; // status is the status of the bet, such as `unspecified` or `settled`. - Status status = 7; + Status status = 8; // result is the result of the bet, such as `won` or `lost`. - Result result = 8; + Result result = 9; // creator is the bettor address. - string creator = 9; + string creator = 10; // created_at is the bet placement timestamp. - int64 created_at = 10; + int64 created_at = 11; // settlement_height is the block height at which the bet is settled. - int64 settlement_height = 11; + int64 settlement_height = 12; // max_loss_multiplier is the multiplier coefficient of max loss. - string max_loss_multiplier = 12 [ + string max_loss_multiplier = 13 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false ]; // bet_fulfillment is the fulfillment data. - repeated BetFulfillment bet_fulfillment = 13; + repeated BetFulfillment bet_fulfillment = 14; // meta is metadata for bet - MetaData meta = 14; + MetaData meta = 15; // Status of the Bet. enum Status { From c56c4d37dfe4d882a119b498263481f4b152279d Mon Sep 17 00:00:00 2001 From: P-U-D-G-E Date: Fri, 3 Nov 2023 18:41:20 +0530 Subject: [PATCH 15/17] adds max withdrawal count per deposit --- config.yml | 6 ++- proto/sge/house/params.proto | 5 ++ x/house/keeper/msg_server_withdraw.go | 4 ++ x/house/keeper/params.go | 5 ++ x/house/types/errors.go | 1 + x/house/types/params.go | 27 +++++++++- x/house/types/params.pb.go | 78 ++++++++++++++++++++------- 7 files changed, 105 insertions(+), 21 deletions(-) diff --git a/config.yml b/config.yml index 17ffd503..b1632abb 100644 --- a/config.yml +++ b/config.yml @@ -8,6 +8,7 @@ accounts: - name: admin mnemonic: patch donor arena plug burst silk cram day charge valve prize awake remind wolf resource silk oyster man tray police ritual immune foot beef - name: oracle + coins: ["100000000000000usge"] mnemonic: better ketchup radio relax scheme worth foam utility bamboo moon slab trade tackle hobby once pass daughter isolate nice cost level swim view final validators: - name: cold @@ -33,7 +34,7 @@ genesis: ovm: key_vault: public_keys: [ - "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEAdUWfzVUf4BqsHvErsJoXIaIpO60CHXfaaef+xKU3bbY=\n-----END PUBLIC KEY-----", + "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEAzoP3SVo1tUEhd+cF/zw+8XxtOScdJyD7T3QqKzpC9x0=\n-----END PUBLIC KEY-----", "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEA58w+676YVp61kjXDrteK8hDxulq5zbF6sNHQt3Lt5Ng=\n-----END PUBLIC KEY-----", "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEAw5iPKVbSvyF1A1HDFaWMGlhBp/xTU70i8lMgOml79WM=\n-----END PUBLIC KEY-----", "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEAueEgZMdKn6Bp0mcG04HrNAt1a0o7+0eNliQCNmbxkOQ=\n-----END PUBLIC KEY-----", @@ -64,3 +65,6 @@ genesis: orderbook: params: requeue_threshold: "1000" + house: + params: + max_withdrawal_count: 1 diff --git a/proto/sge/house/params.proto b/proto/sge/house/params.proto index d5e4f6ca..697aa760 100644 --- a/proto/sge/house/params.proto +++ b/proto/sge/house/params.proto @@ -22,4 +22,9 @@ message Params { (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false ]; + + // max_withdrawal_count is the maximum number of withdrawals allowed + // per participation index. + uint64 max_withdrawal_count = 3 + [ (gogoproto.moretags) = "yaml:\"max_withdrawal_count\""]; } diff --git a/x/house/keeper/msg_server_withdraw.go b/x/house/keeper/msg_server_withdraw.go index 23d0893a..9fab3047 100644 --- a/x/house/keeper/msg_server_withdraw.go +++ b/x/house/keeper/msg_server_withdraw.go @@ -36,6 +36,10 @@ func (k msgServer) Withdraw(goCtx context.Context, return nil, sdkerrors.Wrapf(types.ErrDepositNotFound, ": %s, %d", msg.MarketUID, msg.ParticipationIndex) } + if deposit.WithdrawalCount >= k.GetMaxWithdrawalCount(ctx) { + return nil, sdkerrors.Wrapf(types.ErrMaxWithdrawalCountReached, ": %d", deposit.WithdrawalCount) + } + var err error msg.Amount, err = k.orderbookKeeper.CalcWithdrawalAmount(ctx, depositorAddr, diff --git a/x/house/keeper/params.go b/x/house/keeper/params.go index 893dbf2a..9fd0033c 100644 --- a/x/house/keeper/params.go +++ b/x/house/keeper/params.go @@ -27,3 +27,8 @@ func (k Keeper) GetMinAllowedDepositAmount(ctx sdk.Context) (res sdkmath.Int) { func (k Keeper) GetHouseParticipationFee(ctx sdk.Context) (res sdk.Dec) { return k.GetParams(ctx).HouseParticipationFee } + +// GetMaxWithdrawalCount returns number of max withdrawals allowed per participation +func (k Keeper) GetMaxWithdrawalCount(ctx sdk.Context) (res uint64) { + return k.GetParams(ctx).MaxWithdrawalCount +} diff --git a/x/house/types/errors.go b/x/house/types/errors.go index 39acaa56..1186f0c8 100644 --- a/x/house/types/errors.go +++ b/x/house/types/errors.go @@ -22,4 +22,5 @@ var ( ErrUserKycFailed = sdkerrors.Register(ModuleName, 5012, "the account failed the KYC Validation") ErrAuthorizationNotFound = sdkerrors.Register(ModuleName, 5013, "no authorization found") ErrAuthorizationNotAccepted = sdkerrors.Register(ModuleName, 5014, "authorization not accepted") + ErrMaxWithdrawalCountReached = sdkerrors.Register(ModuleName, 5015, "maximum withdrawals per deposit reached") ) diff --git a/x/house/types/params.go b/x/house/types/params.go index faab4fbe..52b2ea35 100644 --- a/x/house/types/params.go +++ b/x/house/types/params.go @@ -16,11 +16,15 @@ const ( // DefaultHouseParticipationFee is default house participation fee. DefaultHouseParticipationFee string = "0.1" + + // DefaultMaxWithdrawalCount is default maximum withdrawals allowed per participation. + DefaultMaxWithdrawalCount uint64 = 1 ) var ( keyMinDeposit = []byte("MinDeposit") keyHouseParticipationFee = []byte("HouseParticipationFee") + keyMaxWithdrawalCount = []byte("MaxWithdrawalCount") ) // ParamKeyTable for house module @@ -29,10 +33,11 @@ func ParamKeyTable() paramtypes.KeyTable { } // NewParams creates a new Params instance -func NewParams(minDeposit sdkmath.Int, houseParticipationFee sdk.Dec) Params { +func NewParams(minDeposit sdkmath.Int, houseParticipationFee sdk.Dec, maxWithdrawalCount uint64) Params { return Params{ MinDeposit: minDeposit, HouseParticipationFee: houseParticipationFee, + MaxWithdrawalCount: maxWithdrawalCount, } } @@ -49,6 +54,11 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { &p.HouseParticipationFee, validateHouseParticipationFee, ), + paramtypes.NewParamSetPair( + keyMaxWithdrawalCount, + &p.MaxWithdrawalCount, + validateMaxWithdrawalCount, + ), } } @@ -57,6 +67,7 @@ func DefaultParams() Params { return NewParams( sdk.NewInt(DefaultMinDeposit), sdk.MustNewDecFromStr(DefaultHouseParticipationFee), + DefaultMaxWithdrawalCount, ) } @@ -105,3 +116,17 @@ func validateHouseParticipationFee(i interface{}) error { return nil } + +// validateMaxWithdrawalCount performs validation of max withdrawal count +func validateMaxWithdrawalCount(i interface{}) error { + v, ok := i.(uint64) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if v < 1 { + return fmt.Errorf("max withdrawal count cannot be lower than 1: %d", v) + } + + return nil +} diff --git a/x/house/types/params.pb.go b/x/house/types/params.pb.go index a001ac4f..446aa53f 100644 --- a/x/house/types/params.pb.go +++ b/x/house/types/params.pb.go @@ -31,6 +31,9 @@ type Params struct { // house_participation_fee is the % of the deposit to be paid for a house // participation by the depositor. HouseParticipationFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=house_participation_fee,json=houseParticipationFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"house_participation_fee"` + // max_withdrawal_count is the maximum number of withdrawals allowed + // per participation index. + MaxWithdrawalCount uint64 `protobuf:"varint,3,opt,name=max_withdrawal_count,json=maxWithdrawalCount,proto3" json:"max_withdrawal_count,omitempty" yaml:"max_withdrawal_count"` } func (m *Params) Reset() { *m = Params{} } @@ -65,6 +68,13 @@ func (m *Params) XXX_DiscardUnknown() { var xxx_messageInfo_Params proto.InternalMessageInfo +func (m *Params) GetMaxWithdrawalCount() uint64 { + if m != nil { + return m.MaxWithdrawalCount + } + return 0 +} + func init() { proto.RegisterType((*Params)(nil), "sgenetwork.sge.house.Params") } @@ -72,25 +82,28 @@ func init() { func init() { proto.RegisterFile("sge/house/params.proto", fileDescriptor_632fcdf2e68e6d32) } var fileDescriptor_632fcdf2e68e6d32 = []byte{ - // 277 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2b, 0x4e, 0x4f, 0xd5, - 0xcf, 0xc8, 0x2f, 0x2d, 0x4e, 0xd5, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, - 0x2f, 0xc9, 0x17, 0x12, 0x29, 0x4e, 0x4f, 0xcd, 0x4b, 0x2d, 0x29, 0xcf, 0x2f, 0xca, 0xd6, 0x2b, - 0x4e, 0x4f, 0xd5, 0x03, 0x2b, 0x91, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x2b, 0xd0, 0x07, 0xb1, - 0x20, 0x6a, 0x95, 0xee, 0x32, 0x72, 0xb1, 0x05, 0x80, 0x35, 0x0b, 0xa5, 0x72, 0x71, 0xe7, 0x66, - 0xe6, 0xc5, 0xa7, 0xa4, 0x16, 0xe4, 0x17, 0x67, 0x96, 0x48, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x3a, - 0xb9, 0x9c, 0xb8, 0x27, 0xcf, 0x70, 0xeb, 0x9e, 0xbc, 0x5a, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, - 0x5e, 0x72, 0x7e, 0xae, 0x7e, 0x72, 0x7e, 0x71, 0x6e, 0x7e, 0x31, 0x94, 0xd2, 0x2d, 0x4e, 0xc9, - 0xd6, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0xf3, 0xcc, 0x2b, 0xf9, 0x74, 0x4f, 0x5e, 0xa8, 0x32, - 0x31, 0x37, 0xc7, 0x4a, 0x09, 0xc9, 0x28, 0xa5, 0x20, 0xae, 0xdc, 0xcc, 0x3c, 0x17, 0x08, 0x47, - 0x28, 0x8d, 0x4b, 0x1c, 0xec, 0xa0, 0xf8, 0x82, 0xc4, 0xa2, 0x92, 0xcc, 0xe4, 0xcc, 0x82, 0xc4, - 0x92, 0xcc, 0xfc, 0xbc, 0xf8, 0xb4, 0xd4, 0x54, 0x09, 0x26, 0xb0, 0x95, 0x7a, 0x24, 0x58, 0xe9, - 0x92, 0x9a, 0x1c, 0x24, 0x0a, 0x36, 0x2e, 0x00, 0xd9, 0x34, 0xb7, 0xd4, 0x54, 0x2b, 0x96, 0x19, - 0x0b, 0xe4, 0x19, 0x9c, 0x9c, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, - 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0x4a, - 0x03, 0xc9, 0xf8, 0xe2, 0xf4, 0x54, 0x5d, 0x68, 0x88, 0x81, 0xd8, 0xfa, 0x15, 0xd0, 0x60, 0x05, - 0x5b, 0x92, 0xc4, 0x06, 0x0e, 0x2a, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0xfe, 0x9e, 0x0a, - 0x2d, 0x70, 0x01, 0x00, 0x00, + // 327 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x91, 0xb1, 0x6e, 0xf2, 0x30, + 0x10, 0xc7, 0x13, 0x3e, 0x84, 0xf4, 0xa5, 0x5b, 0x44, 0x5b, 0xd4, 0x4a, 0x09, 0xca, 0x50, 0xb1, + 0x10, 0x0f, 0xdd, 0x18, 0x53, 0x54, 0xa9, 0x1b, 0x65, 0xa9, 0xd4, 0x25, 0x32, 0xe1, 0x30, 0x16, + 0xd8, 0x67, 0xc5, 0x46, 0xc0, 0x5b, 0x74, 0xec, 0xd8, 0x47, 0xe8, 0x63, 0x30, 0x32, 0x56, 0x1d, + 0xa2, 0x0a, 0xde, 0x80, 0x27, 0xa8, 0x30, 0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fe, 0x42, + 0x45, 0x43, 0x5f, 0xd0, 0xd5, 0xd3, 0x4f, 0xf7, 0xee, 0xd8, 0xec, 0xd5, 0x5f, 0xdf, 0x42, 0x27, + 0x49, 0x36, 0xbb, 0xc0, 0xdd, 0xee, 0x02, 0xf7, 0x6b, 0x17, 0xb8, 0x2f, 0xfb, 0xc0, 0xd9, 0xee, + 0x03, 0xe7, 0x63, 0x1f, 0x38, 0xcf, 0x9d, 0x8a, 0xb1, 0x66, 0xd0, 0x2d, 0x97, 0x70, 0xac, 0xc9, + 0xaa, 0xdc, 0x94, 0xf5, 0x1e, 0x35, 0xec, 0xef, 0xdf, 0x7e, 0x07, 0x00, 0x00, 0xff, 0xff, 0xd0, + 0x1a, 0x41, 0x56, 0xc3, 0x01, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -113,6 +126,11 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.MaxWithdrawalCount != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.MaxWithdrawalCount)) + i-- + dAtA[i] = 0x18 + } { size := m.HouseParticipationFee.Size() i -= size @@ -157,6 +175,9 @@ func (m *Params) Size() (n int) { n += 1 + l + sovParams(uint64(l)) l = m.HouseParticipationFee.Size() n += 1 + l + sovParams(uint64(l)) + if m.MaxWithdrawalCount != 0 { + n += 1 + sovParams(uint64(m.MaxWithdrawalCount)) + } return n } @@ -263,6 +284,25 @@ func (m *Params) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxWithdrawalCount", wireType) + } + m.MaxWithdrawalCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxWithdrawalCount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:]) From 465f05b07d04dc34ed4c9f236685a1ba3d5b9fb9 Mon Sep 17 00:00:00 2001 From: Born in Scorpio <97235353+scorpioborn@users.noreply.github.com> Date: Fri, 3 Nov 2023 17:11:13 +0300 Subject: [PATCH 16/17] test: fix unmarshallable params test (#280) --- x/house/client/cli/query_params_test.go | 8 +++++++- x/orderbook/client/cli/query_params_test.go | 16 +++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/x/house/client/cli/query_params_test.go b/x/house/client/cli/query_params_test.go index df3878d7..449ddf9d 100644 --- a/x/house/client/cli/query_params_test.go +++ b/x/house/client/cli/query_params_test.go @@ -40,9 +40,15 @@ func TestQueryParams(t *testing.T) { var params types.QueryParamsResponse err = json.Unmarshal(res.Bytes(), ¶ms) - require.NoError(t, err) + // command-line response, wraps the primitive numbers in double quotes, so it is not unmarshall-able. + require.EqualError( + t, + err, + "json: cannot unmarshal string into Go struct field Params.params.max_withdrawal_count of type uint64", + ) defaultParams := types.DefaultParams() + defaultParams.MaxWithdrawalCount = 0 require.Equal(t, types.QueryParamsResponse{ Params: defaultParams, }, params) diff --git a/x/orderbook/client/cli/query_params_test.go b/x/orderbook/client/cli/query_params_test.go index df3878d7..54679251 100644 --- a/x/orderbook/client/cli/query_params_test.go +++ b/x/orderbook/client/cli/query_params_test.go @@ -6,8 +6,8 @@ import ( clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" "github.com/sge-network/sge/testutil/network" - "github.com/sge-network/sge/x/house/client/cli" - "github.com/sge-network/sge/x/house/types" + "github.com/sge-network/sge/x/orderbook/client/cli" + "github.com/sge-network/sge/x/orderbook/types" "github.com/stretchr/testify/require" ) @@ -40,9 +40,19 @@ func TestQueryParams(t *testing.T) { var params types.QueryParamsResponse err = json.Unmarshal(res.Bytes(), ¶ms) - require.NoError(t, err) + // command-line response, wraps the primitive numbers in double quotes, so it is not unmarshall-able. + require.EqualError( + t, + err, + "json: cannot unmarshal string into Go struct field Params.params.max_order_book_participations of type uint64", + "json: cannot unmarshal string into Go struct field Params.params.batch_settlement_count of type uint64", + "json: cannot unmarshal string into Go struct field Params.params.requeue_threshold of type uint64", + ) defaultParams := types.DefaultParams() + defaultParams.BatchSettlementCount = 0 + defaultParams.MaxOrderBookParticipations = 0 + defaultParams.RequeueThreshold = 0 require.Equal(t, types.QueryParamsResponse{ Params: defaultParams, }, params) From e5246466df9017f16f4f7c222c90665c1c886b70 Mon Sep 17 00:00:00 2001 From: P-U-D-G-E Date: Fri, 3 Nov 2023 19:42:08 +0530 Subject: [PATCH 17/17] removes changes in config.yml --- config.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/config.yml b/config.yml index b1632abb..17ffd503 100644 --- a/config.yml +++ b/config.yml @@ -8,7 +8,6 @@ accounts: - name: admin mnemonic: patch donor arena plug burst silk cram day charge valve prize awake remind wolf resource silk oyster man tray police ritual immune foot beef - name: oracle - coins: ["100000000000000usge"] mnemonic: better ketchup radio relax scheme worth foam utility bamboo moon slab trade tackle hobby once pass daughter isolate nice cost level swim view final validators: - name: cold @@ -34,7 +33,7 @@ genesis: ovm: key_vault: public_keys: [ - "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEAzoP3SVo1tUEhd+cF/zw+8XxtOScdJyD7T3QqKzpC9x0=\n-----END PUBLIC KEY-----", + "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEAdUWfzVUf4BqsHvErsJoXIaIpO60CHXfaaef+xKU3bbY=\n-----END PUBLIC KEY-----", "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEA58w+676YVp61kjXDrteK8hDxulq5zbF6sNHQt3Lt5Ng=\n-----END PUBLIC KEY-----", "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEAw5iPKVbSvyF1A1HDFaWMGlhBp/xTU70i8lMgOml79WM=\n-----END PUBLIC KEY-----", "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEAueEgZMdKn6Bp0mcG04HrNAt1a0o7+0eNliQCNmbxkOQ=\n-----END PUBLIC KEY-----", @@ -65,6 +64,3 @@ genesis: orderbook: params: requeue_threshold: "1000" - house: - params: - max_withdrawal_count: 1