From 211849b23f235726de84faa07d74e83d92665dd4 Mon Sep 17 00:00:00 2001 From: Redouane Lakrache Date: Tue, 20 Feb 2024 10:11:22 +0100 Subject: [PATCH] chore: service module review improvements --- api/poktroll/service/params.pulsar.go | 3 + api/poktroll/service/query.pulsar.go | 541 +++++++++--------- api/poktroll/service/tx.pulsar.go | 1 + api/poktroll/shared/service.pulsar.go | 4 +- proto/poktroll/service/genesis.proto | 5 +- proto/poktroll/service/params.proto | 7 +- proto/poktroll/service/query.proto | 17 +- proto/poktroll/service/tx.proto | 18 +- proto/poktroll/shared/service.proto | 4 +- testutil/keeper/service.go | 48 +- x/service/keeper/msg_server.go | 4 +- x/service/keeper/msg_server_add_service.go | 10 +- .../keeper/msg_server_add_service_test.go | 113 ++-- x/service/keeper/msg_server_test.go | 4 + x/service/keeper/msg_update_params.go | 8 +- x/service/keeper/msg_update_params_test.go | 36 +- x/service/keeper/params.go | 10 +- x/service/keeper/query.go | 4 +- x/service/keeper/query_params.go | 4 +- x/service/keeper/query_service.go | 16 +- x/service/keeper/query_service_test.go | 48 +- x/service/keeper/service.go | 12 +- x/service/keeper/service_test.go | 23 +- x/service/module/autocli.go | 81 +-- x/service/module/genesis.go | 10 +- x/service/module/module.go | 6 +- x/service/module/tx.go | 11 +- x/service/module/tx_add_service.go | 5 +- x/service/module/tx_add_service_test.go | 30 +- x/service/simulation/add_service.go | 1 + x/service/types/errors.go | 24 +- x/service/types/expected_keepers.go | 7 +- x/service/types/genesis.go | 23 +- x/service/types/genesis_test.go | 36 +- x/service/types/key_service.go | 2 +- x/service/types/keys.go | 8 +- x/service/types/message_add_service.go | 4 +- x/service/types/message_add_service_test.go | 14 +- ...ate_params.go => message_update_params.go} | 0 x/service/types/params.go | 8 +- x/service/types/types.go | 2 + 41 files changed, 590 insertions(+), 622 deletions(-) rename x/service/types/{msg_update_params.go => message_update_params.go} (100%) diff --git a/api/poktroll/service/params.pulsar.go b/api/poktroll/service/params.pulsar.go index d85bbf213..346acdd52 100644 --- a/api/poktroll/service/params.pulsar.go +++ b/api/poktroll/service/params.pulsar.go @@ -437,6 +437,9 @@ type Params struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + // The amount of uPOKT required to add a new service. + // This will be deducted from the signer's account balance, + // and transferred to the pocket network foundation. AddServiceFee uint64 `protobuf:"varint,1,opt,name=add_service_fee,json=addServiceFee,proto3" json:"add_service_fee,omitempty"` } diff --git a/api/poktroll/service/query.pulsar.go b/api/poktroll/service/query.pulsar.go index 1b1039159..2f313aef1 100644 --- a/api/poktroll/service/query.pulsar.go +++ b/api/poktroll/service/query.pulsar.go @@ -809,14 +809,14 @@ func (x *fastReflection_QueryParamsResponse) ProtoMethods() *protoiface.Methods } var ( - md_QueryGetServiceRequest protoreflect.MessageDescriptor - fd_QueryGetServiceRequest_index protoreflect.FieldDescriptor + md_QueryGetServiceRequest protoreflect.MessageDescriptor + fd_QueryGetServiceRequest_id protoreflect.FieldDescriptor ) func init() { file_poktroll_service_query_proto_init() md_QueryGetServiceRequest = File_poktroll_service_query_proto.Messages().ByName("QueryGetServiceRequest") - fd_QueryGetServiceRequest_index = md_QueryGetServiceRequest.Fields().ByName("index") + fd_QueryGetServiceRequest_id = md_QueryGetServiceRequest.Fields().ByName("id") } var _ protoreflect.Message = (*fastReflection_QueryGetServiceRequest)(nil) @@ -884,9 +884,9 @@ func (x *fastReflection_QueryGetServiceRequest) Interface() protoreflect.ProtoMe // While iterating, mutating operations may only be performed // on the current field descriptor. func (x *fastReflection_QueryGetServiceRequest) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { - if x.Index != "" { - value := protoreflect.ValueOfString(x.Index) - if !f(fd_QueryGetServiceRequest_index, value) { + if x.Id != "" { + value := protoreflect.ValueOfString(x.Id) + if !f(fd_QueryGetServiceRequest_id, value) { return } } @@ -905,8 +905,8 @@ func (x *fastReflection_QueryGetServiceRequest) Range(f func(protoreflect.FieldD // a repeated field is populated if it is non-empty. func (x *fastReflection_QueryGetServiceRequest) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { - case "poktroll.service.QueryGetServiceRequest.index": - return x.Index != "" + case "poktroll.service.QueryGetServiceRequest.id": + return x.Id != "" default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.service.QueryGetServiceRequest")) @@ -923,8 +923,8 @@ func (x *fastReflection_QueryGetServiceRequest) Has(fd protoreflect.FieldDescrip // Clear is a mutating operation and unsafe for concurrent use. func (x *fastReflection_QueryGetServiceRequest) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { - case "poktroll.service.QueryGetServiceRequest.index": - x.Index = "" + case "poktroll.service.QueryGetServiceRequest.id": + x.Id = "" default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.service.QueryGetServiceRequest")) @@ -941,8 +941,8 @@ func (x *fastReflection_QueryGetServiceRequest) Clear(fd protoreflect.FieldDescr // of the value; to obtain a mutable reference, use Mutable. func (x *fastReflection_QueryGetServiceRequest) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { switch descriptor.FullName() { - case "poktroll.service.QueryGetServiceRequest.index": - value := x.Index + case "poktroll.service.QueryGetServiceRequest.id": + value := x.Id return protoreflect.ValueOfString(value) default: if descriptor.IsExtension() { @@ -964,8 +964,8 @@ func (x *fastReflection_QueryGetServiceRequest) Get(descriptor protoreflect.Fiel // Set is a mutating operation and unsafe for concurrent use. func (x *fastReflection_QueryGetServiceRequest) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { switch fd.FullName() { - case "poktroll.service.QueryGetServiceRequest.index": - x.Index = value.Interface().(string) + case "poktroll.service.QueryGetServiceRequest.id": + x.Id = value.Interface().(string) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.service.QueryGetServiceRequest")) @@ -986,8 +986,8 @@ func (x *fastReflection_QueryGetServiceRequest) Set(fd protoreflect.FieldDescrip // Mutable is a mutating operation and unsafe for concurrent use. func (x *fastReflection_QueryGetServiceRequest) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "poktroll.service.QueryGetServiceRequest.index": - panic(fmt.Errorf("field index of message poktroll.service.QueryGetServiceRequest is not mutable")) + case "poktroll.service.QueryGetServiceRequest.id": + panic(fmt.Errorf("field id of message poktroll.service.QueryGetServiceRequest is not mutable")) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.service.QueryGetServiceRequest")) @@ -1001,7 +1001,7 @@ func (x *fastReflection_QueryGetServiceRequest) Mutable(fd protoreflect.FieldDes // For lists, maps, and messages, this returns a new, empty, mutable value. func (x *fastReflection_QueryGetServiceRequest) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "poktroll.service.QueryGetServiceRequest.index": + case "poktroll.service.QueryGetServiceRequest.id": return protoreflect.ValueOfString("") default: if fd.IsExtension() { @@ -1072,7 +1072,7 @@ func (x *fastReflection_QueryGetServiceRequest) ProtoMethods() *protoiface.Metho var n int var l int _ = l - l = len(x.Index) + l = len(x.Id) if l > 0 { n += 1 + l + runtime.Sov(uint64(l)) } @@ -1105,10 +1105,10 @@ func (x *fastReflection_QueryGetServiceRequest) ProtoMethods() *protoiface.Metho i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } - if len(x.Index) > 0 { - i -= len(x.Index) - copy(dAtA[i:], x.Index) - i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Index))) + if len(x.Id) > 0 { + i -= len(x.Id) + copy(dAtA[i:], x.Id) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Id))) i-- dAtA[i] = 0xa } @@ -1163,7 +1163,7 @@ func (x *fastReflection_QueryGetServiceRequest) ProtoMethods() *protoiface.Metho switch fieldNum { case 1: if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Index", wireType) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1191,7 +1191,7 @@ func (x *fastReflection_QueryGetServiceRequest) ProtoMethods() *protoiface.Metho if postIndex > l { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF } - x.Index = string(dAtA[iNdEx:postIndex]) + x.Id = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -1664,25 +1664,25 @@ func (x *fastReflection_QueryGetServiceResponse) ProtoMethods() *protoiface.Meth } var ( - md_QueryAllServiceRequest protoreflect.MessageDescriptor - fd_QueryAllServiceRequest_pagination protoreflect.FieldDescriptor + md_QueryAllServicesRequest protoreflect.MessageDescriptor + fd_QueryAllServicesRequest_pagination protoreflect.FieldDescriptor ) func init() { file_poktroll_service_query_proto_init() - md_QueryAllServiceRequest = File_poktroll_service_query_proto.Messages().ByName("QueryAllServiceRequest") - fd_QueryAllServiceRequest_pagination = md_QueryAllServiceRequest.Fields().ByName("pagination") + md_QueryAllServicesRequest = File_poktroll_service_query_proto.Messages().ByName("QueryAllServicesRequest") + fd_QueryAllServicesRequest_pagination = md_QueryAllServicesRequest.Fields().ByName("pagination") } -var _ protoreflect.Message = (*fastReflection_QueryAllServiceRequest)(nil) +var _ protoreflect.Message = (*fastReflection_QueryAllServicesRequest)(nil) -type fastReflection_QueryAllServiceRequest QueryAllServiceRequest +type fastReflection_QueryAllServicesRequest QueryAllServicesRequest -func (x *QueryAllServiceRequest) ProtoReflect() protoreflect.Message { - return (*fastReflection_QueryAllServiceRequest)(x) +func (x *QueryAllServicesRequest) ProtoReflect() protoreflect.Message { + return (*fastReflection_QueryAllServicesRequest)(x) } -func (x *QueryAllServiceRequest) slowProtoReflect() protoreflect.Message { +func (x *QueryAllServicesRequest) slowProtoReflect() protoreflect.Message { mi := &file_poktroll_service_query_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -1694,43 +1694,43 @@ func (x *QueryAllServiceRequest) slowProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -var _fastReflection_QueryAllServiceRequest_messageType fastReflection_QueryAllServiceRequest_messageType -var _ protoreflect.MessageType = fastReflection_QueryAllServiceRequest_messageType{} +var _fastReflection_QueryAllServicesRequest_messageType fastReflection_QueryAllServicesRequest_messageType +var _ protoreflect.MessageType = fastReflection_QueryAllServicesRequest_messageType{} -type fastReflection_QueryAllServiceRequest_messageType struct{} +type fastReflection_QueryAllServicesRequest_messageType struct{} -func (x fastReflection_QueryAllServiceRequest_messageType) Zero() protoreflect.Message { - return (*fastReflection_QueryAllServiceRequest)(nil) +func (x fastReflection_QueryAllServicesRequest_messageType) Zero() protoreflect.Message { + return (*fastReflection_QueryAllServicesRequest)(nil) } -func (x fastReflection_QueryAllServiceRequest_messageType) New() protoreflect.Message { - return new(fastReflection_QueryAllServiceRequest) +func (x fastReflection_QueryAllServicesRequest_messageType) New() protoreflect.Message { + return new(fastReflection_QueryAllServicesRequest) } -func (x fastReflection_QueryAllServiceRequest_messageType) Descriptor() protoreflect.MessageDescriptor { - return md_QueryAllServiceRequest +func (x fastReflection_QueryAllServicesRequest_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_QueryAllServicesRequest } // Descriptor returns message descriptor, which contains only the protobuf // type information for the message. -func (x *fastReflection_QueryAllServiceRequest) Descriptor() protoreflect.MessageDescriptor { - return md_QueryAllServiceRequest +func (x *fastReflection_QueryAllServicesRequest) Descriptor() protoreflect.MessageDescriptor { + return md_QueryAllServicesRequest } // 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_QueryAllServiceRequest) Type() protoreflect.MessageType { - return _fastReflection_QueryAllServiceRequest_messageType +func (x *fastReflection_QueryAllServicesRequest) Type() protoreflect.MessageType { + return _fastReflection_QueryAllServicesRequest_messageType } // New returns a newly allocated and mutable empty message. -func (x *fastReflection_QueryAllServiceRequest) New() protoreflect.Message { - return new(fastReflection_QueryAllServiceRequest) +func (x *fastReflection_QueryAllServicesRequest) New() protoreflect.Message { + return new(fastReflection_QueryAllServicesRequest) } // Interface unwraps the message reflection interface and // returns the underlying ProtoMessage interface. -func (x *fastReflection_QueryAllServiceRequest) Interface() protoreflect.ProtoMessage { - return (*QueryAllServiceRequest)(x) +func (x *fastReflection_QueryAllServicesRequest) Interface() protoreflect.ProtoMessage { + return (*QueryAllServicesRequest)(x) } // Range iterates over every populated field in an undefined order, @@ -1738,10 +1738,10 @@ func (x *fastReflection_QueryAllServiceRequest) Interface() protoreflect.ProtoMe // Range returns immediately if f returns false. // While iterating, mutating operations may only be performed // on the current field descriptor. -func (x *fastReflection_QueryAllServiceRequest) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { +func (x *fastReflection_QueryAllServicesRequest) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { if x.Pagination != nil { value := protoreflect.ValueOfMessage(x.Pagination.ProtoReflect()) - if !f(fd_QueryAllServiceRequest_pagination, value) { + if !f(fd_QueryAllServicesRequest_pagination, value) { return } } @@ -1758,15 +1758,15 @@ func (x *fastReflection_QueryAllServiceRequest) Range(f func(protoreflect.FieldD // 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_QueryAllServiceRequest) Has(fd protoreflect.FieldDescriptor) bool { +func (x *fastReflection_QueryAllServicesRequest) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { - case "poktroll.service.QueryAllServiceRequest.pagination": + case "poktroll.service.QueryAllServicesRequest.pagination": return x.Pagination != nil default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.service.QueryAllServiceRequest")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.service.QueryAllServicesRequest")) } - panic(fmt.Errorf("message poktroll.service.QueryAllServiceRequest does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.service.QueryAllServicesRequest does not contain field %s", fd.FullName())) } } @@ -1776,15 +1776,15 @@ func (x *fastReflection_QueryAllServiceRequest) Has(fd protoreflect.FieldDescrip // associated with the given field number. // // Clear is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_QueryAllServiceRequest) Clear(fd protoreflect.FieldDescriptor) { +func (x *fastReflection_QueryAllServicesRequest) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { - case "poktroll.service.QueryAllServiceRequest.pagination": + case "poktroll.service.QueryAllServicesRequest.pagination": x.Pagination = nil default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.service.QueryAllServiceRequest")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.service.QueryAllServicesRequest")) } - panic(fmt.Errorf("message poktroll.service.QueryAllServiceRequest does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.service.QueryAllServicesRequest does not contain field %s", fd.FullName())) } } @@ -1794,16 +1794,16 @@ func (x *fastReflection_QueryAllServiceRequest) Clear(fd protoreflect.FieldDescr // 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_QueryAllServiceRequest) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { +func (x *fastReflection_QueryAllServicesRequest) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { switch descriptor.FullName() { - case "poktroll.service.QueryAllServiceRequest.pagination": + case "poktroll.service.QueryAllServicesRequest.pagination": value := x.Pagination return protoreflect.ValueOfMessage(value.ProtoReflect()) default: if descriptor.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.service.QueryAllServiceRequest")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.service.QueryAllServicesRequest")) } - panic(fmt.Errorf("message poktroll.service.QueryAllServiceRequest does not contain field %s", descriptor.FullName())) + panic(fmt.Errorf("message poktroll.service.QueryAllServicesRequest does not contain field %s", descriptor.FullName())) } } @@ -1817,15 +1817,15 @@ func (x *fastReflection_QueryAllServiceRequest) Get(descriptor protoreflect.Fiel // empty, read-only value, then it panics. // // Set is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_QueryAllServiceRequest) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { +func (x *fastReflection_QueryAllServicesRequest) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { switch fd.FullName() { - case "poktroll.service.QueryAllServiceRequest.pagination": + case "poktroll.service.QueryAllServicesRequest.pagination": x.Pagination = value.Message().Interface().(*v1beta1.PageRequest) default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.service.QueryAllServiceRequest")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.service.QueryAllServicesRequest")) } - panic(fmt.Errorf("message poktroll.service.QueryAllServiceRequest does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.service.QueryAllServicesRequest does not contain field %s", fd.FullName())) } } @@ -1839,44 +1839,44 @@ func (x *fastReflection_QueryAllServiceRequest) Set(fd protoreflect.FieldDescrip // It panics if the field does not contain a composite type. // // Mutable is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_QueryAllServiceRequest) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { +func (x *fastReflection_QueryAllServicesRequest) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "poktroll.service.QueryAllServiceRequest.pagination": + case "poktroll.service.QueryAllServicesRequest.pagination": if x.Pagination == nil { x.Pagination = new(v1beta1.PageRequest) } return protoreflect.ValueOfMessage(x.Pagination.ProtoReflect()) default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.service.QueryAllServiceRequest")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.service.QueryAllServicesRequest")) } - panic(fmt.Errorf("message poktroll.service.QueryAllServiceRequest does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.service.QueryAllServicesRequest 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_QueryAllServiceRequest) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { +func (x *fastReflection_QueryAllServicesRequest) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "poktroll.service.QueryAllServiceRequest.pagination": + case "poktroll.service.QueryAllServicesRequest.pagination": m := new(v1beta1.PageRequest) return protoreflect.ValueOfMessage(m.ProtoReflect()) default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.service.QueryAllServiceRequest")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.service.QueryAllServicesRequest")) } - panic(fmt.Errorf("message poktroll.service.QueryAllServiceRequest does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.service.QueryAllServicesRequest 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_QueryAllServiceRequest) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { +func (x *fastReflection_QueryAllServicesRequest) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { switch d.FullName() { default: - panic(fmt.Errorf("%s is not a oneof field in poktroll.service.QueryAllServiceRequest", d.FullName())) + panic(fmt.Errorf("%s is not a oneof field in poktroll.service.QueryAllServicesRequest", d.FullName())) } panic("unreachable") } @@ -1884,7 +1884,7 @@ func (x *fastReflection_QueryAllServiceRequest) WhichOneof(d protoreflect.OneofD // 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_QueryAllServiceRequest) GetUnknown() protoreflect.RawFields { +func (x *fastReflection_QueryAllServicesRequest) GetUnknown() protoreflect.RawFields { return x.unknownFields } @@ -1895,7 +1895,7 @@ func (x *fastReflection_QueryAllServiceRequest) GetUnknown() protoreflect.RawFie // An empty RawFields may be passed to clear the fields. // // SetUnknown is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_QueryAllServiceRequest) SetUnknown(fields protoreflect.RawFields) { +func (x *fastReflection_QueryAllServicesRequest) SetUnknown(fields protoreflect.RawFields) { x.unknownFields = fields } @@ -1907,7 +1907,7 @@ func (x *fastReflection_QueryAllServiceRequest) SetUnknown(fields protoreflect.R // 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_QueryAllServiceRequest) IsValid() bool { +func (x *fastReflection_QueryAllServicesRequest) IsValid() bool { return x != nil } @@ -1917,9 +1917,9 @@ func (x *fastReflection_QueryAllServiceRequest) IsValid() bool { // The returned methods type is identical to // "google.golang.org/protobuf/runtime/protoiface".Methods. // Consult the protoiface package documentation for details. -func (x *fastReflection_QueryAllServiceRequest) ProtoMethods() *protoiface.Methods { +func (x *fastReflection_QueryAllServicesRequest) ProtoMethods() *protoiface.Methods { size := func(input protoiface.SizeInput) protoiface.SizeOutput { - x := input.Message.Interface().(*QueryAllServiceRequest) + x := input.Message.Interface().(*QueryAllServicesRequest) if x == nil { return protoiface.SizeOutput{ NoUnkeyedLiterals: input.NoUnkeyedLiterals, @@ -1945,7 +1945,7 @@ func (x *fastReflection_QueryAllServiceRequest) ProtoMethods() *protoiface.Metho } marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { - x := input.Message.Interface().(*QueryAllServiceRequest) + x := input.Message.Interface().(*QueryAllServicesRequest) if x == nil { return protoiface.MarshalOutput{ NoUnkeyedLiterals: input.NoUnkeyedLiterals, @@ -1989,7 +1989,7 @@ func (x *fastReflection_QueryAllServiceRequest) ProtoMethods() *protoiface.Metho }, nil } unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { - x := input.Message.Interface().(*QueryAllServiceRequest) + x := input.Message.Interface().(*QueryAllServicesRequest) if x == nil { return protoiface.UnmarshalOutput{ NoUnkeyedLiterals: input.NoUnkeyedLiterals, @@ -2021,10 +2021,10 @@ func (x *fastReflection_QueryAllServiceRequest) ProtoMethods() *protoiface.Metho fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: QueryAllServiceRequest: wiretype end group for non-group") + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: QueryAllServicesRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: QueryAllServiceRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: QueryAllServicesRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -2098,79 +2098,79 @@ func (x *fastReflection_QueryAllServiceRequest) ProtoMethods() *protoiface.Metho } } -var _ protoreflect.List = (*_QueryAllServiceResponse_1_list)(nil) +var _ protoreflect.List = (*_QueryAllServicesResponse_1_list)(nil) -type _QueryAllServiceResponse_1_list struct { +type _QueryAllServicesResponse_1_list struct { list *[]*shared.Service } -func (x *_QueryAllServiceResponse_1_list) Len() int { +func (x *_QueryAllServicesResponse_1_list) Len() int { if x.list == nil { return 0 } return len(*x.list) } -func (x *_QueryAllServiceResponse_1_list) Get(i int) protoreflect.Value { +func (x *_QueryAllServicesResponse_1_list) Get(i int) protoreflect.Value { return protoreflect.ValueOfMessage((*x.list)[i].ProtoReflect()) } -func (x *_QueryAllServiceResponse_1_list) Set(i int, value protoreflect.Value) { +func (x *_QueryAllServicesResponse_1_list) Set(i int, value protoreflect.Value) { valueUnwrapped := value.Message() concreteValue := valueUnwrapped.Interface().(*shared.Service) (*x.list)[i] = concreteValue } -func (x *_QueryAllServiceResponse_1_list) Append(value protoreflect.Value) { +func (x *_QueryAllServicesResponse_1_list) Append(value protoreflect.Value) { valueUnwrapped := value.Message() concreteValue := valueUnwrapped.Interface().(*shared.Service) *x.list = append(*x.list, concreteValue) } -func (x *_QueryAllServiceResponse_1_list) AppendMutable() protoreflect.Value { +func (x *_QueryAllServicesResponse_1_list) AppendMutable() protoreflect.Value { v := new(shared.Service) *x.list = append(*x.list, v) return protoreflect.ValueOfMessage(v.ProtoReflect()) } -func (x *_QueryAllServiceResponse_1_list) Truncate(n int) { +func (x *_QueryAllServicesResponse_1_list) Truncate(n int) { for i := n; i < len(*x.list); i++ { (*x.list)[i] = nil } *x.list = (*x.list)[:n] } -func (x *_QueryAllServiceResponse_1_list) NewElement() protoreflect.Value { +func (x *_QueryAllServicesResponse_1_list) NewElement() protoreflect.Value { v := new(shared.Service) return protoreflect.ValueOfMessage(v.ProtoReflect()) } -func (x *_QueryAllServiceResponse_1_list) IsValid() bool { +func (x *_QueryAllServicesResponse_1_list) IsValid() bool { return x.list != nil } var ( - md_QueryAllServiceResponse protoreflect.MessageDescriptor - fd_QueryAllServiceResponse_service protoreflect.FieldDescriptor - fd_QueryAllServiceResponse_pagination protoreflect.FieldDescriptor + md_QueryAllServicesResponse protoreflect.MessageDescriptor + fd_QueryAllServicesResponse_service protoreflect.FieldDescriptor + fd_QueryAllServicesResponse_pagination protoreflect.FieldDescriptor ) func init() { file_poktroll_service_query_proto_init() - md_QueryAllServiceResponse = File_poktroll_service_query_proto.Messages().ByName("QueryAllServiceResponse") - fd_QueryAllServiceResponse_service = md_QueryAllServiceResponse.Fields().ByName("service") - fd_QueryAllServiceResponse_pagination = md_QueryAllServiceResponse.Fields().ByName("pagination") + md_QueryAllServicesResponse = File_poktroll_service_query_proto.Messages().ByName("QueryAllServicesResponse") + fd_QueryAllServicesResponse_service = md_QueryAllServicesResponse.Fields().ByName("service") + fd_QueryAllServicesResponse_pagination = md_QueryAllServicesResponse.Fields().ByName("pagination") } -var _ protoreflect.Message = (*fastReflection_QueryAllServiceResponse)(nil) +var _ protoreflect.Message = (*fastReflection_QueryAllServicesResponse)(nil) -type fastReflection_QueryAllServiceResponse QueryAllServiceResponse +type fastReflection_QueryAllServicesResponse QueryAllServicesResponse -func (x *QueryAllServiceResponse) ProtoReflect() protoreflect.Message { - return (*fastReflection_QueryAllServiceResponse)(x) +func (x *QueryAllServicesResponse) ProtoReflect() protoreflect.Message { + return (*fastReflection_QueryAllServicesResponse)(x) } -func (x *QueryAllServiceResponse) slowProtoReflect() protoreflect.Message { +func (x *QueryAllServicesResponse) slowProtoReflect() protoreflect.Message { mi := &file_poktroll_service_query_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -2182,43 +2182,43 @@ func (x *QueryAllServiceResponse) slowProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -var _fastReflection_QueryAllServiceResponse_messageType fastReflection_QueryAllServiceResponse_messageType -var _ protoreflect.MessageType = fastReflection_QueryAllServiceResponse_messageType{} +var _fastReflection_QueryAllServicesResponse_messageType fastReflection_QueryAllServicesResponse_messageType +var _ protoreflect.MessageType = fastReflection_QueryAllServicesResponse_messageType{} -type fastReflection_QueryAllServiceResponse_messageType struct{} +type fastReflection_QueryAllServicesResponse_messageType struct{} -func (x fastReflection_QueryAllServiceResponse_messageType) Zero() protoreflect.Message { - return (*fastReflection_QueryAllServiceResponse)(nil) +func (x fastReflection_QueryAllServicesResponse_messageType) Zero() protoreflect.Message { + return (*fastReflection_QueryAllServicesResponse)(nil) } -func (x fastReflection_QueryAllServiceResponse_messageType) New() protoreflect.Message { - return new(fastReflection_QueryAllServiceResponse) +func (x fastReflection_QueryAllServicesResponse_messageType) New() protoreflect.Message { + return new(fastReflection_QueryAllServicesResponse) } -func (x fastReflection_QueryAllServiceResponse_messageType) Descriptor() protoreflect.MessageDescriptor { - return md_QueryAllServiceResponse +func (x fastReflection_QueryAllServicesResponse_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_QueryAllServicesResponse } // Descriptor returns message descriptor, which contains only the protobuf // type information for the message. -func (x *fastReflection_QueryAllServiceResponse) Descriptor() protoreflect.MessageDescriptor { - return md_QueryAllServiceResponse +func (x *fastReflection_QueryAllServicesResponse) Descriptor() protoreflect.MessageDescriptor { + return md_QueryAllServicesResponse } // 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_QueryAllServiceResponse) Type() protoreflect.MessageType { - return _fastReflection_QueryAllServiceResponse_messageType +func (x *fastReflection_QueryAllServicesResponse) Type() protoreflect.MessageType { + return _fastReflection_QueryAllServicesResponse_messageType } // New returns a newly allocated and mutable empty message. -func (x *fastReflection_QueryAllServiceResponse) New() protoreflect.Message { - return new(fastReflection_QueryAllServiceResponse) +func (x *fastReflection_QueryAllServicesResponse) New() protoreflect.Message { + return new(fastReflection_QueryAllServicesResponse) } // Interface unwraps the message reflection interface and // returns the underlying ProtoMessage interface. -func (x *fastReflection_QueryAllServiceResponse) Interface() protoreflect.ProtoMessage { - return (*QueryAllServiceResponse)(x) +func (x *fastReflection_QueryAllServicesResponse) Interface() protoreflect.ProtoMessage { + return (*QueryAllServicesResponse)(x) } // Range iterates over every populated field in an undefined order, @@ -2226,16 +2226,16 @@ func (x *fastReflection_QueryAllServiceResponse) Interface() protoreflect.ProtoM // Range returns immediately if f returns false. // While iterating, mutating operations may only be performed // on the current field descriptor. -func (x *fastReflection_QueryAllServiceResponse) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { +func (x *fastReflection_QueryAllServicesResponse) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { if len(x.Service) != 0 { - value := protoreflect.ValueOfList(&_QueryAllServiceResponse_1_list{list: &x.Service}) - if !f(fd_QueryAllServiceResponse_service, value) { + value := protoreflect.ValueOfList(&_QueryAllServicesResponse_1_list{list: &x.Service}) + if !f(fd_QueryAllServicesResponse_service, value) { return } } if x.Pagination != nil { value := protoreflect.ValueOfMessage(x.Pagination.ProtoReflect()) - if !f(fd_QueryAllServiceResponse_pagination, value) { + if !f(fd_QueryAllServicesResponse_pagination, value) { return } } @@ -2252,17 +2252,17 @@ func (x *fastReflection_QueryAllServiceResponse) Range(f func(protoreflect.Field // 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_QueryAllServiceResponse) Has(fd protoreflect.FieldDescriptor) bool { +func (x *fastReflection_QueryAllServicesResponse) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { - case "poktroll.service.QueryAllServiceResponse.service": + case "poktroll.service.QueryAllServicesResponse.service": return len(x.Service) != 0 - case "poktroll.service.QueryAllServiceResponse.pagination": + case "poktroll.service.QueryAllServicesResponse.pagination": return x.Pagination != nil default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.service.QueryAllServiceResponse")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.service.QueryAllServicesResponse")) } - panic(fmt.Errorf("message poktroll.service.QueryAllServiceResponse does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.service.QueryAllServicesResponse does not contain field %s", fd.FullName())) } } @@ -2272,17 +2272,17 @@ func (x *fastReflection_QueryAllServiceResponse) Has(fd protoreflect.FieldDescri // associated with the given field number. // // Clear is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_QueryAllServiceResponse) Clear(fd protoreflect.FieldDescriptor) { +func (x *fastReflection_QueryAllServicesResponse) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { - case "poktroll.service.QueryAllServiceResponse.service": + case "poktroll.service.QueryAllServicesResponse.service": x.Service = nil - case "poktroll.service.QueryAllServiceResponse.pagination": + case "poktroll.service.QueryAllServicesResponse.pagination": x.Pagination = nil default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.service.QueryAllServiceResponse")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.service.QueryAllServicesResponse")) } - panic(fmt.Errorf("message poktroll.service.QueryAllServiceResponse does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.service.QueryAllServicesResponse does not contain field %s", fd.FullName())) } } @@ -2292,22 +2292,22 @@ func (x *fastReflection_QueryAllServiceResponse) Clear(fd protoreflect.FieldDesc // 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_QueryAllServiceResponse) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { +func (x *fastReflection_QueryAllServicesResponse) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { switch descriptor.FullName() { - case "poktroll.service.QueryAllServiceResponse.service": + case "poktroll.service.QueryAllServicesResponse.service": if len(x.Service) == 0 { - return protoreflect.ValueOfList(&_QueryAllServiceResponse_1_list{}) + return protoreflect.ValueOfList(&_QueryAllServicesResponse_1_list{}) } - listValue := &_QueryAllServiceResponse_1_list{list: &x.Service} + listValue := &_QueryAllServicesResponse_1_list{list: &x.Service} return protoreflect.ValueOfList(listValue) - case "poktroll.service.QueryAllServiceResponse.pagination": + case "poktroll.service.QueryAllServicesResponse.pagination": value := x.Pagination return protoreflect.ValueOfMessage(value.ProtoReflect()) default: if descriptor.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.service.QueryAllServiceResponse")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.service.QueryAllServicesResponse")) } - panic(fmt.Errorf("message poktroll.service.QueryAllServiceResponse does not contain field %s", descriptor.FullName())) + panic(fmt.Errorf("message poktroll.service.QueryAllServicesResponse does not contain field %s", descriptor.FullName())) } } @@ -2321,19 +2321,19 @@ func (x *fastReflection_QueryAllServiceResponse) Get(descriptor protoreflect.Fie // empty, read-only value, then it panics. // // Set is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_QueryAllServiceResponse) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { +func (x *fastReflection_QueryAllServicesResponse) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { switch fd.FullName() { - case "poktroll.service.QueryAllServiceResponse.service": + case "poktroll.service.QueryAllServicesResponse.service": lv := value.List() - clv := lv.(*_QueryAllServiceResponse_1_list) + clv := lv.(*_QueryAllServicesResponse_1_list) x.Service = *clv.list - case "poktroll.service.QueryAllServiceResponse.pagination": + case "poktroll.service.QueryAllServicesResponse.pagination": x.Pagination = value.Message().Interface().(*v1beta1.PageResponse) default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.service.QueryAllServiceResponse")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.service.QueryAllServicesResponse")) } - panic(fmt.Errorf("message poktroll.service.QueryAllServiceResponse does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.service.QueryAllServicesResponse does not contain field %s", fd.FullName())) } } @@ -2347,53 +2347,53 @@ func (x *fastReflection_QueryAllServiceResponse) Set(fd protoreflect.FieldDescri // It panics if the field does not contain a composite type. // // Mutable is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_QueryAllServiceResponse) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { +func (x *fastReflection_QueryAllServicesResponse) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "poktroll.service.QueryAllServiceResponse.service": + case "poktroll.service.QueryAllServicesResponse.service": if x.Service == nil { x.Service = []*shared.Service{} } - value := &_QueryAllServiceResponse_1_list{list: &x.Service} + value := &_QueryAllServicesResponse_1_list{list: &x.Service} return protoreflect.ValueOfList(value) - case "poktroll.service.QueryAllServiceResponse.pagination": + case "poktroll.service.QueryAllServicesResponse.pagination": if x.Pagination == nil { x.Pagination = new(v1beta1.PageResponse) } return protoreflect.ValueOfMessage(x.Pagination.ProtoReflect()) default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.service.QueryAllServiceResponse")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.service.QueryAllServicesResponse")) } - panic(fmt.Errorf("message poktroll.service.QueryAllServiceResponse does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.service.QueryAllServicesResponse 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_QueryAllServiceResponse) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { +func (x *fastReflection_QueryAllServicesResponse) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "poktroll.service.QueryAllServiceResponse.service": + case "poktroll.service.QueryAllServicesResponse.service": list := []*shared.Service{} - return protoreflect.ValueOfList(&_QueryAllServiceResponse_1_list{list: &list}) - case "poktroll.service.QueryAllServiceResponse.pagination": + return protoreflect.ValueOfList(&_QueryAllServicesResponse_1_list{list: &list}) + case "poktroll.service.QueryAllServicesResponse.pagination": m := new(v1beta1.PageResponse) return protoreflect.ValueOfMessage(m.ProtoReflect()) default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.service.QueryAllServiceResponse")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.service.QueryAllServicesResponse")) } - panic(fmt.Errorf("message poktroll.service.QueryAllServiceResponse does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message poktroll.service.QueryAllServicesResponse 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_QueryAllServiceResponse) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { +func (x *fastReflection_QueryAllServicesResponse) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { switch d.FullName() { default: - panic(fmt.Errorf("%s is not a oneof field in poktroll.service.QueryAllServiceResponse", d.FullName())) + panic(fmt.Errorf("%s is not a oneof field in poktroll.service.QueryAllServicesResponse", d.FullName())) } panic("unreachable") } @@ -2401,7 +2401,7 @@ func (x *fastReflection_QueryAllServiceResponse) WhichOneof(d protoreflect.Oneof // 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_QueryAllServiceResponse) GetUnknown() protoreflect.RawFields { +func (x *fastReflection_QueryAllServicesResponse) GetUnknown() protoreflect.RawFields { return x.unknownFields } @@ -2412,7 +2412,7 @@ func (x *fastReflection_QueryAllServiceResponse) GetUnknown() protoreflect.RawFi // An empty RawFields may be passed to clear the fields. // // SetUnknown is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_QueryAllServiceResponse) SetUnknown(fields protoreflect.RawFields) { +func (x *fastReflection_QueryAllServicesResponse) SetUnknown(fields protoreflect.RawFields) { x.unknownFields = fields } @@ -2424,7 +2424,7 @@ func (x *fastReflection_QueryAllServiceResponse) SetUnknown(fields protoreflect. // 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_QueryAllServiceResponse) IsValid() bool { +func (x *fastReflection_QueryAllServicesResponse) IsValid() bool { return x != nil } @@ -2434,9 +2434,9 @@ func (x *fastReflection_QueryAllServiceResponse) IsValid() bool { // The returned methods type is identical to // "google.golang.org/protobuf/runtime/protoiface".Methods. // Consult the protoiface package documentation for details. -func (x *fastReflection_QueryAllServiceResponse) ProtoMethods() *protoiface.Methods { +func (x *fastReflection_QueryAllServicesResponse) ProtoMethods() *protoiface.Methods { size := func(input protoiface.SizeInput) protoiface.SizeOutput { - x := input.Message.Interface().(*QueryAllServiceResponse) + x := input.Message.Interface().(*QueryAllServicesResponse) if x == nil { return protoiface.SizeOutput{ NoUnkeyedLiterals: input.NoUnkeyedLiterals, @@ -2468,7 +2468,7 @@ func (x *fastReflection_QueryAllServiceResponse) ProtoMethods() *protoiface.Meth } marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { - x := input.Message.Interface().(*QueryAllServiceResponse) + x := input.Message.Interface().(*QueryAllServicesResponse) if x == nil { return protoiface.MarshalOutput{ NoUnkeyedLiterals: input.NoUnkeyedLiterals, @@ -2528,7 +2528,7 @@ func (x *fastReflection_QueryAllServiceResponse) ProtoMethods() *protoiface.Meth }, nil } unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { - x := input.Message.Interface().(*QueryAllServiceResponse) + x := input.Message.Interface().(*QueryAllServicesResponse) if x == nil { return protoiface.UnmarshalOutput{ NoUnkeyedLiterals: input.NoUnkeyedLiterals, @@ -2560,10 +2560,10 @@ func (x *fastReflection_QueryAllServiceResponse) ProtoMethods() *protoiface.Meth fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: QueryAllServiceResponse: wiretype end group for non-group") + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: QueryAllServicesResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: QueryAllServiceResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: QueryAllServicesResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -2753,7 +2753,8 @@ type QueryGetServiceRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Index string `protobuf:"bytes,1,opt,name=index,proto3" json:"index,omitempty"` + // TODO: We could support getting services by name. + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` } func (x *QueryGetServiceRequest) Reset() { @@ -2776,9 +2777,9 @@ func (*QueryGetServiceRequest) Descriptor() ([]byte, []int) { return file_poktroll_service_query_proto_rawDescGZIP(), []int{2} } -func (x *QueryGetServiceRequest) GetIndex() string { +func (x *QueryGetServiceRequest) GetId() string { if x != nil { - return x.Index + return x.Id } return "" } @@ -2818,7 +2819,7 @@ func (x *QueryGetServiceResponse) GetService() *shared.Service { return nil } -type QueryAllServiceRequest struct { +type QueryAllServicesRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields @@ -2826,8 +2827,8 @@ type QueryAllServiceRequest struct { Pagination *v1beta1.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` } -func (x *QueryAllServiceRequest) Reset() { - *x = QueryAllServiceRequest{} +func (x *QueryAllServicesRequest) Reset() { + *x = QueryAllServicesRequest{} if protoimpl.UnsafeEnabled { mi := &file_poktroll_service_query_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -2835,25 +2836,25 @@ func (x *QueryAllServiceRequest) Reset() { } } -func (x *QueryAllServiceRequest) String() string { +func (x *QueryAllServicesRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*QueryAllServiceRequest) ProtoMessage() {} +func (*QueryAllServicesRequest) ProtoMessage() {} -// Deprecated: Use QueryAllServiceRequest.ProtoReflect.Descriptor instead. -func (*QueryAllServiceRequest) Descriptor() ([]byte, []int) { +// Deprecated: Use QueryAllServicesRequest.ProtoReflect.Descriptor instead. +func (*QueryAllServicesRequest) Descriptor() ([]byte, []int) { return file_poktroll_service_query_proto_rawDescGZIP(), []int{4} } -func (x *QueryAllServiceRequest) GetPagination() *v1beta1.PageRequest { +func (x *QueryAllServicesRequest) GetPagination() *v1beta1.PageRequest { if x != nil { return x.Pagination } return nil } -type QueryAllServiceResponse struct { +type QueryAllServicesResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields @@ -2862,8 +2863,8 @@ type QueryAllServiceResponse struct { Pagination *v1beta1.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } -func (x *QueryAllServiceResponse) Reset() { - *x = QueryAllServiceResponse{} +func (x *QueryAllServicesResponse) Reset() { + *x = QueryAllServicesResponse{} if protoimpl.UnsafeEnabled { mi := &file_poktroll_service_query_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -2871,25 +2872,25 @@ func (x *QueryAllServiceResponse) Reset() { } } -func (x *QueryAllServiceResponse) String() string { +func (x *QueryAllServicesResponse) String() string { return protoimpl.X.MessageStringOf(x) } -func (*QueryAllServiceResponse) ProtoMessage() {} +func (*QueryAllServicesResponse) ProtoMessage() {} -// Deprecated: Use QueryAllServiceResponse.ProtoReflect.Descriptor instead. -func (*QueryAllServiceResponse) Descriptor() ([]byte, []int) { +// Deprecated: Use QueryAllServicesResponse.ProtoReflect.Descriptor instead. +func (*QueryAllServicesResponse) Descriptor() ([]byte, []int) { return file_poktroll_service_query_proto_rawDescGZIP(), []int{5} } -func (x *QueryAllServiceResponse) GetService() []*shared.Service { +func (x *QueryAllServicesResponse) GetService() []*shared.Service { if x != nil { return x.Service } return nil } -func (x *QueryAllServiceResponse) GetPagination() *v1beta1.PageResponse { +func (x *QueryAllServicesResponse) GetPagination() *v1beta1.PageResponse { if x != nil { return x.Pagination } @@ -2919,70 +2920,70 @@ var file_poktroll_service_query_proto_rawDesc = []byte{ 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x42, 0x09, 0xc8, 0xde, 0x1f, 0x00, 0xa8, 0xe7, - 0xb0, 0x2a, 0x01, 0x52, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x22, 0x2e, 0x0a, 0x16, 0x51, + 0xb0, 0x2a, 0x01, 0x52, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x22, 0x28, 0x0a, 0x16, 0x51, 0x75, 0x65, 0x72, 0x79, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x22, 0x53, 0x0a, 0x17, 0x51, - 0x75, 0x65, 0x72, 0x79, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x38, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, - 0x6c, 0x6c, 0x2e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x22, 0x60, 0x0a, 0x16, 0x51, 0x75, 0x65, 0x72, 0x79, 0x41, 0x6c, 0x6c, 0x53, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x46, 0x0a, 0x0a, 0x70, 0x61, - 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, - 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x71, 0x75, 0x65, - 0x72, 0x79, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x0a, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x22, 0x9c, 0x01, 0x0a, 0x17, 0x51, 0x75, 0x65, 0x72, 0x79, 0x41, 0x6c, 0x6c, 0x53, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x38, - 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x18, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x68, 0x61, 0x72, 0x65, - 0x64, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, - 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x47, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x69, - 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x63, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x71, 0x75, 0x65, 0x72, 0x79, - 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x0a, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x32, 0xbb, 0x03, 0x0a, 0x05, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x84, 0x01, 0x0a, 0x06, - 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x24, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, - 0x6c, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, - 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x70, - 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, - 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x2d, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x27, 0x12, 0x25, 0x2f, 0x70, 0x6f, - 0x6b, 0x74, 0x2d, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x72, - 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2f, 0x70, 0x61, 0x72, 0x61, - 0x6d, 0x73, 0x12, 0x96, 0x01, 0x0a, 0x07, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x28, - 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x53, 0x0a, 0x17, 0x51, 0x75, 0x65, 0x72, 0x79, 0x47, 0x65, + 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x38, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x18, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x68, 0x61, + 0x72, 0x65, 0x64, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x42, 0x04, 0xc8, 0xde, 0x1f, + 0x00, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x22, 0x61, 0x0a, 0x17, 0x51, 0x75, + 0x65, 0x72, 0x79, 0x41, 0x6c, 0x6c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x46, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x76, 0x31, + 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x52, 0x0a, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x9d, 0x01, + 0x0a, 0x18, 0x51, 0x75, 0x65, 0x72, 0x79, 0x41, 0x6c, 0x6c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x38, 0x0a, 0x07, 0x73, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x70, 0x6f, + 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2e, 0x53, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x07, 0x73, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x12, 0x47, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x62, + 0x65, 0x74, 0x61, 0x31, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x52, 0x0a, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x32, 0xbb, 0x03, + 0x0a, 0x05, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x84, 0x01, 0x0a, 0x06, 0x50, 0x61, 0x72, 0x61, + 0x6d, 0x73, 0x12, 0x24, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, + 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x51, 0x75, 0x65, 0x72, - 0x79, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x36, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x30, 0x12, 0x2e, 0x2f, 0x70, 0x6f, - 0x6b, 0x74, 0x2d, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x72, - 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2f, 0x73, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x2f, 0x7b, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x7d, 0x12, 0x91, 0x01, 0x0a, 0x0a, - 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x41, 0x6c, 0x6c, 0x12, 0x28, 0x2e, 0x70, 0x6f, 0x6b, + 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x2d, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x27, 0x12, 0x25, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x2d, 0x6e, + 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, + 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x93, + 0x01, 0x0a, 0x07, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x28, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x51, 0x75, - 0x65, 0x72, 0x79, 0x41, 0x6c, 0x6c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x71, + 0x65, 0x72, 0x79, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, - 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x41, 0x6c, 0x6c, + 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x2e, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x28, 0x12, 0x26, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x2d, 0x6e, + 0x33, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2d, 0x12, 0x2b, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x2d, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, - 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x42, - 0xa6, 0x01, 0x0a, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, - 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x42, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, - 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x21, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, - 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, - 0x6c, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0xa2, 0x02, 0x03, 0x50, 0x53, 0x58, 0xaa, - 0x02, 0x10, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0xca, 0x02, 0x10, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0xe2, 0x02, 0x1c, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, - 0x5c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, - 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x11, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x3a, - 0x3a, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2f, + 0x7b, 0x69, 0x64, 0x7d, 0x12, 0x94, 0x01, 0x0a, 0x0b, 0x41, 0x6c, 0x6c, 0x53, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x73, 0x12, 0x29, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, + 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x41, 0x6c, 0x6c, + 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x2a, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x41, 0x6c, 0x6c, 0x53, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2e, 0x82, 0xd3, 0xe4, + 0x93, 0x02, 0x28, 0x12, 0x26, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x2d, 0x6e, 0x65, 0x74, 0x77, 0x6f, + 0x72, 0x6b, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x42, 0xa6, 0x01, 0x0a, 0x14, + 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x42, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, + 0x50, 0x01, 0x5a, 0x21, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, + 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0xa2, 0x02, 0x03, 0x50, 0x53, 0x58, 0xaa, 0x02, 0x10, 0x50, 0x6f, + 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0xca, 0x02, + 0x10, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0xe2, 0x02, 0x1c, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, + 0xea, 0x02, 0x11, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x3a, 0x3a, 0x53, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -2999,29 +3000,29 @@ func file_poktroll_service_query_proto_rawDescGZIP() []byte { var file_poktroll_service_query_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_poktroll_service_query_proto_goTypes = []interface{}{ - (*QueryParamsRequest)(nil), // 0: poktroll.service.QueryParamsRequest - (*QueryParamsResponse)(nil), // 1: poktroll.service.QueryParamsResponse - (*QueryGetServiceRequest)(nil), // 2: poktroll.service.QueryGetServiceRequest - (*QueryGetServiceResponse)(nil), // 3: poktroll.service.QueryGetServiceResponse - (*QueryAllServiceRequest)(nil), // 4: poktroll.service.QueryAllServiceRequest - (*QueryAllServiceResponse)(nil), // 5: poktroll.service.QueryAllServiceResponse - (*Params)(nil), // 6: poktroll.service.Params - (*shared.Service)(nil), // 7: poktroll.shared.Service - (*v1beta1.PageRequest)(nil), // 8: cosmos.base.query.v1beta1.PageRequest - (*v1beta1.PageResponse)(nil), // 9: cosmos.base.query.v1beta1.PageResponse + (*QueryParamsRequest)(nil), // 0: poktroll.service.QueryParamsRequest + (*QueryParamsResponse)(nil), // 1: poktroll.service.QueryParamsResponse + (*QueryGetServiceRequest)(nil), // 2: poktroll.service.QueryGetServiceRequest + (*QueryGetServiceResponse)(nil), // 3: poktroll.service.QueryGetServiceResponse + (*QueryAllServicesRequest)(nil), // 4: poktroll.service.QueryAllServicesRequest + (*QueryAllServicesResponse)(nil), // 5: poktroll.service.QueryAllServicesResponse + (*Params)(nil), // 6: poktroll.service.Params + (*shared.Service)(nil), // 7: poktroll.shared.Service + (*v1beta1.PageRequest)(nil), // 8: cosmos.base.query.v1beta1.PageRequest + (*v1beta1.PageResponse)(nil), // 9: cosmos.base.query.v1beta1.PageResponse } var file_poktroll_service_query_proto_depIdxs = []int32{ 6, // 0: poktroll.service.QueryParamsResponse.params:type_name -> poktroll.service.Params 7, // 1: poktroll.service.QueryGetServiceResponse.service:type_name -> poktroll.shared.Service - 8, // 2: poktroll.service.QueryAllServiceRequest.pagination:type_name -> cosmos.base.query.v1beta1.PageRequest - 7, // 3: poktroll.service.QueryAllServiceResponse.service:type_name -> poktroll.shared.Service - 9, // 4: poktroll.service.QueryAllServiceResponse.pagination:type_name -> cosmos.base.query.v1beta1.PageResponse + 8, // 2: poktroll.service.QueryAllServicesRequest.pagination:type_name -> cosmos.base.query.v1beta1.PageRequest + 7, // 3: poktroll.service.QueryAllServicesResponse.service:type_name -> poktroll.shared.Service + 9, // 4: poktroll.service.QueryAllServicesResponse.pagination:type_name -> cosmos.base.query.v1beta1.PageResponse 0, // 5: poktroll.service.Query.Params:input_type -> poktroll.service.QueryParamsRequest 2, // 6: poktroll.service.Query.Service:input_type -> poktroll.service.QueryGetServiceRequest - 4, // 7: poktroll.service.Query.ServiceAll:input_type -> poktroll.service.QueryAllServiceRequest + 4, // 7: poktroll.service.Query.AllServices:input_type -> poktroll.service.QueryAllServicesRequest 1, // 8: poktroll.service.Query.Params:output_type -> poktroll.service.QueryParamsResponse 3, // 9: poktroll.service.Query.Service:output_type -> poktroll.service.QueryGetServiceResponse - 5, // 10: poktroll.service.Query.ServiceAll:output_type -> poktroll.service.QueryAllServiceResponse + 5, // 10: poktroll.service.Query.AllServices:output_type -> poktroll.service.QueryAllServicesResponse 8, // [8:11] is the sub-list for method output_type 5, // [5:8] is the sub-list for method input_type 5, // [5:5] is the sub-list for extension type_name @@ -3085,7 +3086,7 @@ func file_poktroll_service_query_proto_init() { } } file_poktroll_service_query_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*QueryAllServiceRequest); i { + switch v := v.(*QueryAllServicesRequest); i { case 0: return &v.state case 1: @@ -3097,7 +3098,7 @@ func file_poktroll_service_query_proto_init() { } } file_poktroll_service_query_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*QueryAllServiceResponse); i { + switch v := v.(*QueryAllServicesResponse); i { case 0: return &v.state case 1: diff --git a/api/poktroll/service/tx.pulsar.go b/api/poktroll/service/tx.pulsar.go index 0cd43516f..b756d9c17 100644 --- a/api/poktroll/service/tx.pulsar.go +++ b/api/poktroll/service/tx.pulsar.go @@ -1748,6 +1748,7 @@ 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 x/service parameters to update. // NOTE: All parameters must be supplied. Params *Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params,omitempty"` } diff --git a/api/poktroll/shared/service.pulsar.go b/api/poktroll/shared/service.pulsar.go index a9450676c..8cece2d86 100644 --- a/api/poktroll/shared/service.pulsar.go +++ b/api/poktroll/shared/service.pulsar.go @@ -503,7 +503,7 @@ func (x *fastReflection_Service) ProtoMethods() *protoiface.Methods { // source: poktroll/shared/service.proto // NOTE that the `shared` package is not a Cosmos module, -// but rather a manually created package to resolve circular dependencies. +// but rather a manually created package to resolve circular type dependencies. const ( // Verify that this generated code is sufficiently up-to-date. @@ -520,7 +520,7 @@ type Service struct { // For example, what if we want to request a session for a certain service but with some additional configs that identify it? Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` // Unique identifier for the service - // TODO_TECHDEBT: Name is currently unused but acts as a reminder than an optional onchain representation of the service is necessary + // TODO_TECHDEBT: Name is currently unused but acts as a reminder that an optional onchain representation of the service is necessary Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` // (Optional) Semantic human readable name for the service } diff --git a/proto/poktroll/service/genesis.proto b/proto/poktroll/service/genesis.proto index c563bf3a7..698660b69 100644 --- a/proto/poktroll/service/genesis.proto +++ b/proto/poktroll/service/genesis.proto @@ -1,13 +1,14 @@ syntax = "proto3"; - package poktroll.service; +option go_package = "github.com/pokt-network/poktroll/x/service/types"; + import "amino/amino.proto"; import "gogoproto/gogo.proto"; + import "poktroll/service/params.proto"; import "poktroll/shared/service.proto"; -option go_package = "github.com/pokt-network/poktroll/x/service/types"; // GenesisState defines the service module's genesis state. message GenesisState { diff --git a/proto/poktroll/service/params.proto b/proto/poktroll/service/params.proto index ab19273e8..aa963aba5 100644 --- a/proto/poktroll/service/params.proto +++ b/proto/poktroll/service/params.proto @@ -1,16 +1,19 @@ syntax = "proto3"; package poktroll.service; +option go_package = "github.com/pokt-network/poktroll/x/service/types"; + import "amino/amino.proto"; import "gogoproto/gogo.proto"; -option go_package = "github.com/pokt-network/poktroll/x/service/types"; // Params defines the parameters for the module. message Params { option (amino.name) = "poktroll/x/service/Params"; option (gogoproto.equal) = true; - + // The amount of uPOKT required to add a new service. + // This will be deducted from the signer's account balance, + // and transferred to the pocket network foundation. uint64 add_service_fee = 1 [(gogoproto.moretags) = "yaml:\"add_service_fee\""]; } \ No newline at end of file diff --git a/proto/poktroll/service/query.proto b/proto/poktroll/service/query.proto index ca2dacb7c..909394ed6 100644 --- a/proto/poktroll/service/query.proto +++ b/proto/poktroll/service/query.proto @@ -1,16 +1,16 @@ syntax = "proto3"; - package poktroll.service; +option go_package = "github.com/pokt-network/poktroll/x/service/types"; + import "amino/amino.proto"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; + import "poktroll/service/params.proto"; import "poktroll/shared/service.proto"; -option go_package = "github.com/pokt-network/poktroll/x/service/types"; - // Query defines the gRPC querier service. service Query { @@ -22,10 +22,10 @@ service Query { // Queries a list of Service items. rpc Service (QueryGetServiceRequest) returns (QueryGetServiceResponse) { - option (google.api.http).get = "/pokt-network/poktroll/service/service/{index}"; + option (google.api.http).get = "/pokt-network/poktroll/service/service/{id}"; } - rpc ServiceAll (QueryAllServiceRequest) returns (QueryAllServiceResponse) { + rpc AllServices (QueryAllServicesRequest) returns (QueryAllServicesResponse) { option (google.api.http).get = "/pokt-network/poktroll/service/service"; } @@ -41,18 +41,19 @@ message QueryParamsResponse { } message QueryGetServiceRequest { - string index = 1; + // TODO: We could support getting services by name. + string id = 1; } message QueryGetServiceResponse { poktroll.shared.Service service = 1 [(gogoproto.nullable) = false]; } -message QueryAllServiceRequest { +message QueryAllServicesRequest { cosmos.base.query.v1beta1.PageRequest pagination = 1; } -message QueryAllServiceResponse { +message QueryAllServicesResponse { repeated poktroll.shared.Service service = 1 [(gogoproto.nullable) = false]; cosmos.base.query.v1beta1.PageResponse pagination = 2; } diff --git a/proto/poktroll/service/tx.proto b/proto/poktroll/service/tx.proto index 26b4b3400..469c47b1e 100644 --- a/proto/poktroll/service/tx.proto +++ b/proto/poktroll/service/tx.proto @@ -1,20 +1,21 @@ syntax = "proto3"; - package poktroll.service; +option go_package = "github.com/pokt-network/poktroll/x/service/types"; + import "amino/amino.proto"; import "cosmos/msg/v1/msg.proto"; import "cosmos_proto/cosmos.proto"; import "gogoproto/gogo.proto"; + import "poktroll/service/params.proto"; import "poktroll/shared/service.proto"; -option go_package = "github.com/pokt-network/poktroll/x/service/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); @@ -22,14 +23,17 @@ service Msg { } // MsgUpdateParams is the Msg/UpdateParams request type. message MsgUpdateParams { - option (cosmos.msg.v1.signer) = "authority"; + option (cosmos.msg.v1.signer) = "authority"; option (amino.name) = "poktroll/x/service/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. - + // TODO_IMPROVE(#322): The requirement to provide all params is adopted from the + // latest Cosmos SDK version. We should look into either improving this ourselves + // or seeing if it is on their roadmap. + + // params defines the x/service parameters to update. // NOTE: All parameters must be supplied. Params params = 2 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; } diff --git a/proto/poktroll/shared/service.proto b/proto/poktroll/shared/service.proto index d1443755b..60a046eac 100644 --- a/proto/poktroll/shared/service.proto +++ b/proto/poktroll/shared/service.proto @@ -1,7 +1,7 @@ syntax = "proto3"; // NOTE that the `shared` package is not a Cosmos module, -// but rather a manually created package to resolve circular dependencies. +// but rather a manually created package to resolve circular type dependencies. package poktroll.shared; option go_package = "github.com/pokt-network/poktroll/x/shared/types"; @@ -13,7 +13,7 @@ message Service { // For example, what if we want to request a session for a certain service but with some additional configs that identify it? string id = 1; // Unique identifier for the service - // TODO_TECHDEBT: Name is currently unused but acts as a reminder than an optional onchain representation of the service is necessary + // TODO_TECHDEBT: Name is currently unused but acts as a reminder that an optional onchain representation of the service is necessary string name = 2; // (Optional) Semantic human readable name for the service } diff --git a/testutil/keeper/service.go b/testutil/keeper/service.go index d6bf955d5..74a88169d 100644 --- a/testutil/keeper/service.go +++ b/testutil/keeper/service.go @@ -1,6 +1,7 @@ package keeper import ( + "context" "sync" "testing" @@ -32,7 +33,8 @@ var ( mapMu = sync.RWMutex{} ) -func ServiceKeeper(t testing.TB) (keeper.Keeper, sdk.Context) { +func ServiceKeeper(t testing.TB) (keeper.Keeper, context.Context) { + t.Helper() storeKey := storetypes.NewKVStoreKey(types.StoreKey) db := dbm.NewMemDB() @@ -48,28 +50,30 @@ func ServiceKeeper(t testing.TB) (keeper.Keeper, sdk.Context) { mockBankKeeper := mocks.NewMockBankKeeper(ctrl) mockBankKeeper.EXPECT(). SpendableCoins(gomock.Any(), gomock.Any()). - DoAndReturn(func(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins { - mapMu.RLock() - defer mapMu.RUnlock() - if coins, ok := mapAccAddrCoins[addr.String()]; ok { - return coins - } - return sdk.Coins{} - }). - AnyTimes() + DoAndReturn( + func(ctx context.Context, addr sdk.AccAddress) sdk.Coins { + mapMu.RLock() + defer mapMu.RUnlock() + if coins, ok := mapAccAddrCoins[addr.String()]; ok { + return coins + } + return sdk.Coins{} + }, + ).AnyTimes() mockBankKeeper.EXPECT(). SendCoinsFromAccountToModule(gomock.Any(), gomock.Any(), types.ModuleName, gomock.Any()). - DoAndReturn(func(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error { - mapMu.Lock() - defer mapMu.Unlock() - coins := mapAccAddrCoins[senderAddr.String()] - if coins.AmountOf("upokt").GT(amt.AmountOf("upokt")) { - mapAccAddrCoins[senderAddr.String()] = coins.Sub(amt...) - return nil - } - return types.ErrServiceNotEnoughFunds - }). - AnyTimes() + DoAndReturn( + func(ctx context.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error { + mapMu.Lock() + defer mapMu.Unlock() + coins := mapAccAddrCoins[senderAddr.String()] + if coins.AmountOf("upokt").GT(amt.AmountOf("upokt")) { + mapAccAddrCoins[senderAddr.String()] = coins.Sub(amt...) + return nil + } + return types.ErrServiceNotEnoughFunds + }, + ).AnyTimes() k := keeper.NewKeeper( cdc, @@ -82,7 +86,7 @@ func ServiceKeeper(t testing.TB) (keeper.Keeper, sdk.Context) { ctx := sdk.NewContext(stateStore, cmtproto.Header{}, false, log.NewNopLogger()) // Initialize params - k.SetParams(ctx, types.DefaultParams()) + require.NoError(t, k.SetParams(ctx, types.DefaultParams())) return k, ctx } diff --git a/x/service/keeper/msg_server.go b/x/service/keeper/msg_server.go index e5f891b01..070f36dd6 100644 --- a/x/service/keeper/msg_server.go +++ b/x/service/keeper/msg_server.go @@ -1,8 +1,6 @@ package keeper -import ( - "github.com/pokt-network/poktroll/x/service/types" -) +import "github.com/pokt-network/poktroll/x/service/types" type msgServer struct { Keeper diff --git a/x/service/keeper/msg_server_add_service.go b/x/service/keeper/msg_server_add_service.go index 0b3c9c718..f22f15438 100644 --- a/x/service/keeper/msg_server_add_service.go +++ b/x/service/keeper/msg_server_add_service.go @@ -10,12 +10,10 @@ import ( "github.com/pokt-network/poktroll/x/service/types" ) -// AddService handles MsgAddService and adds a service to the network storing -// it in the service keeper's store using the provided ID from the message. -// If the transaction's signer does not have enough funds (upokt) to cover the -// AddServiceFee service module's governance parameter, it will not be able to -// add the service. If it does, the fee will be deducted and debited to the -// service module's account, then the service will be added on-chain. +// AddService adds a service to the network. +// The operation checks if the signer has enough funds (upokt) to pay the AddServiceFee. +// If funds are insufficient, the service won't be added. Otherwise, the fee is transferred from +// the signer to the service module's account, afterwards the service will be present on-chain. func (k msgServer) AddService( goCtx context.Context, msg *types.MsgAddService, diff --git a/x/service/keeper/msg_server_add_service_test.go b/x/service/keeper/msg_server_add_service_test.go index d1bfbfedd..0930ede44 100644 --- a/x/service/keeper/msg_server_add_service_test.go +++ b/x/service/keeper/msg_server_add_service_test.go @@ -19,27 +19,30 @@ func TestMsgServer_AddService(t *testing.T) { k, ctx := keepertest.ServiceKeeper(t) srv := keeper.NewMsgServerImpl(k) - // Create a service + // Declare test services svc1 := sharedtypes.Service{ Id: "svc1", Name: "service 1", } - // Generate a valid address - addr := sample.AccAddress() - // Create a service preExistingService := sharedtypes.Service{ Id: "svc2", Name: "service 2", } + + // Generate a valid address + addr := sample.AccAddress() + // Mock adding a balance to the account keepertest.AddAccToAccMapCoins(t, addr, "upokt", oneUPOKTGreaterThanFee) + // Add the service to the store _, err := srv.AddService(ctx, &types.MsgAddService{ Address: addr, Service: preExistingService, }) require.NoError(t, err) + // Validate the service was added serviceFound, found := k.GetService(ctx, preExistingService.Id) require.True(t, found) @@ -49,11 +52,11 @@ func TestMsgServer_AddService(t *testing.T) { validAddr2 := sample.AccAddress() tests := []struct { - desc string - setup func(t *testing.T) - address string - service sharedtypes.Service - expectedError error + desc string + setup func(t *testing.T) + address string + service sharedtypes.Service + expectedErr error }{ { desc: "valid - service added successfully", @@ -61,9 +64,9 @@ func TestMsgServer_AddService(t *testing.T) { // Add 10000000001 upokt to the account keepertest.AddAccToAccMapCoins(t, validAddr1, "upokt", oneUPOKTGreaterThanFee) }, - address: validAddr1, - service: svc1, - expectedError: nil, + address: validAddr1, + service: svc1, + expectedErr: nil, }, { desc: "invalid - service supplier address is empty", @@ -73,14 +76,14 @@ func TestMsgServer_AddService(t *testing.T) { Id: "svc1", Name: "service 1", }, - expectedError: types.ErrServiceInvalidAddress, + expectedErr: types.ErrServiceInvalidAddress, }, { - desc: "invalid - invalid service supplier address", - setup: func(t *testing.T) {}, - address: "invalid address", - service: svc1, - expectedError: types.ErrServiceInvalidAddress, + desc: "invalid - invalid service supplier address", + setup: func(t *testing.T) {}, + address: "invalid address", + service: svc1, + expectedErr: types.ErrServiceInvalidAddress, }, { desc: "invalid - missing service ID", @@ -90,7 +93,7 @@ func TestMsgServer_AddService(t *testing.T) { // Explicitly omitting Id field Name: "service 1", }, - expectedError: types.ErrServiceMissingID, + expectedErr: types.ErrServiceMissingID, }, { desc: "invalid - empty service ID", @@ -100,7 +103,7 @@ func TestMsgServer_AddService(t *testing.T) { Id: "", // explicitly set to empty string Name: "service 1", }, - expectedError: types.ErrServiceMissingID, + expectedErr: types.ErrServiceMissingID, }, { desc: "invalid - missing service name", @@ -110,7 +113,7 @@ func TestMsgServer_AddService(t *testing.T) { Id: "svc1", // Explicitly omitting Name field }, - expectedError: types.ErrServiceMissingName, + expectedErr: types.ErrServiceMissingName, }, { desc: "invalid - empty service name", @@ -120,28 +123,28 @@ func TestMsgServer_AddService(t *testing.T) { Id: "svc1", Name: "", // explicitly set to empty string }, - expectedError: types.ErrServiceMissingName, + expectedErr: types.ErrServiceMissingName, }, { - desc: "invalid - service already exists (same service supplier)", - setup: func(t *testing.T) {}, - address: addr, - service: preExistingService, - expectedError: types.ErrServiceAlreadyExists, + desc: "invalid - service already exists (same service supplier)", + setup: func(t *testing.T) {}, + address: addr, + service: preExistingService, + expectedErr: types.ErrServiceAlreadyExists, }, { - desc: "invalid - service already exists (different service supplier)", - setup: func(t *testing.T) {}, - address: sample.AccAddress(), - service: preExistingService, - expectedError: types.ErrServiceAlreadyExists, + desc: "invalid - service already exists (different service supplier)", + setup: func(t *testing.T) {}, + address: sample.AccAddress(), + service: preExistingService, + expectedErr: types.ErrServiceAlreadyExists, }, { - desc: "invalid - no spendable coins", - setup: func(t *testing.T) {}, - address: sample.AccAddress(), - service: svc1, - expectedError: types.ErrServiceNotEnoughFunds, + desc: "invalid - no spendable coins", + setup: func(t *testing.T) {}, + address: sample.AccAddress(), + service: svc1, + expectedErr: types.ErrServiceNotEnoughFunds, }, { desc: "invalid - insufficient upokt balance", @@ -149,9 +152,9 @@ func TestMsgServer_AddService(t *testing.T) { // Add 999999999 upokt to the account (one less than AddServiceFee) keepertest.AddAccToAccMapCoins(t, validAddr2, "upokt", oneUPOKTGreaterThanFee-2) }, - address: validAddr2, - service: svc1, - expectedError: types.ErrServiceNotEnoughFunds, + address: validAddr2, + service: svc1, + expectedErr: types.ErrServiceNotEnoughFunds, }, { desc: "invalid - account has exactly AddServiceFee", @@ -159,9 +162,9 @@ func TestMsgServer_AddService(t *testing.T) { // Add the exact fee in upokt to the account keepertest.AddAccToAccMapCoins(t, validAddr2, "upokt", types.DefaultAddServiceFee) }, - address: validAddr2, - service: svc1, - expectedError: types.ErrServiceNotEnoughFunds, + address: validAddr2, + service: svc1, + expectedErr: types.ErrServiceNotEnoughFunds, }, { desc: "invalid - sufficient balance of different denom", @@ -169,29 +172,29 @@ func TestMsgServer_AddService(t *testing.T) { // Adds 10000000001 wrong coins to the account keepertest.AddAccToAccMapCoins(t, validAddr2, "wrong", oneUPOKTGreaterThanFee) }, - address: validAddr2, - service: svc1, - expectedError: types.ErrServiceNotEnoughFunds, + address: validAddr2, + service: svc1, + expectedErr: types.ErrServiceNotEnoughFunds, }, } - for _, tt := range tests { - t.Run(tt.desc, func(t *testing.T) { - tt.setup(t) + for _, test := range tests { + t.Run(test.desc, func(t *testing.T) { + test.setup(t) _, err := srv.AddService(ctx, &types.MsgAddService{ - Address: tt.address, - Service: tt.service, + Address: test.address, + Service: test.service, }) - if tt.expectedError != nil { + if test.expectedErr != nil { // Using ErrorAs as wrapping the error sometimes gives errors with ErrorIs - require.ErrorAs(t, err, &tt.expectedError) + require.ErrorAs(t, err, &test.expectedErr) return } require.NoError(t, err) // Validate the service was added - serviceFound, found := k.GetService(ctx, tt.service.Id) + serviceFound, found := k.GetService(ctx, test.service.Id) require.True(t, found) - require.Equal(t, tt.service, serviceFound) + require.Equal(t, test.service, serviceFound) }) } } diff --git a/x/service/keeper/msg_server_test.go b/x/service/keeper/msg_server_test.go index a2aed4881..0bda2a3f4 100644 --- a/x/service/keeper/msg_server_test.go +++ b/x/service/keeper/msg_server_test.go @@ -12,11 +12,15 @@ import ( ) func setupMsgServer(t testing.TB) (keeper.Keeper, types.MsgServer, context.Context) { + t.Helper() + k, ctx := keepertest.ServiceKeeper(t) return k, keeper.NewMsgServerImpl(k), ctx } func TestMsgServer(t *testing.T) { + t.Helper() + k, ms, ctx := setupMsgServer(t) require.NotNil(t, ms) require.NotNil(t, ctx) diff --git a/x/service/keeper/msg_update_params.go b/x/service/keeper/msg_update_params.go index e7fc8cc1f..a926bc1dd 100644 --- a/x/service/keeper/msg_update_params.go +++ b/x/service/keeper/msg_update_params.go @@ -3,18 +3,14 @@ package keeper import ( "context" - errorsmod "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/pokt-network/poktroll/x/service/types" ) -func (k msgServer) UpdateParams(goCtx context.Context, req *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { +func (k msgServer) UpdateParams(ctx context.Context, req *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { if k.GetAuthority() != req.Authority { - return nil, errorsmod.Wrapf(types.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.GetAuthority(), req.Authority) + return nil, types.ErrServiceInvalidSigner.Wrapf("invalid authority; expected %s, got %s", k.GetAuthority(), req.Authority) } - ctx := sdk.UnwrapSDKContext(goCtx) if err := k.SetParams(ctx, req.Params); err != nil { return nil, err } diff --git a/x/service/keeper/msg_update_params_test.go b/x/service/keeper/msg_update_params_test.go index b9cc12a59..8fe9ecfb1 100644 --- a/x/service/keeper/msg_update_params_test.go +++ b/x/service/keeper/msg_update_params_test.go @@ -3,7 +3,6 @@ package keeper_test import ( "testing" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" "github.com/pokt-network/poktroll/x/service/types" @@ -13,49 +12,48 @@ func TestMsgUpdateParams(t *testing.T) { k, ms, ctx := setupMsgServer(t) params := types.DefaultParams() require.NoError(t, k.SetParams(ctx, params)) - wctx := sdk.UnwrapSDKContext(ctx) // default params - testCases := []struct { - name string - input *types.MsgUpdateParams - expErr bool - expErrMsg string + tests := []struct { + desc string + input *types.MsgUpdateParams + shouldError bool + expectedErrMsg string }{ { - name: "invalid authority", + desc: "invalid authority", input: &types.MsgUpdateParams{ Authority: "invalid", Params: params, }, - expErr: true, - expErrMsg: "invalid authority", + shouldError: true, + expectedErrMsg: "invalid authority", }, { - name: "send enabled param", + desc: "send enabled param", input: &types.MsgUpdateParams{ Authority: k.GetAuthority(), Params: types.Params{}, }, - expErr: false, + shouldError: false, }, { - name: "all good", + desc: "all good", input: &types.MsgUpdateParams{ Authority: k.GetAuthority(), Params: params, }, - expErr: false, + shouldError: false, }, } - for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { - _, err := ms.UpdateParams(wctx, tc.input) + for _, test := range tests { + t.Run(test.desc, func(t *testing.T) { + _, err := ms.UpdateParams(ctx, test.input) - if tc.expErr { + if test.shouldError { require.Error(t, err) - require.Contains(t, err.Error(), tc.expErrMsg) + require.Contains(t, err.Error(), test.expectedErrMsg) } else { require.NoError(t, err) } diff --git a/x/service/keeper/params.go b/x/service/keeper/params.go index e980f9ec4..564b30b2b 100644 --- a/x/service/keeper/params.go +++ b/x/service/keeper/params.go @@ -11,23 +11,23 @@ import ( // GetParams get all parameters as types.Params func (k Keeper) GetParams(ctx context.Context) (params types.Params) { store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) - bz := store.Get(types.ParamsKey) - if bz == nil { + paramsBz := store.Get(types.ParamsKey) + if paramsBz == nil { return params } - k.cdc.MustUnmarshal(bz, ¶ms) + k.cdc.MustUnmarshal(paramsBz, ¶ms) return params } // SetParams set the params func (k Keeper) SetParams(ctx context.Context, params types.Params) error { store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) - bz, err := k.cdc.Marshal(¶ms) + paramsBz, err := k.cdc.Marshal(¶ms) if err != nil { return err } - store.Set(types.ParamsKey, bz) + store.Set(types.ParamsKey, paramsBz) return nil } diff --git a/x/service/keeper/query.go b/x/service/keeper/query.go index ac3116f9a..48d9d1663 100644 --- a/x/service/keeper/query.go +++ b/x/service/keeper/query.go @@ -1,7 +1,5 @@ package keeper -import ( - "github.com/pokt-network/poktroll/x/service/types" -) +import "github.com/pokt-network/poktroll/x/service/types" var _ types.QueryServer = Keeper{} diff --git a/x/service/keeper/query_params.go b/x/service/keeper/query_params.go index c04f32dd9..397ea09c4 100644 --- a/x/service/keeper/query_params.go +++ b/x/service/keeper/query_params.go @@ -3,18 +3,16 @@ package keeper import ( "context" - sdk "github.com/cosmos/cosmos-sdk/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "github.com/pokt-network/poktroll/x/service/types" ) -func (k Keeper) Params(goCtx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { +func (k Keeper) Params(ctx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") } - ctx := sdk.UnwrapSDKContext(goCtx) return &types.QueryParamsResponse{Params: k.GetParams(ctx)}, nil } diff --git a/x/service/keeper/query_service.go b/x/service/keeper/query_service.go index d308e0038..94a0e4ad3 100644 --- a/x/service/keeper/query_service.go +++ b/x/service/keeper/query_service.go @@ -6,16 +6,15 @@ import ( "cosmossdk.io/store/prefix" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/types/query" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" "github.com/pokt-network/poktroll/x/service/types" sharedtypes "github.com/pokt-network/poktroll/x/shared/types" - - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" ) -// ServiceAll queries all services. -func (k Keeper) ServiceAll(ctx context.Context, req *types.QueryAllServiceRequest) (*types.QueryAllServiceResponse, error) { +// AllServices queries all services. +func (k Keeper) AllServices(ctx context.Context, req *types.QueryAllServicesRequest) (*types.QueryAllServicesResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") } @@ -39,7 +38,7 @@ func (k Keeper) ServiceAll(ctx context.Context, req *types.QueryAllServiceReques return nil, status.Error(codes.Internal, err.Error()) } - return &types.QueryAllServiceResponse{Service: services, Pagination: pageRes}, nil + return &types.QueryAllServicesResponse{Service: services, Pagination: pageRes}, nil } // Service returns the requested service if it exists. @@ -48,10 +47,7 @@ func (k Keeper) Service(ctx context.Context, req *types.QueryGetServiceRequest) return nil, status.Error(codes.InvalidArgument, "invalid request") } - service, found := k.GetService( - ctx, - req.Index, - ) + service, found := k.GetService(ctx, req.Id) if !found { return nil, status.Error(codes.NotFound, "not found") } diff --git a/x/service/keeper/query_service_test.go b/x/service/keeper/query_service_test.go index 50ba3117c..f1f968fd6 100644 --- a/x/service/keeper/query_service_test.go +++ b/x/service/keeper/query_service_test.go @@ -19,48 +19,48 @@ var _ = strconv.IntSize func TestServiceQuerySingle(t *testing.T) { keeper, ctx := keepertest.ServiceKeeper(t) - msgs := createNService(keeper, ctx, 2) + msgs := createNServices(keeper, ctx, 2) tests := []struct { - desc string - request *types.QueryGetServiceRequest - response *types.QueryGetServiceResponse - err error + desc string + request *types.QueryGetServiceRequest + response *types.QueryGetServiceResponse + expectedErr error }{ { desc: "First", request: &types.QueryGetServiceRequest{ - Index: msgs[0].Id, + Id: msgs[0].Id, }, response: &types.QueryGetServiceResponse{Service: msgs[0]}, }, { desc: "Second", request: &types.QueryGetServiceRequest{ - Index: msgs[1].Id, + Id: msgs[1].Id, }, response: &types.QueryGetServiceResponse{Service: msgs[1]}, }, { desc: "KeyNotFound", request: &types.QueryGetServiceRequest{ - Index: strconv.Itoa(100000), + Id: strconv.Itoa(100000), }, - err: status.Error(codes.NotFound, "not found"), + expectedErr: status.Error(codes.NotFound, "not found"), }, { - desc: "InvalidRequest", - err: status.Error(codes.InvalidArgument, "invalid request"), + desc: "InvalidRequest", + expectedErr: status.Error(codes.InvalidArgument, "invalid request"), }, } - for _, tc := range tests { - t.Run(tc.desc, func(t *testing.T) { - response, err := keeper.Service(ctx, tc.request) - if tc.err != nil { - require.ErrorIs(t, err, tc.err) + for _, test := range tests { + t.Run(test.desc, func(t *testing.T) { + response, err := keeper.Service(ctx, test.request) + if test.expectedErr != nil { + require.ErrorIs(t, err, test.expectedErr) } else { require.NoError(t, err) require.Equal(t, - nullify.Fill(tc.response), + nullify.Fill(test.response), nullify.Fill(response), ) } @@ -70,10 +70,10 @@ func TestServiceQuerySingle(t *testing.T) { func TestServiceQueryPaginated(t *testing.T) { keeper, ctx := keepertest.ServiceKeeper(t) - msgs := createNService(keeper, ctx, 5) + msgs := createNServices(keeper, ctx, 5) - request := func(next []byte, offset, limit uint64, total bool) *types.QueryAllServiceRequest { - return &types.QueryAllServiceRequest{ + request := func(next []byte, offset, limit uint64, total bool) *types.QueryAllServicesRequest { + return &types.QueryAllServicesRequest{ Pagination: &query.PageRequest{ Key: next, Offset: offset, @@ -85,7 +85,7 @@ func TestServiceQueryPaginated(t *testing.T) { t.Run("ByOffset", func(t *testing.T) { step := 2 for i := 0; i < len(msgs); i += step { - resp, err := keeper.ServiceAll(ctx, request(nil, uint64(i), uint64(step), false)) + resp, err := keeper.AllServices(ctx, request(nil, uint64(i), uint64(step), false)) require.NoError(t, err) require.LessOrEqual(t, len(resp.Service), step) require.Subset(t, @@ -98,7 +98,7 @@ func TestServiceQueryPaginated(t *testing.T) { step := 2 var next []byte for i := 0; i < len(msgs); i += step { - resp, err := keeper.ServiceAll(ctx, request(next, 0, uint64(step), false)) + resp, err := keeper.AllServices(ctx, request(next, 0, uint64(step), false)) require.NoError(t, err) require.LessOrEqual(t, len(resp.Service), step) require.Subset(t, @@ -109,7 +109,7 @@ func TestServiceQueryPaginated(t *testing.T) { } }) t.Run("Total", func(t *testing.T) { - resp, err := keeper.ServiceAll(ctx, request(nil, 0, 0, true)) + resp, err := keeper.AllServices(ctx, request(nil, 0, 0, true)) require.NoError(t, err) require.Equal(t, len(msgs), int(resp.Pagination.Total)) require.ElementsMatch(t, @@ -118,7 +118,7 @@ func TestServiceQueryPaginated(t *testing.T) { ) }) t.Run("InvalidRequest", func(t *testing.T) { - _, err := keeper.ServiceAll(ctx, nil) + _, err := keeper.AllServices(ctx, nil) require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) }) } diff --git a/x/service/keeper/service.go b/x/service/keeper/service.go index 38c5b9a96..fe060e9a7 100644 --- a/x/service/keeper/service.go +++ b/x/service/keeper/service.go @@ -16,9 +16,7 @@ func (k Keeper) SetService(ctx context.Context, service sharedtypes.Service) { storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) store := prefix.NewStore(storeAdapter, types.KeyPrefix(types.ServiceKeyPrefix)) serviceBz := k.cdc.MustMarshal(&service) - store.Set(types.ServiceKey( - service.Id, - ), serviceBz) + store.Set(types.ServiceKey(service.Id), serviceBz) } // GetService returns a service from its index @@ -29,9 +27,7 @@ func (k Keeper) GetService( storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) store := prefix.NewStore(storeAdapter, types.KeyPrefix(types.ServiceKeyPrefix)) - serviceBz := store.Get(types.ServiceKey( - serviceId, - )) + serviceBz := store.Get(types.ServiceKey(serviceId)) if serviceBz == nil { return service, false } @@ -47,9 +43,7 @@ func (k Keeper) RemoveService( ) { storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) store := prefix.NewStore(storeAdapter, types.KeyPrefix(types.ServiceKeyPrefix)) - store.Delete(types.ServiceKey( - serviceId, - )) + store.Delete(types.ServiceKey(serviceId)) } // GetAllService returns all service diff --git a/x/service/keeper/service_test.go b/x/service/keeper/service_test.go index 231f8c151..d3a37f6e6 100644 --- a/x/service/keeper/service_test.go +++ b/x/service/keeper/service_test.go @@ -7,6 +7,7 @@ import ( "testing" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/stretchr/testify/require" "github.com/pokt-network/poktroll/cmd/poktrolld/cmd" keepertest "github.com/pokt-network/poktroll/testutil/keeper" @@ -14,8 +15,6 @@ import ( "github.com/pokt-network/poktroll/x/service/keeper" "github.com/pokt-network/poktroll/x/service/types" sharedtypes "github.com/pokt-network/poktroll/x/shared/types" - - "github.com/stretchr/testify/require" ) // Prevent strconv unused error @@ -25,7 +24,7 @@ func init() { cmd.InitSDKConfig() } -func createNService(keeper keeper.Keeper, ctx context.Context, n int) []sharedtypes.Service { +func createNServices(keeper keeper.Keeper, ctx context.Context, n int) []sharedtypes.Service { services := make([]sharedtypes.Service, n) for i := range services { services[i].Id = strconv.Itoa(i) @@ -43,11 +42,9 @@ func TestServiceModuleAddress(t *testing.T) { func TestServiceGet(t *testing.T) { keeper, ctx := keepertest.ServiceKeeper(t) - services := createNService(keeper, ctx, 10) + services := createNServices(keeper, ctx, 10) for _, service := range services { - foundService, found := keeper.GetService(ctx, - service.Id, - ) + foundService, found := keeper.GetService(ctx, service.Id) require.True(t, found) require.Equal(t, nullify.Fill(&service), @@ -57,21 +54,17 @@ func TestServiceGet(t *testing.T) { } func TestServiceRemove(t *testing.T) { keeper, ctx := keepertest.ServiceKeeper(t) - services := createNService(keeper, ctx, 10) + services := createNServices(keeper, ctx, 10) for _, service := range services { - keeper.RemoveService(ctx, - service.Id, - ) - _, found := keeper.GetService(ctx, - service.Id, - ) + keeper.RemoveService(ctx, service.Id) + _, found := keeper.GetService(ctx, service.Id) require.False(t, found) } } func TestServiceGetAll(t *testing.T) { keeper, ctx := keepertest.ServiceKeeper(t) - services := createNService(keeper, ctx, 10) + services := createNServices(keeper, ctx, 10) require.ElementsMatch(t, nullify.Fill(services), nullify.Fill(keeper.GetAllService(ctx)), diff --git a/x/service/module/autocli.go b/x/service/module/autocli.go index cb9fa8e88..287cbbcbc 100644 --- a/x/service/module/autocli.go +++ b/x/service/module/autocli.go @@ -2,50 +2,51 @@ package service import ( autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" + + modulev1 "github.com/pokt-network/poktroll/api/poktroll/service" ) // AutoCLIOptions implements the autocli.HasAutoCLIConfig interface. func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { return &autocliv1.ModuleOptions{ - // TODO_TECHDEBT(#370): Integrate with AutoCLI - // Query: &autocliv1.ServiceCommandDescriptor{ - // Service: modulev1.Query_ServiceDesc.ServiceName, - // RpcCommandOptions: []*autocliv1.RpcCommandOptions{ - // { - // RpcMethod: "Params", - // Use: "params", - // Short: "Shows the parameters of the module", - // }, - // { - // RpcMethod: "ServiceAll", - // Use: "list-service", - // Short: "List all service", - // }, - // { - // RpcMethod: "Service", - // Use: "show-service [id]", - // Short: "Shows a service", - // PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "index"}}, - // }, - // // this line is used by ignite scaffolding # autocli/query - // }, - // }, - // Tx: &autocliv1.ServiceCommandDescriptor{ - // Service: modulev1.Msg_ServiceDesc.ServiceName, - // EnhanceCustomCommand: true, // only required if you want to use the custom command - // RpcCommandOptions: []*autocliv1.RpcCommandOptions{ - // { - // RpcMethod: "UpdateParams", - // Skip: true, // skipped because authority gated - // }, - // { - // RpcMethod: "AddService", - // Use: "add-service", - // Short: "Send a add-service tx", - // PositionalArgs: []*autocliv1.PositionalArgDescriptor{}, - // }, - // // this line is used by ignite scaffolding # autocli/tx - // }, - // }, + Query: &autocliv1.ServiceCommandDescriptor{ + Service: modulev1.Query_ServiceDesc.ServiceName, + RpcCommandOptions: []*autocliv1.RpcCommandOptions{ + // { + // RpcMethod: "Params", + // Use: "params", + // Short: "Shows the parameters of the module", + // }, + // { + // RpcMethod: "AllServices", + // Use: "list-service", + // Short: "List all service", + // }, + // { + // RpcMethod: "Service", + // Use: "show-service [id]", + // Short: "Shows a service", + // PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "index"}}, + // }, + // this line is used by ignite scaffolding # autocli/query + }, + }, + Tx: &autocliv1.ServiceCommandDescriptor{ + Service: modulev1.Msg_ServiceDesc.ServiceName, + EnhanceCustomCommand: true, // only required if you want to use the custom command + RpcCommandOptions: []*autocliv1.RpcCommandOptions{ + // { + // RpcMethod: "UpdateParams", + // Skip: true, // skipped because authority gated + // }, + // { + // RpcMethod: "AddService", + // Use: "add-service", + // Short: "Send a add-service tx", + // PositionalArgs: []*autocliv1.PositionalArgDescriptor{}, + // }, + // this line is used by ignite scaffolding # autocli/tx + }, + }, } } diff --git a/x/service/module/genesis.go b/x/service/module/genesis.go index d3bdb9acd..fded93481 100644 --- a/x/service/module/genesis.go +++ b/x/service/module/genesis.go @@ -1,24 +1,26 @@ package service import ( - sdk "github.com/cosmos/cosmos-sdk/types" + "context" "github.com/pokt-network/poktroll/x/service/keeper" "github.com/pokt-network/poktroll/x/service/types" ) // InitGenesis initializes the module's state from a provided genesis state. -func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { +func InitGenesis(ctx context.Context, k keeper.Keeper, genState types.GenesisState) { // Set all the service for _, service := range genState.ServiceList { k.SetService(ctx, service) } // this line is used by starport scaffolding # genesis/module/init - k.SetParams(ctx, genState.Params) + if err := k.SetParams(ctx, genState.Params); err != nil { + panic(err) + } } // ExportGenesis returns the module's exported genesis. -func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { +func ExportGenesis(ctx context.Context, k keeper.Keeper) *types.GenesisState { genesis := types.DefaultGenesis() genesis.Params = k.GetParams(ctx) diff --git a/x/service/module/module.go b/x/service/module/module.go index 6a733dd22..e57949906 100644 --- a/x/service/module/module.go +++ b/x/service/module/module.go @@ -141,6 +141,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. +// TODO_TECHDEBT(#395): Make consensus version configurable func (AppModule) ConsensusVersion() uint64 { return 1 } // BeginBlock contains the logic that is automatically triggered at the beginning of each block. @@ -166,10 +167,7 @@ func (am AppModule) IsAppModule() {} // ---------------------------------------------------------------------------- func init() { - appmodule.Register( - &modulev1.Module{}, - appmodule.Provide(ProvideModule), - ) + appmodule.Register(&modulev1.Module{}, appmodule.Provide(ProvideModule)) } type ModuleInputs struct { diff --git a/x/service/module/tx.go b/x/service/module/tx.go index ccbad12ed..48abdd9cc 100644 --- a/x/service/module/tx.go +++ b/x/service/module/tx.go @@ -2,7 +2,6 @@ package service import ( "fmt" - "time" "github.com/cosmos/cosmos-sdk/client" "github.com/spf13/cobra" @@ -10,16 +9,8 @@ import ( "github.com/pokt-network/poktroll/x/service/types" ) -var ( - DefaultRelativePacketTimeoutTimestamp = uint64((time.Duration(10) * time.Minute).Nanoseconds()) -) - -const ( - flagPacketTimeoutTimestamp = "packet-timeout-timestamp" - listSeparator = "," -) - // GetTxCmd returns the transaction commands for this module +// TODO_TECHDEBT(#370): remove if custom query commands are consolidated into AutoCLI. func (am AppModule) GetTxCmd() *cobra.Command { cmd := &cobra.Command{ Use: types.ModuleName, diff --git a/x/service/module/tx_add_service.go b/x/service/module/tx_add_service.go index 5676fc440..48ed62ccb 100644 --- a/x/service/module/tx_add_service.go +++ b/x/service/module/tx_add_service.go @@ -18,11 +18,10 @@ func CmdAddService() *cobra.Command { Use: "add-service ", Short: "Add a new service to the network", Long: `Add a new service to the network that will be available for applications, -gateways and suppliers to use. The service id MUST be unique - or the command -will fail, however the name you use to describe it does not have to be unique. +gateways and suppliers to use. The service id MUST be unique but the service name doesn't have to be. Example: -$ poktrolld tx service add-service "svc1" "service_one" --keyring-backend test --from $(SUPPLIER) --node $(POCKET_NODE) --home=$(POKTROLLD_HOME)`, +$ poktrolld tx service add-service "svc1" "service_one" --keyring-backend test --from $(SUPPLIER) --node $(POCKET_NODE) --home $(POKTROLLD_HOME)`, Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) (err error) { serviceIdStr := args[0] diff --git a/x/service/module/tx_add_service_test.go b/x/service/module/tx_add_service_test.go index 9a1bc3ace..bd2b2131f 100644 --- a/x/service/module/tx_add_service_test.go +++ b/x/service/module/tx_add_service_test.go @@ -5,7 +5,7 @@ import ( "testing" sdkerrors "cosmossdk.io/errors" - sdkmath "cosmossdk.io/math" + "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/testutil" clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" @@ -39,7 +39,7 @@ func TestCLI_AddService(t *testing.T) { fmt.Sprintf( "--%s=%s", flags.FlagFees, - sdk.NewCoins(sdk.NewCoin(net.Config.BondDenom, sdkmath.NewInt(10))).String(), + sdk.NewCoins(sdk.NewCoin(net.Config.BondDenom, math.NewInt(10))).String(), ), } @@ -74,7 +74,7 @@ func TestCLI_AddService(t *testing.T) { desc string supplierAddress string service sharedtypes.Service - err *sdkerrors.Error + expectedErr *sdkerrors.Error }{ { desc: "valid - add new service", @@ -85,39 +85,39 @@ func TestCLI_AddService(t *testing.T) { desc: "invalid - missing service id", supplierAddress: account.Address.String(), service: sharedtypes.Service{Name: "service name"}, // ID intentionally omitted - err: types.ErrServiceMissingID, + expectedErr: types.ErrServiceMissingID, }, { desc: "invalid - missing service name", supplierAddress: account.Address.String(), service: sharedtypes.Service{Id: "svc1"}, // Name intentionally omitted - err: types.ErrServiceMissingName, + expectedErr: types.ErrServiceMissingName, }, { desc: "invalid - invalid supplier address", supplierAddress: "invalid address", service: svc1, - err: types.ErrServiceInvalidAddress, + expectedErr: types.ErrServiceInvalidAddress, }, { desc: "invalid - service already staked", supplierAddress: account.Address.String(), service: svc2, - err: types.ErrServiceAlreadyExists, + expectedErr: types.ErrServiceAlreadyExists, }, } // Run the tests - for _, tt := range tests { - t.Run(tt.desc, func(t *testing.T) { + for _, test := range tests { + t.Run(test.desc, func(t *testing.T) { // Wait for a new block to be committed require.NoError(t, net.WaitForNextBlock()) // Prepare the arguments for the CLI command args := []string{ - tt.service.Id, - tt.service.Name, - fmt.Sprintf("--%s=%s", flags.FlagFrom, tt.supplierAddress), + test.service.Id, + test.service.Name, + fmt.Sprintf("--%s=%s", flags.FlagFrom, test.supplierAddress), } args = append(args, commonArgs...) @@ -125,10 +125,10 @@ func TestCLI_AddService(t *testing.T) { addServiceOutput, err := clitestutil.ExecTestCLICmd(ctx, service.CmdAddService(), args) // Validate the error if one is expected - if tt.err != nil { - stat, ok := status.FromError(tt.err) + if test.expectedErr != nil { + stat, ok := status.FromError(test.expectedErr) require.True(t, ok) - require.Contains(t, stat.Message(), tt.err.Error()) + require.Contains(t, stat.Message(), test.expectedErr.Error()) return } require.NoError(t, err) diff --git a/x/service/simulation/add_service.go b/x/service/simulation/add_service.go index 4872ab877..d7647d639 100644 --- a/x/service/simulation/add_service.go +++ b/x/service/simulation/add_service.go @@ -6,6 +6,7 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/pokt-network/poktroll/x/service/keeper" "github.com/pokt-network/poktroll/x/service/types" ) diff --git a/x/service/types/errors.go b/x/service/types/errors.go index 4a8ad050e..cd4ea82b6 100644 --- a/x/service/types/errors.go +++ b/x/service/types/errors.go @@ -2,20 +2,18 @@ package types // DONTCOVER -import ( - sdkerrors "cosmossdk.io/errors" -) +import sdkerrors "cosmossdk.io/errors" // x/service module sentinel errors var ( - ErrServiceDuplicateIndex = sdkerrors.Register(ModuleName, 1, "duplicate index when adding a new service") - ErrServiceInvalidAddress = sdkerrors.Register(ModuleName, 2, "invalid address when adding a new service") - ErrServiceMissingID = sdkerrors.Register(ModuleName, 3, "missing service ID") - ErrServiceMissingName = sdkerrors.Register(ModuleName, 4, "missing service name") - ErrServiceAlreadyExists = sdkerrors.Register(ModuleName, 5, "service already exists") - ErrServiceInvalidServiceFee = sdkerrors.Register(ModuleName, 6, "invalid service fee") - ErrServiceAccountNotFound = sdkerrors.Register(ModuleName, 7, "account not found") - ErrServiceNotEnoughFunds = sdkerrors.Register(ModuleName, 8, "not enough funds to add service") - ErrServiceFailedToDeductFee = sdkerrors.Register(ModuleName, 9, "failed to deduct fee") - ErrInvalidSigner = sdkerrors.Register(ModuleName, 1100, "expected gov account as only signer for proposal message") + ErrServiceInvalidSigner = sdkerrors.Register(ModuleName, 1100, "expected gov account as only signer for proposal message") + ErrServiceDuplicateIndex = sdkerrors.Register(ModuleName, 1101, "duplicate index when adding a new service") + ErrServiceInvalidAddress = sdkerrors.Register(ModuleName, 1102, "invalid address when adding a new service") + ErrServiceMissingID = sdkerrors.Register(ModuleName, 1103, "missing service ID") + ErrServiceMissingName = sdkerrors.Register(ModuleName, 1104, "missing service name") + ErrServiceAlreadyExists = sdkerrors.Register(ModuleName, 1105, "service already exists") + ErrServiceInvalidServiceFee = sdkerrors.Register(ModuleName, 1106, "invalid service fee") + ErrServiceAccountNotFound = sdkerrors.Register(ModuleName, 1107, "account not found") + ErrServiceNotEnoughFunds = sdkerrors.Register(ModuleName, 1108, "not enough funds to add service") + ErrServiceFailedToDeductFee = sdkerrors.Register(ModuleName, 1109, "failed to deduct fee") ) diff --git a/x/service/types/expected_keepers.go b/x/service/types/expected_keepers.go index 5f5c88175..ca6a8da01 100644 --- a/x/service/types/expected_keepers.go +++ b/x/service/types/expected_keepers.go @@ -1,4 +1,5 @@ //go:generate mockgen -destination ../../../testutil/service/mocks/expected_keepers_mock.go -package mocks . BankKeeper + package types import ( @@ -25,9 +26,3 @@ type BankKeeper interface { amt sdk.Coins, ) error } - -// ParamSubspace defines the expected Subspace interface for parameters. -type ParamSubspace interface { - Get(context.Context, []byte, interface{}) - Set(context.Context, []byte, interface{}) -} diff --git a/x/service/types/genesis.go b/x/service/types/genesis.go index 06cc3f252..4c324a41f 100644 --- a/x/service/types/genesis.go +++ b/x/service/types/genesis.go @@ -1,11 +1,6 @@ package types -import ( - sharedtypes "github.com/pokt-network/poktroll/x/shared/types" -) - -// DefaultIndex is the default global index -const DefaultIndex uint64 = 1 +import sharedtypes "github.com/pokt-network/poktroll/x/shared/types" // DefaultGenesis returns the default genesis state func DefaultGenesis() *GenesisState { @@ -20,19 +15,19 @@ func DefaultGenesis() *GenesisState { // failure. func (gs GenesisState) Validate() error { // Check for duplicated index in services - serviceIDIndexMap := make(map[string]struct{}) - serviceNameIndexMap := make(map[string]struct{}) + serviceIDMap := make(map[string]struct{}) + serviceNameMap := make(map[string]struct{}) for _, service := range gs.ServiceList { - idIndex := string(ServiceKey(service.Id)) - if _, ok := serviceIDIndexMap[idIndex]; ok { + serviceID := string(ServiceKey(service.Id)) + if _, ok := serviceIDMap[serviceID]; ok { return ErrServiceDuplicateIndex.Wrapf("duplicated ID for service: %v", service) } - serviceIDIndexMap[idIndex] = struct{}{} - nameIndex := string(ServiceKey(service.Name)) - if _, ok := serviceNameIndexMap[nameIndex]; ok { + serviceIDMap[serviceID] = struct{}{} + serviceName := string(ServiceKey(service.Name)) + if _, ok := serviceNameMap[serviceName]; ok { return ErrServiceDuplicateIndex.Wrapf("duplicated name for service: %v", service) } - serviceNameIndexMap[nameIndex] = struct{}{} + serviceNameMap[serviceName] = struct{}{} } // this line is used by starport scaffolding # genesis/types/validate diff --git a/x/service/types/genesis_test.go b/x/service/types/genesis_test.go index 149d004e8..d6abdd42d 100644 --- a/x/service/types/genesis_test.go +++ b/x/service/types/genesis_test.go @@ -3,10 +3,10 @@ package types_test import ( "testing" + "github.com/stretchr/testify/require" + "github.com/pokt-network/poktroll/x/service/types" sharedtypes "github.com/pokt-network/poktroll/x/shared/types" - - "github.com/stretchr/testify/require" ) func TestGenesisState_Validate(t *testing.T) { @@ -22,18 +22,18 @@ func TestGenesisState_Validate(t *testing.T) { svc3 := &sharedtypes.Service{ Id: "svcId3", - Name: "svcName1", + Name: svc1.Name, } tests := []struct { - desc string - genState *types.GenesisState - expectedError error + desc string + genState *types.GenesisState + expectedErr error }{ { - desc: "default is valid", - genState: types.DefaultGenesis(), - expectedError: nil, + desc: "default is valid", + genState: types.DefaultGenesis(), + expectedErr: nil, }, { desc: "valid genesis state", @@ -44,7 +44,7 @@ func TestGenesisState_Validate(t *testing.T) { }, // this line is used by starport scaffolding # types/genesis/validField }, - expectedError: nil, + expectedErr: nil, }, { desc: "invalid - duplicate service ID", @@ -54,7 +54,7 @@ func TestGenesisState_Validate(t *testing.T) { *svc1, *svc1, }, }, - expectedError: types.ErrServiceDuplicateIndex, + expectedErr: types.ErrServiceDuplicateIndex, }, { desc: "invalid - duplicate service name", @@ -64,7 +64,7 @@ func TestGenesisState_Validate(t *testing.T) { *svc1, *svc3, }, }, - expectedError: types.ErrServiceDuplicateIndex, + expectedErr: types.ErrServiceDuplicateIndex, }, { desc: "invalid - invalid add service fee parameter (below minimum)", @@ -76,18 +76,18 @@ func TestGenesisState_Validate(t *testing.T) { *svc1, *svc2, }, }, - expectedError: types.ErrServiceInvalidServiceFee, + expectedErr: types.ErrServiceInvalidServiceFee, }, // this line is used by starport scaffolding # types/genesis/testcase } - for _, tc := range tests { - t.Run(tc.desc, func(t *testing.T) { - err := tc.genState.Validate() - if tc.expectedError == nil { + for _, test := range tests { + t.Run(test.desc, func(t *testing.T) { + err := test.genState.Validate() + if test.expectedErr == nil { require.NoError(t, err) } else { - require.ErrorIs(t, err, tc.expectedError) + require.ErrorIs(t, err, test.expectedErr) } }) } diff --git a/x/service/types/key_service.go b/x/service/types/key_service.go index cf6a10a79..168955896 100644 --- a/x/service/types/key_service.go +++ b/x/service/types/key_service.go @@ -6,7 +6,7 @@ var _ binary.ByteOrder const ( // ServiceKeyPrefix is the prefix to retrieve all Service - ServiceKeyPrefix = "Service/value/" + ServiceKeyPrefix = "Service/id/" ) // ServiceKey returns the store key to retrieve a Service from the index fields diff --git a/x/service/types/keys.go b/x/service/types/keys.go index 24ab75ebb..0025cbba8 100644 --- a/x/service/types/keys.go +++ b/x/service/types/keys.go @@ -11,10 +11,6 @@ const ( MemStoreKey = "mem_service" ) -var ( - ParamsKey = []byte("p_service") -) +var ParamsKey = []byte("p_service") -func KeyPrefix(p string) []byte { - return []byte(p) -} +func KeyPrefix(p string) []byte { return []byte(p) } diff --git a/x/service/types/message_add_service.go b/x/service/types/message_add_service.go index efd2d2f9f..eaed93489 100644 --- a/x/service/types/message_add_service.go +++ b/x/service/types/message_add_service.go @@ -21,9 +21,7 @@ func NewMsgAddService(address, serviceId, serviceName string) *MsgAddService { // ValidateBasic performs basic validation of the message and its fields func (msg *MsgAddService) ValidateBasic() error { if _, err := sdk.AccAddressFromBech32(msg.Address); err != nil { - return ErrServiceInvalidAddress.Wrapf( - "invalid supplier address %s; (%v)", msg.Address, err, - ) + return ErrServiceInvalidAddress.Wrapf("invalid supplier address %s; (%v)", msg.Address, err) } // TODO_TECHDEBT: Add a validate basic function to the `Service` object if msg.Service.Id == "" { diff --git a/x/service/types/message_add_service_test.go b/x/service/types/message_add_service_test.go index 6a44da578..05fd283c1 100644 --- a/x/service/types/message_add_service_test.go +++ b/x/service/types/message_add_service_test.go @@ -3,10 +3,10 @@ package types import ( "testing" + "github.com/stretchr/testify/require" + "github.com/pokt-network/poktroll/testutil/sample" sharedtypes "github.com/pokt-network/poktroll/x/shared/types" - - "github.com/stretchr/testify/require" ) func TestMsgAddService_ValidateBasic(t *testing.T) { @@ -45,11 +45,11 @@ func TestMsgAddService_ValidateBasic(t *testing.T) { expectedErr: nil, }, } - for _, tt := range tests { - t.Run(tt.desc, func(t *testing.T) { - err := tt.msg.ValidateBasic() - if tt.expectedErr != nil { - require.ErrorIs(t, err, tt.expectedErr) + for _, test := range tests { + t.Run(test.desc, func(t *testing.T) { + err := test.msg.ValidateBasic() + if test.expectedErr != nil { + require.ErrorIs(t, err, test.expectedErr) return } require.NoError(t, err) diff --git a/x/service/types/msg_update_params.go b/x/service/types/message_update_params.go similarity index 100% rename from x/service/types/msg_update_params.go rename to x/service/types/message_update_params.go diff --git a/x/service/types/params.go b/x/service/types/params.go index 90201e142..fd0b612ad 100644 --- a/x/service/types/params.go +++ b/x/service/types/params.go @@ -12,9 +12,9 @@ import ( // TODO_BLOCKER: Revisit default param values for service fee const DefaultAddServiceFee = 1000000000 // 1000 POKT -var _ paramtypes.ParamSet = (*Params)(nil) - var ( + _ paramtypes.ParamSet = (*Params)(nil) + KeyAddServiceFee = []byte("AddServiceFee") ) @@ -24,9 +24,7 @@ func ParamKeyTable() paramtypes.KeyTable { } // NewParams creates a new Params instance -func NewParams( - addServiceFee uint64, -) Params { +func NewParams(addServiceFee uint64) Params { return Params{ AddServiceFee: addServiceFee, } diff --git a/x/service/types/types.go b/x/service/types/types.go index ab1254f4c..78d9ec9f9 100644 --- a/x/service/types/types.go +++ b/x/service/types/types.go @@ -1 +1,3 @@ package types + +// This file is in place to declare the package for dynamically generated protobufs