From eb01537f3c8dc816d284fdda5bbb86ec8840a1d7 Mon Sep 17 00:00:00 2001 From: Callum Waters Date: Fri, 21 Jan 2022 15:55:17 +0100 Subject: [PATCH] feat: add feegrant query to see allowances from a given granter (#10947) --- CHANGELOG.md | 1 + api/cosmos/feegrant/v1beta1/query.pulsar.go | 1341 +++++++++++++++++- api/cosmos/feegrant/v1beta1/query_grpc.pb.go | 40 + proto/cosmos/feegrant/v1beta1/query.proto | 23 + x/feegrant/client/cli/query.go | 56 +- x/feegrant/client/testutil/cli_test.go | 1 + x/feegrant/client/testutil/suite.go | 62 +- x/feegrant/keeper/grpc_query.go | 39 + x/feegrant/keeper/grpc_query_test.go | 66 + x/feegrant/key.go | 15 + x/feegrant/key_test.go | 25 + x/feegrant/query.pb.go | 580 +++++++- x/feegrant/query.pb.gw.go | 116 ++ 13 files changed, 2272 insertions(+), 93 deletions(-) create mode 100644 x/feegrant/key_test.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a6b9ffbfca4..9eafd98da196 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,6 +56,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * [\#10507](https://github.com/cosmos/cosmos-sdk/pull/10507) Add middleware for tx priority. * [\#10311](https://github.com/cosmos/cosmos-sdk/pull/10311) Adds cli to use tips transactions. It adds an `--aux` flag to all CLI tx commands to generate the aux signer data (with optional tip), and a new `tx aux-to-fee` subcommand to let the fee payer gather aux signer data and broadcast the tx * [\#10430](https://github.com/cosmos/cosmos-sdk/pull/10430) ADR-040: Add store/v2 `MultiStore` implementation +* [\#10947](https://github.com/cosmos/cosmos-sdk/pull/10947) Add `AllowancesByGranter` query to the feegrant module ### API Breaking Changes diff --git a/api/cosmos/feegrant/v1beta1/query.pulsar.go b/api/cosmos/feegrant/v1beta1/query.pulsar.go index 72ea84bcf31b..9afb842b0963 100644 --- a/api/cosmos/feegrant/v1beta1/query.pulsar.go +++ b/api/cosmos/feegrant/v1beta1/query.pulsar.go @@ -2005,6 +2005,1078 @@ func (x *fastReflection_QueryAllowancesResponse) ProtoMethods() *protoiface.Meth } } +var ( + md_QueryAllowancesByGranterRequest protoreflect.MessageDescriptor + fd_QueryAllowancesByGranterRequest_granter protoreflect.FieldDescriptor + fd_QueryAllowancesByGranterRequest_pagination protoreflect.FieldDescriptor +) + +func init() { + file_cosmos_feegrant_v1beta1_query_proto_init() + md_QueryAllowancesByGranterRequest = File_cosmos_feegrant_v1beta1_query_proto.Messages().ByName("QueryAllowancesByGranterRequest") + fd_QueryAllowancesByGranterRequest_granter = md_QueryAllowancesByGranterRequest.Fields().ByName("granter") + fd_QueryAllowancesByGranterRequest_pagination = md_QueryAllowancesByGranterRequest.Fields().ByName("pagination") +} + +var _ protoreflect.Message = (*fastReflection_QueryAllowancesByGranterRequest)(nil) + +type fastReflection_QueryAllowancesByGranterRequest QueryAllowancesByGranterRequest + +func (x *QueryAllowancesByGranterRequest) ProtoReflect() protoreflect.Message { + return (*fastReflection_QueryAllowancesByGranterRequest)(x) +} + +func (x *QueryAllowancesByGranterRequest) slowProtoReflect() protoreflect.Message { + mi := &file_cosmos_feegrant_v1beta1_query_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_QueryAllowancesByGranterRequest_messageType fastReflection_QueryAllowancesByGranterRequest_messageType +var _ protoreflect.MessageType = fastReflection_QueryAllowancesByGranterRequest_messageType{} + +type fastReflection_QueryAllowancesByGranterRequest_messageType struct{} + +func (x fastReflection_QueryAllowancesByGranterRequest_messageType) Zero() protoreflect.Message { + return (*fastReflection_QueryAllowancesByGranterRequest)(nil) +} +func (x fastReflection_QueryAllowancesByGranterRequest_messageType) New() protoreflect.Message { + return new(fastReflection_QueryAllowancesByGranterRequest) +} +func (x fastReflection_QueryAllowancesByGranterRequest_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_QueryAllowancesByGranterRequest +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_QueryAllowancesByGranterRequest) Descriptor() protoreflect.MessageDescriptor { + return md_QueryAllowancesByGranterRequest +} + +// 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_QueryAllowancesByGranterRequest) Type() protoreflect.MessageType { + return _fastReflection_QueryAllowancesByGranterRequest_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_QueryAllowancesByGranterRequest) New() protoreflect.Message { + return new(fastReflection_QueryAllowancesByGranterRequest) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_QueryAllowancesByGranterRequest) Interface() protoreflect.ProtoMessage { + return (*QueryAllowancesByGranterRequest)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_QueryAllowancesByGranterRequest) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Granter != "" { + value := protoreflect.ValueOfString(x.Granter) + if !f(fd_QueryAllowancesByGranterRequest_granter, value) { + return + } + } + if x.Pagination != nil { + value := protoreflect.ValueOfMessage(x.Pagination.ProtoReflect()) + if !f(fd_QueryAllowancesByGranterRequest_pagination, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_QueryAllowancesByGranterRequest) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "cosmos.feegrant.v1beta1.QueryAllowancesByGranterRequest.granter": + return x.Granter != "" + case "cosmos.feegrant.v1beta1.QueryAllowancesByGranterRequest.pagination": + return x.Pagination != nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.feegrant.v1beta1.QueryAllowancesByGranterRequest")) + } + panic(fmt.Errorf("message cosmos.feegrant.v1beta1.QueryAllowancesByGranterRequest does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_QueryAllowancesByGranterRequest) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "cosmos.feegrant.v1beta1.QueryAllowancesByGranterRequest.granter": + x.Granter = "" + case "cosmos.feegrant.v1beta1.QueryAllowancesByGranterRequest.pagination": + x.Pagination = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.feegrant.v1beta1.QueryAllowancesByGranterRequest")) + } + panic(fmt.Errorf("message cosmos.feegrant.v1beta1.QueryAllowancesByGranterRequest does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_QueryAllowancesByGranterRequest) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "cosmos.feegrant.v1beta1.QueryAllowancesByGranterRequest.granter": + value := x.Granter + return protoreflect.ValueOfString(value) + case "cosmos.feegrant.v1beta1.QueryAllowancesByGranterRequest.pagination": + value := x.Pagination + return protoreflect.ValueOfMessage(value.ProtoReflect()) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.feegrant.v1beta1.QueryAllowancesByGranterRequest")) + } + panic(fmt.Errorf("message cosmos.feegrant.v1beta1.QueryAllowancesByGranterRequest does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_QueryAllowancesByGranterRequest) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "cosmos.feegrant.v1beta1.QueryAllowancesByGranterRequest.granter": + x.Granter = value.Interface().(string) + case "cosmos.feegrant.v1beta1.QueryAllowancesByGranterRequest.pagination": + x.Pagination = value.Message().Interface().(*v1beta1.PageRequest) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.feegrant.v1beta1.QueryAllowancesByGranterRequest")) + } + panic(fmt.Errorf("message cosmos.feegrant.v1beta1.QueryAllowancesByGranterRequest does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_QueryAllowancesByGranterRequest) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.feegrant.v1beta1.QueryAllowancesByGranterRequest.pagination": + if x.Pagination == nil { + x.Pagination = new(v1beta1.PageRequest) + } + return protoreflect.ValueOfMessage(x.Pagination.ProtoReflect()) + case "cosmos.feegrant.v1beta1.QueryAllowancesByGranterRequest.granter": + panic(fmt.Errorf("field granter of message cosmos.feegrant.v1beta1.QueryAllowancesByGranterRequest is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.feegrant.v1beta1.QueryAllowancesByGranterRequest")) + } + panic(fmt.Errorf("message cosmos.feegrant.v1beta1.QueryAllowancesByGranterRequest 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_QueryAllowancesByGranterRequest) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.feegrant.v1beta1.QueryAllowancesByGranterRequest.granter": + return protoreflect.ValueOfString("") + case "cosmos.feegrant.v1beta1.QueryAllowancesByGranterRequest.pagination": + m := new(v1beta1.PageRequest) + return protoreflect.ValueOfMessage(m.ProtoReflect()) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.feegrant.v1beta1.QueryAllowancesByGranterRequest")) + } + panic(fmt.Errorf("message cosmos.feegrant.v1beta1.QueryAllowancesByGranterRequest 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_QueryAllowancesByGranterRequest) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.feegrant.v1beta1.QueryAllowancesByGranterRequest", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_QueryAllowancesByGranterRequest) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_QueryAllowancesByGranterRequest) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_QueryAllowancesByGranterRequest) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_QueryAllowancesByGranterRequest) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*QueryAllowancesByGranterRequest) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + l = len(x.Granter) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.Pagination != nil { + l = options.Size(x.Pagination) + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*QueryAllowancesByGranterRequest) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if x.Pagination != nil { + encoded, err := options.Marshal(x.Pagination) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x12 + } + if len(x.Granter) > 0 { + i -= len(x.Granter) + copy(dAtA[i:], x.Granter) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Granter))) + i-- + dAtA[i] = 0xa + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*QueryAllowancesByGranterRequest) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: QueryAllowancesByGranterRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: QueryAllowancesByGranterRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Granter", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Granter = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if x.Pagination == nil { + x.Pagination = &v1beta1.PageRequest{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Pagination); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +var _ protoreflect.List = (*_QueryAllowancesByGranterResponse_1_list)(nil) + +type _QueryAllowancesByGranterResponse_1_list struct { + list *[]*Grant +} + +func (x *_QueryAllowancesByGranterResponse_1_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_QueryAllowancesByGranterResponse_1_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfMessage((*x.list)[i].ProtoReflect()) +} + +func (x *_QueryAllowancesByGranterResponse_1_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*Grant) + (*x.list)[i] = concreteValue +} + +func (x *_QueryAllowancesByGranterResponse_1_list) Append(value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*Grant) + *x.list = append(*x.list, concreteValue) +} + +func (x *_QueryAllowancesByGranterResponse_1_list) AppendMutable() protoreflect.Value { + v := new(Grant) + *x.list = append(*x.list, v) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_QueryAllowancesByGranterResponse_1_list) Truncate(n int) { + for i := n; i < len(*x.list); i++ { + (*x.list)[i] = nil + } + *x.list = (*x.list)[:n] +} + +func (x *_QueryAllowancesByGranterResponse_1_list) NewElement() protoreflect.Value { + v := new(Grant) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_QueryAllowancesByGranterResponse_1_list) IsValid() bool { + return x.list != nil +} + +var ( + md_QueryAllowancesByGranterResponse protoreflect.MessageDescriptor + fd_QueryAllowancesByGranterResponse_allowances protoreflect.FieldDescriptor + fd_QueryAllowancesByGranterResponse_pagination protoreflect.FieldDescriptor +) + +func init() { + file_cosmos_feegrant_v1beta1_query_proto_init() + md_QueryAllowancesByGranterResponse = File_cosmos_feegrant_v1beta1_query_proto.Messages().ByName("QueryAllowancesByGranterResponse") + fd_QueryAllowancesByGranterResponse_allowances = md_QueryAllowancesByGranterResponse.Fields().ByName("allowances") + fd_QueryAllowancesByGranterResponse_pagination = md_QueryAllowancesByGranterResponse.Fields().ByName("pagination") +} + +var _ protoreflect.Message = (*fastReflection_QueryAllowancesByGranterResponse)(nil) + +type fastReflection_QueryAllowancesByGranterResponse QueryAllowancesByGranterResponse + +func (x *QueryAllowancesByGranterResponse) ProtoReflect() protoreflect.Message { + return (*fastReflection_QueryAllowancesByGranterResponse)(x) +} + +func (x *QueryAllowancesByGranterResponse) slowProtoReflect() protoreflect.Message { + mi := &file_cosmos_feegrant_v1beta1_query_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_QueryAllowancesByGranterResponse_messageType fastReflection_QueryAllowancesByGranterResponse_messageType +var _ protoreflect.MessageType = fastReflection_QueryAllowancesByGranterResponse_messageType{} + +type fastReflection_QueryAllowancesByGranterResponse_messageType struct{} + +func (x fastReflection_QueryAllowancesByGranterResponse_messageType) Zero() protoreflect.Message { + return (*fastReflection_QueryAllowancesByGranterResponse)(nil) +} +func (x fastReflection_QueryAllowancesByGranterResponse_messageType) New() protoreflect.Message { + return new(fastReflection_QueryAllowancesByGranterResponse) +} +func (x fastReflection_QueryAllowancesByGranterResponse_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_QueryAllowancesByGranterResponse +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_QueryAllowancesByGranterResponse) Descriptor() protoreflect.MessageDescriptor { + return md_QueryAllowancesByGranterResponse +} + +// 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_QueryAllowancesByGranterResponse) Type() protoreflect.MessageType { + return _fastReflection_QueryAllowancesByGranterResponse_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_QueryAllowancesByGranterResponse) New() protoreflect.Message { + return new(fastReflection_QueryAllowancesByGranterResponse) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_QueryAllowancesByGranterResponse) Interface() protoreflect.ProtoMessage { + return (*QueryAllowancesByGranterResponse)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_QueryAllowancesByGranterResponse) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if len(x.Allowances) != 0 { + value := protoreflect.ValueOfList(&_QueryAllowancesByGranterResponse_1_list{list: &x.Allowances}) + if !f(fd_QueryAllowancesByGranterResponse_allowances, value) { + return + } + } + if x.Pagination != nil { + value := protoreflect.ValueOfMessage(x.Pagination.ProtoReflect()) + if !f(fd_QueryAllowancesByGranterResponse_pagination, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_QueryAllowancesByGranterResponse) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "cosmos.feegrant.v1beta1.QueryAllowancesByGranterResponse.allowances": + return len(x.Allowances) != 0 + case "cosmos.feegrant.v1beta1.QueryAllowancesByGranterResponse.pagination": + return x.Pagination != nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.feegrant.v1beta1.QueryAllowancesByGranterResponse")) + } + panic(fmt.Errorf("message cosmos.feegrant.v1beta1.QueryAllowancesByGranterResponse does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_QueryAllowancesByGranterResponse) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "cosmos.feegrant.v1beta1.QueryAllowancesByGranterResponse.allowances": + x.Allowances = nil + case "cosmos.feegrant.v1beta1.QueryAllowancesByGranterResponse.pagination": + x.Pagination = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.feegrant.v1beta1.QueryAllowancesByGranterResponse")) + } + panic(fmt.Errorf("message cosmos.feegrant.v1beta1.QueryAllowancesByGranterResponse does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_QueryAllowancesByGranterResponse) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "cosmos.feegrant.v1beta1.QueryAllowancesByGranterResponse.allowances": + if len(x.Allowances) == 0 { + return protoreflect.ValueOfList(&_QueryAllowancesByGranterResponse_1_list{}) + } + listValue := &_QueryAllowancesByGranterResponse_1_list{list: &x.Allowances} + return protoreflect.ValueOfList(listValue) + case "cosmos.feegrant.v1beta1.QueryAllowancesByGranterResponse.pagination": + value := x.Pagination + return protoreflect.ValueOfMessage(value.ProtoReflect()) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.feegrant.v1beta1.QueryAllowancesByGranterResponse")) + } + panic(fmt.Errorf("message cosmos.feegrant.v1beta1.QueryAllowancesByGranterResponse does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_QueryAllowancesByGranterResponse) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "cosmos.feegrant.v1beta1.QueryAllowancesByGranterResponse.allowances": + lv := value.List() + clv := lv.(*_QueryAllowancesByGranterResponse_1_list) + x.Allowances = *clv.list + case "cosmos.feegrant.v1beta1.QueryAllowancesByGranterResponse.pagination": + x.Pagination = value.Message().Interface().(*v1beta1.PageResponse) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.feegrant.v1beta1.QueryAllowancesByGranterResponse")) + } + panic(fmt.Errorf("message cosmos.feegrant.v1beta1.QueryAllowancesByGranterResponse does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_QueryAllowancesByGranterResponse) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.feegrant.v1beta1.QueryAllowancesByGranterResponse.allowances": + if x.Allowances == nil { + x.Allowances = []*Grant{} + } + value := &_QueryAllowancesByGranterResponse_1_list{list: &x.Allowances} + return protoreflect.ValueOfList(value) + case "cosmos.feegrant.v1beta1.QueryAllowancesByGranterResponse.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: cosmos.feegrant.v1beta1.QueryAllowancesByGranterResponse")) + } + panic(fmt.Errorf("message cosmos.feegrant.v1beta1.QueryAllowancesByGranterResponse 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_QueryAllowancesByGranterResponse) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.feegrant.v1beta1.QueryAllowancesByGranterResponse.allowances": + list := []*Grant{} + return protoreflect.ValueOfList(&_QueryAllowancesByGranterResponse_1_list{list: &list}) + case "cosmos.feegrant.v1beta1.QueryAllowancesByGranterResponse.pagination": + m := new(v1beta1.PageResponse) + return protoreflect.ValueOfMessage(m.ProtoReflect()) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.feegrant.v1beta1.QueryAllowancesByGranterResponse")) + } + panic(fmt.Errorf("message cosmos.feegrant.v1beta1.QueryAllowancesByGranterResponse 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_QueryAllowancesByGranterResponse) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.feegrant.v1beta1.QueryAllowancesByGranterResponse", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_QueryAllowancesByGranterResponse) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_QueryAllowancesByGranterResponse) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_QueryAllowancesByGranterResponse) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_QueryAllowancesByGranterResponse) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*QueryAllowancesByGranterResponse) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + if len(x.Allowances) > 0 { + for _, e := range x.Allowances { + l = options.Size(e) + n += 1 + l + runtime.Sov(uint64(l)) + } + } + if x.Pagination != nil { + l = options.Size(x.Pagination) + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*QueryAllowancesByGranterResponse) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if x.Pagination != nil { + encoded, err := options.Marshal(x.Pagination) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x12 + } + if len(x.Allowances) > 0 { + for iNdEx := len(x.Allowances) - 1; iNdEx >= 0; iNdEx-- { + encoded, err := options.Marshal(x.Allowances[iNdEx]) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0xa + } + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*QueryAllowancesByGranterResponse) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: QueryAllowancesByGranterResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: QueryAllowancesByGranterResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Allowances", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Allowances = append(x.Allowances, &Grant{}) + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Allowances[len(x.Allowances)-1]); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if x.Pagination == nil { + x.Pagination = &v1beta1.PageResponse{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Pagination); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + // Since: cosmos-sdk 0.43 // Code generated by protoc-gen-go. DO NOT EDIT. @@ -2194,6 +3266,97 @@ func (x *QueryAllowancesResponse) GetPagination() *v1beta1.PageResponse { return nil } +// QueryAllowancesByGranterRequest is the request type for the Query/AllowancesByGranter RPC method. +type QueryAllowancesByGranterRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Granter string `protobuf:"bytes,1,opt,name=granter,proto3" json:"granter,omitempty"` + // pagination defines an pagination for the request. + Pagination *v1beta1.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (x *QueryAllowancesByGranterRequest) Reset() { + *x = QueryAllowancesByGranterRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_feegrant_v1beta1_query_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *QueryAllowancesByGranterRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*QueryAllowancesByGranterRequest) ProtoMessage() {} + +// Deprecated: Use QueryAllowancesByGranterRequest.ProtoReflect.Descriptor instead. +func (*QueryAllowancesByGranterRequest) Descriptor() ([]byte, []int) { + return file_cosmos_feegrant_v1beta1_query_proto_rawDescGZIP(), []int{4} +} + +func (x *QueryAllowancesByGranterRequest) GetGranter() string { + if x != nil { + return x.Granter + } + return "" +} + +func (x *QueryAllowancesByGranterRequest) GetPagination() *v1beta1.PageRequest { + if x != nil { + return x.Pagination + } + return nil +} + +// QueryAllowancesByGranterResponse is the response type for the Query/AllowancesByGranter RPC method. +type QueryAllowancesByGranterResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // allowances that have been issued by the granter. + Allowances []*Grant `protobuf:"bytes,1,rep,name=allowances,proto3" json:"allowances,omitempty"` + // pagination defines an pagination for the response. + Pagination *v1beta1.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (x *QueryAllowancesByGranterResponse) Reset() { + *x = QueryAllowancesByGranterResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_feegrant_v1beta1_query_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *QueryAllowancesByGranterResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*QueryAllowancesByGranterResponse) ProtoMessage() {} + +// Deprecated: Use QueryAllowancesByGranterResponse.ProtoReflect.Descriptor instead. +func (*QueryAllowancesByGranterResponse) Descriptor() ([]byte, []int) { + return file_cosmos_feegrant_v1beta1_query_proto_rawDescGZIP(), []int{5} +} + +func (x *QueryAllowancesByGranterResponse) GetAllowances() []*Grant { + if x != nil { + return x.Allowances + } + return nil +} + +func (x *QueryAllowancesByGranterResponse) GetPagination() *v1beta1.PageResponse { + if x != nil { + return x.Pagination + } + return nil +} + var File_cosmos_feegrant_v1beta1_query_proto protoreflect.FileDescriptor var file_cosmos_feegrant_v1beta1_query_proto_rawDesc = []byte{ @@ -2243,44 +3406,77 @@ var file_cosmos_feegrant_v1beta1_query_proto_rawDesc = []byte{ 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, 0xdf, 0x02, 0x0a, 0x05, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0xac, 0x01, 0x0a, 0x09, 0x41, - 0x6c, 0x6c, 0x6f, 0x77, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x2e, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x2e, 0x66, 0x65, 0x65, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, - 0x61, 0x31, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x41, 0x6c, 0x6c, 0x6f, 0x77, 0x61, 0x6e, 0x63, - 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2f, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x2e, 0x66, 0x65, 0x65, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, - 0x61, 0x31, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x41, 0x6c, 0x6c, 0x6f, 0x77, 0x61, 0x6e, 0x63, - 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x3e, 0x82, 0xd3, 0xe4, 0x93, 0x02, - 0x38, 0x12, 0x36, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x66, 0x65, 0x65, 0x67, 0x72, + 0x22, 0x9d, 0x01, 0x0a, 0x1f, 0x51, 0x75, 0x65, 0x72, 0x79, 0x41, 0x6c, 0x6c, 0x6f, 0x77, 0x61, + 0x6e, 0x63, 0x65, 0x73, 0x42, 0x79, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x32, 0x0a, 0x07, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x65, 0x72, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, + 0x07, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x65, 0x72, 0x12, 0x46, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x69, + 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 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, 0xab, 0x01, 0x0a, 0x20, 0x51, 0x75, 0x65, 0x72, 0x79, 0x41, 0x6c, 0x6c, 0x6f, 0x77, 0x61, + 0x6e, 0x63, 0x65, 0x73, 0x42, 0x79, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3e, 0x0a, 0x0a, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x61, 0x6e, + 0x63, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x2e, 0x66, 0x65, 0x65, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, + 0x74, 0x61, 0x31, 0x2e, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x52, 0x0a, 0x61, 0x6c, 0x6c, 0x6f, 0x77, + 0x61, 0x6e, 0x63, 0x65, 0x73, 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, 0x9f, + 0x04, 0x0a, 0x05, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0xac, 0x01, 0x0a, 0x09, 0x41, 0x6c, 0x6c, + 0x6f, 0x77, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x2e, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, + 0x66, 0x65, 0x65, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, + 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x41, 0x6c, 0x6c, 0x6f, 0x77, 0x61, 0x6e, 0x63, 0x65, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2f, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, + 0x66, 0x65, 0x65, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, + 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x41, 0x6c, 0x6c, 0x6f, 0x77, 0x61, 0x6e, 0x63, 0x65, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x3e, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x38, 0x12, + 0x36, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x66, 0x65, 0x65, 0x67, 0x72, 0x61, 0x6e, + 0x74, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x61, + 0x6e, 0x63, 0x65, 0x2f, 0x7b, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x65, 0x72, 0x7d, 0x2f, 0x7b, 0x67, + 0x72, 0x61, 0x6e, 0x74, 0x65, 0x65, 0x7d, 0x12, 0xa6, 0x01, 0x0a, 0x0a, 0x41, 0x6c, 0x6c, 0x6f, + 0x77, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x12, 0x2f, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, + 0x66, 0x65, 0x65, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, + 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x41, 0x6c, 0x6c, 0x6f, 0x77, 0x61, 0x6e, 0x63, 0x65, 0x73, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x2e, 0x66, 0x65, 0x65, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, + 0x31, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x41, 0x6c, 0x6c, 0x6f, 0x77, 0x61, 0x6e, 0x63, 0x65, + 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x35, 0x82, 0xd3, 0xe4, 0x93, 0x02, + 0x2f, 0x12, 0x2d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x66, 0x65, 0x65, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x61, 0x6c, 0x6c, 0x6f, - 0x77, 0x61, 0x6e, 0x63, 0x65, 0x2f, 0x7b, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x65, 0x72, 0x7d, 0x2f, - 0x7b, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x65, 0x65, 0x7d, 0x12, 0xa6, 0x01, 0x0a, 0x0a, 0x41, 0x6c, - 0x6c, 0x6f, 0x77, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x12, 0x2f, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x77, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x2f, 0x7b, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x65, 0x65, 0x7d, + 0x12, 0xbd, 0x01, 0x0a, 0x13, 0x41, 0x6c, 0x6c, 0x6f, 0x77, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x42, + 0x79, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x65, 0x72, 0x12, 0x38, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x66, 0x65, 0x65, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x41, 0x6c, 0x6c, 0x6f, 0x77, 0x61, 0x6e, 0x63, - 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, 0x2e, 0x63, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x2e, 0x66, 0x65, 0x65, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, - 0x74, 0x61, 0x31, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x41, 0x6c, 0x6c, 0x6f, 0x77, 0x61, 0x6e, - 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x35, 0x82, 0xd3, 0xe4, - 0x93, 0x02, 0x2f, 0x12, 0x2d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x66, 0x65, 0x65, - 0x67, 0x72, 0x61, 0x6e, 0x74, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x61, 0x6c, - 0x6c, 0x6f, 0x77, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x2f, 0x7b, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x65, - 0x65, 0x7d, 0x42, 0xf1, 0x01, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x2e, 0x66, 0x65, 0x65, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, - 0x61, 0x31, 0x42, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, - 0x5a, 0x48, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, - 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x66, 0x65, 0x65, 0x67, 0x72, 0x61, - 0x6e, 0x74, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x66, 0x65, 0x65, 0x67, 0x72, - 0x61, 0x6e, 0x74, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x46, 0x58, - 0xaa, 0x02, 0x17, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x46, 0x65, 0x65, 0x67, 0x72, 0x61, - 0x6e, 0x74, 0x2e, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xca, 0x02, 0x17, 0x43, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x5c, 0x46, 0x65, 0x65, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x5c, 0x56, 0x31, 0x62, - 0x65, 0x74, 0x61, 0x31, 0xe2, 0x02, 0x23, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x46, 0x65, - 0x65, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x5c, 0x47, - 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x19, 0x43, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x46, 0x65, 0x65, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x3a, 0x3a, 0x56, - 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x73, 0x42, 0x79, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x39, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x66, 0x65, 0x65, 0x67, + 0x72, 0x61, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x51, 0x75, 0x65, + 0x72, 0x79, 0x41, 0x6c, 0x6c, 0x6f, 0x77, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x42, 0x79, 0x47, 0x72, + 0x61, 0x6e, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x31, 0x82, + 0xd3, 0xe4, 0x93, 0x02, 0x2b, 0x12, 0x29, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x66, + 0x65, 0x65, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, + 0x69, 0x73, 0x73, 0x75, 0x65, 0x64, 0x2f, 0x7b, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x65, 0x72, 0x7d, + 0x42, 0xf1, 0x01, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, + 0x66, 0x65, 0x65, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, + 0x42, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x48, + 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, + 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x66, 0x65, 0x65, 0x67, 0x72, 0x61, 0x6e, 0x74, + 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x66, 0x65, 0x65, 0x67, 0x72, 0x61, 0x6e, + 0x74, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x46, 0x58, 0xaa, 0x02, + 0x17, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x46, 0x65, 0x65, 0x67, 0x72, 0x61, 0x6e, 0x74, + 0x2e, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xca, 0x02, 0x17, 0x43, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x5c, 0x46, 0x65, 0x65, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, + 0x61, 0x31, 0xe2, 0x02, 0x23, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x46, 0x65, 0x65, 0x67, + 0x72, 0x61, 0x6e, 0x74, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, + 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x19, 0x43, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x3a, 0x3a, 0x46, 0x65, 0x65, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x3a, 0x3a, 0x56, 0x31, 0x62, + 0x65, 0x74, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -2295,30 +3491,37 @@ func file_cosmos_feegrant_v1beta1_query_proto_rawDescGZIP() []byte { return file_cosmos_feegrant_v1beta1_query_proto_rawDescData } -var file_cosmos_feegrant_v1beta1_query_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_cosmos_feegrant_v1beta1_query_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_cosmos_feegrant_v1beta1_query_proto_goTypes = []interface{}{ - (*QueryAllowanceRequest)(nil), // 0: cosmos.feegrant.v1beta1.QueryAllowanceRequest - (*QueryAllowanceResponse)(nil), // 1: cosmos.feegrant.v1beta1.QueryAllowanceResponse - (*QueryAllowancesRequest)(nil), // 2: cosmos.feegrant.v1beta1.QueryAllowancesRequest - (*QueryAllowancesResponse)(nil), // 3: cosmos.feegrant.v1beta1.QueryAllowancesResponse - (*Grant)(nil), // 4: cosmos.feegrant.v1beta1.Grant - (*v1beta1.PageRequest)(nil), // 5: cosmos.base.query.v1beta1.PageRequest - (*v1beta1.PageResponse)(nil), // 6: cosmos.base.query.v1beta1.PageResponse + (*QueryAllowanceRequest)(nil), // 0: cosmos.feegrant.v1beta1.QueryAllowanceRequest + (*QueryAllowanceResponse)(nil), // 1: cosmos.feegrant.v1beta1.QueryAllowanceResponse + (*QueryAllowancesRequest)(nil), // 2: cosmos.feegrant.v1beta1.QueryAllowancesRequest + (*QueryAllowancesResponse)(nil), // 3: cosmos.feegrant.v1beta1.QueryAllowancesResponse + (*QueryAllowancesByGranterRequest)(nil), // 4: cosmos.feegrant.v1beta1.QueryAllowancesByGranterRequest + (*QueryAllowancesByGranterResponse)(nil), // 5: cosmos.feegrant.v1beta1.QueryAllowancesByGranterResponse + (*Grant)(nil), // 6: cosmos.feegrant.v1beta1.Grant + (*v1beta1.PageRequest)(nil), // 7: cosmos.base.query.v1beta1.PageRequest + (*v1beta1.PageResponse)(nil), // 8: cosmos.base.query.v1beta1.PageResponse } var file_cosmos_feegrant_v1beta1_query_proto_depIdxs = []int32{ - 4, // 0: cosmos.feegrant.v1beta1.QueryAllowanceResponse.allowance:type_name -> cosmos.feegrant.v1beta1.Grant - 5, // 1: cosmos.feegrant.v1beta1.QueryAllowancesRequest.pagination:type_name -> cosmos.base.query.v1beta1.PageRequest - 4, // 2: cosmos.feegrant.v1beta1.QueryAllowancesResponse.allowances:type_name -> cosmos.feegrant.v1beta1.Grant - 6, // 3: cosmos.feegrant.v1beta1.QueryAllowancesResponse.pagination:type_name -> cosmos.base.query.v1beta1.PageResponse - 0, // 4: cosmos.feegrant.v1beta1.Query.Allowance:input_type -> cosmos.feegrant.v1beta1.QueryAllowanceRequest - 2, // 5: cosmos.feegrant.v1beta1.Query.Allowances:input_type -> cosmos.feegrant.v1beta1.QueryAllowancesRequest - 1, // 6: cosmos.feegrant.v1beta1.Query.Allowance:output_type -> cosmos.feegrant.v1beta1.QueryAllowanceResponse - 3, // 7: cosmos.feegrant.v1beta1.Query.Allowances:output_type -> cosmos.feegrant.v1beta1.QueryAllowancesResponse - 6, // [6:8] is the sub-list for method output_type - 4, // [4:6] is the sub-list for method input_type - 4, // [4:4] is the sub-list for extension type_name - 4, // [4:4] is the sub-list for extension extendee - 0, // [0:4] is the sub-list for field type_name + 6, // 0: cosmos.feegrant.v1beta1.QueryAllowanceResponse.allowance:type_name -> cosmos.feegrant.v1beta1.Grant + 7, // 1: cosmos.feegrant.v1beta1.QueryAllowancesRequest.pagination:type_name -> cosmos.base.query.v1beta1.PageRequest + 6, // 2: cosmos.feegrant.v1beta1.QueryAllowancesResponse.allowances:type_name -> cosmos.feegrant.v1beta1.Grant + 8, // 3: cosmos.feegrant.v1beta1.QueryAllowancesResponse.pagination:type_name -> cosmos.base.query.v1beta1.PageResponse + 7, // 4: cosmos.feegrant.v1beta1.QueryAllowancesByGranterRequest.pagination:type_name -> cosmos.base.query.v1beta1.PageRequest + 6, // 5: cosmos.feegrant.v1beta1.QueryAllowancesByGranterResponse.allowances:type_name -> cosmos.feegrant.v1beta1.Grant + 8, // 6: cosmos.feegrant.v1beta1.QueryAllowancesByGranterResponse.pagination:type_name -> cosmos.base.query.v1beta1.PageResponse + 0, // 7: cosmos.feegrant.v1beta1.Query.Allowance:input_type -> cosmos.feegrant.v1beta1.QueryAllowanceRequest + 2, // 8: cosmos.feegrant.v1beta1.Query.Allowances:input_type -> cosmos.feegrant.v1beta1.QueryAllowancesRequest + 4, // 9: cosmos.feegrant.v1beta1.Query.AllowancesByGranter:input_type -> cosmos.feegrant.v1beta1.QueryAllowancesByGranterRequest + 1, // 10: cosmos.feegrant.v1beta1.Query.Allowance:output_type -> cosmos.feegrant.v1beta1.QueryAllowanceResponse + 3, // 11: cosmos.feegrant.v1beta1.Query.Allowances:output_type -> cosmos.feegrant.v1beta1.QueryAllowancesResponse + 5, // 12: cosmos.feegrant.v1beta1.Query.AllowancesByGranter:output_type -> cosmos.feegrant.v1beta1.QueryAllowancesByGranterResponse + 10, // [10:13] is the sub-list for method output_type + 7, // [7:10] is the sub-list for method input_type + 7, // [7:7] is the sub-list for extension type_name + 7, // [7:7] is the sub-list for extension extendee + 0, // [0:7] is the sub-list for field type_name } func init() { file_cosmos_feegrant_v1beta1_query_proto_init() } @@ -2376,6 +3579,30 @@ func file_cosmos_feegrant_v1beta1_query_proto_init() { return nil } } + file_cosmos_feegrant_v1beta1_query_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*QueryAllowancesByGranterRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_cosmos_feegrant_v1beta1_query_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*QueryAllowancesByGranterResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -2383,7 +3610,7 @@ func file_cosmos_feegrant_v1beta1_query_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_cosmos_feegrant_v1beta1_query_proto_rawDesc, NumEnums: 0, - NumMessages: 4, + NumMessages: 6, NumExtensions: 0, NumServices: 1, }, diff --git a/api/cosmos/feegrant/v1beta1/query_grpc.pb.go b/api/cosmos/feegrant/v1beta1/query_grpc.pb.go index 9a2f1a95d742..64cef481bdaa 100644 --- a/api/cosmos/feegrant/v1beta1/query_grpc.pb.go +++ b/api/cosmos/feegrant/v1beta1/query_grpc.pb.go @@ -26,6 +26,9 @@ type QueryClient interface { Allowance(ctx context.Context, in *QueryAllowanceRequest, opts ...grpc.CallOption) (*QueryAllowanceResponse, error) // Allowances returns all the grants for address. Allowances(ctx context.Context, in *QueryAllowancesRequest, opts ...grpc.CallOption) (*QueryAllowancesResponse, error) + // AllowancesByGranter returns all the grants given by an address + // Since v0.46 + AllowancesByGranter(ctx context.Context, in *QueryAllowancesByGranterRequest, opts ...grpc.CallOption) (*QueryAllowancesByGranterResponse, error) } type queryClient struct { @@ -54,6 +57,15 @@ func (c *queryClient) Allowances(ctx context.Context, in *QueryAllowancesRequest return out, nil } +func (c *queryClient) AllowancesByGranter(ctx context.Context, in *QueryAllowancesByGranterRequest, opts ...grpc.CallOption) (*QueryAllowancesByGranterResponse, error) { + out := new(QueryAllowancesByGranterResponse) + err := c.cc.Invoke(ctx, "/cosmos.feegrant.v1beta1.Query/AllowancesByGranter", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. // All implementations must embed UnimplementedQueryServer // for forward compatibility @@ -62,6 +74,9 @@ type QueryServer interface { Allowance(context.Context, *QueryAllowanceRequest) (*QueryAllowanceResponse, error) // Allowances returns all the grants for address. Allowances(context.Context, *QueryAllowancesRequest) (*QueryAllowancesResponse, error) + // AllowancesByGranter returns all the grants given by an address + // Since v0.46 + AllowancesByGranter(context.Context, *QueryAllowancesByGranterRequest) (*QueryAllowancesByGranterResponse, error) mustEmbedUnimplementedQueryServer() } @@ -75,6 +90,9 @@ func (UnimplementedQueryServer) Allowance(context.Context, *QueryAllowanceReques func (UnimplementedQueryServer) Allowances(context.Context, *QueryAllowancesRequest) (*QueryAllowancesResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Allowances not implemented") } +func (UnimplementedQueryServer) AllowancesByGranter(context.Context, *QueryAllowancesByGranterRequest) (*QueryAllowancesByGranterResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AllowancesByGranter not implemented") +} func (UnimplementedQueryServer) mustEmbedUnimplementedQueryServer() {} // UnsafeQueryServer may be embedded to opt out of forward compatibility for this service. @@ -124,6 +142,24 @@ func _Query_Allowances_Handler(srv interface{}, ctx context.Context, dec func(in return interceptor(ctx, in, info, handler) } +func _Query_AllowancesByGranter_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryAllowancesByGranterRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).AllowancesByGranter(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmos.feegrant.v1beta1.Query/AllowancesByGranter", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).AllowancesByGranter(ctx, req.(*QueryAllowancesByGranterRequest)) + } + return interceptor(ctx, in, info, handler) +} + // Query_ServiceDesc is the grpc.ServiceDesc for Query service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -139,6 +175,10 @@ var Query_ServiceDesc = grpc.ServiceDesc{ MethodName: "Allowances", Handler: _Query_Allowances_Handler, }, + { + MethodName: "AllowancesByGranter", + Handler: _Query_AllowancesByGranter_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "cosmos/feegrant/v1beta1/query.proto", diff --git a/proto/cosmos/feegrant/v1beta1/query.proto b/proto/cosmos/feegrant/v1beta1/query.proto index 69fef2e7eb19..59c992c911d6 100644 --- a/proto/cosmos/feegrant/v1beta1/query.proto +++ b/proto/cosmos/feegrant/v1beta1/query.proto @@ -21,6 +21,12 @@ service Query { rpc Allowances(QueryAllowancesRequest) returns (QueryAllowancesResponse) { option (google.api.http).get = "/cosmos/feegrant/v1beta1/allowances/{grantee}"; } + + // AllowancesByGranter returns all the grants given by an address + // Since v0.46 + rpc AllowancesByGranter(QueryAllowancesByGranterRequest) returns (QueryAllowancesByGranterResponse) { + option (google.api.http).get = "/cosmos/feegrant/v1beta1/issued/{granter}"; + } } // QueryAllowanceRequest is the request type for the Query/Allowance RPC method. @@ -54,3 +60,20 @@ message QueryAllowancesResponse { // pagination defines an pagination for the response. cosmos.base.query.v1beta1.PageResponse pagination = 2; } + +// QueryAllowancesByGranterRequest is the request type for the Query/AllowancesByGranter RPC method. +message QueryAllowancesByGranterRequest { + string granter = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + + // pagination defines an pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QueryAllowancesByGranterResponse is the response type for the Query/AllowancesByGranter RPC method. +message QueryAllowancesByGranterResponse { + // allowances that have been issued by the granter. + repeated cosmos.feegrant.v1beta1.Grant allowances = 1; + + // pagination defines an pagination for the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} diff --git a/x/feegrant/client/cli/query.go b/x/feegrant/client/cli/query.go index 93aab3765c37..66e26b328e18 100644 --- a/x/feegrant/client/cli/query.go +++ b/x/feegrant/client/cli/query.go @@ -25,7 +25,8 @@ func GetQueryCmd() *cobra.Command { feegrantQueryCmd.AddCommand( GetCmdQueryFeeGrant(), - GetCmdQueryFeeGrants(), + GetCmdQueryFeeGrantsByGrantee(), + GetCmdQueryFeeGrantsByGranter(), ) return feegrantQueryCmd @@ -80,8 +81,8 @@ $ %s query feegrant grant [granter] [grantee] return cmd } -// GetCmdQueryFeeGrants returns cmd to query for all grants for a grantee. -func GetCmdQueryFeeGrants() *cobra.Command { +// GetCmdQueryFeeGrantsByGrantee returns cmd to query for all grants for a grantee. +func GetCmdQueryFeeGrantsByGrantee() *cobra.Command { cmd := &cobra.Command{ Use: "grants [grantee]", Args: cobra.ExactArgs(1), @@ -128,3 +129,52 @@ $ %s query feegrant grants [grantee] return cmd } + +// GetCmdQueryFeeGrantsByGranter returns cmd to query for all grants by a granter. +func GetCmdQueryFeeGrantsByGranter() *cobra.Command { + cmd := &cobra.Command{ + Use: "grants [granter]", + Args: cobra.ExactArgs(1), + Short: "Query all grants by a granter", + Long: strings.TrimSpace( + fmt.Sprintf(`Queries all the grants issued for a granter address. + +Example: +$ %s query feegrant grants [granter] +`, version.AppName), + ), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + queryClient := feegrant.NewQueryClient(clientCtx) + + granterAddr, err := sdk.AccAddressFromBech32(args[0]) + if err != nil { + return err + } + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + res, err := queryClient.AllowancesByGranter( + cmd.Context(), + &feegrant.QueryAllowancesByGranterRequest{ + Granter: granterAddr.String(), + Pagination: pageReq, + }, + ) + + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + flags.AddPaginationFlagsToCmd(cmd, "grants") + + return cmd +} diff --git a/x/feegrant/client/testutil/cli_test.go b/x/feegrant/client/testutil/cli_test.go index bdbfb78d0bd1..9814e9573b3f 100644 --- a/x/feegrant/client/testutil/cli_test.go +++ b/x/feegrant/client/testutil/cli_test.go @@ -1,3 +1,4 @@ +//go:build norace // +build norace package testutil diff --git a/x/feegrant/client/testutil/suite.go b/x/feegrant/client/testutil/suite.go index 1439b73558f4..df6defaa1ca0 100644 --- a/x/feegrant/client/testutil/suite.go +++ b/x/feegrant/client/testutil/suite.go @@ -198,7 +198,7 @@ func (s *IntegrationTestSuite) TestCmdGetFeeGrant() { } } -func (s *IntegrationTestSuite) TestCmdGetFeeGrants() { +func (s *IntegrationTestSuite) TestCmdGetFeeGrantsByGrantee() { val := s.network.Validators[0] grantee := s.addedGrantee clientCtx := val.ClientCtx @@ -219,7 +219,7 @@ func (s *IntegrationTestSuite) TestCmdGetFeeGrants() { true, nil, 0, }, { - "non existed grantee", + "non existent grantee", []string{ "cosmos1nph3cfzk6trsmfxkeu943nvach5qw4vwstnvkl", fmt.Sprintf("--%s=json", tmcli.OutputFlag), @@ -240,7 +240,63 @@ func (s *IntegrationTestSuite) TestCmdGetFeeGrants() { tc := tc s.Run(tc.name, func() { - cmd := cli.GetCmdQueryFeeGrants() + cmd := cli.GetCmdQueryFeeGrantsByGrantee() + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) + + if tc.expectErr { + s.Require().Error(err) + } else { + s.Require().NoError(err) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.resp), out.String()) + s.Require().Len(tc.resp.Allowances, tc.expectLength) + } + }) + } +} + +func (s *IntegrationTestSuite) TestCmdGetFeeGrantsByGranter() { + val := s.network.Validators[0] + granter := s.addedGranter + clientCtx := val.ClientCtx + + testCases := []struct { + name string + args []string + expectErr bool + resp *feegrant.QueryAllowancesByGranterResponse + expectLength int + }{ + { + "wrong grantee", + []string{ + "wrong_grantee", + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + }, + true, nil, 0, + }, + { + "non existent grantee", + []string{ + "cosmos1nph3cfzk6trsmfxkeu943nvach5qw4vwstnvkl", + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + }, + false, &feegrant.QueryAllowancesByGranterResponse{}, 0, + }, + { + "valid req", + []string{ + granter.String(), + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + }, + false, &feegrant.QueryAllowancesByGranterResponse{}, 1, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := cli.GetCmdQueryFeeGrantsByGranter() out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) if tc.expectErr { diff --git a/x/feegrant/keeper/grpc_query.go b/x/feegrant/keeper/grpc_query.go index d8c23d0313cf..c439d0b73523 100644 --- a/x/feegrant/keeper/grpc_query.go +++ b/x/feegrant/keeper/grpc_query.go @@ -93,3 +93,42 @@ func (q Keeper) Allowances(c context.Context, req *feegrant.QueryAllowancesReque return &feegrant.QueryAllowancesResponse{Allowances: grants, Pagination: pageRes}, nil } + +// AllowancesByGranter queries all the allowances granted by the given granter +func (q Keeper) AllowancesByGranter(c context.Context, req *feegrant.QueryAllowancesByGranterRequest) (*feegrant.QueryAllowancesByGranterResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + granterAddr, err := sdk.AccAddressFromBech32(req.Granter) + if err != nil { + return nil, err + } + + ctx := sdk.UnwrapSDKContext(c) + + var grants []*feegrant.Grant + + store := ctx.KVStore(q.storeKey) + pageRes, err := query.Paginate(store, req.Pagination, func(key []byte, value []byte) error { + var grant feegrant.Grant + + granter, _ := feegrant.ParseAddressesFromFeeAllowanceKey(key) + if !granter.Equals(granterAddr) { + return nil + } + + if err := q.cdc.Unmarshal(value, &grant); err != nil { + return err + } + + grants = append(grants, &grant) + return nil + }) + + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + return &feegrant.QueryAllowancesByGranterResponse{Allowances: grants, Pagination: pageRes}, nil +} diff --git a/x/feegrant/keeper/grpc_query_test.go b/x/feegrant/keeper/grpc_query_test.go index 299b1b121eed..cf813d1c19f5 100644 --- a/x/feegrant/keeper/grpc_query_test.go +++ b/x/feegrant/keeper/grpc_query_test.go @@ -148,6 +148,72 @@ func (suite *KeeperTestSuite) TestFeeAllowances() { } } +func (suite *KeeperTestSuite) TestFeeAllowancesByGranter() { + testCases := []struct { + name string + req *feegrant.QueryAllowancesByGranterRequest + expectErr bool + preRun func() + postRun func(_ *feegrant.QueryAllowancesByGranterResponse) + }{ + { + "nil request", + nil, + true, + func() {}, + func(*feegrant.QueryAllowancesByGranterResponse) {}, + }, + { + "fail: invalid grantee", + &feegrant.QueryAllowancesByGranterRequest{ + Granter: "invalid_grantee", + }, + true, + func() {}, + func(*feegrant.QueryAllowancesByGranterResponse) {}, + }, + { + "no grants", + &feegrant.QueryAllowancesByGranterRequest{ + Granter: suite.addrs[0].String(), + }, + false, + func() {}, + func(resp *feegrant.QueryAllowancesByGranterResponse) { + suite.Require().Equal(len(resp.Allowances), 0) + }, + }, + { + "valid query: expect single grant", + &feegrant.QueryAllowancesByGranterRequest{ + Granter: suite.addrs[0].String(), + }, + false, + func() { + grantFeeAllowance(suite) + }, + func(resp *feegrant.QueryAllowancesByGranterResponse) { + suite.Require().Equal(len(resp.Allowances), 1) + suite.Require().Equal(resp.Allowances[0].Granter, suite.addrs[0].String()) + suite.Require().Equal(resp.Allowances[0].Grantee, suite.addrs[1].String()) + }, + }, + } + + for _, tc := range testCases { + suite.Run(tc.name, func() { + tc.preRun() + resp, err := suite.keeper.AllowancesByGranter(suite.ctx, tc.req) + if tc.expectErr { + suite.Require().Error(err) + } else { + suite.Require().NoError(err) + tc.postRun(resp) + } + }) + } +} + func grantFeeAllowance(suite *KeeperTestSuite) { exp := suite.sdkCtx.BlockTime().AddDate(1, 0, 0) err := suite.app.FeeGrantKeeper.GrantAllowance(suite.sdkCtx, suite.addrs[0], suite.addrs[1], &feegrant.BasicAllowance{ diff --git a/x/feegrant/key.go b/x/feegrant/key.go index cfc885d9a7a1..70f6eaa44003 100644 --- a/x/feegrant/key.go +++ b/x/feegrant/key.go @@ -3,6 +3,7 @@ package feegrant import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/address" + "github.com/cosmos/cosmos-sdk/types/kv" ) const ( @@ -34,3 +35,17 @@ func FeeAllowanceKey(granter sdk.AccAddress, grantee sdk.AccAddress) []byte { func FeeAllowancePrefixByGrantee(grantee sdk.AccAddress) []byte { return append(FeeAllowanceKeyPrefix, address.MustLengthPrefix(grantee.Bytes())...) } + +func ParseAddressesFromFeeAllowanceKey(key []byte) (granter, grantee sdk.AccAddress) { + // key is of format: + // 0x00 + kv.AssertKeyAtLeastLength(key, 2) + granteeAddrLen := key[1] // remove prefix key + kv.AssertKeyAtLeastLength(key, int(2+granteeAddrLen)) + grantee = sdk.AccAddress(key[2 : 2+granteeAddrLen]) + granterAddrLen := int(key[2+granteeAddrLen]) + kv.AssertKeyAtLeastLength(key, 3+int(granteeAddrLen+byte(granterAddrLen))) + granter = sdk.AccAddress(key[3+granterAddrLen : 3+granteeAddrLen+byte(granterAddrLen)]) + + return granter, grantee +} diff --git a/x/feegrant/key_test.go b/x/feegrant/key_test.go new file mode 100644 index 000000000000..75a7964bec32 --- /dev/null +++ b/x/feegrant/key_test.go @@ -0,0 +1,25 @@ +package feegrant_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/feegrant" +) + +func TestMarshalAndUnmarshalFeegrantKey(t *testing.T) { + grantee, err := sdk.AccAddressFromBech32("cosmos1qk93t4j0yyzgqgt6k5qf8deh8fq6smpn3ntu3x") + require.NoError(t, err) + granter, err := sdk.AccAddressFromBech32("cosmos1p9qh4ldfd6n0qehujsal4k7g0e37kel90rc4ts") + require.NoError(t, err) + + key := feegrant.FeeAllowanceKey(granter, grantee) + require.Len(t, key, len(grantee.Bytes())+len(granter.Bytes())+3) + require.Equal(t, feegrant.FeeAllowancePrefixByGrantee(grantee), key[:len(grantee.Bytes())+2]) + + g1, g2 := feegrant.ParseAddressesFromFeeAllowanceKey(key) + require.Equal(t, granter, g1) + require.Equal(t, grantee, g2) +} diff --git a/x/feegrant/query.pb.go b/x/feegrant/query.pb.go index c5e7ff342a94..d3038e9d5faa 100644 --- a/x/feegrant/query.pb.go +++ b/x/feegrant/query.pb.go @@ -240,11 +240,122 @@ func (m *QueryAllowancesResponse) GetPagination() *query.PageResponse { return nil } +// QueryAllowancesByGranterRequest is the request type for the Query/AllowancesByGranter RPC method. +type QueryAllowancesByGranterRequest struct { + Granter string `protobuf:"bytes,1,opt,name=granter,proto3" json:"granter,omitempty"` + // pagination defines an pagination for the request. + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryAllowancesByGranterRequest) Reset() { *m = QueryAllowancesByGranterRequest{} } +func (m *QueryAllowancesByGranterRequest) String() string { return proto.CompactTextString(m) } +func (*QueryAllowancesByGranterRequest) ProtoMessage() {} +func (*QueryAllowancesByGranterRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_59efc303945de53f, []int{4} +} +func (m *QueryAllowancesByGranterRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAllowancesByGranterRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAllowancesByGranterRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryAllowancesByGranterRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAllowancesByGranterRequest.Merge(m, src) +} +func (m *QueryAllowancesByGranterRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryAllowancesByGranterRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAllowancesByGranterRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAllowancesByGranterRequest proto.InternalMessageInfo + +func (m *QueryAllowancesByGranterRequest) GetGranter() string { + if m != nil { + return m.Granter + } + return "" +} + +func (m *QueryAllowancesByGranterRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryAllowancesByGranterResponse is the response type for the Query/AllowancesByGranter RPC method. +type QueryAllowancesByGranterResponse struct { + // allowances that have been issued by the granter. + Allowances []*Grant `protobuf:"bytes,1,rep,name=allowances,proto3" json:"allowances,omitempty"` + // pagination defines an pagination for the response. + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryAllowancesByGranterResponse) Reset() { *m = QueryAllowancesByGranterResponse{} } +func (m *QueryAllowancesByGranterResponse) String() string { return proto.CompactTextString(m) } +func (*QueryAllowancesByGranterResponse) ProtoMessage() {} +func (*QueryAllowancesByGranterResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_59efc303945de53f, []int{5} +} +func (m *QueryAllowancesByGranterResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAllowancesByGranterResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAllowancesByGranterResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryAllowancesByGranterResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAllowancesByGranterResponse.Merge(m, src) +} +func (m *QueryAllowancesByGranterResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryAllowancesByGranterResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAllowancesByGranterResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAllowancesByGranterResponse proto.InternalMessageInfo + +func (m *QueryAllowancesByGranterResponse) GetAllowances() []*Grant { + if m != nil { + return m.Allowances + } + return nil +} + +func (m *QueryAllowancesByGranterResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + func init() { proto.RegisterType((*QueryAllowanceRequest)(nil), "cosmos.feegrant.v1beta1.QueryAllowanceRequest") proto.RegisterType((*QueryAllowanceResponse)(nil), "cosmos.feegrant.v1beta1.QueryAllowanceResponse") proto.RegisterType((*QueryAllowancesRequest)(nil), "cosmos.feegrant.v1beta1.QueryAllowancesRequest") proto.RegisterType((*QueryAllowancesResponse)(nil), "cosmos.feegrant.v1beta1.QueryAllowancesResponse") + proto.RegisterType((*QueryAllowancesByGranterRequest)(nil), "cosmos.feegrant.v1beta1.QueryAllowancesByGranterRequest") + proto.RegisterType((*QueryAllowancesByGranterResponse)(nil), "cosmos.feegrant.v1beta1.QueryAllowancesByGranterResponse") } func init() { @@ -252,36 +363,40 @@ func init() { } var fileDescriptor_59efc303945de53f = []byte{ - // 461 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0x4f, 0x8b, 0x13, 0x31, - 0x18, 0xc6, 0x9b, 0x8a, 0x4a, 0xb3, 0xb7, 0xa0, 0xee, 0x38, 0xc8, 0xb0, 0x8c, 0xb0, 0x2b, 0x42, - 0x13, 0x77, 0x44, 0xf1, 0x20, 0x0b, 0xdd, 0x83, 0x7b, 0xd5, 0x11, 0x3c, 0x78, 0x91, 0x4c, 0xfb, - 0x3a, 0x0e, 0x76, 0x93, 0xd9, 0x49, 0xea, 0x1f, 0x64, 0x11, 0xfc, 0x04, 0x82, 0x7e, 0x02, 0x0f, - 0x9e, 0x3c, 0xfa, 0x21, 0x3c, 0x2e, 0x7a, 0xf1, 0xa6, 0xb4, 0x7e, 0x10, 0x69, 0x26, 0x99, 0x29, - 0x6d, 0x87, 0xce, 0xa9, 0xcd, 0xe4, 0x79, 0x9e, 0xfc, 0xde, 0x37, 0x6f, 0xf0, 0xf5, 0xa1, 0x54, - 0xc7, 0x52, 0xb1, 0xe7, 0x00, 0x69, 0xc1, 0x85, 0x66, 0xaf, 0xf6, 0x13, 0xd0, 0x7c, 0x9f, 0x9d, - 0x4c, 0xa0, 0x78, 0x4b, 0xf3, 0x42, 0x6a, 0x49, 0xb6, 0x4b, 0x11, 0x75, 0x22, 0x6a, 0x45, 0xfe, - 0x6e, 0x93, 0xbb, 0x52, 0x9a, 0x00, 0xff, 0xa6, 0xd5, 0x25, 0x5c, 0x41, 0x99, 0x5c, 0x29, 0x73, - 0x9e, 0x66, 0x82, 0xeb, 0x4c, 0x0a, 0xab, 0xbd, 0x96, 0x4a, 0x99, 0x8e, 0x81, 0xf1, 0x3c, 0x63, - 0x5c, 0x08, 0xa9, 0xcd, 0xa6, 0xb2, 0xbb, 0x57, 0xcb, 0xa4, 0x67, 0x66, 0xc5, 0x2c, 0x97, 0x59, - 0x84, 0xef, 0xf1, 0xe5, 0x47, 0xf3, 0xe8, 0xc1, 0x78, 0x2c, 0x5f, 0x73, 0x31, 0x84, 0x18, 0x4e, - 0x26, 0xa0, 0x34, 0x89, 0xf0, 0x45, 0x03, 0x03, 0x85, 0x87, 0x76, 0xd0, 0x8d, 0xde, 0xa1, 0xf7, - 0xf3, 0x7b, 0xff, 0x92, 0xf5, 0x0e, 0x46, 0xa3, 0x02, 0x94, 0x7a, 0xac, 0x8b, 0x4c, 0xa4, 0xb1, - 0x13, 0xd6, 0x1e, 0xf0, 0xba, 0xed, 0x3c, 0x10, 0x3e, 0xc1, 0x57, 0x96, 0x01, 0x54, 0x2e, 0x85, - 0x02, 0x72, 0x1f, 0xf7, 0xb8, 0xfb, 0x68, 0x18, 0xb6, 0xa2, 0x80, 0x36, 0x34, 0x95, 0x1e, 0xcd, - 0x57, 0x71, 0x6d, 0x08, 0x3f, 0xa3, 0xe5, 0x60, 0xb5, 0x52, 0x1a, 0xb4, 0x2d, 0x0d, 0xc8, 0x03, - 0x8c, 0xeb, 0xa6, 0x9b, 0xea, 0xb6, 0xa2, 0x5d, 0x47, 0x33, 0xbf, 0x21, 0x5a, 0xde, 0xbd, 0xe3, - 0x79, 0xc8, 0x53, 0xd7, 0xca, 0x78, 0xc1, 0x19, 0x7e, 0x41, 0x78, 0x7b, 0x05, 0xcb, 0x16, 0x7c, - 0x80, 0x71, 0xc5, 0xaf, 0x3c, 0xb4, 0x73, 0xae, 0x45, 0xc5, 0x0b, 0x0e, 0x72, 0xb4, 0x86, 0x71, - 0x6f, 0x23, 0x63, 0x79, 0xf8, 0x22, 0x64, 0xf4, 0xa7, 0x8b, 0xcf, 0x1b, 0x48, 0xf2, 0x0d, 0xe1, - 0x5e, 0x45, 0x4a, 0x68, 0x23, 0xcc, 0xda, 0x19, 0xf2, 0x59, 0x6b, 0x7d, 0x09, 0x11, 0x1e, 0x7c, - 0xf8, 0xf5, 0xef, 0x53, 0xf7, 0x1e, 0xb9, 0xcb, 0x9a, 0xde, 0x48, 0x55, 0x2e, 0x7b, 0x67, 0xa7, - 0xee, 0xd4, 0xfd, 0x83, 0x53, 0xf2, 0x15, 0x61, 0x5c, 0x37, 0x96, 0xb4, 0x3d, 0xdf, 0x4d, 0x86, - 0x7f, 0xab, 0xbd, 0xc1, 0x12, 0xdf, 0x31, 0xc4, 0x8c, 0xf4, 0x37, 0x13, 0xab, 0x1a, 0xf4, 0x70, - 0xf0, 0x63, 0x1a, 0xa0, 0xb3, 0x69, 0x80, 0xfe, 0x4e, 0x03, 0xf4, 0x71, 0x16, 0x74, 0xce, 0x66, - 0x41, 0xe7, 0xf7, 0x2c, 0xe8, 0x3c, 0xdd, 0x4b, 0x33, 0xfd, 0x62, 0x92, 0xd0, 0xa1, 0x3c, 0x76, - 0x91, 0xe5, 0x4f, 0x5f, 0x8d, 0x5e, 0xb2, 0x37, 0x55, 0x7e, 0x72, 0xc1, 0x3c, 0xe0, 0xdb, 0xff, - 0x03, 0x00, 0x00, 0xff, 0xff, 0x15, 0x17, 0x19, 0x54, 0x8d, 0x04, 0x00, 0x00, + // 525 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x94, 0xbd, 0x8b, 0x13, 0x41, + 0x18, 0xc6, 0x33, 0xe7, 0x17, 0x79, 0xaf, 0x1b, 0x3f, 0x2e, 0x2e, 0xb2, 0x86, 0x15, 0xee, 0xfc, + 0x20, 0x3b, 0x26, 0xa2, 0x9c, 0x20, 0x07, 0x49, 0x61, 0x5a, 0x8d, 0x60, 0x61, 0x23, 0x93, 0xe4, + 0x75, 0x5d, 0xcc, 0xed, 0xe4, 0x76, 0x36, 0xea, 0x21, 0x87, 0xe0, 0x5f, 0x20, 0x68, 0x2b, 0x82, + 0x85, 0x8d, 0x96, 0xb6, 0xf6, 0x96, 0x87, 0x36, 0x96, 0x92, 0xf8, 0x87, 0x48, 0xe6, 0x63, 0x37, + 0xe6, 0xb2, 0x64, 0x51, 0x0b, 0xab, 0x64, 0x76, 0x9f, 0xe7, 0xdd, 0xdf, 0xf3, 0xbe, 0x33, 0x03, + 0xe7, 0x7a, 0x42, 0x6e, 0x0b, 0xc9, 0x1e, 0x20, 0x06, 0x31, 0x8f, 0x12, 0xf6, 0xb8, 0xde, 0xc5, + 0x84, 0xd7, 0xd9, 0xce, 0x08, 0xe3, 0x5d, 0x7f, 0x18, 0x8b, 0x44, 0xd0, 0x35, 0x2d, 0xf2, 0xad, + 0xc8, 0x37, 0x22, 0x67, 0x3d, 0xcf, 0x9d, 0x2a, 0x55, 0x01, 0xe7, 0xa2, 0xd1, 0x75, 0xb9, 0x44, + 0x5d, 0x39, 0x55, 0x0e, 0x79, 0x10, 0x46, 0x3c, 0x09, 0x45, 0x64, 0xb4, 0x67, 0x02, 0x21, 0x82, + 0x01, 0x32, 0x3e, 0x0c, 0x19, 0x8f, 0x22, 0x91, 0xa8, 0x97, 0xd2, 0xbc, 0x3d, 0xad, 0x2b, 0xdd, + 0x57, 0x2b, 0x66, 0xb8, 0xd4, 0xc2, 0x7b, 0x0e, 0x27, 0x6f, 0x4f, 0x4b, 0x37, 0x07, 0x03, 0xf1, + 0x84, 0x47, 0x3d, 0xec, 0xe0, 0xce, 0x08, 0x65, 0x42, 0x1b, 0x70, 0x4c, 0xc1, 0x60, 0x5c, 0x21, + 0x55, 0x72, 0xbe, 0xdc, 0xaa, 0x7c, 0xfd, 0x54, 0x3b, 0x61, 0xbc, 0xcd, 0x7e, 0x3f, 0x46, 0x29, + 0xef, 0x24, 0x71, 0x18, 0x05, 0x1d, 0x2b, 0xcc, 0x3c, 0x58, 0x59, 0x29, 0xe6, 0x41, 0xef, 0x2e, + 0x9c, 0x9a, 0x07, 0x90, 0x43, 0x11, 0x49, 0xa4, 0x37, 0xa0, 0xcc, 0xed, 0x43, 0xc5, 0xb0, 0xda, + 0x70, 0xfd, 0x9c, 0xa6, 0xfa, 0xed, 0xe9, 0xaa, 0x93, 0x19, 0xbc, 0xd7, 0x64, 0xbe, 0xb0, 0x3c, + 0x10, 0x0d, 0x8b, 0x46, 0x43, 0x7a, 0x13, 0x20, 0x6b, 0xba, 0x4a, 0xb7, 0xda, 0x58, 0xb7, 0x34, + 0xd3, 0x09, 0xf9, 0x7a, 0xf6, 0x96, 0xe7, 0x16, 0x0f, 0x6c, 0x2b, 0x3b, 0x33, 0x4e, 0xef, 0x1d, + 0x81, 0xb5, 0x03, 0x58, 0x26, 0xf0, 0x16, 0x40, 0xca, 0x2f, 0x2b, 0xa4, 0x7a, 0xa8, 0x40, 0xe2, + 0x19, 0x07, 0x6d, 0x2f, 0x60, 0xdc, 0x58, 0xca, 0xa8, 0x3f, 0xfe, 0x1b, 0xe4, 0x1b, 0x02, 0x67, + 0xe7, 0x20, 0x5b, 0xbb, 0x6d, 0x3d, 0xe4, 0xbf, 0xd9, 0x1f, 0xff, 0xaa, 0x89, 0x1f, 0x08, 0x54, + 0xf3, 0xf9, 0xfe, 0xb3, 0x6e, 0x36, 0xde, 0x1e, 0x86, 0x23, 0x8a, 0x96, 0x7e, 0x24, 0x50, 0x4e, + 0x91, 0xa9, 0x9f, 0x0b, 0xb3, 0xf0, 0x44, 0x3a, 0xac, 0xb0, 0x5e, 0x43, 0x78, 0x5b, 0x2f, 0xbe, + 0xfd, 0x7c, 0xb5, 0xb2, 0x49, 0xaf, 0xb1, 0xbc, 0x1b, 0x27, 0x8d, 0xcb, 0x9e, 0x99, 0x19, 0xed, + 0xd9, 0x7f, 0xb8, 0x47, 0xdf, 0x13, 0x80, 0xac, 0xc3, 0xb4, 0xe8, 0xf7, 0xed, 0x39, 0x73, 0x2e, + 0x17, 0x37, 0x18, 0xe2, 0xab, 0x8a, 0x98, 0xd1, 0xda, 0x72, 0x62, 0x39, 0x03, 0xfa, 0x99, 0xc0, + 0xf1, 0x05, 0x5b, 0x81, 0x6e, 0x16, 0x05, 0x98, 0xdf, 0xdd, 0xce, 0xf5, 0x3f, 0x70, 0x9a, 0x0c, + 0x75, 0x95, 0xe1, 0x12, 0xbd, 0x90, 0x9b, 0x21, 0x94, 0x72, 0x84, 0xfd, 0xac, 0xe5, 0xad, 0xe6, + 0x97, 0xb1, 0x4b, 0xf6, 0xc7, 0x2e, 0xf9, 0x31, 0x76, 0xc9, 0xcb, 0x89, 0x5b, 0xda, 0x9f, 0xb8, + 0xa5, 0xef, 0x13, 0xb7, 0x74, 0x6f, 0x23, 0x08, 0x93, 0x87, 0xa3, 0xae, 0xdf, 0x13, 0xdb, 0xb6, + 0x9c, 0xfe, 0xa9, 0xc9, 0xfe, 0x23, 0xf6, 0x34, 0xad, 0xdd, 0x3d, 0xaa, 0xae, 0xf3, 0x2b, 0xbf, + 0x02, 0x00, 0x00, 0xff, 0xff, 0x67, 0xde, 0x8f, 0xb5, 0x9b, 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -300,6 +415,9 @@ type QueryClient interface { Allowance(ctx context.Context, in *QueryAllowanceRequest, opts ...grpc.CallOption) (*QueryAllowanceResponse, error) // Allowances returns all the grants for address. Allowances(ctx context.Context, in *QueryAllowancesRequest, opts ...grpc.CallOption) (*QueryAllowancesResponse, error) + // AllowancesByGranter returns all the grants given by an address + // Since v0.46 + AllowancesByGranter(ctx context.Context, in *QueryAllowancesByGranterRequest, opts ...grpc.CallOption) (*QueryAllowancesByGranterResponse, error) } type queryClient struct { @@ -328,12 +446,24 @@ func (c *queryClient) Allowances(ctx context.Context, in *QueryAllowancesRequest return out, nil } +func (c *queryClient) AllowancesByGranter(ctx context.Context, in *QueryAllowancesByGranterRequest, opts ...grpc.CallOption) (*QueryAllowancesByGranterResponse, error) { + out := new(QueryAllowancesByGranterResponse) + err := c.cc.Invoke(ctx, "/cosmos.feegrant.v1beta1.Query/AllowancesByGranter", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Allowance returns fee granted to the grantee by the granter. Allowance(context.Context, *QueryAllowanceRequest) (*QueryAllowanceResponse, error) // Allowances returns all the grants for address. Allowances(context.Context, *QueryAllowancesRequest) (*QueryAllowancesResponse, error) + // AllowancesByGranter returns all the grants given by an address + // Since v0.46 + AllowancesByGranter(context.Context, *QueryAllowancesByGranterRequest) (*QueryAllowancesByGranterResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -346,6 +476,9 @@ func (*UnimplementedQueryServer) Allowance(ctx context.Context, req *QueryAllowa func (*UnimplementedQueryServer) Allowances(ctx context.Context, req *QueryAllowancesRequest) (*QueryAllowancesResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Allowances not implemented") } +func (*UnimplementedQueryServer) AllowancesByGranter(ctx context.Context, req *QueryAllowancesByGranterRequest) (*QueryAllowancesByGranterResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AllowancesByGranter not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -387,6 +520,24 @@ func _Query_Allowances_Handler(srv interface{}, ctx context.Context, dec func(in return interceptor(ctx, in, info, handler) } +func _Query_AllowancesByGranter_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryAllowancesByGranterRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).AllowancesByGranter(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmos.feegrant.v1beta1.Query/AllowancesByGranter", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).AllowancesByGranter(ctx, req.(*QueryAllowancesByGranterRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "cosmos.feegrant.v1beta1.Query", HandlerType: (*QueryServer)(nil), @@ -399,6 +550,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "Allowances", Handler: _Query_Allowances_Handler, }, + { + MethodName: "AllowancesByGranter", + Handler: _Query_AllowancesByGranter_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "cosmos/feegrant/v1beta1/query.proto", @@ -567,6 +722,97 @@ func (m *QueryAllowancesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } +func (m *QueryAllowancesByGranterRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryAllowancesByGranterRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAllowancesByGranterRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Granter) > 0 { + i -= len(m.Granter) + copy(dAtA[i:], m.Granter) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Granter))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryAllowancesByGranterResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryAllowancesByGranterResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAllowancesByGranterResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Allowances) > 0 { + for iNdEx := len(m.Allowances) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Allowances[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -644,6 +890,42 @@ func (m *QueryAllowancesResponse) Size() (n int) { return n } +func (m *QueryAllowancesByGranterRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Granter) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryAllowancesByGranterResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Allowances) > 0 { + for _, e := range m.Allowances { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1088,6 +1370,244 @@ func (m *QueryAllowancesResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryAllowancesByGranterRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryAllowancesByGranterRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAllowancesByGranterRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Granter", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Granter = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryAllowancesByGranterResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryAllowancesByGranterResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAllowancesByGranterResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Allowances", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Allowances = append(m.Allowances, &Grant{}) + if err := m.Allowances[len(m.Allowances)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/feegrant/query.pb.gw.go b/x/feegrant/query.pb.gw.go index 06689435e071..925971b911fc 100644 --- a/x/feegrant/query.pb.gw.go +++ b/x/feegrant/query.pb.gw.go @@ -179,6 +179,78 @@ func local_request_Query_Allowances_0(ctx context.Context, marshaler runtime.Mar } +var ( + filter_Query_AllowancesByGranter_0 = &utilities.DoubleArray{Encoding: map[string]int{"granter": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Query_AllowancesByGranter_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAllowancesByGranterRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["granter"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "granter") + } + + protoReq.Granter, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "granter", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_AllowancesByGranter_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.AllowancesByGranter(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_AllowancesByGranter_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAllowancesByGranterRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["granter"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "granter") + } + + protoReq.Granter, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "granter", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_AllowancesByGranter_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.AllowancesByGranter(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -225,6 +297,26 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_AllowancesByGranter_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_AllowancesByGranter_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_AllowancesByGranter_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -306,6 +398,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_AllowancesByGranter_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_AllowancesByGranter_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_AllowancesByGranter_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -313,10 +425,14 @@ var ( pattern_Query_Allowance_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"cosmos", "feegrant", "v1beta1", "allowance", "granter", "grantee"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_Allowances_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"cosmos", "feegrant", "v1beta1", "allowances", "grantee"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_AllowancesByGranter_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"cosmos", "feegrant", "v1beta1", "issued", "granter"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( forward_Query_Allowance_0 = runtime.ForwardResponseMessage forward_Query_Allowances_0 = runtime.ForwardResponseMessage + + forward_Query_AllowancesByGranter_0 = runtime.ForwardResponseMessage )