diff --git a/api/elys/commitment/commitments.pulsar.go b/api/elys/commitment/commitments.pulsar.go index e60aa3103..9b0a9eba1 100644 --- a/api/elys/commitment/commitments.pulsar.go +++ b/api/elys/commitment/commitments.pulsar.go @@ -2634,6 +2634,490 @@ func (x *fastReflection_VestingTokens) ProtoMethods() *protoiface.Methods { } } +var ( + md_TotalSupply protoreflect.MessageDescriptor + fd_TotalSupply_total_eden_supply protoreflect.FieldDescriptor + fd_TotalSupply_total_edenb_supply protoreflect.FieldDescriptor +) + +func init() { + file_elys_commitment_commitments_proto_init() + md_TotalSupply = File_elys_commitment_commitments_proto.Messages().ByName("TotalSupply") + fd_TotalSupply_total_eden_supply = md_TotalSupply.Fields().ByName("total_eden_supply") + fd_TotalSupply_total_edenb_supply = md_TotalSupply.Fields().ByName("total_edenb_supply") +} + +var _ protoreflect.Message = (*fastReflection_TotalSupply)(nil) + +type fastReflection_TotalSupply TotalSupply + +func (x *TotalSupply) ProtoReflect() protoreflect.Message { + return (*fastReflection_TotalSupply)(x) +} + +func (x *TotalSupply) slowProtoReflect() protoreflect.Message { + mi := &file_elys_commitment_commitments_proto_msgTypes[4] + 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_TotalSupply_messageType fastReflection_TotalSupply_messageType +var _ protoreflect.MessageType = fastReflection_TotalSupply_messageType{} + +type fastReflection_TotalSupply_messageType struct{} + +func (x fastReflection_TotalSupply_messageType) Zero() protoreflect.Message { + return (*fastReflection_TotalSupply)(nil) +} +func (x fastReflection_TotalSupply_messageType) New() protoreflect.Message { + return new(fastReflection_TotalSupply) +} +func (x fastReflection_TotalSupply_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_TotalSupply +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_TotalSupply) Descriptor() protoreflect.MessageDescriptor { + return md_TotalSupply +} + +// 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_TotalSupply) Type() protoreflect.MessageType { + return _fastReflection_TotalSupply_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_TotalSupply) New() protoreflect.Message { + return new(fastReflection_TotalSupply) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_TotalSupply) Interface() protoreflect.ProtoMessage { + return (*TotalSupply)(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_TotalSupply) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.TotalEdenSupply != "" { + value := protoreflect.ValueOfString(x.TotalEdenSupply) + if !f(fd_TotalSupply_total_eden_supply, value) { + return + } + } + if x.TotalEdenbSupply != "" { + value := protoreflect.ValueOfString(x.TotalEdenbSupply) + if !f(fd_TotalSupply_total_edenb_supply, 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_TotalSupply) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "elys.commitment.TotalSupply.total_eden_supply": + return x.TotalEdenSupply != "" + case "elys.commitment.TotalSupply.total_edenb_supply": + return x.TotalEdenbSupply != "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: elys.commitment.TotalSupply")) + } + panic(fmt.Errorf("message elys.commitment.TotalSupply 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_TotalSupply) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "elys.commitment.TotalSupply.total_eden_supply": + x.TotalEdenSupply = "" + case "elys.commitment.TotalSupply.total_edenb_supply": + x.TotalEdenbSupply = "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: elys.commitment.TotalSupply")) + } + panic(fmt.Errorf("message elys.commitment.TotalSupply 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_TotalSupply) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "elys.commitment.TotalSupply.total_eden_supply": + value := x.TotalEdenSupply + return protoreflect.ValueOfString(value) + case "elys.commitment.TotalSupply.total_edenb_supply": + value := x.TotalEdenbSupply + return protoreflect.ValueOfString(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: elys.commitment.TotalSupply")) + } + panic(fmt.Errorf("message elys.commitment.TotalSupply 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_TotalSupply) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "elys.commitment.TotalSupply.total_eden_supply": + x.TotalEdenSupply = value.Interface().(string) + case "elys.commitment.TotalSupply.total_edenb_supply": + x.TotalEdenbSupply = value.Interface().(string) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: elys.commitment.TotalSupply")) + } + panic(fmt.Errorf("message elys.commitment.TotalSupply 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_TotalSupply) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "elys.commitment.TotalSupply.total_eden_supply": + panic(fmt.Errorf("field total_eden_supply of message elys.commitment.TotalSupply is not mutable")) + case "elys.commitment.TotalSupply.total_edenb_supply": + panic(fmt.Errorf("field total_edenb_supply of message elys.commitment.TotalSupply is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: elys.commitment.TotalSupply")) + } + panic(fmt.Errorf("message elys.commitment.TotalSupply 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_TotalSupply) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "elys.commitment.TotalSupply.total_eden_supply": + return protoreflect.ValueOfString("") + case "elys.commitment.TotalSupply.total_edenb_supply": + return protoreflect.ValueOfString("") + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: elys.commitment.TotalSupply")) + } + panic(fmt.Errorf("message elys.commitment.TotalSupply 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_TotalSupply) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in elys.commitment.TotalSupply", 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_TotalSupply) 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_TotalSupply) 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_TotalSupply) 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_TotalSupply) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*TotalSupply) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + l = len(x.TotalEdenSupply) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.TotalEdenbSupply) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + 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().(*TotalSupply) + 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 len(x.TotalEdenbSupply) > 0 { + i -= len(x.TotalEdenbSupply) + copy(dAtA[i:], x.TotalEdenbSupply) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.TotalEdenbSupply))) + i-- + dAtA[i] = 0x12 + } + if len(x.TotalEdenSupply) > 0 { + i -= len(x.TotalEdenSupply) + copy(dAtA[i:], x.TotalEdenSupply) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.TotalEdenSupply))) + i-- + dAtA[i] = 0xa + } + 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().(*TotalSupply) + 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: TotalSupply: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: TotalSupply: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field TotalEdenSupply", 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.TotalEdenSupply = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field TotalEdenbSupply", 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.TotalEdenbSupply = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + 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 @@ -2876,6 +3360,49 @@ func (x *VestingTokens) GetVestStartedTimestamp() int64 { return 0 } +type TotalSupply struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + TotalEdenSupply string `protobuf:"bytes,1,opt,name=total_eden_supply,json=totalEdenSupply,proto3" json:"total_eden_supply,omitempty"` + TotalEdenbSupply string `protobuf:"bytes,2,opt,name=total_edenb_supply,json=totalEdenbSupply,proto3" json:"total_edenb_supply,omitempty"` +} + +func (x *TotalSupply) Reset() { + *x = TotalSupply{} + if protoimpl.UnsafeEnabled { + mi := &file_elys_commitment_commitments_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TotalSupply) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TotalSupply) ProtoMessage() {} + +// Deprecated: Use TotalSupply.ProtoReflect.Descriptor instead. +func (*TotalSupply) Descriptor() ([]byte, []int) { + return file_elys_commitment_commitments_proto_rawDescGZIP(), []int{4} +} + +func (x *TotalSupply) GetTotalEdenSupply() string { + if x != nil { + return x.TotalEdenSupply + } + return "" +} + +func (x *TotalSupply) GetTotalEdenbSupply() string { + if x != nil { + return x.TotalEdenbSupply + } + return "" +} + var File_elys_commitment_commitments_proto protoreflect.FileDescriptor var file_elys_commitment_commitments_proto_rawDesc = []byte{ @@ -2952,19 +3479,31 @@ var file_elys_commitment_commitments_proto_rawDesc = []byte{ 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x34, 0x0a, 0x16, 0x76, 0x65, 0x73, 0x74, 0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x65, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x07, 0x20, 0x01, 0x28, 0x03, 0x52, 0x14, 0x76, 0x65, 0x73, 0x74, 0x53, 0x74, 0x61, 0x72, 0x74, 0x65, - 0x64, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x42, 0xb6, 0x01, 0x0a, 0x13, 0x63, - 0x6f, 0x6d, 0x2e, 0x65, 0x6c, 0x79, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x6d, 0x65, - 0x6e, 0x74, 0x42, 0x10, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x50, - 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x30, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x65, 0x6c, 0x79, 0x73, 0x2d, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2f, - 0x65, 0x6c, 0x79, 0x73, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x65, 0x6c, 0x79, 0x73, 0x2f, 0x63, 0x6f, - 0x6d, 0x6d, 0x69, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0xa2, 0x02, 0x03, 0x45, 0x43, 0x58, 0xaa, 0x02, - 0x0f, 0x45, 0x6c, 0x79, 0x73, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x6d, 0x65, 0x6e, 0x74, - 0xca, 0x02, 0x0f, 0x45, 0x6c, 0x79, 0x73, 0x5c, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x6d, 0x65, - 0x6e, 0x74, 0xe2, 0x02, 0x1b, 0x45, 0x6c, 0x79, 0x73, 0x5c, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, - 0x6d, 0x65, 0x6e, 0x74, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, - 0xea, 0x02, 0x10, 0x45, 0x6c, 0x79, 0x73, 0x3a, 0x3a, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x6d, - 0x65, 0x6e, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x64, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x22, 0xc1, 0x01, 0x0a, 0x0b, 0x54, + 0x6f, 0x74, 0x61, 0x6c, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x79, 0x12, 0x57, 0x0a, 0x11, 0x74, 0x6f, + 0x74, 0x61, 0x6c, 0x5f, 0x65, 0x64, 0x65, 0x6e, 0x5f, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x79, 0x18, + 0x01, 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, 0x0f, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x45, 0x64, 0x65, 0x6e, 0x53, 0x75, 0x70, + 0x70, 0x6c, 0x79, 0x12, 0x59, 0x0a, 0x12, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x65, 0x64, 0x65, + 0x6e, 0x62, 0x5f, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x79, 0x18, 0x02, 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, 0x10, 0x74, 0x6f, + 0x74, 0x61, 0x6c, 0x45, 0x64, 0x65, 0x6e, 0x62, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x79, 0x42, 0xb6, + 0x01, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x65, 0x6c, 0x79, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, + 0x69, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x42, 0x10, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x6d, 0x65, + 0x6e, 0x74, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x30, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x65, 0x6c, 0x79, 0x73, 0x2d, 0x6e, 0x65, 0x74, 0x77, + 0x6f, 0x72, 0x6b, 0x2f, 0x65, 0x6c, 0x79, 0x73, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x65, 0x6c, 0x79, + 0x73, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0xa2, 0x02, 0x03, 0x45, + 0x43, 0x58, 0xaa, 0x02, 0x0f, 0x45, 0x6c, 0x79, 0x73, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, + 0x6d, 0x65, 0x6e, 0x74, 0xca, 0x02, 0x0f, 0x45, 0x6c, 0x79, 0x73, 0x5c, 0x43, 0x6f, 0x6d, 0x6d, + 0x69, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0xe2, 0x02, 0x1b, 0x45, 0x6c, 0x79, 0x73, 0x5c, 0x43, 0x6f, + 0x6d, 0x6d, 0x69, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, + 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x10, 0x45, 0x6c, 0x79, 0x73, 0x3a, 0x3a, 0x43, 0x6f, 0x6d, + 0x6d, 0x69, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -2979,17 +3518,18 @@ func file_elys_commitment_commitments_proto_rawDescGZIP() []byte { return file_elys_commitment_commitments_proto_rawDescData } -var file_elys_commitment_commitments_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_elys_commitment_commitments_proto_msgTypes = make([]protoimpl.MessageInfo, 5) var file_elys_commitment_commitments_proto_goTypes = []interface{}{ (*Commitments)(nil), // 0: elys.commitment.Commitments (*Lockup)(nil), // 1: elys.commitment.Lockup (*CommittedTokens)(nil), // 2: elys.commitment.CommittedTokens (*VestingTokens)(nil), // 3: elys.commitment.VestingTokens - (*v1beta1.Coin)(nil), // 4: cosmos.base.v1beta1.Coin + (*TotalSupply)(nil), // 4: elys.commitment.TotalSupply + (*v1beta1.Coin)(nil), // 5: cosmos.base.v1beta1.Coin } var file_elys_commitment_commitments_proto_depIdxs = []int32{ 2, // 0: elys.commitment.Commitments.committed_tokens:type_name -> elys.commitment.CommittedTokens - 4, // 1: elys.commitment.Commitments.claimed:type_name -> cosmos.base.v1beta1.Coin + 5, // 1: elys.commitment.Commitments.claimed:type_name -> cosmos.base.v1beta1.Coin 3, // 2: elys.commitment.Commitments.vesting_tokens:type_name -> elys.commitment.VestingTokens 1, // 3: elys.commitment.CommittedTokens.lockups:type_name -> elys.commitment.Lockup 4, // [4:4] is the sub-list for method output_type @@ -3054,6 +3594,18 @@ func file_elys_commitment_commitments_proto_init() { return nil } } + file_elys_commitment_commitments_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TotalSupply); 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{ @@ -3061,7 +3613,7 @@ func file_elys_commitment_commitments_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_elys_commitment_commitments_proto_rawDesc, NumEnums: 0, - NumMessages: 4, + NumMessages: 5, NumExtensions: 0, NumServices: 0, }, diff --git a/proto/elys/commitment/commitments.proto b/proto/elys/commitment/commitments.proto index 70471d88a..e79575edd 100644 --- a/proto/elys/commitment/commitments.proto +++ b/proto/elys/commitment/commitments.proto @@ -57,3 +57,16 @@ message VestingTokens { int64 start_block = 6; int64 vest_started_timestamp = 7; } + +message TotalSupply { + string total_eden_supply = 1 [ + (cosmos_proto.scalar) = "cosmos.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", + (gogoproto.nullable) = false + ]; + string total_edenb_supply = 2 [ + (cosmos_proto.scalar) = "cosmos.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", + (gogoproto.nullable) = false + ]; +} diff --git a/x/commitment/keeper/commitments.go b/x/commitment/keeper/commitments.go index 25b571e64..46eb03f6a 100644 --- a/x/commitment/keeper/commitments.go +++ b/x/commitment/keeper/commitments.go @@ -162,6 +162,9 @@ func (k Keeper) BurnEdenBoost(ctx sdk.Context, creator sdk.AccAddress, denom str if err != nil { return err // never happens } + prev := k.GetTotalSupply(ctx) + prev.TotalEdenbSupply = prev.TotalEdenbSupply.Sub(claimedRemovalAmount) + k.SetTotalSupply(ctx, prev) amount = amount.Sub(claimedRemovalAmount) if amount.IsZero() { @@ -189,6 +192,9 @@ func (k Keeper) BurnEdenBoost(ctx sdk.Context, creator sdk.AccAddress, denom str if err != nil { return err } + prev = k.GetTotalSupply(ctx) + prev.TotalEdenbSupply = prev.TotalEdenbSupply.Sub(amount) + k.SetTotalSupply(ctx, prev) k.SetCommitments(ctx, commitments) diff --git a/x/commitment/keeper/keeper.go b/x/commitment/keeper/keeper.go index 9881a4121..4b713b24a 100644 --- a/x/commitment/keeper/keeper.go +++ b/x/commitment/keeper/keeper.go @@ -101,83 +101,126 @@ func (k Keeper) BlockedAddr(addr sdk.AccAddress) bool { return k.bankKeeper.BlockedAddr(addr) } -func (k Keeper) AddEdenEdenBOnAccount(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins) sdk.Coins { +func (k Keeper) AddEdenEdenBOnAccount(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins) (sdk.Coins, sdk.Coins) { commitments := k.GetCommitments(ctx, addr) + var coinsChanged sdk.Coins if amt.AmountOf(ptypes.Eden).IsPositive() { coin := sdk.NewCoin(ptypes.Eden, amt.AmountOf(ptypes.Eden)) + coinsChanged.Add(coin) amt = amt.Sub(coin) commitments.AddClaimed(coin) } if amt.AmountOf(ptypes.EdenB).IsPositive() { coin := sdk.NewCoin(ptypes.EdenB, amt.AmountOf(ptypes.EdenB)) + coinsChanged.Add(coin) amt = amt.Sub(coin) commitments.AddClaimed(coin) } // Save the updated Commitments k.SetCommitments(ctx, commitments) - return amt + + return amt, coinsChanged } -func (k Keeper) AddEdenEdenBOnModule(ctx sdk.Context, moduleName string, amt sdk.Coins) sdk.Coins { +func (k Keeper) AddEdenEdenBOnModule(ctx sdk.Context, moduleName string, amt sdk.Coins) (sdk.Coins, sdk.Coins) { addr := authtypes.NewModuleAddress(moduleName) commitments := k.GetCommitments(ctx, addr) + var coinsChanged sdk.Coins if amt.AmountOf(ptypes.Eden).IsPositive() { coin := sdk.NewCoin(ptypes.Eden, amt.AmountOf(ptypes.Eden)) + coinsChanged.Add(coin) amt = amt.Sub(coin) commitments.AddClaimed(coin) } if amt.AmountOf(ptypes.EdenB).IsPositive() { coin := sdk.NewCoin(ptypes.EdenB, amt.AmountOf(ptypes.EdenB)) + coinsChanged.Add(coin) amt = amt.Sub(coin) commitments.AddClaimed(coin) } // Save the updated Commitments k.SetCommitments(ctx, commitments) - return amt + + return amt, coinsChanged } -func (k Keeper) SubEdenEdenBOnModule(ctx sdk.Context, moduleName string, amt sdk.Coins) (sdk.Coins, error) { +func (k Keeper) SubEdenEdenBOnModule(ctx sdk.Context, moduleName string, amt sdk.Coins) (sdk.Coins, sdk.Coins, error) { addr := authtypes.NewModuleAddress(moduleName) commitments := k.GetCommitments(ctx, addr) + var coinsChanged sdk.Coins if amt.AmountOf(ptypes.Eden).IsPositive() { coin := sdk.NewCoin(ptypes.Eden, amt.AmountOf(ptypes.Eden)) + coinsChanged.Add(coin) amt = amt.Sub(coin) err := commitments.SubClaimed(coin) if err != nil { - return amt, err + return amt, nil, err } } if amt.AmountOf(ptypes.EdenB).IsPositive() { coin := sdk.NewCoin(ptypes.EdenB, amt.AmountOf(ptypes.EdenB)) + coinsChanged.Add(coin) amt = amt.Sub(coin) err := commitments.SubClaimed(coin) if err != nil { - return amt, err + return amt, nil, err } } // Save the updated Commitments k.SetCommitments(ctx, commitments) - return amt, nil + return amt, coinsChanged, nil } func (k Keeper) MintCoins(goCtx context.Context, moduleName string, amt sdk.Coins) error { ctx := sdk.UnwrapSDKContext(goCtx) - amt = k.AddEdenEdenBOnModule(ctx, moduleName, amt) + amt, coinsChanged := k.AddEdenEdenBOnModule(ctx, moduleName, amt) + + prev := k.GetTotalSupply(ctx) + prev.TotalEdenSupply = prev.TotalEdenSupply.Add(coinsChanged.AmountOf(ptypes.Eden)) + prev.TotalEdenbSupply = prev.TotalEdenbSupply.Add(coinsChanged.AmountOf(ptypes.EdenB)) + k.SetTotalSupply(ctx, prev) + + // Emit event to track Eden and EdenB mint amount + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeMintCoins, + sdk.NewAttribute("module", moduleName), + sdk.NewAttribute("coins", coinsChanged.String()), + ), + ) + if amt.Empty() { return nil } + return k.bankKeeper.MintCoins(ctx, moduleName, amt) } func (k Keeper) BurnCoins(goCtx context.Context, moduleName string, amt sdk.Coins) error { ctx := sdk.UnwrapSDKContext(goCtx) - amt, err := k.SubEdenEdenBOnModule(ctx, moduleName, amt) + + amt, coinsChanged, err := k.SubEdenEdenBOnModule(ctx, moduleName, amt) if err != nil { return err } + + prev := k.GetTotalSupply(ctx) + prev.TotalEdenSupply = prev.TotalEdenSupply.Sub(coinsChanged.AmountOf(ptypes.Eden)) + prev.TotalEdenbSupply = prev.TotalEdenbSupply.Sub(coinsChanged.AmountOf(ptypes.EdenB)) + k.SetTotalSupply(ctx, prev) + + // Emit event to track Eden and EdenB burn amount + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeBurnCoins, + sdk.NewAttribute("module", moduleName), + sdk.NewAttribute("coins", coinsChanged.String()), + ), + ) + if amt.Empty() { return nil } @@ -187,25 +230,44 @@ func (k Keeper) BurnCoins(goCtx context.Context, moduleName string, amt sdk.Coin func (k Keeper) SendCoinsFromModuleToModule(goCtx context.Context, senderModule string, recipientModule string, amt sdk.Coins) error { ctx := sdk.UnwrapSDKContext(goCtx) - _, err := k.SubEdenEdenBOnModule(ctx, senderModule, amt) + _, _, err := k.SubEdenEdenBOnModule(ctx, senderModule, amt) if err != nil { return err } - amt = k.AddEdenEdenBOnModule(ctx, recipientModule, amt) + amt, coinsChanged := k.AddEdenEdenBOnModule(ctx, recipientModule, amt) + // Emit event to track Eden and EdenB send amount + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeSendCoins, + sdk.NewAttribute("sender_module", senderModule), + sdk.NewAttribute("recipient_module", recipientModule), + sdk.NewAttribute("coins", coinsChanged.String()), + ), + ) if amt.Empty() { return nil } + return k.bankKeeper.SendCoinsFromModuleToModule(ctx, senderModule, recipientModule, amt) } func (k Keeper) SendCoinsFromModuleToAccount(goCtx context.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error { ctx := sdk.UnwrapSDKContext(goCtx) - _, err := k.SubEdenEdenBOnModule(ctx, senderModule, amt) + _, _, err := k.SubEdenEdenBOnModule(ctx, senderModule, amt) if err != nil { return err } - amt = k.AddEdenEdenBOnAccount(ctx, recipientAddr, amt) + amt, coinsChanged := k.AddEdenEdenBOnAccount(ctx, recipientAddr, amt) + // Emit event to track Eden and EdenB send amount + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeSendCoins, + sdk.NewAttribute("sender_module", senderModule), + sdk.NewAttribute("recipient_address", recipientAddr.String()), + sdk.NewAttribute("coins", coinsChanged.String()), + ), + ) if amt.Empty() { return nil } diff --git a/x/commitment/keeper/keeper_test.go b/x/commitment/keeper/keeper_test.go index 7f36c76c4..1b08bb204 100644 --- a/x/commitment/keeper/keeper_test.go +++ b/x/commitment/keeper/keeper_test.go @@ -1,9 +1,10 @@ package keeper_test import ( - sdkmath "cosmossdk.io/math" "testing" + sdkmath "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" simapp "github.com/elys-network/elys/app" @@ -85,7 +86,7 @@ func TestKeeper_AddEdenEdenBOnAccount(t *testing.T) { keeper.SetCommitments(ctx, commitments) // Test AddEdenEdenBOnAccount - _ = keeper.AddEdenEdenBOnAccount(ctx, creator, sdk.NewCoins(sdk.NewCoin(ptypes.Eden, sdkmath.NewInt(50)), sdk.NewCoin(ptypes.EdenB, sdkmath.NewInt(50)))) + _, _ = keeper.AddEdenEdenBOnAccount(ctx, creator, sdk.NewCoins(sdk.NewCoin(ptypes.Eden, sdkmath.NewInt(50)), sdk.NewCoin(ptypes.EdenB, sdkmath.NewInt(50)))) // Check the updated commitments commitments = keeper.GetCommitments(ctx, creator) @@ -128,7 +129,7 @@ func TestKeeper_AddEdenEdenBOnModule(t *testing.T) { keeper.SetCommitments(ctx, commitments) // Test AddEdenEdenBOnModule - _ = keeper.AddEdenEdenBOnModule( + _, _ = keeper.AddEdenEdenBOnModule( ctx, moduleName, sdk.NewCoins( sdk.NewCoin(ptypes.Eden, sdkmath.NewInt(50)), @@ -189,7 +190,7 @@ func TestKeeper_SubEdenEdenBOnModule_InsufficientClaimedTokens(t *testing.T) { keeper.SetCommitments(ctx, commitments) // Test SubEdenEdenBOnModule - _, err = keeper.SubEdenEdenBOnModule( + _, _, err = keeper.SubEdenEdenBOnModule( ctx, moduleName, sdk.NewCoins( sdk.NewCoin(ptypes.Eden, sdkmath.NewInt(50)), diff --git a/x/commitment/keeper/msg_server_cancel_vest.go b/x/commitment/keeper/msg_server_cancel_vest.go index 7ebd8d257..f028a74ed 100644 --- a/x/commitment/keeper/msg_server_cancel_vest.go +++ b/x/commitment/keeper/msg_server_cancel_vest.go @@ -60,6 +60,10 @@ func (k msgServer) CancelVest(goCtx context.Context, msg *types.MsgCancelVest) ( // Update the unclaimed tokens amount commitments.AddClaimed(sdk.NewCoin(ptypes.Eden, msg.Amount)) + + prev := k.GetTotalSupply(ctx) + prev.TotalEdenSupply = prev.TotalEdenSupply.Add(msg.Amount) + k.SetTotalSupply(ctx, prev) k.SetCommitments(ctx, commitments) // Emit blockchain event diff --git a/x/commitment/keeper/msg_server_vest.go b/x/commitment/keeper/msg_server_vest.go index e7a3e3fb3..d2b2eaed4 100644 --- a/x/commitment/keeper/msg_server_vest.go +++ b/x/commitment/keeper/msg_server_vest.go @@ -8,6 +8,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/elys-network/elys/x/commitment/types" + ptypes "github.com/elys-network/elys/x/parameter/types" ) // Vest converts user's commitment to vesting - start with unclaimed rewards and if it's not enough deduct from committed bucket @@ -56,6 +57,12 @@ func (k Keeper) ProcessTokenVesting(ctx sdk.Context, denom string, amount math.I }) commitments.VestingTokens = vestingTokens + if denom == ptypes.Eden { + prev := k.GetTotalSupply(ctx) + prev.TotalEdenSupply = prev.TotalEdenSupply.Sub(amount) + k.SetTotalSupply(ctx, prev) + } + // Update the commitments k.SetCommitments(ctx, commitments) diff --git a/x/commitment/keeper/msg_server_vest_now.go b/x/commitment/keeper/msg_server_vest_now.go index 7db4fd948..0cf11f12b 100644 --- a/x/commitment/keeper/msg_server_vest_now.go +++ b/x/commitment/keeper/msg_server_vest_now.go @@ -54,6 +54,10 @@ func (k msgServer) VestNow(goCtx context.Context, msg *types.MsgVestNow) (*types return nil, errorsmod.Wrap(sdkerrors.ErrInsufficientFunds, "unable to send withdrawn tokens") } + prev := k.GetTotalSupply(ctx) + prev.TotalEdenSupply = prev.TotalEdenSupply.Sub(msg.Amount) + k.SetTotalSupply(ctx, prev) + // Update the commitments k.SetCommitments(ctx, commitments) diff --git a/x/commitment/keeper/params.go b/x/commitment/keeper/params.go index d7e7240bb..440b118ba 100644 --- a/x/commitment/keeper/params.go +++ b/x/commitment/keeper/params.go @@ -1,7 +1,6 @@ package keeper import ( - storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/runtime" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/elys-network/elys/x/commitment/types" @@ -52,26 +51,3 @@ func (k Keeper) GetVestingInfo(ctx sdk.Context, baseDenom string) (*types.Vestin return nil, 0 } - -func (k Keeper) V8_ParamsMigration(ctx sdk.Context) { - store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) - iterator := storetypes.KVStorePrefixIterator(store, types.CommitmentsKeyPrefix) - - defer iterator.Close() - - var totalCommited sdk.Coins - - for ; iterator.Valid(); iterator.Next() { - var val types.Commitments - k.cdc.MustUnmarshal(iterator.Value(), &val) - for _, token := range val.CommittedTokens { - totalCommited = totalCommited.Add(sdk.NewCoin(token.Denom, token.Amount)) - } - } - - params := k.GetParams(ctx) - params.TotalCommitted = totalCommited - k.SetParams(ctx, params) - - return -} diff --git a/x/commitment/keeper/total_supply.go b/x/commitment/keeper/total_supply.go new file mode 100644 index 000000000..6519dacb1 --- /dev/null +++ b/x/commitment/keeper/total_supply.go @@ -0,0 +1,60 @@ +package keeper + +import ( + "cosmossdk.io/math" + storetypes "cosmossdk.io/store/types" + "github.com/cosmos/cosmos-sdk/runtime" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/elys-network/elys/x/commitment/types" + ptypes "github.com/elys-network/elys/x/parameter/types" +) + +func (k Keeper) GetTotalSupply(ctx sdk.Context) (val types.TotalSupply) { + store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + b := store.Get(types.TotalSupplyKeyPrefix) + + if b != nil { + k.cdc.MustUnmarshal(b, &val) + } else { + val.TotalEdenSupply = math.ZeroInt() + val.TotalEdenbSupply = math.ZeroInt() + } + return +} + +func (k Keeper) SetTotalSupply(ctx sdk.Context, val types.TotalSupply) { + store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + b := k.cdc.MustMarshal(&val) + store.Set(types.TotalSupplyKeyPrefix, b) +} + +func (k Keeper) V9_SetSupply(ctx sdk.Context) { + store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + iterator := storetypes.KVStorePrefixIterator(store, types.CommitmentsKeyPrefix) + + defer iterator.Close() + + totalEden := math.ZeroInt() + totalEdenB := math.ZeroInt() + + for ; iterator.Valid(); iterator.Next() { + var val types.Commitments + k.cdc.MustUnmarshal(iterator.Value(), &val) + for _, token := range val.CommittedTokens { + if token.Denom == ptypes.Eden { + totalEden.Add(token.Amount) + } + if token.Denom == ptypes.EdenB { + totalEdenB.Add(token.Amount) + } + } + + totalEden.Add(val.Claimed.AmountOf(ptypes.Eden)) + totalEdenB.Add(val.Claimed.AmountOf(ptypes.EdenB)) + + k.SetTotalSupply(ctx, types.TotalSupply{ + TotalEdenSupply: totalEden, + TotalEdenbSupply: totalEdenB, + }) + } +} diff --git a/x/commitment/migrations/v8_migration.go b/x/commitment/migrations/v8_migration.go index b2ae57605..34302582a 100644 --- a/x/commitment/migrations/v8_migration.go +++ b/x/commitment/migrations/v8_migration.go @@ -5,6 +5,6 @@ import ( ) func (m Migrator) V8Migration(ctx sdk.Context) error { - m.keeper.V8_ParamsMigration(ctx) + //m.keeper.V8_ParamsMigration(ctx) return nil } diff --git a/x/commitment/migrations/v9_migration.go b/x/commitment/migrations/v9_migration.go new file mode 100644 index 000000000..48bd035ba --- /dev/null +++ b/x/commitment/migrations/v9_migration.go @@ -0,0 +1,10 @@ +package migrations + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (m Migrator) V9Migration(ctx sdk.Context) error { + m.keeper.V9_SetSupply(ctx) + return nil +} diff --git a/x/commitment/module.go b/x/commitment/module.go index 8f4f97bdb..896b85899 100644 --- a/x/commitment/module.go +++ b/x/commitment/module.go @@ -123,7 +123,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) types.RegisterQueryServer(cfg.QueryServer(), am.keeper) m := migrations.NewMigrator(am.keeper) - err := cfg.RegisterMigration(types.ModuleName, 7, m.V8Migration) + err := cfg.RegisterMigration(types.ModuleName, 8, m.V9Migration) if err != nil { panic(err) } @@ -150,7 +150,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw } // ConsensusVersion is a sequence number for state-breaking change of the module. It should be incremented on each consensus-breaking change introduced by the module. To avoid wrong/empty versions, the initial version should be set to 1 -func (AppModule) ConsensusVersion() uint64 { return 8 } +func (AppModule) ConsensusVersion() uint64 { return 9 } // BeginBlock contains the logic that is automatically triggered at the beginning of each block func (am AppModule) BeginBlock(_ context.Context) error { diff --git a/x/commitment/types/commitments.pb.go b/x/commitment/types/commitments.pb.go index 4e3ebcba9..38706ec92 100644 --- a/x/commitment/types/commitments.pb.go +++ b/x/commitment/types/commitments.pb.go @@ -267,56 +267,98 @@ func (m *VestingTokens) GetVestStartedTimestamp() int64 { return 0 } +type TotalSupply struct { + TotalEdenSupply cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=total_eden_supply,json=totalEdenSupply,proto3,customtype=cosmossdk.io/math.Int" json:"total_eden_supply"` + TotalEdenbSupply cosmossdk_io_math.Int `protobuf:"bytes,2,opt,name=total_edenb_supply,json=totalEdenbSupply,proto3,customtype=cosmossdk.io/math.Int" json:"total_edenb_supply"` +} + +func (m *TotalSupply) Reset() { *m = TotalSupply{} } +func (m *TotalSupply) String() string { return proto.CompactTextString(m) } +func (*TotalSupply) ProtoMessage() {} +func (*TotalSupply) Descriptor() ([]byte, []int) { + return fileDescriptor_47379c930fe66ed6, []int{4} +} +func (m *TotalSupply) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TotalSupply) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TotalSupply.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 *TotalSupply) XXX_Merge(src proto.Message) { + xxx_messageInfo_TotalSupply.Merge(m, src) +} +func (m *TotalSupply) XXX_Size() int { + return m.Size() +} +func (m *TotalSupply) XXX_DiscardUnknown() { + xxx_messageInfo_TotalSupply.DiscardUnknown(m) +} + +var xxx_messageInfo_TotalSupply proto.InternalMessageInfo + func init() { proto.RegisterType((*Commitments)(nil), "elys.commitment.Commitments") proto.RegisterType((*Lockup)(nil), "elys.commitment.Lockup") proto.RegisterType((*CommittedTokens)(nil), "elys.commitment.CommittedTokens") proto.RegisterType((*VestingTokens)(nil), "elys.commitment.VestingTokens") + proto.RegisterType((*TotalSupply)(nil), "elys.commitment.TotalSupply") } func init() { proto.RegisterFile("elys/commitment/commitments.proto", fileDescriptor_47379c930fe66ed6) } var fileDescriptor_47379c930fe66ed6 = []byte{ - // 614 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0x31, 0x6f, 0xd3, 0x40, - 0x14, 0x8e, 0x93, 0x36, 0x51, 0x2f, 0xb4, 0x29, 0x56, 0x00, 0xb7, 0x02, 0x27, 0x64, 0x0a, 0x42, - 0xf1, 0xd1, 0x82, 0xc4, 0xdc, 0x44, 0x0c, 0x11, 0x88, 0xc1, 0xad, 0x18, 0x58, 0xac, 0xb3, 0x7d, - 0xb8, 0x96, 0x7d, 0x77, 0x91, 0xef, 0x1c, 0xda, 0x7f, 0xc1, 0x9f, 0x60, 0x61, 0xee, 0x88, 0xc4, - 0xda, 0xb1, 0xea, 0x84, 0x18, 0x0a, 0x4a, 0xfe, 0x08, 0xf2, 0xdd, 0x39, 0x4d, 0x53, 0x31, 0xd0, - 0xa5, 0xf5, 0x7b, 0xef, 0x7b, 0xdf, 0x7d, 0xef, 0x7b, 0x77, 0x01, 0x4f, 0x71, 0x7a, 0xca, 0x61, - 0xc0, 0x08, 0x89, 0x05, 0xc1, 0x54, 0x2c, 0x7d, 0x72, 0x67, 0x92, 0x31, 0xc1, 0xcc, 0x56, 0x01, - 0x71, 0xae, 0xf3, 0xbb, 0x9d, 0x88, 0xb1, 0x28, 0xc5, 0x50, 0x96, 0xfd, 0xfc, 0x13, 0x14, 0x31, - 0xc1, 0x5c, 0x20, 0x32, 0x51, 0x1d, 0xbb, 0xf6, 0x2a, 0x20, 0xcc, 0x33, 0x24, 0x62, 0x46, 0x75, - 0x7d, 0x27, 0x60, 0x9c, 0x30, 0xee, 0xc9, 0x08, 0xaa, 0xa0, 0x6c, 0x55, 0x11, 0xf4, 0x11, 0xc7, - 0x70, 0xba, 0xe7, 0x63, 0x81, 0xf6, 0x60, 0xc0, 0xe2, 0xb2, 0xb5, 0x1d, 0xb1, 0x88, 0xa9, 0xbe, - 0xe2, 0x4b, 0x67, 0x1f, 0xaf, 0x4e, 0x31, 0x41, 0x19, 0x22, 0x25, 0xe7, 0x7d, 0x44, 0x62, 0xca, - 0xa0, 0xfc, 0xab, 0x52, 0xbd, 0xef, 0x55, 0xd0, 0x1c, 0x5d, 0x4f, 0x6a, 0xee, 0x83, 0x46, 0x90, - 0x61, 0x24, 0x58, 0x66, 0x19, 0x5d, 0xa3, 0xbf, 0x31, 0xb4, 0x2e, 0xcf, 0x06, 0x6d, 0xad, 0xec, - 0x20, 0x0c, 0x33, 0xcc, 0xf9, 0xa1, 0xc8, 0x62, 0x1a, 0xb9, 0x25, 0xd0, 0x7c, 0x0b, 0xb6, 0xd5, - 0x89, 0x02, 0x87, 0x9e, 0x60, 0x09, 0xa6, 0xdc, 0xaa, 0x76, 0x6b, 0xfd, 0xe6, 0x7e, 0xd7, 0x59, - 0xb1, 0xcc, 0x19, 0x95, 0xc0, 0x23, 0x89, 0x73, 0x5b, 0xc1, 0xcd, 0x84, 0x89, 0x41, 0x23, 0x48, - 0x51, 0x4c, 0x70, 0x68, 0xd5, 0x24, 0xc7, 0x8e, 0xa3, 0x4f, 0x2f, 0x9c, 0x70, 0xb4, 0x13, 0xce, - 0x88, 0xc5, 0x74, 0xf8, 0xe2, 0xfc, 0xaa, 0x53, 0xf9, 0xf6, 0xbb, 0xd3, 0x8f, 0x62, 0x71, 0x9c, - 0xfb, 0xc5, 0x39, 0xda, 0x44, 0xfd, 0x6f, 0xc0, 0xc3, 0x04, 0x8a, 0xd3, 0x09, 0xe6, 0xb2, 0x81, - 0xbb, 0x25, 0xb7, 0xf9, 0x06, 0x6c, 0x4d, 0x31, 0x17, 0x31, 0x8d, 0x4a, 0xc5, 0x6b, 0xf2, 0x34, - 0xfb, 0x96, 0xe2, 0x0f, 0x0a, 0xa6, 0xf5, 0x6e, 0x4e, 0x97, 0xc3, 0xde, 0x09, 0xa8, 0xbf, 0x63, - 0x41, 0x92, 0x4f, 0xcc, 0x11, 0xa8, 0x23, 0xc2, 0x72, 0x2a, 0xb4, 0x6f, 0xcf, 0x0b, 0x6d, 0xbf, - 0xae, 0x3a, 0x0f, 0x94, 0x12, 0x1e, 0x26, 0x4e, 0xcc, 0x20, 0x41, 0xe2, 0xd8, 0x19, 0x53, 0x71, - 0x79, 0x36, 0x00, 0x7a, 0xac, 0x31, 0x15, 0xae, 0x6e, 0x35, 0x9f, 0x81, 0xed, 0x9c, 0xa6, 0x2c, - 0x48, 0xbc, 0xc5, 0x4d, 0xb2, 0xaa, 0x5d, 0xa3, 0xbf, 0xe6, 0xb6, 0x54, 0xfe, 0xa8, 0x4c, 0xf7, - 0xbe, 0x1a, 0xa0, 0xb5, 0x62, 0xa6, 0xd9, 0x06, 0xeb, 0x21, 0xa6, 0x8c, 0x28, 0x09, 0xae, 0x0a, - 0x96, 0x94, 0x55, 0xef, 0xae, 0xec, 0x35, 0x68, 0xa4, 0x72, 0x50, 0xae, 0xd7, 0xf2, 0xe8, 0x96, - 0x51, 0xca, 0x88, 0xe1, 0x5a, 0x41, 0xef, 0x96, 0xe8, 0xde, 0x8f, 0x2a, 0xd8, 0xbc, 0x61, 0xe1, - 0x3f, 0x54, 0xbe, 0x07, 0xf7, 0x04, 0x13, 0x28, 0xf5, 0xee, 0xae, 0xb5, 0x29, 0x09, 0x0e, 0x94, - 0x60, 0x17, 0x6c, 0xe9, 0x5d, 0x97, 0x8c, 0xb5, 0xff, 0x67, 0xdc, 0xd4, 0x14, 0x9a, 0xf3, 0x09, - 0x00, 0x34, 0x27, 0x9e, 0x5f, 0xcc, 0xc6, 0xad, 0xf5, 0xae, 0xd1, 0xaf, 0xb9, 0x1b, 0x34, 0x27, - 0x43, 0x99, 0x30, 0x3b, 0xa0, 0xc9, 0x05, 0xca, 0x84, 0x02, 0x58, 0x75, 0x59, 0x07, 0x32, 0x25, - 0x11, 0xe6, 0x2b, 0xf0, 0xb0, 0xb8, 0x3e, 0x9e, 0x4c, 0x15, 0x6f, 0x65, 0xb1, 0xe4, 0x86, 0xc4, - 0xb6, 0x8b, 0xea, 0xa1, 0x2a, 0x2e, 0x36, 0x3d, 0x1c, 0x9f, 0xcf, 0x6c, 0xe3, 0x62, 0x66, 0x1b, - 0x7f, 0x66, 0xb6, 0xf1, 0x65, 0x6e, 0x57, 0x2e, 0xe6, 0x76, 0xe5, 0xe7, 0xdc, 0xae, 0x7c, 0x84, - 0x4b, 0xf7, 0xbe, 0xd8, 0xc6, 0x80, 0x62, 0xf1, 0x99, 0x65, 0x89, 0x0c, 0xe0, 0xc9, 0xf2, 0xef, - 0x80, 0x7c, 0x04, 0x7e, 0x5d, 0x3e, 0xfa, 0x97, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x8b, 0xec, - 0xd1, 0x55, 0xed, 0x04, 0x00, 0x00, + // 665 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0x3f, 0x6f, 0xd3, 0x4e, + 0x18, 0x8e, 0x93, 0x36, 0x51, 0x2f, 0xbf, 0x36, 0xad, 0x95, 0x1f, 0xb8, 0x15, 0x38, 0x21, 0x53, + 0x10, 0x8a, 0x4d, 0x0b, 0x12, 0x73, 0x13, 0x75, 0xa8, 0x40, 0x0c, 0x6e, 0x05, 0x82, 0xc5, 0x3a, + 0xdb, 0x87, 0x6b, 0xc5, 0x77, 0x67, 0xf9, 0xce, 0xa5, 0xfd, 0x16, 0x7c, 0x09, 0x16, 0xe6, 0x8e, + 0x48, 0x88, 0xad, 0x63, 0xd5, 0x09, 0x31, 0x14, 0xd4, 0x7e, 0x11, 0x74, 0x7f, 0x9c, 0xa4, 0xa9, + 0x18, 0xc8, 0x92, 0xf8, 0x7d, 0xee, 0x79, 0x9f, 0x7b, 0xde, 0xe7, 0xce, 0x06, 0x8f, 0x50, 0x7a, + 0xca, 0xdc, 0x90, 0x62, 0x9c, 0x70, 0x8c, 0x08, 0x9f, 0x79, 0x64, 0x4e, 0x96, 0x53, 0x4e, 0xcd, + 0x96, 0xa0, 0x38, 0x53, 0x7c, 0xab, 0x13, 0x53, 0x1a, 0xa7, 0xc8, 0x95, 0xcb, 0x41, 0xf1, 0xc1, + 0xe5, 0x09, 0x46, 0x8c, 0x43, 0x9c, 0xa9, 0x8e, 0x2d, 0x7b, 0x9e, 0x10, 0x15, 0x39, 0xe4, 0x09, + 0x25, 0x7a, 0x7d, 0x33, 0xa4, 0x0c, 0x53, 0xe6, 0xcb, 0xca, 0x55, 0x45, 0xd9, 0xaa, 0x2a, 0x37, + 0x80, 0x0c, 0xb9, 0xc7, 0xdb, 0x01, 0xe2, 0x70, 0xdb, 0x0d, 0x69, 0x52, 0xb6, 0xb6, 0x63, 0x1a, + 0x53, 0xd5, 0x27, 0x9e, 0x34, 0xfa, 0x60, 0x7e, 0x8a, 0x0c, 0xe6, 0x10, 0x97, 0x9a, 0x1b, 0x10, + 0x27, 0x84, 0xba, 0xf2, 0x57, 0x41, 0xbd, 0xaf, 0x55, 0xd0, 0x1c, 0x4d, 0x27, 0x35, 0x77, 0x40, + 0x23, 0xcc, 0x11, 0xe4, 0x34, 0xb7, 0x8c, 0xae, 0xd1, 0x5f, 0x19, 0x5a, 0x97, 0x67, 0x83, 0xb6, + 0x76, 0xb6, 0x1b, 0x45, 0x39, 0x62, 0xec, 0x80, 0xe7, 0x09, 0x89, 0xbd, 0x92, 0x68, 0xbe, 0x04, + 0xeb, 0x6a, 0x47, 0x8e, 0x22, 0x9f, 0xd3, 0x31, 0x22, 0xcc, 0xaa, 0x76, 0x6b, 0xfd, 0xe6, 0x4e, + 0xd7, 0x99, 0x8b, 0xcc, 0x19, 0x95, 0xc4, 0x43, 0xc9, 0xf3, 0x5a, 0xe1, 0x6d, 0xc0, 0x44, 0xa0, + 0x11, 0xa6, 0x30, 0xc1, 0x28, 0xb2, 0x6a, 0x52, 0x63, 0xd3, 0xd1, 0xbb, 0x8b, 0x24, 0x1c, 0x9d, + 0x84, 0x33, 0xa2, 0x09, 0x19, 0x3e, 0x3d, 0xbf, 0xea, 0x54, 0xbe, 0xfc, 0xea, 0xf4, 0xe3, 0x84, + 0x1f, 0x15, 0x81, 0xd8, 0x47, 0x87, 0xa8, 0xff, 0x06, 0x2c, 0x1a, 0xbb, 0xfc, 0x34, 0x43, 0x4c, + 0x36, 0x30, 0xaf, 0xd4, 0x36, 0xf7, 0xc0, 0xda, 0x31, 0x62, 0x3c, 0x21, 0x71, 0xe9, 0x78, 0x49, + 0xee, 0x66, 0xdf, 0x71, 0xfc, 0x46, 0xd1, 0xb4, 0xdf, 0xd5, 0xe3, 0xd9, 0xb2, 0x77, 0x02, 0xea, + 0xaf, 0x68, 0x38, 0x2e, 0x32, 0x73, 0x04, 0xea, 0x10, 0xd3, 0x82, 0x70, 0x9d, 0xdb, 0x13, 0xe1, + 0xed, 0xe7, 0x55, 0xe7, 0x7f, 0xe5, 0x84, 0x45, 0x63, 0x27, 0xa1, 0x2e, 0x86, 0xfc, 0xc8, 0xd9, + 0x27, 0xfc, 0xf2, 0x6c, 0x00, 0xf4, 0x58, 0xfb, 0x84, 0x7b, 0xba, 0xd5, 0x7c, 0x0c, 0xd6, 0x0b, + 0x92, 0xd2, 0x70, 0xec, 0x4f, 0x6e, 0x92, 0x55, 0xed, 0x1a, 0xfd, 0x25, 0xaf, 0xa5, 0xf0, 0xc3, + 0x12, 0xee, 0x7d, 0x36, 0x40, 0x6b, 0x2e, 0x4c, 0xb3, 0x0d, 0x96, 0x23, 0x44, 0x28, 0x56, 0x16, + 0x3c, 0x55, 0xcc, 0x38, 0xab, 0x2e, 0xee, 0xec, 0x05, 0x68, 0xa4, 0x72, 0x50, 0xa6, 0x8f, 0xe5, + 0xfe, 0x9d, 0xa0, 0x54, 0x10, 0xc3, 0x25, 0x21, 0xef, 0x95, 0xec, 0xde, 0xb7, 0x2a, 0x58, 0xbd, + 0x15, 0xe1, 0x5f, 0x5c, 0xbe, 0x06, 0xff, 0x71, 0xca, 0x61, 0xea, 0x2f, 0xee, 0xb5, 0x29, 0x05, + 0x76, 0x95, 0x61, 0x0f, 0xac, 0xe9, 0xb3, 0x2e, 0x15, 0x6b, 0xff, 0xae, 0xb8, 0xaa, 0x25, 0xb4, + 0xe6, 0x43, 0x00, 0x48, 0x81, 0xfd, 0x40, 0xcc, 0xc6, 0xac, 0xe5, 0xae, 0xd1, 0xaf, 0x79, 0x2b, + 0xa4, 0xc0, 0x43, 0x09, 0x98, 0x1d, 0xd0, 0x64, 0x1c, 0xe6, 0x5c, 0x11, 0xac, 0xba, 0x5c, 0x07, + 0x12, 0x92, 0x0c, 0xf3, 0x39, 0xb8, 0x27, 0xae, 0x8f, 0x2f, 0x21, 0xf1, 0xae, 0x4c, 0x0e, 0xb9, + 0x21, 0xb9, 0x6d, 0xb1, 0x7a, 0xa0, 0x16, 0xa7, 0x27, 0xfd, 0xdd, 0x00, 0xcd, 0x43, 0x31, 0xd9, + 0x41, 0x91, 0x65, 0xe9, 0xa9, 0xf9, 0x16, 0x6c, 0xa8, 0xa4, 0x50, 0x84, 0x88, 0xcf, 0x24, 0xb8, + 0xc8, 0xa5, 0x6b, 0x49, 0x95, 0xbd, 0x08, 0x11, 0x2d, 0xfc, 0x0e, 0x98, 0x53, 0xe1, 0xa0, 0x54, + 0x5e, 0xe0, 0x20, 0xd6, 0x27, 0xca, 0x81, 0x92, 0x1e, 0xee, 0x9f, 0x5f, 0xdb, 0xc6, 0xc5, 0xb5, + 0x6d, 0xfc, 0xbe, 0xb6, 0x8d, 0x4f, 0x37, 0x76, 0xe5, 0xe2, 0xc6, 0xae, 0xfc, 0xb8, 0xb1, 0x2b, + 0xef, 0xdd, 0x99, 0x77, 0x57, 0xdc, 0xa8, 0x01, 0x41, 0xfc, 0x23, 0xcd, 0xc7, 0xb2, 0x70, 0x4f, + 0x66, 0xbf, 0x65, 0xf2, 0x45, 0x0e, 0xea, 0xf2, 0xc3, 0xf5, 0xec, 0x4f, 0x00, 0x00, 0x00, 0xff, + 0xff, 0xc3, 0x1c, 0xd7, 0x44, 0xb1, 0x05, 0x00, 0x00, } func (m *Commitments) Marshal() (dAtA []byte, err error) { @@ -548,6 +590,49 @@ func (m *VestingTokens) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *TotalSupply) 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 *TotalSupply) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TotalSupply) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.TotalEdenbSupply.Size() + i -= size + if _, err := m.TotalEdenbSupply.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintCommitments(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size := m.TotalEdenSupply.Size() + i -= size + if _, err := m.TotalEdenSupply.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintCommitments(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + func encodeVarintCommitments(dAtA []byte, offset int, v uint64) int { offset -= sovCommitments(v) base := offset @@ -651,6 +736,19 @@ func (m *VestingTokens) Size() (n int) { return n } +func (m *TotalSupply) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.TotalEdenSupply.Size() + n += 1 + l + sovCommitments(uint64(l)) + l = m.TotalEdenbSupply.Size() + n += 1 + l + sovCommitments(uint64(l)) + return n +} + func sovCommitments(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1301,6 +1399,124 @@ func (m *VestingTokens) Unmarshal(dAtA []byte) error { } return nil } +func (m *TotalSupply) 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 ErrIntOverflowCommitments + } + 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: TotalSupply: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TotalSupply: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalEdenSupply", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCommitments + } + 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 ErrInvalidLengthCommitments + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCommitments + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TotalEdenSupply.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalEdenbSupply", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCommitments + } + 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 ErrInvalidLengthCommitments + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCommitments + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TotalEdenbSupply.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipCommitments(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthCommitments + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipCommitments(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/commitment/types/events.go b/x/commitment/types/events.go index f42e1e450..fc6b7ccfd 100644 --- a/x/commitment/types/events.go +++ b/x/commitment/types/events.go @@ -4,6 +4,9 @@ package types const ( EventTypeCommitmentChanged = "commitment_changed" EventTypeClaimVesting = "claim_vesting" + EventTypeMintCoins = "mint_coins" + EventTypeBurnCoins = "burn_coins" + EventTypeSendCoins = "send_coins" AttributeCreator = "creator" AttributeAmount = "token_amount" diff --git a/x/commitment/types/keys.go b/x/commitment/types/keys.go index b6ae8bf8a..97b9d647a 100644 --- a/x/commitment/types/keys.go +++ b/x/commitment/types/keys.go @@ -25,6 +25,7 @@ var ( AirdropClaimedKeyPrefix = []byte{0x07} TotalClaimedKeyPrefix = []byte{0x08} KolKeyPrefix = []byte{0x09} + TotalSupplyKeyPrefix = []byte{0x10} ) func GetCommitmentsKey(creator sdk.AccAddress) []byte { diff --git a/x/commitment/types/params.go b/x/commitment/types/params.go index bb466c2cd..cc447f50a 100644 --- a/x/commitment/types/params.go +++ b/x/commitment/types/params.go @@ -1,9 +1,10 @@ package types import ( + "fmt" + errorsmod "cosmossdk.io/errors" "cosmossdk.io/math" - "fmt" sdk "github.com/cosmos/cosmos-sdk/types" ptypes "github.com/elys-network/elys/x/parameter/types"