diff --git a/api/cosmos/authz/v1beta1/authz.pulsar.go b/api/cosmos/authz/v1beta1/authz.pulsar.go index 90983b2ebe9f..60729519614d 100644 --- a/api/cosmos/authz/v1beta1/authz.pulsar.go +++ b/api/cosmos/authz/v1beta1/authz.pulsar.go @@ -437,10 +437,62 @@ func (x *fastReflection_GenericAuthorization) ProtoMethods() *protoiface.Methods } } +var _ protoreflect.List = (*_Grant_3_list)(nil) + +type _Grant_3_list struct { + list *[]*Rule +} + +func (x *_Grant_3_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_Grant_3_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfMessage((*x.list)[i].ProtoReflect()) +} + +func (x *_Grant_3_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*Rule) + (*x.list)[i] = concreteValue +} + +func (x *_Grant_3_list) Append(value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*Rule) + *x.list = append(*x.list, concreteValue) +} + +func (x *_Grant_3_list) AppendMutable() protoreflect.Value { + v := new(Rule) + *x.list = append(*x.list, v) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_Grant_3_list) Truncate(n int) { + for i := n; i < len(*x.list); i++ { + (*x.list)[i] = nil + } + *x.list = (*x.list)[:n] +} + +func (x *_Grant_3_list) NewElement() protoreflect.Value { + v := new(Rule) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_Grant_3_list) IsValid() bool { + return x.list != nil +} + var ( md_Grant protoreflect.MessageDescriptor fd_Grant_authorization protoreflect.FieldDescriptor fd_Grant_expiration protoreflect.FieldDescriptor + fd_Grant_rules protoreflect.FieldDescriptor ) func init() { @@ -448,6 +500,7 @@ func init() { md_Grant = File_cosmos_authz_v1beta1_authz_proto.Messages().ByName("Grant") fd_Grant_authorization = md_Grant.Fields().ByName("authorization") fd_Grant_expiration = md_Grant.Fields().ByName("expiration") + fd_Grant_rules = md_Grant.Fields().ByName("rules") } var _ protoreflect.Message = (*fastReflection_Grant)(nil) @@ -527,6 +580,12 @@ func (x *fastReflection_Grant) Range(f func(protoreflect.FieldDescriptor, protor return } } + if len(x.Rules) != 0 { + value := protoreflect.ValueOfList(&_Grant_3_list{list: &x.Rules}) + if !f(fd_Grant_rules, value) { + return + } + } } // Has reports whether a field is populated. @@ -546,6 +605,8 @@ func (x *fastReflection_Grant) Has(fd protoreflect.FieldDescriptor) bool { return x.Authorization != nil case "cosmos.authz.v1beta1.Grant.expiration": return x.Expiration != nil + case "cosmos.authz.v1beta1.Grant.rules": + return len(x.Rules) != 0 default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.Grant")) @@ -566,6 +627,8 @@ func (x *fastReflection_Grant) Clear(fd protoreflect.FieldDescriptor) { x.Authorization = nil case "cosmos.authz.v1beta1.Grant.expiration": x.Expiration = nil + case "cosmos.authz.v1beta1.Grant.rules": + x.Rules = nil default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.Grant")) @@ -588,6 +651,12 @@ func (x *fastReflection_Grant) Get(descriptor protoreflect.FieldDescriptor) prot case "cosmos.authz.v1beta1.Grant.expiration": value := x.Expiration return protoreflect.ValueOfMessage(value.ProtoReflect()) + case "cosmos.authz.v1beta1.Grant.rules": + if len(x.Rules) == 0 { + return protoreflect.ValueOfList(&_Grant_3_list{}) + } + listValue := &_Grant_3_list{list: &x.Rules} + return protoreflect.ValueOfList(listValue) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.Grant")) @@ -612,6 +681,10 @@ func (x *fastReflection_Grant) Set(fd protoreflect.FieldDescriptor, value protor x.Authorization = value.Message().Interface().(*anypb.Any) case "cosmos.authz.v1beta1.Grant.expiration": x.Expiration = value.Message().Interface().(*timestamppb.Timestamp) + case "cosmos.authz.v1beta1.Grant.rules": + lv := value.List() + clv := lv.(*_Grant_3_list) + x.Rules = *clv.list default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.Grant")) @@ -642,6 +715,12 @@ func (x *fastReflection_Grant) Mutable(fd protoreflect.FieldDescriptor) protoref x.Expiration = new(timestamppb.Timestamp) } return protoreflect.ValueOfMessage(x.Expiration.ProtoReflect()) + case "cosmos.authz.v1beta1.Grant.rules": + if x.Rules == nil { + x.Rules = []*Rule{} + } + value := &_Grant_3_list{list: &x.Rules} + return protoreflect.ValueOfList(value) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.Grant")) @@ -661,6 +740,9 @@ func (x *fastReflection_Grant) NewField(fd protoreflect.FieldDescriptor) protore case "cosmos.authz.v1beta1.Grant.expiration": m := new(timestamppb.Timestamp) return protoreflect.ValueOfMessage(m.ProtoReflect()) + case "cosmos.authz.v1beta1.Grant.rules": + list := []*Rule{} + return protoreflect.ValueOfList(&_Grant_3_list{list: &list}) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.Grant")) @@ -738,6 +820,12 @@ func (x *fastReflection_Grant) ProtoMethods() *protoiface.Methods { l = options.Size(x.Expiration) n += 1 + l + runtime.Sov(uint64(l)) } + if len(x.Rules) > 0 { + for _, e := range x.Rules { + l = options.Size(e) + n += 1 + l + runtime.Sov(uint64(l)) + } + } if x.unknownFields != nil { n += len(x.unknownFields) } @@ -767,6 +855,22 @@ func (x *fastReflection_Grant) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } + if len(x.Rules) > 0 { + for iNdEx := len(x.Rules) - 1; iNdEx >= 0; iNdEx-- { + encoded, err := options.Marshal(x.Rules[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] = 0x1a + } + } if x.Expiration != nil { encoded, err := options.Marshal(x.Expiration) if err != nil { @@ -916,6 +1020,40 @@ func (x *fastReflection_Grant) ProtoMethods() *protoiface.Methods { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err } iNdEx = postIndex + case 3: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Rules", 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.Rules = append(x.Rules, &Rule{}) + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Rules[len(x.Rules)-1]); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := runtime.Skip(dAtA[iNdEx:]) @@ -951,32 +1089,74 @@ func (x *fastReflection_Grant) ProtoMethods() *protoiface.Methods { } } +var _ protoreflect.List = (*_Rule_2_list)(nil) + +type _Rule_2_list struct { + list *[]string +} + +func (x *_Rule_2_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_Rule_2_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfString((*x.list)[i]) +} + +func (x *_Rule_2_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.String() + concreteValue := valueUnwrapped + (*x.list)[i] = concreteValue +} + +func (x *_Rule_2_list) Append(value protoreflect.Value) { + valueUnwrapped := value.String() + concreteValue := valueUnwrapped + *x.list = append(*x.list, concreteValue) +} + +func (x *_Rule_2_list) AppendMutable() protoreflect.Value { + panic(fmt.Errorf("AppendMutable can not be called on message Rule at list field Values as it is not of Message kind")) +} + +func (x *_Rule_2_list) Truncate(n int) { + *x.list = (*x.list)[:n] +} + +func (x *_Rule_2_list) NewElement() protoreflect.Value { + v := "" + return protoreflect.ValueOfString(v) +} + +func (x *_Rule_2_list) IsValid() bool { + return x.list != nil +} + var ( - md_GrantAuthorization protoreflect.MessageDescriptor - fd_GrantAuthorization_granter protoreflect.FieldDescriptor - fd_GrantAuthorization_grantee protoreflect.FieldDescriptor - fd_GrantAuthorization_authorization protoreflect.FieldDescriptor - fd_GrantAuthorization_expiration protoreflect.FieldDescriptor + md_Rule protoreflect.MessageDescriptor + fd_Rule_key protoreflect.FieldDescriptor + fd_Rule_values protoreflect.FieldDescriptor ) func init() { file_cosmos_authz_v1beta1_authz_proto_init() - md_GrantAuthorization = File_cosmos_authz_v1beta1_authz_proto.Messages().ByName("GrantAuthorization") - fd_GrantAuthorization_granter = md_GrantAuthorization.Fields().ByName("granter") - fd_GrantAuthorization_grantee = md_GrantAuthorization.Fields().ByName("grantee") - fd_GrantAuthorization_authorization = md_GrantAuthorization.Fields().ByName("authorization") - fd_GrantAuthorization_expiration = md_GrantAuthorization.Fields().ByName("expiration") + md_Rule = File_cosmos_authz_v1beta1_authz_proto.Messages().ByName("Rule") + fd_Rule_key = md_Rule.Fields().ByName("key") + fd_Rule_values = md_Rule.Fields().ByName("values") } -var _ protoreflect.Message = (*fastReflection_GrantAuthorization)(nil) +var _ protoreflect.Message = (*fastReflection_Rule)(nil) -type fastReflection_GrantAuthorization GrantAuthorization +type fastReflection_Rule Rule -func (x *GrantAuthorization) ProtoReflect() protoreflect.Message { - return (*fastReflection_GrantAuthorization)(x) +func (x *Rule) ProtoReflect() protoreflect.Message { + return (*fastReflection_Rule)(x) } -func (x *GrantAuthorization) slowProtoReflect() protoreflect.Message { +func (x *Rule) slowProtoReflect() protoreflect.Message { mi := &file_cosmos_authz_v1beta1_authz_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -988,43 +1168,43 @@ func (x *GrantAuthorization) slowProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -var _fastReflection_GrantAuthorization_messageType fastReflection_GrantAuthorization_messageType -var _ protoreflect.MessageType = fastReflection_GrantAuthorization_messageType{} +var _fastReflection_Rule_messageType fastReflection_Rule_messageType +var _ protoreflect.MessageType = fastReflection_Rule_messageType{} -type fastReflection_GrantAuthorization_messageType struct{} +type fastReflection_Rule_messageType struct{} -func (x fastReflection_GrantAuthorization_messageType) Zero() protoreflect.Message { - return (*fastReflection_GrantAuthorization)(nil) +func (x fastReflection_Rule_messageType) Zero() protoreflect.Message { + return (*fastReflection_Rule)(nil) } -func (x fastReflection_GrantAuthorization_messageType) New() protoreflect.Message { - return new(fastReflection_GrantAuthorization) +func (x fastReflection_Rule_messageType) New() protoreflect.Message { + return new(fastReflection_Rule) } -func (x fastReflection_GrantAuthorization_messageType) Descriptor() protoreflect.MessageDescriptor { - return md_GrantAuthorization +func (x fastReflection_Rule_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_Rule } // Descriptor returns message descriptor, which contains only the protobuf // type information for the message. -func (x *fastReflection_GrantAuthorization) Descriptor() protoreflect.MessageDescriptor { - return md_GrantAuthorization +func (x *fastReflection_Rule) Descriptor() protoreflect.MessageDescriptor { + return md_Rule } // 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_GrantAuthorization) Type() protoreflect.MessageType { - return _fastReflection_GrantAuthorization_messageType +func (x *fastReflection_Rule) Type() protoreflect.MessageType { + return _fastReflection_Rule_messageType } // New returns a newly allocated and mutable empty message. -func (x *fastReflection_GrantAuthorization) New() protoreflect.Message { - return new(fastReflection_GrantAuthorization) +func (x *fastReflection_Rule) New() protoreflect.Message { + return new(fastReflection_Rule) } // Interface unwraps the message reflection interface and // returns the underlying ProtoMessage interface. -func (x *fastReflection_GrantAuthorization) Interface() protoreflect.ProtoMessage { - return (*GrantAuthorization)(x) +func (x *fastReflection_Rule) Interface() protoreflect.ProtoMessage { + return (*Rule)(x) } // Range iterates over every populated field in an undefined order, @@ -1032,28 +1212,16 @@ func (x *fastReflection_GrantAuthorization) Interface() protoreflect.ProtoMessag // Range returns immediately if f returns false. // While iterating, mutating operations may only be performed // on the current field descriptor. -func (x *fastReflection_GrantAuthorization) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { - if x.Granter != "" { - value := protoreflect.ValueOfString(x.Granter) - if !f(fd_GrantAuthorization_granter, value) { - return - } - } - if x.Grantee != "" { - value := protoreflect.ValueOfString(x.Grantee) - if !f(fd_GrantAuthorization_grantee, value) { +func (x *fastReflection_Rule) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Key != "" { + value := protoreflect.ValueOfString(x.Key) + if !f(fd_Rule_key, value) { return } } - if x.Authorization != nil { - value := protoreflect.ValueOfMessage(x.Authorization.ProtoReflect()) - if !f(fd_GrantAuthorization_authorization, value) { - return - } - } - if x.Expiration != nil { - value := protoreflect.ValueOfMessage(x.Expiration.ProtoReflect()) - if !f(fd_GrantAuthorization_expiration, value) { + if len(x.Values) != 0 { + value := protoreflect.ValueOfList(&_Rule_2_list{list: &x.Values}) + if !f(fd_Rule_values, value) { return } } @@ -1070,21 +1238,17 @@ func (x *fastReflection_GrantAuthorization) Range(f func(protoreflect.FieldDescr // 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_GrantAuthorization) Has(fd protoreflect.FieldDescriptor) bool { +func (x *fastReflection_Rule) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { - case "cosmos.authz.v1beta1.GrantAuthorization.granter": - return x.Granter != "" - case "cosmos.authz.v1beta1.GrantAuthorization.grantee": - return x.Grantee != "" - case "cosmos.authz.v1beta1.GrantAuthorization.authorization": - return x.Authorization != nil - case "cosmos.authz.v1beta1.GrantAuthorization.expiration": - return x.Expiration != nil + case "cosmos.authz.v1beta1.Rule.key": + return x.Key != "" + case "cosmos.authz.v1beta1.Rule.values": + return len(x.Values) != 0 default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.GrantAuthorization")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.Rule")) } - panic(fmt.Errorf("message cosmos.authz.v1beta1.GrantAuthorization does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message cosmos.authz.v1beta1.Rule does not contain field %s", fd.FullName())) } } @@ -1094,21 +1258,17 @@ func (x *fastReflection_GrantAuthorization) Has(fd protoreflect.FieldDescriptor) // associated with the given field number. // // Clear is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_GrantAuthorization) Clear(fd protoreflect.FieldDescriptor) { +func (x *fastReflection_Rule) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { - case "cosmos.authz.v1beta1.GrantAuthorization.granter": - x.Granter = "" - case "cosmos.authz.v1beta1.GrantAuthorization.grantee": - x.Grantee = "" - case "cosmos.authz.v1beta1.GrantAuthorization.authorization": - x.Authorization = nil - case "cosmos.authz.v1beta1.GrantAuthorization.expiration": - x.Expiration = nil + case "cosmos.authz.v1beta1.Rule.key": + x.Key = "" + case "cosmos.authz.v1beta1.Rule.values": + x.Values = nil default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.GrantAuthorization")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.Rule")) } - panic(fmt.Errorf("message cosmos.authz.v1beta1.GrantAuthorization does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message cosmos.authz.v1beta1.Rule does not contain field %s", fd.FullName())) } } @@ -1118,25 +1278,22 @@ func (x *fastReflection_GrantAuthorization) Clear(fd protoreflect.FieldDescripto // 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_GrantAuthorization) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { +func (x *fastReflection_Rule) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { switch descriptor.FullName() { - case "cosmos.authz.v1beta1.GrantAuthorization.granter": - value := x.Granter - return protoreflect.ValueOfString(value) - case "cosmos.authz.v1beta1.GrantAuthorization.grantee": - value := x.Grantee + case "cosmos.authz.v1beta1.Rule.key": + value := x.Key return protoreflect.ValueOfString(value) - case "cosmos.authz.v1beta1.GrantAuthorization.authorization": - value := x.Authorization - return protoreflect.ValueOfMessage(value.ProtoReflect()) - case "cosmos.authz.v1beta1.GrantAuthorization.expiration": - value := x.Expiration - return protoreflect.ValueOfMessage(value.ProtoReflect()) + case "cosmos.authz.v1beta1.Rule.values": + if len(x.Values) == 0 { + return protoreflect.ValueOfList(&_Rule_2_list{}) + } + listValue := &_Rule_2_list{list: &x.Values} + return protoreflect.ValueOfList(listValue) default: if descriptor.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.GrantAuthorization")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.Rule")) } - panic(fmt.Errorf("message cosmos.authz.v1beta1.GrantAuthorization does not contain field %s", descriptor.FullName())) + panic(fmt.Errorf("message cosmos.authz.v1beta1.Rule does not contain field %s", descriptor.FullName())) } } @@ -1150,21 +1307,19 @@ func (x *fastReflection_GrantAuthorization) Get(descriptor protoreflect.FieldDes // empty, read-only value, then it panics. // // Set is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_GrantAuthorization) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { +func (x *fastReflection_Rule) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { switch fd.FullName() { - case "cosmos.authz.v1beta1.GrantAuthorization.granter": - x.Granter = value.Interface().(string) - case "cosmos.authz.v1beta1.GrantAuthorization.grantee": - x.Grantee = value.Interface().(string) - case "cosmos.authz.v1beta1.GrantAuthorization.authorization": - x.Authorization = value.Message().Interface().(*anypb.Any) - case "cosmos.authz.v1beta1.GrantAuthorization.expiration": - x.Expiration = value.Message().Interface().(*timestamppb.Timestamp) + case "cosmos.authz.v1beta1.Rule.key": + x.Key = value.Interface().(string) + case "cosmos.authz.v1beta1.Rule.values": + lv := value.List() + clv := lv.(*_Rule_2_list) + x.Values = *clv.list default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.GrantAuthorization")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.Rule")) } - panic(fmt.Errorf("message cosmos.authz.v1beta1.GrantAuthorization does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message cosmos.authz.v1beta1.Rule does not contain field %s", fd.FullName())) } } @@ -1178,60 +1333,49 @@ func (x *fastReflection_GrantAuthorization) Set(fd protoreflect.FieldDescriptor, // It panics if the field does not contain a composite type. // // Mutable is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_GrantAuthorization) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { +func (x *fastReflection_Rule) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "cosmos.authz.v1beta1.GrantAuthorization.authorization": - if x.Authorization == nil { - x.Authorization = new(anypb.Any) - } - return protoreflect.ValueOfMessage(x.Authorization.ProtoReflect()) - case "cosmos.authz.v1beta1.GrantAuthorization.expiration": - if x.Expiration == nil { - x.Expiration = new(timestamppb.Timestamp) + case "cosmos.authz.v1beta1.Rule.values": + if x.Values == nil { + x.Values = []string{} } - return protoreflect.ValueOfMessage(x.Expiration.ProtoReflect()) - case "cosmos.authz.v1beta1.GrantAuthorization.granter": - panic(fmt.Errorf("field granter of message cosmos.authz.v1beta1.GrantAuthorization is not mutable")) - case "cosmos.authz.v1beta1.GrantAuthorization.grantee": - panic(fmt.Errorf("field grantee of message cosmos.authz.v1beta1.GrantAuthorization is not mutable")) + value := &_Rule_2_list{list: &x.Values} + return protoreflect.ValueOfList(value) + case "cosmos.authz.v1beta1.Rule.key": + panic(fmt.Errorf("field key of message cosmos.authz.v1beta1.Rule is not mutable")) default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.GrantAuthorization")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.Rule")) } - panic(fmt.Errorf("message cosmos.authz.v1beta1.GrantAuthorization does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message cosmos.authz.v1beta1.Rule 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_GrantAuthorization) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { +func (x *fastReflection_Rule) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "cosmos.authz.v1beta1.GrantAuthorization.granter": - return protoreflect.ValueOfString("") - case "cosmos.authz.v1beta1.GrantAuthorization.grantee": + case "cosmos.authz.v1beta1.Rule.key": return protoreflect.ValueOfString("") - case "cosmos.authz.v1beta1.GrantAuthorization.authorization": - m := new(anypb.Any) - return protoreflect.ValueOfMessage(m.ProtoReflect()) - case "cosmos.authz.v1beta1.GrantAuthorization.expiration": - m := new(timestamppb.Timestamp) - return protoreflect.ValueOfMessage(m.ProtoReflect()) + case "cosmos.authz.v1beta1.Rule.values": + list := []string{} + return protoreflect.ValueOfList(&_Rule_2_list{list: &list}) default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.GrantAuthorization")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.Rule")) } - panic(fmt.Errorf("message cosmos.authz.v1beta1.GrantAuthorization does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message cosmos.authz.v1beta1.Rule 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_GrantAuthorization) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { +func (x *fastReflection_Rule) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { switch d.FullName() { default: - panic(fmt.Errorf("%s is not a oneof field in cosmos.authz.v1beta1.GrantAuthorization", d.FullName())) + panic(fmt.Errorf("%s is not a oneof field in cosmos.authz.v1beta1.Rule", d.FullName())) } panic("unreachable") } @@ -1239,7 +1383,7 @@ func (x *fastReflection_GrantAuthorization) WhichOneof(d protoreflect.OneofDescr // 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_GrantAuthorization) GetUnknown() protoreflect.RawFields { +func (x *fastReflection_Rule) GetUnknown() protoreflect.RawFields { return x.unknownFields } @@ -1250,7 +1394,7 @@ func (x *fastReflection_GrantAuthorization) GetUnknown() protoreflect.RawFields // An empty RawFields may be passed to clear the fields. // // SetUnknown is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_GrantAuthorization) SetUnknown(fields protoreflect.RawFields) { +func (x *fastReflection_Rule) SetUnknown(fields protoreflect.RawFields) { x.unknownFields = fields } @@ -1262,7 +1406,7 @@ func (x *fastReflection_GrantAuthorization) SetUnknown(fields protoreflect.RawFi // 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_GrantAuthorization) IsValid() bool { +func (x *fastReflection_Rule) IsValid() bool { return x != nil } @@ -1272,9 +1416,9 @@ func (x *fastReflection_GrantAuthorization) IsValid() bool { // The returned methods type is identical to // "google.golang.org/protobuf/runtime/protoiface".Methods. // Consult the protoiface package documentation for details. -func (x *fastReflection_GrantAuthorization) ProtoMethods() *protoiface.Methods { +func (x *fastReflection_Rule) ProtoMethods() *protoiface.Methods { size := func(input protoiface.SizeInput) protoiface.SizeOutput { - x := input.Message.Interface().(*GrantAuthorization) + x := input.Message.Interface().(*Rule) if x == nil { return protoiface.SizeOutput{ NoUnkeyedLiterals: input.NoUnkeyedLiterals, @@ -1286,21 +1430,15 @@ func (x *fastReflection_GrantAuthorization) ProtoMethods() *protoiface.Methods { var n int var l int _ = l - l = len(x.Granter) + l = len(x.Key) if l > 0 { n += 1 + l + runtime.Sov(uint64(l)) } - l = len(x.Grantee) - if l > 0 { - n += 1 + l + runtime.Sov(uint64(l)) - } - if x.Authorization != nil { - l = options.Size(x.Authorization) - n += 1 + l + runtime.Sov(uint64(l)) - } - if x.Expiration != nil { - l = options.Size(x.Expiration) - n += 1 + l + runtime.Sov(uint64(l)) + if len(x.Values) > 0 { + for _, s := range x.Values { + l = len(s) + n += 1 + l + runtime.Sov(uint64(l)) + } } if x.unknownFields != nil { n += len(x.unknownFields) @@ -1312,7 +1450,7 @@ func (x *fastReflection_GrantAuthorization) ProtoMethods() *protoiface.Methods { } marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { - x := input.Message.Interface().(*GrantAuthorization) + x := input.Message.Interface().(*Rule) if x == nil { return protoiface.MarshalOutput{ NoUnkeyedLiterals: input.NoUnkeyedLiterals, @@ -1331,45 +1469,19 @@ func (x *fastReflection_GrantAuthorization) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } - if x.Expiration != nil { - encoded, err := options.Marshal(x.Expiration) - 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] = 0x22 - } - if x.Authorization != nil { - encoded, err := options.Marshal(x.Authorization) - if err != nil { - return protoiface.MarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Buf: input.Buf, - }, err + if len(x.Values) > 0 { + for iNdEx := len(x.Values) - 1; iNdEx >= 0; iNdEx-- { + i -= len(x.Values[iNdEx]) + copy(dAtA[i:], x.Values[iNdEx]) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Values[iNdEx]))) + i-- + dAtA[i] = 0x12 } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) - i-- - dAtA[i] = 0x1a - } - if len(x.Grantee) > 0 { - i -= len(x.Grantee) - copy(dAtA[i:], x.Grantee) - i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Grantee))) - 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))) + if len(x.Key) > 0 { + i -= len(x.Key) + copy(dAtA[i:], x.Key) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Key))) i-- dAtA[i] = 0xa } @@ -1384,7 +1496,7 @@ func (x *fastReflection_GrantAuthorization) ProtoMethods() *protoiface.Methods { }, nil } unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { - x := input.Message.Interface().(*GrantAuthorization) + x := input.Message.Interface().(*Rule) if x == nil { return protoiface.UnmarshalOutput{ NoUnkeyedLiterals: input.NoUnkeyedLiterals, @@ -1416,15 +1528,15 @@ func (x *fastReflection_GrantAuthorization) ProtoMethods() *protoiface.Methods { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: GrantAuthorization: wiretype end group for non-group") + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: Rule: wiretype end group for non-group") } if fieldNum <= 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: GrantAuthorization: illegal tag %d (wire type %d)", fieldNum, wire) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: Rule: 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) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1452,11 +1564,11 @@ func (x *fastReflection_GrantAuthorization) ProtoMethods() *protoiface.Methods { if postIndex > l { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF } - x.Granter = string(dAtA[iNdEx:postIndex]) + x.Key = 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 Grantee", wireType) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Values", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1484,79 +1596,7 @@ func (x *fastReflection_GrantAuthorization) ProtoMethods() *protoiface.Methods { if postIndex > l { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF } - x.Grantee = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Authorization", 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.Authorization == nil { - x.Authorization = &anypb.Any{} - } - if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Authorization); err != nil { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Expiration", 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.Expiration == nil { - x.Expiration = ×tamppb.Timestamp{} - } - if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Expiration); err != nil { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err - } + x.Values = append(x.Values, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex default: iNdEx = preIndex @@ -1577,89 +1617,1897 @@ func (x *fastReflection_GrantAuthorization) ProtoMethods() *protoiface.Methods { } } - 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, + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +var ( + md_GrantAuthorization protoreflect.MessageDescriptor + fd_GrantAuthorization_granter protoreflect.FieldDescriptor + fd_GrantAuthorization_grantee protoreflect.FieldDescriptor + fd_GrantAuthorization_authorization protoreflect.FieldDescriptor + fd_GrantAuthorization_expiration protoreflect.FieldDescriptor +) + +func init() { + file_cosmos_authz_v1beta1_authz_proto_init() + md_GrantAuthorization = File_cosmos_authz_v1beta1_authz_proto.Messages().ByName("GrantAuthorization") + fd_GrantAuthorization_granter = md_GrantAuthorization.Fields().ByName("granter") + fd_GrantAuthorization_grantee = md_GrantAuthorization.Fields().ByName("grantee") + fd_GrantAuthorization_authorization = md_GrantAuthorization.Fields().ByName("authorization") + fd_GrantAuthorization_expiration = md_GrantAuthorization.Fields().ByName("expiration") +} + +var _ protoreflect.Message = (*fastReflection_GrantAuthorization)(nil) + +type fastReflection_GrantAuthorization GrantAuthorization + +func (x *GrantAuthorization) ProtoReflect() protoreflect.Message { + return (*fastReflection_GrantAuthorization)(x) +} + +func (x *GrantAuthorization) slowProtoReflect() protoreflect.Message { + mi := &file_cosmos_authz_v1beta1_authz_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_GrantAuthorization_messageType fastReflection_GrantAuthorization_messageType +var _ protoreflect.MessageType = fastReflection_GrantAuthorization_messageType{} + +type fastReflection_GrantAuthorization_messageType struct{} + +func (x fastReflection_GrantAuthorization_messageType) Zero() protoreflect.Message { + return (*fastReflection_GrantAuthorization)(nil) +} +func (x fastReflection_GrantAuthorization_messageType) New() protoreflect.Message { + return new(fastReflection_GrantAuthorization) +} +func (x fastReflection_GrantAuthorization_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_GrantAuthorization +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_GrantAuthorization) Descriptor() protoreflect.MessageDescriptor { + return md_GrantAuthorization +} + +// 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_GrantAuthorization) Type() protoreflect.MessageType { + return _fastReflection_GrantAuthorization_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_GrantAuthorization) New() protoreflect.Message { + return new(fastReflection_GrantAuthorization) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_GrantAuthorization) Interface() protoreflect.ProtoMessage { + return (*GrantAuthorization)(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_GrantAuthorization) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Granter != "" { + value := protoreflect.ValueOfString(x.Granter) + if !f(fd_GrantAuthorization_granter, value) { + return + } + } + if x.Grantee != "" { + value := protoreflect.ValueOfString(x.Grantee) + if !f(fd_GrantAuthorization_grantee, value) { + return + } + } + if x.Authorization != nil { + value := protoreflect.ValueOfMessage(x.Authorization.ProtoReflect()) + if !f(fd_GrantAuthorization_authorization, value) { + return + } + } + if x.Expiration != nil { + value := protoreflect.ValueOfMessage(x.Expiration.ProtoReflect()) + if !f(fd_GrantAuthorization_expiration, 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_GrantAuthorization) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "cosmos.authz.v1beta1.GrantAuthorization.granter": + return x.Granter != "" + case "cosmos.authz.v1beta1.GrantAuthorization.grantee": + return x.Grantee != "" + case "cosmos.authz.v1beta1.GrantAuthorization.authorization": + return x.Authorization != nil + case "cosmos.authz.v1beta1.GrantAuthorization.expiration": + return x.Expiration != nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.GrantAuthorization")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.GrantAuthorization 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_GrantAuthorization) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "cosmos.authz.v1beta1.GrantAuthorization.granter": + x.Granter = "" + case "cosmos.authz.v1beta1.GrantAuthorization.grantee": + x.Grantee = "" + case "cosmos.authz.v1beta1.GrantAuthorization.authorization": + x.Authorization = nil + case "cosmos.authz.v1beta1.GrantAuthorization.expiration": + x.Expiration = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.GrantAuthorization")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.GrantAuthorization 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_GrantAuthorization) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "cosmos.authz.v1beta1.GrantAuthorization.granter": + value := x.Granter + return protoreflect.ValueOfString(value) + case "cosmos.authz.v1beta1.GrantAuthorization.grantee": + value := x.Grantee + return protoreflect.ValueOfString(value) + case "cosmos.authz.v1beta1.GrantAuthorization.authorization": + value := x.Authorization + return protoreflect.ValueOfMessage(value.ProtoReflect()) + case "cosmos.authz.v1beta1.GrantAuthorization.expiration": + value := x.Expiration + return protoreflect.ValueOfMessage(value.ProtoReflect()) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.GrantAuthorization")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.GrantAuthorization 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_GrantAuthorization) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "cosmos.authz.v1beta1.GrantAuthorization.granter": + x.Granter = value.Interface().(string) + case "cosmos.authz.v1beta1.GrantAuthorization.grantee": + x.Grantee = value.Interface().(string) + case "cosmos.authz.v1beta1.GrantAuthorization.authorization": + x.Authorization = value.Message().Interface().(*anypb.Any) + case "cosmos.authz.v1beta1.GrantAuthorization.expiration": + x.Expiration = value.Message().Interface().(*timestamppb.Timestamp) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.GrantAuthorization")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.GrantAuthorization 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_GrantAuthorization) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.authz.v1beta1.GrantAuthorization.authorization": + if x.Authorization == nil { + x.Authorization = new(anypb.Any) + } + return protoreflect.ValueOfMessage(x.Authorization.ProtoReflect()) + case "cosmos.authz.v1beta1.GrantAuthorization.expiration": + if x.Expiration == nil { + x.Expiration = new(timestamppb.Timestamp) + } + return protoreflect.ValueOfMessage(x.Expiration.ProtoReflect()) + case "cosmos.authz.v1beta1.GrantAuthorization.granter": + panic(fmt.Errorf("field granter of message cosmos.authz.v1beta1.GrantAuthorization is not mutable")) + case "cosmos.authz.v1beta1.GrantAuthorization.grantee": + panic(fmt.Errorf("field grantee of message cosmos.authz.v1beta1.GrantAuthorization is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.GrantAuthorization")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.GrantAuthorization 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_GrantAuthorization) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.authz.v1beta1.GrantAuthorization.granter": + return protoreflect.ValueOfString("") + case "cosmos.authz.v1beta1.GrantAuthorization.grantee": + return protoreflect.ValueOfString("") + case "cosmos.authz.v1beta1.GrantAuthorization.authorization": + m := new(anypb.Any) + return protoreflect.ValueOfMessage(m.ProtoReflect()) + case "cosmos.authz.v1beta1.GrantAuthorization.expiration": + m := new(timestamppb.Timestamp) + return protoreflect.ValueOfMessage(m.ProtoReflect()) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.GrantAuthorization")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.GrantAuthorization 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_GrantAuthorization) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.authz.v1beta1.GrantAuthorization", 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_GrantAuthorization) 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_GrantAuthorization) 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_GrantAuthorization) 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_GrantAuthorization) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*GrantAuthorization) + 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)) + } + l = len(x.Grantee) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.Authorization != nil { + l = options.Size(x.Authorization) + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.Expiration != nil { + l = options.Size(x.Expiration) + 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().(*GrantAuthorization) + 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.Expiration != nil { + encoded, err := options.Marshal(x.Expiration) + 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] = 0x22 + } + if x.Authorization != nil { + encoded, err := options.Marshal(x.Authorization) + 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] = 0x1a + } + if len(x.Grantee) > 0 { + i -= len(x.Grantee) + copy(dAtA[i:], x.Grantee) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Grantee))) + 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().(*GrantAuthorization) + 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: GrantAuthorization: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: GrantAuthorization: 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 Grantee", 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.Grantee = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Authorization", 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.Authorization == nil { + x.Authorization = &anypb.Any{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Authorization); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Expiration", 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.Expiration == nil { + x.Expiration = ×tamppb.Timestamp{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Expiration); 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 = (*_GrantQueueItem_1_list)(nil) + +type _GrantQueueItem_1_list struct { + list *[]string +} + +func (x *_GrantQueueItem_1_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_GrantQueueItem_1_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfString((*x.list)[i]) +} + +func (x *_GrantQueueItem_1_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.String() + concreteValue := valueUnwrapped + (*x.list)[i] = concreteValue +} + +func (x *_GrantQueueItem_1_list) Append(value protoreflect.Value) { + valueUnwrapped := value.String() + concreteValue := valueUnwrapped + *x.list = append(*x.list, concreteValue) +} + +func (x *_GrantQueueItem_1_list) AppendMutable() protoreflect.Value { + panic(fmt.Errorf("AppendMutable can not be called on message GrantQueueItem at list field MsgTypeUrls as it is not of Message kind")) +} + +func (x *_GrantQueueItem_1_list) Truncate(n int) { + *x.list = (*x.list)[:n] +} + +func (x *_GrantQueueItem_1_list) NewElement() protoreflect.Value { + v := "" + return protoreflect.ValueOfString(v) +} + +func (x *_GrantQueueItem_1_list) IsValid() bool { + return x.list != nil +} + +var ( + md_GrantQueueItem protoreflect.MessageDescriptor + fd_GrantQueueItem_msg_type_urls protoreflect.FieldDescriptor +) + +func init() { + file_cosmos_authz_v1beta1_authz_proto_init() + md_GrantQueueItem = File_cosmos_authz_v1beta1_authz_proto.Messages().ByName("GrantQueueItem") + fd_GrantQueueItem_msg_type_urls = md_GrantQueueItem.Fields().ByName("msg_type_urls") +} + +var _ protoreflect.Message = (*fastReflection_GrantQueueItem)(nil) + +type fastReflection_GrantQueueItem GrantQueueItem + +func (x *GrantQueueItem) ProtoReflect() protoreflect.Message { + return (*fastReflection_GrantQueueItem)(x) +} + +func (x *GrantQueueItem) slowProtoReflect() protoreflect.Message { + mi := &file_cosmos_authz_v1beta1_authz_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_GrantQueueItem_messageType fastReflection_GrantQueueItem_messageType +var _ protoreflect.MessageType = fastReflection_GrantQueueItem_messageType{} + +type fastReflection_GrantQueueItem_messageType struct{} + +func (x fastReflection_GrantQueueItem_messageType) Zero() protoreflect.Message { + return (*fastReflection_GrantQueueItem)(nil) +} +func (x fastReflection_GrantQueueItem_messageType) New() protoreflect.Message { + return new(fastReflection_GrantQueueItem) +} +func (x fastReflection_GrantQueueItem_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_GrantQueueItem +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_GrantQueueItem) Descriptor() protoreflect.MessageDescriptor { + return md_GrantQueueItem +} + +// 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_GrantQueueItem) Type() protoreflect.MessageType { + return _fastReflection_GrantQueueItem_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_GrantQueueItem) New() protoreflect.Message { + return new(fastReflection_GrantQueueItem) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_GrantQueueItem) Interface() protoreflect.ProtoMessage { + return (*GrantQueueItem)(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_GrantQueueItem) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if len(x.MsgTypeUrls) != 0 { + value := protoreflect.ValueOfList(&_GrantQueueItem_1_list{list: &x.MsgTypeUrls}) + if !f(fd_GrantQueueItem_msg_type_urls, 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_GrantQueueItem) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "cosmos.authz.v1beta1.GrantQueueItem.msg_type_urls": + return len(x.MsgTypeUrls) != 0 + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.GrantQueueItem")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.GrantQueueItem 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_GrantQueueItem) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "cosmos.authz.v1beta1.GrantQueueItem.msg_type_urls": + x.MsgTypeUrls = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.GrantQueueItem")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.GrantQueueItem 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_GrantQueueItem) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "cosmos.authz.v1beta1.GrantQueueItem.msg_type_urls": + if len(x.MsgTypeUrls) == 0 { + return protoreflect.ValueOfList(&_GrantQueueItem_1_list{}) + } + listValue := &_GrantQueueItem_1_list{list: &x.MsgTypeUrls} + return protoreflect.ValueOfList(listValue) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.GrantQueueItem")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.GrantQueueItem 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_GrantQueueItem) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "cosmos.authz.v1beta1.GrantQueueItem.msg_type_urls": + lv := value.List() + clv := lv.(*_GrantQueueItem_1_list) + x.MsgTypeUrls = *clv.list + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.GrantQueueItem")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.GrantQueueItem 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_GrantQueueItem) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.authz.v1beta1.GrantQueueItem.msg_type_urls": + if x.MsgTypeUrls == nil { + x.MsgTypeUrls = []string{} + } + value := &_GrantQueueItem_1_list{list: &x.MsgTypeUrls} + return protoreflect.ValueOfList(value) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.GrantQueueItem")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.GrantQueueItem 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_GrantQueueItem) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.authz.v1beta1.GrantQueueItem.msg_type_urls": + list := []string{} + return protoreflect.ValueOfList(&_GrantQueueItem_1_list{list: &list}) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.GrantQueueItem")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.GrantQueueItem 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_GrantQueueItem) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.authz.v1beta1.GrantQueueItem", 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_GrantQueueItem) 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_GrantQueueItem) 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_GrantQueueItem) 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_GrantQueueItem) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*GrantQueueItem) + 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.MsgTypeUrls) > 0 { + for _, s := range x.MsgTypeUrls { + l = len(s) + 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().(*GrantQueueItem) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if len(x.MsgTypeUrls) > 0 { + for iNdEx := len(x.MsgTypeUrls) - 1; iNdEx >= 0; iNdEx-- { + i -= len(x.MsgTypeUrls[iNdEx]) + copy(dAtA[i:], x.MsgTypeUrls[iNdEx]) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.MsgTypeUrls[iNdEx]))) + 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().(*GrantQueueItem) + 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: GrantQueueItem: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: GrantQueueItem: 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 MsgTypeUrls", 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.MsgTypeUrls = append(x.MsgTypeUrls, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +var _ protoreflect.List = (*_AllowedGrantRulesKeys_1_list)(nil) + +type _AllowedGrantRulesKeys_1_list struct { + list *[]*Rule +} + +func (x *_AllowedGrantRulesKeys_1_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_AllowedGrantRulesKeys_1_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfMessage((*x.list)[i].ProtoReflect()) +} + +func (x *_AllowedGrantRulesKeys_1_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*Rule) + (*x.list)[i] = concreteValue +} + +func (x *_AllowedGrantRulesKeys_1_list) Append(value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*Rule) + *x.list = append(*x.list, concreteValue) +} + +func (x *_AllowedGrantRulesKeys_1_list) AppendMutable() protoreflect.Value { + v := new(Rule) + *x.list = append(*x.list, v) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_AllowedGrantRulesKeys_1_list) Truncate(n int) { + for i := n; i < len(*x.list); i++ { + (*x.list)[i] = nil + } + *x.list = (*x.list)[:n] +} + +func (x *_AllowedGrantRulesKeys_1_list) NewElement() protoreflect.Value { + v := new(Rule) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_AllowedGrantRulesKeys_1_list) IsValid() bool { + return x.list != nil +} + +var ( + md_AllowedGrantRulesKeys protoreflect.MessageDescriptor + fd_AllowedGrantRulesKeys_keys protoreflect.FieldDescriptor +) + +func init() { + file_cosmos_authz_v1beta1_authz_proto_init() + md_AllowedGrantRulesKeys = File_cosmos_authz_v1beta1_authz_proto.Messages().ByName("AllowedGrantRulesKeys") + fd_AllowedGrantRulesKeys_keys = md_AllowedGrantRulesKeys.Fields().ByName("keys") +} + +var _ protoreflect.Message = (*fastReflection_AllowedGrantRulesKeys)(nil) + +type fastReflection_AllowedGrantRulesKeys AllowedGrantRulesKeys + +func (x *AllowedGrantRulesKeys) ProtoReflect() protoreflect.Message { + return (*fastReflection_AllowedGrantRulesKeys)(x) +} + +func (x *AllowedGrantRulesKeys) slowProtoReflect() protoreflect.Message { + mi := &file_cosmos_authz_v1beta1_authz_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_AllowedGrantRulesKeys_messageType fastReflection_AllowedGrantRulesKeys_messageType +var _ protoreflect.MessageType = fastReflection_AllowedGrantRulesKeys_messageType{} + +type fastReflection_AllowedGrantRulesKeys_messageType struct{} + +func (x fastReflection_AllowedGrantRulesKeys_messageType) Zero() protoreflect.Message { + return (*fastReflection_AllowedGrantRulesKeys)(nil) +} +func (x fastReflection_AllowedGrantRulesKeys_messageType) New() protoreflect.Message { + return new(fastReflection_AllowedGrantRulesKeys) +} +func (x fastReflection_AllowedGrantRulesKeys_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_AllowedGrantRulesKeys +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_AllowedGrantRulesKeys) Descriptor() protoreflect.MessageDescriptor { + return md_AllowedGrantRulesKeys +} + +// 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_AllowedGrantRulesKeys) Type() protoreflect.MessageType { + return _fastReflection_AllowedGrantRulesKeys_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_AllowedGrantRulesKeys) New() protoreflect.Message { + return new(fastReflection_AllowedGrantRulesKeys) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_AllowedGrantRulesKeys) Interface() protoreflect.ProtoMessage { + return (*AllowedGrantRulesKeys)(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_AllowedGrantRulesKeys) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if len(x.Keys) != 0 { + value := protoreflect.ValueOfList(&_AllowedGrantRulesKeys_1_list{list: &x.Keys}) + if !f(fd_AllowedGrantRulesKeys_keys, 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_AllowedGrantRulesKeys) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "cosmos.authz.v1beta1.AllowedGrantRulesKeys.keys": + return len(x.Keys) != 0 + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.AllowedGrantRulesKeys")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.AllowedGrantRulesKeys 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_AllowedGrantRulesKeys) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "cosmos.authz.v1beta1.AllowedGrantRulesKeys.keys": + x.Keys = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.AllowedGrantRulesKeys")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.AllowedGrantRulesKeys 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_AllowedGrantRulesKeys) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "cosmos.authz.v1beta1.AllowedGrantRulesKeys.keys": + if len(x.Keys) == 0 { + return protoreflect.ValueOfList(&_AllowedGrantRulesKeys_1_list{}) + } + listValue := &_AllowedGrantRulesKeys_1_list{list: &x.Keys} + return protoreflect.ValueOfList(listValue) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.AllowedGrantRulesKeys")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.AllowedGrantRulesKeys 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_AllowedGrantRulesKeys) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "cosmos.authz.v1beta1.AllowedGrantRulesKeys.keys": + lv := value.List() + clv := lv.(*_AllowedGrantRulesKeys_1_list) + x.Keys = *clv.list + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.AllowedGrantRulesKeys")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.AllowedGrantRulesKeys 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_AllowedGrantRulesKeys) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.authz.v1beta1.AllowedGrantRulesKeys.keys": + if x.Keys == nil { + x.Keys = []*Rule{} + } + value := &_AllowedGrantRulesKeys_1_list{list: &x.Keys} + return protoreflect.ValueOfList(value) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.AllowedGrantRulesKeys")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.AllowedGrantRulesKeys 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_AllowedGrantRulesKeys) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.authz.v1beta1.AllowedGrantRulesKeys.keys": + list := []*Rule{} + return protoreflect.ValueOfList(&_AllowedGrantRulesKeys_1_list{list: &list}) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.AllowedGrantRulesKeys")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.AllowedGrantRulesKeys 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_AllowedGrantRulesKeys) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.authz.v1beta1.AllowedGrantRulesKeys", 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_AllowedGrantRulesKeys) 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_AllowedGrantRulesKeys) 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_AllowedGrantRulesKeys) 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_AllowedGrantRulesKeys) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*AllowedGrantRulesKeys) + 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.Keys) > 0 { + for _, e := range x.Keys { + l = options.Size(e) + 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().(*AllowedGrantRulesKeys) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if len(x.Keys) > 0 { + for iNdEx := len(x.Keys) - 1; iNdEx >= 0; iNdEx-- { + encoded, err := options.Marshal(x.Keys[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().(*AllowedGrantRulesKeys) + 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: AllowedGrantRulesKeys: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: AllowedGrantRulesKeys: 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 Keys", 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.Keys = append(x.Keys, &Rule{}) + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Keys[len(x.Keys)-1]); 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 = (*_AppAuthzRules_1_list)(nil) + +type _AppAuthzRules_1_list struct { + list *[]string +} + +func (x *_AppAuthzRules_1_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_AppAuthzRules_1_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfString((*x.list)[i]) +} + +func (x *_AppAuthzRules_1_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.String() + concreteValue := valueUnwrapped + (*x.list)[i] = concreteValue +} + +func (x *_AppAuthzRules_1_list) Append(value protoreflect.Value) { + valueUnwrapped := value.String() + concreteValue := valueUnwrapped + *x.list = append(*x.list, concreteValue) +} + +func (x *_AppAuthzRules_1_list) AppendMutable() protoreflect.Value { + panic(fmt.Errorf("AppendMutable can not be called on message AppAuthzRules at list field AllowedRecipients as it is not of Message kind")) +} + +func (x *_AppAuthzRules_1_list) Truncate(n int) { + *x.list = (*x.list)[:n] +} + +func (x *_AppAuthzRules_1_list) NewElement() protoreflect.Value { + v := "" + return protoreflect.ValueOfString(v) +} + +func (x *_AppAuthzRules_1_list) IsValid() bool { + return x.list != nil +} + +var _ protoreflect.List = (*_AppAuthzRules_2_list)(nil) + +type _AppAuthzRules_2_list struct { + list *[]string +} + +func (x *_AppAuthzRules_2_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_AppAuthzRules_2_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfString((*x.list)[i]) +} + +func (x *_AppAuthzRules_2_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.String() + concreteValue := valueUnwrapped + (*x.list)[i] = concreteValue +} + +func (x *_AppAuthzRules_2_list) Append(value protoreflect.Value) { + valueUnwrapped := value.String() + concreteValue := valueUnwrapped + *x.list = append(*x.list, concreteValue) +} + +func (x *_AppAuthzRules_2_list) AppendMutable() protoreflect.Value { + panic(fmt.Errorf("AppendMutable can not be called on message AppAuthzRules at list field MaxAmount as it is not of Message kind")) +} + +func (x *_AppAuthzRules_2_list) Truncate(n int) { + *x.list = (*x.list)[:n] +} + +func (x *_AppAuthzRules_2_list) NewElement() protoreflect.Value { + v := "" + return protoreflect.ValueOfString(v) +} + +func (x *_AppAuthzRules_2_list) IsValid() bool { + return x.list != nil +} + +var _ protoreflect.List = (*_AppAuthzRules_3_list)(nil) + +type _AppAuthzRules_3_list struct { + list *[]string +} + +func (x *_AppAuthzRules_3_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_AppAuthzRules_3_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfString((*x.list)[i]) +} + +func (x *_AppAuthzRules_3_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.String() + concreteValue := valueUnwrapped + (*x.list)[i] = concreteValue +} + +func (x *_AppAuthzRules_3_list) Append(value protoreflect.Value) { + valueUnwrapped := value.String() + concreteValue := valueUnwrapped + *x.list = append(*x.list, concreteValue) +} + +func (x *_AppAuthzRules_3_list) AppendMutable() protoreflect.Value { + panic(fmt.Errorf("AppendMutable can not be called on message AppAuthzRules at list field AllowedStakeValidators as it is not of Message kind")) +} + +func (x *_AppAuthzRules_3_list) Truncate(n int) { + *x.list = (*x.list)[:n] +} + +func (x *_AppAuthzRules_3_list) NewElement() protoreflect.Value { + v := "" + return protoreflect.ValueOfString(v) +} + +func (x *_AppAuthzRules_3_list) IsValid() bool { + return x.list != nil +} + +var _ protoreflect.List = (*_AppAuthzRules_4_list)(nil) + +type _AppAuthzRules_4_list struct { + list *[]string +} + +func (x *_AppAuthzRules_4_list) Len() int { + if x.list == nil { + return 0 } + return len(*x.list) } -var _ protoreflect.List = (*_GrantQueueItem_1_list)(nil) +func (x *_AppAuthzRules_4_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfString((*x.list)[i]) +} -type _GrantQueueItem_1_list struct { +func (x *_AppAuthzRules_4_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.String() + concreteValue := valueUnwrapped + (*x.list)[i] = concreteValue +} + +func (x *_AppAuthzRules_4_list) Append(value protoreflect.Value) { + valueUnwrapped := value.String() + concreteValue := valueUnwrapped + *x.list = append(*x.list, concreteValue) +} + +func (x *_AppAuthzRules_4_list) AppendMutable() protoreflect.Value { + panic(fmt.Errorf("AppendMutable can not be called on message AppAuthzRules at list field AllowedMaxStakeAmount as it is not of Message kind")) +} + +func (x *_AppAuthzRules_4_list) Truncate(n int) { + *x.list = (*x.list)[:n] +} + +func (x *_AppAuthzRules_4_list) NewElement() protoreflect.Value { + v := "" + return protoreflect.ValueOfString(v) +} + +func (x *_AppAuthzRules_4_list) IsValid() bool { + return x.list != nil +} + +var _ protoreflect.List = (*_AppAuthzRules_5_list)(nil) + +type _AppAuthzRules_5_list struct { list *[]string } -func (x *_GrantQueueItem_1_list) Len() int { +func (x *_AppAuthzRules_5_list) Len() int { if x.list == nil { return 0 } return len(*x.list) } -func (x *_GrantQueueItem_1_list) Get(i int) protoreflect.Value { +func (x *_AppAuthzRules_5_list) Get(i int) protoreflect.Value { return protoreflect.ValueOfString((*x.list)[i]) } -func (x *_GrantQueueItem_1_list) Set(i int, value protoreflect.Value) { +func (x *_AppAuthzRules_5_list) Set(i int, value protoreflect.Value) { valueUnwrapped := value.String() concreteValue := valueUnwrapped (*x.list)[i] = concreteValue } -func (x *_GrantQueueItem_1_list) Append(value protoreflect.Value) { +func (x *_AppAuthzRules_5_list) Append(value protoreflect.Value) { valueUnwrapped := value.String() concreteValue := valueUnwrapped *x.list = append(*x.list, concreteValue) } -func (x *_GrantQueueItem_1_list) AppendMutable() protoreflect.Value { - panic(fmt.Errorf("AppendMutable can not be called on message GrantQueueItem at list field MsgTypeUrls as it is not of Message kind")) +func (x *_AppAuthzRules_5_list) AppendMutable() protoreflect.Value { + panic(fmt.Errorf("AppendMutable can not be called on message AppAuthzRules at list field AllowedProposalTypes as it is not of Message kind")) } -func (x *_GrantQueueItem_1_list) Truncate(n int) { +func (x *_AppAuthzRules_5_list) Truncate(n int) { *x.list = (*x.list)[:n] } -func (x *_GrantQueueItem_1_list) NewElement() protoreflect.Value { +func (x *_AppAuthzRules_5_list) NewElement() protoreflect.Value { v := "" return protoreflect.ValueOfString(v) } -func (x *_GrantQueueItem_1_list) IsValid() bool { +func (x *_AppAuthzRules_5_list) IsValid() bool { return x.list != nil } var ( - md_GrantQueueItem protoreflect.MessageDescriptor - fd_GrantQueueItem_msg_type_urls protoreflect.FieldDescriptor + md_AppAuthzRules protoreflect.MessageDescriptor + fd_AppAuthzRules_allowed_recipients protoreflect.FieldDescriptor + fd_AppAuthzRules_max_amount protoreflect.FieldDescriptor + fd_AppAuthzRules_allowed_stake_validators protoreflect.FieldDescriptor + fd_AppAuthzRules_allowed_max_stake_amount protoreflect.FieldDescriptor + fd_AppAuthzRules_allowed_proposal_types protoreflect.FieldDescriptor ) func init() { file_cosmos_authz_v1beta1_authz_proto_init() - md_GrantQueueItem = File_cosmos_authz_v1beta1_authz_proto.Messages().ByName("GrantQueueItem") - fd_GrantQueueItem_msg_type_urls = md_GrantQueueItem.Fields().ByName("msg_type_urls") + md_AppAuthzRules = File_cosmos_authz_v1beta1_authz_proto.Messages().ByName("AppAuthzRules") + fd_AppAuthzRules_allowed_recipients = md_AppAuthzRules.Fields().ByName("allowed_recipients") + fd_AppAuthzRules_max_amount = md_AppAuthzRules.Fields().ByName("max_amount") + fd_AppAuthzRules_allowed_stake_validators = md_AppAuthzRules.Fields().ByName("allowed_stake_validators") + fd_AppAuthzRules_allowed_max_stake_amount = md_AppAuthzRules.Fields().ByName("allowed_max_stake_amount") + fd_AppAuthzRules_allowed_proposal_types = md_AppAuthzRules.Fields().ByName("allowed_proposal_types") } -var _ protoreflect.Message = (*fastReflection_GrantQueueItem)(nil) +var _ protoreflect.Message = (*fastReflection_AppAuthzRules)(nil) -type fastReflection_GrantQueueItem GrantQueueItem +type fastReflection_AppAuthzRules AppAuthzRules -func (x *GrantQueueItem) ProtoReflect() protoreflect.Message { - return (*fastReflection_GrantQueueItem)(x) +func (x *AppAuthzRules) ProtoReflect() protoreflect.Message { + return (*fastReflection_AppAuthzRules)(x) } -func (x *GrantQueueItem) slowProtoReflect() protoreflect.Message { - mi := &file_cosmos_authz_v1beta1_authz_proto_msgTypes[3] +func (x *AppAuthzRules) slowProtoReflect() protoreflect.Message { + mi := &file_cosmos_authz_v1beta1_authz_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1670,43 +3518,43 @@ func (x *GrantQueueItem) slowProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -var _fastReflection_GrantQueueItem_messageType fastReflection_GrantQueueItem_messageType -var _ protoreflect.MessageType = fastReflection_GrantQueueItem_messageType{} +var _fastReflection_AppAuthzRules_messageType fastReflection_AppAuthzRules_messageType +var _ protoreflect.MessageType = fastReflection_AppAuthzRules_messageType{} -type fastReflection_GrantQueueItem_messageType struct{} +type fastReflection_AppAuthzRules_messageType struct{} -func (x fastReflection_GrantQueueItem_messageType) Zero() protoreflect.Message { - return (*fastReflection_GrantQueueItem)(nil) +func (x fastReflection_AppAuthzRules_messageType) Zero() protoreflect.Message { + return (*fastReflection_AppAuthzRules)(nil) } -func (x fastReflection_GrantQueueItem_messageType) New() protoreflect.Message { - return new(fastReflection_GrantQueueItem) +func (x fastReflection_AppAuthzRules_messageType) New() protoreflect.Message { + return new(fastReflection_AppAuthzRules) } -func (x fastReflection_GrantQueueItem_messageType) Descriptor() protoreflect.MessageDescriptor { - return md_GrantQueueItem +func (x fastReflection_AppAuthzRules_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_AppAuthzRules } // Descriptor returns message descriptor, which contains only the protobuf // type information for the message. -func (x *fastReflection_GrantQueueItem) Descriptor() protoreflect.MessageDescriptor { - return md_GrantQueueItem +func (x *fastReflection_AppAuthzRules) Descriptor() protoreflect.MessageDescriptor { + return md_AppAuthzRules } // 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_GrantQueueItem) Type() protoreflect.MessageType { - return _fastReflection_GrantQueueItem_messageType +func (x *fastReflection_AppAuthzRules) Type() protoreflect.MessageType { + return _fastReflection_AppAuthzRules_messageType } // New returns a newly allocated and mutable empty message. -func (x *fastReflection_GrantQueueItem) New() protoreflect.Message { - return new(fastReflection_GrantQueueItem) +func (x *fastReflection_AppAuthzRules) New() protoreflect.Message { + return new(fastReflection_AppAuthzRules) } // Interface unwraps the message reflection interface and // returns the underlying ProtoMessage interface. -func (x *fastReflection_GrantQueueItem) Interface() protoreflect.ProtoMessage { - return (*GrantQueueItem)(x) +func (x *fastReflection_AppAuthzRules) Interface() protoreflect.ProtoMessage { + return (*AppAuthzRules)(x) } // Range iterates over every populated field in an undefined order, @@ -1714,10 +3562,34 @@ func (x *fastReflection_GrantQueueItem) Interface() protoreflect.ProtoMessage { // Range returns immediately if f returns false. // While iterating, mutating operations may only be performed // on the current field descriptor. -func (x *fastReflection_GrantQueueItem) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { - if len(x.MsgTypeUrls) != 0 { - value := protoreflect.ValueOfList(&_GrantQueueItem_1_list{list: &x.MsgTypeUrls}) - if !f(fd_GrantQueueItem_msg_type_urls, value) { +func (x *fastReflection_AppAuthzRules) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if len(x.AllowedRecipients) != 0 { + value := protoreflect.ValueOfList(&_AppAuthzRules_1_list{list: &x.AllowedRecipients}) + if !f(fd_AppAuthzRules_allowed_recipients, value) { + return + } + } + if len(x.MaxAmount) != 0 { + value := protoreflect.ValueOfList(&_AppAuthzRules_2_list{list: &x.MaxAmount}) + if !f(fd_AppAuthzRules_max_amount, value) { + return + } + } + if len(x.AllowedStakeValidators) != 0 { + value := protoreflect.ValueOfList(&_AppAuthzRules_3_list{list: &x.AllowedStakeValidators}) + if !f(fd_AppAuthzRules_allowed_stake_validators, value) { + return + } + } + if len(x.AllowedMaxStakeAmount) != 0 { + value := protoreflect.ValueOfList(&_AppAuthzRules_4_list{list: &x.AllowedMaxStakeAmount}) + if !f(fd_AppAuthzRules_allowed_max_stake_amount, value) { + return + } + } + if len(x.AllowedProposalTypes) != 0 { + value := protoreflect.ValueOfList(&_AppAuthzRules_5_list{list: &x.AllowedProposalTypes}) + if !f(fd_AppAuthzRules_allowed_proposal_types, value) { return } } @@ -1734,15 +3606,23 @@ func (x *fastReflection_GrantQueueItem) Range(f func(protoreflect.FieldDescripto // 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_GrantQueueItem) Has(fd protoreflect.FieldDescriptor) bool { +func (x *fastReflection_AppAuthzRules) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { - case "cosmos.authz.v1beta1.GrantQueueItem.msg_type_urls": - return len(x.MsgTypeUrls) != 0 + case "cosmos.authz.v1beta1.AppAuthzRules.allowed_recipients": + return len(x.AllowedRecipients) != 0 + case "cosmos.authz.v1beta1.AppAuthzRules.max_amount": + return len(x.MaxAmount) != 0 + case "cosmos.authz.v1beta1.AppAuthzRules.allowed_stake_validators": + return len(x.AllowedStakeValidators) != 0 + case "cosmos.authz.v1beta1.AppAuthzRules.allowed_max_stake_amount": + return len(x.AllowedMaxStakeAmount) != 0 + case "cosmos.authz.v1beta1.AppAuthzRules.allowed_proposal_types": + return len(x.AllowedProposalTypes) != 0 default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.GrantQueueItem")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.AppAuthzRules")) } - panic(fmt.Errorf("message cosmos.authz.v1beta1.GrantQueueItem does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message cosmos.authz.v1beta1.AppAuthzRules does not contain field %s", fd.FullName())) } } @@ -1752,15 +3632,23 @@ func (x *fastReflection_GrantQueueItem) Has(fd protoreflect.FieldDescriptor) boo // associated with the given field number. // // Clear is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_GrantQueueItem) Clear(fd protoreflect.FieldDescriptor) { +func (x *fastReflection_AppAuthzRules) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { - case "cosmos.authz.v1beta1.GrantQueueItem.msg_type_urls": - x.MsgTypeUrls = nil + case "cosmos.authz.v1beta1.AppAuthzRules.allowed_recipients": + x.AllowedRecipients = nil + case "cosmos.authz.v1beta1.AppAuthzRules.max_amount": + x.MaxAmount = nil + case "cosmos.authz.v1beta1.AppAuthzRules.allowed_stake_validators": + x.AllowedStakeValidators = nil + case "cosmos.authz.v1beta1.AppAuthzRules.allowed_max_stake_amount": + x.AllowedMaxStakeAmount = nil + case "cosmos.authz.v1beta1.AppAuthzRules.allowed_proposal_types": + x.AllowedProposalTypes = nil default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.GrantQueueItem")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.AppAuthzRules")) } - panic(fmt.Errorf("message cosmos.authz.v1beta1.GrantQueueItem does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message cosmos.authz.v1beta1.AppAuthzRules does not contain field %s", fd.FullName())) } } @@ -1770,19 +3658,43 @@ func (x *fastReflection_GrantQueueItem) Clear(fd protoreflect.FieldDescriptor) { // 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_GrantQueueItem) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { +func (x *fastReflection_AppAuthzRules) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { switch descriptor.FullName() { - case "cosmos.authz.v1beta1.GrantQueueItem.msg_type_urls": - if len(x.MsgTypeUrls) == 0 { - return protoreflect.ValueOfList(&_GrantQueueItem_1_list{}) + case "cosmos.authz.v1beta1.AppAuthzRules.allowed_recipients": + if len(x.AllowedRecipients) == 0 { + return protoreflect.ValueOfList(&_AppAuthzRules_1_list{}) } - listValue := &_GrantQueueItem_1_list{list: &x.MsgTypeUrls} + listValue := &_AppAuthzRules_1_list{list: &x.AllowedRecipients} + return protoreflect.ValueOfList(listValue) + case "cosmos.authz.v1beta1.AppAuthzRules.max_amount": + if len(x.MaxAmount) == 0 { + return protoreflect.ValueOfList(&_AppAuthzRules_2_list{}) + } + listValue := &_AppAuthzRules_2_list{list: &x.MaxAmount} + return protoreflect.ValueOfList(listValue) + case "cosmos.authz.v1beta1.AppAuthzRules.allowed_stake_validators": + if len(x.AllowedStakeValidators) == 0 { + return protoreflect.ValueOfList(&_AppAuthzRules_3_list{}) + } + listValue := &_AppAuthzRules_3_list{list: &x.AllowedStakeValidators} + return protoreflect.ValueOfList(listValue) + case "cosmos.authz.v1beta1.AppAuthzRules.allowed_max_stake_amount": + if len(x.AllowedMaxStakeAmount) == 0 { + return protoreflect.ValueOfList(&_AppAuthzRules_4_list{}) + } + listValue := &_AppAuthzRules_4_list{list: &x.AllowedMaxStakeAmount} + return protoreflect.ValueOfList(listValue) + case "cosmos.authz.v1beta1.AppAuthzRules.allowed_proposal_types": + if len(x.AllowedProposalTypes) == 0 { + return protoreflect.ValueOfList(&_AppAuthzRules_5_list{}) + } + listValue := &_AppAuthzRules_5_list{list: &x.AllowedProposalTypes} return protoreflect.ValueOfList(listValue) default: if descriptor.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.GrantQueueItem")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.AppAuthzRules")) } - panic(fmt.Errorf("message cosmos.authz.v1beta1.GrantQueueItem does not contain field %s", descriptor.FullName())) + panic(fmt.Errorf("message cosmos.authz.v1beta1.AppAuthzRules does not contain field %s", descriptor.FullName())) } } @@ -1796,17 +3708,33 @@ func (x *fastReflection_GrantQueueItem) Get(descriptor protoreflect.FieldDescrip // empty, read-only value, then it panics. // // Set is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_GrantQueueItem) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { +func (x *fastReflection_AppAuthzRules) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { switch fd.FullName() { - case "cosmos.authz.v1beta1.GrantQueueItem.msg_type_urls": + case "cosmos.authz.v1beta1.AppAuthzRules.allowed_recipients": lv := value.List() - clv := lv.(*_GrantQueueItem_1_list) - x.MsgTypeUrls = *clv.list + clv := lv.(*_AppAuthzRules_1_list) + x.AllowedRecipients = *clv.list + case "cosmos.authz.v1beta1.AppAuthzRules.max_amount": + lv := value.List() + clv := lv.(*_AppAuthzRules_2_list) + x.MaxAmount = *clv.list + case "cosmos.authz.v1beta1.AppAuthzRules.allowed_stake_validators": + lv := value.List() + clv := lv.(*_AppAuthzRules_3_list) + x.AllowedStakeValidators = *clv.list + case "cosmos.authz.v1beta1.AppAuthzRules.allowed_max_stake_amount": + lv := value.List() + clv := lv.(*_AppAuthzRules_4_list) + x.AllowedMaxStakeAmount = *clv.list + case "cosmos.authz.v1beta1.AppAuthzRules.allowed_proposal_types": + lv := value.List() + clv := lv.(*_AppAuthzRules_5_list) + x.AllowedProposalTypes = *clv.list default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.GrantQueueItem")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.AppAuthzRules")) } - panic(fmt.Errorf("message cosmos.authz.v1beta1.GrantQueueItem does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message cosmos.authz.v1beta1.AppAuthzRules does not contain field %s", fd.FullName())) } } @@ -1820,45 +3748,81 @@ func (x *fastReflection_GrantQueueItem) Set(fd protoreflect.FieldDescriptor, val // It panics if the field does not contain a composite type. // // Mutable is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_GrantQueueItem) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { +func (x *fastReflection_AppAuthzRules) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "cosmos.authz.v1beta1.GrantQueueItem.msg_type_urls": - if x.MsgTypeUrls == nil { - x.MsgTypeUrls = []string{} + case "cosmos.authz.v1beta1.AppAuthzRules.allowed_recipients": + if x.AllowedRecipients == nil { + x.AllowedRecipients = []string{} } - value := &_GrantQueueItem_1_list{list: &x.MsgTypeUrls} + value := &_AppAuthzRules_1_list{list: &x.AllowedRecipients} + return protoreflect.ValueOfList(value) + case "cosmos.authz.v1beta1.AppAuthzRules.max_amount": + if x.MaxAmount == nil { + x.MaxAmount = []string{} + } + value := &_AppAuthzRules_2_list{list: &x.MaxAmount} + return protoreflect.ValueOfList(value) + case "cosmos.authz.v1beta1.AppAuthzRules.allowed_stake_validators": + if x.AllowedStakeValidators == nil { + x.AllowedStakeValidators = []string{} + } + value := &_AppAuthzRules_3_list{list: &x.AllowedStakeValidators} + return protoreflect.ValueOfList(value) + case "cosmos.authz.v1beta1.AppAuthzRules.allowed_max_stake_amount": + if x.AllowedMaxStakeAmount == nil { + x.AllowedMaxStakeAmount = []string{} + } + value := &_AppAuthzRules_4_list{list: &x.AllowedMaxStakeAmount} + return protoreflect.ValueOfList(value) + case "cosmos.authz.v1beta1.AppAuthzRules.allowed_proposal_types": + if x.AllowedProposalTypes == nil { + x.AllowedProposalTypes = []string{} + } + value := &_AppAuthzRules_5_list{list: &x.AllowedProposalTypes} return protoreflect.ValueOfList(value) default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.GrantQueueItem")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.AppAuthzRules")) } - panic(fmt.Errorf("message cosmos.authz.v1beta1.GrantQueueItem does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message cosmos.authz.v1beta1.AppAuthzRules 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_GrantQueueItem) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { +func (x *fastReflection_AppAuthzRules) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "cosmos.authz.v1beta1.GrantQueueItem.msg_type_urls": + case "cosmos.authz.v1beta1.AppAuthzRules.allowed_recipients": list := []string{} - return protoreflect.ValueOfList(&_GrantQueueItem_1_list{list: &list}) + return protoreflect.ValueOfList(&_AppAuthzRules_1_list{list: &list}) + case "cosmos.authz.v1beta1.AppAuthzRules.max_amount": + list := []string{} + return protoreflect.ValueOfList(&_AppAuthzRules_2_list{list: &list}) + case "cosmos.authz.v1beta1.AppAuthzRules.allowed_stake_validators": + list := []string{} + return protoreflect.ValueOfList(&_AppAuthzRules_3_list{list: &list}) + case "cosmos.authz.v1beta1.AppAuthzRules.allowed_max_stake_amount": + list := []string{} + return protoreflect.ValueOfList(&_AppAuthzRules_4_list{list: &list}) + case "cosmos.authz.v1beta1.AppAuthzRules.allowed_proposal_types": + list := []string{} + return protoreflect.ValueOfList(&_AppAuthzRules_5_list{list: &list}) default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.GrantQueueItem")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.AppAuthzRules")) } - panic(fmt.Errorf("message cosmos.authz.v1beta1.GrantQueueItem does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message cosmos.authz.v1beta1.AppAuthzRules 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_GrantQueueItem) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { +func (x *fastReflection_AppAuthzRules) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { switch d.FullName() { default: - panic(fmt.Errorf("%s is not a oneof field in cosmos.authz.v1beta1.GrantQueueItem", d.FullName())) + panic(fmt.Errorf("%s is not a oneof field in cosmos.authz.v1beta1.AppAuthzRules", d.FullName())) } panic("unreachable") } @@ -1866,7 +3830,7 @@ func (x *fastReflection_GrantQueueItem) WhichOneof(d protoreflect.OneofDescripto // 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_GrantQueueItem) GetUnknown() protoreflect.RawFields { +func (x *fastReflection_AppAuthzRules) GetUnknown() protoreflect.RawFields { return x.unknownFields } @@ -1877,7 +3841,7 @@ func (x *fastReflection_GrantQueueItem) GetUnknown() protoreflect.RawFields { // An empty RawFields may be passed to clear the fields. // // SetUnknown is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_GrantQueueItem) SetUnknown(fields protoreflect.RawFields) { +func (x *fastReflection_AppAuthzRules) SetUnknown(fields protoreflect.RawFields) { x.unknownFields = fields } @@ -1889,7 +3853,7 @@ func (x *fastReflection_GrantQueueItem) SetUnknown(fields protoreflect.RawFields // 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_GrantQueueItem) IsValid() bool { +func (x *fastReflection_AppAuthzRules) IsValid() bool { return x != nil } @@ -1899,9 +3863,9 @@ func (x *fastReflection_GrantQueueItem) IsValid() bool { // The returned methods type is identical to // "google.golang.org/protobuf/runtime/protoiface".Methods. // Consult the protoiface package documentation for details. -func (x *fastReflection_GrantQueueItem) ProtoMethods() *protoiface.Methods { +func (x *fastReflection_AppAuthzRules) ProtoMethods() *protoiface.Methods { size := func(input protoiface.SizeInput) protoiface.SizeOutput { - x := input.Message.Interface().(*GrantQueueItem) + x := input.Message.Interface().(*AppAuthzRules) if x == nil { return protoiface.SizeOutput{ NoUnkeyedLiterals: input.NoUnkeyedLiterals, @@ -1913,8 +3877,32 @@ func (x *fastReflection_GrantQueueItem) ProtoMethods() *protoiface.Methods { var n int var l int _ = l - if len(x.MsgTypeUrls) > 0 { - for _, s := range x.MsgTypeUrls { + if len(x.AllowedRecipients) > 0 { + for _, s := range x.AllowedRecipients { + l = len(s) + n += 1 + l + runtime.Sov(uint64(l)) + } + } + if len(x.MaxAmount) > 0 { + for _, s := range x.MaxAmount { + l = len(s) + n += 1 + l + runtime.Sov(uint64(l)) + } + } + if len(x.AllowedStakeValidators) > 0 { + for _, s := range x.AllowedStakeValidators { + l = len(s) + n += 1 + l + runtime.Sov(uint64(l)) + } + } + if len(x.AllowedMaxStakeAmount) > 0 { + for _, s := range x.AllowedMaxStakeAmount { + l = len(s) + n += 1 + l + runtime.Sov(uint64(l)) + } + } + if len(x.AllowedProposalTypes) > 0 { + for _, s := range x.AllowedProposalTypes { l = len(s) n += 1 + l + runtime.Sov(uint64(l)) } @@ -1929,7 +3917,7 @@ func (x *fastReflection_GrantQueueItem) ProtoMethods() *protoiface.Methods { } marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { - x := input.Message.Interface().(*GrantQueueItem) + x := input.Message.Interface().(*AppAuthzRules) if x == nil { return protoiface.MarshalOutput{ NoUnkeyedLiterals: input.NoUnkeyedLiterals, @@ -1948,11 +3936,47 @@ func (x *fastReflection_GrantQueueItem) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } - if len(x.MsgTypeUrls) > 0 { - for iNdEx := len(x.MsgTypeUrls) - 1; iNdEx >= 0; iNdEx-- { - i -= len(x.MsgTypeUrls[iNdEx]) - copy(dAtA[i:], x.MsgTypeUrls[iNdEx]) - i = runtime.EncodeVarint(dAtA, i, uint64(len(x.MsgTypeUrls[iNdEx]))) + if len(x.AllowedProposalTypes) > 0 { + for iNdEx := len(x.AllowedProposalTypes) - 1; iNdEx >= 0; iNdEx-- { + i -= len(x.AllowedProposalTypes[iNdEx]) + copy(dAtA[i:], x.AllowedProposalTypes[iNdEx]) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.AllowedProposalTypes[iNdEx]))) + i-- + dAtA[i] = 0x2a + } + } + if len(x.AllowedMaxStakeAmount) > 0 { + for iNdEx := len(x.AllowedMaxStakeAmount) - 1; iNdEx >= 0; iNdEx-- { + i -= len(x.AllowedMaxStakeAmount[iNdEx]) + copy(dAtA[i:], x.AllowedMaxStakeAmount[iNdEx]) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.AllowedMaxStakeAmount[iNdEx]))) + i-- + dAtA[i] = 0x22 + } + } + if len(x.AllowedStakeValidators) > 0 { + for iNdEx := len(x.AllowedStakeValidators) - 1; iNdEx >= 0; iNdEx-- { + i -= len(x.AllowedStakeValidators[iNdEx]) + copy(dAtA[i:], x.AllowedStakeValidators[iNdEx]) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.AllowedStakeValidators[iNdEx]))) + i-- + dAtA[i] = 0x1a + } + } + if len(x.MaxAmount) > 0 { + for iNdEx := len(x.MaxAmount) - 1; iNdEx >= 0; iNdEx-- { + i -= len(x.MaxAmount[iNdEx]) + copy(dAtA[i:], x.MaxAmount[iNdEx]) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.MaxAmount[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } + if len(x.AllowedRecipients) > 0 { + for iNdEx := len(x.AllowedRecipients) - 1; iNdEx >= 0; iNdEx-- { + i -= len(x.AllowedRecipients[iNdEx]) + copy(dAtA[i:], x.AllowedRecipients[iNdEx]) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.AllowedRecipients[iNdEx]))) i-- dAtA[i] = 0xa } @@ -1968,7 +3992,7 @@ func (x *fastReflection_GrantQueueItem) ProtoMethods() *protoiface.Methods { }, nil } unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { - x := input.Message.Interface().(*GrantQueueItem) + x := input.Message.Interface().(*AppAuthzRules) if x == nil { return protoiface.UnmarshalOutput{ NoUnkeyedLiterals: input.NoUnkeyedLiterals, @@ -1987,28 +4011,92 @@ func (x *fastReflection_GrantQueueItem) ProtoMethods() *protoiface.Methods { if shift >= 64 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow } - if iNdEx >= l { + 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: AppAuthzRules: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: AppAuthzRules: 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 AllowedRecipients", 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 } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break + x.AllowedRecipients = append(x.AllowedRecipients, 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 MaxAmount", wireType) } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: GrantQueueItem: wiretype end group for non-group") - } - if fieldNum <= 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: GrantQueueItem: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: + 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.MaxAmount = append(x.MaxAmount, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 3: if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field MsgTypeUrls", wireType) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field AllowedStakeValidators", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2036,7 +4124,71 @@ func (x *fastReflection_GrantQueueItem) ProtoMethods() *protoiface.Methods { if postIndex > l { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF } - x.MsgTypeUrls = append(x.MsgTypeUrls, string(dAtA[iNdEx:postIndex])) + x.AllowedStakeValidators = append(x.AllowedStakeValidators, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 4: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field AllowedMaxStakeAmount", 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.AllowedMaxStakeAmount = append(x.AllowedMaxStakeAmount, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 5: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field AllowedProposalTypes", 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.AllowedProposalTypes = append(x.AllowedProposalTypes, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex default: iNdEx = preIndex @@ -2138,6 +4290,8 @@ type Grant struct { // doesn't have a time expiration (other conditions in `authorization` // may apply to invalidate the grant) Expiration *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=expiration,proto3" json:"expiration,omitempty"` + // rules are conditions to execute the grant. + Rules []*Rule `protobuf:"bytes,3,rep,name=rules,proto3" json:"rules,omitempty"` } func (x *Grant) Reset() { @@ -2174,6 +4328,57 @@ func (x *Grant) GetExpiration() *timestamppb.Timestamp { return nil } +func (x *Grant) GetRules() []*Rule { + if x != nil { + return x.Rules + } + return nil +} + +// rules are conditions to execute the grant. +type Rule struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Values []string `protobuf:"bytes,2,rep,name=values,proto3" json:"values,omitempty"` +} + +func (x *Rule) Reset() { + *x = Rule{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_authz_v1beta1_authz_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Rule) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Rule) ProtoMessage() {} + +// Deprecated: Use Rule.ProtoReflect.Descriptor instead. +func (*Rule) Descriptor() ([]byte, []int) { + return file_cosmos_authz_v1beta1_authz_proto_rawDescGZIP(), []int{2} +} + +func (x *Rule) GetKey() string { + if x != nil { + return x.Key + } + return "" +} + +func (x *Rule) GetValues() []string { + if x != nil { + return x.Values + } + return nil +} + // GrantAuthorization extends a grant with both the addresses of the grantee and granter. // It is used in genesis.proto and query.proto type GrantAuthorization struct { @@ -2190,7 +4395,7 @@ type GrantAuthorization struct { func (x *GrantAuthorization) Reset() { *x = GrantAuthorization{} if protoimpl.UnsafeEnabled { - mi := &file_cosmos_authz_v1beta1_authz_proto_msgTypes[2] + mi := &file_cosmos_authz_v1beta1_authz_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2204,7 +4409,7 @@ func (*GrantAuthorization) ProtoMessage() {} // Deprecated: Use GrantAuthorization.ProtoReflect.Descriptor instead. func (*GrantAuthorization) Descriptor() ([]byte, []int) { - return file_cosmos_authz_v1beta1_authz_proto_rawDescGZIP(), []int{2} + return file_cosmos_authz_v1beta1_authz_proto_rawDescGZIP(), []int{3} } func (x *GrantAuthorization) GetGranter() string { @@ -2248,7 +4453,7 @@ type GrantQueueItem struct { func (x *GrantQueueItem) Reset() { *x = GrantQueueItem{} if protoimpl.UnsafeEnabled { - mi := &file_cosmos_authz_v1beta1_authz_proto_msgTypes[3] + mi := &file_cosmos_authz_v1beta1_authz_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2262,7 +4467,7 @@ func (*GrantQueueItem) ProtoMessage() {} // Deprecated: Use GrantQueueItem.ProtoReflect.Descriptor instead. func (*GrantQueueItem) Descriptor() ([]byte, []int) { - return file_cosmos_authz_v1beta1_authz_proto_rawDescGZIP(), []int{3} + return file_cosmos_authz_v1beta1_authz_proto_rawDescGZIP(), []int{4} } func (x *GrantQueueItem) GetMsgTypeUrls() []string { @@ -2272,6 +4477,110 @@ func (x *GrantQueueItem) GetMsgTypeUrls() []string { return nil } +// AllowedGrantRulesKeys contains the keys allowed for each message. +type AllowedGrantRulesKeys struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Keys []*Rule `protobuf:"bytes,1,rep,name=keys,proto3" json:"keys,omitempty"` +} + +func (x *AllowedGrantRulesKeys) Reset() { + *x = AllowedGrantRulesKeys{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_authz_v1beta1_authz_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AllowedGrantRulesKeys) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AllowedGrantRulesKeys) ProtoMessage() {} + +// Deprecated: Use AllowedGrantRulesKeys.ProtoReflect.Descriptor instead. +func (*AllowedGrantRulesKeys) Descriptor() ([]byte, []int) { + return file_cosmos_authz_v1beta1_authz_proto_rawDescGZIP(), []int{5} +} + +func (x *AllowedGrantRulesKeys) GetKeys() []*Rule { + if x != nil { + return x.Keys + } + return nil +} + +// AppAuthzRules is rules passed to the authz app. +type AppAuthzRules struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + AllowedRecipients []string `protobuf:"bytes,1,rep,name=allowed_recipients,json=allowedRecipients,proto3" json:"allowed_recipients,omitempty"` + MaxAmount []string `protobuf:"bytes,2,rep,name=max_amount,json=maxAmount,proto3" json:"max_amount,omitempty"` + AllowedStakeValidators []string `protobuf:"bytes,3,rep,name=allowed_stake_validators,json=allowedStakeValidators,proto3" json:"allowed_stake_validators,omitempty"` + AllowedMaxStakeAmount []string `protobuf:"bytes,4,rep,name=allowed_max_stake_amount,json=allowedMaxStakeAmount,proto3" json:"allowed_max_stake_amount,omitempty"` + AllowedProposalTypes []string `protobuf:"bytes,5,rep,name=allowed_proposal_types,json=allowedProposalTypes,proto3" json:"allowed_proposal_types,omitempty"` +} + +func (x *AppAuthzRules) Reset() { + *x = AppAuthzRules{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_authz_v1beta1_authz_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AppAuthzRules) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AppAuthzRules) ProtoMessage() {} + +// Deprecated: Use AppAuthzRules.ProtoReflect.Descriptor instead. +func (*AppAuthzRules) Descriptor() ([]byte, []int) { + return file_cosmos_authz_v1beta1_authz_proto_rawDescGZIP(), []int{6} +} + +func (x *AppAuthzRules) GetAllowedRecipients() []string { + if x != nil { + return x.AllowedRecipients + } + return nil +} + +func (x *AppAuthzRules) GetMaxAmount() []string { + if x != nil { + return x.MaxAmount + } + return nil +} + +func (x *AppAuthzRules) GetAllowedStakeValidators() []string { + if x != nil { + return x.AllowedStakeValidators + } + return nil +} + +func (x *AppAuthzRules) GetAllowedMaxStakeAmount() []string { + if x != nil { + return x.AllowedMaxStakeAmount + } + return nil +} + +func (x *AppAuthzRules) GetAllowedProposalTypes() []string { + if x != nil { + return x.AllowedProposalTypes + } + return nil +} + var File_cosmos_authz_v1beta1_authz_proto protoreflect.FileDescriptor var file_cosmos_authz_v1beta1_authz_proto_rawDesc = []byte{ @@ -2293,7 +4602,7 @@ var file_cosmos_authz_v1beta1_authz_proto_rawDesc = []byte{ 0x75, 0x74, 0x68, 0x7a, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x8a, 0xe7, 0xb0, 0x2a, 0x1f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x69, - 0x63, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0xb1, + 0x63, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0xe3, 0x01, 0x0a, 0x05, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x12, 0x62, 0x0a, 0x0d, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, @@ -2305,42 +4614,69 @@ var file_cosmos_authz_v1beta1_authz_proto_rawDesc = []byte{ 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x42, 0x08, 0xc8, 0xde, 0x1f, 0x01, 0x90, 0xdf, 0x1f, 0x01, 0x52, 0x0a, 0x65, 0x78, 0x70, 0x69, 0x72, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x22, 0xa2, 0x02, 0x0a, 0x12, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x41, 0x75, 0x74, 0x68, - 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 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, 0x32, 0x0a, - 0x07, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x65, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, + 0x6f, 0x6e, 0x12, 0x30, 0x0a, 0x05, 0x72, 0x75, 0x6c, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x1a, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x7a, + 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x05, 0x72, + 0x75, 0x6c, 0x65, 0x73, 0x22, 0x30, 0x0a, 0x04, 0x52, 0x75, 0x6c, 0x65, 0x12, 0x10, 0x0a, 0x03, + 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x16, + 0x0a, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x22, 0xa2, 0x02, 0x0a, 0x12, 0x47, 0x72, 0x61, 0x6e, 0x74, + 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 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, - 0x65, 0x12, 0x62, 0x0a, 0x0d, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x42, 0x26, - 0xca, 0xb4, 0x2d, 0x22, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x7a, - 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, - 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0d, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x40, 0x0a, 0x0a, 0x65, 0x78, 0x70, 0x69, 0x72, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, - 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, - 0x73, 0x74, 0x61, 0x6d, 0x70, 0x42, 0x04, 0x90, 0xdf, 0x1f, 0x01, 0x52, 0x0a, 0x65, 0x78, 0x70, - 0x69, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x34, 0x0a, 0x0e, 0x47, 0x72, 0x61, 0x6e, 0x74, - 0x51, 0x75, 0x65, 0x75, 0x65, 0x49, 0x74, 0x65, 0x6d, 0x12, 0x22, 0x0a, 0x0d, 0x6d, 0x73, 0x67, - 0x5f, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x75, 0x72, 0x6c, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, - 0x52, 0x0b, 0x6d, 0x73, 0x67, 0x54, 0x79, 0x70, 0x65, 0x55, 0x72, 0x6c, 0x73, 0x42, 0xd0, 0x01, - 0x0a, 0x18, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x75, 0x74, - 0x68, 0x7a, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0a, 0x41, 0x75, 0x74, 0x68, - 0x7a, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x32, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, - 0x61, 0x75, 0x74, 0x68, 0x7a, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, - 0x41, 0x58, 0xaa, 0x02, 0x14, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x75, 0x74, 0x68, - 0x7a, 0x2e, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xca, 0x02, 0x14, 0x43, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x5c, 0x41, 0x75, 0x74, 0x68, 0x7a, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, - 0xe2, 0x02, 0x20, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x75, 0x74, 0x68, 0x7a, 0x5c, - 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, - 0x61, 0x74, 0x61, 0xea, 0x02, 0x16, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x41, 0x75, - 0x74, 0x68, 0x7a, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xc8, 0xe1, 0x1e, 0x00, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x72, 0x12, 0x32, 0x0a, 0x07, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x65, 0x65, 0x18, 0x02, 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, 0x65, 0x12, 0x62, 0x0a, 0x0d, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, + 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, + 0x6e, 0x79, 0x42, 0x26, 0xca, 0xb4, 0x2d, 0x22, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, + 0x75, 0x74, 0x68, 0x7a, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x41, 0x75, 0x74, + 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0d, 0x61, 0x75, 0x74, 0x68, + 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x40, 0x0a, 0x0a, 0x65, 0x78, 0x70, + 0x69, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, + 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x42, 0x04, 0x90, 0xdf, 0x1f, 0x01, 0x52, + 0x0a, 0x65, 0x78, 0x70, 0x69, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x34, 0x0a, 0x0e, 0x47, + 0x72, 0x61, 0x6e, 0x74, 0x51, 0x75, 0x65, 0x75, 0x65, 0x49, 0x74, 0x65, 0x6d, 0x12, 0x22, 0x0a, + 0x0d, 0x6d, 0x73, 0x67, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x75, 0x72, 0x6c, 0x73, 0x18, 0x01, + 0x20, 0x03, 0x28, 0x09, 0x52, 0x0b, 0x6d, 0x73, 0x67, 0x54, 0x79, 0x70, 0x65, 0x55, 0x72, 0x6c, + 0x73, 0x22, 0x47, 0x0a, 0x15, 0x41, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x47, 0x72, 0x61, 0x6e, + 0x74, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x4b, 0x65, 0x79, 0x73, 0x12, 0x2e, 0x0a, 0x04, 0x6b, 0x65, + 0x79, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, + 0x52, 0x75, 0x6c, 0x65, 0x52, 0x04, 0x6b, 0x65, 0x79, 0x73, 0x22, 0x86, 0x02, 0x0a, 0x0d, 0x41, + 0x70, 0x70, 0x41, 0x75, 0x74, 0x68, 0x7a, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x2d, 0x0a, 0x12, + 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x5f, 0x72, 0x65, 0x63, 0x69, 0x70, 0x69, 0x65, 0x6e, + 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x11, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x65, + 0x64, 0x52, 0x65, 0x63, 0x69, 0x70, 0x69, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x6d, + 0x61, 0x78, 0x5f, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, + 0x09, 0x6d, 0x61, 0x78, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x38, 0x0a, 0x18, 0x61, 0x6c, + 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x5f, 0x73, 0x74, 0x61, 0x6b, 0x65, 0x5f, 0x76, 0x61, 0x6c, 0x69, + 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x16, 0x61, 0x6c, + 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x53, 0x74, 0x61, 0x6b, 0x65, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, + 0x74, 0x6f, 0x72, 0x73, 0x12, 0x37, 0x0a, 0x18, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x5f, + 0x6d, 0x61, 0x78, 0x5f, 0x73, 0x74, 0x61, 0x6b, 0x65, 0x5f, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, + 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x15, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x4d, + 0x61, 0x78, 0x53, 0x74, 0x61, 0x6b, 0x65, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x34, 0x0a, + 0x16, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x5f, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, + 0x6c, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x09, 0x52, 0x14, 0x61, + 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x54, 0x79, + 0x70, 0x65, 0x73, 0x42, 0xd0, 0x01, 0x0a, 0x18, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, + 0x42, 0x0a, 0x41, 0x75, 0x74, 0x68, 0x7a, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x32, + 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, + 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x2f, 0x76, 0x31, + 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x76, 0x31, 0x62, 0x65, 0x74, + 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x41, 0x58, 0xaa, 0x02, 0x14, 0x43, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x7a, 0x2e, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xca, + 0x02, 0x14, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x75, 0x74, 0x68, 0x7a, 0x5c, 0x56, + 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xe2, 0x02, 0x20, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, + 0x41, 0x75, 0x74, 0x68, 0x7a, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x5c, 0x47, 0x50, + 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x16, 0x43, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x3a, 0x3a, 0x41, 0x75, 0x74, 0x68, 0x7a, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x65, 0x74, + 0x61, 0x31, 0xc8, 0xe1, 0x1e, 0x00, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -2355,25 +4691,30 @@ func file_cosmos_authz_v1beta1_authz_proto_rawDescGZIP() []byte { return file_cosmos_authz_v1beta1_authz_proto_rawDescData } -var file_cosmos_authz_v1beta1_authz_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_cosmos_authz_v1beta1_authz_proto_msgTypes = make([]protoimpl.MessageInfo, 7) var file_cosmos_authz_v1beta1_authz_proto_goTypes = []interface{}{ (*GenericAuthorization)(nil), // 0: cosmos.authz.v1beta1.GenericAuthorization (*Grant)(nil), // 1: cosmos.authz.v1beta1.Grant - (*GrantAuthorization)(nil), // 2: cosmos.authz.v1beta1.GrantAuthorization - (*GrantQueueItem)(nil), // 3: cosmos.authz.v1beta1.GrantQueueItem - (*anypb.Any)(nil), // 4: google.protobuf.Any - (*timestamppb.Timestamp)(nil), // 5: google.protobuf.Timestamp + (*Rule)(nil), // 2: cosmos.authz.v1beta1.Rule + (*GrantAuthorization)(nil), // 3: cosmos.authz.v1beta1.GrantAuthorization + (*GrantQueueItem)(nil), // 4: cosmos.authz.v1beta1.GrantQueueItem + (*AllowedGrantRulesKeys)(nil), // 5: cosmos.authz.v1beta1.AllowedGrantRulesKeys + (*AppAuthzRules)(nil), // 6: cosmos.authz.v1beta1.AppAuthzRules + (*anypb.Any)(nil), // 7: google.protobuf.Any + (*timestamppb.Timestamp)(nil), // 8: google.protobuf.Timestamp } var file_cosmos_authz_v1beta1_authz_proto_depIdxs = []int32{ - 4, // 0: cosmos.authz.v1beta1.Grant.authorization:type_name -> google.protobuf.Any - 5, // 1: cosmos.authz.v1beta1.Grant.expiration:type_name -> google.protobuf.Timestamp - 4, // 2: cosmos.authz.v1beta1.GrantAuthorization.authorization:type_name -> google.protobuf.Any - 5, // 3: cosmos.authz.v1beta1.GrantAuthorization.expiration:type_name -> google.protobuf.Timestamp - 4, // [4:4] is the sub-list for method output_type - 4, // [4:4] 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 + 7, // 0: cosmos.authz.v1beta1.Grant.authorization:type_name -> google.protobuf.Any + 8, // 1: cosmos.authz.v1beta1.Grant.expiration:type_name -> google.protobuf.Timestamp + 2, // 2: cosmos.authz.v1beta1.Grant.rules:type_name -> cosmos.authz.v1beta1.Rule + 7, // 3: cosmos.authz.v1beta1.GrantAuthorization.authorization:type_name -> google.protobuf.Any + 8, // 4: cosmos.authz.v1beta1.GrantAuthorization.expiration:type_name -> google.protobuf.Timestamp + 2, // 5: cosmos.authz.v1beta1.AllowedGrantRulesKeys.keys:type_name -> cosmos.authz.v1beta1.Rule + 6, // [6:6] is the sub-list for method output_type + 6, // [6:6] is the sub-list for method input_type + 6, // [6:6] is the sub-list for extension type_name + 6, // [6:6] is the sub-list for extension extendee + 0, // [0:6] is the sub-list for field type_name } func init() { file_cosmos_authz_v1beta1_authz_proto_init() } @@ -2407,7 +4748,7 @@ func file_cosmos_authz_v1beta1_authz_proto_init() { } } file_cosmos_authz_v1beta1_authz_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GrantAuthorization); i { + switch v := v.(*Rule); i { case 0: return &v.state case 1: @@ -2419,6 +4760,18 @@ func file_cosmos_authz_v1beta1_authz_proto_init() { } } file_cosmos_authz_v1beta1_authz_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GrantAuthorization); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_cosmos_authz_v1beta1_authz_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*GrantQueueItem); i { case 0: return &v.state @@ -2430,6 +4783,30 @@ func file_cosmos_authz_v1beta1_authz_proto_init() { return nil } } + file_cosmos_authz_v1beta1_authz_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AllowedGrantRulesKeys); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_cosmos_authz_v1beta1_authz_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AppAuthzRules); 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{ @@ -2437,7 +4814,7 @@ func file_cosmos_authz_v1beta1_authz_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_cosmos_authz_v1beta1_authz_proto_rawDesc, NumEnums: 0, - NumMessages: 4, + NumMessages: 7, NumExtensions: 0, NumServices: 0, }, diff --git a/api/cosmos/authz/v1beta1/tx.pulsar.go b/api/cosmos/authz/v1beta1/tx.pulsar.go index 9b2af65e42cc..4fc726a1e59b 100644 --- a/api/cosmos/authz/v1beta1/tx.pulsar.go +++ b/api/cosmos/authz/v1beta1/tx.pulsar.go @@ -22,6 +22,7 @@ var ( fd_MsgGrant_granter protoreflect.FieldDescriptor fd_MsgGrant_grantee protoreflect.FieldDescriptor fd_MsgGrant_grant protoreflect.FieldDescriptor + fd_MsgGrant_rules protoreflect.FieldDescriptor ) func init() { @@ -30,6 +31,7 @@ func init() { fd_MsgGrant_granter = md_MsgGrant.Fields().ByName("granter") fd_MsgGrant_grantee = md_MsgGrant.Fields().ByName("grantee") fd_MsgGrant_grant = md_MsgGrant.Fields().ByName("grant") + fd_MsgGrant_rules = md_MsgGrant.Fields().ByName("rules") } var _ protoreflect.Message = (*fastReflection_MsgGrant)(nil) @@ -115,6 +117,12 @@ func (x *fastReflection_MsgGrant) Range(f func(protoreflect.FieldDescriptor, pro return } } + if len(x.Rules) != 0 { + value := protoreflect.ValueOfBytes(x.Rules) + if !f(fd_MsgGrant_rules, value) { + return + } + } } // Has reports whether a field is populated. @@ -136,6 +144,8 @@ func (x *fastReflection_MsgGrant) Has(fd protoreflect.FieldDescriptor) bool { return x.Grantee != "" case "cosmos.authz.v1beta1.MsgGrant.grant": return x.Grant != nil + case "cosmos.authz.v1beta1.MsgGrant.rules": + return len(x.Rules) != 0 default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.MsgGrant")) @@ -158,6 +168,8 @@ func (x *fastReflection_MsgGrant) Clear(fd protoreflect.FieldDescriptor) { x.Grantee = "" case "cosmos.authz.v1beta1.MsgGrant.grant": x.Grant = nil + case "cosmos.authz.v1beta1.MsgGrant.rules": + x.Rules = nil default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.MsgGrant")) @@ -183,6 +195,9 @@ func (x *fastReflection_MsgGrant) Get(descriptor protoreflect.FieldDescriptor) p case "cosmos.authz.v1beta1.MsgGrant.grant": value := x.Grant return protoreflect.ValueOfMessage(value.ProtoReflect()) + case "cosmos.authz.v1beta1.MsgGrant.rules": + value := x.Rules + return protoreflect.ValueOfBytes(value) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.MsgGrant")) @@ -209,6 +224,8 @@ func (x *fastReflection_MsgGrant) Set(fd protoreflect.FieldDescriptor, value pro x.Grantee = value.Interface().(string) case "cosmos.authz.v1beta1.MsgGrant.grant": x.Grant = value.Message().Interface().(*Grant) + case "cosmos.authz.v1beta1.MsgGrant.rules": + x.Rules = value.Bytes() default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.MsgGrant")) @@ -238,6 +255,8 @@ func (x *fastReflection_MsgGrant) Mutable(fd protoreflect.FieldDescriptor) proto panic(fmt.Errorf("field granter of message cosmos.authz.v1beta1.MsgGrant is not mutable")) case "cosmos.authz.v1beta1.MsgGrant.grantee": panic(fmt.Errorf("field grantee of message cosmos.authz.v1beta1.MsgGrant is not mutable")) + case "cosmos.authz.v1beta1.MsgGrant.rules": + panic(fmt.Errorf("field rules of message cosmos.authz.v1beta1.MsgGrant is not mutable")) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.MsgGrant")) @@ -258,6 +277,8 @@ func (x *fastReflection_MsgGrant) NewField(fd protoreflect.FieldDescriptor) prot case "cosmos.authz.v1beta1.MsgGrant.grant": m := new(Grant) return protoreflect.ValueOfMessage(m.ProtoReflect()) + case "cosmos.authz.v1beta1.MsgGrant.rules": + return protoreflect.ValueOfBytes(nil) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.MsgGrant")) @@ -339,6 +360,10 @@ func (x *fastReflection_MsgGrant) ProtoMethods() *protoiface.Methods { l = options.Size(x.Grant) n += 1 + l + runtime.Sov(uint64(l)) } + l = len(x.Rules) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } if x.unknownFields != nil { n += len(x.unknownFields) } @@ -368,6 +393,13 @@ func (x *fastReflection_MsgGrant) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } + if len(x.Rules) > 0 { + i -= len(x.Rules) + copy(dAtA[i:], x.Rules) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Rules))) + i-- + dAtA[i] = 0x22 + } if x.Grant != nil { encoded, err := options.Marshal(x.Grant) if err != nil { @@ -545,6 +577,40 @@ func (x *fastReflection_MsgGrant) ProtoMethods() *protoiface.Methods { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err } iNdEx = postIndex + case 4: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Rules", wireType) + } + var byteLen 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++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + byteLen + 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.Rules = append(x.Rules[:0], dAtA[iNdEx:postIndex]...) + if x.Rules == nil { + x.Rules = []byte{} + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := runtime.Skip(dAtA[iNdEx:]) @@ -2903,6 +2969,8 @@ type MsgGrant struct { Granter string `protobuf:"bytes,1,opt,name=granter,proto3" json:"granter,omitempty"` Grantee string `protobuf:"bytes,2,opt,name=grantee,proto3" json:"grantee,omitempty"` Grant *Grant `protobuf:"bytes,3,opt,name=grant,proto3" json:"grant,omitempty"` + // rules are conditions to execute the grant. + Rules []byte `protobuf:"bytes,4,opt,name=rules,proto3" json:"rules,omitempty"` } func (x *MsgGrant) Reset() { @@ -2946,6 +3014,13 @@ func (x *MsgGrant) GetGrant() *Grant { return nil } +func (x *MsgGrant) GetRules() []byte { + if x != nil { + return x.Rules + } + return nil +} + // MsgGrantResponse defines the Msg/MsgGrant response type. type MsgGrantResponse struct { state protoimpl.MessageState @@ -3154,7 +3229,7 @@ var file_cosmos_authz_v1beta1_tx_proto_rawDesc = []byte{ 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x6d, 0x73, 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x6d, 0x73, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x11, 0x61, 0x6d, 0x69, 0x6e, 0x6f, 0x2f, 0x61, 0x6d, 0x69, 0x6e, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, - 0xd6, 0x01, 0x0a, 0x08, 0x4d, 0x73, 0x67, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x12, 0x32, 0x0a, 0x07, + 0xec, 0x01, 0x0a, 0x08, 0x4d, 0x73, 0x67, 0x47, 0x72, 0x61, 0x6e, 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, @@ -3165,67 +3240,68 @@ var file_cosmos_authz_v1beta1_tx_proto_rawDesc = []byte{ 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x42, 0x09, 0xc8, 0xde, 0x1f, 0x00, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x05, 0x67, 0x72, 0x61, - 0x6e, 0x74, 0x3a, 0x24, 0x82, 0xe7, 0xb0, 0x2a, 0x07, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x65, 0x72, - 0x8a, 0xe7, 0xb0, 0x2a, 0x13, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, - 0x4d, 0x73, 0x67, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x22, 0x12, 0x0a, 0x10, 0x4d, 0x73, 0x67, 0x47, - 0x72, 0x61, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0xa9, 0x01, 0x0a, - 0x07, 0x4d, 0x73, 0x67, 0x45, 0x78, 0x65, 0x63, 0x12, 0x32, 0x0a, 0x07, 0x67, 0x72, 0x61, 0x6e, - 0x74, 0x65, 0x65, 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, 0x65, 0x12, 0x45, 0x0a, 0x04, - 0x6d, 0x73, 0x67, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, - 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, - 0x42, 0x1b, 0xca, 0xb4, 0x2d, 0x17, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, - 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x52, 0x04, 0x6d, - 0x73, 0x67, 0x73, 0x3a, 0x23, 0x82, 0xe7, 0xb0, 0x2a, 0x07, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x65, - 0x65, 0x8a, 0xe7, 0xb0, 0x2a, 0x12, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, - 0x2f, 0x4d, 0x73, 0x67, 0x45, 0x78, 0x65, 0x63, 0x22, 0x2b, 0x0a, 0x0f, 0x4d, 0x73, 0x67, 0x45, - 0x78, 0x65, 0x63, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x72, - 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x07, 0x72, 0x65, - 0x73, 0x75, 0x6c, 0x74, 0x73, 0x22, 0xbc, 0x01, 0x0a, 0x09, 0x4d, 0x73, 0x67, 0x52, 0x65, 0x76, - 0x6f, 0x6b, 0x65, 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, 0x32, 0x0a, 0x07, 0x67, 0x72, 0x61, 0x6e, 0x74, - 0x65, 0x65, 0x18, 0x02, 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, 0x65, 0x12, 0x20, 0x0a, 0x0c, 0x6d, - 0x73, 0x67, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0a, 0x6d, 0x73, 0x67, 0x54, 0x79, 0x70, 0x65, 0x55, 0x72, 0x6c, 0x3a, 0x25, 0x82, - 0xe7, 0xb0, 0x2a, 0x07, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x65, 0x72, 0x8a, 0xe7, 0xb0, 0x2a, 0x14, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x4d, 0x73, 0x67, 0x52, 0x65, - 0x76, 0x6f, 0x6b, 0x65, 0x22, 0x13, 0x0a, 0x11, 0x4d, 0x73, 0x67, 0x52, 0x65, 0x76, 0x6f, 0x6b, - 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xff, 0x01, 0x0a, 0x03, 0x4d, 0x73, - 0x67, 0x12, 0x4f, 0x0a, 0x05, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x12, 0x1e, 0x2e, 0x63, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, - 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x1a, 0x26, 0x2e, 0x63, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, - 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x4c, 0x0a, 0x04, 0x45, 0x78, 0x65, 0x63, 0x12, 0x1d, 0x2e, 0x63, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, - 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x45, 0x78, 0x65, 0x63, 0x1a, 0x25, 0x2e, 0x63, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, - 0x2e, 0x4d, 0x73, 0x67, 0x45, 0x78, 0x65, 0x63, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x52, 0x0a, 0x06, 0x52, 0x65, 0x76, 0x6f, 0x6b, 0x65, 0x12, 0x1f, 0x2e, 0x63, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, - 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x52, 0x65, 0x76, 0x6f, 0x6b, 0x65, 0x1a, 0x27, 0x2e, 0x63, 0x6f, - 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, - 0x61, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x52, 0x65, 0x76, 0x6f, 0x6b, 0x65, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x1a, 0x05, 0x80, 0xe7, 0xb0, 0x2a, 0x01, 0x42, 0xcd, 0x01, 0x0a, 0x18, - 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x7a, - 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, - 0x6f, 0x50, 0x01, 0x5a, 0x32, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, - 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x75, 0x74, - 0x68, 0x7a, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x61, 0x75, 0x74, 0x68, 0x7a, - 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x41, 0x58, 0xaa, 0x02, 0x14, - 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x7a, 0x2e, 0x56, 0x31, 0x62, - 0x65, 0x74, 0x61, 0x31, 0xca, 0x02, 0x14, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x75, - 0x74, 0x68, 0x7a, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xe2, 0x02, 0x20, 0x43, 0x6f, - 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x75, 0x74, 0x68, 0x7a, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, - 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, - 0x16, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x41, 0x75, 0x74, 0x68, 0x7a, 0x3a, 0x3a, - 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xc8, 0xe1, 0x1e, 0x00, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x6e, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x75, 0x6c, 0x65, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x0c, 0x52, 0x05, 0x72, 0x75, 0x6c, 0x65, 0x73, 0x3a, 0x24, 0x82, 0xe7, 0xb0, 0x2a, 0x07, 0x67, + 0x72, 0x61, 0x6e, 0x74, 0x65, 0x72, 0x8a, 0xe7, 0xb0, 0x2a, 0x13, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x4d, 0x73, 0x67, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x22, 0x12, + 0x0a, 0x10, 0x4d, 0x73, 0x67, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0xa9, 0x01, 0x0a, 0x07, 0x4d, 0x73, 0x67, 0x45, 0x78, 0x65, 0x63, 0x12, 0x32, + 0x0a, 0x07, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x65, 0x65, 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, 0x65, 0x12, 0x45, 0x0a, 0x04, 0x6d, 0x73, 0x67, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x42, 0x1b, 0xca, 0xb4, 0x2d, 0x17, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, + 0x4d, 0x73, 0x67, 0x52, 0x04, 0x6d, 0x73, 0x67, 0x73, 0x3a, 0x23, 0x82, 0xe7, 0xb0, 0x2a, 0x07, + 0x67, 0x72, 0x61, 0x6e, 0x74, 0x65, 0x65, 0x8a, 0xe7, 0xb0, 0x2a, 0x12, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x4d, 0x73, 0x67, 0x45, 0x78, 0x65, 0x63, 0x22, 0x2b, + 0x0a, 0x0f, 0x4d, 0x73, 0x67, 0x45, 0x78, 0x65, 0x63, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, + 0x28, 0x0c, 0x52, 0x07, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x22, 0xbc, 0x01, 0x0a, 0x09, + 0x4d, 0x73, 0x67, 0x52, 0x65, 0x76, 0x6f, 0x6b, 0x65, 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, 0x32, 0x0a, + 0x07, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x65, 0x65, 0x18, 0x02, 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, + 0x65, 0x12, 0x20, 0x0a, 0x0c, 0x6d, 0x73, 0x67, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x75, 0x72, + 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x6d, 0x73, 0x67, 0x54, 0x79, 0x70, 0x65, + 0x55, 0x72, 0x6c, 0x3a, 0x25, 0x82, 0xe7, 0xb0, 0x2a, 0x07, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x65, + 0x72, 0x8a, 0xe7, 0xb0, 0x2a, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, + 0x2f, 0x4d, 0x73, 0x67, 0x52, 0x65, 0x76, 0x6f, 0x6b, 0x65, 0x22, 0x13, 0x0a, 0x11, 0x4d, 0x73, + 0x67, 0x52, 0x65, 0x76, 0x6f, 0x6b, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, + 0xff, 0x01, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x12, 0x4f, 0x0a, 0x05, 0x47, 0x72, 0x61, 0x6e, 0x74, + 0x12, 0x1e, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x2e, + 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x47, 0x72, 0x61, 0x6e, 0x74, + 0x1a, 0x26, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x2e, + 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x47, 0x72, 0x61, 0x6e, 0x74, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4c, 0x0a, 0x04, 0x45, 0x78, 0x65, 0x63, + 0x12, 0x1d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x2e, + 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x45, 0x78, 0x65, 0x63, 0x1a, + 0x25, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x2e, 0x76, + 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x45, 0x78, 0x65, 0x63, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x52, 0x0a, 0x06, 0x52, 0x65, 0x76, 0x6f, 0x6b, 0x65, + 0x12, 0x1f, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x2e, + 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x52, 0x65, 0x76, 0x6f, 0x6b, + 0x65, 0x1a, 0x27, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x7a, + 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x52, 0x65, 0x76, 0x6f, + 0x6b, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x1a, 0x05, 0x80, 0xe7, 0xb0, 0x2a, + 0x01, 0x42, 0xcd, 0x01, 0x0a, 0x18, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x2e, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x07, + 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x32, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, + 0x3b, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, + 0x43, 0x41, 0x58, 0xaa, 0x02, 0x14, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x75, 0x74, + 0x68, 0x7a, 0x2e, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xca, 0x02, 0x14, 0x43, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x75, 0x74, 0x68, 0x7a, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, + 0x31, 0xe2, 0x02, 0x20, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x75, 0x74, 0x68, 0x7a, + 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, + 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x16, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x41, + 0x75, 0x74, 0x68, 0x7a, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xc8, 0xe1, 0x1e, + 0x00, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/proto/cosmos/authz/v1beta1/authz.proto b/proto/cosmos/authz/v1beta1/authz.proto old mode 100644 new mode 100755 index 3fee7364365c..22eb7bfa4067 --- a/proto/cosmos/authz/v1beta1/authz.proto +++ b/proto/cosmos/authz/v1beta1/authz.proto @@ -29,6 +29,15 @@ message Grant { // doesn't have a time expiration (other conditions in `authorization` // may apply to invalidate the grant) google.protobuf.Timestamp expiration = 2 [(gogoproto.stdtime) = true, (gogoproto.nullable) = true]; + + // rules are conditions to execute the grant. + repeated Rule rules = 3; +} + +// rules are conditions to execute the grant. +message Rule { + string key = 1; + repeated string values = 2; } // GrantAuthorization extends a grant with both the addresses of the grantee and granter. @@ -46,3 +55,17 @@ message GrantQueueItem { // msg_type_urls contains the list of TypeURL of a sdk.Msg. repeated string msg_type_urls = 1; } + +// AllowedGrantRulesKeys contains the keys allowed for each message. +message AllowedGrantRulesKeys { + repeated cosmos.authz.v1beta1.Rule keys = 1; +} + +// AppAuthzRules is rules passed to the authz app. +message AppAuthzRules { + repeated string allowed_recipients = 1; + repeated string max_amount = 2; + repeated string allowed_stake_validators = 3; + repeated string allowed_max_stake_amount = 4; + repeated string allowed_proposal_types = 5; +} \ No newline at end of file diff --git a/proto/cosmos/authz/v1beta1/tx.proto b/proto/cosmos/authz/v1beta1/tx.proto old mode 100644 new mode 100755 index a1abff0d6f00..858b582dcd05 --- a/proto/cosmos/authz/v1beta1/tx.proto +++ b/proto/cosmos/authz/v1beta1/tx.proto @@ -42,6 +42,9 @@ message MsgGrant { string grantee = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; cosmos.authz.v1beta1.Grant grant = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; + + // rules are conditions to execute the grant. + bytes rules = 4; } // MsgGrantResponse defines the Msg/MsgGrant response type. diff --git a/scripts/README.md b/scripts/README.md old mode 100644 new mode 100755 diff --git a/simapp/ante.go b/simapp/ante.go index 58e85a7597dc..58d90eb0e4d1 100644 --- a/simapp/ante.go +++ b/simapp/ante.go @@ -40,6 +40,7 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { ante.NewValidateMemoDecorator(options.AccountKeeper), ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper), ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TxFeeChecker), + ante.NewAuthzDecorator(options.AuthzKeeper, options.AccountKeeper, options.GovKeeper), ante.NewSetPubKeyDecorator(options.AccountKeeper), // SetPubKeyDecorator must be called before all signature verification decorators ante.NewValidateSigCountDecorator(options.AccountKeeper), ante.NewSigGasConsumeDecorator(options.AccountKeeper, options.SigGasConsumer), diff --git a/simapp/app.go b/simapp/app.go index 3c27030af82d..075fdb8860bf 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -1,4 +1,6 @@ -//go:build app_v1 +//go:build !app_v1 + +// TODO: (revert) added for testing package simapp @@ -522,6 +524,7 @@ func NewSimApp( app.SetPreBlocker(app.PreBlocker) app.SetBeginBlocker(app.BeginBlocker) app.SetEndBlocker(app.EndBlocker) + app.setAnteHandler(txConfig) // In v0.46, the SDK introduces _postHandlers_. PostHandlers are like @@ -566,10 +569,12 @@ func (app *SimApp) setAnteHandler(txConfig client.TxConfig) { HandlerOptions{ ante.HandlerOptions{ AccountKeeper: app.AccountKeeper, + AuthzKeeper: app.AuthzKeeper, BankKeeper: app.BankKeeper, SignModeHandler: txConfig.SignModeHandler(), FeegrantKeeper: app.FeeGrantKeeper, SigGasConsumer: ante.DefaultSigVerificationGasConsumer, + GovKeeper: app.GovKeeper, }, &app.CircuitKeeper, }, diff --git a/simapp/app_v2.go b/simapp/app_v2.go index e10a54e7449e..86f7871f5ca0 100644 --- a/simapp/app_v2.go +++ b/simapp/app_v2.go @@ -1,4 +1,6 @@ -//go:build !app_v1 +//go:build app_v1 + +// TODO: (revert) add for testing package simapp @@ -89,6 +91,7 @@ type SimApp struct { } func init() { + userHomeDir, err := os.UserHomeDir() if err != nil { panic(err) diff --git a/simapp/upgrades.go b/simapp/upgrades.go index 66c9fb87e7c0..2e55db6c67af 100644 --- a/simapp/upgrades.go +++ b/simapp/upgrades.go @@ -7,7 +7,11 @@ import ( circuittypes "cosmossdk.io/x/circuit/types" upgradetypes "cosmossdk.io/x/upgrade/types" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + "github.com/cosmos/cosmos-sdk/x/authz" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) // UpgradeName defines the on-chain upgrade name for the sample SimApp upgrade @@ -26,6 +30,26 @@ func (app SimApp) RegisterUpgradeHandlers() { }, ) + app.UpgradeKeeper.SetUpgradeHandler( + "v2", + func(ctx context.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + app.AuthzKeeper.SetAuthzRulesKeys(ctx, &authz.AllowedGrantRulesKeys{ + Keys: []*authz.Rule{ + { + Key: sdk.MsgTypeURL(&banktypes.MsgSend{}), + Values: []string{authz.MaxAmount, authz.AllowedRecipients}, + }, + { + Key: sdk.MsgTypeURL(&stakingtypes.MsgDelegate{}), + Values: []string{authz.AllowedStakeValidators, authz.AllowedMaxStakeAmount}, + }, + }, + }) + + return app.ModuleManager.RunMigrations(ctx, app.Configurator(), fromVM) + }, + ) + upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk() if err != nil { panic(err) diff --git a/x/auth/ante/ante.go b/x/auth/ante/ante.go index 8b2277aeb88b..e1fe15bcb269 100644 --- a/x/auth/ante/ante.go +++ b/x/auth/ante/ante.go @@ -14,12 +14,14 @@ import ( // HandlerOptions are the options required for constructing a default SDK AnteHandler. type HandlerOptions struct { AccountKeeper AccountKeeper + AuthzKeeper AuthzKeeper BankKeeper types.BankKeeper ExtensionOptionChecker ExtensionOptionChecker FeegrantKeeper FeegrantKeeper SignModeHandler *txsigning.HandlerMap SigGasConsumer func(meter storetypes.GasMeter, sig signing.SignatureV2, params types.Params) error TxFeeChecker TxFeeChecker + GovKeeper GovKeeper } // NewAnteHandler returns an AnteHandler that checks and increments sequence @@ -46,6 +48,7 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { NewValidateMemoDecorator(options.AccountKeeper), NewConsumeGasForTxSizeDecorator(options.AccountKeeper), NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TxFeeChecker), + NewAuthzDecorator(options.AuthzKeeper, options.AccountKeeper, options.GovKeeper), NewSetPubKeyDecorator(options.AccountKeeper), // SetPubKeyDecorator must be called before all signature verification decorators NewValidateSigCountDecorator(options.AccountKeeper), NewSigGasConsumeDecorator(options.AccountKeeper, options.SigGasConsumer), diff --git a/x/auth/ante/authz_rules_ante.go b/x/auth/ante/authz_rules_ante.go new file mode 100644 index 000000000000..6f5a89ae410d --- /dev/null +++ b/x/auth/ante/authz_rules_ante.go @@ -0,0 +1,228 @@ +package ante + +import ( + "fmt" + "strings" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" + authztypes "github.com/cosmos/cosmos-sdk/x/authz" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" + stakingv1beta1 "github.com/cosmos/cosmos-sdk/x/staking/types" + + errorsmod "cosmossdk.io/errors" +) + +type AuthzDecorator struct { + azk AuthzKeeper + ak AccountKeeper + govKeeper GovKeeper +} + +func NewAuthzDecorator(azk AuthzKeeper, ak AccountKeeper, govKeeper GovKeeper) AuthzDecorator { + return AuthzDecorator{ + azk: azk, + ak: ak, + govKeeper: govKeeper, + } +} + +// AnteHandle checks the authorization message grants for some rules. +func (azd AuthzDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) { + // Ensure the transaction can be verified for signatures + sigTx, ok := tx.(authsigning.SigVerifiableTx) + if !ok { + return ctx, errorsmod.Wrap(sdkerrors.ErrTxDecode, "invalid tx type") + } + + // Get the signers of the transaction + signers, err := sigTx.GetSigners() + if err != nil { + return ctx, err + } + + // Assume the first signer is the grantee + grantee := signers[0] + + // Get the messages in the transaction + msgs := tx.GetMsgs() + for _, msg := range msgs { + // Check if the message is an authorization message + authzMsg, ok := msg.(*authztypes.MsgExec) + if !ok { + continue + } + + // Get the inner messages of the authorization message + authzMsgs, err := authzMsg.GetMessages() + if err != nil { + return ctx, err + } + + // Handle each inner message based on its type + for _, innerMsg := range authzMsgs { + switch innerMsg1 := innerMsg.(type) { + case *banktypes.MsgSend: + if err := azd.handleSendAuthzRules(ctx, innerMsg1, grantee); err != nil { + return ctx, err + } + case *stakingv1beta1.MsgDelegate: + if err := azd.handleStakeAuthzRules(ctx, innerMsg1, grantee); err != nil { + return ctx, err + } + case *govv1.MsgVote: + if err := azd.handleProposalAuthzRules(ctx, innerMsg1, grantee); err != nil { + return ctx, err + } + + default: + fmt.Printf("Unhandled inner message type: %T\n", innerMsg) + } + } + } + + // Continue with the next AnteHandler if all checks pass + return next(ctx, tx, simulate) +} + +// handleSendAuthzRules checks if a MsgSend transaction is authorized based on the rules set by the granter. +func (azd AuthzDecorator) handleSendAuthzRules(ctx sdk.Context, msg *banktypes.MsgSend, grantee []byte) error { + // Convert the sender's address to bytes + granter, err := azd.ak.AddressCodec().StringToBytes(msg.FromAddress) + if err != nil { + return err + } + + // Retrieve authorization rules + _, rules := azd.azk.GetAuthzWithRules(ctx, grantee, granter, sdk.MsgTypeURL(&banktypes.MsgSend{})) + + // Initialize maps for quick lookup + allowedRecipients := make(map[string]struct{}) + var maxAmount sdk.Coins + + // Populate maps with rule values + for _, rule := range rules { + switch rule.Key { + case authztypes.AllowedRecipients: + for _, recipient := range rule.Values { + allowedRecipients[recipient] = struct{}{} + } + case authztypes.MaxAmount: + maxAmount, err = sdk.ParseCoinsNormalized(strings.Join(rule.Values, ",")) + if err != nil { + return err + } + } + } + + // Check if recipient is allowed + if len(allowedRecipients) > 0 { + if _, isAllowed := allowedRecipients[msg.ToAddress]; !isAllowed { + return errorsmod.Wrap(sdkerrors.ErrTxDecode, "Recipient is not in the allowed list of the grant") + } + } + + // Check if the amount does not exceed the maximum allowed + if maxAmount != nil { + if !maxAmount.IsAllGTE(msg.Amount) { + return errorsmod.Wrap(sdkerrors.ErrTxDecode, "Amount exceeds the max_amount limit set by the granter") + } + } + + return nil +} + +// handleStakeAuthzRules checks if a MsgDelegate transaction is authorized based on the rules set by the granter. +func (azd AuthzDecorator) handleStakeAuthzRules(ctx sdk.Context, msg *stakingv1beta1.MsgDelegate, grantee []byte) error { + // Convert the delegator's address to bytes + granter, err := azd.ak.AddressCodec().StringToBytes(msg.DelegatorAddress) + if err != nil { + return err + } + + // Retrieve authorization rules + _, rules := azd.azk.GetAuthzWithRules(ctx, grantee, granter, sdk.MsgTypeURL(&stakingv1beta1.MsgDelegate{})) + + // Initialize maps for quick lookup + allowedValidators := make(map[string]struct{}) + var maxStakeAmount sdk.Coins + + // Populate maps with rule values + for _, rule := range rules { + switch rule.Key { + case authztypes.AllowedStakeValidators: + for _, validator := range rule.Values { + allowedValidators[validator] = struct{}{} + } + case authztypes.AllowedMaxStakeAmount: + maxStakeAmount, err = sdk.ParseCoinsNormalized(strings.Join(rule.Values, ",")) + if err != nil { + return err + } + } + } + + // Check if validator is allowed + if len(allowedValidators) > 0 { + if _, isAllowed := allowedValidators[msg.ValidatorAddress]; !isAllowed { + return errorsmod.Wrap(sdkerrors.ErrTxDecode, "Validator is not in the allowed validators of the grant") + } + } + + // Check if the stake amount does not exceed the maximum allowed + if maxStakeAmount != nil { + amount, err := sdk.ParseCoinNormalized(msg.Amount.String()) + if err != nil { + return err + } + if !maxStakeAmount.IsAllGTE(sdk.NewCoins(amount)) { + return errorsmod.Wrap(sdkerrors.ErrTxDecode, "Amount exceeds the max_amount limit set by the granter") + } + } + + return nil +} + +// handleProposalAuthzRules checks if a MsgVote transaction is authorized based on the rules set by the granter. +func (azd AuthzDecorator) handleProposalAuthzRules(ctx sdk.Context, msg *govv1.MsgVote, grantee []byte) error { + // Convert the voter's address to bytes + granter, err := azd.ak.AddressCodec().StringToBytes(msg.Voter) + if err != nil { + return err + } + + // Retrieve the proposal by ID + proposal, err := azd.govKeeper.GetProposalById(ctx, msg.ProposalId) + if err != nil { + return err + } + + // Retrieve authorization rules + _, rules := azd.azk.GetAuthzWithRules(ctx, grantee, granter, sdk.MsgTypeURL(&govv1.MsgVote{})) + if len(rules) == 0 { + return nil + } + + // Initialize a map for quick lookup of allowed proposal types + allowedProposalTypes := make(map[string]struct{}) + + // Populate map with rule values + for _, rule := range rules { + if rule.Key == authztypes.AllowedProposalTypes { + for _, allowedProposalType := range rule.Values { + allowedProposalTypes[allowedProposalType] = struct{}{} + } + } + } + + // Check if any of the proposal messages' types are allowed + for _, msg := range proposal.GetMessages() { + if _, exists := allowedProposalTypes[msg.GetTypeUrl()]; exists { + return nil // Proposal type is allowed + } + } + + return errorsmod.Wrap(sdkerrors.ErrTxDecode, "Voter is not allowed to vote on the proposal") +} diff --git a/x/auth/ante/authz_rules_spec.md b/x/auth/ante/authz_rules_spec.md new file mode 100644 index 000000000000..b14809284211 --- /dev/null +++ b/x/auth/ante/authz_rules_spec.md @@ -0,0 +1,199 @@ +# Status + +DRAFT + +# Context + +The current authorization (authz) module lacks the flexibility needed to grant permissions (authz grants) for various types of messages along with +specific conditions or rules. This limitation prevents users from customizing their transaction behavior according to specific needs or strategies. To address this issue, we propose enhancing the authz module to support more granular permissions and conditional rules, allowing for greater +customization and control over transaction authorization. + +## Specific Examples of Limitations + +Managing Reward Tokens: + + - At present, users are able to restake their tokens via authz. But it can do more. Currently users are unable to establish rules for swapping their +reward tokens as a strategy as it requires IBCTransfer or PacketForward msgs access. It's not secure to give this grant currently as the recipient address can be anything and grantee can behave maliciously. But if there's a way to restrict recipient address to match with granter's address, this problem is solved. This functionality is necessary to enable users to automate and customize their token management strategies effectively. + + - Users currently cannot authorize sending tokens to a pre-defined or selected address. This restriction limits their ability to control and automate the +transfer of tokens to specific recipients, thereby reducing the efficiency and flexibility of their token management strategies. For example, if an organization wants to authorize an accountant to process salaries every month, the current system's limitations prevent this. Implementing an authz grant to recurrently allow a user to send a specified amount to certain accounts would solve this issue. This feature would automate salary payments, ensuring timely and accurate transactions while reducing administrative overhead. + +Managing Proposals: + + - Currently authz module does not allow for granular permissions, meaning that users cannot be restricted to vote only on certain types of proposals. This +limitation can lead to less informed voting decisions as users may vote on proposals outside their area of expertise. for ex: param change proposal or software upgrade proposals both are different type of messages. + +Proposed Enhancement: +The enhanced authz module will allow the delegation of voting permissions on a per-proposal-type basis. This ensures that voters only vote on proposals they are knowledgeable about, leading to more informed and effective governance decisions. + +# Use Case: Delegating Voting Permissions Based on Proposal Types + + - To grant specific voting permissions to different groups of people based on their expertise, ensuring they vote only on proposals relevant to their +knowledge. + +## Let's take 2 types of Proposals: +### Types of Proposals +1. **Parameter Change Proposals**: + - These proposals involve changes to the network's parameters, such as block size, transaction fees, or other configurable parameters. + +2. **Software Upgrade Proposals**: + - These proposals involve upgrading the blockchain software to a new version, which might include new features, security patches, or performance improvements. + +### Implementation Steps + +1. **Identify Expertise of Voters**: + - Determine the areas of expertise for different groups of voters. For instance, some voters may have deep knowledge of network parameters, while others may be experts in blockchain software development. + +2. **Define Authz Grants**: + - Create specific authz grants that allow voters to vote only on the proposals relevant to their expertise. + + **Example Grants**: + - Grant A: Authorization to vote on Parameter Change Proposals. + - Grant B: Authorization to vote on Software Upgrade Proposals. + +3. **Assign Authz Grants**: + - Assign these grants to the appropriate groups of voters based on their expertise. + + **Example Assignments**: + - Group 1: Experts in network parameters receive Grant A. + - Group 2: Experts in software development receive Grant B. + +4. **Enforce Voting Permissions**: + - Ensure that the voting system checks the authz grants before allowing a user to vote on a proposal. If a user tries to vote on a proposal type for which they do not have the appropriate grant, the system will deny the vote. + +## Detailed Example + +### Scenario +- **Group 1**: Network administrators who have in-depth knowledge of how changes to parameters like block size or transaction fees impact the network. +- **Group 2**: Software engineers who are well-versed in the technical aspects of software upgrades and new feature implementations. + +### Steps + +1. **Grant Creation**: + - **Grant A**: Allows voting on Parameter Change Proposals. + - **Grant B**: Allows voting on Software Upgrade Proposals. + +2. **Assigning Grants**: + - **Group 1**: Assigned Grant A. + - **Group 2**: Assigned Grant B. + +3. **Voting Process**: + - When a Parameter Change Proposal is submitted: + - Only members of Group 1 are allowed to vote. If a member of Group 2 attempts to vote, the system checks their authz and denies the vote. + + - When a Software Upgrade Proposal is submitted: + - Only members of Group 2 are allowed to vote. If a member of Group 1 attempts to vote, the system checks their authz and denies the vote. + +## Benefits + +1. **Informed Voting**: + - By restricting voting permissions based on expertise, the voting process becomes more informed and effective, as only knowledgeable individuals vote on relevant proposals. + +2. **Enhanced Security**: + - Reduces the risk of uninformed or malicious votes affecting critical decisions. + +3. **Efficient Governance**: + - Streamlines the governance process by ensuring that proposals are evaluated by the most qualified individuals, leading to better decision-making and more robust governance outcomes. + +By implementing these enhancements, the governance process becomes more structured and reliable, with decisions being made by those best equipped to understand the implications of the proposals. This approach ensures a higher quality of governance and more effective management of the blockchain network. + +# Pull Request: New Ante Handler for Authorization Rules + +## Introduction + +This PR introduces several key enhancements to the authorization (authz) system, aimed at providing more flexibility and control for app developers and users. + +## Key Changes + +1. **New Ante Handler**: + + - A new ante handler has been introduced to help app developers check authorization grants along with the specified rules. This allows for more granular control and ensures that all transactions comply with the defined rules before they are processed. + +2. **Updated Authz Grant Proto**: + + - The `authz grant proto` has been updated to include the capability to add rules to the grants. When granting authorization, developers can now specify conditions based on the type of message. If no rules are specified, the grant will function as a basic grant without any additional conditions. + +3. **Customization for App Developers**: + + - App developers need to edit the `authz_rules_ante.go` file to add more rules based on different message types. This file serves as the central point for defining and enforcing custom rules for various message types within the authorization framework. + +## Sample Code Snippet + +Below is a sample snippet illustrating how the new ante handler processes messages and checks authorization rules: + +```go +for _, msg := range msgs { + // Check if the message is an authorization message + if authzMsg, ok := msg.(*authztypes.MsgExec); ok { + + authzMsgs, err := authzMsg.GetMessages() + if err != nil { + return ctx, err + } + + for _, innerMsg := range authzMsgs { + switch innerMsgConverted := innerMsg.(type) { + case *banktypes.MsgSend: + err := azd.handleSendAuthzRules(ctx, innerMsgConverted, grantee) + if err != nil { + return ctx, err + } + case *govtypes.MsgVote: + err := azd.handleVote(ctx, innerMsgConverted, grantee) + if err != nil { + return ctx, err + } + case *stakingv1beta1.MsgDelegate: + // handle delegate message + } + } + } +} + +// handleCheckSendAuthzRules returns true if the rules are voilated +func (azd AuthzDecorator) handleVote(ctx sdk.Context, msg *govtypes.MsgVote, grantee []byte) error { + + _, rules := azd.azk.GetAuthzWithRules(ctx, grantee, granter, sdk.MsgTypeURL(&govtypes.MsgVote{})) + + proposal, err := azd.govKeeper.GetProposal(msg.ProposalId) + propMsgs := proposal.GetMessages() + if rules == nil { + return nil + } + + for _, msg := range propMsgs { + for _, rule := range rules { + if rule.AllowedMessage != msg.GetTypeUrl() { + return return errorsmod.Wrap(sdkerrors.ErrTxDecode, "Voter is not allowed vote on this message") + } + } + } + + return nil +} + +// handleCheckSendAuthzRules returns true if the rules are voilated +func (azd AuthzDecorator) handleSendAuthzRules(ctx sdk.Context, msg *banktypes.MsgSend, grantee []byte) error { + + _, rules := azd.azk.GetAuthzWithRules(ctx, grantee, granter, sdk.MsgTypeURL(&banktypes.MsgSend{})) + for _, rule := range rules { + + if rule.Key == authztypes.MaxAmount { + limit, err := sdk.ParseCoinsNormalized(strings.Join(rule.Values, ",")) + if err != nil { + return err + } + if !limit.IsAllGTE(msg.Amount) { + return errorsmod.Wrap(sdkerrors.ErrTxDecode, "Amount exceeds the max_amount limit set by the granter") + } + } + + } + + return nil +} +``` + +# Conclusion + +This Spec significantly enhances the authorization system by introducing a new ante handler for checking rules, updating the authz grant proto to support conditional grants, and providing a mechanism for developers to add custom rules. These changes ensure that transactions are processed according to the defined conditions, improving the security and flexibility of the authorization framework. \ No newline at end of file diff --git a/x/auth/ante/expected_keepers.go b/x/auth/ante/expected_keepers.go index 139204cedf78..4f7f3d8c0667 100644 --- a/x/auth/ante/expected_keepers.go +++ b/x/auth/ante/expected_keepers.go @@ -7,6 +7,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/cosmos/cosmos-sdk/x/authz" + govv1types "github.com/cosmos/cosmos-sdk/x/gov/types/v1" ) // AccountKeeper defines the contract needed for AccountKeeper related APIs. @@ -23,3 +25,11 @@ type AccountKeeper interface { type FeegrantKeeper interface { UseGrantedFees(ctx context.Context, granter, grantee sdk.AccAddress, fee sdk.Coins, msgs []sdk.Msg) error } + +type AuthzKeeper interface { + GetAuthzWithRules(ctx context.Context, grantee, granter sdk.AccAddress, msgType string) (authz.Authorization, []*authz.Rule) +} + +type GovKeeper interface { + GetProposalById(ctx context.Context, proposalId uint64) (*govv1types.Proposal, error) +} diff --git a/x/authz/authorization_grant.go b/x/authz/authorization_grant.go index cb2088316fc0..9390410dc661 100644 --- a/x/authz/authorization_grant.go +++ b/x/authz/authorization_grant.go @@ -14,7 +14,7 @@ import ( // NewGrant returns new Grant. Expiration is optional and noop if null. // It returns an error if the expiration is before the current block time, // which is passed into the `blockTime` arg. -func NewGrant(blockTime time.Time, a Authorization, expiration *time.Time) (Grant, error) { +func NewGrant(blockTime time.Time, a Authorization, expiration *time.Time, rules []*Rule) (Grant, error) { if expiration != nil && !expiration.After(blockTime) { return Grant{}, errorsmod.Wrapf(ErrInvalidExpirationTime, "expiration must be after the current block time (%v), got %v", blockTime.Format(time.RFC3339), expiration.Format(time.RFC3339)) } @@ -29,6 +29,7 @@ func NewGrant(blockTime time.Time, a Authorization, expiration *time.Time) (Gran return Grant{ Expiration: expiration, Authorization: any, + Rules: rules, }, nil } diff --git a/x/authz/authorization_grant_test.go b/x/authz/authorization_grant_test.go index ce14692c0b5a..eddc9ee17c03 100644 --- a/x/authz/authorization_grant_test.go +++ b/x/authz/authorization_grant_test.go @@ -36,7 +36,7 @@ func TestNewGrant(t *testing.T) { for _, tc := range tcs { tc := tc t.Run(tc.title, func(t *testing.T) { - _, err := NewGrant(tc.blockTime, tc.a, tc.expire) + _, err := NewGrant(tc.blockTime, tc.a, tc.expire, nil) expecError(require.New(t), tc.err, err) }) } diff --git a/x/authz/authz.pb.go b/x/authz/authz.pb.go index 2b5bf359cb9f..c5d7ce12af4b 100644 --- a/x/authz/authz.pb.go +++ b/x/authz/authz.pb.go @@ -78,6 +78,8 @@ type Grant struct { // doesn't have a time expiration (other conditions in `authorization` // may apply to invalidate the grant) Expiration *time.Time `protobuf:"bytes,2,opt,name=expiration,proto3,stdtime" json:"expiration,omitempty"` + // rules are conditions to execute the grant. + Rules []*Rule `protobuf:"bytes,3,rep,name=rules,proto3" json:"rules,omitempty"` } func (m *Grant) Reset() { *m = Grant{} } @@ -113,6 +115,45 @@ func (m *Grant) XXX_DiscardUnknown() { var xxx_messageInfo_Grant proto.InternalMessageInfo +// rules are conditions to execute the grant. +type Rule struct { + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Values []string `protobuf:"bytes,2,rep,name=values,proto3" json:"values,omitempty"` +} + +func (m *Rule) Reset() { *m = Rule{} } +func (m *Rule) String() string { return proto.CompactTextString(m) } +func (*Rule) ProtoMessage() {} +func (*Rule) Descriptor() ([]byte, []int) { + return fileDescriptor_544dc2e84b61c637, []int{2} +} +func (m *Rule) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Rule) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Rule.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 *Rule) XXX_Merge(src proto.Message) { + xxx_messageInfo_Rule.Merge(m, src) +} +func (m *Rule) XXX_Size() int { + return m.Size() +} +func (m *Rule) XXX_DiscardUnknown() { + xxx_messageInfo_Rule.DiscardUnknown(m) +} + +var xxx_messageInfo_Rule proto.InternalMessageInfo + // GrantAuthorization extends a grant with both the addresses of the grantee and granter. // It is used in genesis.proto and query.proto type GrantAuthorization struct { @@ -126,7 +167,7 @@ func (m *GrantAuthorization) Reset() { *m = GrantAuthorization{} } func (m *GrantAuthorization) String() string { return proto.CompactTextString(m) } func (*GrantAuthorization) ProtoMessage() {} func (*GrantAuthorization) Descriptor() ([]byte, []int) { - return fileDescriptor_544dc2e84b61c637, []int{2} + return fileDescriptor_544dc2e84b61c637, []int{3} } func (m *GrantAuthorization) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -165,7 +206,7 @@ func (m *GrantQueueItem) Reset() { *m = GrantQueueItem{} } func (m *GrantQueueItem) String() string { return proto.CompactTextString(m) } func (*GrantQueueItem) ProtoMessage() {} func (*GrantQueueItem) Descriptor() ([]byte, []int) { - return fileDescriptor_544dc2e84b61c637, []int{3} + return fileDescriptor_544dc2e84b61c637, []int{4} } func (m *GrantQueueItem) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -194,45 +235,141 @@ func (m *GrantQueueItem) XXX_DiscardUnknown() { var xxx_messageInfo_GrantQueueItem proto.InternalMessageInfo +// AllowedGrantRulesKeys contains the keys allowed for each message. +type AllowedGrantRulesKeys struct { + Keys []*Rule `protobuf:"bytes,1,rep,name=keys,proto3" json:"keys,omitempty"` +} + +func (m *AllowedGrantRulesKeys) Reset() { *m = AllowedGrantRulesKeys{} } +func (m *AllowedGrantRulesKeys) String() string { return proto.CompactTextString(m) } +func (*AllowedGrantRulesKeys) ProtoMessage() {} +func (*AllowedGrantRulesKeys) Descriptor() ([]byte, []int) { + return fileDescriptor_544dc2e84b61c637, []int{5} +} +func (m *AllowedGrantRulesKeys) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AllowedGrantRulesKeys) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AllowedGrantRulesKeys.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 *AllowedGrantRulesKeys) XXX_Merge(src proto.Message) { + xxx_messageInfo_AllowedGrantRulesKeys.Merge(m, src) +} +func (m *AllowedGrantRulesKeys) XXX_Size() int { + return m.Size() +} +func (m *AllowedGrantRulesKeys) XXX_DiscardUnknown() { + xxx_messageInfo_AllowedGrantRulesKeys.DiscardUnknown(m) +} + +var xxx_messageInfo_AllowedGrantRulesKeys proto.InternalMessageInfo + +// AppAuthzRules is rules passed to the authz app. +type AppAuthzRules struct { + AllowedRecipients []string `protobuf:"bytes,1,rep,name=allowed_recipients,json=allowedRecipients,proto3" json:"allowed_recipients,omitempty"` + MaxAmount []string `protobuf:"bytes,2,rep,name=max_amount,json=maxAmount,proto3" json:"max_amount,omitempty"` + AllowedStakeValidators []string `protobuf:"bytes,3,rep,name=allowed_stake_validators,json=allowedStakeValidators,proto3" json:"allowed_stake_validators,omitempty"` + AllowedMaxStakeAmount []string `protobuf:"bytes,4,rep,name=allowed_max_stake_amount,json=allowedMaxStakeAmount,proto3" json:"allowed_max_stake_amount,omitempty"` + AllowedProposalTypes []string `protobuf:"bytes,5,rep,name=allowed_proposal_types,json=allowedProposalTypes,proto3" json:"allowed_proposal_types,omitempty"` +} + +func (m *AppAuthzRules) Reset() { *m = AppAuthzRules{} } +func (m *AppAuthzRules) String() string { return proto.CompactTextString(m) } +func (*AppAuthzRules) ProtoMessage() {} +func (*AppAuthzRules) Descriptor() ([]byte, []int) { + return fileDescriptor_544dc2e84b61c637, []int{6} +} +func (m *AppAuthzRules) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AppAuthzRules) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AppAuthzRules.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 *AppAuthzRules) XXX_Merge(src proto.Message) { + xxx_messageInfo_AppAuthzRules.Merge(m, src) +} +func (m *AppAuthzRules) XXX_Size() int { + return m.Size() +} +func (m *AppAuthzRules) XXX_DiscardUnknown() { + xxx_messageInfo_AppAuthzRules.DiscardUnknown(m) +} + +var xxx_messageInfo_AppAuthzRules proto.InternalMessageInfo + func init() { proto.RegisterType((*GenericAuthorization)(nil), "cosmos.authz.v1beta1.GenericAuthorization") proto.RegisterType((*Grant)(nil), "cosmos.authz.v1beta1.Grant") + proto.RegisterType((*Rule)(nil), "cosmos.authz.v1beta1.Rule") proto.RegisterType((*GrantAuthorization)(nil), "cosmos.authz.v1beta1.GrantAuthorization") proto.RegisterType((*GrantQueueItem)(nil), "cosmos.authz.v1beta1.GrantQueueItem") + proto.RegisterType((*AllowedGrantRulesKeys)(nil), "cosmos.authz.v1beta1.AllowedGrantRulesKeys") + proto.RegisterType((*AppAuthzRules)(nil), "cosmos.authz.v1beta1.AppAuthzRules") } func init() { proto.RegisterFile("cosmos/authz/v1beta1/authz.proto", fileDescriptor_544dc2e84b61c637) } var fileDescriptor_544dc2e84b61c637 = []byte{ - // 446 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x93, 0x3f, 0x8f, 0xd3, 0x30, - 0x18, 0xc6, 0xe3, 0xeb, 0xf1, 0xe7, 0x7c, 0x3a, 0x04, 0x51, 0x86, 0xd2, 0x21, 0xa9, 0x22, 0x84, - 0x4e, 0x48, 0x8d, 0x75, 0x07, 0x13, 0x13, 0x8d, 0x90, 0x4e, 0xb0, 0x11, 0x8e, 0x85, 0xa5, 0x72, - 0x5a, 0xe3, 0x5a, 0xd4, 0x71, 0x64, 0x3b, 0xe8, 0x72, 0x1f, 0x81, 0xe9, 0x3e, 0x03, 0x9f, 0x00, - 0xa4, 0x7e, 0x88, 0x8a, 0xa9, 0x62, 0x62, 0xe2, 0x4f, 0x3b, 0xf0, 0x35, 0x50, 0xed, 0x44, 0x34, - 0xb4, 0x12, 0x1d, 0x58, 0x22, 0xdb, 0xef, 0xf3, 0xbc, 0xef, 0x93, 0x5f, 0x62, 0xd8, 0x1d, 0x0a, - 0xc5, 0x85, 0x42, 0xb8, 0xd0, 0xe3, 0x4b, 0xf4, 0xee, 0x24, 0x25, 0x1a, 0x9f, 0xd8, 0x5d, 0x94, - 0x4b, 0xa1, 0x85, 0xeb, 0x59, 0x45, 0x64, 0xcf, 0x2a, 0x45, 0xe7, 0x0e, 0xe6, 0x2c, 0x13, 0xc8, - 0x3c, 0xad, 0xb0, 0x73, 0xd7, 0x0a, 0x07, 0x66, 0x87, 0x2a, 0x97, 0x2d, 0x05, 0x54, 0x08, 0x3a, - 0x21, 0xc8, 0xec, 0xd2, 0xe2, 0x0d, 0xd2, 0x8c, 0x13, 0xa5, 0x31, 0xcf, 0x2b, 0x81, 0x47, 0x05, - 0x15, 0xd6, 0xb8, 0x5a, 0xd5, 0x1d, 0xff, 0xb6, 0xe1, 0xac, 0xb4, 0xa5, 0x50, 0x43, 0xef, 0x8c, - 0x64, 0x44, 0xb2, 0x61, 0xbf, 0xd0, 0x63, 0x21, 0xd9, 0x25, 0xd6, 0x4c, 0x64, 0xee, 0x6d, 0xd8, - 0xe2, 0x8a, 0xb6, 0x41, 0x17, 0x1c, 0x1f, 0x24, 0xab, 0xe5, 0xe3, 0xe7, 0x9f, 0xa7, 0xbd, 0x70, - 0xdb, 0x3b, 0x44, 0x0d, 0xe7, 0xfb, 0x5f, 0x1f, 0x1f, 0x04, 0x56, 0xd6, 0x53, 0xa3, 0xb7, 0x68, - 0x5b, 0xf7, 0xf0, 0x13, 0x80, 0xd7, 0xce, 0x24, 0xce, 0xb4, 0x9b, 0xc2, 0x23, 0xbc, 0x5e, 0x32, - 0x13, 0x0f, 0x4f, 0xbd, 0xc8, 0x46, 0x8e, 0xea, 0xc8, 0x51, 0x3f, 0x2b, 0xe3, 0xfb, 0xbb, 0x45, - 0x48, 0x9a, 0x2d, 0xdd, 0xa7, 0x10, 0x92, 0x8b, 0x9c, 0x49, 0x3b, 0x60, 0xcf, 0x0c, 0xe8, 0x6c, - 0x0c, 0x38, 0xaf, 0x51, 0xc6, 0x37, 0x67, 0xdf, 0x02, 0x70, 0xf5, 0x3d, 0x00, 0xc9, 0x9a, 0x2f, - 0xfc, 0xb0, 0x07, 0x5d, 0x93, 0xb9, 0x09, 0xea, 0x14, 0xde, 0xa0, 0xab, 0x53, 0x22, 0x2d, 0xac, - 0xb8, 0xfd, 0x65, 0xda, 0xab, 0xbf, 0x75, 0x7f, 0x34, 0x92, 0x44, 0xa9, 0x97, 0x5a, 0xb2, 0x8c, - 0x26, 0xb5, 0xf0, 0x8f, 0x87, 0x98, 0x34, 0x3b, 0x78, 0xc8, 0x26, 0xa8, 0xd6, 0xff, 0x07, 0xf5, - 0xa4, 0x01, 0x6a, 0xff, 0x9f, 0xa0, 0xf6, 0x37, 0x20, 0x3d, 0x82, 0xb7, 0x0c, 0xa3, 0x17, 0x05, - 0x29, 0xc8, 0x33, 0x4d, 0xb8, 0x1b, 0xc2, 0x23, 0xae, 0xe8, 0x40, 0x97, 0x39, 0x19, 0x14, 0x72, - 0xa2, 0xda, 0xa0, 0xdb, 0x3a, 0x3e, 0x48, 0x0e, 0xb9, 0xa2, 0xe7, 0x65, 0x4e, 0x5e, 0xc9, 0x89, - 0x8a, 0xe3, 0xd9, 0x4f, 0xdf, 0x99, 0x2d, 0x7c, 0x30, 0x5f, 0xf8, 0xe0, 0xc7, 0xc2, 0x07, 0x57, - 0x4b, 0xdf, 0x99, 0x2f, 0x7d, 0xe7, 0xeb, 0xd2, 0x77, 0x5e, 0xdf, 0xa3, 0x4c, 0x8f, 0x8b, 0x34, - 0x1a, 0x0a, 0x5e, 0xdd, 0x06, 0xb4, 0xf6, 0x7f, 0x5d, 0xd8, 0x4b, 0x96, 0x5e, 0x37, 0xf9, 0x1e, - 0xfe, 0x0e, 0x00, 0x00, 0xff, 0xff, 0x50, 0x89, 0xaf, 0x02, 0x89, 0x03, 0x00, 0x00, + // 645 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xcf, 0x6e, 0xd3, 0x30, + 0x18, 0x6f, 0xda, 0x6e, 0x50, 0x4f, 0x43, 0xcc, 0xea, 0xa6, 0x30, 0x89, 0xb4, 0x8a, 0x10, 0x9a, + 0x90, 0x9a, 0x6c, 0x63, 0x12, 0x88, 0x13, 0xad, 0x90, 0x26, 0x40, 0x48, 0x90, 0x0d, 0x0e, 0x5c, + 0x22, 0xb7, 0xfd, 0xc8, 0xa2, 0x26, 0x71, 0x64, 0x3b, 0xa3, 0xd9, 0x03, 0x70, 0xe0, 0xb4, 0x67, + 0xe0, 0x09, 0x38, 0xec, 0x21, 0x26, 0x4e, 0x13, 0x27, 0x4e, 0xfc, 0x59, 0x0f, 0xbc, 0x06, 0x8a, + 0xed, 0x6c, 0xeb, 0x36, 0xc1, 0x0e, 0x5c, 0xa2, 0xd8, 0xbf, 0x3f, 0xdf, 0xe7, 0xef, 0x67, 0x19, + 0xb5, 0x07, 0x94, 0xc7, 0x94, 0xbb, 0x24, 0x13, 0x3b, 0x7b, 0xee, 0xee, 0x5a, 0x1f, 0x04, 0x59, + 0x53, 0x2b, 0x27, 0x65, 0x54, 0x50, 0xdc, 0x54, 0x0c, 0x47, 0xed, 0x69, 0xc6, 0xf2, 0x02, 0x89, + 0xc3, 0x84, 0xba, 0xf2, 0xab, 0x88, 0xcb, 0xb7, 0x14, 0xd1, 0x97, 0x2b, 0x57, 0xab, 0x14, 0xd4, + 0x0a, 0x28, 0x0d, 0x22, 0x70, 0xe5, 0xaa, 0x9f, 0xbd, 0x73, 0x45, 0x18, 0x03, 0x17, 0x24, 0x4e, + 0x35, 0xa1, 0x19, 0xd0, 0x80, 0x2a, 0x61, 0xf1, 0x57, 0x3a, 0x9e, 0x97, 0x91, 0x24, 0x57, 0x90, + 0x2d, 0x50, 0x73, 0x13, 0x12, 0x60, 0xe1, 0xa0, 0x9b, 0x89, 0x1d, 0xca, 0xc2, 0x3d, 0x22, 0x42, + 0x9a, 0xe0, 0x9b, 0xa8, 0x16, 0xf3, 0xc0, 0x34, 0xda, 0xc6, 0x4a, 0xc3, 0x2b, 0x7e, 0x1f, 0x3d, + 0xfb, 0x72, 0xd0, 0xb1, 0x2f, 0x3b, 0x83, 0x33, 0xa5, 0xfc, 0xf8, 0xfb, 0xf3, 0xbd, 0x96, 0xa2, + 0x75, 0xf8, 0x70, 0xe4, 0x5e, 0xe6, 0x6e, 0x4f, 0x0c, 0x34, 0xb3, 0xc9, 0x48, 0x22, 0x70, 0x1f, + 0xcd, 0x93, 0xb3, 0x90, 0xac, 0x38, 0xb7, 0xde, 0x74, 0x54, 0xcb, 0x4e, 0xd9, 0xb2, 0xd3, 0x4d, + 0xf2, 0xde, 0xdd, 0xab, 0xb5, 0xe0, 0x4d, 0x5b, 0xe2, 0x27, 0x08, 0xc1, 0x38, 0x0d, 0x99, 0x2a, + 0x50, 0x95, 0x05, 0x96, 0x2f, 0x14, 0xd8, 0x2e, 0x47, 0xd9, 0xbb, 0x7e, 0xf8, 0xbd, 0x65, 0xec, + 0xff, 0x68, 0x19, 0xde, 0x19, 0x1d, 0x5e, 0x45, 0x33, 0x2c, 0x8b, 0x80, 0x9b, 0xb5, 0x76, 0x4d, + 0x1a, 0x5c, 0xda, 0x88, 0x97, 0x45, 0xe0, 0x29, 0xa2, 0xbd, 0x8a, 0xea, 0xc5, 0xb2, 0x98, 0xe5, + 0x08, 0xf2, 0x72, 0x96, 0x23, 0xc8, 0xf1, 0x12, 0x9a, 0xdd, 0x25, 0x51, 0x06, 0xdc, 0xac, 0xb6, + 0x6b, 0x2b, 0x0d, 0x4f, 0xaf, 0xec, 0x4f, 0x55, 0x84, 0xe5, 0x5c, 0xa6, 0xc3, 0x58, 0x47, 0xd7, + 0x82, 0x62, 0x17, 0x98, 0x32, 0xe9, 0x99, 0x5f, 0x0f, 0x3a, 0xe5, 0x7d, 0xea, 0x0e, 0x87, 0x0c, + 0x38, 0xdf, 0x12, 0x2c, 0x4c, 0x02, 0xaf, 0x24, 0x9e, 0x6a, 0x40, 0x9e, 0xf8, 0x0a, 0x1a, 0xb8, + 0x18, 0x46, 0xed, 0xff, 0x87, 0xf1, 0x78, 0x2a, 0x8c, 0xfa, 0x3f, 0xc3, 0xa8, 0x9f, 0x0f, 0xc2, + 0xde, 0x40, 0x37, 0xe4, 0x8c, 0x5e, 0x65, 0x90, 0xc1, 0x53, 0x01, 0x31, 0xb6, 0xd1, 0x7c, 0xcc, + 0x03, 0x5f, 0xe4, 0x29, 0xf8, 0x19, 0x8b, 0xb8, 0x69, 0xc8, 0xa9, 0xce, 0xc5, 0x3c, 0xd8, 0xce, + 0x53, 0x78, 0xcd, 0x22, 0x6e, 0x6f, 0xa2, 0xc5, 0x6e, 0x14, 0xd1, 0xf7, 0x30, 0x94, 0xe2, 0x22, + 0x18, 0xfe, 0x1c, 0x72, 0x8e, 0x1d, 0x54, 0x1f, 0x41, 0xae, 0x34, 0x7f, 0x8f, 0x55, 0xf2, 0xec, + 0x0f, 0x55, 0x34, 0xdf, 0x4d, 0xd3, 0xe2, 0x90, 0x7b, 0xd2, 0x05, 0x77, 0x10, 0x26, 0xca, 0xda, + 0x67, 0x30, 0x08, 0xd3, 0x10, 0x12, 0x51, 0xf6, 0xb0, 0xa0, 0x11, 0xef, 0x04, 0xc0, 0xb7, 0x11, + 0x8a, 0xc9, 0xd8, 0x27, 0x31, 0xcd, 0x12, 0xa1, 0x2f, 0x40, 0x23, 0x26, 0xe3, 0xae, 0xdc, 0xc0, + 0x0f, 0x91, 0x59, 0xba, 0x71, 0x41, 0x46, 0xe0, 0xef, 0x92, 0x28, 0x1c, 0x12, 0x41, 0x99, 0xba, + 0x7a, 0x0d, 0x6f, 0x49, 0xe3, 0x5b, 0x05, 0xfc, 0xe6, 0x04, 0xc5, 0x0f, 0x4e, 0x95, 0x45, 0x01, + 0xa5, 0xd6, 0x65, 0xea, 0x52, 0xb9, 0xa8, 0xf1, 0x17, 0x64, 0x2c, 0xc5, 0xba, 0xe4, 0x06, 0x2a, + 0x2d, 0x8b, 0x47, 0x27, 0xa5, 0x9c, 0x44, 0x72, 0x98, 0xdc, 0x9c, 0x91, 0xb2, 0xa6, 0x46, 0x5f, + 0x6a, 0xb0, 0x18, 0x2a, 0xef, 0xf5, 0x0e, 0x7f, 0x59, 0x95, 0xc3, 0x63, 0xcb, 0x38, 0x3a, 0xb6, + 0x8c, 0x9f, 0xc7, 0x96, 0xb1, 0x3f, 0xb1, 0x2a, 0x47, 0x13, 0xab, 0xf2, 0x6d, 0x62, 0x55, 0xde, + 0xde, 0x09, 0x42, 0xb1, 0x93, 0xf5, 0x9d, 0x01, 0x8d, 0xf5, 0x1b, 0xe6, 0x9e, 0x79, 0x15, 0xc6, + 0xea, 0x69, 0xec, 0xcf, 0xca, 0xc4, 0xef, 0xff, 0x09, 0x00, 0x00, 0xff, 0xff, 0x87, 0xe7, 0x38, + 0xf0, 0x3f, 0x05, 0x00, 0x00, } func (m *GenericAuthorization) Marshal() (dAtA []byte, err error) { @@ -285,6 +422,20 @@ func (m *Grant) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.Rules) > 0 { + for iNdEx := len(m.Rules) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Rules[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintAuthz(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } if m.Expiration != nil { n1, err1 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(*m.Expiration, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(*m.Expiration):]) if err1 != nil { @@ -310,6 +461,45 @@ func (m *Grant) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *Rule) 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 *Rule) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Rule) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Values) > 0 { + for iNdEx := len(m.Values) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Values[iNdEx]) + copy(dAtA[i:], m.Values[iNdEx]) + i = encodeVarintAuthz(dAtA, i, uint64(len(m.Values[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintAuthz(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *GrantAuthorization) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -401,6 +591,111 @@ func (m *GrantQueueItem) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *AllowedGrantRulesKeys) 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 *AllowedGrantRulesKeys) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AllowedGrantRulesKeys) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Keys) > 0 { + for iNdEx := len(m.Keys) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Keys[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintAuthz(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *AppAuthzRules) 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 *AppAuthzRules) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AppAuthzRules) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.AllowedProposalTypes) > 0 { + for iNdEx := len(m.AllowedProposalTypes) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.AllowedProposalTypes[iNdEx]) + copy(dAtA[i:], m.AllowedProposalTypes[iNdEx]) + i = encodeVarintAuthz(dAtA, i, uint64(len(m.AllowedProposalTypes[iNdEx]))) + i-- + dAtA[i] = 0x2a + } + } + if len(m.AllowedMaxStakeAmount) > 0 { + for iNdEx := len(m.AllowedMaxStakeAmount) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.AllowedMaxStakeAmount[iNdEx]) + copy(dAtA[i:], m.AllowedMaxStakeAmount[iNdEx]) + i = encodeVarintAuthz(dAtA, i, uint64(len(m.AllowedMaxStakeAmount[iNdEx]))) + i-- + dAtA[i] = 0x22 + } + } + if len(m.AllowedStakeValidators) > 0 { + for iNdEx := len(m.AllowedStakeValidators) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.AllowedStakeValidators[iNdEx]) + copy(dAtA[i:], m.AllowedStakeValidators[iNdEx]) + i = encodeVarintAuthz(dAtA, i, uint64(len(m.AllowedStakeValidators[iNdEx]))) + i-- + dAtA[i] = 0x1a + } + } + if len(m.MaxAmount) > 0 { + for iNdEx := len(m.MaxAmount) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.MaxAmount[iNdEx]) + copy(dAtA[i:], m.MaxAmount[iNdEx]) + i = encodeVarintAuthz(dAtA, i, uint64(len(m.MaxAmount[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } + if len(m.AllowedRecipients) > 0 { + for iNdEx := len(m.AllowedRecipients) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.AllowedRecipients[iNdEx]) + copy(dAtA[i:], m.AllowedRecipients[iNdEx]) + i = encodeVarintAuthz(dAtA, i, uint64(len(m.AllowedRecipients[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func encodeVarintAuthz(dAtA []byte, offset int, v uint64) int { offset -= sovAuthz(v) base := offset @@ -439,6 +734,31 @@ func (m *Grant) Size() (n int) { l = github_com_cosmos_gogoproto_types.SizeOfStdTime(*m.Expiration) n += 1 + l + sovAuthz(uint64(l)) } + if len(m.Rules) > 0 { + for _, e := range m.Rules { + l = e.Size() + n += 1 + l + sovAuthz(uint64(l)) + } + } + return n +} + +func (m *Rule) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovAuthz(uint64(l)) + } + if len(m.Values) > 0 { + for _, s := range m.Values { + l = len(s) + n += 1 + l + sovAuthz(uint64(l)) + } + } return n } @@ -482,6 +802,60 @@ func (m *GrantQueueItem) Size() (n int) { return n } +func (m *AllowedGrantRulesKeys) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Keys) > 0 { + for _, e := range m.Keys { + l = e.Size() + n += 1 + l + sovAuthz(uint64(l)) + } + } + return n +} + +func (m *AppAuthzRules) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.AllowedRecipients) > 0 { + for _, s := range m.AllowedRecipients { + l = len(s) + n += 1 + l + sovAuthz(uint64(l)) + } + } + if len(m.MaxAmount) > 0 { + for _, s := range m.MaxAmount { + l = len(s) + n += 1 + l + sovAuthz(uint64(l)) + } + } + if len(m.AllowedStakeValidators) > 0 { + for _, s := range m.AllowedStakeValidators { + l = len(s) + n += 1 + l + sovAuthz(uint64(l)) + } + } + if len(m.AllowedMaxStakeAmount) > 0 { + for _, s := range m.AllowedMaxStakeAmount { + l = len(s) + n += 1 + l + sovAuthz(uint64(l)) + } + } + if len(m.AllowedProposalTypes) > 0 { + for _, s := range m.AllowedProposalTypes { + l = len(s) + n += 1 + l + sovAuthz(uint64(l)) + } + } + return n +} + func sovAuthz(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -671,6 +1045,40 @@ func (m *Grant) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Rules", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuthz + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAuthz + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAuthz + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Rules = append(m.Rules, &Rule{}) + if err := m.Rules[len(m.Rules)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipAuthz(dAtA[iNdEx:]) @@ -692,7 +1100,7 @@ func (m *Grant) Unmarshal(dAtA []byte) error { } return nil } -func (m *GrantAuthorization) Unmarshal(dAtA []byte) error { +func (m *Rule) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -715,15 +1123,15 @@ func (m *GrantAuthorization) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: GrantAuthorization: wiretype end group for non-group") + return fmt.Errorf("proto: Rule: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: GrantAuthorization: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: Rule: 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) + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -751,11 +1159,11 @@ func (m *GrantAuthorization) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Granter = string(dAtA[iNdEx:postIndex]) + m.Key = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Grantee", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Values", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -783,9 +1191,123 @@ func (m *GrantAuthorization) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Grantee = string(dAtA[iNdEx:postIndex]) + m.Values = append(m.Values, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex - case 3: + default: + iNdEx = preIndex + skippy, err := skipAuthz(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAuthz + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GrantAuthorization) 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 ErrIntOverflowAuthz + } + 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: GrantAuthorization: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GrantAuthorization: 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 ErrIntOverflowAuthz + } + 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 ErrInvalidLengthAuthz + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAuthz + } + 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 Grantee", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuthz + } + 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 ErrInvalidLengthAuthz + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAuthz + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Grantee = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Authorization", wireType) } @@ -960,6 +1482,300 @@ func (m *GrantQueueItem) Unmarshal(dAtA []byte) error { } return nil } +func (m *AllowedGrantRulesKeys) 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 ErrIntOverflowAuthz + } + 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: AllowedGrantRulesKeys: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AllowedGrantRulesKeys: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Keys", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuthz + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAuthz + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAuthz + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Keys = append(m.Keys, &Rule{}) + if err := m.Keys[len(m.Keys)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAuthz(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAuthz + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *AppAuthzRules) 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 ErrIntOverflowAuthz + } + 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: AppAuthzRules: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AppAuthzRules: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AllowedRecipients", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuthz + } + 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 ErrInvalidLengthAuthz + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAuthz + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AllowedRecipients = append(m.AllowedRecipients, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxAmount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuthz + } + 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 ErrInvalidLengthAuthz + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAuthz + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MaxAmount = append(m.MaxAmount, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AllowedStakeValidators", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuthz + } + 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 ErrInvalidLengthAuthz + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAuthz + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AllowedStakeValidators = append(m.AllowedStakeValidators, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AllowedMaxStakeAmount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuthz + } + 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 ErrInvalidLengthAuthz + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAuthz + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AllowedMaxStakeAmount = append(m.AllowedMaxStakeAmount, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AllowedProposalTypes", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuthz + } + 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 ErrInvalidLengthAuthz + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAuthz + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AllowedProposalTypes = append(m.AllowedProposalTypes, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAuthz(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAuthz + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipAuthz(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/authz/client/cli/tx.go b/x/authz/client/cli/tx.go index 78151eaa3d5c..80da44d113a0 100644 --- a/x/authz/client/cli/tx.go +++ b/x/authz/client/cli/tx.go @@ -3,6 +3,7 @@ package cli import ( "errors" "fmt" + "os" "strings" "time" @@ -32,6 +33,7 @@ const ( delegate = "delegate" redelegate = "redelegate" unbond = "unbond" + FlagAuthzRules = "authz-rules" ) // GetTxCmd returns the transaction commands for this module @@ -203,6 +205,20 @@ Examples: return err } + rules, err := cmd.Flags().GetString(FlagAuthzRules) + if err != nil { + return err + } + + if rules != "" { + contents, err := os.ReadFile(rules) + if err != nil { + return err + } + + msg.SetAuthzRules(contents) + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) }, } @@ -213,6 +229,7 @@ Examples: cmd.Flags().StringSlice(FlagDenyValidators, []string{}, "Deny validators addresses separated by ,") cmd.Flags().StringSlice(FlagAllowList, []string{}, "Allowed addresses grantee is allowed to send funds separated by ,") cmd.Flags().Int64(FlagExpiration, 0, "Expire time as Unix timestamp. Set zero (0) for no expiry. Default is 0.") + cmd.Flags().String(FlagAuthzRules, "", "Rules are conditions to be satisfied when the grant is executed") return cmd } diff --git a/x/authz/consts.go b/x/authz/consts.go new file mode 100644 index 000000000000..38f41f232c85 --- /dev/null +++ b/x/authz/consts.go @@ -0,0 +1,9 @@ +package authz + +const ( + AllowedRecipients = "allowed_recipients" + MaxAmount = "max_amount" + AllowedStakeValidators = "allowed_stake_validators" + AllowedMaxStakeAmount = "allowed_max_stake_amount" + AllowedProposalTypes = "allowed_proposal_types" +) diff --git a/x/authz/errors.go b/x/authz/errors.go index 2c353726202f..009b0e434cd2 100644 --- a/x/authz/errors.go +++ b/x/authz/errors.go @@ -20,4 +20,6 @@ var ( ErrAuthorizationNumOfSigners = errors.Register(ModuleName, 9, "authorization can be given to msg with only one signer") // ErrNegativeMaxTokens error if the max tokens is negative ErrNegativeMaxTokens = errors.Register(ModuleName, 12, "max tokens should be positive") + // ErrEmptyAuthzRules error if the authz rules are not set + ErrEmptyAuthzRules = errors.Register(ModuleName, 13, "authz rules are not set") ) diff --git a/x/authz/keeper/genesis.go b/x/authz/keeper/genesis.go index 08b84b8ed682..7b18e5b56ad9 100644 --- a/x/authz/keeper/genesis.go +++ b/x/authz/keeper/genesis.go @@ -28,7 +28,7 @@ func (k Keeper) InitGenesis(ctx sdk.Context, data *authz.GenesisState) { panic("expected authorization") } - err = k.SaveGrant(ctx, grantee, granter, a, entry.Expiration) + err = k.SaveGrant(ctx, grantee, granter, a, entry.Expiration, nil) if err != nil { panic(err) } diff --git a/x/authz/keeper/genesis_test.go b/x/authz/keeper/genesis_test.go index 94320f0ff654..e62ee7fea532 100644 --- a/x/authz/keeper/genesis_test.go +++ b/x/authz/keeper/genesis_test.go @@ -76,7 +76,7 @@ func (suite *GenesisTestSuite) TestImportExportGenesis() { now := suite.ctx.BlockTime() expires := now.Add(time.Hour) grant := &bank.SendAuthorization{SpendLimit: coins} - err := suite.keeper.SaveGrant(suite.ctx, granteeAddr, granterAddr, grant, &expires) + err := suite.keeper.SaveGrant(suite.ctx, granteeAddr, granterAddr, grant, &expires, nil) suite.Require().NoError(err) genesis := suite.keeper.ExportGenesis(suite.ctx) diff --git a/x/authz/keeper/grpc_query_test.go b/x/authz/keeper/grpc_query_test.go index 00d16f96381a..4d96d3316137 100644 --- a/x/authz/keeper/grpc_query_test.go +++ b/x/authz/keeper/grpc_query_test.go @@ -278,7 +278,7 @@ func (suite *TestSuite) createSendAuthorization(grantee, granter sdk.AccAddress) exp := suite.ctx.BlockHeader().Time.Add(time.Hour) newCoins := sdk.NewCoins(sdk.NewInt64Coin("steak", 100)) authorization := &banktypes.SendAuthorization{SpendLimit: newCoins} - err := suite.authzKeeper.SaveGrant(suite.ctx, grantee, granter, authorization, &exp) + err := suite.authzKeeper.SaveGrant(suite.ctx, grantee, granter, authorization, &exp, nil) suite.Require().NoError(err) return authorization } @@ -287,7 +287,7 @@ func (suite *TestSuite) createSendAuthorizationWithAllowList(grantee, granter sd exp := suite.ctx.BlockHeader().Time.Add(time.Hour) newCoins := sdk.NewCoins(sdk.NewInt64Coin("steak", 100)) authorization := &banktypes.SendAuthorization{SpendLimit: newCoins, AllowList: []string{suite.addrs[5].String()}} - err := suite.authzKeeper.SaveGrant(suite.ctx, grantee, granter, authorization, &exp) + err := suite.authzKeeper.SaveGrant(suite.ctx, grantee, granter, authorization, &exp, nil) suite.Require().NoError(err) return authorization } diff --git a/x/authz/keeper/keeper.go b/x/authz/keeper/keeper.go index c7dc7dec5421..147aaba368cf 100644 --- a/x/authz/keeper/keeper.go +++ b/x/authz/keeper/keeper.go @@ -181,13 +181,13 @@ func (k Keeper) DispatchActions(ctx context.Context, grantee sdk.AccAddress, msg // SaveGrant method grants the provided authorization to the grantee on the granter's account // with the provided expiration time and insert authorization key into the grants queue. If there is an existing authorization grant for the // same `sdk.Msg` type, this grant overwrites that. -func (k Keeper) SaveGrant(ctx context.Context, grantee, granter sdk.AccAddress, authorization authz.Authorization, expiration *time.Time) error { +func (k Keeper) SaveGrant(ctx context.Context, grantee, granter sdk.AccAddress, authorization authz.Authorization, expiration *time.Time, rules []*authz.Rule) error { sdkCtx := sdk.UnwrapSDKContext(ctx) msgType := authorization.MsgTypeURL() store := k.storeService.OpenKVStore(ctx) skey := grantStoreKey(grantee, granter, msgType) - grant, err := authz.NewGrant(sdkCtx.BlockTime(), authorization, expiration) + grant, err := authz.NewGrant(sdkCtx.BlockTime(), authorization, expiration, rules) if err != nil { return err } @@ -302,6 +302,21 @@ func (k Keeper) GetAuthorization(ctx context.Context, grantee, granter sdk.AccAd return auth, grant.Expiration } +func (k Keeper) GetAuthzWithRules(ctx context.Context, grantee, granter sdk.AccAddress, msgType string) (authz.Authorization, []*authz.Rule) { + sdkCtx := sdk.UnwrapSDKContext(ctx) + grant, found := k.getGrant(ctx, grantStoreKey(grantee, granter, msgType)) + if !found || (grant.Expiration != nil && grant.Expiration.Before(sdkCtx.BlockHeader().Time)) { + return nil, nil + } + + authz, err := grant.GetAuthorization() + if err != nil { + return nil, nil + } + + return authz, grant.Rules +} + // IterateGrants iterates over all authorization grants // This function should be used with caution because it can involve significant IO operations. // It should not be used in query or msg services without charging additional gas. @@ -322,6 +337,47 @@ func (k Keeper) IterateGrants(ctx context.Context, } } +func (k Keeper) SetAuthzRulesKeys(ctx context.Context, rules *authz.AllowedGrantRulesKeys) error { + store := k.storeService.OpenKVStore(ctx) + + bz, err := k.cdc.Marshal(rules) + if err != nil { + return err + } + + err = store.Set(AuthzOptionsKeys, bz) + return err +} + +func (k Keeper) GetAuthzRulesKeys(ctx context.Context) (*authz.AllowedGrantRulesKeys, error) { + + // TODO: testing purpose, please remove. + return &authz.AllowedGrantRulesKeys{ + Keys: []*authz.Rule{ + { + Key: "/cosmos.gov.v1.MsgVote", + Values: []string{"allowed_authz_rules"}, + }, + }, + }, nil + // till here + + // store := k.storeService.OpenKVStore(ctx) + // bz, err := store.Get(AuthzOptionsKeys) + + // if err != nil { + // return nil, err + // } + + // var authzRuleKeys *authz.AllowedGrantRulesKeys + // err = k.cdc.Unmarshal(bz, authzRuleKeys) + // if err != nil { + // return nil, err + // } + + // return authzRuleKeys, nil +} + func (k Keeper) getGrantQueueItem(ctx context.Context, expiration time.Time, granter, grantee sdk.AccAddress) (*authz.GrantQueueItem, error) { store := k.storeService.OpenKVStore(ctx) bz, err := store.Get(GrantQueueKey(expiration, granter, grantee)) diff --git a/x/authz/keeper/keeper_test.go b/x/authz/keeper/keeper_test.go index 066e7d70750a..58dc918b4249 100644 --- a/x/authz/keeper/keeper_test.go +++ b/x/authz/keeper/keeper_test.go @@ -101,7 +101,7 @@ func (s *TestSuite) TestKeeper() { s.T().Log("verify save, get and delete") sendAutz := &banktypes.SendAuthorization{SpendLimit: coins100} expire := now.AddDate(1, 0, 0) - err = s.authzKeeper.SaveGrant(ctx, granteeAddr, granterAddr, sendAutz, &expire) + err = s.authzKeeper.SaveGrant(ctx, granteeAddr, granterAddr, sendAutz, &expire, nil) require.NoError(err) authorizations, err = s.authzKeeper.GetAuthorizations(ctx, granteeAddr, granterAddr) @@ -116,7 +116,7 @@ func (s *TestSuite) TestKeeper() { require.Len(authorizations, 0) s.T().Log("verify granting same authorization overwrite existing authorization") - err = s.authzKeeper.SaveGrant(ctx, granteeAddr, granterAddr, sendAutz, &expire) + err = s.authzKeeper.SaveGrant(ctx, granteeAddr, granterAddr, sendAutz, &expire, nil) require.NoError(err) authorizations, err = s.authzKeeper.GetAuthorizations(ctx, granteeAddr, granterAddr) @@ -124,7 +124,7 @@ func (s *TestSuite) TestKeeper() { require.Len(authorizations, 1) sendAutz = &banktypes.SendAuthorization{SpendLimit: coins1000} - err = s.authzKeeper.SaveGrant(ctx, granteeAddr, granterAddr, sendAutz, &expire) + err = s.authzKeeper.SaveGrant(ctx, granteeAddr, granterAddr, sendAutz, &expire, nil) require.NoError(err) authorizations, err = s.authzKeeper.GetAuthorizations(ctx, granteeAddr, granterAddr) require.NoError(err) @@ -148,8 +148,8 @@ func (s *TestSuite) TestKeeperIter() { e := ctx.BlockTime().AddDate(1, 0, 0) sendAuthz := banktypes.NewSendAuthorization(coins100, nil) - s.authzKeeper.SaveGrant(ctx, granteeAddr, granterAddr, sendAuthz, &e) - s.authzKeeper.SaveGrant(ctx, granteeAddr, granter2Addr, sendAuthz, &e) + s.authzKeeper.SaveGrant(ctx, granteeAddr, granterAddr, sendAuthz, &e, nil) + s.authzKeeper.SaveGrant(ctx, granteeAddr, granter2Addr, sendAuthz, &e, nil) s.authzKeeper.IterateGrants(ctx, func(granter, grantee sdk.AccAddress, grant authz.Grant) bool { s.Require().Equal(granteeAddr, grantee) @@ -207,7 +207,7 @@ func (s *TestSuite) TestDispatchAction() { "authorization expired", func() sdk.Context { e := now.AddDate(0, 0, 1) - err := s.authzKeeper.SaveGrant(s.ctx, granteeAddr, granterAddr, a, &e) + err := s.authzKeeper.SaveGrant(s.ctx, granteeAddr, granterAddr, a, &e, nil) require.NoError(err) return s.ctx.WithBlockTime(s.ctx.BlockTime().AddDate(0, 0, 2)) }, @@ -226,7 +226,7 @@ func (s *TestSuite) TestDispatchAction() { "requested amount is more than spend limit", func() sdk.Context { e := now.AddDate(0, 1, 0) - err := s.authzKeeper.SaveGrant(s.ctx, granteeAddr, granterAddr, a, &e) + err := s.authzKeeper.SaveGrant(s.ctx, granteeAddr, granterAddr, a, &e, nil) require.NoError(err) return s.ctx }, @@ -245,7 +245,7 @@ func (s *TestSuite) TestDispatchAction() { "", func() sdk.Context { e := now.AddDate(0, 1, 0) - err := s.authzKeeper.SaveGrant(s.ctx, granteeAddr, granterAddr, a, &e) + err := s.authzKeeper.SaveGrant(s.ctx, granteeAddr, granterAddr, a, &e, nil) require.NoError(err) return s.ctx }, @@ -271,7 +271,7 @@ func (s *TestSuite) TestDispatchAction() { "", func() sdk.Context { e := now.AddDate(0, 1, 0) - err := s.authzKeeper.SaveGrant(s.ctx, granteeAddr, granterAddr, a, &e) + err := s.authzKeeper.SaveGrant(s.ctx, granteeAddr, granterAddr, a, &e, nil) require.NoError(err) return s.ctx }, @@ -321,7 +321,7 @@ func (s *TestSuite) TestDispatchedEvents() { }) // grant authorization - err := s.authzKeeper.SaveGrant(s.ctx, granteeAddr, granterAddr, &banktypes.SendAuthorization{SpendLimit: coins10}, &expiration) + err := s.authzKeeper.SaveGrant(s.ctx, granteeAddr, granterAddr, &banktypes.SendAuthorization{SpendLimit: coins10}, &expiration, nil) require.NoError(err) authorizations, err := s.authzKeeper.GetAuthorizations(s.ctx, granteeAddr, granterAddr) require.NoError(err) @@ -363,18 +363,18 @@ func (s *TestSuite) TestDequeueAllGrantsQueue() { a := banktypes.SendAuthorization{SpendLimit: coins100} // create few authorizations - err := s.authzKeeper.SaveGrant(s.ctx, grantee, granter, &a, &exp) + err := s.authzKeeper.SaveGrant(s.ctx, grantee, granter, &a, &exp, nil) require.NoError(err) - err = s.authzKeeper.SaveGrant(s.ctx, grantee1, granter, &a, &exp) + err = s.authzKeeper.SaveGrant(s.ctx, grantee1, granter, &a, &exp, nil) require.NoError(err) exp2 := exp.AddDate(0, 1, 0) - err = s.authzKeeper.SaveGrant(s.ctx, granter, grantee1, &a, &exp2) + err = s.authzKeeper.SaveGrant(s.ctx, granter, grantee1, &a, &exp2, nil) require.NoError(err) exp2 = exp.AddDate(2, 0, 0) - err = s.authzKeeper.SaveGrant(s.ctx, granter, grantee, &a, &exp2) + err = s.authzKeeper.SaveGrant(s.ctx, granter, grantee, &a, &exp2, nil) require.NoError(err) newCtx := s.ctx.WithBlockTime(exp.AddDate(1, 0, 0)) @@ -413,9 +413,9 @@ func (s *TestSuite) TestGetAuthorization() { expired := start.Add(time.Duration(1) * time.Second) notExpired := start.Add(time.Duration(5) * time.Hour) - s.Require().NoError(s.authzKeeper.SaveGrant(s.ctx, addr1, addr2, genAuthMulti, nil), "creating grant 1->2") - s.Require().NoError(s.authzKeeper.SaveGrant(s.ctx, addr1, addr3, genAuthSend, &expired), "creating grant 1->3") - s.Require().NoError(s.authzKeeper.SaveGrant(s.ctx, addr1, addr4, sendAuth, ¬Expired), "creating grant 1->4") + s.Require().NoError(s.authzKeeper.SaveGrant(s.ctx, addr1, addr2, genAuthMulti, nil, nil), "creating grant 1->2") + s.Require().NoError(s.authzKeeper.SaveGrant(s.ctx, addr1, addr3, genAuthSend, &expired, nil), "creating grant 1->3") + s.Require().NoError(s.authzKeeper.SaveGrant(s.ctx, addr1, addr4, sendAuth, ¬Expired, nil), "creating grant 1->4") // Without access to private keeper methods, I don't know how to save a grant with an invalid authorization. newCtx := s.ctx.WithBlockTime(start.Add(time.Duration(1) * time.Minute)) @@ -489,8 +489,8 @@ func (s *TestSuite) TestGetAuthorizations() { start := s.ctx.BlockHeader().Time expired := start.Add(time.Duration(1) * time.Second) - s.Require().NoError(s.authzKeeper.SaveGrant(s.ctx, addr1, addr2, genAuthMulti, &expired), "creating multi send grant 1->2") - s.Require().NoError(s.authzKeeper.SaveGrant(s.ctx, addr1, addr2, genAuthSend, &expired), "creating send grant 1->2") + s.Require().NoError(s.authzKeeper.SaveGrant(s.ctx, addr1, addr2, genAuthMulti, &expired, nil), "creating multi send grant 1->2") + s.Require().NoError(s.authzKeeper.SaveGrant(s.ctx, addr1, addr2, genAuthSend, &expired, nil), "creating send grant 1->2") authzs, err := s.authzKeeper.GetAuthorizations(s.ctx, addr1, addr2) require.NoError(err) diff --git a/x/authz/keeper/keys.go b/x/authz/keeper/keys.go index 83eabef777e7..24e4f1428a1a 100644 --- a/x/authz/keeper/keys.go +++ b/x/authz/keeper/keys.go @@ -18,6 +18,7 @@ import ( var ( GrantKey = []byte{0x01} // prefix for each key GrantQueuePrefix = []byte{0x02} + AuthzOptionsKeys = []byte{0x03} ) var lenTime = len(sdk.FormatTimeBytes(time.Now())) diff --git a/x/authz/keeper/msg_server.go b/x/authz/keeper/msg_server.go index b6755a9f8436..644a2a95602b 100644 --- a/x/authz/keeper/msg_server.go +++ b/x/authz/keeper/msg_server.go @@ -2,7 +2,10 @@ package keeper import ( "context" + "encoding/json" "errors" + "fmt" + "reflect" "strings" errorsmod "cosmossdk.io/errors" @@ -10,6 +13,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/authz" + bankv1beta1 "github.com/cosmos/cosmos-sdk/x/bank/types" + govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" + staking "github.com/cosmos/cosmos-sdk/x/staking/types" ) var _ authz.MsgServer = Keeper{} @@ -52,7 +58,16 @@ func (k Keeper) Grant(goCtx context.Context, msg *authz.MsgGrant) (*authz.MsgGra return nil, sdkerrors.ErrInvalidType.Wrapf("%s doesn't exist.", t) } - err = k.SaveGrant(ctx, grantee, granter, authorization, msg.Grant.Expiration) + var rules []*authz.Rule + if msg.Rules != nil { + var err error + rules, err = k.VerifyAndBuildRules(goCtx, t, msg.Rules) + if err != nil { + return nil, err + } + } + + err = k.SaveGrant(ctx, grantee, granter, authorization, msg.Grant.Expiration, rules) if err != nil { return nil, err } @@ -60,6 +75,127 @@ func (k Keeper) Grant(goCtx context.Context, msg *authz.MsgGrant) (*authz.MsgGra return &authz.MsgGrantResponse{}, nil } +// VerifyTheRules checks the keys of rules provided are allowed +func (k Keeper) VerifyAndBuildRules(goCtx context.Context, msg string, rulesBytes []byte) ([]*authz.Rule, error) { + var rulesJson authz.AppAuthzRules + err := json.Unmarshal(rulesBytes, &rulesJson) + if err != nil { + return nil, err + } + + if err := validateRules(rulesJson); err != nil { + return nil, err + } + + registeredRules, err := k.GetAuthzRulesKeys(goCtx) + if err != nil { + return nil, err + } + + var values []string + for _, v := range registeredRules.Keys { + if v.Key == msg { + values = v.Values + break + } + } + + if err := checkStructKeys(rulesJson, values); err != nil { + // TODO the condition back + // return nil, err + } + + rules := []*authz.Rule{} + switch msg { + case sdk.MsgTypeURL(&bankv1beta1.MsgSend{}): + if len(rulesJson.AllowedRecipients) > 0 { + rules = append(rules, &authz.Rule{Key: authz.AllowedRecipients, Values: rulesJson.AllowedRecipients}) + } + if len(rulesJson.MaxAmount) > 0 { + rules = append(rules, &authz.Rule{Key: authz.MaxAmount, Values: rulesJson.MaxAmount}) + } + + case sdk.MsgTypeURL(&staking.MsgDelegate{}): + rules = []*authz.Rule{} + if len(rulesJson.AllowedStakeValidators) > 0 { + rules = append(rules, &authz.Rule{Key: authz.AllowedStakeValidators, Values: rulesJson.AllowedStakeValidators}) + } + if len(rulesJson.AllowedMaxStakeAmount) > 0 { + rules = append(rules, &authz.Rule{Key: authz.AllowedMaxStakeAmount, Values: rulesJson.AllowedMaxStakeAmount}) + } + + case sdk.MsgTypeURL(&govv1.MsgVote{}): + rules = []*authz.Rule{} + if len(rulesJson.AllowedProposalTypes) > 0 { + rules = append(rules, &authz.Rule{Key: authz.AllowedProposalTypes, Values: rulesJson.AllowedProposalTypes}) + } + } + + return rules, nil +} + +func checkStructKeys(s interface{}, allowedKeys []string) error { + v := reflect.ValueOf(s) + if v.Kind() == reflect.Ptr { + v = v.Elem() + } + if v.Kind() != reflect.Struct { + return fmt.Errorf("expected a struct, but got %s", v.Kind()) + } + + t := v.Type() + for i := 0; i < t.NumField(); i++ { + field := t.Field(i) + if !isAllowedKey(field.Name, allowedKeys) { + return fmt.Errorf("field %s is not allowed", field.Name) + } + } + return nil +} + +func isAllowedKey(key string, allowedKeys []string) bool { + for _, allowedKey := range allowedKeys { + if key == allowedKey { + return true + } + } + return false +} + +func validateRules(rules authz.AppAuthzRules) error { + for _, addr := range rules.AllowedRecipients { + if _, err := sdk.AccAddressFromBech32(addr); err != nil { + return err + } + } + + coins, err := sdk.ParseCoinsNormalized(strings.Join(rules.MaxAmount, ",")) + if err != nil { + return err + } + + if err := coins.Sort().Validate(); err != nil { + return err + } + + for _, valAddr := range rules.AllowedStakeValidators { + if _, err := sdk.ValAddressFromBech32(valAddr); err != nil { + return err + } + } + + maxStake, err := sdk.ParseCoinsNormalized(strings.Join(rules.AllowedMaxStakeAmount, ",")) + if err != nil { + return err + } + + if err := maxStake.Sort().Validate(); err != nil { + return err + } + + return nil +} + // Revoke implements the MsgServer.Revoke method. func (k Keeper) Revoke(goCtx context.Context, msg *authz.MsgRevoke) (*authz.MsgRevokeResponse, error) { if strings.EqualFold(msg.Grantee, msg.Granter) { diff --git a/x/authz/keeper/msg_server_test.go b/x/authz/keeper/msg_server_test.go index d314c4d2ce08..900689835479 100644 --- a/x/authz/keeper/msg_server_test.go +++ b/x/authz/keeper/msg_server_test.go @@ -45,7 +45,7 @@ func (suite *TestSuite) TestGrant() { { name: "identical grantee and granter", malleate: func() *authz.MsgGrant { - grant, err := authz.NewGrant(curBlockTime, banktypes.NewSendAuthorization(coins, nil), &oneYear) + grant, err := authz.NewGrant(curBlockTime, banktypes.NewSendAuthorization(coins, nil), &oneYear, nil) suite.Require().NoError(err) return &authz.MsgGrant{ Granter: grantee.String(), @@ -59,7 +59,7 @@ func (suite *TestSuite) TestGrant() { { name: "invalid granter", malleate: func() *authz.MsgGrant { - grant, err := authz.NewGrant(curBlockTime, banktypes.NewSendAuthorization(coins, nil), &oneYear) + grant, err := authz.NewGrant(curBlockTime, banktypes.NewSendAuthorization(coins, nil), &oneYear, nil) suite.Require().NoError(err) return &authz.MsgGrant{ Granter: "invalid", @@ -73,7 +73,7 @@ func (suite *TestSuite) TestGrant() { { name: "invalid grantee", malleate: func() *authz.MsgGrant { - grant, err := authz.NewGrant(curBlockTime, banktypes.NewSendAuthorization(coins, nil), &oneYear) + grant, err := authz.NewGrant(curBlockTime, banktypes.NewSendAuthorization(coins, nil), &oneYear, nil) suite.Require().NoError(err) return &authz.MsgGrant{ Granter: granter.String(), @@ -102,7 +102,7 @@ func (suite *TestSuite) TestGrant() { name: "invalid grant, past time", malleate: func() *authz.MsgGrant { pastTime := curBlockTime.Add(-time.Hour) - grant, err := authz.NewGrant(curBlockTime, banktypes.NewSendAuthorization(coins, nil), &oneHour) // we only need the authorization + grant, err := authz.NewGrant(curBlockTime, banktypes.NewSendAuthorization(coins, nil), &oneHour, nil) // we only need the authorization suite.Require().NoError(err) return &authz.MsgGrant{ Granter: granter.String(), @@ -125,7 +125,7 @@ func (suite *TestSuite) TestGrant() { suite.accountKeeper.EXPECT().NewAccountWithAddress(gomock.Any(), newAcc).Return(acc).AnyTimes() suite.accountKeeper.EXPECT().SetAccount(gomock.Any(), acc).Return() - grant, err := authz.NewGrant(curBlockTime, banktypes.NewSendAuthorization(coins, nil), &oneYear) + grant, err := authz.NewGrant(curBlockTime, banktypes.NewSendAuthorization(coins, nil), &oneYear, nil) suite.Require().NoError(err) return &authz.MsgGrant{ Granter: granter.String(), @@ -137,7 +137,7 @@ func (suite *TestSuite) TestGrant() { { name: "valid grant", malleate: func() *authz.MsgGrant { - grant, err := authz.NewGrant(curBlockTime, banktypes.NewSendAuthorization(coins, nil), &oneYear) + grant, err := authz.NewGrant(curBlockTime, banktypes.NewSendAuthorization(coins, nil), &oneYear, nil) suite.Require().NoError(err) return &authz.MsgGrant{ Granter: granter.String(), @@ -149,7 +149,7 @@ func (suite *TestSuite) TestGrant() { { name: "valid grant, same grantee, granter pair but different msgType", malleate: func() *authz.MsgGrant { - g, err := authz.NewGrant(curBlockTime, banktypes.NewSendAuthorization(coins, nil), &oneHour) + g, err := authz.NewGrant(curBlockTime, banktypes.NewSendAuthorization(coins, nil), &oneHour, nil) suite.Require().NoError(err) _, err = suite.msgSrvr.Grant(suite.ctx, &authz.MsgGrant{ Granter: granter.String(), @@ -158,7 +158,7 @@ func (suite *TestSuite) TestGrant() { }) suite.Require().NoError(err) - grant, err := authz.NewGrant(curBlockTime, authz.NewGenericAuthorization("/cosmos.bank.v1beta1.MsgUpdateParams"), &oneHour) + grant, err := authz.NewGrant(curBlockTime, authz.NewGenericAuthorization("/cosmos.bank.v1beta1.MsgUpdateParams"), &oneHour, nil) suite.Require().NoError(err) return &authz.MsgGrant{ Granter: granter.String(), @@ -170,7 +170,7 @@ func (suite *TestSuite) TestGrant() { { name: "valid grant with allow list", malleate: func() *authz.MsgGrant { - grant, err := authz.NewGrant(curBlockTime, banktypes.NewSendAuthorization(coins, []sdk.AccAddress{granter}), &oneYear) + grant, err := authz.NewGrant(curBlockTime, banktypes.NewSendAuthorization(coins, []sdk.AccAddress{granter}), &oneYear, nil) suite.Require().NoError(err) return &authz.MsgGrant{ Granter: granter.String(), @@ -182,7 +182,7 @@ func (suite *TestSuite) TestGrant() { { name: "valid grant with nil expiration time", malleate: func() *authz.MsgGrant { - grant, err := authz.NewGrant(curBlockTime, banktypes.NewSendAuthorization(coins, nil), nil) + grant, err := authz.NewGrant(curBlockTime, banktypes.NewSendAuthorization(coins, nil), nil, nil) suite.Require().NoError(err) return &authz.MsgGrant{ Granter: granter.String(), diff --git a/x/authz/module/abci_test.go b/x/authz/module/abci_test.go index 12055e0cfa12..273fb2858804 100644 --- a/x/authz/module/abci_test.go +++ b/x/authz/module/abci_test.go @@ -68,7 +68,7 @@ func TestExpiredGrantsQueue(t *testing.T) { authzKeeper := keeper.NewKeeper(storeService, encCfg.Codec, baseApp.MsgServiceRouter(), accountKeeper) save := func(grantee sdk.AccAddress, exp *time.Time) { - err := authzKeeper.SaveGrant(ctx, grantee, granter, sendAuthz, exp) + err := authzKeeper.SaveGrant(ctx, grantee, granter, sendAuthz, exp, nil) require.NoError(t, err, "Grant from %s", grantee.String()) } save(grantee1, &expiration) diff --git a/x/authz/msgs.go b/x/authz/msgs.go index 1721c6c5347c..bfdef2a7b6ea 100644 --- a/x/authz/msgs.go +++ b/x/authz/msgs.go @@ -33,6 +33,10 @@ func NewMsgGrant(granter, grantee sdk.AccAddress, a Authorization, expiration *t return m, nil } +func (msg *MsgGrant) SetAuthzRules(rules []byte) { + msg.Rules = rules +} + // GetAuthorization returns the cache value from the MsgGrant.Authorization if present. func (msg *MsgGrant) GetAuthorization() (Authorization, error) { return msg.Grant.GetAuthorization() diff --git a/x/authz/msgs_test.go b/x/authz/msgs_test.go index ea634fd39526..736213f63d71 100644 --- a/x/authz/msgs_test.go +++ b/x/authz/msgs_test.go @@ -64,16 +64,16 @@ func TestAminoJSON(t *testing.T) { typeURL := sdk.MsgTypeURL(&msgSend) msgSendAny, err := cdctypes.NewAnyWithValue(&msgSend) require.NoError(t, err) - grant, err := authz.NewGrant(blockTime, authz.NewGenericAuthorization(typeURL), &expiresAt) + grant, err := authz.NewGrant(blockTime, authz.NewGenericAuthorization(typeURL), &expiresAt, nil) require.NoError(t, err) sendAuthz := banktypes.NewSendAuthorization(sdk.NewCoins(sdk.NewCoin("stake", sdkmath.NewInt(1000))), nil) - sendGrant, err := authz.NewGrant(blockTime, sendAuthz, &expiresAt) + sendGrant, err := authz.NewGrant(blockTime, sendAuthz, &expiresAt, nil) require.NoError(t, err) valAddr, err := sdk.ValAddressFromBech32("cosmosvaloper1xcy3els9ua75kdm783c3qu0rfa2eples6eavqq") require.NoError(t, err) stakingAuth, err := stakingtypes.NewStakeAuthorization([]sdk.ValAddress{valAddr}, nil, stakingtypes.AuthorizationType_AUTHORIZATION_TYPE_DELEGATE, &sdk.Coin{Denom: "stake", Amount: sdkmath.NewInt(1000)}) require.NoError(t, err) - delegateGrant, err := authz.NewGrant(blockTime, stakingAuth, nil) + delegateGrant, err := authz.NewGrant(blockTime, stakingAuth, nil, nil) require.NoError(t, err) // Amino JSON encoding has changed in authz since v0.46. diff --git a/x/authz/simulation/decoder_test.go b/x/authz/simulation/decoder_test.go index ffaf441195f1..7a933284309c 100644 --- a/x/authz/simulation/decoder_test.go +++ b/x/authz/simulation/decoder_test.go @@ -26,7 +26,7 @@ func TestDecodeStore(t *testing.T) { now := time.Now().UTC() e := now.Add(1) sendAuthz := banktypes.NewSendAuthorization(sdk.NewCoins(sdk.NewInt64Coin("foo", 123)), nil) - grant, _ := authz.NewGrant(now, sendAuthz, &e) + grant, _ := authz.NewGrant(now, sendAuthz, &e, nil) grantBz, err := encCfg.Codec.Marshal(&grant) require.NoError(t, err) kvPairs := kv.Pairs{ diff --git a/x/authz/simulation/operations_test.go b/x/authz/simulation/operations_test.go index 8a6894dc2b07..dcf205ebfaee 100644 --- a/x/authz/simulation/operations_test.go +++ b/x/authz/simulation/operations_test.go @@ -163,7 +163,7 @@ func (suite *SimTestSuite) TestSimulateRevoke() { a := banktypes.NewSendAuthorization(initCoins, nil) expire := time.Now().Add(30 * time.Hour) - err := suite.authzKeeper.SaveGrant(suite.ctx, grantee.Address, granter.Address, a, &expire) + err := suite.authzKeeper.SaveGrant(suite.ctx, grantee.Address, granter.Address, a, &expire, nil) suite.Require().NoError(err) // execute operation @@ -197,7 +197,7 @@ func (suite *SimTestSuite) TestSimulateExec() { a := banktypes.NewSendAuthorization(initCoins, nil) expire := suite.ctx.BlockTime().Add(1 * time.Hour) - err := suite.authzKeeper.SaveGrant(suite.ctx, grantee.Address, granter.Address, a, &expire) + err := suite.authzKeeper.SaveGrant(suite.ctx, grantee.Address, granter.Address, a, &expire, nil) suite.Require().NoError(err) // execute operation diff --git a/x/authz/tx.pb.go b/x/authz/tx.pb.go index efbb15db7cc7..ead6fd14538f 100644 --- a/x/authz/tx.pb.go +++ b/x/authz/tx.pb.go @@ -38,6 +38,8 @@ type MsgGrant struct { Granter string `protobuf:"bytes,1,opt,name=granter,proto3" json:"granter,omitempty"` Grantee string `protobuf:"bytes,2,opt,name=grantee,proto3" json:"grantee,omitempty"` Grant Grant `protobuf:"bytes,3,opt,name=grant,proto3" json:"grant"` + // rules are conditions to execute the grant. + Rules []byte `protobuf:"bytes,4,opt,name=rules,proto3" json:"rules,omitempty"` } func (m *MsgGrant) Reset() { *m = MsgGrant{} } @@ -282,42 +284,43 @@ func init() { func init() { proto.RegisterFile("cosmos/authz/v1beta1/tx.proto", fileDescriptor_3ceddab7d8589ad1) } var fileDescriptor_3ceddab7d8589ad1 = []byte{ - // 555 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x54, 0xbf, 0x6e, 0x13, 0x4f, - 0x10, 0xf6, 0xc6, 0x71, 0xfc, 0xf3, 0x26, 0xd2, 0x8f, 0x5c, 0x2c, 0x71, 0xb9, 0x28, 0x97, 0xd3, - 0x91, 0x80, 0x65, 0xe4, 0x5d, 0xd9, 0x74, 0x16, 0x4d, 0x2c, 0x45, 0x34, 0x58, 0x48, 0x07, 0x34, - 0x34, 0xd6, 0xd9, 0x5e, 0x36, 0x56, 0x7c, 0xb7, 0xd6, 0xed, 0xd9, 0xb2, 0xa9, 0x10, 0x25, 0x15, - 0x8f, 0x01, 0x9d, 0x8b, 0x94, 0x3c, 0x80, 0x45, 0x15, 0x51, 0x20, 0x2a, 0x04, 0x76, 0xe1, 0xc7, - 0x00, 0xdd, 0xfe, 0x31, 0x0e, 0x72, 0x42, 0x2a, 0x9a, 0xbb, 0x99, 0xf9, 0xbe, 0xd9, 0x9d, 0x6f, - 0x66, 0xb4, 0x70, 0xbf, 0xc5, 0x78, 0xc0, 0x38, 0xf6, 0xfb, 0xf1, 0xe9, 0x2b, 0x3c, 0x28, 0x37, - 0x49, 0xec, 0x97, 0x71, 0x3c, 0x44, 0xbd, 0x88, 0xc5, 0xcc, 0xc8, 0x4b, 0x18, 0x09, 0x18, 0x29, - 0xd8, 0xda, 0x95, 0xd1, 0x86, 0xe0, 0x60, 0x45, 0x11, 0x8e, 0x95, 0xa7, 0x8c, 0x32, 0x19, 0x4f, - 0x2c, 0x15, 0xdd, 0xa5, 0x8c, 0xd1, 0x2e, 0xc1, 0xc2, 0x6b, 0xf6, 0x5f, 0x62, 0x3f, 0x1c, 0x29, - 0xc8, 0x59, 0x59, 0x80, 0xbc, 0x4f, 0x32, 0x6e, 0x2b, 0x46, 0xc0, 0x29, 0x1e, 0x94, 0x93, 0x9f, - 0x02, 0xb6, 0xfd, 0xa0, 0x13, 0x32, 0x2c, 0xbe, 0x32, 0xe4, 0x7e, 0x01, 0xf0, 0xbf, 0x3a, 0xa7, - 0x8f, 0x22, 0x3f, 0x8c, 0x8d, 0x0a, 0xcc, 0xd2, 0xc4, 0x20, 0x91, 0x09, 0x1c, 0x50, 0xc8, 0xd5, - 0xcc, 0xcf, 0xe7, 0x25, 0xad, 0xe8, 0xb8, 0xdd, 0x8e, 0x08, 0xe7, 0x4f, 0xe3, 0xa8, 0x13, 0x52, - 0x4f, 0x13, 0x7f, 0xe7, 0x10, 0x73, 0xed, 0x66, 0x39, 0xc4, 0x78, 0x08, 0x33, 0xc2, 0x34, 0xd3, - 0x0e, 0x28, 0x6c, 0x56, 0xf6, 0xd0, 0xaa, 0xa6, 0x21, 0x51, 0x53, 0x2d, 0x37, 0xf9, 0x76, 0x90, - 0x7a, 0x3f, 0x1f, 0x17, 0x81, 0x27, 0x93, 0xaa, 0x87, 0x6f, 0xe6, 0xe3, 0xa2, 0xbe, 0xff, 0xed, - 0x7c, 0x5c, 0xdc, 0x91, 0xe9, 0x25, 0xde, 0x3e, 0xc3, 0x5a, 0x8b, 0x6b, 0xc0, 0x5b, 0xda, 0xf6, - 0x08, 0xef, 0xb1, 0x90, 0x13, 0xf7, 0x03, 0x80, 0xd9, 0x3a, 0xa7, 0x27, 0x43, 0xd2, 0x5a, 0xae, - 0x1b, 0xdc, 0xb4, 0xee, 0x13, 0xb8, 0x1e, 0x70, 0xca, 0xcd, 0x35, 0x27, 0x5d, 0xd8, 0xac, 0xe4, - 0x91, 0x1c, 0x12, 0xd2, 0x43, 0x42, 0xc7, 0xe1, 0xa8, 0xb6, 0xf7, 0xe9, 0xbc, 0xa4, 0x06, 0x80, - 0x9a, 0x3e, 0x27, 0x0b, 0x39, 0x75, 0x4e, 0x3d, 0x91, 0x5e, 0xbd, 0xb3, 0x24, 0x80, 0x24, 0x02, - 0x8c, 0xcb, 0x02, 0x92, 0xfa, 0xdc, 0xfb, 0xf0, 0x7f, 0x65, 0xea, 0xf2, 0x0d, 0x13, 0x66, 0x23, - 0xc2, 0xfb, 0xdd, 0x98, 0x9b, 0xc0, 0x49, 0x17, 0xb6, 0x3c, 0xed, 0xba, 0x1f, 0x01, 0xcc, 0x25, - 0xe7, 0x93, 0x01, 0x3b, 0x23, 0xff, 0x6c, 0x8c, 0x0e, 0xdc, 0x0a, 0x38, 0x6d, 0xc4, 0xa3, 0x1e, - 0x69, 0xf4, 0xa3, 0xae, 0x98, 0x66, 0xce, 0x83, 0x01, 0xa7, 0xcf, 0x46, 0x3d, 0xf2, 0x3c, 0xea, - 0x56, 0x8f, 0xfe, 0x1c, 0x55, 0xfe, 0xb2, 0x52, 0x59, 0xb0, 0xbb, 0x03, 0xb7, 0x17, 0x8e, 0x56, - 0x5b, 0xf9, 0x09, 0x60, 0xba, 0xce, 0xa9, 0xf1, 0x04, 0x66, 0xe4, 0x76, 0xda, 0xab, 0xd7, 0x44, - 0x4f, 0xd9, 0xba, 0x7b, 0x3d, 0xbe, 0x68, 0xe3, 0x63, 0xb8, 0x2e, 0x36, 0x60, 0xff, 0x4a, 0x7e, - 0x02, 0x5b, 0x47, 0xd7, 0xc2, 0x8b, 0xd3, 0x3c, 0xb8, 0xa1, 0xda, 0x7e, 0x70, 0x65, 0x82, 0x24, - 0x58, 0xf7, 0xfe, 0x42, 0xd0, 0x67, 0x5a, 0x99, 0xd7, 0xc9, 0xbe, 0xd7, 0x6a, 0x93, 0x1f, 0x76, - 0x6a, 0x32, 0xb5, 0xc1, 0xc5, 0xd4, 0x06, 0xdf, 0xa7, 0x36, 0x78, 0x37, 0xb3, 0x53, 0x17, 0x33, - 0x3b, 0xf5, 0x75, 0x66, 0xa7, 0x5e, 0x1c, 0xd2, 0x4e, 0x7c, 0xda, 0x6f, 0xa2, 0x16, 0x0b, 0xd4, - 0x8b, 0x82, 0x97, 0x9a, 0x3b, 0x94, 0x2f, 0x42, 0x73, 0x43, 0x2c, 0xe7, 0x83, 0x5f, 0x01, 0x00, - 0x00, 0xff, 0xff, 0x13, 0x38, 0x6d, 0x34, 0xb7, 0x04, 0x00, 0x00, + // 569 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x54, 0x41, 0x6f, 0x12, 0x5f, + 0x10, 0xe7, 0x15, 0x28, 0x7f, 0x5e, 0x49, 0xfe, 0x76, 0x4b, 0xe2, 0x76, 0x9b, 0x6e, 0x37, 0x6b, + 0xab, 0x04, 0xc3, 0x6e, 0xc0, 0x1b, 0xf1, 0x52, 0x92, 0xc6, 0x8b, 0xc4, 0x64, 0xd5, 0x8b, 0x17, + 0xb2, 0xc0, 0xf3, 0x95, 0x94, 0xdd, 0x47, 0x76, 0x76, 0x09, 0x78, 0x32, 0x1e, 0x3d, 0xf9, 0x31, + 0xf4, 0xc6, 0xa1, 0x47, 0x3f, 0x00, 0xf1, 0xd4, 0x78, 0xf2, 0x64, 0x14, 0x0e, 0x5c, 0xfc, 0x0e, + 0x9a, 0x7d, 0x6f, 0x1f, 0x52, 0x43, 0x6b, 0x4f, 0x5e, 0x60, 0x66, 0x7e, 0xbf, 0x19, 0xe6, 0x37, + 0x33, 0x3c, 0xbc, 0xdf, 0x61, 0xe0, 0x31, 0xb0, 0xdd, 0x28, 0x3c, 0x7d, 0x65, 0x0f, 0xab, 0x6d, + 0x12, 0xba, 0x55, 0x3b, 0x1c, 0x59, 0x83, 0x80, 0x85, 0x4c, 0x29, 0x0a, 0xd8, 0xe2, 0xb0, 0x95, + 0xc0, 0xda, 0xae, 0x88, 0xb6, 0x38, 0xc7, 0x4e, 0x28, 0xdc, 0xd1, 0x8a, 0x94, 0x51, 0x26, 0xe2, + 0xb1, 0x95, 0x44, 0x77, 0x29, 0x63, 0xb4, 0x4f, 0x6c, 0xee, 0xb5, 0xa3, 0x97, 0xb6, 0xeb, 0x8f, + 0x13, 0xc8, 0x58, 0xdb, 0x80, 0xf8, 0x3d, 0xc1, 0xb8, 0x9d, 0x30, 0x3c, 0xa0, 0xf6, 0xb0, 0x1a, + 0x7f, 0x25, 0xc0, 0xb6, 0xeb, 0xf5, 0x7c, 0x66, 0xf3, 0x4f, 0x11, 0x32, 0x7f, 0x20, 0xfc, 0x5f, + 0x13, 0xe8, 0xa3, 0xc0, 0xf5, 0x43, 0xa5, 0x86, 0x73, 0x34, 0x36, 0x48, 0xa0, 0x22, 0x03, 0x95, + 0xf2, 0x0d, 0xf5, 0xf3, 0x79, 0x45, 0x2a, 0x3a, 0xee, 0x76, 0x03, 0x02, 0xf0, 0x34, 0x0c, 0x7a, + 0x3e, 0x75, 0x24, 0xf1, 0x77, 0x0e, 0x51, 0x37, 0x6e, 0x96, 0x43, 0x94, 0x87, 0x38, 0xcb, 0x4d, + 0x35, 0x6d, 0xa0, 0xd2, 0x56, 0x6d, 0xcf, 0x5a, 0x37, 0x34, 0x8b, 0xf7, 0xd4, 0xc8, 0x4f, 0xbf, + 0x1e, 0xa4, 0xde, 0x2f, 0x26, 0x65, 0xe4, 0x88, 0x24, 0xa5, 0x88, 0xb3, 0x41, 0xd4, 0x27, 0xa0, + 0x66, 0x0c, 0x54, 0x2a, 0x38, 0xc2, 0xa9, 0x1f, 0xbe, 0x59, 0x4c, 0xca, 0xb2, 0xab, 0xb7, 0x8b, + 0x49, 0x79, 0x47, 0x14, 0xad, 0x40, 0xf7, 0xcc, 0x96, 0x0a, 0x4d, 0x05, 0xdf, 0x92, 0xb6, 0x43, + 0x60, 0xc0, 0x7c, 0x20, 0xe6, 0x07, 0x84, 0x73, 0x4d, 0xa0, 0x27, 0x23, 0xd2, 0x59, 0x55, 0x83, + 0x6e, 0xaa, 0xe6, 0x04, 0x67, 0x3c, 0xa0, 0xa0, 0x6e, 0x18, 0xe9, 0xd2, 0x56, 0xad, 0x68, 0x89, + 0xd5, 0x59, 0x72, 0x75, 0xd6, 0xb1, 0x3f, 0x6e, 0xec, 0x7d, 0x3a, 0xaf, 0x24, 0x6b, 0xb1, 0xda, + 0x2e, 0x90, 0xa5, 0xc8, 0x26, 0x50, 0x87, 0xa7, 0xd7, 0xef, 0xac, 0x08, 0x20, 0xb1, 0x00, 0xe5, + 0xb2, 0x80, 0xb8, 0x3f, 0xf3, 0x3e, 0xfe, 0x3f, 0x31, 0x65, 0xfb, 0x8a, 0x8a, 0x73, 0x01, 0x81, + 0xa8, 0x1f, 0x82, 0x8a, 0x8c, 0x74, 0xa9, 0xe0, 0x48, 0xd7, 0xfc, 0x88, 0x70, 0x3e, 0xae, 0x4f, + 0x86, 0xec, 0x8c, 0xfc, 0xb3, 0xe5, 0x1a, 0xb8, 0xe0, 0x01, 0x6d, 0x85, 0xe3, 0x01, 0x69, 0x45, + 0x41, 0x9f, 0xef, 0x38, 0xef, 0x60, 0x0f, 0xe8, 0xb3, 0xf1, 0x80, 0x3c, 0x0f, 0xfa, 0xf5, 0xa3, + 0x3f, 0x57, 0x55, 0xbc, 0xac, 0x54, 0x34, 0x6c, 0xee, 0xe0, 0xed, 0xa5, 0x23, 0xd5, 0xd6, 0x7e, + 0x22, 0x9c, 0x6e, 0x02, 0x55, 0x9e, 0xe0, 0xac, 0xb8, 0x59, 0x7d, 0xfd, 0xf1, 0xc8, 0x2d, 0x6b, + 0x77, 0xaf, 0xc7, 0x97, 0x63, 0x7c, 0x8c, 0x33, 0xfc, 0x02, 0xf6, 0xaf, 0xe4, 0xc7, 0xb0, 0x76, + 0x74, 0x2d, 0xbc, 0xac, 0xe6, 0xe0, 0xcd, 0x64, 0xec, 0x07, 0x57, 0x26, 0x08, 0x82, 0x76, 0xef, + 0x2f, 0x04, 0x59, 0x53, 0xcb, 0xbe, 0x8e, 0xff, 0x05, 0x8d, 0xc6, 0xf4, 0xbb, 0x9e, 0x9a, 0xce, + 0x74, 0x74, 0x31, 0xd3, 0xd1, 0xb7, 0x99, 0x8e, 0xde, 0xcd, 0xf5, 0xd4, 0xc5, 0x5c, 0x4f, 0x7d, + 0x99, 0xeb, 0xa9, 0x17, 0x87, 0xb4, 0x17, 0x9e, 0x46, 0x6d, 0xab, 0xc3, 0xbc, 0xe4, 0x9d, 0xb1, + 0x57, 0x86, 0x3b, 0x12, 0xef, 0x44, 0x7b, 0x93, 0x1f, 0xe7, 0x83, 0x5f, 0x01, 0x00, 0x00, 0xff, + 0xff, 0x05, 0x07, 0xc6, 0x37, 0xcd, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -510,6 +513,13 @@ func (m *MsgGrant) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.Rules) > 0 { + i -= len(m.Rules) + copy(dAtA[i:], m.Rules) + i = encodeVarintTx(dAtA, i, uint64(len(m.Rules))) + i-- + dAtA[i] = 0x22 + } { size, err := m.Grant.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -730,6 +740,10 @@ func (m *MsgGrant) Size() (n int) { } l = m.Grant.Size() n += 1 + l + sovTx(uint64(l)) + l = len(m.Rules) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } return n } @@ -938,6 +952,40 @@ func (m *MsgGrant) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Rules", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Rules = append(m.Rules[:0], dAtA[iNdEx:postIndex]...) + if m.Rules == nil { + m.Rules = []byte{} + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) diff --git a/x/gov/keeper/proposal.go b/x/gov/keeper/proposal.go index 20eb6763d069..41cd1ddfdd30 100644 --- a/x/gov/keeper/proposal.go +++ b/x/gov/keeper/proposal.go @@ -9,6 +9,8 @@ import ( "cosmossdk.io/collections" errorsmod "cosmossdk.io/errors" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/gov/types" @@ -268,3 +270,15 @@ func (keeper Keeper) ActivateVotingPeriod(ctx context.Context, proposal v1.Propo return keeper.ActiveProposalsQueue.Set(ctx, collections.Join(*proposal.VotingEndTime, proposal.Id), proposal.Id) } + +func (keeper Keeper) GetProposalById(ctx context.Context, proposalId uint64) (*v1.Proposal, error) { + proposal, err := keeper.Proposals.Get(ctx, proposalId) + if err != nil { + if errorsmod.IsOf(err, collections.ErrNotFound) { + return nil, status.Errorf(codes.NotFound, "proposal %d doesn't exist", proposalId) + } + return nil, status.Error(codes.Internal, err.Error()) + } + + return &proposal, err +}