From e5d7e38be04f18ef2dd6feb5de1966fdbcfd96c1 Mon Sep 17 00:00:00 2001 From: Charles Dusek Date: Fri, 19 Apr 2024 03:27:53 -0500 Subject: [PATCH] Added drop proto --- api/onex/market/drop.pulsar.go | 915 ++++++++++++++++++++++ docs/static/openapi.yml | 92 +-- proto/onex/market/drop.proto | 24 + x/market/keeper/drop.go | 25 + x/market/keeper/msg_server_create_drop.go | 3 + x/market/types/drop.pb.go | 546 +++++++++++++ x/market/types/key_drop.go | 57 ++ 7 files changed, 1616 insertions(+), 46 deletions(-) create mode 100644 api/onex/market/drop.pulsar.go create mode 100644 proto/onex/market/drop.proto create mode 100644 x/market/keeper/drop.go create mode 100644 x/market/types/drop.pb.go create mode 100644 x/market/types/key_drop.go diff --git a/api/onex/market/drop.pulsar.go b/api/onex/market/drop.pulsar.go new file mode 100644 index 0000000..5ecd175 --- /dev/null +++ b/api/onex/market/drop.pulsar.go @@ -0,0 +1,915 @@ +// Code generated by protoc-gen-go-pulsar. DO NOT EDIT. +package market + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + runtime "github.com/cosmos/cosmos-proto/runtime" + _ "github.com/cosmos/gogoproto/gogoproto" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoiface "google.golang.org/protobuf/runtime/protoiface" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" + reflect "reflect" + sync "sync" +) + +var ( + md_Drop protoreflect.MessageDescriptor + fd_Drop_uid protoreflect.FieldDescriptor + fd_Drop_owner protoreflect.FieldDescriptor + fd_Drop_pair protoreflect.FieldDescriptor + fd_Drop_drops protoreflect.FieldDescriptor + fd_Drop_product protoreflect.FieldDescriptor + fd_Drop_active protoreflect.FieldDescriptor +) + +func init() { + file_onex_market_drop_proto_init() + md_Drop = File_onex_market_drop_proto.Messages().ByName("Drop") + fd_Drop_uid = md_Drop.Fields().ByName("uid") + fd_Drop_owner = md_Drop.Fields().ByName("owner") + fd_Drop_pair = md_Drop.Fields().ByName("pair") + fd_Drop_drops = md_Drop.Fields().ByName("drops") + fd_Drop_product = md_Drop.Fields().ByName("product") + fd_Drop_active = md_Drop.Fields().ByName("active") +} + +var _ protoreflect.Message = (*fastReflection_Drop)(nil) + +type fastReflection_Drop Drop + +func (x *Drop) ProtoReflect() protoreflect.Message { + return (*fastReflection_Drop)(x) +} + +func (x *Drop) slowProtoReflect() protoreflect.Message { + mi := &file_onex_market_drop_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_Drop_messageType fastReflection_Drop_messageType +var _ protoreflect.MessageType = fastReflection_Drop_messageType{} + +type fastReflection_Drop_messageType struct{} + +func (x fastReflection_Drop_messageType) Zero() protoreflect.Message { + return (*fastReflection_Drop)(nil) +} +func (x fastReflection_Drop_messageType) New() protoreflect.Message { + return new(fastReflection_Drop) +} +func (x fastReflection_Drop_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_Drop +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_Drop) Descriptor() protoreflect.MessageDescriptor { + return md_Drop +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_Drop) Type() protoreflect.MessageType { + return _fastReflection_Drop_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_Drop) New() protoreflect.Message { + return new(fastReflection_Drop) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_Drop) Interface() protoreflect.ProtoMessage { + return (*Drop)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_Drop) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Uid != uint64(0) { + value := protoreflect.ValueOfUint64(x.Uid) + if !f(fd_Drop_uid, value) { + return + } + } + if x.Owner != "" { + value := protoreflect.ValueOfString(x.Owner) + if !f(fd_Drop_owner, value) { + return + } + } + if x.Pair != "" { + value := protoreflect.ValueOfString(x.Pair) + if !f(fd_Drop_pair, value) { + return + } + } + if x.Drops != "" { + value := protoreflect.ValueOfString(x.Drops) + if !f(fd_Drop_drops, value) { + return + } + } + if x.Product != "" { + value := protoreflect.ValueOfString(x.Product) + if !f(fd_Drop_product, value) { + return + } + } + if x.Active != false { + value := protoreflect.ValueOfBool(x.Active) + if !f(fd_Drop_active, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_Drop) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "onex.market.Drop.uid": + return x.Uid != uint64(0) + case "onex.market.Drop.owner": + return x.Owner != "" + case "onex.market.Drop.pair": + return x.Pair != "" + case "onex.market.Drop.drops": + return x.Drops != "" + case "onex.market.Drop.product": + return x.Product != "" + case "onex.market.Drop.active": + return x.Active != false + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: onex.market.Drop")) + } + panic(fmt.Errorf("message onex.market.Drop does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_Drop) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "onex.market.Drop.uid": + x.Uid = uint64(0) + case "onex.market.Drop.owner": + x.Owner = "" + case "onex.market.Drop.pair": + x.Pair = "" + case "onex.market.Drop.drops": + x.Drops = "" + case "onex.market.Drop.product": + x.Product = "" + case "onex.market.Drop.active": + x.Active = false + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: onex.market.Drop")) + } + panic(fmt.Errorf("message onex.market.Drop does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_Drop) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "onex.market.Drop.uid": + value := x.Uid + return protoreflect.ValueOfUint64(value) + case "onex.market.Drop.owner": + value := x.Owner + return protoreflect.ValueOfString(value) + case "onex.market.Drop.pair": + value := x.Pair + return protoreflect.ValueOfString(value) + case "onex.market.Drop.drops": + value := x.Drops + return protoreflect.ValueOfString(value) + case "onex.market.Drop.product": + value := x.Product + return protoreflect.ValueOfString(value) + case "onex.market.Drop.active": + value := x.Active + return protoreflect.ValueOfBool(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: onex.market.Drop")) + } + panic(fmt.Errorf("message onex.market.Drop does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_Drop) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "onex.market.Drop.uid": + x.Uid = value.Uint() + case "onex.market.Drop.owner": + x.Owner = value.Interface().(string) + case "onex.market.Drop.pair": + x.Pair = value.Interface().(string) + case "onex.market.Drop.drops": + x.Drops = value.Interface().(string) + case "onex.market.Drop.product": + x.Product = value.Interface().(string) + case "onex.market.Drop.active": + x.Active = value.Bool() + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: onex.market.Drop")) + } + panic(fmt.Errorf("message onex.market.Drop does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_Drop) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "onex.market.Drop.uid": + panic(fmt.Errorf("field uid of message onex.market.Drop is not mutable")) + case "onex.market.Drop.owner": + panic(fmt.Errorf("field owner of message onex.market.Drop is not mutable")) + case "onex.market.Drop.pair": + panic(fmt.Errorf("field pair of message onex.market.Drop is not mutable")) + case "onex.market.Drop.drops": + panic(fmt.Errorf("field drops of message onex.market.Drop is not mutable")) + case "onex.market.Drop.product": + panic(fmt.Errorf("field product of message onex.market.Drop is not mutable")) + case "onex.market.Drop.active": + panic(fmt.Errorf("field active of message onex.market.Drop is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: onex.market.Drop")) + } + panic(fmt.Errorf("message onex.market.Drop does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_Drop) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "onex.market.Drop.uid": + return protoreflect.ValueOfUint64(uint64(0)) + case "onex.market.Drop.owner": + return protoreflect.ValueOfString("") + case "onex.market.Drop.pair": + return protoreflect.ValueOfString("") + case "onex.market.Drop.drops": + return protoreflect.ValueOfString("") + case "onex.market.Drop.product": + return protoreflect.ValueOfString("") + case "onex.market.Drop.active": + return protoreflect.ValueOfBool(false) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: onex.market.Drop")) + } + panic(fmt.Errorf("message onex.market.Drop does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_Drop) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in onex.market.Drop", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_Drop) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_Drop) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_Drop) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_Drop) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*Drop) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + if x.Uid != 0 { + n += 1 + runtime.Sov(uint64(x.Uid)) + } + l = len(x.Owner) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.Pair) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.Drops) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.Product) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.Active { + n += 2 + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*Drop) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if x.Active { + i-- + if x.Active { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x30 + } + if len(x.Product) > 0 { + i -= len(x.Product) + copy(dAtA[i:], x.Product) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Product))) + i-- + dAtA[i] = 0x2a + } + if len(x.Drops) > 0 { + i -= len(x.Drops) + copy(dAtA[i:], x.Drops) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Drops))) + i-- + dAtA[i] = 0x22 + } + if len(x.Pair) > 0 { + i -= len(x.Pair) + copy(dAtA[i:], x.Pair) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Pair))) + i-- + dAtA[i] = 0x1a + } + if len(x.Owner) > 0 { + i -= len(x.Owner) + copy(dAtA[i:], x.Owner) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Owner))) + i-- + dAtA[i] = 0x12 + } + if x.Uid != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.Uid)) + i-- + dAtA[i] = 0x8 + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*Drop) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, 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 protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: Drop: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: Drop: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Uid", wireType) + } + x.Uid = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.Uid |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Pair", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Pair = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Drops", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Drops = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Product", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Product = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Active", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + x.Active = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.27.0 +// protoc (unknown) +// source: onex/market/drop.proto + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// Drop is the data structure for pool drops +type Drop struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Uid uint64 `protobuf:"varint,1,opt,name=uid,proto3" json:"uid,omitempty"` + Owner string `protobuf:"bytes,2,opt,name=owner,proto3" json:"owner,omitempty"` + Pair string `protobuf:"bytes,3,opt,name=pair,proto3" json:"pair,omitempty"` + Drops string `protobuf:"bytes,4,opt,name=drops,proto3" json:"drops,omitempty"` + Product string `protobuf:"bytes,5,opt,name=product,proto3" json:"product,omitempty"` + Active bool `protobuf:"varint,6,opt,name=active,proto3" json:"active,omitempty"` +} + +func (x *Drop) Reset() { + *x = Drop{} + if protoimpl.UnsafeEnabled { + mi := &file_onex_market_drop_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Drop) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Drop) ProtoMessage() {} + +// Deprecated: Use Drop.ProtoReflect.Descriptor instead. +func (*Drop) Descriptor() ([]byte, []int) { + return file_onex_market_drop_proto_rawDescGZIP(), []int{0} +} + +func (x *Drop) GetUid() uint64 { + if x != nil { + return x.Uid + } + return 0 +} + +func (x *Drop) GetOwner() string { + if x != nil { + return x.Owner + } + return "" +} + +func (x *Drop) GetPair() string { + if x != nil { + return x.Pair + } + return "" +} + +func (x *Drop) GetDrops() string { + if x != nil { + return x.Drops + } + return "" +} + +func (x *Drop) GetProduct() string { + if x != nil { + return x.Product + } + return "" +} + +func (x *Drop) GetActive() bool { + if x != nil { + return x.Active + } + return false +} + +var File_onex_market_drop_proto protoreflect.FileDescriptor + +var file_onex_market_drop_proto_rawDesc = []byte{ + 0x0a, 0x16, 0x6f, 0x6e, 0x65, 0x78, 0x2f, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x2f, 0x64, 0x72, + 0x6f, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0b, 0x6f, 0x6e, 0x65, 0x78, 0x2e, 0x6d, + 0x61, 0x72, 0x6b, 0x65, 0x74, 0x1a, 0x14, 0x67, 0x6f, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x2f, 0x67, 0x6f, 0x67, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xe4, 0x01, 0x0a, 0x04, 0x44, 0x72, 0x6f, 0x70, 0x12, + 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x03, 0x75, 0x69, + 0x64, 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x69, 0x72, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x69, 0x72, 0x12, 0x41, 0x0a, 0x05, 0x64, + 0x72, 0x6f, 0x70, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x42, 0x2b, 0xc8, 0xde, 0x1f, 0x00, + 0xda, 0xde, 0x1f, 0x15, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, + 0x2f, 0x6d, 0x61, 0x74, 0x68, 0x2e, 0x49, 0x6e, 0x74, 0xd2, 0xb4, 0x2d, 0x0a, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x2e, 0x49, 0x6e, 0x74, 0x52, 0x05, 0x64, 0x72, 0x6f, 0x70, 0x73, 0x12, 0x45, + 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x42, + 0x2b, 0xc8, 0xde, 0x1f, 0x00, 0xda, 0xde, 0x1f, 0x15, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, + 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x6d, 0x61, 0x74, 0x68, 0x2e, 0x49, 0x6e, 0x74, 0xd2, 0xb4, + 0x2d, 0x0a, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x49, 0x6e, 0x74, 0x52, 0x07, 0x70, 0x72, + 0x6f, 0x64, 0x75, 0x63, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x18, + 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x42, 0x87, 0x01, + 0x0a, 0x0f, 0x63, 0x6f, 0x6d, 0x2e, 0x6f, 0x6e, 0x65, 0x78, 0x2e, 0x6d, 0x61, 0x72, 0x6b, 0x65, + 0x74, 0x42, 0x09, 0x44, 0x72, 0x6f, 0x70, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x1c, + 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, + 0x2f, 0x6f, 0x6e, 0x65, 0x78, 0x2f, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0xa2, 0x02, 0x03, 0x4f, + 0x4d, 0x58, 0xaa, 0x02, 0x0b, 0x4f, 0x6e, 0x65, 0x78, 0x2e, 0x4d, 0x61, 0x72, 0x6b, 0x65, 0x74, + 0xca, 0x02, 0x0b, 0x4f, 0x6e, 0x65, 0x78, 0x5c, 0x4d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0xe2, 0x02, + 0x17, 0x4f, 0x6e, 0x65, 0x78, 0x5c, 0x4d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x5c, 0x47, 0x50, 0x42, + 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0c, 0x4f, 0x6e, 0x65, 0x78, 0x3a, + 0x3a, 0x4d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_onex_market_drop_proto_rawDescOnce sync.Once + file_onex_market_drop_proto_rawDescData = file_onex_market_drop_proto_rawDesc +) + +func file_onex_market_drop_proto_rawDescGZIP() []byte { + file_onex_market_drop_proto_rawDescOnce.Do(func() { + file_onex_market_drop_proto_rawDescData = protoimpl.X.CompressGZIP(file_onex_market_drop_proto_rawDescData) + }) + return file_onex_market_drop_proto_rawDescData +} + +var file_onex_market_drop_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_onex_market_drop_proto_goTypes = []interface{}{ + (*Drop)(nil), // 0: onex.market.Drop +} +var file_onex_market_drop_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_onex_market_drop_proto_init() } +func file_onex_market_drop_proto_init() { + if File_onex_market_drop_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_onex_market_drop_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Drop); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_onex_market_drop_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_onex_market_drop_proto_goTypes, + DependencyIndexes: file_onex_market_drop_proto_depIdxs, + MessageInfos: file_onex_market_drop_proto_msgTypes, + }.Build() + File_onex_market_drop_proto = out.File + file_onex_market_drop_proto_rawDesc = nil + file_onex_market_drop_proto_goTypes = nil + file_onex_market_drop_proto_depIdxs = nil +} diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index e5a4b1a..61c4447 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -13156,6 +13156,42 @@ paths: description: MsgUpdateParams is the Msg/UpdateParams request type. tags: - Msg + /onex/market/params: + get: + summary: Parameters queries the parameters of the module. + operationId: OnexMarketQuery_Params + responses: + '200': + description: A successful response. + schema: + type: object + properties: + params: + description: params holds all the parameters of this module. + type: object + description: >- + QueryParamsResponse is response type for the Query/Params RPC + method. + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + tags: + - Query /onex.market.Msg/CreateDrop: post: summary: CreateDrop defines an operation for creating a drop @@ -13301,42 +13337,6 @@ paths: description: MsgUpdateParams is the Msg/UpdateParams request type. tags: - Msg - /onex/market/params: - get: - summary: Parameters queries the parameters of the module. - operationId: OnexMarketQuery_Params - responses: - '200': - description: A successful response. - schema: - type: object - properties: - params: - description: params holds all the parameters of this module. - type: object - description: >- - QueryParamsResponse is response type for the Query/Params RPC - method. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - additionalProperties: {} - tags: - - Query definitions: cosmos.auth.v1beta1.MsgUpdateParams: type: object @@ -20472,6 +20472,16 @@ definitions: onex.denom.Params: type: object description: Params defines the parameters for the module. + onex.market.Params: + type: object + description: Params defines the parameters for the module. + onex.market.QueryParamsResponse: + type: object + properties: + params: + description: params holds all the parameters of this module. + type: object + description: QueryParamsResponse is response type for the Query/Params RPC method. onex.market.MsgCreateDrop: type: object properties: @@ -20515,13 +20525,3 @@ definitions: description: |- MsgUpdateParamsResponse defines the response structure for executing a MsgUpdateParams message. - onex.market.Params: - type: object - description: Params defines the parameters for the module. - onex.market.QueryParamsResponse: - type: object - properties: - params: - description: params holds all the parameters of this module. - type: object - description: QueryParamsResponse is response type for the Query/Params RPC method. diff --git a/proto/onex/market/drop.proto b/proto/onex/market/drop.proto new file mode 100644 index 0000000..50997c1 --- /dev/null +++ b/proto/onex/market/drop.proto @@ -0,0 +1,24 @@ +syntax = "proto3"; +package onex.market; +import "gogoproto/gogo.proto"; +import "cosmos_proto/cosmos.proto"; + +option go_package = "onex/x/market/types"; + +// Drop is the data structure for pool drops +message Drop { + uint64 uid = 1; + string owner = 2; + string pair = 3; + string drops = 4 [ + (cosmos_proto.scalar) = "cosmos.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", + (gogoproto.nullable) = false + ]; + string product = 5 [ + (cosmos_proto.scalar) = "cosmos.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", + (gogoproto.nullable) = false + ]; + bool active = 6; +} \ No newline at end of file diff --git a/x/market/keeper/drop.go b/x/market/keeper/drop.go new file mode 100644 index 0000000..ac1fb66 --- /dev/null +++ b/x/market/keeper/drop.go @@ -0,0 +1,25 @@ +package keeper + +import ( + "github.com/cosmos/cosmos-sdk/runtime" + + "context" + "onex/x/market/types" +) + +// GetParams get all parameters as types.Params +func (k Keeper) GetDrop( + ctx context.Context, + uid uint64, +) (drop types.Drop, found bool) { + store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + bz := store.Get(types.DropKey( + uid, + )) + if bz == nil { + return drop, false + } + + k.cdc.MustUnmarshal(bz, &drop) + return drop, true +} diff --git a/x/market/keeper/msg_server_create_drop.go b/x/market/keeper/msg_server_create_drop.go index 7e05605..bcae86f 100644 --- a/x/market/keeper/msg_server_create_drop.go +++ b/x/market/keeper/msg_server_create_drop.go @@ -49,6 +49,9 @@ func (k msgServer) CreateDrop(goCtx context.Context, msg *types.MsgCreateDrop) ( // Create the uid uid := k.GetUidCount(ctx) + drops, _ := math.NewIntFromString(msg.Drops) + + _ = drops _ = memberA _ = memberB _ = uid.Count diff --git a/x/market/types/drop.pb.go b/x/market/types/drop.pb.go new file mode 100644 index 0000000..a2e9c28 --- /dev/null +++ b/x/market/types/drop.pb.go @@ -0,0 +1,546 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: onex/market/drop.proto + +package types + +import ( + cosmossdk_io_math "cosmossdk.io/math" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Drop is the data structure for pool drops +type Drop struct { + Uid uint64 `protobuf:"varint,1,opt,name=uid,proto3" json:"uid,omitempty"` + Owner string `protobuf:"bytes,2,opt,name=owner,proto3" json:"owner,omitempty"` + Pair string `protobuf:"bytes,3,opt,name=pair,proto3" json:"pair,omitempty"` + Drops cosmossdk_io_math.Int `protobuf:"bytes,4,opt,name=drops,proto3,customtype=cosmossdk.io/math.Int" json:"drops"` + Product cosmossdk_io_math.Int `protobuf:"bytes,5,opt,name=product,proto3,customtype=cosmossdk.io/math.Int" json:"product"` + Active bool `protobuf:"varint,6,opt,name=active,proto3" json:"active,omitempty"` +} + +func (m *Drop) Reset() { *m = Drop{} } +func (m *Drop) String() string { return proto.CompactTextString(m) } +func (*Drop) ProtoMessage() {} +func (*Drop) Descriptor() ([]byte, []int) { + return fileDescriptor_809262ccab935bb7, []int{0} +} +func (m *Drop) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Drop) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Drop.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 *Drop) XXX_Merge(src proto.Message) { + xxx_messageInfo_Drop.Merge(m, src) +} +func (m *Drop) XXX_Size() int { + return m.Size() +} +func (m *Drop) XXX_DiscardUnknown() { + xxx_messageInfo_Drop.DiscardUnknown(m) +} + +var xxx_messageInfo_Drop proto.InternalMessageInfo + +func (m *Drop) GetUid() uint64 { + if m != nil { + return m.Uid + } + return 0 +} + +func (m *Drop) GetOwner() string { + if m != nil { + return m.Owner + } + return "" +} + +func (m *Drop) GetPair() string { + if m != nil { + return m.Pair + } + return "" +} + +func (m *Drop) GetActive() bool { + if m != nil { + return m.Active + } + return false +} + +func init() { + proto.RegisterType((*Drop)(nil), "onex.market.Drop") +} + +func init() { proto.RegisterFile("onex/market/drop.proto", fileDescriptor_809262ccab935bb7) } + +var fileDescriptor_809262ccab935bb7 = []byte{ + // 270 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xcb, 0xcf, 0x4b, 0xad, + 0xd0, 0xcf, 0x4d, 0x2c, 0xca, 0x4e, 0x2d, 0xd1, 0x4f, 0x29, 0xca, 0x2f, 0xd0, 0x2b, 0x28, 0xca, + 0x2f, 0xc9, 0x17, 0xe2, 0x06, 0x89, 0xeb, 0x41, 0xc4, 0xa5, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, + 0xe2, 0xfa, 0x20, 0x16, 0x44, 0x89, 0x94, 0x64, 0x72, 0x7e, 0x71, 0x6e, 0x7e, 0x71, 0x3c, 0x44, + 0x02, 0xc2, 0x81, 0x48, 0x29, 0x3d, 0x61, 0xe4, 0x62, 0x71, 0x29, 0xca, 0x2f, 0x10, 0x12, 0xe0, + 0x62, 0x2e, 0xcd, 0x4c, 0x91, 0x60, 0x54, 0x60, 0xd4, 0x60, 0x09, 0x02, 0x31, 0x85, 0x44, 0xb8, + 0x58, 0xf3, 0xcb, 0xf3, 0x52, 0x8b, 0x24, 0x98, 0x14, 0x18, 0x35, 0x38, 0x83, 0x20, 0x1c, 0x21, + 0x21, 0x2e, 0x96, 0x82, 0xc4, 0xcc, 0x22, 0x09, 0x66, 0xb0, 0x20, 0x98, 0x2d, 0xe4, 0xc8, 0xc5, + 0x0a, 0x72, 0x50, 0xb1, 0x04, 0x0b, 0x48, 0xd0, 0x49, 0xfb, 0xc4, 0x3d, 0x79, 0x86, 0x5b, 0xf7, + 0xe4, 0x45, 0x21, 0x36, 0x15, 0xa7, 0x64, 0xeb, 0x65, 0xe6, 0xeb, 0xe7, 0x26, 0x96, 0x64, 0xe8, + 0x79, 0xe6, 0x95, 0x5c, 0xda, 0xa2, 0xcb, 0x05, 0x75, 0x82, 0x67, 0x5e, 0x49, 0x10, 0x44, 0xa7, + 0x90, 0x2b, 0x17, 0x7b, 0x41, 0x51, 0x7e, 0x4a, 0x69, 0x72, 0x89, 0x04, 0x2b, 0xe9, 0x86, 0xc0, + 0xf4, 0x0a, 0x89, 0x71, 0xb1, 0x25, 0x26, 0x97, 0x64, 0x96, 0xa5, 0x4a, 0xb0, 0x29, 0x30, 0x6a, + 0x70, 0x04, 0x41, 0x79, 0x4e, 0xba, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, + 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, + 0x25, 0x0c, 0x0e, 0x56, 0x78, 0xc0, 0x96, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0x03, 0xc7, + 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x20, 0xc0, 0x4b, 0x56, 0x74, 0x01, 0x00, 0x00, +} + +func (m *Drop) 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 *Drop) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Drop) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Active { + i-- + if m.Active { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x30 + } + { + size := m.Product.Size() + i -= size + if _, err := m.Product.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintDrop(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + { + size := m.Drops.Size() + i -= size + if _, err := m.Drops.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintDrop(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + if len(m.Pair) > 0 { + i -= len(m.Pair) + copy(dAtA[i:], m.Pair) + i = encodeVarintDrop(dAtA, i, uint64(len(m.Pair))) + i-- + dAtA[i] = 0x1a + } + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintDrop(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0x12 + } + if m.Uid != 0 { + i = encodeVarintDrop(dAtA, i, uint64(m.Uid)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintDrop(dAtA []byte, offset int, v uint64) int { + offset -= sovDrop(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Drop) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Uid != 0 { + n += 1 + sovDrop(uint64(m.Uid)) + } + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovDrop(uint64(l)) + } + l = len(m.Pair) + if l > 0 { + n += 1 + l + sovDrop(uint64(l)) + } + l = m.Drops.Size() + n += 1 + l + sovDrop(uint64(l)) + l = m.Product.Size() + n += 1 + l + sovDrop(uint64(l)) + if m.Active { + n += 2 + } + return n +} + +func sovDrop(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozDrop(x uint64) (n int) { + return sovDrop(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Drop) 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 ErrIntOverflowDrop + } + 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: Drop: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Drop: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Uid", wireType) + } + m.Uid = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDrop + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Uid |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDrop + } + 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 ErrInvalidLengthDrop + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDrop + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pair", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDrop + } + 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 ErrInvalidLengthDrop + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDrop + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Pair = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Drops", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDrop + } + 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 ErrInvalidLengthDrop + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDrop + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Drops.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Product", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDrop + } + 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 ErrInvalidLengthDrop + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDrop + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Product.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Active", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDrop + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Active = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipDrop(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthDrop + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipDrop(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowDrop + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowDrop + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowDrop + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthDrop + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupDrop + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthDrop + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthDrop = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowDrop = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupDrop = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/market/types/key_drop.go b/x/market/types/key_drop.go new file mode 100644 index 0000000..9e50873 --- /dev/null +++ b/x/market/types/key_drop.go @@ -0,0 +1,57 @@ +package types + +import "encoding/binary" + +var _ binary.ByteOrder + +const ( + // DropKeyPrefix is the prefix to retrieve all Drop + DropKeyPrefix = "Drop/value/" + // DropsKeyPrefix is the prefix to retrieve all Owner of Drops + DropsKeyPrefix = "Drop/Owner/Pair/" + // DropPairsKeyPrefix is the prefix to retrieve all Pairs an Owner owns Drops + DropPairsKeyPrefix = "Drop/Owner/" +) + +// DropKey returns the store key to retrieve a Drop from the index fields +func DropKey( + uid uint64, +) []byte { + var key []byte + + uidBytes := make([]byte, 8) + binary.BigEndian.PutUint64(uidBytes, uid) + key = append(key, uidBytes...) + key = append(key, []byte("/")...) + + return key +} + +// DropKey returns the store key to retrieve a Drop from the index fields +func DropsKey( + owner string, + pair string, +) []byte { + var key []byte + + ownerBytes := []byte(owner) + pairBytes := []byte(pair) + key = append(key, ownerBytes...) + key = append(key, pairBytes...) + key = append(key, []byte("/")...) + + return key +} + +// DropKey returns the store key to retrieve all Pairs and Owner has Drops +func DropPairsKey( + owner string, +) []byte { + var key []byte + + ownerBytes := []byte(owner) + key = append(key, ownerBytes...) + key = append(key, []byte("/")...) + + return key +}