From eb0d6811574c7eba4599bc971722c049018c0cd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C5=A9=20Kh=C6=B0=C6=A1ng=20Duy?= Date: Sun, 30 Jun 2024 15:24:33 +0000 Subject: [PATCH] Handling Loan request --- api/loan/loan/tx.pulsar.go | 1213 ++++++++++++++++++++- api/loan/loan/tx_grpc.pb.go | 37 + docs/static/openapi.yml | 70 +- proto/loan/loan/tx.proto | 34 +- x/loan/keeper/msg_server_request_loan.go | 18 + x/loan/module/autocli.go | 6 + x/loan/module/simulation.go | 25 +- x/loan/simulation/request_loan.go | 30 + x/loan/types/codec.go | 3 + x/loan/types/message_request_loan.go | 27 + x/loan/types/message_request_loan_test.go | 41 + x/loan/types/tx.pb.go | 581 +++++++++- 12 files changed, 2018 insertions(+), 67 deletions(-) create mode 100644 x/loan/keeper/msg_server_request_loan.go create mode 100644 x/loan/simulation/request_loan.go create mode 100644 x/loan/types/message_request_loan.go create mode 100644 x/loan/types/message_request_loan_test.go diff --git a/api/loan/loan/tx.pulsar.go b/api/loan/loan/tx.pulsar.go index 21c695c..ba63e21 100644 --- a/api/loan/loan/tx.pulsar.go +++ b/api/loan/loan/tx.pulsar.go @@ -872,6 +872,1038 @@ func (x *fastReflection_MsgUpdateParamsResponse) ProtoMethods() *protoiface.Meth } } +var ( + md_MsgRequestLoan protoreflect.MessageDescriptor + fd_MsgRequestLoan_creator protoreflect.FieldDescriptor + fd_MsgRequestLoan_amount protoreflect.FieldDescriptor + fd_MsgRequestLoan_fee protoreflect.FieldDescriptor + fd_MsgRequestLoan_collateral protoreflect.FieldDescriptor + fd_MsgRequestLoan_deadline protoreflect.FieldDescriptor +) + +func init() { + file_loan_loan_tx_proto_init() + md_MsgRequestLoan = File_loan_loan_tx_proto.Messages().ByName("MsgRequestLoan") + fd_MsgRequestLoan_creator = md_MsgRequestLoan.Fields().ByName("creator") + fd_MsgRequestLoan_amount = md_MsgRequestLoan.Fields().ByName("amount") + fd_MsgRequestLoan_fee = md_MsgRequestLoan.Fields().ByName("fee") + fd_MsgRequestLoan_collateral = md_MsgRequestLoan.Fields().ByName("collateral") + fd_MsgRequestLoan_deadline = md_MsgRequestLoan.Fields().ByName("deadline") +} + +var _ protoreflect.Message = (*fastReflection_MsgRequestLoan)(nil) + +type fastReflection_MsgRequestLoan MsgRequestLoan + +func (x *MsgRequestLoan) ProtoReflect() protoreflect.Message { + return (*fastReflection_MsgRequestLoan)(x) +} + +func (x *MsgRequestLoan) slowProtoReflect() protoreflect.Message { + mi := &file_loan_loan_tx_proto_msgTypes[2] + 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_MsgRequestLoan_messageType fastReflection_MsgRequestLoan_messageType +var _ protoreflect.MessageType = fastReflection_MsgRequestLoan_messageType{} + +type fastReflection_MsgRequestLoan_messageType struct{} + +func (x fastReflection_MsgRequestLoan_messageType) Zero() protoreflect.Message { + return (*fastReflection_MsgRequestLoan)(nil) +} +func (x fastReflection_MsgRequestLoan_messageType) New() protoreflect.Message { + return new(fastReflection_MsgRequestLoan) +} +func (x fastReflection_MsgRequestLoan_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_MsgRequestLoan +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_MsgRequestLoan) Descriptor() protoreflect.MessageDescriptor { + return md_MsgRequestLoan +} + +// 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_MsgRequestLoan) Type() protoreflect.MessageType { + return _fastReflection_MsgRequestLoan_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_MsgRequestLoan) New() protoreflect.Message { + return new(fastReflection_MsgRequestLoan) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_MsgRequestLoan) Interface() protoreflect.ProtoMessage { + return (*MsgRequestLoan)(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_MsgRequestLoan) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Creator != "" { + value := protoreflect.ValueOfString(x.Creator) + if !f(fd_MsgRequestLoan_creator, value) { + return + } + } + if x.Amount != "" { + value := protoreflect.ValueOfString(x.Amount) + if !f(fd_MsgRequestLoan_amount, value) { + return + } + } + if x.Fee != "" { + value := protoreflect.ValueOfString(x.Fee) + if !f(fd_MsgRequestLoan_fee, value) { + return + } + } + if x.Collateral != "" { + value := protoreflect.ValueOfString(x.Collateral) + if !f(fd_MsgRequestLoan_collateral, value) { + return + } + } + if x.Deadline != "" { + value := protoreflect.ValueOfString(x.Deadline) + if !f(fd_MsgRequestLoan_deadline, 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_MsgRequestLoan) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "loan.loan.MsgRequestLoan.creator": + return x.Creator != "" + case "loan.loan.MsgRequestLoan.amount": + return x.Amount != "" + case "loan.loan.MsgRequestLoan.fee": + return x.Fee != "" + case "loan.loan.MsgRequestLoan.collateral": + return x.Collateral != "" + case "loan.loan.MsgRequestLoan.deadline": + return x.Deadline != "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: loan.loan.MsgRequestLoan")) + } + panic(fmt.Errorf("message loan.loan.MsgRequestLoan 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_MsgRequestLoan) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "loan.loan.MsgRequestLoan.creator": + x.Creator = "" + case "loan.loan.MsgRequestLoan.amount": + x.Amount = "" + case "loan.loan.MsgRequestLoan.fee": + x.Fee = "" + case "loan.loan.MsgRequestLoan.collateral": + x.Collateral = "" + case "loan.loan.MsgRequestLoan.deadline": + x.Deadline = "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: loan.loan.MsgRequestLoan")) + } + panic(fmt.Errorf("message loan.loan.MsgRequestLoan 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_MsgRequestLoan) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "loan.loan.MsgRequestLoan.creator": + value := x.Creator + return protoreflect.ValueOfString(value) + case "loan.loan.MsgRequestLoan.amount": + value := x.Amount + return protoreflect.ValueOfString(value) + case "loan.loan.MsgRequestLoan.fee": + value := x.Fee + return protoreflect.ValueOfString(value) + case "loan.loan.MsgRequestLoan.collateral": + value := x.Collateral + return protoreflect.ValueOfString(value) + case "loan.loan.MsgRequestLoan.deadline": + value := x.Deadline + return protoreflect.ValueOfString(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: loan.loan.MsgRequestLoan")) + } + panic(fmt.Errorf("message loan.loan.MsgRequestLoan 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_MsgRequestLoan) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "loan.loan.MsgRequestLoan.creator": + x.Creator = value.Interface().(string) + case "loan.loan.MsgRequestLoan.amount": + x.Amount = value.Interface().(string) + case "loan.loan.MsgRequestLoan.fee": + x.Fee = value.Interface().(string) + case "loan.loan.MsgRequestLoan.collateral": + x.Collateral = value.Interface().(string) + case "loan.loan.MsgRequestLoan.deadline": + x.Deadline = value.Interface().(string) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: loan.loan.MsgRequestLoan")) + } + panic(fmt.Errorf("message loan.loan.MsgRequestLoan 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_MsgRequestLoan) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "loan.loan.MsgRequestLoan.creator": + panic(fmt.Errorf("field creator of message loan.loan.MsgRequestLoan is not mutable")) + case "loan.loan.MsgRequestLoan.amount": + panic(fmt.Errorf("field amount of message loan.loan.MsgRequestLoan is not mutable")) + case "loan.loan.MsgRequestLoan.fee": + panic(fmt.Errorf("field fee of message loan.loan.MsgRequestLoan is not mutable")) + case "loan.loan.MsgRequestLoan.collateral": + panic(fmt.Errorf("field collateral of message loan.loan.MsgRequestLoan is not mutable")) + case "loan.loan.MsgRequestLoan.deadline": + panic(fmt.Errorf("field deadline of message loan.loan.MsgRequestLoan is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: loan.loan.MsgRequestLoan")) + } + panic(fmt.Errorf("message loan.loan.MsgRequestLoan 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_MsgRequestLoan) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "loan.loan.MsgRequestLoan.creator": + return protoreflect.ValueOfString("") + case "loan.loan.MsgRequestLoan.amount": + return protoreflect.ValueOfString("") + case "loan.loan.MsgRequestLoan.fee": + return protoreflect.ValueOfString("") + case "loan.loan.MsgRequestLoan.collateral": + return protoreflect.ValueOfString("") + case "loan.loan.MsgRequestLoan.deadline": + return protoreflect.ValueOfString("") + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: loan.loan.MsgRequestLoan")) + } + panic(fmt.Errorf("message loan.loan.MsgRequestLoan 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_MsgRequestLoan) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in loan.loan.MsgRequestLoan", 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_MsgRequestLoan) 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_MsgRequestLoan) 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_MsgRequestLoan) 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_MsgRequestLoan) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*MsgRequestLoan) + 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.Creator) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.Amount) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.Fee) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.Collateral) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.Deadline) + 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().(*MsgRequestLoan) + 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.Deadline) > 0 { + i -= len(x.Deadline) + copy(dAtA[i:], x.Deadline) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Deadline))) + i-- + dAtA[i] = 0x2a + } + if len(x.Collateral) > 0 { + i -= len(x.Collateral) + copy(dAtA[i:], x.Collateral) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Collateral))) + i-- + dAtA[i] = 0x22 + } + if len(x.Fee) > 0 { + i -= len(x.Fee) + copy(dAtA[i:], x.Fee) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Fee))) + i-- + dAtA[i] = 0x1a + } + if len(x.Amount) > 0 { + i -= len(x.Amount) + copy(dAtA[i:], x.Amount) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Amount))) + i-- + dAtA[i] = 0x12 + } + if len(x.Creator) > 0 { + i -= len(x.Creator) + copy(dAtA[i:], x.Creator) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Creator))) + 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().(*MsgRequestLoan) + 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: MsgRequestLoan: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: MsgRequestLoan: 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 Creator", 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.Creator = 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 Amount", 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.Amount = 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 Fee", 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.Fee = 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 Collateral", 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.Collateral = 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 Deadline", 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.Deadline = 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, + } +} + +var ( + md_MsgRequestLoanResponse protoreflect.MessageDescriptor +) + +func init() { + file_loan_loan_tx_proto_init() + md_MsgRequestLoanResponse = File_loan_loan_tx_proto.Messages().ByName("MsgRequestLoanResponse") +} + +var _ protoreflect.Message = (*fastReflection_MsgRequestLoanResponse)(nil) + +type fastReflection_MsgRequestLoanResponse MsgRequestLoanResponse + +func (x *MsgRequestLoanResponse) ProtoReflect() protoreflect.Message { + return (*fastReflection_MsgRequestLoanResponse)(x) +} + +func (x *MsgRequestLoanResponse) slowProtoReflect() protoreflect.Message { + mi := &file_loan_loan_tx_proto_msgTypes[3] + 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_MsgRequestLoanResponse_messageType fastReflection_MsgRequestLoanResponse_messageType +var _ protoreflect.MessageType = fastReflection_MsgRequestLoanResponse_messageType{} + +type fastReflection_MsgRequestLoanResponse_messageType struct{} + +func (x fastReflection_MsgRequestLoanResponse_messageType) Zero() protoreflect.Message { + return (*fastReflection_MsgRequestLoanResponse)(nil) +} +func (x fastReflection_MsgRequestLoanResponse_messageType) New() protoreflect.Message { + return new(fastReflection_MsgRequestLoanResponse) +} +func (x fastReflection_MsgRequestLoanResponse_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_MsgRequestLoanResponse +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_MsgRequestLoanResponse) Descriptor() protoreflect.MessageDescriptor { + return md_MsgRequestLoanResponse +} + +// 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_MsgRequestLoanResponse) Type() protoreflect.MessageType { + return _fastReflection_MsgRequestLoanResponse_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_MsgRequestLoanResponse) New() protoreflect.Message { + return new(fastReflection_MsgRequestLoanResponse) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_MsgRequestLoanResponse) Interface() protoreflect.ProtoMessage { + return (*MsgRequestLoanResponse)(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_MsgRequestLoanResponse) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { +} + +// 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_MsgRequestLoanResponse) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: loan.loan.MsgRequestLoanResponse")) + } + panic(fmt.Errorf("message loan.loan.MsgRequestLoanResponse 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_MsgRequestLoanResponse) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: loan.loan.MsgRequestLoanResponse")) + } + panic(fmt.Errorf("message loan.loan.MsgRequestLoanResponse 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_MsgRequestLoanResponse) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: loan.loan.MsgRequestLoanResponse")) + } + panic(fmt.Errorf("message loan.loan.MsgRequestLoanResponse 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_MsgRequestLoanResponse) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: loan.loan.MsgRequestLoanResponse")) + } + panic(fmt.Errorf("message loan.loan.MsgRequestLoanResponse 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_MsgRequestLoanResponse) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: loan.loan.MsgRequestLoanResponse")) + } + panic(fmt.Errorf("message loan.loan.MsgRequestLoanResponse 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_MsgRequestLoanResponse) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: loan.loan.MsgRequestLoanResponse")) + } + panic(fmt.Errorf("message loan.loan.MsgRequestLoanResponse 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_MsgRequestLoanResponse) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in loan.loan.MsgRequestLoanResponse", 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_MsgRequestLoanResponse) 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_MsgRequestLoanResponse) 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_MsgRequestLoanResponse) 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_MsgRequestLoanResponse) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*MsgRequestLoanResponse) + 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.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().(*MsgRequestLoanResponse) + 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 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().(*MsgRequestLoanResponse) + 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: MsgRequestLoanResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: MsgRequestLoanResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + 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 @@ -893,8 +1925,6 @@ type MsgUpdateParams struct { // authority is the address that controls the module (defaults to x/gov unless overwritten). Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` - // params defines the module parameters to update. - // // NOTE: All parameters must be supplied. Params *Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params,omitempty"` } @@ -961,6 +1991,99 @@ func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { return file_loan_loan_tx_proto_rawDescGZIP(), []int{1} } +type MsgRequestLoan struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + Amount string `protobuf:"bytes,2,opt,name=amount,proto3" json:"amount,omitempty"` + Fee string `protobuf:"bytes,3,opt,name=fee,proto3" json:"fee,omitempty"` + Collateral string `protobuf:"bytes,4,opt,name=collateral,proto3" json:"collateral,omitempty"` + Deadline string `protobuf:"bytes,5,opt,name=deadline,proto3" json:"deadline,omitempty"` +} + +func (x *MsgRequestLoan) Reset() { + *x = MsgRequestLoan{} + if protoimpl.UnsafeEnabled { + mi := &file_loan_loan_tx_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MsgRequestLoan) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MsgRequestLoan) ProtoMessage() {} + +// Deprecated: Use MsgRequestLoan.ProtoReflect.Descriptor instead. +func (*MsgRequestLoan) Descriptor() ([]byte, []int) { + return file_loan_loan_tx_proto_rawDescGZIP(), []int{2} +} + +func (x *MsgRequestLoan) GetCreator() string { + if x != nil { + return x.Creator + } + return "" +} + +func (x *MsgRequestLoan) GetAmount() string { + if x != nil { + return x.Amount + } + return "" +} + +func (x *MsgRequestLoan) GetFee() string { + if x != nil { + return x.Fee + } + return "" +} + +func (x *MsgRequestLoan) GetCollateral() string { + if x != nil { + return x.Collateral + } + return "" +} + +func (x *MsgRequestLoan) GetDeadline() string { + if x != nil { + return x.Deadline + } + return "" +} + +type MsgRequestLoanResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *MsgRequestLoanResponse) Reset() { + *x = MsgRequestLoanResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_loan_loan_tx_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MsgRequestLoanResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MsgRequestLoanResponse) ProtoMessage() {} + +// Deprecated: Use MsgRequestLoanResponse.ProtoReflect.Descriptor instead. +func (*MsgRequestLoanResponse) Descriptor() ([]byte, []int) { + return file_loan_loan_tx_proto_rawDescGZIP(), []int{3} +} + var File_loan_loan_tx_proto protoreflect.FileDescriptor var file_loan_loan_tx_proto_rawDesc = []byte{ @@ -986,21 +2109,37 @@ var file_loan_loan_tx_proto_rawDesc = []byte{ 0x78, 0x2f, 0x6c, 0x6f, 0x61, 0x6e, 0x2f, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x22, 0x19, 0x0a, 0x17, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x32, 0x5c, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x12, 0x4e, 0x0a, 0x0c, 0x55, 0x70, 0x64, 0x61, - 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x1a, 0x2e, 0x6c, 0x6f, 0x61, 0x6e, 0x2e, - 0x6c, 0x6f, 0x61, 0x6e, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, - 0x72, 0x61, 0x6d, 0x73, 0x1a, 0x22, 0x2e, 0x6c, 0x6f, 0x61, 0x6e, 0x2e, 0x6c, 0x6f, 0x61, 0x6e, + 0x65, 0x22, 0x9e, 0x01, 0x0a, 0x0e, 0x4d, 0x73, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x4c, 0x6f, 0x61, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x16, + 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, + 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x66, 0x65, 0x65, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x03, 0x66, 0x65, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x63, 0x6f, 0x6c, 0x6c, + 0x61, 0x74, 0x65, 0x72, 0x61, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x63, 0x6f, + 0x6c, 0x6c, 0x61, 0x74, 0x65, 0x72, 0x61, 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x64, 0x65, 0x61, 0x64, + 0x6c, 0x69, 0x6e, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x64, 0x65, 0x61, 0x64, + 0x6c, 0x69, 0x6e, 0x65, 0x3a, 0x0c, 0x82, 0xe7, 0xb0, 0x2a, 0x07, 0x63, 0x72, 0x65, 0x61, 0x74, + 0x6f, 0x72, 0x22, 0x18, 0x0a, 0x16, 0x4d, 0x73, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x4c, 0x6f, 0x61, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xa9, 0x01, 0x0a, + 0x03, 0x4d, 0x73, 0x67, 0x12, 0x4e, 0x0a, 0x0c, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, + 0x72, 0x61, 0x6d, 0x73, 0x12, 0x1a, 0x2e, 0x6c, 0x6f, 0x61, 0x6e, 0x2e, 0x6c, 0x6f, 0x61, 0x6e, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x1a, 0x05, 0x80, 0xe7, 0xb0, 0x2a, 0x01, 0x42, - 0x79, 0x0a, 0x0d, 0x63, 0x6f, 0x6d, 0x2e, 0x6c, 0x6f, 0x61, 0x6e, 0x2e, 0x6c, 0x6f, 0x61, 0x6e, - 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x1a, 0x63, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x6c, 0x6f, - 0x61, 0x6e, 0x2f, 0x6c, 0x6f, 0x61, 0x6e, 0xa2, 0x02, 0x03, 0x4c, 0x4c, 0x58, 0xaa, 0x02, 0x09, - 0x4c, 0x6f, 0x61, 0x6e, 0x2e, 0x4c, 0x6f, 0x61, 0x6e, 0xca, 0x02, 0x09, 0x4c, 0x6f, 0x61, 0x6e, - 0x5c, 0x4c, 0x6f, 0x61, 0x6e, 0xe2, 0x02, 0x15, 0x4c, 0x6f, 0x61, 0x6e, 0x5c, 0x4c, 0x6f, 0x61, - 0x6e, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0a, - 0x4c, 0x6f, 0x61, 0x6e, 0x3a, 0x3a, 0x4c, 0x6f, 0x61, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x1a, 0x22, 0x2e, 0x6c, 0x6f, 0x61, 0x6e, 0x2e, 0x6c, 0x6f, 0x61, 0x6e, 0x2e, 0x4d, 0x73, 0x67, + 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4b, 0x0a, 0x0b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4c, + 0x6f, 0x61, 0x6e, 0x12, 0x19, 0x2e, 0x6c, 0x6f, 0x61, 0x6e, 0x2e, 0x6c, 0x6f, 0x61, 0x6e, 0x2e, + 0x4d, 0x73, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4c, 0x6f, 0x61, 0x6e, 0x1a, 0x21, + 0x2e, 0x6c, 0x6f, 0x61, 0x6e, 0x2e, 0x6c, 0x6f, 0x61, 0x6e, 0x2e, 0x4d, 0x73, 0x67, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x4c, 0x6f, 0x61, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x1a, 0x05, 0x80, 0xe7, 0xb0, 0x2a, 0x01, 0x42, 0x79, 0x0a, 0x0d, 0x63, 0x6f, 0x6d, 0x2e, + 0x6c, 0x6f, 0x61, 0x6e, 0x2e, 0x6c, 0x6f, 0x61, 0x6e, 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, + 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x1a, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, + 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x6c, 0x6f, 0x61, 0x6e, 0x2f, 0x6c, 0x6f, 0x61, 0x6e, + 0xa2, 0x02, 0x03, 0x4c, 0x4c, 0x58, 0xaa, 0x02, 0x09, 0x4c, 0x6f, 0x61, 0x6e, 0x2e, 0x4c, 0x6f, + 0x61, 0x6e, 0xca, 0x02, 0x09, 0x4c, 0x6f, 0x61, 0x6e, 0x5c, 0x4c, 0x6f, 0x61, 0x6e, 0xe2, 0x02, + 0x15, 0x4c, 0x6f, 0x61, 0x6e, 0x5c, 0x4c, 0x6f, 0x61, 0x6e, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, + 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0a, 0x4c, 0x6f, 0x61, 0x6e, 0x3a, 0x3a, 0x4c, + 0x6f, 0x61, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1015,18 +2154,22 @@ func file_loan_loan_tx_proto_rawDescGZIP() []byte { return file_loan_loan_tx_proto_rawDescData } -var file_loan_loan_tx_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_loan_loan_tx_proto_msgTypes = make([]protoimpl.MessageInfo, 4) var file_loan_loan_tx_proto_goTypes = []interface{}{ (*MsgUpdateParams)(nil), // 0: loan.loan.MsgUpdateParams (*MsgUpdateParamsResponse)(nil), // 1: loan.loan.MsgUpdateParamsResponse - (*Params)(nil), // 2: loan.loan.Params + (*MsgRequestLoan)(nil), // 2: loan.loan.MsgRequestLoan + (*MsgRequestLoanResponse)(nil), // 3: loan.loan.MsgRequestLoanResponse + (*Params)(nil), // 4: loan.loan.Params } var file_loan_loan_tx_proto_depIdxs = []int32{ - 2, // 0: loan.loan.MsgUpdateParams.params:type_name -> loan.loan.Params + 4, // 0: loan.loan.MsgUpdateParams.params:type_name -> loan.loan.Params 0, // 1: loan.loan.Msg.UpdateParams:input_type -> loan.loan.MsgUpdateParams - 1, // 2: loan.loan.Msg.UpdateParams:output_type -> loan.loan.MsgUpdateParamsResponse - 2, // [2:3] is the sub-list for method output_type - 1, // [1:2] is the sub-list for method input_type + 2, // 2: loan.loan.Msg.RequestLoan:input_type -> loan.loan.MsgRequestLoan + 1, // 3: loan.loan.Msg.UpdateParams:output_type -> loan.loan.MsgUpdateParamsResponse + 3, // 4: loan.loan.Msg.RequestLoan:output_type -> loan.loan.MsgRequestLoanResponse + 3, // [3:5] is the sub-list for method output_type + 1, // [1:3] is the sub-list for method input_type 1, // [1:1] is the sub-list for extension type_name 1, // [1:1] is the sub-list for extension extendee 0, // [0:1] is the sub-list for field type_name @@ -1063,6 +2206,30 @@ func file_loan_loan_tx_proto_init() { return nil } } + file_loan_loan_tx_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MsgRequestLoan); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_loan_loan_tx_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MsgRequestLoanResponse); 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{ @@ -1070,7 +2237,7 @@ func file_loan_loan_tx_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_loan_loan_tx_proto_rawDesc, NumEnums: 0, - NumMessages: 2, + NumMessages: 4, NumExtensions: 0, NumServices: 1, }, diff --git a/api/loan/loan/tx_grpc.pb.go b/api/loan/loan/tx_grpc.pb.go index 0d01b08..6f4dbc2 100644 --- a/api/loan/loan/tx_grpc.pb.go +++ b/api/loan/loan/tx_grpc.pb.go @@ -21,6 +21,7 @@ const _ = grpc.SupportPackageIsVersion7 const ( Msg_UpdateParams_FullMethodName = "/loan.loan.Msg/UpdateParams" + Msg_RequestLoan_FullMethodName = "/loan.loan.Msg/RequestLoan" ) // MsgClient is the client API for Msg service. @@ -30,6 +31,7 @@ type MsgClient interface { // UpdateParams defines a (governance) operation for updating the module // parameters. The authority defaults to the x/gov module account. UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) + RequestLoan(ctx context.Context, in *MsgRequestLoan, opts ...grpc.CallOption) (*MsgRequestLoanResponse, error) } type msgClient struct { @@ -49,6 +51,15 @@ func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts return out, nil } +func (c *msgClient) RequestLoan(ctx context.Context, in *MsgRequestLoan, opts ...grpc.CallOption) (*MsgRequestLoanResponse, error) { + out := new(MsgRequestLoanResponse) + err := c.cc.Invoke(ctx, Msg_RequestLoan_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. // All implementations must embed UnimplementedMsgServer // for forward compatibility @@ -56,6 +67,7 @@ type MsgServer interface { // UpdateParams defines a (governance) operation for updating the module // parameters. The authority defaults to the x/gov module account. UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) + RequestLoan(context.Context, *MsgRequestLoan) (*MsgRequestLoanResponse, error) mustEmbedUnimplementedMsgServer() } @@ -66,6 +78,9 @@ type UnimplementedMsgServer struct { func (UnimplementedMsgServer) UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") } +func (UnimplementedMsgServer) RequestLoan(context.Context, *MsgRequestLoan) (*MsgRequestLoanResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RequestLoan not implemented") +} func (UnimplementedMsgServer) mustEmbedUnimplementedMsgServer() {} // UnsafeMsgServer may be embedded to opt out of forward compatibility for this service. @@ -97,6 +112,24 @@ func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(in return interceptor(ctx, in, info, handler) } +func _Msg_RequestLoan_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRequestLoan) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).RequestLoan(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Msg_RequestLoan_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).RequestLoan(ctx, req.(*MsgRequestLoan)) + } + return interceptor(ctx, in, info, handler) +} + // Msg_ServiceDesc is the grpc.ServiceDesc for Msg service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -108,6 +141,10 @@ var Msg_ServiceDesc = grpc.ServiceDesc{ MethodName: "UpdateParams", Handler: _Msg_UpdateParams_Handler, }, + { + MethodName: "RequestLoan", + Handler: _Msg_RequestLoan_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "loan/loan/tx.proto", diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index 813e635..16201ff 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -16447,6 +16447,51 @@ paths: additionalProperties: {} tags: - Query + /loan.loan.Msg/RequestLoan: + post: + operationId: LoanLoanMsg_RequestLoan + responses: + '200': + description: A successful response. + schema: + type: object + 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: {} + parameters: + - name: body + in: body + required: true + schema: + type: object + properties: + creator: + type: string + amount: + type: string + fee: + type: string + collateral: + type: string + deadline: + type: string + tags: + - Msg /loan.loan.Msg/UpdateParams: post: summary: |- @@ -16495,10 +16540,7 @@ paths: authority is the address that controls the module (defaults to x/gov unless overwritten). params: - description: |- - params defines the module parameters to update. - - NOTE: All parameters must be supplied. + description: 'NOTE: All parameters must be supplied.' type: object description: MsgUpdateParams is the Msg/UpdateParams request type. tags: @@ -23336,6 +23378,21 @@ definitions: description: params holds all the parameters of this module. type: object description: QueryParamsResponse is response type for the Query/Params RPC method. + loan.loan.MsgRequestLoan: + type: object + properties: + creator: + type: string + amount: + type: string + fee: + type: string + collateral: + type: string + deadline: + type: string + loan.loan.MsgRequestLoanResponse: + type: object loan.loan.MsgUpdateParams: type: object properties: @@ -23345,10 +23402,7 @@ definitions: authority is the address that controls the module (defaults to x/gov unless overwritten). params: - description: |- - params defines the module parameters to update. - - NOTE: All parameters must be supplied. + description: 'NOTE: All parameters must be supplied.' type: object description: MsgUpdateParams is the Msg/UpdateParams request type. loan.loan.MsgUpdateParamsResponse: diff --git a/proto/loan/loan/tx.proto b/proto/loan/loan/tx.proto index d74d2a8..625c838 100644 --- a/proto/loan/loan/tx.proto +++ b/proto/loan/loan/tx.proto @@ -1,4 +1,5 @@ syntax = "proto3"; + package loan.loan; import "amino/amino.proto"; @@ -12,29 +13,38 @@ option go_package = "loan/x/loan/types"; // Msg defines the Msg service. service Msg { option (cosmos.msg.v1.service) = true; - + // UpdateParams defines a (governance) operation for updating the module // parameters. The authority defaults to the x/gov module account. - rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); + rpc UpdateParams (MsgUpdateParams) returns (MsgUpdateParamsResponse); + rpc RequestLoan (MsgRequestLoan ) returns (MsgRequestLoanResponse ); } - // MsgUpdateParams is the Msg/UpdateParams request type. message MsgUpdateParams { - option (cosmos.msg.v1.signer) = "authority"; - option (amino.name) = "loan/x/loan/MsgUpdateParams"; - + option (cosmos.msg.v1.signer) = "authority"; + option (amino.name) = "loan/x/loan/MsgUpdateParams"; + // authority is the address that controls the module (defaults to x/gov unless overwritten). string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // params defines the module parameters to update. - // + // NOTE: All parameters must be supplied. - Params params = 2 [ - (gogoproto.nullable) = false, - (amino.dont_omitempty) = true - ]; + Params params = 2 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; } // MsgUpdateParamsResponse defines the response structure for executing a // MsgUpdateParams message. -message MsgUpdateParamsResponse {} \ No newline at end of file +message MsgUpdateParamsResponse {} + +message MsgRequestLoan { + option (cosmos.msg.v1.signer) = "creator"; + string creator = 1; + string amount = 2; + string fee = 3; + string collateral = 4; + string deadline = 5; +} + +message MsgRequestLoanResponse {} + diff --git a/x/loan/keeper/msg_server_request_loan.go b/x/loan/keeper/msg_server_request_loan.go new file mode 100644 index 0000000..73786f4 --- /dev/null +++ b/x/loan/keeper/msg_server_request_loan.go @@ -0,0 +1,18 @@ +package keeper + +import ( + "context" + + "loan/x/loan/types" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (k msgServer) RequestLoan(goCtx context.Context, msg *types.MsgRequestLoan) (*types.MsgRequestLoanResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + // TODO: Handling the message + _ = ctx + + return &types.MsgRequestLoanResponse{}, nil +} diff --git a/x/loan/module/autocli.go b/x/loan/module/autocli.go index dfb5b7c..b013a4c 100644 --- a/x/loan/module/autocli.go +++ b/x/loan/module/autocli.go @@ -39,6 +39,12 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { RpcMethod: "UpdateParams", Skip: true, // skipped because authority gated }, + { + RpcMethod: "RequestLoan", + Use: "request-loan [amount] [fee] [collateral] [deadline]", + Short: "Send a request-loan tx", + PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "amount"}, {ProtoField: "fee"}, {ProtoField: "collateral"}, {ProtoField: "deadline"}}, + }, // this line is used by ignite scaffolding # autocli/tx }, }, diff --git a/x/loan/module/simulation.go b/x/loan/module/simulation.go index f01ba70..44f22fd 100644 --- a/x/loan/module/simulation.go +++ b/x/loan/module/simulation.go @@ -23,7 +23,11 @@ var ( ) const ( -// this line is used by starport scaffolding # simapp/module/const + opWeightMsgRequestLoan = "op_weight_msg_request_loan" + // TODO: Determine the simulation weight value + defaultWeightMsgRequestLoan int = 100 + + // this line is used by starport scaffolding # simapp/module/const ) // GenerateGenesisState creates a randomized GenState of the module. @@ -46,6 +50,17 @@ func (am AppModule) RegisterStoreDecoder(_ simtypes.StoreDecoderRegistry) {} func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { operations := make([]simtypes.WeightedOperation, 0) + var weightMsgRequestLoan int + simState.AppParams.GetOrGenerate(opWeightMsgRequestLoan, &weightMsgRequestLoan, nil, + func(_ *rand.Rand) { + weightMsgRequestLoan = defaultWeightMsgRequestLoan + }, + ) + operations = append(operations, simulation.NewWeightedOperation( + weightMsgRequestLoan, + loansimulation.SimulateMsgRequestLoan(am.accountKeeper, am.bankKeeper, am.keeper), + )) + // this line is used by starport scaffolding # simapp/module/operation return operations @@ -54,6 +69,14 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp // ProposalMsgs returns msgs used for governance proposals for simulations. func (am AppModule) ProposalMsgs(simState module.SimulationState) []simtypes.WeightedProposalMsg { return []simtypes.WeightedProposalMsg{ + simulation.NewWeightedProposalMsg( + opWeightMsgRequestLoan, + defaultWeightMsgRequestLoan, + func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) sdk.Msg { + loansimulation.SimulateMsgRequestLoan(am.accountKeeper, am.bankKeeper, am.keeper) + return nil + }, + ), // this line is used by starport scaffolding # simapp/module/OpMsg } } diff --git a/x/loan/simulation/request_loan.go b/x/loan/simulation/request_loan.go new file mode 100644 index 0000000..99bc89c --- /dev/null +++ b/x/loan/simulation/request_loan.go @@ -0,0 +1,30 @@ +package simulation + +import ( + "math/rand" + + "loan/x/loan/keeper" + "loan/x/loan/types" + + "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" +) + +func SimulateMsgRequestLoan( + ak types.AccountKeeper, + bk types.BankKeeper, + k keeper.Keeper, +) simtypes.Operation { + return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + simAccount, _ := simtypes.RandomAcc(r, accs) + msg := &types.MsgRequestLoan{ + Creator: simAccount.Address.String(), + } + + // TODO: Handling the RequestLoan simulation + + return simtypes.NoOpMsg(types.ModuleName, sdk.MsgTypeURL(msg), "RequestLoan simulation not implemented"), nil, nil + } +} diff --git a/x/loan/types/codec.go b/x/loan/types/codec.go index ac55263..b7ae191 100644 --- a/x/loan/types/codec.go +++ b/x/loan/types/codec.go @@ -8,6 +8,9 @@ import ( ) func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgRequestLoan{}, + ) // this line is used by starport scaffolding # 3 registry.RegisterImplementations((*sdk.Msg)(nil), diff --git a/x/loan/types/message_request_loan.go b/x/loan/types/message_request_loan.go new file mode 100644 index 0000000..31f048d --- /dev/null +++ b/x/loan/types/message_request_loan.go @@ -0,0 +1,27 @@ +package types + +import ( + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +var _ sdk.Msg = &MsgRequestLoan{} + +func NewMsgRequestLoan(creator string, amount string, fee string, collateral string, deadline string) *MsgRequestLoan { + return &MsgRequestLoan{ + Creator: creator, + Amount: amount, + Fee: fee, + Collateral: collateral, + Deadline: deadline, + } +} + +func (msg *MsgRequestLoan) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + return nil +} diff --git a/x/loan/types/message_request_loan_test.go b/x/loan/types/message_request_loan_test.go new file mode 100644 index 0000000..2f56439 --- /dev/null +++ b/x/loan/types/message_request_loan_test.go @@ -0,0 +1,41 @@ +package types + +import ( + "testing" + + "loan/testutil/sample" + + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/stretchr/testify/require" +) + +func TestMsgRequestLoan_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgRequestLoan + err error + }{ + { + name: "invalid address", + msg: MsgRequestLoan{ + Creator: "invalid_address", + }, + err: sdkerrors.ErrInvalidAddress, + }, { + name: "valid address", + msg: MsgRequestLoan{ + Creator: sample.AccAddress(), + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} diff --git a/x/loan/types/tx.pb.go b/x/loan/types/tx.pb.go index 997c361..3ebcad6 100644 --- a/x/loan/types/tx.pb.go +++ b/x/loan/types/tx.pb.go @@ -36,8 +36,6 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type MsgUpdateParams struct { // authority is the address that controls the module (defaults to x/gov unless overwritten). Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` - // params defines the module parameters to update. - // // NOTE: All parameters must be supplied. Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` } @@ -127,35 +125,157 @@ func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo +type MsgRequestLoan struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + Amount string `protobuf:"bytes,2,opt,name=amount,proto3" json:"amount,omitempty"` + Fee string `protobuf:"bytes,3,opt,name=fee,proto3" json:"fee,omitempty"` + Collateral string `protobuf:"bytes,4,opt,name=collateral,proto3" json:"collateral,omitempty"` + Deadline string `protobuf:"bytes,5,opt,name=deadline,proto3" json:"deadline,omitempty"` +} + +func (m *MsgRequestLoan) Reset() { *m = MsgRequestLoan{} } +func (m *MsgRequestLoan) String() string { return proto.CompactTextString(m) } +func (*MsgRequestLoan) ProtoMessage() {} +func (*MsgRequestLoan) Descriptor() ([]byte, []int) { + return fileDescriptor_a914cc78de7d0204, []int{2} +} +func (m *MsgRequestLoan) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRequestLoan) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRequestLoan.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 *MsgRequestLoan) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRequestLoan.Merge(m, src) +} +func (m *MsgRequestLoan) XXX_Size() int { + return m.Size() +} +func (m *MsgRequestLoan) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRequestLoan.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRequestLoan proto.InternalMessageInfo + +func (m *MsgRequestLoan) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgRequestLoan) GetAmount() string { + if m != nil { + return m.Amount + } + return "" +} + +func (m *MsgRequestLoan) GetFee() string { + if m != nil { + return m.Fee + } + return "" +} + +func (m *MsgRequestLoan) GetCollateral() string { + if m != nil { + return m.Collateral + } + return "" +} + +func (m *MsgRequestLoan) GetDeadline() string { + if m != nil { + return m.Deadline + } + return "" +} + +type MsgRequestLoanResponse struct { +} + +func (m *MsgRequestLoanResponse) Reset() { *m = MsgRequestLoanResponse{} } +func (m *MsgRequestLoanResponse) String() string { return proto.CompactTextString(m) } +func (*MsgRequestLoanResponse) ProtoMessage() {} +func (*MsgRequestLoanResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_a914cc78de7d0204, []int{3} +} +func (m *MsgRequestLoanResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRequestLoanResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRequestLoanResponse.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 *MsgRequestLoanResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRequestLoanResponse.Merge(m, src) +} +func (m *MsgRequestLoanResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgRequestLoanResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRequestLoanResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRequestLoanResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgUpdateParams)(nil), "loan.loan.MsgUpdateParams") proto.RegisterType((*MsgUpdateParamsResponse)(nil), "loan.loan.MsgUpdateParamsResponse") + proto.RegisterType((*MsgRequestLoan)(nil), "loan.loan.MsgRequestLoan") + proto.RegisterType((*MsgRequestLoanResponse)(nil), "loan.loan.MsgRequestLoanResponse") } func init() { proto.RegisterFile("loan/loan/tx.proto", fileDescriptor_a914cc78de7d0204) } var fileDescriptor_a914cc78de7d0204 = []byte{ - // 312 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xca, 0xc9, 0x4f, 0xcc, - 0xd3, 0x07, 0x13, 0x25, 0x15, 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, 0x42, 0x9c, 0x20, 0xae, 0x1e, - 0x88, 0x90, 0x12, 0x4c, 0xcc, 0xcd, 0xcc, 0xcb, 0xd7, 0x07, 0x93, 0x10, 0x59, 0x29, 0xf1, 0xe4, - 0xfc, 0xe2, 0xdc, 0xfc, 0x62, 0xfd, 0xdc, 0xe2, 0x74, 0xfd, 0x32, 0x43, 0x10, 0x05, 0x95, 0x90, - 0x84, 0x48, 0xc4, 0x83, 0x79, 0xfa, 0x10, 0x0e, 0x54, 0x4a, 0x24, 0x3d, 0x3f, 0x3d, 0x1f, 0x22, - 0x0e, 0x62, 0x41, 0x45, 0xc5, 0x10, 0x76, 0x17, 0x24, 0x16, 0x25, 0xe6, 0x42, 0x55, 0x2b, 0xad, - 0x67, 0xe4, 0xe2, 0xf7, 0x2d, 0x4e, 0x0f, 0x2d, 0x48, 0x49, 0x2c, 0x49, 0x0d, 0x00, 0xcb, 0x08, - 0x99, 0x71, 0x71, 0x26, 0x96, 0x96, 0x64, 0xe4, 0x17, 0x65, 0x96, 0x54, 0x4a, 0x30, 0x2a, 0x30, - 0x6a, 0x70, 0x3a, 0x49, 0x5c, 0xda, 0xa2, 0x2b, 0x02, 0xb5, 0xc6, 0x31, 0x25, 0xa5, 0x28, 0xb5, - 0xb8, 0x38, 0xb8, 0xa4, 0x28, 0x33, 0x2f, 0x3d, 0x08, 0xa1, 0x54, 0xc8, 0x84, 0x8b, 0x0d, 0x62, - 0xb6, 0x04, 0x93, 0x02, 0xa3, 0x06, 0xb7, 0x91, 0xa0, 0x1e, 0xdc, 0x73, 0x7a, 0x10, 0xa3, 0x9d, - 0x38, 0x4f, 0xdc, 0x93, 0x67, 0x58, 0xf1, 0x7c, 0x83, 0x16, 0x63, 0x10, 0x54, 0xad, 0x95, 0x5e, - 0xd3, 0xf3, 0x0d, 0x5a, 0x08, 0x53, 0xba, 0x9e, 0x6f, 0xd0, 0x92, 0x06, 0xbb, 0xb3, 0x02, 0xe2, - 0x5c, 0x34, 0xd7, 0x29, 0x49, 0x72, 0x89, 0xa3, 0x09, 0x05, 0xa5, 0x16, 0x17, 0xe4, 0xe7, 0x15, - 0xa7, 0x1a, 0xc5, 0x70, 0x31, 0xfb, 0x16, 0xa7, 0x0b, 0xf9, 0x71, 0xf1, 0xa0, 0xf8, 0x47, 0x0a, - 0xc9, 0x1d, 0x68, 0x5a, 0xa5, 0x94, 0x70, 0xcb, 0xc1, 0x8c, 0x95, 0x62, 0x6d, 0x00, 0x39, 0xd8, - 0x49, 0xfb, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, - 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x04, 0x91, 0xdd, 0x5b, - 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x0e, 0x5e, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, - 0x14, 0x91, 0xb0, 0x5e, 0xf4, 0x01, 0x00, 0x00, + // 440 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x52, 0x31, 0x8f, 0xd3, 0x30, + 0x14, 0x8e, 0x29, 0x57, 0xc8, 0xbb, 0x13, 0x50, 0xeb, 0xd4, 0x73, 0x83, 0x14, 0x8e, 0x4c, 0xa7, + 0x22, 0x12, 0x71, 0x20, 0x86, 0xdb, 0xe8, 0x0a, 0x45, 0x28, 0x88, 0x85, 0x05, 0x99, 0xc6, 0x84, + 0x48, 0x49, 0x1c, 0x6c, 0x17, 0x5d, 0x37, 0xc4, 0xc8, 0xc4, 0x2f, 0x60, 0x86, 0x89, 0x0e, 0xfc, + 0x88, 0x8e, 0x15, 0x13, 0x13, 0x42, 0xed, 0xd0, 0xbf, 0x81, 0x62, 0x27, 0x6d, 0x5a, 0xa9, 0xcb, + 0x8b, 0xbf, 0xf7, 0xbd, 0x7c, 0xef, 0x7b, 0x7e, 0x06, 0x9c, 0x72, 0x9a, 0x07, 0x3a, 0xa8, 0x4b, + 0xbf, 0x10, 0x5c, 0x71, 0x6c, 0x97, 0xd0, 0x2f, 0x83, 0xd3, 0xa1, 0x59, 0x92, 0xf3, 0x40, 0x47, + 0xc3, 0x3a, 0x27, 0x23, 0x2e, 0x33, 0x2e, 0x83, 0x4c, 0xc6, 0xc1, 0xc7, 0x07, 0xe5, 0xa7, 0x22, + 0x7a, 0x86, 0x78, 0xa3, 0x51, 0x60, 0x40, 0x45, 0x1d, 0xc7, 0x3c, 0xe6, 0x26, 0x5f, 0x9e, 0xaa, + 0x6c, 0x77, 0xd3, 0xbb, 0xa0, 0x82, 0x66, 0x55, 0xb5, 0xf7, 0x13, 0xc1, 0xcd, 0xa1, 0x8c, 0x5f, + 0x15, 0x11, 0x55, 0xec, 0x85, 0x66, 0xf0, 0x63, 0xb0, 0xe9, 0x58, 0xbd, 0xe7, 0x22, 0x51, 0x13, + 0x82, 0x4e, 0xd1, 0x99, 0x3d, 0x20, 0xbf, 0x7f, 0xdd, 0x3f, 0xae, 0xda, 0x3c, 0x89, 0x22, 0xc1, + 0xa4, 0x7c, 0xa9, 0x44, 0x92, 0xc7, 0xe1, 0xa6, 0x14, 0x3f, 0x82, 0xb6, 0xd1, 0x26, 0x57, 0x4e, + 0xd1, 0xd9, 0xe1, 0x79, 0xc7, 0x5f, 0x0f, 0xe7, 0x1b, 0xe9, 0x81, 0x3d, 0xfb, 0x7b, 0xc7, 0xfa, + 0xbe, 0x9a, 0xf6, 0x51, 0x58, 0xd5, 0x5e, 0xf8, 0x9f, 0x57, 0xd3, 0xfe, 0x46, 0xe5, 0xcb, 0x6a, + 0xda, 0xbf, 0xad, 0x7d, 0x5e, 0x1a, 0xbb, 0x3b, 0xee, 0xbc, 0x1e, 0x9c, 0xec, 0xa4, 0x42, 0x26, + 0x0b, 0x9e, 0x4b, 0xe6, 0x7d, 0x43, 0x70, 0x63, 0x28, 0xe3, 0x90, 0x7d, 0x18, 0x33, 0xa9, 0x9e, + 0x71, 0x9a, 0x63, 0x02, 0xd7, 0x46, 0x82, 0x51, 0xc5, 0x85, 0x99, 0x24, 0xac, 0x21, 0xee, 0x42, + 0x9b, 0x66, 0x7c, 0x9c, 0x2b, 0xed, 0xd6, 0x0e, 0x2b, 0x84, 0x6f, 0x41, 0xeb, 0x1d, 0x63, 0xa4, + 0xa5, 0x93, 0xe5, 0x11, 0xbb, 0x00, 0x23, 0x9e, 0xa6, 0x54, 0x31, 0x41, 0x53, 0x72, 0x55, 0x13, + 0x8d, 0x0c, 0x76, 0xe0, 0x7a, 0xc4, 0x68, 0x94, 0x26, 0x39, 0x23, 0x07, 0x9a, 0x5d, 0xe3, 0x8b, + 0xa3, 0x72, 0xba, 0xba, 0xa7, 0x47, 0xa0, 0xbb, 0xed, 0xaf, 0xb6, 0x7e, 0xfe, 0x03, 0x41, 0x6b, + 0x28, 0x63, 0xfc, 0x1c, 0x8e, 0xb6, 0x76, 0xe1, 0x34, 0xee, 0x70, 0x67, 0x6c, 0xc7, 0xdb, 0xcf, + 0xd5, 0xba, 0xf8, 0x29, 0x1c, 0x36, 0xaf, 0xa3, 0xb7, 0xfd, 0x4b, 0x83, 0x72, 0xee, 0xee, 0xa5, + 0x6a, 0x31, 0xe7, 0xe0, 0x53, 0xb9, 0xb9, 0xc1, 0xbd, 0xd9, 0xc2, 0x45, 0xf3, 0x85, 0x8b, 0xfe, + 0x2d, 0x5c, 0xf4, 0x75, 0xe9, 0x5a, 0xf3, 0xa5, 0x6b, 0xfd, 0x59, 0xba, 0xd6, 0xeb, 0x4e, 0x73, + 0x71, 0x6a, 0x52, 0x30, 0xf9, 0xb6, 0xad, 0xdf, 0xd9, 0xc3, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, + 0xf8, 0x1c, 0x39, 0x55, 0xfd, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -173,6 +293,7 @@ type MsgClient interface { // UpdateParams defines a (governance) operation for updating the module // parameters. The authority defaults to the x/gov module account. UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) + RequestLoan(ctx context.Context, in *MsgRequestLoan, opts ...grpc.CallOption) (*MsgRequestLoanResponse, error) } type msgClient struct { @@ -192,11 +313,21 @@ func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts return out, nil } +func (c *msgClient) RequestLoan(ctx context.Context, in *MsgRequestLoan, opts ...grpc.CallOption) (*MsgRequestLoanResponse, error) { + out := new(MsgRequestLoanResponse) + err := c.cc.Invoke(ctx, "/loan.loan.Msg/RequestLoan", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { // UpdateParams defines a (governance) operation for updating the module // parameters. The authority defaults to the x/gov module account. UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) + RequestLoan(context.Context, *MsgRequestLoan) (*MsgRequestLoanResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -206,6 +337,9 @@ type UnimplementedMsgServer struct { func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") } +func (*UnimplementedMsgServer) RequestLoan(ctx context.Context, req *MsgRequestLoan) (*MsgRequestLoanResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RequestLoan not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -229,6 +363,24 @@ func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(in return interceptor(ctx, in, info, handler) } +func _Msg_RequestLoan_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRequestLoan) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).RequestLoan(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/loan.loan.Msg/RequestLoan", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).RequestLoan(ctx, req.(*MsgRequestLoan)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "loan.loan.Msg", HandlerType: (*MsgServer)(nil), @@ -237,6 +389,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "UpdateParams", Handler: _Msg_UpdateParams_Handler, }, + { + MethodName: "RequestLoan", + Handler: _Msg_RequestLoan_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "loan/loan/tx.proto", @@ -305,6 +461,87 @@ func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } +func (m *MsgRequestLoan) 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 *MsgRequestLoan) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRequestLoan) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Deadline) > 0 { + i -= len(m.Deadline) + copy(dAtA[i:], m.Deadline) + i = encodeVarintTx(dAtA, i, uint64(len(m.Deadline))) + i-- + dAtA[i] = 0x2a + } + if len(m.Collateral) > 0 { + i -= len(m.Collateral) + copy(dAtA[i:], m.Collateral) + i = encodeVarintTx(dAtA, i, uint64(len(m.Collateral))) + i-- + dAtA[i] = 0x22 + } + if len(m.Fee) > 0 { + i -= len(m.Fee) + copy(dAtA[i:], m.Fee) + i = encodeVarintTx(dAtA, i, uint64(len(m.Fee))) + i-- + dAtA[i] = 0x1a + } + if len(m.Amount) > 0 { + i -= len(m.Amount) + copy(dAtA[i:], m.Amount) + i = encodeVarintTx(dAtA, i, uint64(len(m.Amount))) + i-- + dAtA[i] = 0x12 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgRequestLoanResponse) 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 *MsgRequestLoanResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRequestLoanResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -340,6 +577,44 @@ func (m *MsgUpdateParamsResponse) Size() (n int) { return n } +func (m *MsgRequestLoan) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Amount) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Fee) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Collateral) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Deadline) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgRequestLoanResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -511,6 +786,266 @@ func (m *MsgUpdateParamsResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgRequestLoan) 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 ErrIntOverflowTx + } + 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: MsgRequestLoan: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRequestLoan: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Amount = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Fee", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Fee = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Collateral", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Collateral = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Deadline", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Deadline = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgRequestLoanResponse) 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 ErrIntOverflowTx + } + 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: MsgRequestLoanResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRequestLoanResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0