From 3b2a261cb1c78ef2a285ca45b7f6374ea9ff5e4a Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 10 Apr 2024 10:49:27 +0530 Subject: [PATCH 01/30] feat: authz-rules POC --- x/auth/ante/authz_rules.go | 43 +++++++++++++++++++++++++++++++++ x/auth/ante/expected_keepers.go | 3 +++ 2 files changed, 46 insertions(+) create mode 100644 x/auth/ante/authz_rules.go diff --git a/x/auth/ante/authz_rules.go b/x/auth/ante/authz_rules.go new file mode 100644 index 000000000000..f9473d30cf27 --- /dev/null +++ b/x/auth/ante/authz_rules.go @@ -0,0 +1,43 @@ +package ante + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + authztypes "github.com/cosmos/cosmos-sdk/x/authz" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" +) + +// AuthzDecorator checks the authorization message grants for some rules. +func AuthzDecorator(ak AccountKeeper, _ AuthzKeeper) sdk.AnteHandler { + return func(ctx sdk.Context, tx sdk.Tx, simulate bool) (sdk.Context, error) { + msgs := tx.GetMsgs() + for _, msg := range msgs { + // Check if the message is an authorization message + if authzMsg, ok := msg.(*authztypes.MsgGrant); ok { + authz, err := authzMsg.Grant.GetAuthorization() + if err != nil { + return ctx, err + } + + switch authzConverted := authz.(type) { + case *banktypes.SendAuthorization: + if checkSendAuthzRulesVoilated(authzConverted) { + return ctx, fmt.Errorf("authz rules are not meeting") + } + + default: + fmt.Println("default case reached here") + } + } + } + + // Continue with the transaction if all checks pass + return ctx, nil + } +} + +func checkSendAuthzRulesVoilated(authz *banktypes.SendAuthorization) bool { + // more rules can be added here. + return authz.SpendLimit.IsAllGT(sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 1000))) +} diff --git a/x/auth/ante/expected_keepers.go b/x/auth/ante/expected_keepers.go index 139204cedf78..7f99af55dd0b 100644 --- a/x/auth/ante/expected_keepers.go +++ b/x/auth/ante/expected_keepers.go @@ -23,3 +23,6 @@ type AccountKeeper interface { type FeegrantKeeper interface { UseGrantedFees(ctx context.Context, granter, grantee sdk.AccAddress, fee sdk.Coins, msgs []sdk.Msg) error } + +type AuthzKeeper interface { +} From 07a9f17194302cb668b6e4e3c79b6e3b3e740fa4 Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 10 Apr 2024 11:01:49 +0530 Subject: [PATCH 02/30] changes --- x/auth/ante/authz_rules.go | 45 ++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/x/auth/ante/authz_rules.go b/x/auth/ante/authz_rules.go index f9473d30cf27..489a39c55032 100644 --- a/x/auth/ante/authz_rules.go +++ b/x/auth/ante/authz_rules.go @@ -8,33 +8,36 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" ) -// AuthzDecorator checks the authorization message grants for some rules. -func AuthzDecorator(ak AccountKeeper, _ AuthzKeeper) sdk.AnteHandler { - return func(ctx sdk.Context, tx sdk.Tx, simulate bool) (sdk.Context, error) { - msgs := tx.GetMsgs() - for _, msg := range msgs { - // Check if the message is an authorization message - if authzMsg, ok := msg.(*authztypes.MsgGrant); ok { - authz, err := authzMsg.Grant.GetAuthorization() - if err != nil { - return ctx, err - } +type AuthzDecorator struct { + accountKeeper AccountKeeper + authzKeeper AuthzKeeper +} - switch authzConverted := authz.(type) { - case *banktypes.SendAuthorization: - if checkSendAuthzRulesVoilated(authzConverted) { - return ctx, fmt.Errorf("authz rules are not meeting") - } +// AuthzDecorator checks the authorization message grants for some rules. +func (az AuthzDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) { + msgs := tx.GetMsgs() + for _, msg := range msgs { + // Check if the message is an authorization message + if authzMsg, ok := msg.(*authztypes.MsgGrant); ok { + authz, err := authzMsg.Grant.GetAuthorization() + if err != nil { + return ctx, err + } - default: - fmt.Println("default case reached here") + switch authzConverted := authz.(type) { + case *banktypes.SendAuthorization: + if checkSendAuthzRulesVoilated(authzConverted) { + return ctx, fmt.Errorf("authz rules are not meeting") } + + default: + fmt.Println("default case reached here") } } - - // Continue with the transaction if all checks pass - return ctx, nil } + + // Continue with the transaction if all checks pass + return next(ctx, tx, simulate) } func checkSendAuthzRulesVoilated(authz *banktypes.SendAuthorization) bool { From 7394c1934f0aca3528a5e2a6dc6631968e96a08a Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 10 Apr 2024 11:03:16 +0530 Subject: [PATCH 03/30] changes --- x/auth/ante/authz_rules.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/x/auth/ante/authz_rules.go b/x/auth/ante/authz_rules.go index 489a39c55032..237d9d4adc44 100644 --- a/x/auth/ante/authz_rules.go +++ b/x/auth/ante/authz_rules.go @@ -19,7 +19,8 @@ func (az AuthzDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, n for _, msg := range msgs { // Check if the message is an authorization message if authzMsg, ok := msg.(*authztypes.MsgGrant); ok { - authz, err := authzMsg.Grant.GetAuthorization() + + authz, err := authzMsg.GetAuthorization() if err != nil { return ctx, err } From a03ab3bd8fb1129e4c8e97228a2d7d0fa6d7923c Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 10 Apr 2024 11:03:43 +0530 Subject: [PATCH 04/30] changes --- x/auth/ante/authz_rules.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/x/auth/ante/authz_rules.go b/x/auth/ante/authz_rules.go index 237d9d4adc44..969961b89dc8 100644 --- a/x/auth/ante/authz_rules.go +++ b/x/auth/ante/authz_rules.go @@ -9,8 +9,7 @@ import ( ) type AuthzDecorator struct { - accountKeeper AccountKeeper - authzKeeper AuthzKeeper + _ AuthzKeeper } // AuthzDecorator checks the authorization message grants for some rules. From 0db8ed246f81849af79baa386663b3b3b6ff3a3f Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 10 Apr 2024 15:26:44 +0530 Subject: [PATCH 05/30] authz rules --- api/cosmos/authz/v1beta1/authz.pulsar.go | 1868 ++++++++++++++++- proto/cosmos/authz/v1beta1/authz.proto | 26 + simapp/authz_rules.go | 13 + .../{authz_rules.go => authz_rules_ante.go} | 26 +- x/auth/ante/expected_keepers.go | 2 + x/authz/authz.pb.go | 677 +++++- x/authz/keeper/keeper.go | 32 + x/authz/keeper/keys.go | 6 + 8 files changed, 2586 insertions(+), 64 deletions(-) create mode 100644 simapp/authz_rules.go rename x/auth/ante/{authz_rules.go => authz_rules_ante.go} (55%) diff --git a/api/cosmos/authz/v1beta1/authz.pulsar.go b/api/cosmos/authz/v1beta1/authz.pulsar.go index 90983b2ebe9f..1693896b9c28 100644 --- a/api/cosmos/authz/v1beta1/authz.pulsar.go +++ b/api/cosmos/authz/v1beta1/authz.pulsar.go @@ -3,6 +3,7 @@ package authzv1beta1 import ( _ "cosmossdk.io/api/amino" + v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" @@ -2073,6 +2074,1618 @@ func (x *fastReflection_GrantQueueItem) ProtoMethods() *protoiface.Methods { } } +var ( + md_AuthzRules protoreflect.MessageDescriptor + fd_AuthzRules_send protoreflect.FieldDescriptor + fd_AuthzRules_stake protoreflect.FieldDescriptor +) + +func init() { + file_cosmos_authz_v1beta1_authz_proto_init() + md_AuthzRules = File_cosmos_authz_v1beta1_authz_proto.Messages().ByName("AuthzRules") + fd_AuthzRules_send = md_AuthzRules.Fields().ByName("send") + fd_AuthzRules_stake = md_AuthzRules.Fields().ByName("stake") +} + +var _ protoreflect.Message = (*fastReflection_AuthzRules)(nil) + +type fastReflection_AuthzRules AuthzRules + +func (x *AuthzRules) ProtoReflect() protoreflect.Message { + return (*fastReflection_AuthzRules)(x) +} + +func (x *AuthzRules) 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_AuthzRules_messageType fastReflection_AuthzRules_messageType +var _ protoreflect.MessageType = fastReflection_AuthzRules_messageType{} + +type fastReflection_AuthzRules_messageType struct{} + +func (x fastReflection_AuthzRules_messageType) Zero() protoreflect.Message { + return (*fastReflection_AuthzRules)(nil) +} +func (x fastReflection_AuthzRules_messageType) New() protoreflect.Message { + return new(fastReflection_AuthzRules) +} +func (x fastReflection_AuthzRules_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_AuthzRules +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_AuthzRules) Descriptor() protoreflect.MessageDescriptor { + return md_AuthzRules +} + +// 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_AuthzRules) Type() protoreflect.MessageType { + return _fastReflection_AuthzRules_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_AuthzRules) New() protoreflect.Message { + return new(fastReflection_AuthzRules) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_AuthzRules) Interface() protoreflect.ProtoMessage { + return (*AuthzRules)(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_AuthzRules) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Send != nil { + value := protoreflect.ValueOfMessage(x.Send.ProtoReflect()) + if !f(fd_AuthzRules_send, value) { + return + } + } + if x.Stake != nil { + value := protoreflect.ValueOfMessage(x.Stake.ProtoReflect()) + if !f(fd_AuthzRules_stake, 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_AuthzRules) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "cosmos.authz.v1beta1.AuthzRules.send": + return x.Send != nil + case "cosmos.authz.v1beta1.AuthzRules.stake": + return x.Stake != nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.AuthzRules")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.AuthzRules 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_AuthzRules) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "cosmos.authz.v1beta1.AuthzRules.send": + x.Send = nil + case "cosmos.authz.v1beta1.AuthzRules.stake": + x.Stake = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.AuthzRules")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.AuthzRules 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_AuthzRules) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "cosmos.authz.v1beta1.AuthzRules.send": + value := x.Send + return protoreflect.ValueOfMessage(value.ProtoReflect()) + case "cosmos.authz.v1beta1.AuthzRules.stake": + value := x.Stake + return protoreflect.ValueOfMessage(value.ProtoReflect()) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.AuthzRules")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.AuthzRules 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_AuthzRules) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "cosmos.authz.v1beta1.AuthzRules.send": + x.Send = value.Message().Interface().(*SendAuthzRules) + case "cosmos.authz.v1beta1.AuthzRules.stake": + x.Stake = value.Message().Interface().(*StakeAuthzRules) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.AuthzRules")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.AuthzRules 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_AuthzRules) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.authz.v1beta1.AuthzRules.send": + if x.Send == nil { + x.Send = new(SendAuthzRules) + } + return protoreflect.ValueOfMessage(x.Send.ProtoReflect()) + case "cosmos.authz.v1beta1.AuthzRules.stake": + if x.Stake == nil { + x.Stake = new(StakeAuthzRules) + } + return protoreflect.ValueOfMessage(x.Stake.ProtoReflect()) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.AuthzRules")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.AuthzRules 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_AuthzRules) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.authz.v1beta1.AuthzRules.send": + m := new(SendAuthzRules) + return protoreflect.ValueOfMessage(m.ProtoReflect()) + case "cosmos.authz.v1beta1.AuthzRules.stake": + m := new(StakeAuthzRules) + return protoreflect.ValueOfMessage(m.ProtoReflect()) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.AuthzRules")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.AuthzRules 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_AuthzRules) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.authz.v1beta1.AuthzRules", 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_AuthzRules) 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_AuthzRules) 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_AuthzRules) 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_AuthzRules) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*AuthzRules) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + if x.Send != nil { + l = options.Size(x.Send) + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.Stake != nil { + l = options.Size(x.Stake) + 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().(*AuthzRules) + 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.Stake != nil { + encoded, err := options.Marshal(x.Stake) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x12 + } + if x.Send != nil { + encoded, err := options.Marshal(x.Send) + 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().(*AuthzRules) + 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: AuthzRules: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: AuthzRules: 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 Send", 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.Send == nil { + x.Send = &SendAuthzRules{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Send); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Stake", 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.Stake == nil { + x.Stake = &StakeAuthzRules{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Stake); 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 = (*_SendAuthzRules_1_list)(nil) + +type _SendAuthzRules_1_list struct { + list *[]*v1beta1.Coin +} + +func (x *_SendAuthzRules_1_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_SendAuthzRules_1_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfMessage((*x.list)[i].ProtoReflect()) +} + +func (x *_SendAuthzRules_1_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*v1beta1.Coin) + (*x.list)[i] = concreteValue +} + +func (x *_SendAuthzRules_1_list) Append(value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*v1beta1.Coin) + *x.list = append(*x.list, concreteValue) +} + +func (x *_SendAuthzRules_1_list) AppendMutable() protoreflect.Value { + v := new(v1beta1.Coin) + *x.list = append(*x.list, v) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_SendAuthzRules_1_list) Truncate(n int) { + for i := n; i < len(*x.list); i++ { + (*x.list)[i] = nil + } + *x.list = (*x.list)[:n] +} + +func (x *_SendAuthzRules_1_list) NewElement() protoreflect.Value { + v := new(v1beta1.Coin) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_SendAuthzRules_1_list) IsValid() bool { + return x.list != nil +} + +var _ protoreflect.List = (*_SendAuthzRules_2_list)(nil) + +type _SendAuthzRules_2_list struct { + list *[]string +} + +func (x *_SendAuthzRules_2_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_SendAuthzRules_2_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfString((*x.list)[i]) +} + +func (x *_SendAuthzRules_2_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.String() + concreteValue := valueUnwrapped + (*x.list)[i] = concreteValue +} + +func (x *_SendAuthzRules_2_list) Append(value protoreflect.Value) { + valueUnwrapped := value.String() + concreteValue := valueUnwrapped + *x.list = append(*x.list, concreteValue) +} + +func (x *_SendAuthzRules_2_list) AppendMutable() protoreflect.Value { + panic(fmt.Errorf("AppendMutable can not be called on message SendAuthzRules at list field BlockedRecipients as it is not of Message kind")) +} + +func (x *_SendAuthzRules_2_list) Truncate(n int) { + *x.list = (*x.list)[:n] +} + +func (x *_SendAuthzRules_2_list) NewElement() protoreflect.Value { + v := "" + return protoreflect.ValueOfString(v) +} + +func (x *_SendAuthzRules_2_list) IsValid() bool { + return x.list != nil +} + +var ( + md_SendAuthzRules protoreflect.MessageDescriptor + fd_SendAuthzRules_spend_limit protoreflect.FieldDescriptor + fd_SendAuthzRules_blocked_recipients protoreflect.FieldDescriptor +) + +func init() { + file_cosmos_authz_v1beta1_authz_proto_init() + md_SendAuthzRules = File_cosmos_authz_v1beta1_authz_proto.Messages().ByName("SendAuthzRules") + fd_SendAuthzRules_spend_limit = md_SendAuthzRules.Fields().ByName("spend_limit") + fd_SendAuthzRules_blocked_recipients = md_SendAuthzRules.Fields().ByName("blocked_recipients") +} + +var _ protoreflect.Message = (*fastReflection_SendAuthzRules)(nil) + +type fastReflection_SendAuthzRules SendAuthzRules + +func (x *SendAuthzRules) ProtoReflect() protoreflect.Message { + return (*fastReflection_SendAuthzRules)(x) +} + +func (x *SendAuthzRules) 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_SendAuthzRules_messageType fastReflection_SendAuthzRules_messageType +var _ protoreflect.MessageType = fastReflection_SendAuthzRules_messageType{} + +type fastReflection_SendAuthzRules_messageType struct{} + +func (x fastReflection_SendAuthzRules_messageType) Zero() protoreflect.Message { + return (*fastReflection_SendAuthzRules)(nil) +} +func (x fastReflection_SendAuthzRules_messageType) New() protoreflect.Message { + return new(fastReflection_SendAuthzRules) +} +func (x fastReflection_SendAuthzRules_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_SendAuthzRules +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_SendAuthzRules) Descriptor() protoreflect.MessageDescriptor { + return md_SendAuthzRules +} + +// 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_SendAuthzRules) Type() protoreflect.MessageType { + return _fastReflection_SendAuthzRules_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_SendAuthzRules) New() protoreflect.Message { + return new(fastReflection_SendAuthzRules) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_SendAuthzRules) Interface() protoreflect.ProtoMessage { + return (*SendAuthzRules)(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_SendAuthzRules) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if len(x.SpendLimit) != 0 { + value := protoreflect.ValueOfList(&_SendAuthzRules_1_list{list: &x.SpendLimit}) + if !f(fd_SendAuthzRules_spend_limit, value) { + return + } + } + if len(x.BlockedRecipients) != 0 { + value := protoreflect.ValueOfList(&_SendAuthzRules_2_list{list: &x.BlockedRecipients}) + if !f(fd_SendAuthzRules_blocked_recipients, 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_SendAuthzRules) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "cosmos.authz.v1beta1.SendAuthzRules.spend_limit": + return len(x.SpendLimit) != 0 + case "cosmos.authz.v1beta1.SendAuthzRules.blocked_recipients": + return len(x.BlockedRecipients) != 0 + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.SendAuthzRules")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.SendAuthzRules 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_SendAuthzRules) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "cosmos.authz.v1beta1.SendAuthzRules.spend_limit": + x.SpendLimit = nil + case "cosmos.authz.v1beta1.SendAuthzRules.blocked_recipients": + x.BlockedRecipients = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.SendAuthzRules")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.SendAuthzRules 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_SendAuthzRules) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "cosmos.authz.v1beta1.SendAuthzRules.spend_limit": + if len(x.SpendLimit) == 0 { + return protoreflect.ValueOfList(&_SendAuthzRules_1_list{}) + } + listValue := &_SendAuthzRules_1_list{list: &x.SpendLimit} + return protoreflect.ValueOfList(listValue) + case "cosmos.authz.v1beta1.SendAuthzRules.blocked_recipients": + if len(x.BlockedRecipients) == 0 { + return protoreflect.ValueOfList(&_SendAuthzRules_2_list{}) + } + listValue := &_SendAuthzRules_2_list{list: &x.BlockedRecipients} + return protoreflect.ValueOfList(listValue) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.SendAuthzRules")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.SendAuthzRules 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_SendAuthzRules) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "cosmos.authz.v1beta1.SendAuthzRules.spend_limit": + lv := value.List() + clv := lv.(*_SendAuthzRules_1_list) + x.SpendLimit = *clv.list + case "cosmos.authz.v1beta1.SendAuthzRules.blocked_recipients": + lv := value.List() + clv := lv.(*_SendAuthzRules_2_list) + x.BlockedRecipients = *clv.list + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.SendAuthzRules")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.SendAuthzRules 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_SendAuthzRules) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.authz.v1beta1.SendAuthzRules.spend_limit": + if x.SpendLimit == nil { + x.SpendLimit = []*v1beta1.Coin{} + } + value := &_SendAuthzRules_1_list{list: &x.SpendLimit} + return protoreflect.ValueOfList(value) + case "cosmos.authz.v1beta1.SendAuthzRules.blocked_recipients": + if x.BlockedRecipients == nil { + x.BlockedRecipients = []string{} + } + value := &_SendAuthzRules_2_list{list: &x.BlockedRecipients} + return protoreflect.ValueOfList(value) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.SendAuthzRules")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.SendAuthzRules 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_SendAuthzRules) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.authz.v1beta1.SendAuthzRules.spend_limit": + list := []*v1beta1.Coin{} + return protoreflect.ValueOfList(&_SendAuthzRules_1_list{list: &list}) + case "cosmos.authz.v1beta1.SendAuthzRules.blocked_recipients": + list := []string{} + return protoreflect.ValueOfList(&_SendAuthzRules_2_list{list: &list}) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.SendAuthzRules")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.SendAuthzRules 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_SendAuthzRules) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.authz.v1beta1.SendAuthzRules", 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_SendAuthzRules) 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_SendAuthzRules) 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_SendAuthzRules) 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_SendAuthzRules) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*SendAuthzRules) + 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.SpendLimit) > 0 { + for _, e := range x.SpendLimit { + l = options.Size(e) + n += 1 + l + runtime.Sov(uint64(l)) + } + } + if len(x.BlockedRecipients) > 0 { + for _, s := range x.BlockedRecipients { + 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().(*SendAuthzRules) + 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.BlockedRecipients) > 0 { + for iNdEx := len(x.BlockedRecipients) - 1; iNdEx >= 0; iNdEx-- { + i -= len(x.BlockedRecipients[iNdEx]) + copy(dAtA[i:], x.BlockedRecipients[iNdEx]) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.BlockedRecipients[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } + if len(x.SpendLimit) > 0 { + for iNdEx := len(x.SpendLimit) - 1; iNdEx >= 0; iNdEx-- { + encoded, err := options.Marshal(x.SpendLimit[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().(*SendAuthzRules) + 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: SendAuthzRules: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: SendAuthzRules: 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 SpendLimit", 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.SpendLimit = append(x.SpendLimit, &v1beta1.Coin{}) + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.SpendLimit[len(x.SpendLimit)-1]); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field BlockedRecipients", 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.BlockedRecipients = append(x.BlockedRecipients, 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 = (*_StakeAuthzRules_1_list)(nil) + +type _StakeAuthzRules_1_list struct { + list *[]string +} + +func (x *_StakeAuthzRules_1_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_StakeAuthzRules_1_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfString((*x.list)[i]) +} + +func (x *_StakeAuthzRules_1_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.String() + concreteValue := valueUnwrapped + (*x.list)[i] = concreteValue +} + +func (x *_StakeAuthzRules_1_list) Append(value protoreflect.Value) { + valueUnwrapped := value.String() + concreteValue := valueUnwrapped + *x.list = append(*x.list, concreteValue) +} + +func (x *_StakeAuthzRules_1_list) AppendMutable() protoreflect.Value { + panic(fmt.Errorf("AppendMutable can not be called on message StakeAuthzRules at list field BlockedValidators as it is not of Message kind")) +} + +func (x *_StakeAuthzRules_1_list) Truncate(n int) { + *x.list = (*x.list)[:n] +} + +func (x *_StakeAuthzRules_1_list) NewElement() protoreflect.Value { + v := "" + return protoreflect.ValueOfString(v) +} + +func (x *_StakeAuthzRules_1_list) IsValid() bool { + return x.list != nil +} + +var ( + md_StakeAuthzRules protoreflect.MessageDescriptor + fd_StakeAuthzRules_blocked_validators protoreflect.FieldDescriptor +) + +func init() { + file_cosmos_authz_v1beta1_authz_proto_init() + md_StakeAuthzRules = File_cosmos_authz_v1beta1_authz_proto.Messages().ByName("StakeAuthzRules") + fd_StakeAuthzRules_blocked_validators = md_StakeAuthzRules.Fields().ByName("blocked_validators") +} + +var _ protoreflect.Message = (*fastReflection_StakeAuthzRules)(nil) + +type fastReflection_StakeAuthzRules StakeAuthzRules + +func (x *StakeAuthzRules) ProtoReflect() protoreflect.Message { + return (*fastReflection_StakeAuthzRules)(x) +} + +func (x *StakeAuthzRules) 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 { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_StakeAuthzRules_messageType fastReflection_StakeAuthzRules_messageType +var _ protoreflect.MessageType = fastReflection_StakeAuthzRules_messageType{} + +type fastReflection_StakeAuthzRules_messageType struct{} + +func (x fastReflection_StakeAuthzRules_messageType) Zero() protoreflect.Message { + return (*fastReflection_StakeAuthzRules)(nil) +} +func (x fastReflection_StakeAuthzRules_messageType) New() protoreflect.Message { + return new(fastReflection_StakeAuthzRules) +} +func (x fastReflection_StakeAuthzRules_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_StakeAuthzRules +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_StakeAuthzRules) Descriptor() protoreflect.MessageDescriptor { + return md_StakeAuthzRules +} + +// 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_StakeAuthzRules) Type() protoreflect.MessageType { + return _fastReflection_StakeAuthzRules_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_StakeAuthzRules) New() protoreflect.Message { + return new(fastReflection_StakeAuthzRules) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_StakeAuthzRules) Interface() protoreflect.ProtoMessage { + return (*StakeAuthzRules)(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_StakeAuthzRules) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if len(x.BlockedValidators) != 0 { + value := protoreflect.ValueOfList(&_StakeAuthzRules_1_list{list: &x.BlockedValidators}) + if !f(fd_StakeAuthzRules_blocked_validators, 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_StakeAuthzRules) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "cosmos.authz.v1beta1.StakeAuthzRules.blocked_validators": + return len(x.BlockedValidators) != 0 + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.StakeAuthzRules")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.StakeAuthzRules 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_StakeAuthzRules) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "cosmos.authz.v1beta1.StakeAuthzRules.blocked_validators": + x.BlockedValidators = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.StakeAuthzRules")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.StakeAuthzRules 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_StakeAuthzRules) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "cosmos.authz.v1beta1.StakeAuthzRules.blocked_validators": + if len(x.BlockedValidators) == 0 { + return protoreflect.ValueOfList(&_StakeAuthzRules_1_list{}) + } + listValue := &_StakeAuthzRules_1_list{list: &x.BlockedValidators} + return protoreflect.ValueOfList(listValue) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.StakeAuthzRules")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.StakeAuthzRules 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_StakeAuthzRules) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "cosmos.authz.v1beta1.StakeAuthzRules.blocked_validators": + lv := value.List() + clv := lv.(*_StakeAuthzRules_1_list) + x.BlockedValidators = *clv.list + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.StakeAuthzRules")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.StakeAuthzRules 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_StakeAuthzRules) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.authz.v1beta1.StakeAuthzRules.blocked_validators": + if x.BlockedValidators == nil { + x.BlockedValidators = []string{} + } + value := &_StakeAuthzRules_1_list{list: &x.BlockedValidators} + return protoreflect.ValueOfList(value) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.StakeAuthzRules")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.StakeAuthzRules 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_StakeAuthzRules) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.authz.v1beta1.StakeAuthzRules.blocked_validators": + list := []string{} + return protoreflect.ValueOfList(&_StakeAuthzRules_1_list{list: &list}) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.StakeAuthzRules")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.StakeAuthzRules 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_StakeAuthzRules) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.authz.v1beta1.StakeAuthzRules", 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_StakeAuthzRules) 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_StakeAuthzRules) 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_StakeAuthzRules) 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_StakeAuthzRules) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*StakeAuthzRules) + 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.BlockedValidators) > 0 { + for _, s := range x.BlockedValidators { + 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().(*StakeAuthzRules) + 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.BlockedValidators) > 0 { + for iNdEx := len(x.BlockedValidators) - 1; iNdEx >= 0; iNdEx-- { + i -= len(x.BlockedValidators[iNdEx]) + copy(dAtA[i:], x.BlockedValidators[iNdEx]) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.BlockedValidators[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().(*StakeAuthzRules) + 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: StakeAuthzRules: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: StakeAuthzRules: 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 BlockedValidators", 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.BlockedValidators = append(x.BlockedValidators, 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, + } +} + // Since: cosmos-sdk 0.43 // Code generated by protoc-gen-go. DO NOT EDIT. @@ -2272,6 +3885,132 @@ func (x *GrantQueueItem) GetMsgTypeUrls() []string { return nil } +// AuthzRules defines the rules for authz messages. +type AuthzRules struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Send authz rules + Send *SendAuthzRules `protobuf:"bytes,1,opt,name=send,proto3" json:"send,omitempty"` + // Stake authz rules + Stake *StakeAuthzRules `protobuf:"bytes,2,opt,name=stake,proto3" json:"stake,omitempty"` +} + +func (x *AuthzRules) Reset() { + *x = AuthzRules{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_authz_v1beta1_authz_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AuthzRules) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AuthzRules) ProtoMessage() {} + +// Deprecated: Use AuthzRules.ProtoReflect.Descriptor instead. +func (*AuthzRules) Descriptor() ([]byte, []int) { + return file_cosmos_authz_v1beta1_authz_proto_rawDescGZIP(), []int{4} +} + +func (x *AuthzRules) GetSend() *SendAuthzRules { + if x != nil { + return x.Send + } + return nil +} + +func (x *AuthzRules) GetStake() *StakeAuthzRules { + if x != nil { + return x.Stake + } + return nil +} + +// Send authz rules +type SendAuthzRules struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + SpendLimit []*v1beta1.Coin `protobuf:"bytes,1,rep,name=spend_limit,json=spendLimit,proto3" json:"spend_limit,omitempty"` + BlockedRecipients []string `protobuf:"bytes,2,rep,name=blocked_recipients,json=blockedRecipients,proto3" json:"blocked_recipients,omitempty"` +} + +func (x *SendAuthzRules) Reset() { + *x = SendAuthzRules{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_authz_v1beta1_authz_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SendAuthzRules) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SendAuthzRules) ProtoMessage() {} + +// Deprecated: Use SendAuthzRules.ProtoReflect.Descriptor instead. +func (*SendAuthzRules) Descriptor() ([]byte, []int) { + return file_cosmos_authz_v1beta1_authz_proto_rawDescGZIP(), []int{5} +} + +func (x *SendAuthzRules) GetSpendLimit() []*v1beta1.Coin { + if x != nil { + return x.SpendLimit + } + return nil +} + +func (x *SendAuthzRules) GetBlockedRecipients() []string { + if x != nil { + return x.BlockedRecipients + } + return nil +} + +// Stake authz rules +type StakeAuthzRules struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + BlockedValidators []string `protobuf:"bytes,1,rep,name=blocked_validators,json=blockedValidators,proto3" json:"blocked_validators,omitempty"` +} + +func (x *StakeAuthzRules) Reset() { + *x = StakeAuthzRules{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_authz_v1beta1_authz_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *StakeAuthzRules) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StakeAuthzRules) ProtoMessage() {} + +// Deprecated: Use StakeAuthzRules.ProtoReflect.Descriptor instead. +func (*StakeAuthzRules) Descriptor() ([]byte, []int) { + return file_cosmos_authz_v1beta1_authz_proto_rawDescGZIP(), []int{6} +} + +func (x *StakeAuthzRules) GetBlockedValidators() []string { + if x != nil { + return x.BlockedValidators + } + return nil +} + var File_cosmos_authz_v1beta1_authz_proto protoreflect.FileDescriptor var file_cosmos_authz_v1beta1_authz_proto_rawDesc = []byte{ @@ -2286,7 +4025,9 @@ var file_cosmos_authz_v1beta1_authz_proto_rawDesc = []byte{ 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x14, 0x67, 0x6f, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x67, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, - 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x74, 0x0a, 0x14, 0x47, 0x65, 0x6e, 0x65, + 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x63, 0x6f, + 0x69, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x74, 0x0a, 0x14, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x69, 0x63, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x3a, 0x4a, 0xca, 0xb4, 0x2d, 0x22, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, @@ -2326,21 +4067,47 @@ var file_cosmos_authz_v1beta1_authz_proto_rawDesc = []byte{ 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, + 0x52, 0x0b, 0x6d, 0x73, 0x67, 0x54, 0x79, 0x70, 0x65, 0x55, 0x72, 0x6c, 0x73, 0x22, 0x8f, 0x01, + 0x0a, 0x0a, 0x41, 0x75, 0x74, 0x68, 0x7a, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x3e, 0x0a, 0x04, + 0x73, 0x65, 0x6e, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, + 0x31, 0x2e, 0x53, 0x65, 0x6e, 0x64, 0x41, 0x75, 0x74, 0x68, 0x7a, 0x52, 0x75, 0x6c, 0x65, 0x73, + 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x04, 0x73, 0x65, 0x6e, 0x64, 0x12, 0x41, 0x0a, 0x05, + 0x73, 0x74, 0x61, 0x6b, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, + 0x61, 0x31, 0x2e, 0x53, 0x74, 0x61, 0x6b, 0x65, 0x41, 0x75, 0x74, 0x68, 0x7a, 0x52, 0x75, 0x6c, + 0x65, 0x73, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x05, 0x73, 0x74, 0x61, 0x6b, 0x65, 0x22, + 0xc4, 0x01, 0x0a, 0x0e, 0x53, 0x65, 0x6e, 0x64, 0x41, 0x75, 0x74, 0x68, 0x7a, 0x52, 0x75, 0x6c, + 0x65, 0x73, 0x12, 0x82, 0x01, 0x0a, 0x0b, 0x73, 0x70, 0x65, 0x6e, 0x64, 0x5f, 0x6c, 0x69, 0x6d, + 0x69, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, + 0x6f, 0x69, 0x6e, 0x42, 0x46, 0xc8, 0xde, 0x1f, 0x00, 0xaa, 0xdf, 0x1f, 0x28, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, + 0x43, 0x6f, 0x69, 0x6e, 0x73, 0x9a, 0xe7, 0xb0, 0x2a, 0x0c, 0x6c, 0x65, 0x67, 0x61, 0x63, 0x79, + 0x5f, 0x63, 0x6f, 0x69, 0x6e, 0x73, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x0a, 0x73, 0x70, 0x65, + 0x6e, 0x64, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x2d, 0x0a, 0x12, 0x62, 0x6c, 0x6f, 0x63, 0x6b, + 0x65, 0x64, 0x5f, 0x72, 0x65, 0x63, 0x69, 0x70, 0x69, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x02, 0x20, + 0x03, 0x28, 0x09, 0x52, 0x11, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x65, 0x64, 0x52, 0x65, 0x63, 0x69, + 0x70, 0x69, 0x65, 0x6e, 0x74, 0x73, 0x22, 0x40, 0x0a, 0x0f, 0x53, 0x74, 0x61, 0x6b, 0x65, 0x41, + 0x75, 0x74, 0x68, 0x7a, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x2d, 0x0a, 0x12, 0x62, 0x6c, 0x6f, + 0x63, 0x6b, 0x65, 0x64, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x18, + 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x11, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x65, 0x64, 0x56, 0x61, + 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 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 +4122,32 @@ 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 + (*AuthzRules)(nil), // 4: cosmos.authz.v1beta1.AuthzRules + (*SendAuthzRules)(nil), // 5: cosmos.authz.v1beta1.SendAuthzRules + (*StakeAuthzRules)(nil), // 6: cosmos.authz.v1beta1.StakeAuthzRules + (*anypb.Any)(nil), // 7: google.protobuf.Any + (*timestamppb.Timestamp)(nil), // 8: google.protobuf.Timestamp + (*v1beta1.Coin)(nil), // 9: cosmos.base.v1beta1.Coin } 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 + 7, // 2: cosmos.authz.v1beta1.GrantAuthorization.authorization:type_name -> google.protobuf.Any + 8, // 3: cosmos.authz.v1beta1.GrantAuthorization.expiration:type_name -> google.protobuf.Timestamp + 5, // 4: cosmos.authz.v1beta1.AuthzRules.send:type_name -> cosmos.authz.v1beta1.SendAuthzRules + 6, // 5: cosmos.authz.v1beta1.AuthzRules.stake:type_name -> cosmos.authz.v1beta1.StakeAuthzRules + 9, // 6: cosmos.authz.v1beta1.SendAuthzRules.spend_limit:type_name -> cosmos.base.v1beta1.Coin + 7, // [7:7] is the sub-list for method output_type + 7, // [7:7] is the sub-list for method input_type + 7, // [7:7] is the sub-list for extension type_name + 7, // [7:7] is the sub-list for extension extendee + 0, // [0:7] is the sub-list for field type_name } func init() { file_cosmos_authz_v1beta1_authz_proto_init() } @@ -2430,6 +4204,42 @@ func file_cosmos_authz_v1beta1_authz_proto_init() { return nil } } + file_cosmos_authz_v1beta1_authz_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AuthzRules); 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[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SendAuthzRules); 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.(*StakeAuthzRules); 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 +4247,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/proto/cosmos/authz/v1beta1/authz.proto b/proto/cosmos/authz/v1beta1/authz.proto index 3fee7364365c..b9004f48e16e 100644 --- a/proto/cosmos/authz/v1beta1/authz.proto +++ b/proto/cosmos/authz/v1beta1/authz.proto @@ -7,6 +7,7 @@ import "cosmos_proto/cosmos.proto"; import "google/protobuf/timestamp.proto"; import "gogoproto/gogo.proto"; import "google/protobuf/any.proto"; +import "cosmos/base/v1beta1/coin.proto"; option go_package = "github.com/cosmos/cosmos-sdk/x/authz"; option (gogoproto.goproto_getters_all) = false; @@ -46,3 +47,28 @@ message GrantQueueItem { // msg_type_urls contains the list of TypeURL of a sdk.Msg. repeated string msg_type_urls = 1; } + +// AuthzRules defines the rules for authz messages. +message AuthzRules { + // Send authz rules + SendAuthzRules send = 1 [(gogoproto.nullable) = false]; + + // Stake authz rules + StakeAuthzRules stake = 2 [(gogoproto.nullable) = false]; +} + +// Send authz rules +message SendAuthzRules { + repeated cosmos.base.v1beta1.Coin spend_limit = 1 [ + (gogoproto.nullable) = false, + (amino.dont_omitempty) = true, + (amino.encoding) = "legacy_coins", + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; + repeated string blocked_recipients = 2; +} + +// Stake authz rules +message StakeAuthzRules { + repeated string blocked_validators = 1; +} diff --git a/simapp/authz_rules.go b/simapp/authz_rules.go new file mode 100644 index 000000000000..e37ebb565f05 --- /dev/null +++ b/simapp/authz_rules.go @@ -0,0 +1,13 @@ +package simapp + +import ( + "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/authz" +) + +var rules = authz.AuthzRules{ + Send: authz.SendAuthzRules{ + SpendLimit: types.NewCoins(types.NewInt64Coin(types.DefaultBondDenom, 1000)), + BlockedRecipients: []string{"cosmos1rnr5jrt4exl0samwj0yegv99jeskl0hsge5zwt", "cosmos12g43c03a4p076valkrpalw7u4nxndv97qp5xf7"}, + }, +} diff --git a/x/auth/ante/authz_rules.go b/x/auth/ante/authz_rules_ante.go similarity index 55% rename from x/auth/ante/authz_rules.go rename to x/auth/ante/authz_rules_ante.go index 969961b89dc8..841257f8d2db 100644 --- a/x/auth/ante/authz_rules.go +++ b/x/auth/ante/authz_rules_ante.go @@ -9,11 +9,11 @@ import ( ) type AuthzDecorator struct { - _ AuthzKeeper + azk AuthzKeeper } // AuthzDecorator checks the authorization message grants for some rules. -func (az AuthzDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) { +func (azd AuthzDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) { msgs := tx.GetMsgs() for _, msg := range msgs { // Check if the message is an authorization message @@ -26,7 +26,12 @@ func (az AuthzDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, n switch authzConverted := authz.(type) { case *banktypes.SendAuthorization: - if checkSendAuthzRulesVoilated(authzConverted) { + rules, err := azd.azk.GetAuthzRules(ctx) + if err != nil { + return ctx, err + } + + if checkSendAuthzRulesVoilated(authzMsg, authzConverted, rules.Send) { return ctx, fmt.Errorf("authz rules are not meeting") } @@ -40,7 +45,16 @@ func (az AuthzDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, n return next(ctx, tx, simulate) } -func checkSendAuthzRulesVoilated(authz *banktypes.SendAuthorization) bool { - // more rules can be added here. - return authz.SpendLimit.IsAllGT(sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 1000))) +func checkSendAuthzRulesVoilated(msgGrant *authztypes.MsgGrant, authz *banktypes.SendAuthorization, sendAuthzRules authztypes.SendAuthzRules) bool { + if authz.SpendLimit.IsAllGT(sendAuthzRules.SpendLimit) { + return true + } + + for _, blockedRecipient := range sendAuthzRules.BlockedRecipients { + if msgGrant.Grantee == blockedRecipient { + return true + } + } + + return false } diff --git a/x/auth/ante/expected_keepers.go b/x/auth/ante/expected_keepers.go index 7f99af55dd0b..051843fdc5a2 100644 --- a/x/auth/ante/expected_keepers.go +++ b/x/auth/ante/expected_keepers.go @@ -7,6 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/cosmos/cosmos-sdk/x/authz" ) // AccountKeeper defines the contract needed for AccountKeeper related APIs. @@ -25,4 +26,5 @@ type FeegrantKeeper interface { } type AuthzKeeper interface { + GetAuthzRules(ctx context.Context) (authz.AuthzRules, error) } diff --git a/x/authz/authz.pb.go b/x/authz/authz.pb.go index 2b5bf359cb9f..9c51e6ae0f4d 100644 --- a/x/authz/authz.pb.go +++ b/x/authz/authz.pb.go @@ -7,6 +7,8 @@ import ( fmt "fmt" _ "github.com/cosmos/cosmos-proto" types "github.com/cosmos/cosmos-sdk/codec/types" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types1 "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/cosmos-sdk/types/tx/amino" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" @@ -194,45 +196,178 @@ func (m *GrantQueueItem) XXX_DiscardUnknown() { var xxx_messageInfo_GrantQueueItem proto.InternalMessageInfo +// AuthzRules defines the rules for authz messages. +type AuthzRules struct { + // Send authz rules + Send SendAuthzRules `protobuf:"bytes,1,opt,name=send,proto3" json:"send"` + // Stake authz rules + Stake StakeAuthzRules `protobuf:"bytes,2,opt,name=stake,proto3" json:"stake"` +} + +func (m *AuthzRules) Reset() { *m = AuthzRules{} } +func (m *AuthzRules) String() string { return proto.CompactTextString(m) } +func (*AuthzRules) ProtoMessage() {} +func (*AuthzRules) Descriptor() ([]byte, []int) { + return fileDescriptor_544dc2e84b61c637, []int{4} +} +func (m *AuthzRules) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AuthzRules) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AuthzRules.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 *AuthzRules) XXX_Merge(src proto.Message) { + xxx_messageInfo_AuthzRules.Merge(m, src) +} +func (m *AuthzRules) XXX_Size() int { + return m.Size() +} +func (m *AuthzRules) XXX_DiscardUnknown() { + xxx_messageInfo_AuthzRules.DiscardUnknown(m) +} + +var xxx_messageInfo_AuthzRules proto.InternalMessageInfo + +// Send authz rules +type SendAuthzRules struct { + SpendLimit github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=spend_limit,json=spendLimit,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"spend_limit"` + BlockedRecipients []string `protobuf:"bytes,2,rep,name=blocked_recipients,json=blockedRecipients,proto3" json:"blocked_recipients,omitempty"` +} + +func (m *SendAuthzRules) Reset() { *m = SendAuthzRules{} } +func (m *SendAuthzRules) String() string { return proto.CompactTextString(m) } +func (*SendAuthzRules) ProtoMessage() {} +func (*SendAuthzRules) Descriptor() ([]byte, []int) { + return fileDescriptor_544dc2e84b61c637, []int{5} +} +func (m *SendAuthzRules) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SendAuthzRules) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SendAuthzRules.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 *SendAuthzRules) XXX_Merge(src proto.Message) { + xxx_messageInfo_SendAuthzRules.Merge(m, src) +} +func (m *SendAuthzRules) XXX_Size() int { + return m.Size() +} +func (m *SendAuthzRules) XXX_DiscardUnknown() { + xxx_messageInfo_SendAuthzRules.DiscardUnknown(m) +} + +var xxx_messageInfo_SendAuthzRules proto.InternalMessageInfo + +// Stake authz rules +type StakeAuthzRules struct { + BlockedValidators []string `protobuf:"bytes,1,rep,name=blocked_validators,json=blockedValidators,proto3" json:"blocked_validators,omitempty"` +} + +func (m *StakeAuthzRules) Reset() { *m = StakeAuthzRules{} } +func (m *StakeAuthzRules) String() string { return proto.CompactTextString(m) } +func (*StakeAuthzRules) ProtoMessage() {} +func (*StakeAuthzRules) Descriptor() ([]byte, []int) { + return fileDescriptor_544dc2e84b61c637, []int{6} +} +func (m *StakeAuthzRules) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StakeAuthzRules) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_StakeAuthzRules.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 *StakeAuthzRules) XXX_Merge(src proto.Message) { + xxx_messageInfo_StakeAuthzRules.Merge(m, src) +} +func (m *StakeAuthzRules) XXX_Size() int { + return m.Size() +} +func (m *StakeAuthzRules) XXX_DiscardUnknown() { + xxx_messageInfo_StakeAuthzRules.DiscardUnknown(m) +} + +var xxx_messageInfo_StakeAuthzRules proto.InternalMessageInfo + func init() { proto.RegisterType((*GenericAuthorization)(nil), "cosmos.authz.v1beta1.GenericAuthorization") proto.RegisterType((*Grant)(nil), "cosmos.authz.v1beta1.Grant") proto.RegisterType((*GrantAuthorization)(nil), "cosmos.authz.v1beta1.GrantAuthorization") proto.RegisterType((*GrantQueueItem)(nil), "cosmos.authz.v1beta1.GrantQueueItem") + proto.RegisterType((*AuthzRules)(nil), "cosmos.authz.v1beta1.AuthzRules") + proto.RegisterType((*SendAuthzRules)(nil), "cosmos.authz.v1beta1.SendAuthzRules") + proto.RegisterType((*StakeAuthzRules)(nil), "cosmos.authz.v1beta1.StakeAuthzRules") } 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, + // 637 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0x41, 0x4f, 0xd4, 0x40, + 0x14, 0xde, 0xc2, 0xa2, 0x32, 0x2b, 0x28, 0xcd, 0x1e, 0x16, 0x0e, 0x5d, 0xd2, 0xa0, 0x21, 0x24, + 0xdb, 0x06, 0xf4, 0xe4, 0xc1, 0xb0, 0xd5, 0x48, 0x34, 0x5e, 0x2c, 0xe8, 0xc1, 0xcb, 0x66, 0xda, + 0x3e, 0xcb, 0x84, 0x76, 0xa6, 0xe9, 0x4c, 0x09, 0xcb, 0xd1, 0xa3, 0x17, 0x39, 0x7b, 0xf4, 0x64, + 0x3c, 0x61, 0xc2, 0x4f, 0xf0, 0xb0, 0xf1, 0x44, 0x3c, 0x79, 0x02, 0x85, 0x03, 0x7f, 0xc3, 0x74, + 0xa6, 0x5d, 0x76, 0x59, 0x54, 0x0e, 0x5e, 0x9a, 0x99, 0x79, 0xdf, 0xf7, 0xbd, 0xf7, 0xbe, 0x99, + 0x57, 0x34, 0xef, 0x33, 0x1e, 0x33, 0x6e, 0xe3, 0x4c, 0x6c, 0xee, 0xda, 0xdb, 0xcb, 0x1e, 0x08, + 0xbc, 0xac, 0x76, 0x56, 0x92, 0x32, 0xc1, 0xf4, 0xba, 0x42, 0x58, 0xea, 0xac, 0x40, 0xcc, 0xcd, + 0xe0, 0x98, 0x50, 0x66, 0xcb, 0xaf, 0x02, 0xce, 0xcd, 0x2a, 0x60, 0x47, 0xee, 0xec, 0x82, 0xa5, + 0x42, 0xcd, 0x90, 0xb1, 0x30, 0x02, 0x5b, 0xee, 0xbc, 0xec, 0x8d, 0x2d, 0x48, 0x0c, 0x5c, 0xe0, + 0x38, 0x29, 0x00, 0xf5, 0x90, 0x85, 0x4c, 0x11, 0xf3, 0x55, 0xa9, 0x78, 0x91, 0x86, 0x69, 0xb7, + 0x08, 0x19, 0x45, 0xdd, 0x1e, 0xe6, 0xd0, 0x2f, 0xdb, 0x67, 0x84, 0xaa, 0xb8, 0x29, 0x50, 0x7d, + 0x0d, 0x28, 0xa4, 0xc4, 0x6f, 0x67, 0x62, 0x93, 0xa5, 0x64, 0x17, 0x0b, 0xc2, 0xa8, 0x7e, 0x1b, + 0x8d, 0xc7, 0x3c, 0x6c, 0x68, 0xf3, 0xda, 0xe2, 0xa4, 0x9b, 0x2f, 0x1f, 0x3c, 0xfb, 0x76, 0xd0, + 0x32, 0x2f, 0xeb, 0xd1, 0x1a, 0x62, 0xbe, 0x3b, 0xdb, 0x5f, 0x6a, 0x2a, 0x58, 0x8b, 0x07, 0x5b, + 0xf6, 0x65, 0xea, 0xe6, 0x17, 0x0d, 0x4d, 0xac, 0xa5, 0x98, 0x0a, 0xdd, 0x43, 0x53, 0x78, 0x30, + 0x24, 0x33, 0xd6, 0x56, 0xea, 0x96, 0x6a, 0xc9, 0x2a, 0x5b, 0xb2, 0xda, 0xb4, 0xeb, 0xdc, 0xbd, + 0x5a, 0x09, 0xee, 0xb0, 0xa4, 0xfe, 0x18, 0x21, 0xd8, 0x49, 0x48, 0xaa, 0x12, 0x8c, 0xc9, 0x04, + 0x73, 0x23, 0x09, 0x36, 0x4a, 0xab, 0x9d, 0x1b, 0xbd, 0xa3, 0xa6, 0xb6, 0x77, 0xdc, 0xd4, 0xdc, + 0x01, 0x9e, 0xf9, 0x71, 0x0c, 0xe9, 0xb2, 0xe6, 0x61, 0xa3, 0x56, 0xd0, 0xf5, 0x30, 0x3f, 0x85, + 0x54, 0x99, 0xe5, 0x34, 0xbe, 0x1f, 0xb4, 0xca, 0xb7, 0xd0, 0x0e, 0x82, 0x14, 0x38, 0x5f, 0x17, + 0x29, 0xa1, 0xa1, 0x5b, 0x02, 0xcf, 0x39, 0x20, 0xab, 0xb9, 0x02, 0x07, 0x46, 0x8d, 0x1a, 0xff, + 0xff, 0x46, 0xad, 0x0e, 0x19, 0x55, 0xfd, 0xa7, 0x51, 0xd5, 0x11, 0x93, 0xee, 0xa3, 0x69, 0xe9, + 0xd1, 0x8b, 0x0c, 0x32, 0x78, 0x2a, 0x20, 0xd6, 0x4d, 0x34, 0x15, 0xf3, 0xb0, 0x23, 0xba, 0x09, + 0x74, 0xb2, 0x34, 0xe2, 0x0d, 0x6d, 0x7e, 0x7c, 0x71, 0xd2, 0xad, 0xc5, 0x3c, 0xdc, 0xe8, 0x26, + 0xf0, 0x32, 0x8d, 0xb8, 0xf9, 0x5e, 0x43, 0x28, 0x2f, 0x6c, 0xd7, 0xcd, 0x22, 0xe0, 0xfa, 0x43, + 0x54, 0xe5, 0x40, 0x83, 0xe2, 0x29, 0x2c, 0x58, 0x97, 0x36, 0xb2, 0x0e, 0x34, 0x38, 0xe7, 0x38, + 0xd5, 0xde, 0x51, 0xb3, 0xe2, 0x4a, 0x9e, 0xde, 0x46, 0x13, 0x5c, 0xe0, 0x2d, 0x28, 0xae, 0xfa, + 0xce, 0x1f, 0x04, 0x72, 0xc8, 0x88, 0x82, 0x62, 0x9a, 0x5f, 0x35, 0x34, 0x3d, 0x9c, 0x41, 0x7f, + 0xab, 0xa1, 0x1a, 0x4f, 0x80, 0x06, 0x9d, 0x88, 0xc4, 0x44, 0xc8, 0x3e, 0x6a, 0x2b, 0xb3, 0xa5, + 0x78, 0x3e, 0x60, 0x7d, 0xed, 0x47, 0x8c, 0x50, 0xe7, 0x49, 0x2e, 0xf8, 0xf9, 0xb8, 0xb9, 0x18, + 0x12, 0xb1, 0x99, 0x79, 0x96, 0xcf, 0xe2, 0x62, 0xda, 0xed, 0x81, 0xf9, 0xc8, 0x8d, 0xe1, 0x92, + 0xc0, 0x3f, 0x9c, 0xed, 0x2f, 0xdd, 0x8c, 0x20, 0xc4, 0x7e, 0xb7, 0x93, 0x8f, 0x28, 0xff, 0x74, + 0xb6, 0xbf, 0xa4, 0xb9, 0x48, 0x66, 0x7d, 0x9e, 0x27, 0xd5, 0x5b, 0x48, 0xf7, 0x22, 0xe6, 0x6f, + 0x41, 0xd0, 0x49, 0xc1, 0x27, 0x09, 0x01, 0x2a, 0x78, 0x63, 0x4c, 0x5a, 0x3a, 0x53, 0x44, 0xdc, + 0x7e, 0xc0, 0x5c, 0x45, 0xb7, 0x2e, 0xb4, 0x39, 0xa8, 0xb0, 0x8d, 0x23, 0x12, 0x60, 0xc1, 0xd2, + 0xf2, 0x52, 0x4a, 0x85, 0x57, 0xfd, 0x80, 0xe3, 0xf4, 0x7e, 0x19, 0x95, 0xde, 0x89, 0xa1, 0x1d, + 0x9e, 0x18, 0xda, 0xcf, 0x13, 0x43, 0xdb, 0x3b, 0x35, 0x2a, 0x87, 0xa7, 0x46, 0xe5, 0xc7, 0xa9, + 0x51, 0x79, 0xbd, 0xf0, 0xd7, 0xd6, 0x76, 0xd4, 0xff, 0xd1, 0xbb, 0x26, 0x9f, 0xce, 0xbd, 0xdf, + 0x01, 0x00, 0x00, 0xff, 0xff, 0x6f, 0xc7, 0x8f, 0x62, 0x44, 0x05, 0x00, 0x00, } func (m *GenericAuthorization) Marshal() (dAtA []byte, err error) { @@ -401,6 +536,127 @@ func (m *GrantQueueItem) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *AuthzRules) 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 *AuthzRules) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AuthzRules) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Stake.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintAuthz(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size, err := m.Send.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 *SendAuthzRules) 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 *SendAuthzRules) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SendAuthzRules) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.BlockedRecipients) > 0 { + for iNdEx := len(m.BlockedRecipients) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.BlockedRecipients[iNdEx]) + copy(dAtA[i:], m.BlockedRecipients[iNdEx]) + i = encodeVarintAuthz(dAtA, i, uint64(len(m.BlockedRecipients[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } + if len(m.SpendLimit) > 0 { + for iNdEx := len(m.SpendLimit) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.SpendLimit[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 *StakeAuthzRules) 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 *StakeAuthzRules) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StakeAuthzRules) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.BlockedValidators) > 0 { + for iNdEx := len(m.BlockedValidators) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.BlockedValidators[iNdEx]) + copy(dAtA[i:], m.BlockedValidators[iNdEx]) + i = encodeVarintAuthz(dAtA, i, uint64(len(m.BlockedValidators[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func encodeVarintAuthz(dAtA []byte, offset int, v uint64) int { offset -= sovAuthz(v) base := offset @@ -482,6 +738,55 @@ func (m *GrantQueueItem) Size() (n int) { return n } +func (m *AuthzRules) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Send.Size() + n += 1 + l + sovAuthz(uint64(l)) + l = m.Stake.Size() + n += 1 + l + sovAuthz(uint64(l)) + return n +} + +func (m *SendAuthzRules) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.SpendLimit) > 0 { + for _, e := range m.SpendLimit { + l = e.Size() + n += 1 + l + sovAuthz(uint64(l)) + } + } + if len(m.BlockedRecipients) > 0 { + for _, s := range m.BlockedRecipients { + l = len(s) + n += 1 + l + sovAuthz(uint64(l)) + } + } + return n +} + +func (m *StakeAuthzRules) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.BlockedValidators) > 0 { + for _, s := range m.BlockedValidators { + 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 } @@ -960,6 +1265,320 @@ func (m *GrantQueueItem) Unmarshal(dAtA []byte) error { } return nil } +func (m *AuthzRules) 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: AuthzRules: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AuthzRules: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Send", 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 + } + if err := m.Send.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Stake", 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 + } + if err := m.Stake.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 *SendAuthzRules) 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: SendAuthzRules: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SendAuthzRules: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SpendLimit", 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.SpendLimit = append(m.SpendLimit, types1.Coin{}) + if err := m.SpendLimit[len(m.SpendLimit)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockedRecipients", 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.BlockedRecipients = append(m.BlockedRecipients, 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 (m *StakeAuthzRules) 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: StakeAuthzRules: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StakeAuthzRules: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockedValidators", 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.BlockedValidators = append(m.BlockedValidators, 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/keeper/keeper.go b/x/authz/keeper/keeper.go index c7dc7dec5421..12628a9da486 100644 --- a/x/authz/keeper/keeper.go +++ b/x/authz/keeper/keeper.go @@ -68,6 +68,38 @@ func (k Keeper) getGrant(ctx context.Context, skey []byte) (grant authz.Grant, f return grant, true } +func (k Keeper) GetAuthzRules(ctx context.Context) (authz.AuthzRules, error) { + store := k.storeService.OpenKVStore(ctx) + + bz, err := store.Get(AuthzRulesPrefix) + if err != nil { + return authz.AuthzRules{}, err + } + + if bz == nil { + return authz.AuthzRules{}, sdkerrors.ErrNotFound.Wrap("nil value") + } + + var authzRules authz.AuthzRules + err = k.cdc.Unmarshal(bz, &authzRules) + if err != nil { + return authz.AuthzRules{}, err + } + + return authzRules, nil +} + +func (k Keeper) SetAuthzRules(ctx context.Context, rules authz.AuthzRules) error { + store := k.storeService.OpenKVStore(ctx) + + bz, err := k.cdc.Marshal(&rules) + if err != nil { + return err + } + + return store.Set(AuthzRulesPrefix, bz) +} + func (k Keeper) update(ctx context.Context, grantee, granter sdk.AccAddress, updated authz.Authorization) error { skey := grantStoreKey(grantee, granter, updated.MsgTypeURL()) grant, found := k.getGrant(ctx, skey) diff --git a/x/authz/keeper/keys.go b/x/authz/keeper/keys.go index 83eabef777e7..a1e3d15ad684 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} + AuthzRulesPrefix = []byte{0x03} ) var lenTime = len(sdk.FormatTimeBytes(time.Now())) @@ -97,3 +98,8 @@ func firstAddressFromGrantStoreKey(key []byte) sdk.AccAddress { addrLen := key[0] return sdk.AccAddress(key[1 : 1+addrLen]) } + +// func BuildAuthzRulesKey(grantName string) []byte { +// g := conv.UnsafeStrToBytes(grantName) +// return append(AuthzRulesPrefix, g...) +// } From dbdd25cf80d3e16cab21ea398f09cd9b4ac6e750 Mon Sep 17 00:00:00 2001 From: atheesh Date: Mon, 29 Apr 2024 12:10:20 +0530 Subject: [PATCH 06/30] added generic authz --- api/cosmos/authz/v1beta1/authz.pulsar.go | 732 +++++++++++++++++++++-- proto/cosmos/authz/v1beta1/authz.proto | 8 + simapp/ante.go | 1 + simapp/app.go | 4 +- simapp/app_v2.go | 2 +- x/auth/ante/ante.go | 1 + x/auth/ante/authz_rules_ante.go | 36 +- x/authz/authz.pb.go | 300 ++++++++-- x/authz/errors.go | 2 + x/authz/keeper/keeper.go | 18 +- 10 files changed, 1004 insertions(+), 100 deletions(-) diff --git a/api/cosmos/authz/v1beta1/authz.pulsar.go b/api/cosmos/authz/v1beta1/authz.pulsar.go index 1693896b9c28..6533eda90218 100644 --- a/api/cosmos/authz/v1beta1/authz.pulsar.go +++ b/api/cosmos/authz/v1beta1/authz.pulsar.go @@ -2075,9 +2075,10 @@ func (x *fastReflection_GrantQueueItem) ProtoMethods() *protoiface.Methods { } var ( - md_AuthzRules protoreflect.MessageDescriptor - fd_AuthzRules_send protoreflect.FieldDescriptor - fd_AuthzRules_stake protoreflect.FieldDescriptor + md_AuthzRules protoreflect.MessageDescriptor + fd_AuthzRules_send protoreflect.FieldDescriptor + fd_AuthzRules_stake protoreflect.FieldDescriptor + fd_AuthzRules_generic protoreflect.FieldDescriptor ) func init() { @@ -2085,6 +2086,7 @@ func init() { md_AuthzRules = File_cosmos_authz_v1beta1_authz_proto.Messages().ByName("AuthzRules") fd_AuthzRules_send = md_AuthzRules.Fields().ByName("send") fd_AuthzRules_stake = md_AuthzRules.Fields().ByName("stake") + fd_AuthzRules_generic = md_AuthzRules.Fields().ByName("generic") } var _ protoreflect.Message = (*fastReflection_AuthzRules)(nil) @@ -2164,6 +2166,12 @@ func (x *fastReflection_AuthzRules) Range(f func(protoreflect.FieldDescriptor, p return } } + if x.Generic != nil { + value := protoreflect.ValueOfMessage(x.Generic.ProtoReflect()) + if !f(fd_AuthzRules_generic, value) { + return + } + } } // Has reports whether a field is populated. @@ -2183,6 +2191,8 @@ func (x *fastReflection_AuthzRules) Has(fd protoreflect.FieldDescriptor) bool { return x.Send != nil case "cosmos.authz.v1beta1.AuthzRules.stake": return x.Stake != nil + case "cosmos.authz.v1beta1.AuthzRules.generic": + return x.Generic != nil default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.AuthzRules")) @@ -2203,6 +2213,8 @@ func (x *fastReflection_AuthzRules) Clear(fd protoreflect.FieldDescriptor) { x.Send = nil case "cosmos.authz.v1beta1.AuthzRules.stake": x.Stake = nil + case "cosmos.authz.v1beta1.AuthzRules.generic": + x.Generic = nil default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.AuthzRules")) @@ -2225,6 +2237,9 @@ func (x *fastReflection_AuthzRules) Get(descriptor protoreflect.FieldDescriptor) case "cosmos.authz.v1beta1.AuthzRules.stake": value := x.Stake return protoreflect.ValueOfMessage(value.ProtoReflect()) + case "cosmos.authz.v1beta1.AuthzRules.generic": + value := x.Generic + return protoreflect.ValueOfMessage(value.ProtoReflect()) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.AuthzRules")) @@ -2249,6 +2264,8 @@ func (x *fastReflection_AuthzRules) Set(fd protoreflect.FieldDescriptor, value p x.Send = value.Message().Interface().(*SendAuthzRules) case "cosmos.authz.v1beta1.AuthzRules.stake": x.Stake = value.Message().Interface().(*StakeAuthzRules) + case "cosmos.authz.v1beta1.AuthzRules.generic": + x.Generic = value.Message().Interface().(*GenericAuthzRules) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.AuthzRules")) @@ -2279,6 +2296,11 @@ func (x *fastReflection_AuthzRules) Mutable(fd protoreflect.FieldDescriptor) pro x.Stake = new(StakeAuthzRules) } return protoreflect.ValueOfMessage(x.Stake.ProtoReflect()) + case "cosmos.authz.v1beta1.AuthzRules.generic": + if x.Generic == nil { + x.Generic = new(GenericAuthzRules) + } + return protoreflect.ValueOfMessage(x.Generic.ProtoReflect()) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.AuthzRules")) @@ -2298,6 +2320,9 @@ func (x *fastReflection_AuthzRules) NewField(fd protoreflect.FieldDescriptor) pr case "cosmos.authz.v1beta1.AuthzRules.stake": m := new(StakeAuthzRules) return protoreflect.ValueOfMessage(m.ProtoReflect()) + case "cosmos.authz.v1beta1.AuthzRules.generic": + m := new(GenericAuthzRules) + return protoreflect.ValueOfMessage(m.ProtoReflect()) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.AuthzRules")) @@ -2375,6 +2400,10 @@ func (x *fastReflection_AuthzRules) ProtoMethods() *protoiface.Methods { l = options.Size(x.Stake) n += 1 + l + runtime.Sov(uint64(l)) } + if x.Generic != nil { + l = options.Size(x.Generic) + n += 1 + l + runtime.Sov(uint64(l)) + } if x.unknownFields != nil { n += len(x.unknownFields) } @@ -2404,6 +2433,20 @@ func (x *fastReflection_AuthzRules) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } + if x.Generic != nil { + encoded, err := options.Marshal(x.Generic) + 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.Stake != nil { encoded, err := options.Marshal(x.Stake) if err != nil { @@ -2553,6 +2596,42 @@ func (x *fastReflection_AuthzRules) 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 Generic", 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.Generic == nil { + x.Generic = &GenericAuthzRules{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Generic); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := runtime.Skip(dAtA[iNdEx:]) @@ -3686,6 +3765,486 @@ func (x *fastReflection_StakeAuthzRules) ProtoMethods() *protoiface.Methods { } } +var _ protoreflect.List = (*_GenericAuthzRules_1_list)(nil) + +type _GenericAuthzRules_1_list struct { + list *[]string +} + +func (x *_GenericAuthzRules_1_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_GenericAuthzRules_1_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfString((*x.list)[i]) +} + +func (x *_GenericAuthzRules_1_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.String() + concreteValue := valueUnwrapped + (*x.list)[i] = concreteValue +} + +func (x *_GenericAuthzRules_1_list) Append(value protoreflect.Value) { + valueUnwrapped := value.String() + concreteValue := valueUnwrapped + *x.list = append(*x.list, concreteValue) +} + +func (x *_GenericAuthzRules_1_list) AppendMutable() protoreflect.Value { + panic(fmt.Errorf("AppendMutable can not be called on message GenericAuthzRules at list field BlockedMessages as it is not of Message kind")) +} + +func (x *_GenericAuthzRules_1_list) Truncate(n int) { + *x.list = (*x.list)[:n] +} + +func (x *_GenericAuthzRules_1_list) NewElement() protoreflect.Value { + v := "" + return protoreflect.ValueOfString(v) +} + +func (x *_GenericAuthzRules_1_list) IsValid() bool { + return x.list != nil +} + +var ( + md_GenericAuthzRules protoreflect.MessageDescriptor + fd_GenericAuthzRules_blocked_messages protoreflect.FieldDescriptor +) + +func init() { + file_cosmos_authz_v1beta1_authz_proto_init() + md_GenericAuthzRules = File_cosmos_authz_v1beta1_authz_proto.Messages().ByName("GenericAuthzRules") + fd_GenericAuthzRules_blocked_messages = md_GenericAuthzRules.Fields().ByName("blocked_messages") +} + +var _ protoreflect.Message = (*fastReflection_GenericAuthzRules)(nil) + +type fastReflection_GenericAuthzRules GenericAuthzRules + +func (x *GenericAuthzRules) ProtoReflect() protoreflect.Message { + return (*fastReflection_GenericAuthzRules)(x) +} + +func (x *GenericAuthzRules) slowProtoReflect() protoreflect.Message { + mi := &file_cosmos_authz_v1beta1_authz_proto_msgTypes[7] + 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_GenericAuthzRules_messageType fastReflection_GenericAuthzRules_messageType +var _ protoreflect.MessageType = fastReflection_GenericAuthzRules_messageType{} + +type fastReflection_GenericAuthzRules_messageType struct{} + +func (x fastReflection_GenericAuthzRules_messageType) Zero() protoreflect.Message { + return (*fastReflection_GenericAuthzRules)(nil) +} +func (x fastReflection_GenericAuthzRules_messageType) New() protoreflect.Message { + return new(fastReflection_GenericAuthzRules) +} +func (x fastReflection_GenericAuthzRules_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_GenericAuthzRules +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_GenericAuthzRules) Descriptor() protoreflect.MessageDescriptor { + return md_GenericAuthzRules +} + +// 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_GenericAuthzRules) Type() protoreflect.MessageType { + return _fastReflection_GenericAuthzRules_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_GenericAuthzRules) New() protoreflect.Message { + return new(fastReflection_GenericAuthzRules) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_GenericAuthzRules) Interface() protoreflect.ProtoMessage { + return (*GenericAuthzRules)(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_GenericAuthzRules) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if len(x.BlockedMessages) != 0 { + value := protoreflect.ValueOfList(&_GenericAuthzRules_1_list{list: &x.BlockedMessages}) + if !f(fd_GenericAuthzRules_blocked_messages, 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_GenericAuthzRules) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "cosmos.authz.v1beta1.GenericAuthzRules.blocked_messages": + return len(x.BlockedMessages) != 0 + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.GenericAuthzRules")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.GenericAuthzRules 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_GenericAuthzRules) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "cosmos.authz.v1beta1.GenericAuthzRules.blocked_messages": + x.BlockedMessages = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.GenericAuthzRules")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.GenericAuthzRules 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_GenericAuthzRules) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "cosmos.authz.v1beta1.GenericAuthzRules.blocked_messages": + if len(x.BlockedMessages) == 0 { + return protoreflect.ValueOfList(&_GenericAuthzRules_1_list{}) + } + listValue := &_GenericAuthzRules_1_list{list: &x.BlockedMessages} + return protoreflect.ValueOfList(listValue) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.GenericAuthzRules")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.GenericAuthzRules 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_GenericAuthzRules) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "cosmos.authz.v1beta1.GenericAuthzRules.blocked_messages": + lv := value.List() + clv := lv.(*_GenericAuthzRules_1_list) + x.BlockedMessages = *clv.list + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.GenericAuthzRules")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.GenericAuthzRules 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_GenericAuthzRules) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.authz.v1beta1.GenericAuthzRules.blocked_messages": + if x.BlockedMessages == nil { + x.BlockedMessages = []string{} + } + value := &_GenericAuthzRules_1_list{list: &x.BlockedMessages} + return protoreflect.ValueOfList(value) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.GenericAuthzRules")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.GenericAuthzRules 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_GenericAuthzRules) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.authz.v1beta1.GenericAuthzRules.blocked_messages": + list := []string{} + return protoreflect.ValueOfList(&_GenericAuthzRules_1_list{list: &list}) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.GenericAuthzRules")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.GenericAuthzRules 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_GenericAuthzRules) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.authz.v1beta1.GenericAuthzRules", 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_GenericAuthzRules) 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_GenericAuthzRules) 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_GenericAuthzRules) 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_GenericAuthzRules) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*GenericAuthzRules) + 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.BlockedMessages) > 0 { + for _, s := range x.BlockedMessages { + 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().(*GenericAuthzRules) + 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.BlockedMessages) > 0 { + for iNdEx := len(x.BlockedMessages) - 1; iNdEx >= 0; iNdEx-- { + i -= len(x.BlockedMessages[iNdEx]) + copy(dAtA[i:], x.BlockedMessages[iNdEx]) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.BlockedMessages[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().(*GenericAuthzRules) + 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: GenericAuthzRules: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: GenericAuthzRules: 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 BlockedMessages", 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.BlockedMessages = append(x.BlockedMessages, 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, + } +} + // Since: cosmos-sdk 0.43 // Code generated by protoc-gen-go. DO NOT EDIT. @@ -3895,6 +4454,8 @@ type AuthzRules struct { Send *SendAuthzRules `protobuf:"bytes,1,opt,name=send,proto3" json:"send,omitempty"` // Stake authz rules Stake *StakeAuthzRules `protobuf:"bytes,2,opt,name=stake,proto3" json:"stake,omitempty"` + // Generic authz rules + Generic *GenericAuthzRules `protobuf:"bytes,3,opt,name=generic,proto3" json:"generic,omitempty"` } func (x *AuthzRules) Reset() { @@ -3931,6 +4492,13 @@ func (x *AuthzRules) GetStake() *StakeAuthzRules { return nil } +func (x *AuthzRules) GetGeneric() *GenericAuthzRules { + if x != nil { + return x.Generic + } + return nil +} + // Send authz rules type SendAuthzRules struct { state protoimpl.MessageState @@ -4011,6 +4579,42 @@ func (x *StakeAuthzRules) GetBlockedValidators() []string { return nil } +// Generic authz rules +type GenericAuthzRules struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + BlockedMessages []string `protobuf:"bytes,1,rep,name=blocked_messages,json=blockedMessages,proto3" json:"blocked_messages,omitempty"` +} + +func (x *GenericAuthzRules) Reset() { + *x = GenericAuthzRules{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_authz_v1beta1_authz_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GenericAuthzRules) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GenericAuthzRules) ProtoMessage() {} + +// Deprecated: Use GenericAuthzRules.ProtoReflect.Descriptor instead. +func (*GenericAuthzRules) Descriptor() ([]byte, []int) { + return file_cosmos_authz_v1beta1_authz_proto_rawDescGZIP(), []int{7} +} + +func (x *GenericAuthzRules) GetBlockedMessages() []string { + if x != nil { + return x.BlockedMessages + } + return nil +} + var File_cosmos_authz_v1beta1_authz_proto protoreflect.FileDescriptor var file_cosmos_authz_v1beta1_authz_proto_rawDesc = []byte{ @@ -4067,7 +4671,7 @@ var file_cosmos_authz_v1beta1_authz_proto_rawDesc = []byte{ 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, 0x8f, 0x01, + 0x52, 0x0b, 0x6d, 0x73, 0x67, 0x54, 0x79, 0x70, 0x65, 0x55, 0x72, 0x6c, 0x73, 0x22, 0xd8, 0x01, 0x0a, 0x0a, 0x41, 0x75, 0x74, 0x68, 0x7a, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x3e, 0x0a, 0x04, 0x73, 0x65, 0x6e, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, @@ -4076,38 +4680,46 @@ var file_cosmos_authz_v1beta1_authz_proto_rawDesc = []byte{ 0x73, 0x74, 0x61, 0x6b, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x53, 0x74, 0x61, 0x6b, 0x65, 0x41, 0x75, 0x74, 0x68, 0x7a, 0x52, 0x75, 0x6c, - 0x65, 0x73, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x05, 0x73, 0x74, 0x61, 0x6b, 0x65, 0x22, - 0xc4, 0x01, 0x0a, 0x0e, 0x53, 0x65, 0x6e, 0x64, 0x41, 0x75, 0x74, 0x68, 0x7a, 0x52, 0x75, 0x6c, - 0x65, 0x73, 0x12, 0x82, 0x01, 0x0a, 0x0b, 0x73, 0x70, 0x65, 0x6e, 0x64, 0x5f, 0x6c, 0x69, 0x6d, - 0x69, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, - 0x6f, 0x69, 0x6e, 0x42, 0x46, 0xc8, 0xde, 0x1f, 0x00, 0xaa, 0xdf, 0x1f, 0x28, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, - 0x43, 0x6f, 0x69, 0x6e, 0x73, 0x9a, 0xe7, 0xb0, 0x2a, 0x0c, 0x6c, 0x65, 0x67, 0x61, 0x63, 0x79, - 0x5f, 0x63, 0x6f, 0x69, 0x6e, 0x73, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x0a, 0x73, 0x70, 0x65, - 0x6e, 0x64, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x2d, 0x0a, 0x12, 0x62, 0x6c, 0x6f, 0x63, 0x6b, - 0x65, 0x64, 0x5f, 0x72, 0x65, 0x63, 0x69, 0x70, 0x69, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x02, 0x20, - 0x03, 0x28, 0x09, 0x52, 0x11, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x65, 0x64, 0x52, 0x65, 0x63, 0x69, - 0x70, 0x69, 0x65, 0x6e, 0x74, 0x73, 0x22, 0x40, 0x0a, 0x0f, 0x53, 0x74, 0x61, 0x6b, 0x65, 0x41, - 0x75, 0x74, 0x68, 0x7a, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x2d, 0x0a, 0x12, 0x62, 0x6c, 0x6f, - 0x63, 0x6b, 0x65, 0x64, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x18, - 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x11, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x65, 0x64, 0x56, 0x61, - 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 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, + 0x65, 0x73, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x05, 0x73, 0x74, 0x61, 0x6b, 0x65, 0x12, + 0x47, 0x0a, 0x07, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x69, 0x63, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x27, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x2e, + 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x69, 0x63, 0x41, + 0x75, 0x74, 0x68, 0x7a, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, + 0x07, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x69, 0x63, 0x22, 0xc4, 0x01, 0x0a, 0x0e, 0x53, 0x65, 0x6e, + 0x64, 0x41, 0x75, 0x74, 0x68, 0x7a, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x82, 0x01, 0x0a, 0x0b, + 0x73, 0x70, 0x65, 0x6e, 0x64, 0x5f, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, + 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x42, 0x46, 0xc8, 0xde, + 0x1f, 0x00, 0xaa, 0xdf, 0x1f, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, + 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x73, 0x9a, 0xe7, + 0xb0, 0x2a, 0x0c, 0x6c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x5f, 0x63, 0x6f, 0x69, 0x6e, 0x73, 0xa8, + 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x0a, 0x73, 0x70, 0x65, 0x6e, 0x64, 0x4c, 0x69, 0x6d, 0x69, 0x74, + 0x12, 0x2d, 0x0a, 0x12, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x65, 0x64, 0x5f, 0x72, 0x65, 0x63, 0x69, + 0x70, 0x69, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x11, 0x62, 0x6c, + 0x6f, 0x63, 0x6b, 0x65, 0x64, 0x52, 0x65, 0x63, 0x69, 0x70, 0x69, 0x65, 0x6e, 0x74, 0x73, 0x22, + 0x40, 0x0a, 0x0f, 0x53, 0x74, 0x61, 0x6b, 0x65, 0x41, 0x75, 0x74, 0x68, 0x7a, 0x52, 0x75, 0x6c, + 0x65, 0x73, 0x12, 0x2d, 0x0a, 0x12, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x65, 0x64, 0x5f, 0x76, 0x61, + 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x11, + 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x65, 0x64, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, + 0x73, 0x22, 0x3e, 0x0a, 0x11, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x69, 0x63, 0x41, 0x75, 0x74, 0x68, + 0x7a, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x29, 0x0a, 0x10, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x65, + 0x64, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, + 0x52, 0x0f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 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 ( @@ -4122,7 +4734,7 @@ 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, 7) +var file_cosmos_authz_v1beta1_authz_proto_msgTypes = make([]protoimpl.MessageInfo, 8) var file_cosmos_authz_v1beta1_authz_proto_goTypes = []interface{}{ (*GenericAuthorization)(nil), // 0: cosmos.authz.v1beta1.GenericAuthorization (*Grant)(nil), // 1: cosmos.authz.v1beta1.Grant @@ -4131,23 +4743,25 @@ var file_cosmos_authz_v1beta1_authz_proto_goTypes = []interface{}{ (*AuthzRules)(nil), // 4: cosmos.authz.v1beta1.AuthzRules (*SendAuthzRules)(nil), // 5: cosmos.authz.v1beta1.SendAuthzRules (*StakeAuthzRules)(nil), // 6: cosmos.authz.v1beta1.StakeAuthzRules - (*anypb.Any)(nil), // 7: google.protobuf.Any - (*timestamppb.Timestamp)(nil), // 8: google.protobuf.Timestamp - (*v1beta1.Coin)(nil), // 9: cosmos.base.v1beta1.Coin + (*GenericAuthzRules)(nil), // 7: cosmos.authz.v1beta1.GenericAuthzRules + (*anypb.Any)(nil), // 8: google.protobuf.Any + (*timestamppb.Timestamp)(nil), // 9: google.protobuf.Timestamp + (*v1beta1.Coin)(nil), // 10: cosmos.base.v1beta1.Coin } var file_cosmos_authz_v1beta1_authz_proto_depIdxs = []int32{ - 7, // 0: cosmos.authz.v1beta1.Grant.authorization:type_name -> google.protobuf.Any - 8, // 1: cosmos.authz.v1beta1.Grant.expiration:type_name -> google.protobuf.Timestamp - 7, // 2: cosmos.authz.v1beta1.GrantAuthorization.authorization:type_name -> google.protobuf.Any - 8, // 3: cosmos.authz.v1beta1.GrantAuthorization.expiration:type_name -> google.protobuf.Timestamp - 5, // 4: cosmos.authz.v1beta1.AuthzRules.send:type_name -> cosmos.authz.v1beta1.SendAuthzRules - 6, // 5: cosmos.authz.v1beta1.AuthzRules.stake:type_name -> cosmos.authz.v1beta1.StakeAuthzRules - 9, // 6: cosmos.authz.v1beta1.SendAuthzRules.spend_limit:type_name -> cosmos.base.v1beta1.Coin - 7, // [7:7] is the sub-list for method output_type - 7, // [7:7] is the sub-list for method input_type - 7, // [7:7] is the sub-list for extension type_name - 7, // [7:7] is the sub-list for extension extendee - 0, // [0:7] is the sub-list for field type_name + 8, // 0: cosmos.authz.v1beta1.Grant.authorization:type_name -> google.protobuf.Any + 9, // 1: cosmos.authz.v1beta1.Grant.expiration:type_name -> google.protobuf.Timestamp + 8, // 2: cosmos.authz.v1beta1.GrantAuthorization.authorization:type_name -> google.protobuf.Any + 9, // 3: cosmos.authz.v1beta1.GrantAuthorization.expiration:type_name -> google.protobuf.Timestamp + 5, // 4: cosmos.authz.v1beta1.AuthzRules.send:type_name -> cosmos.authz.v1beta1.SendAuthzRules + 6, // 5: cosmos.authz.v1beta1.AuthzRules.stake:type_name -> cosmos.authz.v1beta1.StakeAuthzRules + 7, // 6: cosmos.authz.v1beta1.AuthzRules.generic:type_name -> cosmos.authz.v1beta1.GenericAuthzRules + 10, // 7: cosmos.authz.v1beta1.SendAuthzRules.spend_limit:type_name -> cosmos.base.v1beta1.Coin + 8, // [8:8] is the sub-list for method output_type + 8, // [8:8] is the sub-list for method input_type + 8, // [8:8] is the sub-list for extension type_name + 8, // [8:8] is the sub-list for extension extendee + 0, // [0:8] is the sub-list for field type_name } func init() { file_cosmos_authz_v1beta1_authz_proto_init() } @@ -4240,6 +4854,18 @@ func file_cosmos_authz_v1beta1_authz_proto_init() { return nil } } + file_cosmos_authz_v1beta1_authz_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GenericAuthzRules); 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{ @@ -4247,7 +4873,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: 7, + NumMessages: 8, NumExtensions: 0, NumServices: 0, }, diff --git a/proto/cosmos/authz/v1beta1/authz.proto b/proto/cosmos/authz/v1beta1/authz.proto index b9004f48e16e..b4fc32734d68 100644 --- a/proto/cosmos/authz/v1beta1/authz.proto +++ b/proto/cosmos/authz/v1beta1/authz.proto @@ -55,6 +55,9 @@ message AuthzRules { // Stake authz rules StakeAuthzRules stake = 2 [(gogoproto.nullable) = false]; + + // Generic authz rules + GenericAuthzRules generic = 3 [(gogoproto.nullable) = false]; } // Send authz rules @@ -72,3 +75,8 @@ message SendAuthzRules { message StakeAuthzRules { repeated string blocked_validators = 1; } + +// Generic authz rules +message GenericAuthzRules { + repeated string blocked_messages = 1; +} \ No newline at end of file diff --git a/simapp/ante.go b/simapp/ante.go index 58e85a7597dc..f6409a2073e1 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), 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..241f7b54a26a 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -1,4 +1,4 @@ -//go:build app_v1 +//go:build !app_v1 package simapp @@ -522,6 +522,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,6 +567,7 @@ 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, diff --git a/simapp/app_v2.go b/simapp/app_v2.go index e10a54e7449e..40620509414a 100644 --- a/simapp/app_v2.go +++ b/simapp/app_v2.go @@ -1,4 +1,4 @@ -//go:build !app_v1 +//go:build app_v1 package simapp diff --git a/x/auth/ante/ante.go b/x/auth/ante/ante.go index 8b2277aeb88b..6d1c1912ec7a 100644 --- a/x/auth/ante/ante.go +++ b/x/auth/ante/ante.go @@ -14,6 +14,7 @@ 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 diff --git a/x/auth/ante/authz_rules_ante.go b/x/auth/ante/authz_rules_ante.go index 841257f8d2db..3c1df7c694bd 100644 --- a/x/auth/ante/authz_rules_ante.go +++ b/x/auth/ante/authz_rules_ante.go @@ -1,6 +1,7 @@ package ante import ( + "errors" "fmt" sdk "github.com/cosmos/cosmos-sdk/types" @@ -12,29 +13,46 @@ type AuthzDecorator struct { azk AuthzKeeper } +func NewAuthzDecorator(azk AuthzKeeper) AuthzDecorator { + return AuthzDecorator{ + azk: azk, + } +} + // AuthzDecorator 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) { msgs := tx.GetMsgs() for _, msg := range msgs { // Check if the message is an authorization message if authzMsg, ok := msg.(*authztypes.MsgGrant); ok { + fmt.Println("coming here", ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>") authz, err := authzMsg.GetAuthorization() if err != nil { return ctx, err } + rules, err := azd.azk.GetAuthzRules(ctx) + fmt.Println("rules", rules, err, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>") switch authzConverted := authz.(type) { case *banktypes.SendAuthorization: - rules, err := azd.azk.GetAuthzRules(ctx) - if err != nil { - return ctx, err + if err != nil && errors.Is(authztypes.ErrEmptyAuthzRules, err) { + continue } if checkSendAuthzRulesVoilated(authzMsg, authzConverted, rules.Send) { return ctx, fmt.Errorf("authz rules are not meeting") } + case *authztypes.GenericAuthorization: + if err != nil && errors.Is(authztypes.ErrEmptyAuthzRules, err) { + continue + } + + if checkGenericAuthzRules(authzMsg, authzConverted, rules.Generic) { + return ctx, fmt.Errorf("authz rules are not meeting") + } + default: fmt.Println("default case reached here") } @@ -46,6 +64,8 @@ func (azd AuthzDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, } func checkSendAuthzRulesVoilated(msgGrant *authztypes.MsgGrant, authz *banktypes.SendAuthorization, sendAuthzRules authztypes.SendAuthzRules) bool { + fmt.Printf("\">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\": %v\n", ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>") + fmt.Printf("sendAuthzRules: %v\n", sendAuthzRules) if authz.SpendLimit.IsAllGT(sendAuthzRules.SpendLimit) { return true } @@ -58,3 +78,13 @@ func checkSendAuthzRulesVoilated(msgGrant *authztypes.MsgGrant, authz *banktypes return false } + +func checkGenericAuthzRules(msgGrant *authztypes.MsgGrant, authz *authztypes.GenericAuthorization, GenericAuthzRules authztypes.GenericAuthzRules) bool { + for _, v := range GenericAuthzRules.BlockedMessages { + if v == authz.Msg { + return true + } + } + + return false +} diff --git a/x/authz/authz.pb.go b/x/authz/authz.pb.go index 9c51e6ae0f4d..a88de18d9858 100644 --- a/x/authz/authz.pb.go +++ b/x/authz/authz.pb.go @@ -202,6 +202,8 @@ type AuthzRules struct { Send SendAuthzRules `protobuf:"bytes,1,opt,name=send,proto3" json:"send"` // Stake authz rules Stake StakeAuthzRules `protobuf:"bytes,2,opt,name=stake,proto3" json:"stake"` + // Generic authz rules + Generic GenericAuthzRules `protobuf:"bytes,3,opt,name=generic,proto3" json:"generic"` } func (m *AuthzRules) Reset() { *m = AuthzRules{} } @@ -314,6 +316,44 @@ func (m *StakeAuthzRules) XXX_DiscardUnknown() { var xxx_messageInfo_StakeAuthzRules proto.InternalMessageInfo +// Generic authz rules +type GenericAuthzRules struct { + BlockedMessages []string `protobuf:"bytes,1,rep,name=blocked_messages,json=blockedMessages,proto3" json:"blocked_messages,omitempty"` +} + +func (m *GenericAuthzRules) Reset() { *m = GenericAuthzRules{} } +func (m *GenericAuthzRules) String() string { return proto.CompactTextString(m) } +func (*GenericAuthzRules) ProtoMessage() {} +func (*GenericAuthzRules) Descriptor() ([]byte, []int) { + return fileDescriptor_544dc2e84b61c637, []int{7} +} +func (m *GenericAuthzRules) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenericAuthzRules) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenericAuthzRules.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 *GenericAuthzRules) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenericAuthzRules.Merge(m, src) +} +func (m *GenericAuthzRules) XXX_Size() int { + return m.Size() +} +func (m *GenericAuthzRules) XXX_DiscardUnknown() { + xxx_messageInfo_GenericAuthzRules.DiscardUnknown(m) +} + +var xxx_messageInfo_GenericAuthzRules proto.InternalMessageInfo + func init() { proto.RegisterType((*GenericAuthorization)(nil), "cosmos.authz.v1beta1.GenericAuthorization") proto.RegisterType((*Grant)(nil), "cosmos.authz.v1beta1.Grant") @@ -322,52 +362,56 @@ func init() { proto.RegisterType((*AuthzRules)(nil), "cosmos.authz.v1beta1.AuthzRules") proto.RegisterType((*SendAuthzRules)(nil), "cosmos.authz.v1beta1.SendAuthzRules") proto.RegisterType((*StakeAuthzRules)(nil), "cosmos.authz.v1beta1.StakeAuthzRules") + proto.RegisterType((*GenericAuthzRules)(nil), "cosmos.authz.v1beta1.GenericAuthzRules") } func init() { proto.RegisterFile("cosmos/authz/v1beta1/authz.proto", fileDescriptor_544dc2e84b61c637) } var fileDescriptor_544dc2e84b61c637 = []byte{ - // 637 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0x41, 0x4f, 0xd4, 0x40, - 0x14, 0xde, 0xc2, 0xa2, 0x32, 0x2b, 0x28, 0xcd, 0x1e, 0x16, 0x0e, 0x5d, 0xd2, 0xa0, 0x21, 0x24, - 0xdb, 0x06, 0xf4, 0xe4, 0xc1, 0xb0, 0xd5, 0x48, 0x34, 0x5e, 0x2c, 0xe8, 0xc1, 0xcb, 0x66, 0xda, - 0x3e, 0xcb, 0x84, 0x76, 0xa6, 0xe9, 0x4c, 0x09, 0xcb, 0xd1, 0xa3, 0x17, 0x39, 0x7b, 0xf4, 0x64, - 0x3c, 0x61, 0xc2, 0x4f, 0xf0, 0xb0, 0xf1, 0x44, 0x3c, 0x79, 0x02, 0x85, 0x03, 0x7f, 0xc3, 0x74, - 0xa6, 0x5d, 0x76, 0x59, 0x54, 0x0e, 0x5e, 0x9a, 0x99, 0x79, 0xdf, 0xf7, 0xbd, 0xf7, 0xbe, 0x99, - 0x57, 0x34, 0xef, 0x33, 0x1e, 0x33, 0x6e, 0xe3, 0x4c, 0x6c, 0xee, 0xda, 0xdb, 0xcb, 0x1e, 0x08, - 0xbc, 0xac, 0x76, 0x56, 0x92, 0x32, 0xc1, 0xf4, 0xba, 0x42, 0x58, 0xea, 0xac, 0x40, 0xcc, 0xcd, - 0xe0, 0x98, 0x50, 0x66, 0xcb, 0xaf, 0x02, 0xce, 0xcd, 0x2a, 0x60, 0x47, 0xee, 0xec, 0x82, 0xa5, - 0x42, 0xcd, 0x90, 0xb1, 0x30, 0x02, 0x5b, 0xee, 0xbc, 0xec, 0x8d, 0x2d, 0x48, 0x0c, 0x5c, 0xe0, - 0x38, 0x29, 0x00, 0xf5, 0x90, 0x85, 0x4c, 0x11, 0xf3, 0x55, 0xa9, 0x78, 0x91, 0x86, 0x69, 0xb7, - 0x08, 0x19, 0x45, 0xdd, 0x1e, 0xe6, 0xd0, 0x2f, 0xdb, 0x67, 0x84, 0xaa, 0xb8, 0x29, 0x50, 0x7d, - 0x0d, 0x28, 0xa4, 0xc4, 0x6f, 0x67, 0x62, 0x93, 0xa5, 0x64, 0x17, 0x0b, 0xc2, 0xa8, 0x7e, 0x1b, - 0x8d, 0xc7, 0x3c, 0x6c, 0x68, 0xf3, 0xda, 0xe2, 0xa4, 0x9b, 0x2f, 0x1f, 0x3c, 0xfb, 0x76, 0xd0, - 0x32, 0x2f, 0xeb, 0xd1, 0x1a, 0x62, 0xbe, 0x3b, 0xdb, 0x5f, 0x6a, 0x2a, 0x58, 0x8b, 0x07, 0x5b, - 0xf6, 0x65, 0xea, 0xe6, 0x17, 0x0d, 0x4d, 0xac, 0xa5, 0x98, 0x0a, 0xdd, 0x43, 0x53, 0x78, 0x30, - 0x24, 0x33, 0xd6, 0x56, 0xea, 0x96, 0x6a, 0xc9, 0x2a, 0x5b, 0xb2, 0xda, 0xb4, 0xeb, 0xdc, 0xbd, - 0x5a, 0x09, 0xee, 0xb0, 0xa4, 0xfe, 0x18, 0x21, 0xd8, 0x49, 0x48, 0xaa, 0x12, 0x8c, 0xc9, 0x04, - 0x73, 0x23, 0x09, 0x36, 0x4a, 0xab, 0x9d, 0x1b, 0xbd, 0xa3, 0xa6, 0xb6, 0x77, 0xdc, 0xd4, 0xdc, - 0x01, 0x9e, 0xf9, 0x71, 0x0c, 0xe9, 0xb2, 0xe6, 0x61, 0xa3, 0x56, 0xd0, 0xf5, 0x30, 0x3f, 0x85, - 0x54, 0x99, 0xe5, 0x34, 0xbe, 0x1f, 0xb4, 0xca, 0xb7, 0xd0, 0x0e, 0x82, 0x14, 0x38, 0x5f, 0x17, - 0x29, 0xa1, 0xa1, 0x5b, 0x02, 0xcf, 0x39, 0x20, 0xab, 0xb9, 0x02, 0x07, 0x46, 0x8d, 0x1a, 0xff, - 0xff, 0x46, 0xad, 0x0e, 0x19, 0x55, 0xfd, 0xa7, 0x51, 0xd5, 0x11, 0x93, 0xee, 0xa3, 0x69, 0xe9, - 0xd1, 0x8b, 0x0c, 0x32, 0x78, 0x2a, 0x20, 0xd6, 0x4d, 0x34, 0x15, 0xf3, 0xb0, 0x23, 0xba, 0x09, - 0x74, 0xb2, 0x34, 0xe2, 0x0d, 0x6d, 0x7e, 0x7c, 0x71, 0xd2, 0xad, 0xc5, 0x3c, 0xdc, 0xe8, 0x26, - 0xf0, 0x32, 0x8d, 0xb8, 0xf9, 0x5e, 0x43, 0x28, 0x2f, 0x6c, 0xd7, 0xcd, 0x22, 0xe0, 0xfa, 0x43, - 0x54, 0xe5, 0x40, 0x83, 0xe2, 0x29, 0x2c, 0x58, 0x97, 0x36, 0xb2, 0x0e, 0x34, 0x38, 0xe7, 0x38, - 0xd5, 0xde, 0x51, 0xb3, 0xe2, 0x4a, 0x9e, 0xde, 0x46, 0x13, 0x5c, 0xe0, 0x2d, 0x28, 0xae, 0xfa, - 0xce, 0x1f, 0x04, 0x72, 0xc8, 0x88, 0x82, 0x62, 0x9a, 0x5f, 0x35, 0x34, 0x3d, 0x9c, 0x41, 0x7f, - 0xab, 0xa1, 0x1a, 0x4f, 0x80, 0x06, 0x9d, 0x88, 0xc4, 0x44, 0xc8, 0x3e, 0x6a, 0x2b, 0xb3, 0xa5, - 0x78, 0x3e, 0x60, 0x7d, 0xed, 0x47, 0x8c, 0x50, 0xe7, 0x49, 0x2e, 0xf8, 0xf9, 0xb8, 0xb9, 0x18, - 0x12, 0xb1, 0x99, 0x79, 0x96, 0xcf, 0xe2, 0x62, 0xda, 0xed, 0x81, 0xf9, 0xc8, 0x8d, 0xe1, 0x92, - 0xc0, 0x3f, 0x9c, 0xed, 0x2f, 0xdd, 0x8c, 0x20, 0xc4, 0x7e, 0xb7, 0x93, 0x8f, 0x28, 0xff, 0x74, - 0xb6, 0xbf, 0xa4, 0xb9, 0x48, 0x66, 0x7d, 0x9e, 0x27, 0xd5, 0x5b, 0x48, 0xf7, 0x22, 0xe6, 0x6f, - 0x41, 0xd0, 0x49, 0xc1, 0x27, 0x09, 0x01, 0x2a, 0x78, 0x63, 0x4c, 0x5a, 0x3a, 0x53, 0x44, 0xdc, - 0x7e, 0xc0, 0x5c, 0x45, 0xb7, 0x2e, 0xb4, 0x39, 0xa8, 0xb0, 0x8d, 0x23, 0x12, 0x60, 0xc1, 0xd2, - 0xf2, 0x52, 0x4a, 0x85, 0x57, 0xfd, 0x80, 0xe3, 0xf4, 0x7e, 0x19, 0x95, 0xde, 0x89, 0xa1, 0x1d, - 0x9e, 0x18, 0xda, 0xcf, 0x13, 0x43, 0xdb, 0x3b, 0x35, 0x2a, 0x87, 0xa7, 0x46, 0xe5, 0xc7, 0xa9, - 0x51, 0x79, 0xbd, 0xf0, 0xd7, 0xd6, 0x76, 0xd4, 0xff, 0xd1, 0xbb, 0x26, 0x9f, 0xce, 0xbd, 0xdf, - 0x01, 0x00, 0x00, 0xff, 0xff, 0x6f, 0xc7, 0x8f, 0x62, 0x44, 0x05, 0x00, 0x00, + // 681 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xbf, 0x53, 0xd4, 0x4e, + 0x14, 0xbf, 0xc0, 0xf1, 0xe5, 0xcb, 0x9e, 0xfc, 0xca, 0x5c, 0x71, 0x50, 0xe4, 0x98, 0x0c, 0x2a, + 0x32, 0x73, 0xc9, 0x80, 0x56, 0x16, 0x0c, 0x17, 0x1d, 0x19, 0x1d, 0x2d, 0x0c, 0x68, 0x61, 0x73, + 0xb3, 0x49, 0x9e, 0x61, 0x87, 0x24, 0x9b, 0xc9, 0x6e, 0x18, 0x8e, 0xd2, 0xd2, 0x8a, 0xda, 0xd2, + 0xca, 0xb1, 0xc2, 0x19, 0xfe, 0x04, 0x8b, 0x1b, 0x2b, 0xc6, 0x8a, 0x0a, 0x14, 0x0a, 0xfe, 0x0d, + 0x27, 0xbb, 0xc9, 0x71, 0xc7, 0x9d, 0x4a, 0x61, 0x93, 0xc9, 0xee, 0xfb, 0x7c, 0x3e, 0xef, 0xbd, + 0xcf, 0xbe, 0x5d, 0xb4, 0xe0, 0x52, 0x16, 0x52, 0x66, 0xe2, 0x94, 0x6f, 0xef, 0x9b, 0xbb, 0x2b, + 0x0e, 0x70, 0xbc, 0x22, 0x57, 0x46, 0x9c, 0x50, 0x4e, 0xd5, 0xaa, 0x44, 0x18, 0x72, 0x2f, 0x47, + 0xcc, 0xcf, 0xe2, 0x90, 0x44, 0xd4, 0x14, 0x5f, 0x09, 0x9c, 0x9f, 0x93, 0xc0, 0x96, 0x58, 0x99, + 0x39, 0x4b, 0x86, 0xea, 0x3e, 0xa5, 0x7e, 0x00, 0xa6, 0x58, 0x39, 0xe9, 0x5b, 0x93, 0x93, 0x10, + 0x18, 0xc7, 0x61, 0x9c, 0x03, 0xaa, 0x3e, 0xf5, 0xa9, 0x24, 0x66, 0x7f, 0x85, 0xe2, 0x75, 0x1a, + 0x8e, 0xda, 0x79, 0x48, 0xcb, 0xeb, 0x76, 0x30, 0x83, 0x6e, 0xd9, 0x2e, 0x25, 0x91, 0x8c, 0xeb, + 0x1c, 0x55, 0x37, 0x20, 0x82, 0x84, 0xb8, 0xcd, 0x94, 0x6f, 0xd3, 0x84, 0xec, 0x63, 0x4e, 0x68, + 0xa4, 0xce, 0xa0, 0xd1, 0x90, 0xf9, 0x35, 0x65, 0x41, 0x59, 0x9a, 0xb0, 0xb3, 0xdf, 0x87, 0xcf, + 0xbe, 0x1d, 0x35, 0xf4, 0x61, 0x3d, 0x1a, 0x7d, 0xcc, 0xf7, 0x97, 0x87, 0xcb, 0x75, 0x09, 0x6b, + 0x30, 0x6f, 0xc7, 0x1c, 0xa6, 0xae, 0x7f, 0x51, 0xd0, 0xd8, 0x46, 0x82, 0x23, 0xae, 0x3a, 0x68, + 0x12, 0xf7, 0x86, 0x44, 0xc6, 0xca, 0x6a, 0xd5, 0x90, 0x2d, 0x19, 0x45, 0x4b, 0x46, 0x33, 0x6a, + 0x5b, 0x77, 0x6e, 0x56, 0x82, 0xdd, 0x2f, 0xa9, 0x3e, 0x46, 0x08, 0xf6, 0x62, 0x92, 0xc8, 0x04, + 0x23, 0x22, 0xc1, 0xfc, 0x40, 0x82, 0xad, 0xc2, 0x6a, 0xeb, 0xff, 0xce, 0x69, 0x5d, 0x39, 0x38, + 0xab, 0x2b, 0x76, 0x0f, 0x4f, 0xff, 0x38, 0x82, 0x54, 0x51, 0x73, 0xbf, 0x51, 0xab, 0x68, 0xdc, + 0xcf, 0x76, 0x21, 0x91, 0x66, 0x59, 0xb5, 0xef, 0x47, 0x8d, 0x62, 0x16, 0x9a, 0x9e, 0x97, 0x00, + 0x63, 0x9b, 0x3c, 0x21, 0x91, 0x6f, 0x17, 0xc0, 0x2b, 0x0e, 0x88, 0x6a, 0x6e, 0xc0, 0x81, 0x41, + 0xa3, 0x46, 0xff, 0xbd, 0x51, 0xeb, 0x7d, 0x46, 0x95, 0xff, 0x6a, 0x54, 0x79, 0xc0, 0xa4, 0x07, + 0x68, 0x4a, 0x78, 0xf4, 0x32, 0x85, 0x14, 0x9e, 0x72, 0x08, 0x55, 0x1d, 0x4d, 0x86, 0xcc, 0x6f, + 0xf1, 0x76, 0x0c, 0xad, 0x34, 0x09, 0x58, 0x4d, 0x59, 0x18, 0x5d, 0x9a, 0xb0, 0x2b, 0x21, 0xf3, + 0xb7, 0xda, 0x31, 0xbc, 0x4a, 0x02, 0xa6, 0x9f, 0x28, 0x08, 0x65, 0x85, 0xed, 0xdb, 0x69, 0x00, + 0x4c, 0x5d, 0x43, 0x65, 0x06, 0x91, 0x97, 0x8f, 0xc2, 0xa2, 0x31, 0xb4, 0x91, 0x4d, 0x88, 0xbc, + 0x2b, 0x8e, 0x55, 0xee, 0x9c, 0xd6, 0x4b, 0xb6, 0xe0, 0xa9, 0x4d, 0x34, 0xc6, 0x38, 0xde, 0x81, + 0xfc, 0xa8, 0x6f, 0xff, 0x46, 0x20, 0x83, 0x0c, 0x28, 0x48, 0xa6, 0xba, 0x81, 0xc6, 0x7d, 0x39, + 0xb8, 0xb9, 0xcf, 0x77, 0x87, 0x8b, 0xf4, 0x4c, 0x77, 0x9f, 0x4c, 0xc1, 0xd6, 0xbf, 0x2a, 0x68, + 0xaa, 0xbf, 0x54, 0xf5, 0x9d, 0x82, 0x2a, 0x2c, 0x86, 0xc8, 0x6b, 0x05, 0x24, 0x24, 0x5c, 0x18, + 0x52, 0x59, 0x9d, 0x2b, 0x12, 0x64, 0x37, 0xb5, 0xab, 0xff, 0x88, 0x92, 0xc8, 0x7a, 0x92, 0x49, + 0x7e, 0x3e, 0xab, 0x2f, 0xf9, 0x84, 0x6f, 0xa7, 0x8e, 0xe1, 0xd2, 0x30, 0x7f, 0x36, 0xcc, 0x9e, + 0x8b, 0x96, 0x39, 0xcc, 0x04, 0x81, 0x7d, 0xb8, 0x3c, 0x5c, 0xbe, 0x15, 0x80, 0x8f, 0xdd, 0x76, + 0x2b, 0xbb, 0xeb, 0xec, 0xd3, 0xe5, 0xe1, 0xb2, 0x62, 0x23, 0x91, 0xf5, 0x79, 0x96, 0x54, 0x6d, + 0x20, 0xd5, 0x09, 0xa8, 0xbb, 0x03, 0x5e, 0x2b, 0x01, 0x97, 0xc4, 0x04, 0x22, 0xce, 0x6a, 0x23, + 0xe2, 0x6c, 0x66, 0xf3, 0x88, 0xdd, 0x0d, 0xe8, 0xeb, 0x68, 0xfa, 0x9a, 0x5f, 0xbd, 0x0a, 0xbb, + 0x38, 0x20, 0x1e, 0xe6, 0x34, 0x29, 0x4e, 0xb7, 0x50, 0x78, 0xdd, 0x0d, 0xe8, 0x6b, 0x68, 0x76, + 0xc0, 0x2c, 0xf5, 0x1e, 0x9a, 0x29, 0x34, 0x42, 0x60, 0x0c, 0xfb, 0x50, 0x28, 0x4c, 0xe7, 0xfb, + 0x2f, 0xf2, 0x6d, 0xcb, 0xea, 0xfc, 0xd4, 0x4a, 0x9d, 0x73, 0x4d, 0x39, 0x3e, 0xd7, 0x94, 0x1f, + 0xe7, 0x9a, 0x72, 0x70, 0xa1, 0x95, 0x8e, 0x2f, 0xb4, 0xd2, 0xc9, 0x85, 0x56, 0x7a, 0xb3, 0xf8, + 0x47, 0x6b, 0xf6, 0xe4, 0x43, 0xed, 0xfc, 0x27, 0x66, 0xf8, 0xfe, 0xaf, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x8a, 0x67, 0xfb, 0xeb, 0xcd, 0x05, 0x00, 0x00, } func (m *GenericAuthorization) Marshal() (dAtA []byte, err error) { @@ -556,6 +600,16 @@ func (m *AuthzRules) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + { + size, err := m.Generic.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintAuthz(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a { size, err := m.Stake.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -657,6 +711,38 @@ func (m *StakeAuthzRules) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *GenericAuthzRules) 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 *GenericAuthzRules) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenericAuthzRules) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.BlockedMessages) > 0 { + for iNdEx := len(m.BlockedMessages) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.BlockedMessages[iNdEx]) + copy(dAtA[i:], m.BlockedMessages[iNdEx]) + i = encodeVarintAuthz(dAtA, i, uint64(len(m.BlockedMessages[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func encodeVarintAuthz(dAtA []byte, offset int, v uint64) int { offset -= sovAuthz(v) base := offset @@ -748,6 +834,8 @@ func (m *AuthzRules) Size() (n int) { n += 1 + l + sovAuthz(uint64(l)) l = m.Stake.Size() n += 1 + l + sovAuthz(uint64(l)) + l = m.Generic.Size() + n += 1 + l + sovAuthz(uint64(l)) return n } @@ -787,6 +875,21 @@ func (m *StakeAuthzRules) Size() (n int) { return n } +func (m *GenericAuthzRules) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.BlockedMessages) > 0 { + for _, s := range m.BlockedMessages { + 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 } @@ -1360,6 +1463,39 @@ func (m *AuthzRules) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Generic", 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 + } + if err := m.Generic.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipAuthz(dAtA[iNdEx:]) @@ -1579,6 +1715,88 @@ func (m *StakeAuthzRules) Unmarshal(dAtA []byte) error { } return nil } +func (m *GenericAuthzRules) 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: GenericAuthzRules: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenericAuthzRules: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockedMessages", 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.BlockedMessages = append(m.BlockedMessages, 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/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/keeper.go b/x/authz/keeper/keeper.go index 12628a9da486..a6c9b4f6f499 100644 --- a/x/authz/keeper/keeper.go +++ b/x/authz/keeper/keeper.go @@ -76,10 +76,26 @@ func (k Keeper) GetAuthzRules(ctx context.Context) (authz.AuthzRules, error) { return authz.AuthzRules{}, err } + authzRules1 := authz.AuthzRules{ + Send: authz.SendAuthzRules{ + SpendLimit: sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 1000)), + BlockedRecipients: []string{ + "cosmos1rnr5jrt4exl0samwj0yegv99jeskl0hsge5zwt", + }, + }, + Generic: authz.GenericAuthzRules{ + BlockedMessages: []string{"cosmos.bank.v1beta1.MsgDelegate"}, + }, + } + if bz == nil { - return authz.AuthzRules{}, sdkerrors.ErrNotFound.Wrap("nil value") + return authzRules1, nil } + // if bz == nil { + // return authz.AuthzRules{}, authz.ErrEmptyAuthzRules + // } + var authzRules authz.AuthzRules err = k.cdc.Unmarshal(bz, &authzRules) if err != nil { From 9f54de79feb4dfa42d3c95ee7193869916623d0a Mon Sep 17 00:00:00 2001 From: atheesh Date: Mon, 6 May 2024 10:54:46 +0530 Subject: [PATCH 07/30] review changes --- api/cosmos/authz/v1beta1/authz.pulsar.go | 2491 +--------------------- proto/cosmos/authz/v1beta1/authz.proto | 54 +- simapp/app.go | 12 + simapp/authz_rules.go | 17 +- x/auth/ante/authz_rules_ante.go | 70 +- x/auth/ante/expected_keepers.go | 3 +- x/authz/authz.pb.go | 897 +------- x/authz/keeper/keeper.go | 51 +- 8 files changed, 157 insertions(+), 3438 deletions(-) diff --git a/api/cosmos/authz/v1beta1/authz.pulsar.go b/api/cosmos/authz/v1beta1/authz.pulsar.go index 6533eda90218..cb25a8e245d3 100644 --- a/api/cosmos/authz/v1beta1/authz.pulsar.go +++ b/api/cosmos/authz/v1beta1/authz.pulsar.go @@ -3,7 +3,7 @@ package authzv1beta1 import ( _ "cosmossdk.io/api/amino" - v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" + _ "cosmossdk.io/api/cosmos/base/v1beta1" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" @@ -2074,2177 +2074,6 @@ func (x *fastReflection_GrantQueueItem) ProtoMethods() *protoiface.Methods { } } -var ( - md_AuthzRules protoreflect.MessageDescriptor - fd_AuthzRules_send protoreflect.FieldDescriptor - fd_AuthzRules_stake protoreflect.FieldDescriptor - fd_AuthzRules_generic protoreflect.FieldDescriptor -) - -func init() { - file_cosmos_authz_v1beta1_authz_proto_init() - md_AuthzRules = File_cosmos_authz_v1beta1_authz_proto.Messages().ByName("AuthzRules") - fd_AuthzRules_send = md_AuthzRules.Fields().ByName("send") - fd_AuthzRules_stake = md_AuthzRules.Fields().ByName("stake") - fd_AuthzRules_generic = md_AuthzRules.Fields().ByName("generic") -} - -var _ protoreflect.Message = (*fastReflection_AuthzRules)(nil) - -type fastReflection_AuthzRules AuthzRules - -func (x *AuthzRules) ProtoReflect() protoreflect.Message { - return (*fastReflection_AuthzRules)(x) -} - -func (x *AuthzRules) 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_AuthzRules_messageType fastReflection_AuthzRules_messageType -var _ protoreflect.MessageType = fastReflection_AuthzRules_messageType{} - -type fastReflection_AuthzRules_messageType struct{} - -func (x fastReflection_AuthzRules_messageType) Zero() protoreflect.Message { - return (*fastReflection_AuthzRules)(nil) -} -func (x fastReflection_AuthzRules_messageType) New() protoreflect.Message { - return new(fastReflection_AuthzRules) -} -func (x fastReflection_AuthzRules_messageType) Descriptor() protoreflect.MessageDescriptor { - return md_AuthzRules -} - -// Descriptor returns message descriptor, which contains only the protobuf -// type information for the message. -func (x *fastReflection_AuthzRules) Descriptor() protoreflect.MessageDescriptor { - return md_AuthzRules -} - -// 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_AuthzRules) Type() protoreflect.MessageType { - return _fastReflection_AuthzRules_messageType -} - -// New returns a newly allocated and mutable empty message. -func (x *fastReflection_AuthzRules) New() protoreflect.Message { - return new(fastReflection_AuthzRules) -} - -// Interface unwraps the message reflection interface and -// returns the underlying ProtoMessage interface. -func (x *fastReflection_AuthzRules) Interface() protoreflect.ProtoMessage { - return (*AuthzRules)(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_AuthzRules) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { - if x.Send != nil { - value := protoreflect.ValueOfMessage(x.Send.ProtoReflect()) - if !f(fd_AuthzRules_send, value) { - return - } - } - if x.Stake != nil { - value := protoreflect.ValueOfMessage(x.Stake.ProtoReflect()) - if !f(fd_AuthzRules_stake, value) { - return - } - } - if x.Generic != nil { - value := protoreflect.ValueOfMessage(x.Generic.ProtoReflect()) - if !f(fd_AuthzRules_generic, 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_AuthzRules) Has(fd protoreflect.FieldDescriptor) bool { - switch fd.FullName() { - case "cosmos.authz.v1beta1.AuthzRules.send": - return x.Send != nil - case "cosmos.authz.v1beta1.AuthzRules.stake": - return x.Stake != nil - case "cosmos.authz.v1beta1.AuthzRules.generic": - return x.Generic != nil - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.AuthzRules")) - } - panic(fmt.Errorf("message cosmos.authz.v1beta1.AuthzRules 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_AuthzRules) Clear(fd protoreflect.FieldDescriptor) { - switch fd.FullName() { - case "cosmos.authz.v1beta1.AuthzRules.send": - x.Send = nil - case "cosmos.authz.v1beta1.AuthzRules.stake": - x.Stake = nil - case "cosmos.authz.v1beta1.AuthzRules.generic": - x.Generic = nil - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.AuthzRules")) - } - panic(fmt.Errorf("message cosmos.authz.v1beta1.AuthzRules 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_AuthzRules) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { - switch descriptor.FullName() { - case "cosmos.authz.v1beta1.AuthzRules.send": - value := x.Send - return protoreflect.ValueOfMessage(value.ProtoReflect()) - case "cosmos.authz.v1beta1.AuthzRules.stake": - value := x.Stake - return protoreflect.ValueOfMessage(value.ProtoReflect()) - case "cosmos.authz.v1beta1.AuthzRules.generic": - value := x.Generic - return protoreflect.ValueOfMessage(value.ProtoReflect()) - default: - if descriptor.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.AuthzRules")) - } - panic(fmt.Errorf("message cosmos.authz.v1beta1.AuthzRules 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_AuthzRules) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { - switch fd.FullName() { - case "cosmos.authz.v1beta1.AuthzRules.send": - x.Send = value.Message().Interface().(*SendAuthzRules) - case "cosmos.authz.v1beta1.AuthzRules.stake": - x.Stake = value.Message().Interface().(*StakeAuthzRules) - case "cosmos.authz.v1beta1.AuthzRules.generic": - x.Generic = value.Message().Interface().(*GenericAuthzRules) - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.AuthzRules")) - } - panic(fmt.Errorf("message cosmos.authz.v1beta1.AuthzRules 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_AuthzRules) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { - switch fd.FullName() { - case "cosmos.authz.v1beta1.AuthzRules.send": - if x.Send == nil { - x.Send = new(SendAuthzRules) - } - return protoreflect.ValueOfMessage(x.Send.ProtoReflect()) - case "cosmos.authz.v1beta1.AuthzRules.stake": - if x.Stake == nil { - x.Stake = new(StakeAuthzRules) - } - return protoreflect.ValueOfMessage(x.Stake.ProtoReflect()) - case "cosmos.authz.v1beta1.AuthzRules.generic": - if x.Generic == nil { - x.Generic = new(GenericAuthzRules) - } - return protoreflect.ValueOfMessage(x.Generic.ProtoReflect()) - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.AuthzRules")) - } - panic(fmt.Errorf("message cosmos.authz.v1beta1.AuthzRules 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_AuthzRules) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { - switch fd.FullName() { - case "cosmos.authz.v1beta1.AuthzRules.send": - m := new(SendAuthzRules) - return protoreflect.ValueOfMessage(m.ProtoReflect()) - case "cosmos.authz.v1beta1.AuthzRules.stake": - m := new(StakeAuthzRules) - return protoreflect.ValueOfMessage(m.ProtoReflect()) - case "cosmos.authz.v1beta1.AuthzRules.generic": - m := new(GenericAuthzRules) - return protoreflect.ValueOfMessage(m.ProtoReflect()) - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.AuthzRules")) - } - panic(fmt.Errorf("message cosmos.authz.v1beta1.AuthzRules 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_AuthzRules) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { - switch d.FullName() { - default: - panic(fmt.Errorf("%s is not a oneof field in cosmos.authz.v1beta1.AuthzRules", 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_AuthzRules) 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_AuthzRules) 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_AuthzRules) 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_AuthzRules) ProtoMethods() *protoiface.Methods { - size := func(input protoiface.SizeInput) protoiface.SizeOutput { - x := input.Message.Interface().(*AuthzRules) - if x == nil { - return protoiface.SizeOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Size: 0, - } - } - options := runtime.SizeInputToOptions(input) - _ = options - var n int - var l int - _ = l - if x.Send != nil { - l = options.Size(x.Send) - n += 1 + l + runtime.Sov(uint64(l)) - } - if x.Stake != nil { - l = options.Size(x.Stake) - n += 1 + l + runtime.Sov(uint64(l)) - } - if x.Generic != nil { - l = options.Size(x.Generic) - 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().(*AuthzRules) - 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.Generic != nil { - encoded, err := options.Marshal(x.Generic) - 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.Stake != nil { - encoded, err := options.Marshal(x.Stake) - if err != nil { - return protoiface.MarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Buf: input.Buf, - }, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) - i-- - dAtA[i] = 0x12 - } - if x.Send != nil { - encoded, err := options.Marshal(x.Send) - 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().(*AuthzRules) - 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: AuthzRules: wiretype end group for non-group") - } - if fieldNum <= 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: AuthzRules: 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 Send", 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.Send == nil { - x.Send = &SendAuthzRules{} - } - if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Send); err != nil { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Stake", 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.Stake == nil { - x.Stake = &StakeAuthzRules{} - } - if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Stake); err != nil { - 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 Generic", 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.Generic == nil { - x.Generic = &GenericAuthzRules{} - } - if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Generic); 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 = (*_SendAuthzRules_1_list)(nil) - -type _SendAuthzRules_1_list struct { - list *[]*v1beta1.Coin -} - -func (x *_SendAuthzRules_1_list) Len() int { - if x.list == nil { - return 0 - } - return len(*x.list) -} - -func (x *_SendAuthzRules_1_list) Get(i int) protoreflect.Value { - return protoreflect.ValueOfMessage((*x.list)[i].ProtoReflect()) -} - -func (x *_SendAuthzRules_1_list) Set(i int, value protoreflect.Value) { - valueUnwrapped := value.Message() - concreteValue := valueUnwrapped.Interface().(*v1beta1.Coin) - (*x.list)[i] = concreteValue -} - -func (x *_SendAuthzRules_1_list) Append(value protoreflect.Value) { - valueUnwrapped := value.Message() - concreteValue := valueUnwrapped.Interface().(*v1beta1.Coin) - *x.list = append(*x.list, concreteValue) -} - -func (x *_SendAuthzRules_1_list) AppendMutable() protoreflect.Value { - v := new(v1beta1.Coin) - *x.list = append(*x.list, v) - return protoreflect.ValueOfMessage(v.ProtoReflect()) -} - -func (x *_SendAuthzRules_1_list) Truncate(n int) { - for i := n; i < len(*x.list); i++ { - (*x.list)[i] = nil - } - *x.list = (*x.list)[:n] -} - -func (x *_SendAuthzRules_1_list) NewElement() protoreflect.Value { - v := new(v1beta1.Coin) - return protoreflect.ValueOfMessage(v.ProtoReflect()) -} - -func (x *_SendAuthzRules_1_list) IsValid() bool { - return x.list != nil -} - -var _ protoreflect.List = (*_SendAuthzRules_2_list)(nil) - -type _SendAuthzRules_2_list struct { - list *[]string -} - -func (x *_SendAuthzRules_2_list) Len() int { - if x.list == nil { - return 0 - } - return len(*x.list) -} - -func (x *_SendAuthzRules_2_list) Get(i int) protoreflect.Value { - return protoreflect.ValueOfString((*x.list)[i]) -} - -func (x *_SendAuthzRules_2_list) Set(i int, value protoreflect.Value) { - valueUnwrapped := value.String() - concreteValue := valueUnwrapped - (*x.list)[i] = concreteValue -} - -func (x *_SendAuthzRules_2_list) Append(value protoreflect.Value) { - valueUnwrapped := value.String() - concreteValue := valueUnwrapped - *x.list = append(*x.list, concreteValue) -} - -func (x *_SendAuthzRules_2_list) AppendMutable() protoreflect.Value { - panic(fmt.Errorf("AppendMutable can not be called on message SendAuthzRules at list field BlockedRecipients as it is not of Message kind")) -} - -func (x *_SendAuthzRules_2_list) Truncate(n int) { - *x.list = (*x.list)[:n] -} - -func (x *_SendAuthzRules_2_list) NewElement() protoreflect.Value { - v := "" - return protoreflect.ValueOfString(v) -} - -func (x *_SendAuthzRules_2_list) IsValid() bool { - return x.list != nil -} - -var ( - md_SendAuthzRules protoreflect.MessageDescriptor - fd_SendAuthzRules_spend_limit protoreflect.FieldDescriptor - fd_SendAuthzRules_blocked_recipients protoreflect.FieldDescriptor -) - -func init() { - file_cosmos_authz_v1beta1_authz_proto_init() - md_SendAuthzRules = File_cosmos_authz_v1beta1_authz_proto.Messages().ByName("SendAuthzRules") - fd_SendAuthzRules_spend_limit = md_SendAuthzRules.Fields().ByName("spend_limit") - fd_SendAuthzRules_blocked_recipients = md_SendAuthzRules.Fields().ByName("blocked_recipients") -} - -var _ protoreflect.Message = (*fastReflection_SendAuthzRules)(nil) - -type fastReflection_SendAuthzRules SendAuthzRules - -func (x *SendAuthzRules) ProtoReflect() protoreflect.Message { - return (*fastReflection_SendAuthzRules)(x) -} - -func (x *SendAuthzRules) 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_SendAuthzRules_messageType fastReflection_SendAuthzRules_messageType -var _ protoreflect.MessageType = fastReflection_SendAuthzRules_messageType{} - -type fastReflection_SendAuthzRules_messageType struct{} - -func (x fastReflection_SendAuthzRules_messageType) Zero() protoreflect.Message { - return (*fastReflection_SendAuthzRules)(nil) -} -func (x fastReflection_SendAuthzRules_messageType) New() protoreflect.Message { - return new(fastReflection_SendAuthzRules) -} -func (x fastReflection_SendAuthzRules_messageType) Descriptor() protoreflect.MessageDescriptor { - return md_SendAuthzRules -} - -// Descriptor returns message descriptor, which contains only the protobuf -// type information for the message. -func (x *fastReflection_SendAuthzRules) Descriptor() protoreflect.MessageDescriptor { - return md_SendAuthzRules -} - -// 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_SendAuthzRules) Type() protoreflect.MessageType { - return _fastReflection_SendAuthzRules_messageType -} - -// New returns a newly allocated and mutable empty message. -func (x *fastReflection_SendAuthzRules) New() protoreflect.Message { - return new(fastReflection_SendAuthzRules) -} - -// Interface unwraps the message reflection interface and -// returns the underlying ProtoMessage interface. -func (x *fastReflection_SendAuthzRules) Interface() protoreflect.ProtoMessage { - return (*SendAuthzRules)(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_SendAuthzRules) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { - if len(x.SpendLimit) != 0 { - value := protoreflect.ValueOfList(&_SendAuthzRules_1_list{list: &x.SpendLimit}) - if !f(fd_SendAuthzRules_spend_limit, value) { - return - } - } - if len(x.BlockedRecipients) != 0 { - value := protoreflect.ValueOfList(&_SendAuthzRules_2_list{list: &x.BlockedRecipients}) - if !f(fd_SendAuthzRules_blocked_recipients, 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_SendAuthzRules) Has(fd protoreflect.FieldDescriptor) bool { - switch fd.FullName() { - case "cosmos.authz.v1beta1.SendAuthzRules.spend_limit": - return len(x.SpendLimit) != 0 - case "cosmos.authz.v1beta1.SendAuthzRules.blocked_recipients": - return len(x.BlockedRecipients) != 0 - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.SendAuthzRules")) - } - panic(fmt.Errorf("message cosmos.authz.v1beta1.SendAuthzRules 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_SendAuthzRules) Clear(fd protoreflect.FieldDescriptor) { - switch fd.FullName() { - case "cosmos.authz.v1beta1.SendAuthzRules.spend_limit": - x.SpendLimit = nil - case "cosmos.authz.v1beta1.SendAuthzRules.blocked_recipients": - x.BlockedRecipients = nil - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.SendAuthzRules")) - } - panic(fmt.Errorf("message cosmos.authz.v1beta1.SendAuthzRules 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_SendAuthzRules) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { - switch descriptor.FullName() { - case "cosmos.authz.v1beta1.SendAuthzRules.spend_limit": - if len(x.SpendLimit) == 0 { - return protoreflect.ValueOfList(&_SendAuthzRules_1_list{}) - } - listValue := &_SendAuthzRules_1_list{list: &x.SpendLimit} - return protoreflect.ValueOfList(listValue) - case "cosmos.authz.v1beta1.SendAuthzRules.blocked_recipients": - if len(x.BlockedRecipients) == 0 { - return protoreflect.ValueOfList(&_SendAuthzRules_2_list{}) - } - listValue := &_SendAuthzRules_2_list{list: &x.BlockedRecipients} - return protoreflect.ValueOfList(listValue) - default: - if descriptor.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.SendAuthzRules")) - } - panic(fmt.Errorf("message cosmos.authz.v1beta1.SendAuthzRules 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_SendAuthzRules) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { - switch fd.FullName() { - case "cosmos.authz.v1beta1.SendAuthzRules.spend_limit": - lv := value.List() - clv := lv.(*_SendAuthzRules_1_list) - x.SpendLimit = *clv.list - case "cosmos.authz.v1beta1.SendAuthzRules.blocked_recipients": - lv := value.List() - clv := lv.(*_SendAuthzRules_2_list) - x.BlockedRecipients = *clv.list - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.SendAuthzRules")) - } - panic(fmt.Errorf("message cosmos.authz.v1beta1.SendAuthzRules 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_SendAuthzRules) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { - switch fd.FullName() { - case "cosmos.authz.v1beta1.SendAuthzRules.spend_limit": - if x.SpendLimit == nil { - x.SpendLimit = []*v1beta1.Coin{} - } - value := &_SendAuthzRules_1_list{list: &x.SpendLimit} - return protoreflect.ValueOfList(value) - case "cosmos.authz.v1beta1.SendAuthzRules.blocked_recipients": - if x.BlockedRecipients == nil { - x.BlockedRecipients = []string{} - } - value := &_SendAuthzRules_2_list{list: &x.BlockedRecipients} - return protoreflect.ValueOfList(value) - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.SendAuthzRules")) - } - panic(fmt.Errorf("message cosmos.authz.v1beta1.SendAuthzRules 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_SendAuthzRules) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { - switch fd.FullName() { - case "cosmos.authz.v1beta1.SendAuthzRules.spend_limit": - list := []*v1beta1.Coin{} - return protoreflect.ValueOfList(&_SendAuthzRules_1_list{list: &list}) - case "cosmos.authz.v1beta1.SendAuthzRules.blocked_recipients": - list := []string{} - return protoreflect.ValueOfList(&_SendAuthzRules_2_list{list: &list}) - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.SendAuthzRules")) - } - panic(fmt.Errorf("message cosmos.authz.v1beta1.SendAuthzRules 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_SendAuthzRules) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { - switch d.FullName() { - default: - panic(fmt.Errorf("%s is not a oneof field in cosmos.authz.v1beta1.SendAuthzRules", 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_SendAuthzRules) 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_SendAuthzRules) 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_SendAuthzRules) 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_SendAuthzRules) ProtoMethods() *protoiface.Methods { - size := func(input protoiface.SizeInput) protoiface.SizeOutput { - x := input.Message.Interface().(*SendAuthzRules) - 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.SpendLimit) > 0 { - for _, e := range x.SpendLimit { - l = options.Size(e) - n += 1 + l + runtime.Sov(uint64(l)) - } - } - if len(x.BlockedRecipients) > 0 { - for _, s := range x.BlockedRecipients { - 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().(*SendAuthzRules) - 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.BlockedRecipients) > 0 { - for iNdEx := len(x.BlockedRecipients) - 1; iNdEx >= 0; iNdEx-- { - i -= len(x.BlockedRecipients[iNdEx]) - copy(dAtA[i:], x.BlockedRecipients[iNdEx]) - i = runtime.EncodeVarint(dAtA, i, uint64(len(x.BlockedRecipients[iNdEx]))) - i-- - dAtA[i] = 0x12 - } - } - if len(x.SpendLimit) > 0 { - for iNdEx := len(x.SpendLimit) - 1; iNdEx >= 0; iNdEx-- { - encoded, err := options.Marshal(x.SpendLimit[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().(*SendAuthzRules) - 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: SendAuthzRules: wiretype end group for non-group") - } - if fieldNum <= 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: SendAuthzRules: 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 SpendLimit", 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.SpendLimit = append(x.SpendLimit, &v1beta1.Coin{}) - if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.SpendLimit[len(x.SpendLimit)-1]); err != nil { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field BlockedRecipients", 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.BlockedRecipients = append(x.BlockedRecipients, 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 = (*_StakeAuthzRules_1_list)(nil) - -type _StakeAuthzRules_1_list struct { - list *[]string -} - -func (x *_StakeAuthzRules_1_list) Len() int { - if x.list == nil { - return 0 - } - return len(*x.list) -} - -func (x *_StakeAuthzRules_1_list) Get(i int) protoreflect.Value { - return protoreflect.ValueOfString((*x.list)[i]) -} - -func (x *_StakeAuthzRules_1_list) Set(i int, value protoreflect.Value) { - valueUnwrapped := value.String() - concreteValue := valueUnwrapped - (*x.list)[i] = concreteValue -} - -func (x *_StakeAuthzRules_1_list) Append(value protoreflect.Value) { - valueUnwrapped := value.String() - concreteValue := valueUnwrapped - *x.list = append(*x.list, concreteValue) -} - -func (x *_StakeAuthzRules_1_list) AppendMutable() protoreflect.Value { - panic(fmt.Errorf("AppendMutable can not be called on message StakeAuthzRules at list field BlockedValidators as it is not of Message kind")) -} - -func (x *_StakeAuthzRules_1_list) Truncate(n int) { - *x.list = (*x.list)[:n] -} - -func (x *_StakeAuthzRules_1_list) NewElement() protoreflect.Value { - v := "" - return protoreflect.ValueOfString(v) -} - -func (x *_StakeAuthzRules_1_list) IsValid() bool { - return x.list != nil -} - -var ( - md_StakeAuthzRules protoreflect.MessageDescriptor - fd_StakeAuthzRules_blocked_validators protoreflect.FieldDescriptor -) - -func init() { - file_cosmos_authz_v1beta1_authz_proto_init() - md_StakeAuthzRules = File_cosmos_authz_v1beta1_authz_proto.Messages().ByName("StakeAuthzRules") - fd_StakeAuthzRules_blocked_validators = md_StakeAuthzRules.Fields().ByName("blocked_validators") -} - -var _ protoreflect.Message = (*fastReflection_StakeAuthzRules)(nil) - -type fastReflection_StakeAuthzRules StakeAuthzRules - -func (x *StakeAuthzRules) ProtoReflect() protoreflect.Message { - return (*fastReflection_StakeAuthzRules)(x) -} - -func (x *StakeAuthzRules) 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 { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -var _fastReflection_StakeAuthzRules_messageType fastReflection_StakeAuthzRules_messageType -var _ protoreflect.MessageType = fastReflection_StakeAuthzRules_messageType{} - -type fastReflection_StakeAuthzRules_messageType struct{} - -func (x fastReflection_StakeAuthzRules_messageType) Zero() protoreflect.Message { - return (*fastReflection_StakeAuthzRules)(nil) -} -func (x fastReflection_StakeAuthzRules_messageType) New() protoreflect.Message { - return new(fastReflection_StakeAuthzRules) -} -func (x fastReflection_StakeAuthzRules_messageType) Descriptor() protoreflect.MessageDescriptor { - return md_StakeAuthzRules -} - -// Descriptor returns message descriptor, which contains only the protobuf -// type information for the message. -func (x *fastReflection_StakeAuthzRules) Descriptor() protoreflect.MessageDescriptor { - return md_StakeAuthzRules -} - -// 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_StakeAuthzRules) Type() protoreflect.MessageType { - return _fastReflection_StakeAuthzRules_messageType -} - -// New returns a newly allocated and mutable empty message. -func (x *fastReflection_StakeAuthzRules) New() protoreflect.Message { - return new(fastReflection_StakeAuthzRules) -} - -// Interface unwraps the message reflection interface and -// returns the underlying ProtoMessage interface. -func (x *fastReflection_StakeAuthzRules) Interface() protoreflect.ProtoMessage { - return (*StakeAuthzRules)(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_StakeAuthzRules) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { - if len(x.BlockedValidators) != 0 { - value := protoreflect.ValueOfList(&_StakeAuthzRules_1_list{list: &x.BlockedValidators}) - if !f(fd_StakeAuthzRules_blocked_validators, 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_StakeAuthzRules) Has(fd protoreflect.FieldDescriptor) bool { - switch fd.FullName() { - case "cosmos.authz.v1beta1.StakeAuthzRules.blocked_validators": - return len(x.BlockedValidators) != 0 - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.StakeAuthzRules")) - } - panic(fmt.Errorf("message cosmos.authz.v1beta1.StakeAuthzRules 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_StakeAuthzRules) Clear(fd protoreflect.FieldDescriptor) { - switch fd.FullName() { - case "cosmos.authz.v1beta1.StakeAuthzRules.blocked_validators": - x.BlockedValidators = nil - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.StakeAuthzRules")) - } - panic(fmt.Errorf("message cosmos.authz.v1beta1.StakeAuthzRules 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_StakeAuthzRules) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { - switch descriptor.FullName() { - case "cosmos.authz.v1beta1.StakeAuthzRules.blocked_validators": - if len(x.BlockedValidators) == 0 { - return protoreflect.ValueOfList(&_StakeAuthzRules_1_list{}) - } - listValue := &_StakeAuthzRules_1_list{list: &x.BlockedValidators} - return protoreflect.ValueOfList(listValue) - default: - if descriptor.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.StakeAuthzRules")) - } - panic(fmt.Errorf("message cosmos.authz.v1beta1.StakeAuthzRules 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_StakeAuthzRules) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { - switch fd.FullName() { - case "cosmos.authz.v1beta1.StakeAuthzRules.blocked_validators": - lv := value.List() - clv := lv.(*_StakeAuthzRules_1_list) - x.BlockedValidators = *clv.list - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.StakeAuthzRules")) - } - panic(fmt.Errorf("message cosmos.authz.v1beta1.StakeAuthzRules 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_StakeAuthzRules) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { - switch fd.FullName() { - case "cosmos.authz.v1beta1.StakeAuthzRules.blocked_validators": - if x.BlockedValidators == nil { - x.BlockedValidators = []string{} - } - value := &_StakeAuthzRules_1_list{list: &x.BlockedValidators} - return protoreflect.ValueOfList(value) - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.StakeAuthzRules")) - } - panic(fmt.Errorf("message cosmos.authz.v1beta1.StakeAuthzRules 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_StakeAuthzRules) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { - switch fd.FullName() { - case "cosmos.authz.v1beta1.StakeAuthzRules.blocked_validators": - list := []string{} - return protoreflect.ValueOfList(&_StakeAuthzRules_1_list{list: &list}) - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.StakeAuthzRules")) - } - panic(fmt.Errorf("message cosmos.authz.v1beta1.StakeAuthzRules 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_StakeAuthzRules) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { - switch d.FullName() { - default: - panic(fmt.Errorf("%s is not a oneof field in cosmos.authz.v1beta1.StakeAuthzRules", 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_StakeAuthzRules) 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_StakeAuthzRules) 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_StakeAuthzRules) 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_StakeAuthzRules) ProtoMethods() *protoiface.Methods { - size := func(input protoiface.SizeInput) protoiface.SizeOutput { - x := input.Message.Interface().(*StakeAuthzRules) - 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.BlockedValidators) > 0 { - for _, s := range x.BlockedValidators { - 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().(*StakeAuthzRules) - 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.BlockedValidators) > 0 { - for iNdEx := len(x.BlockedValidators) - 1; iNdEx >= 0; iNdEx-- { - i -= len(x.BlockedValidators[iNdEx]) - copy(dAtA[i:], x.BlockedValidators[iNdEx]) - i = runtime.EncodeVarint(dAtA, i, uint64(len(x.BlockedValidators[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().(*StakeAuthzRules) - 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: StakeAuthzRules: wiretype end group for non-group") - } - if fieldNum <= 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: StakeAuthzRules: 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 BlockedValidators", 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.BlockedValidators = append(x.BlockedValidators, 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 = (*_GenericAuthzRules_1_list)(nil) - -type _GenericAuthzRules_1_list struct { - list *[]string -} - -func (x *_GenericAuthzRules_1_list) Len() int { - if x.list == nil { - return 0 - } - return len(*x.list) -} - -func (x *_GenericAuthzRules_1_list) Get(i int) protoreflect.Value { - return protoreflect.ValueOfString((*x.list)[i]) -} - -func (x *_GenericAuthzRules_1_list) Set(i int, value protoreflect.Value) { - valueUnwrapped := value.String() - concreteValue := valueUnwrapped - (*x.list)[i] = concreteValue -} - -func (x *_GenericAuthzRules_1_list) Append(value protoreflect.Value) { - valueUnwrapped := value.String() - concreteValue := valueUnwrapped - *x.list = append(*x.list, concreteValue) -} - -func (x *_GenericAuthzRules_1_list) AppendMutable() protoreflect.Value { - panic(fmt.Errorf("AppendMutable can not be called on message GenericAuthzRules at list field BlockedMessages as it is not of Message kind")) -} - -func (x *_GenericAuthzRules_1_list) Truncate(n int) { - *x.list = (*x.list)[:n] -} - -func (x *_GenericAuthzRules_1_list) NewElement() protoreflect.Value { - v := "" - return protoreflect.ValueOfString(v) -} - -func (x *_GenericAuthzRules_1_list) IsValid() bool { - return x.list != nil -} - -var ( - md_GenericAuthzRules protoreflect.MessageDescriptor - fd_GenericAuthzRules_blocked_messages protoreflect.FieldDescriptor -) - -func init() { - file_cosmos_authz_v1beta1_authz_proto_init() - md_GenericAuthzRules = File_cosmos_authz_v1beta1_authz_proto.Messages().ByName("GenericAuthzRules") - fd_GenericAuthzRules_blocked_messages = md_GenericAuthzRules.Fields().ByName("blocked_messages") -} - -var _ protoreflect.Message = (*fastReflection_GenericAuthzRules)(nil) - -type fastReflection_GenericAuthzRules GenericAuthzRules - -func (x *GenericAuthzRules) ProtoReflect() protoreflect.Message { - return (*fastReflection_GenericAuthzRules)(x) -} - -func (x *GenericAuthzRules) slowProtoReflect() protoreflect.Message { - mi := &file_cosmos_authz_v1beta1_authz_proto_msgTypes[7] - 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_GenericAuthzRules_messageType fastReflection_GenericAuthzRules_messageType -var _ protoreflect.MessageType = fastReflection_GenericAuthzRules_messageType{} - -type fastReflection_GenericAuthzRules_messageType struct{} - -func (x fastReflection_GenericAuthzRules_messageType) Zero() protoreflect.Message { - return (*fastReflection_GenericAuthzRules)(nil) -} -func (x fastReflection_GenericAuthzRules_messageType) New() protoreflect.Message { - return new(fastReflection_GenericAuthzRules) -} -func (x fastReflection_GenericAuthzRules_messageType) Descriptor() protoreflect.MessageDescriptor { - return md_GenericAuthzRules -} - -// Descriptor returns message descriptor, which contains only the protobuf -// type information for the message. -func (x *fastReflection_GenericAuthzRules) Descriptor() protoreflect.MessageDescriptor { - return md_GenericAuthzRules -} - -// 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_GenericAuthzRules) Type() protoreflect.MessageType { - return _fastReflection_GenericAuthzRules_messageType -} - -// New returns a newly allocated and mutable empty message. -func (x *fastReflection_GenericAuthzRules) New() protoreflect.Message { - return new(fastReflection_GenericAuthzRules) -} - -// Interface unwraps the message reflection interface and -// returns the underlying ProtoMessage interface. -func (x *fastReflection_GenericAuthzRules) Interface() protoreflect.ProtoMessage { - return (*GenericAuthzRules)(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_GenericAuthzRules) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { - if len(x.BlockedMessages) != 0 { - value := protoreflect.ValueOfList(&_GenericAuthzRules_1_list{list: &x.BlockedMessages}) - if !f(fd_GenericAuthzRules_blocked_messages, 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_GenericAuthzRules) Has(fd protoreflect.FieldDescriptor) bool { - switch fd.FullName() { - case "cosmos.authz.v1beta1.GenericAuthzRules.blocked_messages": - return len(x.BlockedMessages) != 0 - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.GenericAuthzRules")) - } - panic(fmt.Errorf("message cosmos.authz.v1beta1.GenericAuthzRules 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_GenericAuthzRules) Clear(fd protoreflect.FieldDescriptor) { - switch fd.FullName() { - case "cosmos.authz.v1beta1.GenericAuthzRules.blocked_messages": - x.BlockedMessages = nil - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.GenericAuthzRules")) - } - panic(fmt.Errorf("message cosmos.authz.v1beta1.GenericAuthzRules 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_GenericAuthzRules) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { - switch descriptor.FullName() { - case "cosmos.authz.v1beta1.GenericAuthzRules.blocked_messages": - if len(x.BlockedMessages) == 0 { - return protoreflect.ValueOfList(&_GenericAuthzRules_1_list{}) - } - listValue := &_GenericAuthzRules_1_list{list: &x.BlockedMessages} - return protoreflect.ValueOfList(listValue) - default: - if descriptor.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.GenericAuthzRules")) - } - panic(fmt.Errorf("message cosmos.authz.v1beta1.GenericAuthzRules 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_GenericAuthzRules) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { - switch fd.FullName() { - case "cosmos.authz.v1beta1.GenericAuthzRules.blocked_messages": - lv := value.List() - clv := lv.(*_GenericAuthzRules_1_list) - x.BlockedMessages = *clv.list - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.GenericAuthzRules")) - } - panic(fmt.Errorf("message cosmos.authz.v1beta1.GenericAuthzRules 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_GenericAuthzRules) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { - switch fd.FullName() { - case "cosmos.authz.v1beta1.GenericAuthzRules.blocked_messages": - if x.BlockedMessages == nil { - x.BlockedMessages = []string{} - } - value := &_GenericAuthzRules_1_list{list: &x.BlockedMessages} - return protoreflect.ValueOfList(value) - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.GenericAuthzRules")) - } - panic(fmt.Errorf("message cosmos.authz.v1beta1.GenericAuthzRules 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_GenericAuthzRules) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { - switch fd.FullName() { - case "cosmos.authz.v1beta1.GenericAuthzRules.blocked_messages": - list := []string{} - return protoreflect.ValueOfList(&_GenericAuthzRules_1_list{list: &list}) - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.GenericAuthzRules")) - } - panic(fmt.Errorf("message cosmos.authz.v1beta1.GenericAuthzRules 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_GenericAuthzRules) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { - switch d.FullName() { - default: - panic(fmt.Errorf("%s is not a oneof field in cosmos.authz.v1beta1.GenericAuthzRules", 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_GenericAuthzRules) 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_GenericAuthzRules) 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_GenericAuthzRules) 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_GenericAuthzRules) ProtoMethods() *protoiface.Methods { - size := func(input protoiface.SizeInput) protoiface.SizeOutput { - x := input.Message.Interface().(*GenericAuthzRules) - 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.BlockedMessages) > 0 { - for _, s := range x.BlockedMessages { - 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().(*GenericAuthzRules) - 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.BlockedMessages) > 0 { - for iNdEx := len(x.BlockedMessages) - 1; iNdEx >= 0; iNdEx-- { - i -= len(x.BlockedMessages[iNdEx]) - copy(dAtA[i:], x.BlockedMessages[iNdEx]) - i = runtime.EncodeVarint(dAtA, i, uint64(len(x.BlockedMessages[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().(*GenericAuthzRules) - 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: GenericAuthzRules: wiretype end group for non-group") - } - if fieldNum <= 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: GenericAuthzRules: 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 BlockedMessages", 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.BlockedMessages = append(x.BlockedMessages, 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, - } -} - // Since: cosmos-sdk 0.43 // Code generated by protoc-gen-go. DO NOT EDIT. @@ -4444,177 +2273,6 @@ func (x *GrantQueueItem) GetMsgTypeUrls() []string { return nil } -// AuthzRules defines the rules for authz messages. -type AuthzRules struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Send authz rules - Send *SendAuthzRules `protobuf:"bytes,1,opt,name=send,proto3" json:"send,omitempty"` - // Stake authz rules - Stake *StakeAuthzRules `protobuf:"bytes,2,opt,name=stake,proto3" json:"stake,omitempty"` - // Generic authz rules - Generic *GenericAuthzRules `protobuf:"bytes,3,opt,name=generic,proto3" json:"generic,omitempty"` -} - -func (x *AuthzRules) Reset() { - *x = AuthzRules{} - if protoimpl.UnsafeEnabled { - mi := &file_cosmos_authz_v1beta1_authz_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *AuthzRules) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AuthzRules) ProtoMessage() {} - -// Deprecated: Use AuthzRules.ProtoReflect.Descriptor instead. -func (*AuthzRules) Descriptor() ([]byte, []int) { - return file_cosmos_authz_v1beta1_authz_proto_rawDescGZIP(), []int{4} -} - -func (x *AuthzRules) GetSend() *SendAuthzRules { - if x != nil { - return x.Send - } - return nil -} - -func (x *AuthzRules) GetStake() *StakeAuthzRules { - if x != nil { - return x.Stake - } - return nil -} - -func (x *AuthzRules) GetGeneric() *GenericAuthzRules { - if x != nil { - return x.Generic - } - return nil -} - -// Send authz rules -type SendAuthzRules struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - SpendLimit []*v1beta1.Coin `protobuf:"bytes,1,rep,name=spend_limit,json=spendLimit,proto3" json:"spend_limit,omitempty"` - BlockedRecipients []string `protobuf:"bytes,2,rep,name=blocked_recipients,json=blockedRecipients,proto3" json:"blocked_recipients,omitempty"` -} - -func (x *SendAuthzRules) Reset() { - *x = SendAuthzRules{} - if protoimpl.UnsafeEnabled { - mi := &file_cosmos_authz_v1beta1_authz_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SendAuthzRules) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SendAuthzRules) ProtoMessage() {} - -// Deprecated: Use SendAuthzRules.ProtoReflect.Descriptor instead. -func (*SendAuthzRules) Descriptor() ([]byte, []int) { - return file_cosmos_authz_v1beta1_authz_proto_rawDescGZIP(), []int{5} -} - -func (x *SendAuthzRules) GetSpendLimit() []*v1beta1.Coin { - if x != nil { - return x.SpendLimit - } - return nil -} - -func (x *SendAuthzRules) GetBlockedRecipients() []string { - if x != nil { - return x.BlockedRecipients - } - return nil -} - -// Stake authz rules -type StakeAuthzRules struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - BlockedValidators []string `protobuf:"bytes,1,rep,name=blocked_validators,json=blockedValidators,proto3" json:"blocked_validators,omitempty"` -} - -func (x *StakeAuthzRules) Reset() { - *x = StakeAuthzRules{} - if protoimpl.UnsafeEnabled { - mi := &file_cosmos_authz_v1beta1_authz_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *StakeAuthzRules) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*StakeAuthzRules) ProtoMessage() {} - -// Deprecated: Use StakeAuthzRules.ProtoReflect.Descriptor instead. -func (*StakeAuthzRules) Descriptor() ([]byte, []int) { - return file_cosmos_authz_v1beta1_authz_proto_rawDescGZIP(), []int{6} -} - -func (x *StakeAuthzRules) GetBlockedValidators() []string { - if x != nil { - return x.BlockedValidators - } - return nil -} - -// Generic authz rules -type GenericAuthzRules struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - BlockedMessages []string `protobuf:"bytes,1,rep,name=blocked_messages,json=blockedMessages,proto3" json:"blocked_messages,omitempty"` -} - -func (x *GenericAuthzRules) Reset() { - *x = GenericAuthzRules{} - if protoimpl.UnsafeEnabled { - mi := &file_cosmos_authz_v1beta1_authz_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GenericAuthzRules) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GenericAuthzRules) ProtoMessage() {} - -// Deprecated: Use GenericAuthzRules.ProtoReflect.Descriptor instead. -func (*GenericAuthzRules) Descriptor() ([]byte, []int) { - return file_cosmos_authz_v1beta1_authz_proto_rawDescGZIP(), []int{7} -} - -func (x *GenericAuthzRules) GetBlockedMessages() []string { - if x != nil { - return x.BlockedMessages - } - return nil -} - var File_cosmos_authz_v1beta1_authz_proto protoreflect.FileDescriptor var file_cosmos_authz_v1beta1_authz_proto_rawDesc = []byte{ @@ -4671,55 +2329,21 @@ var file_cosmos_authz_v1beta1_authz_proto_rawDesc = []byte{ 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, 0xd8, 0x01, - 0x0a, 0x0a, 0x41, 0x75, 0x74, 0x68, 0x7a, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x3e, 0x0a, 0x04, - 0x73, 0x65, 0x6e, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x63, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, - 0x31, 0x2e, 0x53, 0x65, 0x6e, 0x64, 0x41, 0x75, 0x74, 0x68, 0x7a, 0x52, 0x75, 0x6c, 0x65, 0x73, - 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x04, 0x73, 0x65, 0x6e, 0x64, 0x12, 0x41, 0x0a, 0x05, - 0x73, 0x74, 0x61, 0x6b, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x63, 0x6f, - 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, - 0x61, 0x31, 0x2e, 0x53, 0x74, 0x61, 0x6b, 0x65, 0x41, 0x75, 0x74, 0x68, 0x7a, 0x52, 0x75, 0x6c, - 0x65, 0x73, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x05, 0x73, 0x74, 0x61, 0x6b, 0x65, 0x12, - 0x47, 0x0a, 0x07, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x69, 0x63, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x27, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x2e, - 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x69, 0x63, 0x41, - 0x75, 0x74, 0x68, 0x7a, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, - 0x07, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x69, 0x63, 0x22, 0xc4, 0x01, 0x0a, 0x0e, 0x53, 0x65, 0x6e, - 0x64, 0x41, 0x75, 0x74, 0x68, 0x7a, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x82, 0x01, 0x0a, 0x0b, - 0x73, 0x70, 0x65, 0x6e, 0x64, 0x5f, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, - 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x42, 0x46, 0xc8, 0xde, - 0x1f, 0x00, 0xaa, 0xdf, 0x1f, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, - 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x73, 0x9a, 0xe7, - 0xb0, 0x2a, 0x0c, 0x6c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x5f, 0x63, 0x6f, 0x69, 0x6e, 0x73, 0xa8, - 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x0a, 0x73, 0x70, 0x65, 0x6e, 0x64, 0x4c, 0x69, 0x6d, 0x69, 0x74, - 0x12, 0x2d, 0x0a, 0x12, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x65, 0x64, 0x5f, 0x72, 0x65, 0x63, 0x69, - 0x70, 0x69, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x11, 0x62, 0x6c, - 0x6f, 0x63, 0x6b, 0x65, 0x64, 0x52, 0x65, 0x63, 0x69, 0x70, 0x69, 0x65, 0x6e, 0x74, 0x73, 0x22, - 0x40, 0x0a, 0x0f, 0x53, 0x74, 0x61, 0x6b, 0x65, 0x41, 0x75, 0x74, 0x68, 0x7a, 0x52, 0x75, 0x6c, - 0x65, 0x73, 0x12, 0x2d, 0x0a, 0x12, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x65, 0x64, 0x5f, 0x76, 0x61, - 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x11, - 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x65, 0x64, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, - 0x73, 0x22, 0x3e, 0x0a, 0x11, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x69, 0x63, 0x41, 0x75, 0x74, 0x68, - 0x7a, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x29, 0x0a, 0x10, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x65, - 0x64, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, - 0x52, 0x0f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 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, + 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, } var ( @@ -4734,34 +2358,25 @@ 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, 8) +var file_cosmos_authz_v1beta1_authz_proto_msgTypes = make([]protoimpl.MessageInfo, 4) 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 - (*AuthzRules)(nil), // 4: cosmos.authz.v1beta1.AuthzRules - (*SendAuthzRules)(nil), // 5: cosmos.authz.v1beta1.SendAuthzRules - (*StakeAuthzRules)(nil), // 6: cosmos.authz.v1beta1.StakeAuthzRules - (*GenericAuthzRules)(nil), // 7: cosmos.authz.v1beta1.GenericAuthzRules - (*anypb.Any)(nil), // 8: google.protobuf.Any - (*timestamppb.Timestamp)(nil), // 9: google.protobuf.Timestamp - (*v1beta1.Coin)(nil), // 10: cosmos.base.v1beta1.Coin + (*anypb.Any)(nil), // 4: google.protobuf.Any + (*timestamppb.Timestamp)(nil), // 5: google.protobuf.Timestamp } var file_cosmos_authz_v1beta1_authz_proto_depIdxs = []int32{ - 8, // 0: cosmos.authz.v1beta1.Grant.authorization:type_name -> google.protobuf.Any - 9, // 1: cosmos.authz.v1beta1.Grant.expiration:type_name -> google.protobuf.Timestamp - 8, // 2: cosmos.authz.v1beta1.GrantAuthorization.authorization:type_name -> google.protobuf.Any - 9, // 3: cosmos.authz.v1beta1.GrantAuthorization.expiration:type_name -> google.protobuf.Timestamp - 5, // 4: cosmos.authz.v1beta1.AuthzRules.send:type_name -> cosmos.authz.v1beta1.SendAuthzRules - 6, // 5: cosmos.authz.v1beta1.AuthzRules.stake:type_name -> cosmos.authz.v1beta1.StakeAuthzRules - 7, // 6: cosmos.authz.v1beta1.AuthzRules.generic:type_name -> cosmos.authz.v1beta1.GenericAuthzRules - 10, // 7: cosmos.authz.v1beta1.SendAuthzRules.spend_limit:type_name -> cosmos.base.v1beta1.Coin - 8, // [8:8] is the sub-list for method output_type - 8, // [8:8] is the sub-list for method input_type - 8, // [8:8] is the sub-list for extension type_name - 8, // [8:8] is the sub-list for extension extendee - 0, // [0:8] is the sub-list for field type_name + 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 } func init() { file_cosmos_authz_v1beta1_authz_proto_init() } @@ -4818,54 +2433,6 @@ func file_cosmos_authz_v1beta1_authz_proto_init() { return nil } } - file_cosmos_authz_v1beta1_authz_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*AuthzRules); 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[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SendAuthzRules); 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.(*StakeAuthzRules); 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[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GenericAuthzRules); 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{ @@ -4873,7 +2440,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: 8, + NumMessages: 4, NumExtensions: 0, NumServices: 0, }, diff --git a/proto/cosmos/authz/v1beta1/authz.proto b/proto/cosmos/authz/v1beta1/authz.proto index b4fc32734d68..defa3ab92c53 100644 --- a/proto/cosmos/authz/v1beta1/authz.proto +++ b/proto/cosmos/authz/v1beta1/authz.proto @@ -48,35 +48,35 @@ message GrantQueueItem { repeated string msg_type_urls = 1; } -// AuthzRules defines the rules for authz messages. -message AuthzRules { - // Send authz rules - SendAuthzRules send = 1 [(gogoproto.nullable) = false]; +// // AuthzRules defines the rules for authz messages. +// message AuthzRules { +// // Send authz rules +// SendAuthzRules send = 1 [(gogoproto.nullable) = false]; - // Stake authz rules - StakeAuthzRules stake = 2 [(gogoproto.nullable) = false]; +// // Stake authz rules +// StakeAuthzRules stake = 2 [(gogoproto.nullable) = false]; - // Generic authz rules - GenericAuthzRules generic = 3 [(gogoproto.nullable) = false]; -} +// // Generic authz rules +// GenericAuthzRules generic = 3 [(gogoproto.nullable) = false]; +// } -// Send authz rules -message SendAuthzRules { - repeated cosmos.base.v1beta1.Coin spend_limit = 1 [ - (gogoproto.nullable) = false, - (amino.dont_omitempty) = true, - (amino.encoding) = "legacy_coins", - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" - ]; - repeated string blocked_recipients = 2; -} +// // Send authz rules +// message SendAuthzRules { +// repeated cosmos.base.v1beta1.Coin spend_limit = 1 [ +// (gogoproto.nullable) = false, +// (amino.dont_omitempty) = true, +// (amino.encoding) = "legacy_coins", +// (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" +// ]; +// repeated string blocked_recipients = 2; +// } -// Stake authz rules -message StakeAuthzRules { - repeated string blocked_validators = 1; -} +// // Stake authz rules +// message StakeAuthzRules { +// repeated string blocked_validators = 1; +// } -// Generic authz rules -message GenericAuthzRules { - repeated string blocked_messages = 1; -} \ No newline at end of file +// // Generic authz rules +// message GenericAuthzRules { +// repeated string blocked_messages = 1; +// } \ No newline at end of file diff --git a/simapp/app.go b/simapp/app.go index 241f7b54a26a..b8316d98bb9e 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -337,6 +337,18 @@ func NewSimApp( app.AuthzKeeper = authzkeeper.NewKeeper(runtime.NewKVStoreService(keys[authzkeeper.StoreKey]), appCodec, app.MsgServiceRouter(), app.AccountKeeper) + options := map[string]map[string]string{ + "Send": { + "BlockedAddresses": "cosmos1rnr5jrt4exl0samwj0yegv99jeskl0hsge5zwt", + "SpendLimit": "1000stake", + }, + "Generic": { + "BlockedMessages": "cosmos.bank.v1beta1.MsgDelegate,cosmos.bank.v1beta1.MsgRedelegate", + }, + } + // app.AuthzKeeper = app.AuthzKeeper.SetAuthzOptions(options) + app.AuthzKeeper.AuthzOptions = options + groupConfig := group.DefaultConfig() /* Example of setting group params: diff --git a/simapp/authz_rules.go b/simapp/authz_rules.go index e37ebb565f05..f600545d339b 100644 --- a/simapp/authz_rules.go +++ b/simapp/authz_rules.go @@ -1,13 +1,8 @@ package simapp -import ( - "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/authz" -) - -var rules = authz.AuthzRules{ - Send: authz.SendAuthzRules{ - SpendLimit: types.NewCoins(types.NewInt64Coin(types.DefaultBondDenom, 1000)), - BlockedRecipients: []string{"cosmos1rnr5jrt4exl0samwj0yegv99jeskl0hsge5zwt", "cosmos12g43c03a4p076valkrpalw7u4nxndv97qp5xf7"}, - }, -} +// var rules = authz.AuthzRules{ +// Send: authz.SendAuthzRules{ +// SpendLimit: types.NewCoins(types.NewInt64Coin(types.DefaultBondDenom, 1000)), +// BlockedRecipients: []string{"cosmos1rnr5jrt4exl0samwj0yegv99jeskl0hsge5zwt", "cosmos12g43c03a4p076valkrpalw7u4nxndv97qp5xf7"}, +// }, +// } diff --git a/x/auth/ante/authz_rules_ante.go b/x/auth/ante/authz_rules_ante.go index 3c1df7c694bd..2976a9dc1f8a 100644 --- a/x/auth/ante/authz_rules_ante.go +++ b/x/auth/ante/authz_rules_ante.go @@ -1,8 +1,8 @@ package ante import ( - "errors" "fmt" + "strings" sdk "github.com/cosmos/cosmos-sdk/types" authztypes "github.com/cosmos/cosmos-sdk/x/authz" @@ -31,26 +31,30 @@ func (azd AuthzDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, if err != nil { return ctx, err } - rules, err := azd.azk.GetAuthzRules(ctx) - fmt.Println("rules", rules, err, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>") + options := azd.azk.GetAuthzOptions() + fmt.Println("rules", options, err, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>") switch authzConverted := authz.(type) { case *banktypes.SendAuthorization: - if err != nil && errors.Is(authztypes.ErrEmptyAuthzRules, err) { - continue - } - - if checkSendAuthzRulesVoilated(authzMsg, authzConverted, rules.Send) { - return ctx, fmt.Errorf("authz rules are not meeting") + // if err != nil && errors.Is(authztypes.ErrEmptyAuthzRules, err) { + // continue + // } + + if sendRules, ok := options["send"]; !ok { + if checkSendAuthzRulesVoilated(authzMsg, authzConverted, sendRules) { + return ctx, fmt.Errorf("authz rules are not meeting") + } } case *authztypes.GenericAuthorization: - if err != nil && errors.Is(authztypes.ErrEmptyAuthzRules, err) { - continue - } - - if checkGenericAuthzRules(authzMsg, authzConverted, rules.Generic) { - return ctx, fmt.Errorf("authz rules are not meeting") + // if err != nil && errors.Is(authztypes.ErrEmptyAuthzRules, err) { + // continue + // } + + if genericRules, ok := options["generic"]; !ok { + if checkGenericAuthzRules(authzMsg, authzConverted, genericRules) { + return ctx, fmt.Errorf("authz rules are not meeting") + } } default: @@ -63,26 +67,42 @@ func (azd AuthzDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, return next(ctx, tx, simulate) } -func checkSendAuthzRulesVoilated(msgGrant *authztypes.MsgGrant, authz *banktypes.SendAuthorization, sendAuthzRules authztypes.SendAuthzRules) bool { +// checkSendAuthzRulesVoilated returns true if the rules are voilated +func checkSendAuthzRulesVoilated(msgGrant *authztypes.MsgGrant, authz *banktypes.SendAuthorization, sendAuthzRules map[string]string) bool { fmt.Printf("\">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\": %v\n", ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>") fmt.Printf("sendAuthzRules: %v\n", sendAuthzRules) - if authz.SpendLimit.IsAllGT(sendAuthzRules.SpendLimit) { - return true + if blockedAddrsStr, ok := sendAuthzRules["blockedAddresses"]; ok { + blockedAddrs := strings.Split(blockedAddrsStr, ",") + for _, blockedRecipient := range blockedAddrs { + if msgGrant.Grantee == blockedRecipient { + return true + } + } } - for _, blockedRecipient := range sendAuthzRules.BlockedRecipients { - if msgGrant.Grantee == blockedRecipient { - return true + if spendLimit, ok := sendAuthzRules["spendLimit"]; ok { + if len(spendLimit) > 1 { + limit, err := sdk.ParseCoinsNormalized(spendLimit) + if err != nil { + return true + } + if !limit.IsAllGTE(authz.SpendLimit) { + return true + } } + return true } return false } -func checkGenericAuthzRules(msgGrant *authztypes.MsgGrant, authz *authztypes.GenericAuthorization, GenericAuthzRules authztypes.GenericAuthzRules) bool { - for _, v := range GenericAuthzRules.BlockedMessages { - if v == authz.Msg { - return true +func checkGenericAuthzRules(_ *authztypes.MsgGrant, authz *authztypes.GenericAuthorization, genericRules map[string]string) bool { + if msgsStr, ok := genericRules["blockedMessages"]; ok { + msgs := strings.Split(msgsStr, ",") + for _, v := range msgs { + if v == authz.Msg { + return true + } } } diff --git a/x/auth/ante/expected_keepers.go b/x/auth/ante/expected_keepers.go index 051843fdc5a2..12b354627045 100644 --- a/x/auth/ante/expected_keepers.go +++ b/x/auth/ante/expected_keepers.go @@ -7,7 +7,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/cosmos/cosmos-sdk/x/authz" ) // AccountKeeper defines the contract needed for AccountKeeper related APIs. @@ -26,5 +25,5 @@ type FeegrantKeeper interface { } type AuthzKeeper interface { - GetAuthzRules(ctx context.Context) (authz.AuthzRules, error) + GetAuthzOptions() map[string]map[string]string } diff --git a/x/authz/authz.pb.go b/x/authz/authz.pb.go index a88de18d9858..094c063662d3 100644 --- a/x/authz/authz.pb.go +++ b/x/authz/authz.pb.go @@ -7,8 +7,7 @@ import ( fmt "fmt" _ "github.com/cosmos/cosmos-proto" types "github.com/cosmos/cosmos-sdk/codec/types" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" - types1 "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/cosmos-sdk/types/tx/amino" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" @@ -196,222 +195,46 @@ func (m *GrantQueueItem) XXX_DiscardUnknown() { var xxx_messageInfo_GrantQueueItem proto.InternalMessageInfo -// AuthzRules defines the rules for authz messages. -type AuthzRules struct { - // Send authz rules - Send SendAuthzRules `protobuf:"bytes,1,opt,name=send,proto3" json:"send"` - // Stake authz rules - Stake StakeAuthzRules `protobuf:"bytes,2,opt,name=stake,proto3" json:"stake"` - // Generic authz rules - Generic GenericAuthzRules `protobuf:"bytes,3,opt,name=generic,proto3" json:"generic"` -} - -func (m *AuthzRules) Reset() { *m = AuthzRules{} } -func (m *AuthzRules) String() string { return proto.CompactTextString(m) } -func (*AuthzRules) ProtoMessage() {} -func (*AuthzRules) Descriptor() ([]byte, []int) { - return fileDescriptor_544dc2e84b61c637, []int{4} -} -func (m *AuthzRules) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *AuthzRules) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_AuthzRules.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 *AuthzRules) XXX_Merge(src proto.Message) { - xxx_messageInfo_AuthzRules.Merge(m, src) -} -func (m *AuthzRules) XXX_Size() int { - return m.Size() -} -func (m *AuthzRules) XXX_DiscardUnknown() { - xxx_messageInfo_AuthzRules.DiscardUnknown(m) -} - -var xxx_messageInfo_AuthzRules proto.InternalMessageInfo - -// Send authz rules -type SendAuthzRules struct { - SpendLimit github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=spend_limit,json=spendLimit,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"spend_limit"` - BlockedRecipients []string `protobuf:"bytes,2,rep,name=blocked_recipients,json=blockedRecipients,proto3" json:"blocked_recipients,omitempty"` -} - -func (m *SendAuthzRules) Reset() { *m = SendAuthzRules{} } -func (m *SendAuthzRules) String() string { return proto.CompactTextString(m) } -func (*SendAuthzRules) ProtoMessage() {} -func (*SendAuthzRules) Descriptor() ([]byte, []int) { - return fileDescriptor_544dc2e84b61c637, []int{5} -} -func (m *SendAuthzRules) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *SendAuthzRules) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_SendAuthzRules.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 *SendAuthzRules) XXX_Merge(src proto.Message) { - xxx_messageInfo_SendAuthzRules.Merge(m, src) -} -func (m *SendAuthzRules) XXX_Size() int { - return m.Size() -} -func (m *SendAuthzRules) XXX_DiscardUnknown() { - xxx_messageInfo_SendAuthzRules.DiscardUnknown(m) -} - -var xxx_messageInfo_SendAuthzRules proto.InternalMessageInfo - -// Stake authz rules -type StakeAuthzRules struct { - BlockedValidators []string `protobuf:"bytes,1,rep,name=blocked_validators,json=blockedValidators,proto3" json:"blocked_validators,omitempty"` -} - -func (m *StakeAuthzRules) Reset() { *m = StakeAuthzRules{} } -func (m *StakeAuthzRules) String() string { return proto.CompactTextString(m) } -func (*StakeAuthzRules) ProtoMessage() {} -func (*StakeAuthzRules) Descriptor() ([]byte, []int) { - return fileDescriptor_544dc2e84b61c637, []int{6} -} -func (m *StakeAuthzRules) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *StakeAuthzRules) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_StakeAuthzRules.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 *StakeAuthzRules) XXX_Merge(src proto.Message) { - xxx_messageInfo_StakeAuthzRules.Merge(m, src) -} -func (m *StakeAuthzRules) XXX_Size() int { - return m.Size() -} -func (m *StakeAuthzRules) XXX_DiscardUnknown() { - xxx_messageInfo_StakeAuthzRules.DiscardUnknown(m) -} - -var xxx_messageInfo_StakeAuthzRules proto.InternalMessageInfo - -// Generic authz rules -type GenericAuthzRules struct { - BlockedMessages []string `protobuf:"bytes,1,rep,name=blocked_messages,json=blockedMessages,proto3" json:"blocked_messages,omitempty"` -} - -func (m *GenericAuthzRules) Reset() { *m = GenericAuthzRules{} } -func (m *GenericAuthzRules) String() string { return proto.CompactTextString(m) } -func (*GenericAuthzRules) ProtoMessage() {} -func (*GenericAuthzRules) Descriptor() ([]byte, []int) { - return fileDescriptor_544dc2e84b61c637, []int{7} -} -func (m *GenericAuthzRules) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *GenericAuthzRules) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_GenericAuthzRules.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 *GenericAuthzRules) XXX_Merge(src proto.Message) { - xxx_messageInfo_GenericAuthzRules.Merge(m, src) -} -func (m *GenericAuthzRules) XXX_Size() int { - return m.Size() -} -func (m *GenericAuthzRules) XXX_DiscardUnknown() { - xxx_messageInfo_GenericAuthzRules.DiscardUnknown(m) -} - -var xxx_messageInfo_GenericAuthzRules proto.InternalMessageInfo - func init() { proto.RegisterType((*GenericAuthorization)(nil), "cosmos.authz.v1beta1.GenericAuthorization") proto.RegisterType((*Grant)(nil), "cosmos.authz.v1beta1.Grant") proto.RegisterType((*GrantAuthorization)(nil), "cosmos.authz.v1beta1.GrantAuthorization") proto.RegisterType((*GrantQueueItem)(nil), "cosmos.authz.v1beta1.GrantQueueItem") - proto.RegisterType((*AuthzRules)(nil), "cosmos.authz.v1beta1.AuthzRules") - proto.RegisterType((*SendAuthzRules)(nil), "cosmos.authz.v1beta1.SendAuthzRules") - proto.RegisterType((*StakeAuthzRules)(nil), "cosmos.authz.v1beta1.StakeAuthzRules") - proto.RegisterType((*GenericAuthzRules)(nil), "cosmos.authz.v1beta1.GenericAuthzRules") } func init() { proto.RegisterFile("cosmos/authz/v1beta1/authz.proto", fileDescriptor_544dc2e84b61c637) } var fileDescriptor_544dc2e84b61c637 = []byte{ - // 681 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xbf, 0x53, 0xd4, 0x4e, - 0x14, 0xbf, 0xc0, 0xf1, 0xe5, 0xcb, 0x9e, 0xfc, 0xca, 0x5c, 0x71, 0x50, 0xe4, 0x98, 0x0c, 0x2a, - 0x32, 0x73, 0xc9, 0x80, 0x56, 0x16, 0x0c, 0x17, 0x1d, 0x19, 0x1d, 0x2d, 0x0c, 0x68, 0x61, 0x73, - 0xb3, 0x49, 0x9e, 0x61, 0x87, 0x24, 0x9b, 0xc9, 0x6e, 0x18, 0x8e, 0xd2, 0xd2, 0x8a, 0xda, 0xd2, - 0xca, 0xb1, 0xc2, 0x19, 0xfe, 0x04, 0x8b, 0x1b, 0x2b, 0xc6, 0x8a, 0x0a, 0x14, 0x0a, 0xfe, 0x0d, - 0x27, 0xbb, 0xc9, 0x71, 0xc7, 0x9d, 0x4a, 0x61, 0x93, 0xc9, 0xee, 0xfb, 0x7c, 0x3e, 0xef, 0xbd, - 0xcf, 0xbe, 0x5d, 0xb4, 0xe0, 0x52, 0x16, 0x52, 0x66, 0xe2, 0x94, 0x6f, 0xef, 0x9b, 0xbb, 0x2b, - 0x0e, 0x70, 0xbc, 0x22, 0x57, 0x46, 0x9c, 0x50, 0x4e, 0xd5, 0xaa, 0x44, 0x18, 0x72, 0x2f, 0x47, - 0xcc, 0xcf, 0xe2, 0x90, 0x44, 0xd4, 0x14, 0x5f, 0x09, 0x9c, 0x9f, 0x93, 0xc0, 0x96, 0x58, 0x99, - 0x39, 0x4b, 0x86, 0xea, 0x3e, 0xa5, 0x7e, 0x00, 0xa6, 0x58, 0x39, 0xe9, 0x5b, 0x93, 0x93, 0x10, - 0x18, 0xc7, 0x61, 0x9c, 0x03, 0xaa, 0x3e, 0xf5, 0xa9, 0x24, 0x66, 0x7f, 0x85, 0xe2, 0x75, 0x1a, - 0x8e, 0xda, 0x79, 0x48, 0xcb, 0xeb, 0x76, 0x30, 0x83, 0x6e, 0xd9, 0x2e, 0x25, 0x91, 0x8c, 0xeb, - 0x1c, 0x55, 0x37, 0x20, 0x82, 0x84, 0xb8, 0xcd, 0x94, 0x6f, 0xd3, 0x84, 0xec, 0x63, 0x4e, 0x68, - 0xa4, 0xce, 0xa0, 0xd1, 0x90, 0xf9, 0x35, 0x65, 0x41, 0x59, 0x9a, 0xb0, 0xb3, 0xdf, 0x87, 0xcf, - 0xbe, 0x1d, 0x35, 0xf4, 0x61, 0x3d, 0x1a, 0x7d, 0xcc, 0xf7, 0x97, 0x87, 0xcb, 0x75, 0x09, 0x6b, - 0x30, 0x6f, 0xc7, 0x1c, 0xa6, 0xae, 0x7f, 0x51, 0xd0, 0xd8, 0x46, 0x82, 0x23, 0xae, 0x3a, 0x68, - 0x12, 0xf7, 0x86, 0x44, 0xc6, 0xca, 0x6a, 0xd5, 0x90, 0x2d, 0x19, 0x45, 0x4b, 0x46, 0x33, 0x6a, - 0x5b, 0x77, 0x6e, 0x56, 0x82, 0xdd, 0x2f, 0xa9, 0x3e, 0x46, 0x08, 0xf6, 0x62, 0x92, 0xc8, 0x04, - 0x23, 0x22, 0xc1, 0xfc, 0x40, 0x82, 0xad, 0xc2, 0x6a, 0xeb, 0xff, 0xce, 0x69, 0x5d, 0x39, 0x38, - 0xab, 0x2b, 0x76, 0x0f, 0x4f, 0xff, 0x38, 0x82, 0x54, 0x51, 0x73, 0xbf, 0x51, 0xab, 0x68, 0xdc, - 0xcf, 0x76, 0x21, 0x91, 0x66, 0x59, 0xb5, 0xef, 0x47, 0x8d, 0x62, 0x16, 0x9a, 0x9e, 0x97, 0x00, - 0x63, 0x9b, 0x3c, 0x21, 0x91, 0x6f, 0x17, 0xc0, 0x2b, 0x0e, 0x88, 0x6a, 0x6e, 0xc0, 0x81, 0x41, - 0xa3, 0x46, 0xff, 0xbd, 0x51, 0xeb, 0x7d, 0x46, 0x95, 0xff, 0x6a, 0x54, 0x79, 0xc0, 0xa4, 0x07, - 0x68, 0x4a, 0x78, 0xf4, 0x32, 0x85, 0x14, 0x9e, 0x72, 0x08, 0x55, 0x1d, 0x4d, 0x86, 0xcc, 0x6f, - 0xf1, 0x76, 0x0c, 0xad, 0x34, 0x09, 0x58, 0x4d, 0x59, 0x18, 0x5d, 0x9a, 0xb0, 0x2b, 0x21, 0xf3, - 0xb7, 0xda, 0x31, 0xbc, 0x4a, 0x02, 0xa6, 0x9f, 0x28, 0x08, 0x65, 0x85, 0xed, 0xdb, 0x69, 0x00, - 0x4c, 0x5d, 0x43, 0x65, 0x06, 0x91, 0x97, 0x8f, 0xc2, 0xa2, 0x31, 0xb4, 0x91, 0x4d, 0x88, 0xbc, - 0x2b, 0x8e, 0x55, 0xee, 0x9c, 0xd6, 0x4b, 0xb6, 0xe0, 0xa9, 0x4d, 0x34, 0xc6, 0x38, 0xde, 0x81, - 0xfc, 0xa8, 0x6f, 0xff, 0x46, 0x20, 0x83, 0x0c, 0x28, 0x48, 0xa6, 0xba, 0x81, 0xc6, 0x7d, 0x39, - 0xb8, 0xb9, 0xcf, 0x77, 0x87, 0x8b, 0xf4, 0x4c, 0x77, 0x9f, 0x4c, 0xc1, 0xd6, 0xbf, 0x2a, 0x68, - 0xaa, 0xbf, 0x54, 0xf5, 0x9d, 0x82, 0x2a, 0x2c, 0x86, 0xc8, 0x6b, 0x05, 0x24, 0x24, 0x5c, 0x18, - 0x52, 0x59, 0x9d, 0x2b, 0x12, 0x64, 0x37, 0xb5, 0xab, 0xff, 0x88, 0x92, 0xc8, 0x7a, 0x92, 0x49, - 0x7e, 0x3e, 0xab, 0x2f, 0xf9, 0x84, 0x6f, 0xa7, 0x8e, 0xe1, 0xd2, 0x30, 0x7f, 0x36, 0xcc, 0x9e, - 0x8b, 0x96, 0x39, 0xcc, 0x04, 0x81, 0x7d, 0xb8, 0x3c, 0x5c, 0xbe, 0x15, 0x80, 0x8f, 0xdd, 0x76, - 0x2b, 0xbb, 0xeb, 0xec, 0xd3, 0xe5, 0xe1, 0xb2, 0x62, 0x23, 0x91, 0xf5, 0x79, 0x96, 0x54, 0x6d, - 0x20, 0xd5, 0x09, 0xa8, 0xbb, 0x03, 0x5e, 0x2b, 0x01, 0x97, 0xc4, 0x04, 0x22, 0xce, 0x6a, 0x23, - 0xe2, 0x6c, 0x66, 0xf3, 0x88, 0xdd, 0x0d, 0xe8, 0xeb, 0x68, 0xfa, 0x9a, 0x5f, 0xbd, 0x0a, 0xbb, - 0x38, 0x20, 0x1e, 0xe6, 0x34, 0x29, 0x4e, 0xb7, 0x50, 0x78, 0xdd, 0x0d, 0xe8, 0x6b, 0x68, 0x76, - 0xc0, 0x2c, 0xf5, 0x1e, 0x9a, 0x29, 0x34, 0x42, 0x60, 0x0c, 0xfb, 0x50, 0x28, 0x4c, 0xe7, 0xfb, - 0x2f, 0xf2, 0x6d, 0xcb, 0xea, 0xfc, 0xd4, 0x4a, 0x9d, 0x73, 0x4d, 0x39, 0x3e, 0xd7, 0x94, 0x1f, - 0xe7, 0x9a, 0x72, 0x70, 0xa1, 0x95, 0x8e, 0x2f, 0xb4, 0xd2, 0xc9, 0x85, 0x56, 0x7a, 0xb3, 0xf8, - 0x47, 0x6b, 0xf6, 0xe4, 0x43, 0xed, 0xfc, 0x27, 0x66, 0xf8, 0xfe, 0xaf, 0x00, 0x00, 0x00, 0xff, - 0xff, 0x8a, 0x67, 0xfb, 0xeb, 0xcd, 0x05, 0x00, 0x00, + // 458 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x53, 0xcd, 0x6e, 0x13, 0x31, + 0x10, 0x8e, 0x9b, 0xf2, 0x53, 0x57, 0x45, 0xb0, 0xca, 0x21, 0xe4, 0xb0, 0x89, 0x56, 0x08, 0x55, + 0x48, 0x59, 0xab, 0x85, 0x13, 0x27, 0xb2, 0x42, 0xaa, 0xe0, 0xc6, 0x52, 0x2e, 0x5c, 0x22, 0x6f, + 0x32, 0x38, 0x16, 0xb1, 0xbd, 0xb2, 0xbd, 0xa8, 0xe9, 0x23, 0x70, 0xea, 0x33, 0xf0, 0x04, 0x20, + 0xf5, 0x21, 0x22, 0x4e, 0x15, 0x27, 0x4e, 0xfc, 0x24, 0x07, 0x5e, 0x03, 0xc5, 0xde, 0x85, 0x84, + 0x54, 0x22, 0x87, 0x5e, 0x2c, 0x8f, 0xe7, 0xfb, 0x66, 0xbe, 0xf9, 0xe4, 0xc1, 0x9d, 0x81, 0x32, + 0x42, 0x19, 0x42, 0x0b, 0x3b, 0x3a, 0x25, 0xef, 0x0e, 0x32, 0xb0, 0xf4, 0xc0, 0x47, 0x71, 0xae, + 0x95, 0x55, 0x41, 0xc3, 0x23, 0x62, 0xff, 0x56, 0x22, 0x5a, 0x77, 0xa8, 0xe0, 0x52, 0x11, 0x77, + 0x7a, 0x60, 0xeb, 0xae, 0x07, 0xf6, 0x5d, 0x44, 0x4a, 0x96, 0x4f, 0xb5, 0x99, 0x52, 0x6c, 0x0c, + 0xc4, 0x45, 0x59, 0xf1, 0x86, 0x58, 0x2e, 0xc0, 0x58, 0x2a, 0xf2, 0x12, 0xd0, 0x60, 0x8a, 0x29, + 0x4f, 0x5c, 0xdc, 0xaa, 0x8a, 0xff, 0xd2, 0xa8, 0x9c, 0x94, 0xa9, 0xb0, 0xd4, 0x9d, 0x51, 0x03, + 0x7f, 0x64, 0x0f, 0x14, 0x97, 0x3e, 0x1f, 0x59, 0xdc, 0x38, 0x02, 0x09, 0x9a, 0x0f, 0x7a, 0x85, + 0x1d, 0x29, 0xcd, 0x4f, 0xa9, 0xe5, 0x4a, 0x06, 0xb7, 0x71, 0x5d, 0x18, 0xd6, 0x44, 0x1d, 0xb4, + 0xbf, 0x93, 0x2e, 0xae, 0x8f, 0x9f, 0x7f, 0x3e, 0xef, 0x46, 0x97, 0xcd, 0x18, 0xaf, 0x30, 0xdf, + 0xff, 0xfa, 0xf8, 0xa0, 0xed, 0x61, 0x5d, 0x33, 0x7c, 0x4b, 0x2e, 0xab, 0x1e, 0x7d, 0x42, 0xf8, + 0xda, 0x91, 0xa6, 0xd2, 0x06, 0x19, 0xde, 0xa3, 0xcb, 0x29, 0xd7, 0x71, 0xf7, 0xb0, 0x11, 0xfb, + 0x91, 0xe2, 0x6a, 0xa4, 0xb8, 0x27, 0x27, 0xc9, 0xfd, 0xcd, 0x24, 0xa4, 0xab, 0x25, 0x83, 0xa7, + 0x18, 0xc3, 0x49, 0xce, 0xb5, 0x6f, 0xb0, 0xe5, 0x1a, 0xb4, 0xd6, 0x1a, 0x1c, 0x57, 0x56, 0x27, + 0x37, 0xa7, 0xdf, 0xda, 0xe8, 0xec, 0x7b, 0x1b, 0xa5, 0x4b, 0xbc, 0xe8, 0xc3, 0x16, 0x0e, 0x9c, + 0xe6, 0x55, 0xa3, 0x0e, 0xf1, 0x0d, 0xb6, 0x78, 0x05, 0xed, 0xcd, 0x4a, 0x9a, 0x5f, 0xce, 0xbb, + 0xd5, 0x5f, 0xe8, 0x0d, 0x87, 0x1a, 0x8c, 0x79, 0x69, 0x35, 0x97, 0x2c, 0xad, 0x80, 0x7f, 0x39, + 0xe0, 0xd4, 0x6c, 0xc0, 0x81, 0x75, 0xa3, 0xea, 0x57, 0x6f, 0xd4, 0x93, 0x15, 0xa3, 0xb6, 0xff, + 0x6b, 0xd4, 0xf6, 0x9a, 0x49, 0x8f, 0xf0, 0x2d, 0xe7, 0xd1, 0x8b, 0x02, 0x0a, 0x78, 0x66, 0x41, + 0x04, 0x11, 0xde, 0x13, 0x86, 0xf5, 0xed, 0x24, 0x87, 0x7e, 0xa1, 0xc7, 0xa6, 0x89, 0x3a, 0xf5, + 0xfd, 0x9d, 0x74, 0x57, 0x18, 0x76, 0x3c, 0xc9, 0xe1, 0x95, 0x1e, 0x9b, 0x24, 0x99, 0xfe, 0x0c, + 0x6b, 0xd3, 0x59, 0x88, 0x2e, 0x66, 0x21, 0xfa, 0x31, 0x0b, 0xd1, 0xd9, 0x3c, 0xac, 0x5d, 0xcc, + 0xc3, 0xda, 0xd7, 0x79, 0x58, 0x7b, 0x7d, 0x8f, 0x71, 0x3b, 0x2a, 0xb2, 0x78, 0xa0, 0x44, 0xb9, + 0x2d, 0x64, 0xe9, 0x7f, 0x9d, 0xf8, 0x25, 0xcc, 0xae, 0x3b, 0x7d, 0x0f, 0x7f, 0x07, 0x00, 0x00, + 0xff, 0xff, 0xca, 0xa0, 0x5a, 0x47, 0xa9, 0x03, 0x00, 0x00, } func (m *GenericAuthorization) Marshal() (dAtA []byte, err error) { @@ -580,169 +403,6 @@ func (m *GrantQueueItem) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *AuthzRules) 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 *AuthzRules) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *AuthzRules) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Generic.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintAuthz(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - { - size, err := m.Stake.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintAuthz(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - { - size, err := m.Send.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 *SendAuthzRules) 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 *SendAuthzRules) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *SendAuthzRules) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.BlockedRecipients) > 0 { - for iNdEx := len(m.BlockedRecipients) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.BlockedRecipients[iNdEx]) - copy(dAtA[i:], m.BlockedRecipients[iNdEx]) - i = encodeVarintAuthz(dAtA, i, uint64(len(m.BlockedRecipients[iNdEx]))) - i-- - dAtA[i] = 0x12 - } - } - if len(m.SpendLimit) > 0 { - for iNdEx := len(m.SpendLimit) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.SpendLimit[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 *StakeAuthzRules) 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 *StakeAuthzRules) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *StakeAuthzRules) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.BlockedValidators) > 0 { - for iNdEx := len(m.BlockedValidators) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.BlockedValidators[iNdEx]) - copy(dAtA[i:], m.BlockedValidators[iNdEx]) - i = encodeVarintAuthz(dAtA, i, uint64(len(m.BlockedValidators[iNdEx]))) - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *GenericAuthzRules) 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 *GenericAuthzRules) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *GenericAuthzRules) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.BlockedMessages) > 0 { - for iNdEx := len(m.BlockedMessages) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.BlockedMessages[iNdEx]) - copy(dAtA[i:], m.BlockedMessages[iNdEx]) - i = encodeVarintAuthz(dAtA, i, uint64(len(m.BlockedMessages[iNdEx]))) - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - func encodeVarintAuthz(dAtA []byte, offset int, v uint64) int { offset -= sovAuthz(v) base := offset @@ -824,72 +484,6 @@ func (m *GrantQueueItem) Size() (n int) { return n } -func (m *AuthzRules) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Send.Size() - n += 1 + l + sovAuthz(uint64(l)) - l = m.Stake.Size() - n += 1 + l + sovAuthz(uint64(l)) - l = m.Generic.Size() - n += 1 + l + sovAuthz(uint64(l)) - return n -} - -func (m *SendAuthzRules) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.SpendLimit) > 0 { - for _, e := range m.SpendLimit { - l = e.Size() - n += 1 + l + sovAuthz(uint64(l)) - } - } - if len(m.BlockedRecipients) > 0 { - for _, s := range m.BlockedRecipients { - l = len(s) - n += 1 + l + sovAuthz(uint64(l)) - } - } - return n -} - -func (m *StakeAuthzRules) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.BlockedValidators) > 0 { - for _, s := range m.BlockedValidators { - l = len(s) - n += 1 + l + sovAuthz(uint64(l)) - } - } - return n -} - -func (m *GenericAuthzRules) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.BlockedMessages) > 0 { - for _, s := range m.BlockedMessages { - 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 } @@ -1368,435 +962,6 @@ func (m *GrantQueueItem) Unmarshal(dAtA []byte) error { } return nil } -func (m *AuthzRules) 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: AuthzRules: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: AuthzRules: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Send", 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 - } - if err := m.Send.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Stake", 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 - } - if err := m.Stake.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Generic", 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 - } - if err := m.Generic.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 *SendAuthzRules) 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: SendAuthzRules: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: SendAuthzRules: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SpendLimit", 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.SpendLimit = append(m.SpendLimit, types1.Coin{}) - if err := m.SpendLimit[len(m.SpendLimit)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BlockedRecipients", 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.BlockedRecipients = append(m.BlockedRecipients, 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 (m *StakeAuthzRules) 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: StakeAuthzRules: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: StakeAuthzRules: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BlockedValidators", 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.BlockedValidators = append(m.BlockedValidators, 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 (m *GenericAuthzRules) 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: GenericAuthzRules: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GenericAuthzRules: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BlockedMessages", 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.BlockedMessages = append(m.BlockedMessages, 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/keeper/keeper.go b/x/authz/keeper/keeper.go index a6c9b4f6f499..64bd7b39d721 100644 --- a/x/authz/keeper/keeper.go +++ b/x/authz/keeper/keeper.go @@ -34,6 +34,7 @@ type Keeper struct { cdc codec.Codec router baseapp.MessageRouter authKeeper authz.AccountKeeper + AuthzOptions map[string]map[string]string } // NewKeeper constructs a message authorization Keeper @@ -68,52 +69,12 @@ func (k Keeper) getGrant(ctx context.Context, skey []byte) (grant authz.Grant, f return grant, true } -func (k Keeper) GetAuthzRules(ctx context.Context) (authz.AuthzRules, error) { - store := k.storeService.OpenKVStore(ctx) - - bz, err := store.Get(AuthzRulesPrefix) - if err != nil { - return authz.AuthzRules{}, err - } - - authzRules1 := authz.AuthzRules{ - Send: authz.SendAuthzRules{ - SpendLimit: sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 1000)), - BlockedRecipients: []string{ - "cosmos1rnr5jrt4exl0samwj0yegv99jeskl0hsge5zwt", - }, - }, - Generic: authz.GenericAuthzRules{ - BlockedMessages: []string{"cosmos.bank.v1beta1.MsgDelegate"}, - }, - } - - if bz == nil { - return authzRules1, nil - } - - // if bz == nil { - // return authz.AuthzRules{}, authz.ErrEmptyAuthzRules - // } - - var authzRules authz.AuthzRules - err = k.cdc.Unmarshal(bz, &authzRules) - if err != nil { - return authz.AuthzRules{}, err - } - - return authzRules, nil -} - -func (k Keeper) SetAuthzRules(ctx context.Context, rules authz.AuthzRules) error { - store := k.storeService.OpenKVStore(ctx) - - bz, err := k.cdc.Marshal(&rules) - if err != nil { - return err - } +// func (k Keeper) SetAuthzOptions(options map[string]map[string][]string) { +// k.AuthzOptions = options +// } - return store.Set(AuthzRulesPrefix, bz) +func (k Keeper) GetAuthzOptions() map[string]map[string]string { + return k.AuthzOptions } func (k Keeper) update(ctx context.Context, grantee, granter sdk.AccAddress, updated authz.Authorization) error { From 0f329bfd22a2d15de5f4ed01242ee25840cf0a1f Mon Sep 17 00:00:00 2001 From: atheesh Date: Mon, 6 May 2024 11:38:47 +0530 Subject: [PATCH 08/30] changes --- simapp/app.go | 6 ++---- x/authz/keeper/keeper.go | 7 ++++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/simapp/app.go b/simapp/app.go index b8316d98bb9e..63213a31e801 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -335,8 +335,6 @@ func NewSimApp( app.CircuitKeeper = circuitkeeper.NewKeeper(appCodec, runtime.NewKVStoreService(keys[circuittypes.StoreKey]), authtypes.NewModuleAddress(govtypes.ModuleName).String(), app.AccountKeeper.AddressCodec()) app.BaseApp.SetCircuitBreaker(&app.CircuitKeeper) - app.AuthzKeeper = authzkeeper.NewKeeper(runtime.NewKVStoreService(keys[authzkeeper.StoreKey]), appCodec, app.MsgServiceRouter(), app.AccountKeeper) - options := map[string]map[string]string{ "Send": { "BlockedAddresses": "cosmos1rnr5jrt4exl0samwj0yegv99jeskl0hsge5zwt", @@ -346,8 +344,8 @@ func NewSimApp( "BlockedMessages": "cosmos.bank.v1beta1.MsgDelegate,cosmos.bank.v1beta1.MsgRedelegate", }, } - // app.AuthzKeeper = app.AuthzKeeper.SetAuthzOptions(options) - app.AuthzKeeper.AuthzOptions = options + + app.AuthzKeeper = authzkeeper.NewKeeper(runtime.NewKVStoreService(keys[authzkeeper.StoreKey]), appCodec, app.MsgServiceRouter(), app.AccountKeeper, options) groupConfig := group.DefaultConfig() /* diff --git a/x/authz/keeper/keeper.go b/x/authz/keeper/keeper.go index 64bd7b39d721..60cba57d06a7 100644 --- a/x/authz/keeper/keeper.go +++ b/x/authz/keeper/keeper.go @@ -34,16 +34,17 @@ type Keeper struct { cdc codec.Codec router baseapp.MessageRouter authKeeper authz.AccountKeeper - AuthzOptions map[string]map[string]string + authzOptions map[string]map[string]string } // NewKeeper constructs a message authorization Keeper -func NewKeeper(storeService corestoretypes.KVStoreService, cdc codec.Codec, router baseapp.MessageRouter, ak authz.AccountKeeper) Keeper { +func NewKeeper(storeService corestoretypes.KVStoreService, cdc codec.Codec, router baseapp.MessageRouter, ak authz.AccountKeeper, options map[string]map[string]string) Keeper { return Keeper{ storeService: storeService, cdc: cdc, router: router, authKeeper: ak, + authzOptions: options, } } @@ -74,7 +75,7 @@ func (k Keeper) getGrant(ctx context.Context, skey []byte) (grant authz.Grant, f // } func (k Keeper) GetAuthzOptions() map[string]map[string]string { - return k.AuthzOptions + return k.authzOptions } func (k Keeper) update(ctx context.Context, grantee, granter sdk.AccAddress, updated authz.Authorization) error { From 70be56d3d14fc90084ceef4758ec75fc557eff12 Mon Sep 17 00:00:00 2001 From: atheesh Date: Mon, 6 May 2024 11:43:38 +0530 Subject: [PATCH 09/30] fixes --- x/authz/keeper/genesis_test.go | 2 +- x/authz/keeper/keeper.go | 4 ---- x/authz/keeper/keeper_test.go | 2 +- x/authz/module/abci_test.go | 2 +- x/authz/module/module.go | 2 +- 5 files changed, 4 insertions(+), 8 deletions(-) diff --git a/x/authz/keeper/genesis_test.go b/x/authz/keeper/genesis_test.go index 94320f0ff654..015e24d34168 100644 --- a/x/authz/keeper/genesis_test.go +++ b/x/authz/keeper/genesis_test.go @@ -67,7 +67,7 @@ func (suite *GenesisTestSuite) SetupTest() { msr := suite.baseApp.MsgServiceRouter() msr.SetInterfaceRegistry(suite.encCfg.InterfaceRegistry) - suite.keeper = keeper.NewKeeper(storeService, suite.encCfg.Codec, msr, suite.accountKeeper) + suite.keeper = keeper.NewKeeper(storeService, suite.encCfg.Codec, msr, suite.accountKeeper, nil) } func (suite *GenesisTestSuite) TestImportExportGenesis() { diff --git a/x/authz/keeper/keeper.go b/x/authz/keeper/keeper.go index 60cba57d06a7..ea66cd73017d 100644 --- a/x/authz/keeper/keeper.go +++ b/x/authz/keeper/keeper.go @@ -70,10 +70,6 @@ func (k Keeper) getGrant(ctx context.Context, skey []byte) (grant authz.Grant, f return grant, true } -// func (k Keeper) SetAuthzOptions(options map[string]map[string][]string) { -// k.AuthzOptions = options -// } - func (k Keeper) GetAuthzOptions() map[string]map[string]string { return k.authzOptions } diff --git a/x/authz/keeper/keeper_test.go b/x/authz/keeper/keeper_test.go index 066e7d70750a..dc54d698cfcc 100644 --- a/x/authz/keeper/keeper_test.go +++ b/x/authz/keeper/keeper_test.go @@ -75,7 +75,7 @@ func (s *TestSuite) SetupTest() { banktypes.RegisterInterfaces(s.encCfg.InterfaceRegistry) banktypes.RegisterMsgServer(s.baseApp.MsgServiceRouter(), s.bankKeeper) - s.authzKeeper = authzkeeper.NewKeeper(storeService, s.encCfg.Codec, s.baseApp.MsgServiceRouter(), s.accountKeeper) + s.authzKeeper = authzkeeper.NewKeeper(storeService, s.encCfg.Codec, s.baseApp.MsgServiceRouter(), s.accountKeeper, nil) queryHelper := baseapp.NewQueryServerTestHelper(s.ctx, s.encCfg.InterfaceRegistry) authz.RegisterQueryServer(queryHelper, s.authzKeeper) diff --git a/x/authz/module/abci_test.go b/x/authz/module/abci_test.go index 12055e0cfa12..fef295766f6c 100644 --- a/x/authz/module/abci_test.go +++ b/x/authz/module/abci_test.go @@ -65,7 +65,7 @@ func TestExpiredGrantsQueue(t *testing.T) { accountKeeper.EXPECT().AddressCodec().Return(address.NewBech32Codec("cosmos")).AnyTimes() - authzKeeper := keeper.NewKeeper(storeService, encCfg.Codec, baseApp.MsgServiceRouter(), accountKeeper) + authzKeeper := keeper.NewKeeper(storeService, encCfg.Codec, baseApp.MsgServiceRouter(), accountKeeper, nil) save := func(grantee sdk.AccAddress, exp *time.Time) { err := authzKeeper.SaveGrant(ctx, grantee, granter, sendAuthz, exp) diff --git a/x/authz/module/module.go b/x/authz/module/module.go index 248a75b8584b..c749a14b95c8 100644 --- a/x/authz/module/module.go +++ b/x/authz/module/module.go @@ -176,7 +176,7 @@ type ModuleOutputs struct { } func ProvideModule(in ModuleInputs) ModuleOutputs { - k := keeper.NewKeeper(in.StoreService, in.Cdc, in.MsgServiceRouter, in.AccountKeeper) + k := keeper.NewKeeper(in.StoreService, in.Cdc, in.MsgServiceRouter, in.AccountKeeper, nil) m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.BankKeeper, in.Registry) return ModuleOutputs{AuthzKeeper: k, Module: m} } From bb94e6355a47a1b93d6cf817835eac4a89d52e8d Mon Sep 17 00:00:00 2001 From: atheesh Date: Mon, 6 May 2024 11:47:56 +0530 Subject: [PATCH 10/30] changes --- simapp/app.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simapp/app.go b/simapp/app.go index 63213a31e801..145616eb3a19 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -337,7 +337,7 @@ func NewSimApp( options := map[string]map[string]string{ "Send": { - "BlockedAddresses": "cosmos1rnr5jrt4exl0samwj0yegv99jeskl0hsge5zwt", + "BlockedAddresses": "cosmos1rnr5jrt4exl0samwj0yegv99jeskl0hsge5zwt,cosmos1rnr5jrt4exl0samwj0yegv99jeskl0hsge5zwt", "SpendLimit": "1000stake", }, "Generic": { From 9ae7ce523c258cb8ac7adebc5dd6f991202ae123 Mon Sep 17 00:00:00 2001 From: atheesh Date: Mon, 6 May 2024 11:49:22 +0530 Subject: [PATCH 11/30] changes --- simapp/authz_rules.go | 8 -------- x/auth/ante/authz_rules_ante.go | 6 +++--- 2 files changed, 3 insertions(+), 11 deletions(-) delete mode 100644 simapp/authz_rules.go diff --git a/simapp/authz_rules.go b/simapp/authz_rules.go deleted file mode 100644 index f600545d339b..000000000000 --- a/simapp/authz_rules.go +++ /dev/null @@ -1,8 +0,0 @@ -package simapp - -// var rules = authz.AuthzRules{ -// Send: authz.SendAuthzRules{ -// SpendLimit: types.NewCoins(types.NewInt64Coin(types.DefaultBondDenom, 1000)), -// BlockedRecipients: []string{"cosmos1rnr5jrt4exl0samwj0yegv99jeskl0hsge5zwt", "cosmos12g43c03a4p076valkrpalw7u4nxndv97qp5xf7"}, -// }, -// } diff --git a/x/auth/ante/authz_rules_ante.go b/x/auth/ante/authz_rules_ante.go index 2976a9dc1f8a..0cd0c4e1067e 100644 --- a/x/auth/ante/authz_rules_ante.go +++ b/x/auth/ante/authz_rules_ante.go @@ -41,7 +41,7 @@ func (azd AuthzDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, // } if sendRules, ok := options["send"]; !ok { - if checkSendAuthzRulesVoilated(authzMsg, authzConverted, sendRules) { + if checkSendAuthzRulesViolated(authzMsg, authzConverted, sendRules) { return ctx, fmt.Errorf("authz rules are not meeting") } } @@ -67,8 +67,8 @@ func (azd AuthzDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, return next(ctx, tx, simulate) } -// checkSendAuthzRulesVoilated returns true if the rules are voilated -func checkSendAuthzRulesVoilated(msgGrant *authztypes.MsgGrant, authz *banktypes.SendAuthorization, sendAuthzRules map[string]string) bool { +// checkSendAuthzRulesViolated returns true if the rules are voilated +func checkSendAuthzRulesViolated(msgGrant *authztypes.MsgGrant, authz *banktypes.SendAuthorization, sendAuthzRules map[string]string) bool { fmt.Printf("\">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\": %v\n", ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>") fmt.Printf("sendAuthzRules: %v\n", sendAuthzRules) if blockedAddrsStr, ok := sendAuthzRules["blockedAddresses"]; ok { From eabb609eb07187b11f1106b9f659949d3e881db7 Mon Sep 17 00:00:00 2001 From: atheesh Date: Fri, 10 May 2024 14:39:59 +0530 Subject: [PATCH 12/30] feat: grant specific authz rules --- api/cosmos/authz/v1beta1/authz.pulsar.go | 640 +++++++++++++++++++++-- proto/cosmos/authz/v1beta1/authz.proto | 10 +- scripts/dep-assert.sh | 0 scripts/go-lint-all.bash | 0 scripts/go-mod-tidy-all.sh | 0 scripts/go-update-dep-all.sh | 0 scripts/init-simapp.sh | 0 scripts/mockgen.sh | 0 scripts/protoc-swagger-gen.sh | 0 scripts/protocgen-pulsar.sh | 0 scripts/protocgen.sh | 0 scripts/validate-gentxs.sh | 0 simapp/app.go | 12 +- x/auth/ante/authz_rules_ante.go | 97 ++-- x/auth/ante/expected_keepers.go | 4 + x/authz/authorizations.go | 4 + x/authz/authz.pb.go | 276 ++++++++-- x/authz/generic_authorization.go | 5 + x/authz/keeper/genesis_test.go | 2 +- x/authz/keeper/keeper.go | 79 ++- x/authz/keeper/keeper_test.go | 2 +- x/authz/keeper/keys.go | 7 +- x/authz/module/abci_test.go | 2 +- x/authz/module/module.go | 2 +- x/bank/types/send_authorization.go | 5 + x/staking/types/authz.go | 5 + 26 files changed, 1012 insertions(+), 140 deletions(-) mode change 100755 => 100644 scripts/dep-assert.sh mode change 100755 => 100644 scripts/go-lint-all.bash mode change 100755 => 100644 scripts/go-mod-tidy-all.sh mode change 100755 => 100644 scripts/go-update-dep-all.sh mode change 100755 => 100644 scripts/init-simapp.sh mode change 100755 => 100644 scripts/mockgen.sh mode change 100755 => 100644 scripts/protoc-swagger-gen.sh mode change 100755 => 100644 scripts/protocgen-pulsar.sh mode change 100755 => 100644 scripts/protocgen.sh mode change 100755 => 100644 scripts/validate-gentxs.sh diff --git a/api/cosmos/authz/v1beta1/authz.pulsar.go b/api/cosmos/authz/v1beta1/authz.pulsar.go index cb25a8e245d3..42424dd25f4f 100644 --- a/api/cosmos/authz/v1beta1/authz.pulsar.go +++ b/api/cosmos/authz/v1beta1/authz.pulsar.go @@ -442,6 +442,7 @@ var ( md_Grant protoreflect.MessageDescriptor fd_Grant_authorization protoreflect.FieldDescriptor fd_Grant_expiration protoreflect.FieldDescriptor + fd_Grant_rules protoreflect.FieldDescriptor ) func init() { @@ -449,6 +450,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) @@ -528,6 +530,12 @@ func (x *fastReflection_Grant) Range(f func(protoreflect.FieldDescriptor, protor return } } + if len(x.Rules) != 0 { + value := protoreflect.ValueOfBytes(x.Rules) + if !f(fd_Grant_rules, value) { + return + } + } } // Has reports whether a field is populated. @@ -547,6 +555,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")) @@ -567,6 +577,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")) @@ -589,6 +601,9 @@ 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": + value := x.Rules + return protoreflect.ValueOfBytes(value) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.Grant")) @@ -613,6 +628,8 @@ 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": + x.Rules = value.Bytes() default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.Grant")) @@ -643,6 +660,8 @@ 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": + panic(fmt.Errorf("field rules of message cosmos.authz.v1beta1.Grant is not mutable")) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.Grant")) @@ -662,6 +681,8 @@ 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": + return protoreflect.ValueOfBytes(nil) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.Grant")) @@ -739,6 +760,10 @@ func (x *fastReflection_Grant) ProtoMethods() *protoiface.Methods { l = options.Size(x.Expiration) 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) } @@ -768,6 +793,13 @@ func (x *fastReflection_Grant) 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] = 0x1a + } if x.Expiration != nil { encoded, err := options.Marshal(x.Expiration) if err != nil { @@ -917,6 +949,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 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:]) @@ -2074,6 +2140,428 @@ func (x *fastReflection_GrantQueueItem) ProtoMethods() *protoiface.Methods { } } +var ( + md_AuthzRuleKeys protoreflect.MessageDescriptor + fd_AuthzRuleKeys_raw_json protoreflect.FieldDescriptor +) + +func init() { + file_cosmos_authz_v1beta1_authz_proto_init() + md_AuthzRuleKeys = File_cosmos_authz_v1beta1_authz_proto.Messages().ByName("AuthzRuleKeys") + fd_AuthzRuleKeys_raw_json = md_AuthzRuleKeys.Fields().ByName("raw_json") +} + +var _ protoreflect.Message = (*fastReflection_AuthzRuleKeys)(nil) + +type fastReflection_AuthzRuleKeys AuthzRuleKeys + +func (x *AuthzRuleKeys) ProtoReflect() protoreflect.Message { + return (*fastReflection_AuthzRuleKeys)(x) +} + +func (x *AuthzRuleKeys) 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_AuthzRuleKeys_messageType fastReflection_AuthzRuleKeys_messageType +var _ protoreflect.MessageType = fastReflection_AuthzRuleKeys_messageType{} + +type fastReflection_AuthzRuleKeys_messageType struct{} + +func (x fastReflection_AuthzRuleKeys_messageType) Zero() protoreflect.Message { + return (*fastReflection_AuthzRuleKeys)(nil) +} +func (x fastReflection_AuthzRuleKeys_messageType) New() protoreflect.Message { + return new(fastReflection_AuthzRuleKeys) +} +func (x fastReflection_AuthzRuleKeys_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_AuthzRuleKeys +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_AuthzRuleKeys) Descriptor() protoreflect.MessageDescriptor { + return md_AuthzRuleKeys +} + +// 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_AuthzRuleKeys) Type() protoreflect.MessageType { + return _fastReflection_AuthzRuleKeys_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_AuthzRuleKeys) New() protoreflect.Message { + return new(fastReflection_AuthzRuleKeys) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_AuthzRuleKeys) Interface() protoreflect.ProtoMessage { + return (*AuthzRuleKeys)(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_AuthzRuleKeys) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if len(x.RawJson) != 0 { + value := protoreflect.ValueOfBytes(x.RawJson) + if !f(fd_AuthzRuleKeys_raw_json, 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_AuthzRuleKeys) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "cosmos.authz.v1beta1.AuthzRuleKeys.raw_json": + return len(x.RawJson) != 0 + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.AuthzRuleKeys")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.AuthzRuleKeys 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_AuthzRuleKeys) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "cosmos.authz.v1beta1.AuthzRuleKeys.raw_json": + x.RawJson = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.AuthzRuleKeys")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.AuthzRuleKeys 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_AuthzRuleKeys) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "cosmos.authz.v1beta1.AuthzRuleKeys.raw_json": + value := x.RawJson + return protoreflect.ValueOfBytes(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.AuthzRuleKeys")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.AuthzRuleKeys 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_AuthzRuleKeys) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "cosmos.authz.v1beta1.AuthzRuleKeys.raw_json": + x.RawJson = value.Bytes() + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.AuthzRuleKeys")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.AuthzRuleKeys 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_AuthzRuleKeys) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.authz.v1beta1.AuthzRuleKeys.raw_json": + panic(fmt.Errorf("field raw_json of message cosmos.authz.v1beta1.AuthzRuleKeys is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.AuthzRuleKeys")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.AuthzRuleKeys 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_AuthzRuleKeys) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.authz.v1beta1.AuthzRuleKeys.raw_json": + return protoreflect.ValueOfBytes(nil) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.AuthzRuleKeys")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.AuthzRuleKeys 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_AuthzRuleKeys) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.authz.v1beta1.AuthzRuleKeys", 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_AuthzRuleKeys) 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_AuthzRuleKeys) 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_AuthzRuleKeys) 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_AuthzRuleKeys) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*AuthzRuleKeys) + 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.RawJson) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*AuthzRuleKeys) + 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.RawJson) > 0 { + i -= len(x.RawJson) + copy(dAtA[i:], x.RawJson) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.RawJson))) + 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().(*AuthzRuleKeys) + 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: AuthzRuleKeys: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: AuthzRuleKeys: 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 RawJson", 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.RawJson = append(x.RawJson[:0], dAtA[iNdEx:postIndex]...) + if x.RawJson == nil { + x.RawJson = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + // Since: cosmos-sdk 0.43 // Code generated by protoc-gen-go. DO NOT EDIT. @@ -2139,6 +2627,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 []byte `protobuf:"bytes,3,opt,name=rules,proto3" json:"rules,omitempty"` } func (x *Grant) Reset() { @@ -2175,6 +2665,13 @@ func (x *Grant) GetExpiration() *timestamppb.Timestamp { return nil } +func (x *Grant) GetRules() []byte { + if x != nil { + return x.Rules + } + 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 { @@ -2273,6 +2770,42 @@ func (x *GrantQueueItem) GetMsgTypeUrls() []string { return nil } +// AuthzRuleKeys is app specific options to the keys +type AuthzRuleKeys struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + RawJson []byte `protobuf:"bytes,1,opt,name=raw_json,json=rawJson,proto3" json:"raw_json,omitempty"` +} + +func (x *AuthzRuleKeys) Reset() { + *x = AuthzRuleKeys{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_authz_v1beta1_authz_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AuthzRuleKeys) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AuthzRuleKeys) ProtoMessage() {} + +// Deprecated: Use AuthzRuleKeys.ProtoReflect.Descriptor instead. +func (*AuthzRuleKeys) Descriptor() ([]byte, []int) { + return file_cosmos_authz_v1beta1_authz_proto_rawDescGZIP(), []int{4} +} + +func (x *AuthzRuleKeys) GetRawJson() []byte { + if x != nil { + return x.RawJson + } + return nil +} + var File_cosmos_authz_v1beta1_authz_proto protoreflect.FileDescriptor var file_cosmos_authz_v1beta1_authz_proto_rawDesc = []byte{ @@ -2296,7 +2829,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, 0xc7, 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, @@ -2308,42 +2841,46 @@ 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, - 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, + 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x75, 0x6c, 0x65, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x0c, 0x52, 0x05, 0x72, 0x75, 0x6c, 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, 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, 0x2a, 0x0a, 0x0d, 0x41, 0x75, 0x74, 0x68, 0x7a, 0x52, 0x75, 0x6c, 0x65, + 0x4b, 0x65, 0x79, 0x73, 0x12, 0x19, 0x0a, 0x08, 0x72, 0x61, 0x77, 0x5f, 0x6a, 0x73, 0x6f, 0x6e, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x72, 0x61, 0x77, 0x4a, 0x73, 0x6f, 0x6e, 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 ( @@ -2358,20 +2895,21 @@ 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, 5) 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 + (*AuthzRuleKeys)(nil), // 4: cosmos.authz.v1beta1.AuthzRuleKeys + (*anypb.Any)(nil), // 5: google.protobuf.Any + (*timestamppb.Timestamp)(nil), // 6: 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 + 5, // 0: cosmos.authz.v1beta1.Grant.authorization:type_name -> google.protobuf.Any + 6, // 1: cosmos.authz.v1beta1.Grant.expiration:type_name -> google.protobuf.Timestamp + 5, // 2: cosmos.authz.v1beta1.GrantAuthorization.authorization:type_name -> google.protobuf.Any + 6, // 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 @@ -2433,6 +2971,18 @@ func file_cosmos_authz_v1beta1_authz_proto_init() { return nil } } + file_cosmos_authz_v1beta1_authz_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AuthzRuleKeys); 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{ @@ -2440,7 +2990,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: 5, NumExtensions: 0, NumServices: 0, }, diff --git a/proto/cosmos/authz/v1beta1/authz.proto b/proto/cosmos/authz/v1beta1/authz.proto index defa3ab92c53..0e80a8082d7b 100644 --- a/proto/cosmos/authz/v1beta1/authz.proto +++ b/proto/cosmos/authz/v1beta1/authz.proto @@ -30,6 +30,9 @@ 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. + bytes rules = 3; } // GrantAuthorization extends a grant with both the addresses of the grantee and granter. @@ -79,4 +82,9 @@ message GrantQueueItem { // // Generic authz rules // message GenericAuthzRules { // repeated string blocked_messages = 1; -// } \ No newline at end of file +// } + +// AuthzRuleKeys is app specific options to the keys +message AuthzRuleKeys { + bytes raw_json = 1; +} \ No newline at end of file diff --git a/scripts/dep-assert.sh b/scripts/dep-assert.sh old mode 100755 new mode 100644 diff --git a/scripts/go-lint-all.bash b/scripts/go-lint-all.bash old mode 100755 new mode 100644 diff --git a/scripts/go-mod-tidy-all.sh b/scripts/go-mod-tidy-all.sh old mode 100755 new mode 100644 diff --git a/scripts/go-update-dep-all.sh b/scripts/go-update-dep-all.sh old mode 100755 new mode 100644 diff --git a/scripts/init-simapp.sh b/scripts/init-simapp.sh old mode 100755 new mode 100644 diff --git a/scripts/mockgen.sh b/scripts/mockgen.sh old mode 100755 new mode 100644 diff --git a/scripts/protoc-swagger-gen.sh b/scripts/protoc-swagger-gen.sh old mode 100755 new mode 100644 diff --git a/scripts/protocgen-pulsar.sh b/scripts/protocgen-pulsar.sh old mode 100755 new mode 100644 diff --git a/scripts/protocgen.sh b/scripts/protocgen.sh old mode 100755 new mode 100644 diff --git a/scripts/validate-gentxs.sh b/scripts/validate-gentxs.sh old mode 100755 new mode 100644 diff --git a/simapp/app.go b/simapp/app.go index 145616eb3a19..241f7b54a26a 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -335,17 +335,7 @@ func NewSimApp( app.CircuitKeeper = circuitkeeper.NewKeeper(appCodec, runtime.NewKVStoreService(keys[circuittypes.StoreKey]), authtypes.NewModuleAddress(govtypes.ModuleName).String(), app.AccountKeeper.AddressCodec()) app.BaseApp.SetCircuitBreaker(&app.CircuitKeeper) - options := map[string]map[string]string{ - "Send": { - "BlockedAddresses": "cosmos1rnr5jrt4exl0samwj0yegv99jeskl0hsge5zwt,cosmos1rnr5jrt4exl0samwj0yegv99jeskl0hsge5zwt", - "SpendLimit": "1000stake", - }, - "Generic": { - "BlockedMessages": "cosmos.bank.v1beta1.MsgDelegate,cosmos.bank.v1beta1.MsgRedelegate", - }, - } - - app.AuthzKeeper = authzkeeper.NewKeeper(runtime.NewKVStoreService(keys[authzkeeper.StoreKey]), appCodec, app.MsgServiceRouter(), app.AccountKeeper, options) + app.AuthzKeeper = authzkeeper.NewKeeper(runtime.NewKVStoreService(keys[authzkeeper.StoreKey]), appCodec, app.MsgServiceRouter(), app.AccountKeeper) groupConfig := group.DefaultConfig() /* diff --git a/x/auth/ante/authz_rules_ante.go b/x/auth/ante/authz_rules_ante.go index 0cd0c4e1067e..74c813899593 100644 --- a/x/auth/ante/authz_rules_ante.go +++ b/x/auth/ante/authz_rules_ante.go @@ -4,7 +4,10 @@ import ( "fmt" "strings" + errorsmod "cosmossdk.io/errors" 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" ) @@ -21,44 +24,55 @@ func NewAuthzDecorator(azk AuthzKeeper) AuthzDecorator { // AuthzDecorator 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) { + sigTx, ok := tx.(authsigning.SigVerifiableTx) + if !ok { + return ctx, errorsmod.Wrap(sdkerrors.ErrTxDecode, "invalid tx type") + } + + signers, err := sigTx.GetSigners() + if err != nil { + return ctx, err + } + + grantee := signers[0] + msgs := tx.GetMsgs() for _, msg := range msgs { // Check if the message is an authorization message - if authzMsg, ok := msg.(*authztypes.MsgGrant); ok { - fmt.Println("coming here", ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>") + if authzMsg, ok := msg.(*authztypes.MsgExec); ok { + + rulesKeys, err := azd.azk.GetAuthzRulesKeys(ctx) + if err != nil { + return ctx, err + } - authz, err := authzMsg.GetAuthorization() + msgs, err := authzMsg.GetMessages() if err != nil { return ctx, err } - options := azd.azk.GetAuthzOptions() - fmt.Println("rules", options, err, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>") - - switch authzConverted := authz.(type) { - case *banktypes.SendAuthorization: - // if err != nil && errors.Is(authztypes.ErrEmptyAuthzRules, err) { - // continue - // } - - if sendRules, ok := options["send"]; !ok { - if checkSendAuthzRulesViolated(authzMsg, authzConverted, sendRules) { - return ctx, fmt.Errorf("authz rules are not meeting") + + for _, innerMsg := range msgs { + switch innerMsgConverted := innerMsg.(type) { + case *banktypes.MsgSend: + sendRuleKeysInterface, ok := rulesKeys["Send"] + if !ok { + fmt.Println("no rule keys") + continue } - } - case *authztypes.GenericAuthorization: - // if err != nil && errors.Is(authztypes.ErrEmptyAuthzRules, err) { - // continue - // } + granter, err := azd.azk.AddressCodec().StringToBytes(innerMsgConverted.FromAddress) + if err != nil { + return ctx, err + } - if genericRules, ok := options["generic"]; !ok { - if checkGenericAuthzRules(authzMsg, authzConverted, genericRules) { - return ctx, fmt.Errorf("authz rules are not meeting") + _, rules := azd.azk.GetAuthzWithRules(ctx, grantee, granter, sdk.MsgTypeURL(&banktypes.MsgSend{})) + if rules != nil { + sendRulesKeys := sendRuleKeysInterface.([]string) + if checkSendAuthzRulesViolated(innerMsgConverted, rules, sendRulesKeys) { + return ctx, fmt.Errorf("authz rules are not meeting") + } } } - - default: - fmt.Println("default case reached here") } } } @@ -68,29 +82,34 @@ func (azd AuthzDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, } // checkSendAuthzRulesViolated returns true if the rules are voilated -func checkSendAuthzRulesViolated(msgGrant *authztypes.MsgGrant, authz *banktypes.SendAuthorization, sendAuthzRules map[string]string) bool { - fmt.Printf("\">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\": %v\n", ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>") - fmt.Printf("sendAuthzRules: %v\n", sendAuthzRules) - if blockedAddrsStr, ok := sendAuthzRules["blockedAddresses"]; ok { - blockedAddrs := strings.Split(blockedAddrsStr, ",") - for _, blockedRecipient := range blockedAddrs { - if msgGrant.Grantee == blockedRecipient { - return true +func checkSendAuthzRulesViolated(msg *banktypes.MsgSend, sendAuthzRules map[string]interface{}, sendRulesKeys []string) bool { + for _, key := range sendRulesKeys { + + fmt.Printf("\">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\": %v\n", ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>") + fmt.Printf("sendAuthzRules: %v\n", sendAuthzRules) + if blockedAddrsStrInt, ok := sendAuthzRules["AllowRecipients"]; key == "AllowRecipients" && ok { + blockedAddrsStr := blockedAddrsStrInt.(string) + blockedAddrs := strings.Split(blockedAddrsStr, ",") + for _, blockedRecipient := range blockedAddrs { + if msg.ToAddress == blockedRecipient { + return true + } } } - } - if spendLimit, ok := sendAuthzRules["spendLimit"]; ok { - if len(spendLimit) > 1 { + if spendLimitInt, ok := sendAuthzRules["SpendLImit"]; key == "SpendLImit" && ok { + spendLimit := spendLimitInt.(string) limit, err := sdk.ParseCoinsNormalized(spendLimit) if err != nil { return true } - if !limit.IsAllGTE(authz.SpendLimit) { + if !limit.IsAllGTE(msg.Amount) { return true } + + return true } - return true + } return false diff --git a/x/auth/ante/expected_keepers.go b/x/auth/ante/expected_keepers.go index 12b354627045..5632a915dafb 100644 --- a/x/auth/ante/expected_keepers.go +++ b/x/auth/ante/expected_keepers.go @@ -7,6 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/cosmos/cosmos-sdk/x/authz" ) // AccountKeeper defines the contract needed for AccountKeeper related APIs. @@ -26,4 +27,7 @@ type FeegrantKeeper interface { type AuthzKeeper interface { GetAuthzOptions() map[string]map[string]string + GetAuthzRulesKeys(ctx context.Context) (map[string]interface{}, error) + GetAuthzWithRules(ctx context.Context, grantee, granter sdk.AccAddress, msgType string) (authz.Authorization, map[string]interface{}) + AddressCodec() address.Codec } diff --git a/x/authz/authorizations.go b/x/authz/authorizations.go index 75b2e0659097..70cb6f8d60c4 100644 --- a/x/authz/authorizations.go +++ b/x/authz/authorizations.go @@ -2,6 +2,7 @@ package authz import ( context "context" + "encoding/json" "github.com/cosmos/gogoproto/proto" @@ -24,6 +25,9 @@ type Authorization interface { // ValidateBasic does a simple validation check that // doesn't require access to any other information. ValidateBasic() error + + // GetOptions are, rules defined if any. + GetOptions() json.RawMessage } // AcceptResponse instruments the controller of an authz message if the request is accepted diff --git a/x/authz/authz.pb.go b/x/authz/authz.pb.go index 094c063662d3..b84eefa30b7c 100644 --- a/x/authz/authz.pb.go +++ b/x/authz/authz.pb.go @@ -79,6 +79,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 []byte `protobuf:"bytes,3,opt,name=rules,proto3" json:"rules,omitempty"` } func (m *Grant) Reset() { *m = Grant{} } @@ -195,46 +197,88 @@ func (m *GrantQueueItem) XXX_DiscardUnknown() { var xxx_messageInfo_GrantQueueItem proto.InternalMessageInfo +// AuthzRuleKeys is app specific options to the keys +type AuthzRuleKeys struct { + RawJson []byte `protobuf:"bytes,1,opt,name=raw_json,json=rawJson,proto3" json:"raw_json,omitempty"` +} + +func (m *AuthzRuleKeys) Reset() { *m = AuthzRuleKeys{} } +func (m *AuthzRuleKeys) String() string { return proto.CompactTextString(m) } +func (*AuthzRuleKeys) ProtoMessage() {} +func (*AuthzRuleKeys) Descriptor() ([]byte, []int) { + return fileDescriptor_544dc2e84b61c637, []int{4} +} +func (m *AuthzRuleKeys) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AuthzRuleKeys) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AuthzRuleKeys.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 *AuthzRuleKeys) XXX_Merge(src proto.Message) { + xxx_messageInfo_AuthzRuleKeys.Merge(m, src) +} +func (m *AuthzRuleKeys) XXX_Size() int { + return m.Size() +} +func (m *AuthzRuleKeys) XXX_DiscardUnknown() { + xxx_messageInfo_AuthzRuleKeys.DiscardUnknown(m) +} + +var xxx_messageInfo_AuthzRuleKeys proto.InternalMessageInfo + func init() { proto.RegisterType((*GenericAuthorization)(nil), "cosmos.authz.v1beta1.GenericAuthorization") proto.RegisterType((*Grant)(nil), "cosmos.authz.v1beta1.Grant") proto.RegisterType((*GrantAuthorization)(nil), "cosmos.authz.v1beta1.GrantAuthorization") proto.RegisterType((*GrantQueueItem)(nil), "cosmos.authz.v1beta1.GrantQueueItem") + proto.RegisterType((*AuthzRuleKeys)(nil), "cosmos.authz.v1beta1.AuthzRuleKeys") } func init() { proto.RegisterFile("cosmos/authz/v1beta1/authz.proto", fileDescriptor_544dc2e84b61c637) } var fileDescriptor_544dc2e84b61c637 = []byte{ - // 458 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x53, 0xcd, 0x6e, 0x13, 0x31, - 0x10, 0x8e, 0x9b, 0xf2, 0x53, 0x57, 0x45, 0xb0, 0xca, 0x21, 0xe4, 0xb0, 0x89, 0x56, 0x08, 0x55, - 0x48, 0x59, 0xab, 0x85, 0x13, 0x27, 0xb2, 0x42, 0xaa, 0xe0, 0xc6, 0x52, 0x2e, 0x5c, 0x22, 0x6f, - 0x32, 0x38, 0x16, 0xb1, 0xbd, 0xb2, 0xbd, 0xa8, 0xe9, 0x23, 0x70, 0xea, 0x33, 0xf0, 0x04, 0x20, - 0xf5, 0x21, 0x22, 0x4e, 0x15, 0x27, 0x4e, 0xfc, 0x24, 0x07, 0x5e, 0x03, 0xc5, 0xde, 0x85, 0x84, - 0x54, 0x22, 0x87, 0x5e, 0x2c, 0x8f, 0xe7, 0xfb, 0x66, 0xbe, 0xf9, 0xe4, 0xc1, 0x9d, 0x81, 0x32, - 0x42, 0x19, 0x42, 0x0b, 0x3b, 0x3a, 0x25, 0xef, 0x0e, 0x32, 0xb0, 0xf4, 0xc0, 0x47, 0x71, 0xae, - 0x95, 0x55, 0x41, 0xc3, 0x23, 0x62, 0xff, 0x56, 0x22, 0x5a, 0x77, 0xa8, 0xe0, 0x52, 0x11, 0x77, - 0x7a, 0x60, 0xeb, 0xae, 0x07, 0xf6, 0x5d, 0x44, 0x4a, 0x96, 0x4f, 0xb5, 0x99, 0x52, 0x6c, 0x0c, - 0xc4, 0x45, 0x59, 0xf1, 0x86, 0x58, 0x2e, 0xc0, 0x58, 0x2a, 0xf2, 0x12, 0xd0, 0x60, 0x8a, 0x29, - 0x4f, 0x5c, 0xdc, 0xaa, 0x8a, 0xff, 0xd2, 0xa8, 0x9c, 0x94, 0xa9, 0xb0, 0xd4, 0x9d, 0x51, 0x03, - 0x7f, 0x64, 0x0f, 0x14, 0x97, 0x3e, 0x1f, 0x59, 0xdc, 0x38, 0x02, 0x09, 0x9a, 0x0f, 0x7a, 0x85, - 0x1d, 0x29, 0xcd, 0x4f, 0xa9, 0xe5, 0x4a, 0x06, 0xb7, 0x71, 0x5d, 0x18, 0xd6, 0x44, 0x1d, 0xb4, - 0xbf, 0x93, 0x2e, 0xae, 0x8f, 0x9f, 0x7f, 0x3e, 0xef, 0x46, 0x97, 0xcd, 0x18, 0xaf, 0x30, 0xdf, - 0xff, 0xfa, 0xf8, 0xa0, 0xed, 0x61, 0x5d, 0x33, 0x7c, 0x4b, 0x2e, 0xab, 0x1e, 0x7d, 0x42, 0xf8, - 0xda, 0x91, 0xa6, 0xd2, 0x06, 0x19, 0xde, 0xa3, 0xcb, 0x29, 0xd7, 0x71, 0xf7, 0xb0, 0x11, 0xfb, - 0x91, 0xe2, 0x6a, 0xa4, 0xb8, 0x27, 0x27, 0xc9, 0xfd, 0xcd, 0x24, 0xa4, 0xab, 0x25, 0x83, 0xa7, - 0x18, 0xc3, 0x49, 0xce, 0xb5, 0x6f, 0xb0, 0xe5, 0x1a, 0xb4, 0xd6, 0x1a, 0x1c, 0x57, 0x56, 0x27, - 0x37, 0xa7, 0xdf, 0xda, 0xe8, 0xec, 0x7b, 0x1b, 0xa5, 0x4b, 0xbc, 0xe8, 0xc3, 0x16, 0x0e, 0x9c, - 0xe6, 0x55, 0xa3, 0x0e, 0xf1, 0x0d, 0xb6, 0x78, 0x05, 0xed, 0xcd, 0x4a, 0x9a, 0x5f, 0xce, 0xbb, - 0xd5, 0x5f, 0xe8, 0x0d, 0x87, 0x1a, 0x8c, 0x79, 0x69, 0x35, 0x97, 0x2c, 0xad, 0x80, 0x7f, 0x39, - 0xe0, 0xd4, 0x6c, 0xc0, 0x81, 0x75, 0xa3, 0xea, 0x57, 0x6f, 0xd4, 0x93, 0x15, 0xa3, 0xb6, 0xff, - 0x6b, 0xd4, 0xf6, 0x9a, 0x49, 0x8f, 0xf0, 0x2d, 0xe7, 0xd1, 0x8b, 0x02, 0x0a, 0x78, 0x66, 0x41, - 0x04, 0x11, 0xde, 0x13, 0x86, 0xf5, 0xed, 0x24, 0x87, 0x7e, 0xa1, 0xc7, 0xa6, 0x89, 0x3a, 0xf5, - 0xfd, 0x9d, 0x74, 0x57, 0x18, 0x76, 0x3c, 0xc9, 0xe1, 0x95, 0x1e, 0x9b, 0x24, 0x99, 0xfe, 0x0c, - 0x6b, 0xd3, 0x59, 0x88, 0x2e, 0x66, 0x21, 0xfa, 0x31, 0x0b, 0xd1, 0xd9, 0x3c, 0xac, 0x5d, 0xcc, - 0xc3, 0xda, 0xd7, 0x79, 0x58, 0x7b, 0x7d, 0x8f, 0x71, 0x3b, 0x2a, 0xb2, 0x78, 0xa0, 0x44, 0xb9, - 0x2d, 0x64, 0xe9, 0x7f, 0x9d, 0xf8, 0x25, 0xcc, 0xae, 0x3b, 0x7d, 0x0f, 0x7f, 0x07, 0x00, 0x00, - 0xff, 0xff, 0xca, 0xa0, 0x5a, 0x47, 0xa9, 0x03, 0x00, 0x00, + // 505 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x53, 0xcd, 0x6e, 0xd3, 0x40, + 0x10, 0xce, 0x36, 0x2d, 0x6d, 0xb7, 0x2d, 0x02, 0xcb, 0x87, 0x34, 0x07, 0x27, 0xb2, 0x10, 0x8a, + 0x2a, 0xc5, 0x56, 0x0b, 0x27, 0x4e, 0xc4, 0x42, 0xaa, 0x28, 0x27, 0x4c, 0xb9, 0x70, 0x89, 0xd6, + 0xc9, 0xb0, 0x31, 0xd8, 0x5e, 0x6b, 0x7f, 0x68, 0x9d, 0x47, 0xe0, 0xd4, 0x67, 0xe0, 0x09, 0x38, + 0xf4, 0x1d, 0x88, 0x38, 0x55, 0x9c, 0x38, 0xf1, 0x93, 0x1c, 0x78, 0x0d, 0x94, 0x5d, 0x1b, 0x92, + 0xb6, 0x12, 0x3d, 0x70, 0x59, 0xed, 0xec, 0x7c, 0xdf, 0xcc, 0x7c, 0x9f, 0x66, 0x71, 0x7b, 0xc0, + 0x44, 0xca, 0x84, 0x4f, 0x94, 0x1c, 0x8d, 0xfd, 0x77, 0xfb, 0x11, 0x48, 0xb2, 0x6f, 0x22, 0x2f, + 0xe7, 0x4c, 0x32, 0xcb, 0x36, 0x08, 0xcf, 0xbc, 0x95, 0x88, 0xe6, 0x5d, 0x92, 0xc6, 0x19, 0xf3, + 0xf5, 0x69, 0x80, 0xcd, 0x5d, 0x03, 0xec, 0xeb, 0xc8, 0x2f, 0x59, 0x26, 0xd5, 0xa2, 0x8c, 0xd1, + 0x04, 0x7c, 0x1d, 0x45, 0xea, 0xb5, 0x2f, 0xe3, 0x14, 0x84, 0x24, 0x69, 0x5e, 0x02, 0x6c, 0xca, + 0x28, 0x33, 0xc4, 0xf9, 0xad, 0xaa, 0x78, 0x99, 0x46, 0xb2, 0xa2, 0x4c, 0x39, 0xe5, 0xdc, 0x11, + 0x11, 0xf0, 0x67, 0xec, 0x01, 0x8b, 0x33, 0x93, 0x77, 0x25, 0xb6, 0x0f, 0x21, 0x03, 0x1e, 0x0f, + 0x7a, 0x4a, 0x8e, 0x18, 0x8f, 0xc7, 0x44, 0xc6, 0x2c, 0xb3, 0xee, 0xe0, 0x7a, 0x2a, 0x68, 0x03, + 0xb5, 0x51, 0x67, 0x33, 0x9c, 0x5f, 0x1f, 0x1d, 0x7d, 0x3e, 0xef, 0xba, 0xd7, 0x69, 0xf4, 0x96, + 0x98, 0xef, 0x7f, 0x7d, 0xdc, 0x6b, 0x19, 0x58, 0x57, 0x0c, 0xdf, 0xfa, 0xd7, 0x55, 0x77, 0x3f, + 0x21, 0xbc, 0x76, 0xc8, 0x49, 0x26, 0xad, 0x08, 0xef, 0x90, 0xc5, 0x94, 0xee, 0xb8, 0x75, 0x60, + 0x7b, 0x46, 0x92, 0x57, 0x49, 0xf2, 0x7a, 0x59, 0x11, 0xdc, 0xbf, 0xd9, 0x08, 0xe1, 0x72, 0x49, + 0xeb, 0x09, 0xc6, 0x70, 0x9a, 0xc7, 0xdc, 0x34, 0x58, 0xd1, 0x0d, 0x9a, 0x57, 0x1a, 0x1c, 0x57, + 0x56, 0x07, 0x1b, 0x93, 0x6f, 0x2d, 0x74, 0xf6, 0xbd, 0x85, 0xc2, 0x05, 0x9e, 0x65, 0xe3, 0x35, + 0xae, 0x12, 0x10, 0x8d, 0x7a, 0x1b, 0x75, 0xb6, 0x43, 0x13, 0xb8, 0x1f, 0x56, 0xb0, 0xa5, 0x95, + 0x2c, 0xdb, 0x77, 0x80, 0xd7, 0xe9, 0xfc, 0x15, 0xb8, 0xb1, 0x30, 0x68, 0x7c, 0x39, 0xef, 0x56, + 0x1b, 0xd2, 0x1b, 0x0e, 0x39, 0x08, 0xf1, 0x42, 0xf2, 0x38, 0xa3, 0x61, 0x05, 0xfc, 0xcb, 0x01, + 0x3d, 0xe3, 0x0d, 0x38, 0x70, 0xd5, 0xbe, 0xfa, 0xff, 0xb7, 0xef, 0xf1, 0x92, 0x7d, 0xab, 0xff, + 0xb4, 0x6f, 0xf5, 0xb2, 0x75, 0xee, 0x43, 0x7c, 0x5b, 0x7b, 0xf4, 0x5c, 0x81, 0x82, 0xa7, 0x12, + 0x52, 0xcb, 0xc5, 0x3b, 0xa9, 0xa0, 0x7d, 0x59, 0xe4, 0xd0, 0x57, 0x3c, 0x11, 0x0d, 0xd4, 0xae, + 0x77, 0x36, 0xc3, 0xad, 0x54, 0xd0, 0xe3, 0x22, 0x87, 0x97, 0x3c, 0x11, 0xee, 0x1e, 0xde, 0x99, + 0xcf, 0x35, 0x0e, 0x55, 0x02, 0xcf, 0xa0, 0x10, 0xd6, 0x2e, 0xde, 0xe0, 0xe4, 0xa4, 0xff, 0x46, + 0x94, 0x6b, 0xb2, 0x1d, 0xae, 0x73, 0x72, 0x72, 0x24, 0x58, 0x16, 0x04, 0x93, 0x9f, 0x4e, 0x6d, + 0x32, 0x75, 0xd0, 0xc5, 0xd4, 0x41, 0x3f, 0xa6, 0x0e, 0x3a, 0x9b, 0x39, 0xb5, 0x8b, 0x99, 0x53, + 0xfb, 0x3a, 0x73, 0x6a, 0xaf, 0xee, 0xd1, 0x58, 0x8e, 0x54, 0xe4, 0x0d, 0x58, 0x5a, 0xfe, 0x37, + 0x7f, 0x61, 0x43, 0x4f, 0xcd, 0x37, 0x8e, 0x6e, 0x69, 0x2d, 0x0f, 0x7e, 0x07, 0x00, 0x00, 0xff, + 0xff, 0x5e, 0x66, 0xb7, 0xda, 0xeb, 0x03, 0x00, 0x00, } func (m *GenericAuthorization) Marshal() (dAtA []byte, err error) { @@ -287,6 +331,13 @@ func (m *Grant) 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 = encodeVarintAuthz(dAtA, i, uint64(len(m.Rules))) + 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 { @@ -403,6 +454,36 @@ func (m *GrantQueueItem) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *AuthzRuleKeys) 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 *AuthzRuleKeys) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AuthzRuleKeys) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.RawJson) > 0 { + i -= len(m.RawJson) + copy(dAtA[i:], m.RawJson) + i = encodeVarintAuthz(dAtA, i, uint64(len(m.RawJson))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintAuthz(dAtA []byte, offset int, v uint64) int { offset -= sovAuthz(v) base := offset @@ -441,6 +522,10 @@ func (m *Grant) Size() (n int) { l = github_com_cosmos_gogoproto_types.SizeOfStdTime(*m.Expiration) n += 1 + l + sovAuthz(uint64(l)) } + l = len(m.Rules) + if l > 0 { + n += 1 + l + sovAuthz(uint64(l)) + } return n } @@ -484,6 +569,19 @@ func (m *GrantQueueItem) Size() (n int) { return n } +func (m *AuthzRuleKeys) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.RawJson) + if l > 0 { + n += 1 + l + sovAuthz(uint64(l)) + } + return n +} + func sovAuthz(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -673,6 +771,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 byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuthz + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAuthz + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAuthz + } + 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 := skipAuthz(dAtA[iNdEx:]) @@ -962,6 +1094,90 @@ func (m *GrantQueueItem) Unmarshal(dAtA []byte) error { } return nil } +func (m *AuthzRuleKeys) 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: AuthzRuleKeys: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AuthzRuleKeys: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RawJson", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuthz + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAuthz + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAuthz + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RawJson = append(m.RawJson[:0], dAtA[iNdEx:postIndex]...) + if m.RawJson == nil { + m.RawJson = []byte{} + } + 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/generic_authorization.go b/x/authz/generic_authorization.go index a7c790e02bf1..535ff2a93383 100644 --- a/x/authz/generic_authorization.go +++ b/x/authz/generic_authorization.go @@ -2,6 +2,7 @@ package authz import ( "context" + "encoding/json" "errors" sdk "github.com/cosmos/cosmos-sdk/types" @@ -33,3 +34,7 @@ func (a GenericAuthorization) ValidateBasic() error { } return nil } + +func (a GenericAuthorization) GetOptions() json.RawMessage { + return nil +} diff --git a/x/authz/keeper/genesis_test.go b/x/authz/keeper/genesis_test.go index 015e24d34168..94320f0ff654 100644 --- a/x/authz/keeper/genesis_test.go +++ b/x/authz/keeper/genesis_test.go @@ -67,7 +67,7 @@ func (suite *GenesisTestSuite) SetupTest() { msr := suite.baseApp.MsgServiceRouter() msr.SetInterfaceRegistry(suite.encCfg.InterfaceRegistry) - suite.keeper = keeper.NewKeeper(storeService, suite.encCfg.Codec, msr, suite.accountKeeper, nil) + suite.keeper = keeper.NewKeeper(storeService, suite.encCfg.Codec, msr, suite.accountKeeper) } func (suite *GenesisTestSuite) TestImportExportGenesis() { diff --git a/x/authz/keeper/keeper.go b/x/authz/keeper/keeper.go index ea66cd73017d..d1567f6bebf1 100644 --- a/x/authz/keeper/keeper.go +++ b/x/authz/keeper/keeper.go @@ -3,6 +3,7 @@ package keeper import ( "bytes" "context" + "encoding/json" "fmt" "strconv" "time" @@ -34,17 +35,15 @@ type Keeper struct { cdc codec.Codec router baseapp.MessageRouter authKeeper authz.AccountKeeper - authzOptions map[string]map[string]string } // NewKeeper constructs a message authorization Keeper -func NewKeeper(storeService corestoretypes.KVStoreService, cdc codec.Codec, router baseapp.MessageRouter, ak authz.AccountKeeper, options map[string]map[string]string) Keeper { +func NewKeeper(storeService corestoretypes.KVStoreService, cdc codec.Codec, router baseapp.MessageRouter, ak authz.AccountKeeper) Keeper { return Keeper{ storeService: storeService, cdc: cdc, router: router, authKeeper: ak, - authzOptions: options, } } @@ -70,8 +69,59 @@ func (k Keeper) getGrant(ctx context.Context, skey []byte) (grant authz.Grant, f return grant, true } +func (k Keeper) SetAuthzRulesKeys(ctx context.Context, options json.RawMessage) error { + store := k.storeService.OpenKVStore(ctx) + + optionsBytes, err := json.Marshal(options) + if err != nil { + return err + } + + authzRuleKeys := authz.AuthzRuleKeys{ + RawJson: optionsBytes, + } + + bz, err := k.cdc.Marshal(&authzRuleKeys) + if err != nil { + return err + } + + err = store.Set(AuthzOptionsKeys, bz) + return err +} + +func (k Keeper) GetAuthzRulesKeys(ctx context.Context) (map[string]interface{}, error) { + store := k.storeService.OpenKVStore(ctx) + bz, err := store.Get(AuthzOptionsKeys) + + if err != nil { + return nil, err + } + + var keys json.RawMessage + var authzRuleKeys authz.AuthzRuleKeys + err = k.cdc.Unmarshal(bz, &authzRuleKeys) + if err != nil { + return nil, err + } + + err = json.Unmarshal(authzRuleKeys.RawJson, &keys) + if err != nil { + return nil, err + } + + rules := map[string]interface{}{ + "Send": []string{"AllowRecipients", "SpendLImit"}, + "Stake": []string{"DelegateLimit"}, + } + + return rules, nil + + // return keys, nil +} + func (k Keeper) GetAuthzOptions() map[string]map[string]string { - return k.authzOptions + return nil } func (k Keeper) update(ctx context.Context, grantee, granter sdk.AccAddress, updated authz.Authorization) error { @@ -308,6 +358,27 @@ 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, map[string]interface{}) { + 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 + } + + auth, err := grant.GetAuthorization() + if err != nil { + return nil, nil + } + + var rules map[string]interface{} + err = json.Unmarshal(grant.Rules, &rules) + if err != nil { + return nil, nil + } + + return auth, 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. diff --git a/x/authz/keeper/keeper_test.go b/x/authz/keeper/keeper_test.go index dc54d698cfcc..066e7d70750a 100644 --- a/x/authz/keeper/keeper_test.go +++ b/x/authz/keeper/keeper_test.go @@ -75,7 +75,7 @@ func (s *TestSuite) SetupTest() { banktypes.RegisterInterfaces(s.encCfg.InterfaceRegistry) banktypes.RegisterMsgServer(s.baseApp.MsgServiceRouter(), s.bankKeeper) - s.authzKeeper = authzkeeper.NewKeeper(storeService, s.encCfg.Codec, s.baseApp.MsgServiceRouter(), s.accountKeeper, nil) + s.authzKeeper = authzkeeper.NewKeeper(storeService, s.encCfg.Codec, s.baseApp.MsgServiceRouter(), s.accountKeeper) queryHelper := baseapp.NewQueryServerTestHelper(s.ctx, s.encCfg.InterfaceRegistry) authz.RegisterQueryServer(queryHelper, s.authzKeeper) diff --git a/x/authz/keeper/keys.go b/x/authz/keeper/keys.go index a1e3d15ad684..120af14b652e 100644 --- a/x/authz/keeper/keys.go +++ b/x/authz/keeper/keys.go @@ -18,7 +18,7 @@ import ( var ( GrantKey = []byte{0x01} // prefix for each key GrantQueuePrefix = []byte{0x02} - AuthzRulesPrefix = []byte{0x03} + AuthzOptionsKeys = []byte{0x04} ) var lenTime = len(sdk.FormatTimeBytes(time.Now())) @@ -98,8 +98,3 @@ func firstAddressFromGrantStoreKey(key []byte) sdk.AccAddress { addrLen := key[0] return sdk.AccAddress(key[1 : 1+addrLen]) } - -// func BuildAuthzRulesKey(grantName string) []byte { -// g := conv.UnsafeStrToBytes(grantName) -// return append(AuthzRulesPrefix, g...) -// } diff --git a/x/authz/module/abci_test.go b/x/authz/module/abci_test.go index fef295766f6c..12055e0cfa12 100644 --- a/x/authz/module/abci_test.go +++ b/x/authz/module/abci_test.go @@ -65,7 +65,7 @@ func TestExpiredGrantsQueue(t *testing.T) { accountKeeper.EXPECT().AddressCodec().Return(address.NewBech32Codec("cosmos")).AnyTimes() - authzKeeper := keeper.NewKeeper(storeService, encCfg.Codec, baseApp.MsgServiceRouter(), accountKeeper, nil) + 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) diff --git a/x/authz/module/module.go b/x/authz/module/module.go index c749a14b95c8..248a75b8584b 100644 --- a/x/authz/module/module.go +++ b/x/authz/module/module.go @@ -176,7 +176,7 @@ type ModuleOutputs struct { } func ProvideModule(in ModuleInputs) ModuleOutputs { - k := keeper.NewKeeper(in.StoreService, in.Cdc, in.MsgServiceRouter, in.AccountKeeper, nil) + k := keeper.NewKeeper(in.StoreService, in.Cdc, in.MsgServiceRouter, in.AccountKeeper) m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.BankKeeper, in.Registry) return ModuleOutputs{AuthzKeeper: k, Module: m} } diff --git a/x/bank/types/send_authorization.go b/x/bank/types/send_authorization.go index 22449301700b..9c174058ea50 100644 --- a/x/bank/types/send_authorization.go +++ b/x/bank/types/send_authorization.go @@ -2,6 +2,7 @@ package types import ( context "context" + "encoding/json" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -96,3 +97,7 @@ func toBech32Addresses(allowed []sdk.AccAddress) []string { return allowedAddrs } + +func (a SendAuthorization) GetOptions() json.RawMessage { + return nil +} diff --git a/x/staking/types/authz.go b/x/staking/types/authz.go index 284be1fa5af8..223e1fe7641e 100644 --- a/x/staking/types/authz.go +++ b/x/staking/types/authz.go @@ -2,6 +2,7 @@ package types import ( context "context" + "encoding/json" errorsmod "cosmossdk.io/errors" @@ -153,6 +154,10 @@ func (a StakeAuthorization) Accept(ctx context.Context, msg sdk.Msg) (authz.Acce }, nil } +func (a StakeAuthorization) GetOptions() json.RawMessage { + return nil +} + func validateAllowAndDenyValidators(allowed, denied []sdk.ValAddress) ([]string, []string, error) { if len(allowed) == 0 && len(denied) == 0 { return nil, nil, sdkerrors.ErrInvalidRequest.Wrap("both allowed & deny list cannot be empty") From 24b70aa0e8e0488313b88b55ed356cf4561409f2 Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 15 May 2024 15:22:34 +0530 Subject: [PATCH 13/30] permissions --- scripts/README.md | 0 scripts/dep-assert.sh | 0 scripts/go-lint-all.bash | 0 scripts/go-mod-tidy-all.sh | 0 scripts/go-update-dep-all.sh | 0 scripts/init-simapp.sh | 0 scripts/mockgen.sh | 0 scripts/protoc-swagger-gen.sh | 0 scripts/protocgen-pulsar.sh | 0 scripts/protocgen.sh | 0 scripts/validate-gentxs.sh | 0 11 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 scripts/README.md mode change 100644 => 100755 scripts/dep-assert.sh mode change 100644 => 100755 scripts/go-lint-all.bash mode change 100644 => 100755 scripts/go-mod-tidy-all.sh mode change 100644 => 100755 scripts/go-update-dep-all.sh mode change 100644 => 100755 scripts/init-simapp.sh mode change 100644 => 100755 scripts/mockgen.sh mode change 100644 => 100755 scripts/protoc-swagger-gen.sh mode change 100644 => 100755 scripts/protocgen-pulsar.sh mode change 100644 => 100755 scripts/protocgen.sh mode change 100644 => 100755 scripts/validate-gentxs.sh diff --git a/scripts/README.md b/scripts/README.md old mode 100644 new mode 100755 diff --git a/scripts/dep-assert.sh b/scripts/dep-assert.sh old mode 100644 new mode 100755 diff --git a/scripts/go-lint-all.bash b/scripts/go-lint-all.bash old mode 100644 new mode 100755 diff --git a/scripts/go-mod-tidy-all.sh b/scripts/go-mod-tidy-all.sh old mode 100644 new mode 100755 diff --git a/scripts/go-update-dep-all.sh b/scripts/go-update-dep-all.sh old mode 100644 new mode 100755 diff --git a/scripts/init-simapp.sh b/scripts/init-simapp.sh old mode 100644 new mode 100755 diff --git a/scripts/mockgen.sh b/scripts/mockgen.sh old mode 100644 new mode 100755 diff --git a/scripts/protoc-swagger-gen.sh b/scripts/protoc-swagger-gen.sh old mode 100644 new mode 100755 diff --git a/scripts/protocgen-pulsar.sh b/scripts/protocgen-pulsar.sh old mode 100644 new mode 100755 diff --git a/scripts/protocgen.sh b/scripts/protocgen.sh old mode 100644 new mode 100755 diff --git a/scripts/validate-gentxs.sh b/scripts/validate-gentxs.sh old mode 100644 new mode 100755 From 7c4fab896ba70714688e4c67a5837d205ccf192d Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 15 May 2024 17:07:45 +0530 Subject: [PATCH 14/30] working POC --- api/cosmos/authz/v1beta1/tx.pulsar.go | 200 ++++++++++++++++++-------- proto/cosmos/authz/v1beta1/tx.proto | 3 + simapp/ante.go | 2 +- x/auth/ante/authz_rules_ante.go | 104 +++++++------- x/auth/ante/expected_keepers.go | 1 - x/authz/authorization_grant.go | 20 +++ x/authz/client/cli/tx.go | 17 +++ x/authz/keeper/keeper.go | 55 ++++++- x/authz/keeper/msg_server.go | 2 +- x/authz/msgs.go | 4 + x/authz/tx.pb.go | 120 +++++++++++----- 11 files changed, 370 insertions(+), 158 deletions(-) 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/tx.proto b/proto/cosmos/authz/v1beta1/tx.proto index a1abff0d6f00..858b582dcd05 100644 --- 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/simapp/ante.go b/simapp/ante.go index f6409a2073e1..11676d622c2c 100644 --- a/simapp/ante.go +++ b/simapp/ante.go @@ -40,7 +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), + ante.NewAuthzDecorator(options.AuthzKeeper, options.AccountKeeper), 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/x/auth/ante/authz_rules_ante.go b/x/auth/ante/authz_rules_ante.go index 74c813899593..8a15c49a2641 100644 --- a/x/auth/ante/authz_rules_ante.go +++ b/x/auth/ante/authz_rules_ante.go @@ -1,7 +1,6 @@ package ante import ( - "fmt" "strings" errorsmod "cosmossdk.io/errors" @@ -12,13 +11,20 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" ) +const ( + AllowedRecipients = "allowed_recipients" + MaxAmount = "max_amount" +) + type AuthzDecorator struct { azk AuthzKeeper + ak AccountKeeper } -func NewAuthzDecorator(azk AuthzKeeper) AuthzDecorator { +func NewAuthzDecorator(azk AuthzKeeper, ak AccountKeeper) AuthzDecorator { return AuthzDecorator{ azk: azk, + ak: ak, } } @@ -41,11 +47,6 @@ func (azd AuthzDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, // Check if the message is an authorization message if authzMsg, ok := msg.(*authztypes.MsgExec); ok { - rulesKeys, err := azd.azk.GetAuthzRulesKeys(ctx) - if err != nil { - return ctx, err - } - msgs, err := authzMsg.GetMessages() if err != nil { return ctx, err @@ -54,24 +55,10 @@ func (azd AuthzDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, for _, innerMsg := range msgs { switch innerMsgConverted := innerMsg.(type) { case *banktypes.MsgSend: - sendRuleKeysInterface, ok := rulesKeys["Send"] - if !ok { - fmt.Println("no rule keys") - continue - } - - granter, err := azd.azk.AddressCodec().StringToBytes(innerMsgConverted.FromAddress) - if err != nil { + isRulesBroken, err := azd.handleSendAuthzRules(ctx, innerMsgConverted, grantee) + if isRulesBroken { return ctx, err } - - _, rules := azd.azk.GetAuthzWithRules(ctx, grantee, granter, sdk.MsgTypeURL(&banktypes.MsgSend{})) - if rules != nil { - sendRulesKeys := sendRuleKeysInterface.([]string) - if checkSendAuthzRulesViolated(innerMsgConverted, rules, sendRulesKeys) { - return ctx, fmt.Errorf("authz rules are not meeting") - } - } } } } @@ -81,49 +68,56 @@ func (azd AuthzDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, return next(ctx, tx, simulate) } -// checkSendAuthzRulesViolated returns true if the rules are voilated -func checkSendAuthzRulesViolated(msg *banktypes.MsgSend, sendAuthzRules map[string]interface{}, sendRulesKeys []string) bool { - for _, key := range sendRulesKeys { - - fmt.Printf("\">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\": %v\n", ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>") - fmt.Printf("sendAuthzRules: %v\n", sendAuthzRules) - if blockedAddrsStrInt, ok := sendAuthzRules["AllowRecipients"]; key == "AllowRecipients" && ok { - blockedAddrsStr := blockedAddrsStrInt.(string) - blockedAddrs := strings.Split(blockedAddrsStr, ",") - for _, blockedRecipient := range blockedAddrs { - if msg.ToAddress == blockedRecipient { - return true +// handleCheckSendAuthzRules returns true if the rules are voilated +func (azd AuthzDecorator) handleSendAuthzRules(ctx sdk.Context, msg *banktypes.MsgSend, grantee []byte) (bool, error) { + + granter, err := azd.ak.AddressCodec().StringToBytes(msg.FromAddress) + if err != nil { + return true, err + } + + _, rules := azd.azk.GetAuthzWithRules(ctx, grantee, granter, sdk.MsgTypeURL(&banktypes.MsgSend{})) + if rules != nil { + if allowedAddrs, ok := rules[AllowedRecipients]; ok { + allowedAddrsValue := allowedAddrs.(string) + allowedAddrs := strings.Split(allowedAddrsValue, ",") + isAllowed := false + for _, allowedRecipient := range allowedAddrs { + if msg.ToAddress == allowedRecipient { + isAllowed = true + break } } + + if !isAllowed { + return true, errorsmod.Wrap(sdkerrors.ErrTxDecode, "Recipient is not in the allowed list of the grant") + } } - if spendLimitInt, ok := sendAuthzRules["SpendLImit"]; key == "SpendLImit" && ok { - spendLimit := spendLimitInt.(string) + if spendLimitInterface, ok := rules[MaxAmount]; ok { + spendLimit := spendLimitInterface.(string) limit, err := sdk.ParseCoinsNormalized(spendLimit) if err != nil { - return true + return true, err } if !limit.IsAllGTE(msg.Amount) { - return true + return true, errorsmod.Wrap(sdkerrors.ErrTxDecode, "Amount exceeds the max_amount limit set by the granter") } - - return true } - } - return false + return false, nil } -func checkGenericAuthzRules(_ *authztypes.MsgGrant, authz *authztypes.GenericAuthorization, genericRules map[string]string) bool { - if msgsStr, ok := genericRules["blockedMessages"]; ok { - msgs := strings.Split(msgsStr, ",") - for _, v := range msgs { - if v == authz.Msg { - return true - } - } - } - - return false -} +// func checkGenericAuthzRules(_ *authztypes.MsgGrant, authz *authztypes.GenericAuthorization, genericRules map[string]string) bool { +// if msgsStr, ok := genericRules["blockedMessages"]; ok { +// msgs := strings.Split(msgsStr, ",") +// for _, v := range msgs { +// if v == authz.Msg { +// return true +// } +// } +// } + +// return false +// } diff --git a/x/auth/ante/expected_keepers.go b/x/auth/ante/expected_keepers.go index 5632a915dafb..1478fc45a2a8 100644 --- a/x/auth/ante/expected_keepers.go +++ b/x/auth/ante/expected_keepers.go @@ -29,5 +29,4 @@ type AuthzKeeper interface { GetAuthzOptions() map[string]map[string]string GetAuthzRulesKeys(ctx context.Context) (map[string]interface{}, error) GetAuthzWithRules(ctx context.Context, grantee, granter sdk.AccAddress, msgType string) (authz.Authorization, map[string]interface{}) - AddressCodec() address.Codec } diff --git a/x/authz/authorization_grant.go b/x/authz/authorization_grant.go index cb2088316fc0..2b3efd6cbaaa 100644 --- a/x/authz/authorization_grant.go +++ b/x/authz/authorization_grant.go @@ -32,6 +32,26 @@ func NewGrant(blockTime time.Time, a Authorization, expiration *time.Time) (Gran }, nil } +// NewGrantWithRules does the same as NewGrant but takes rules as extra arg. +func NewGrantWithRules(blockTime time.Time, a Authorization, expiration *time.Time, rules []byte) (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)) + } + msg, ok := a.(proto.Message) + if !ok { + return Grant{}, sdkerrors.ErrPackAny.Wrapf("cannot proto marshal %T", a) + } + any, err := cdctypes.NewAnyWithValue(msg) + if err != nil { + return Grant{}, err + } + return Grant{ + Expiration: expiration, + Authorization: any, + Rules: rules, + }, nil +} + var _ cdctypes.UnpackInterfacesMessage = &Grant{} // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces 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/keeper/keeper.go b/x/authz/keeper/keeper.go index d1567f6bebf1..68990079cdb4 100644 --- a/x/authz/keeper/keeper.go +++ b/x/authz/keeper/keeper.go @@ -110,9 +110,13 @@ func (k Keeper) GetAuthzRulesKeys(ctx context.Context) (map[string]interface{}, return nil, err } + // rules := map[string]interface{}{ + // "Send": []string{"AllowRecipients", "SpendLImit"}, + // "Stake": []string{"DelegateLimit"}, + // } rules := map[string]interface{}{ - "Send": []string{"AllowRecipients", "SpendLImit"}, - "Stake": []string{"DelegateLimit"}, + // "Send": []string{"AllowRecipients", "SpendLImit"}, + // "Stake": []string{"DelegateLimit"}, } return rules, nil @@ -283,6 +287,53 @@ func (k Keeper) SaveGrant(ctx context.Context, grantee, granter sdk.AccAddress, }) } +// SaveGrantWithRules method does the same as SaveGrant method but stores rules. +func (k Keeper) SaveGrantWithRules(ctx context.Context, grantee, granter sdk.AccAddress, authorization authz.Authorization, expiration *time.Time, rules []byte) error { + sdkCtx := sdk.UnwrapSDKContext(ctx) + msgType := authorization.MsgTypeURL() + store := k.storeService.OpenKVStore(ctx) + skey := grantStoreKey(grantee, granter, msgType) + + grant, err := authz.NewGrantWithRules(sdkCtx.BlockTime(), authorization, expiration, rules) + if err != nil { + return err + } + + var oldExp *time.Time + if oldGrant, found := k.getGrant(ctx, skey); found { + oldExp = oldGrant.Expiration + } + + if oldExp != nil && (expiration == nil || !oldExp.Equal(*expiration)) { + if err = k.removeFromGrantQueue(ctx, skey, granter, grantee, *oldExp); err != nil { + return err + } + } + + // If the expiration didn't change, then we don't remove it and we should not insert again + if expiration != nil && (oldExp == nil || !oldExp.Equal(*expiration)) { + if err = k.insertIntoGrantQueue(ctx, granter, grantee, msgType, *expiration); err != nil { + return err + } + } + + bz, err := k.cdc.Marshal(&grant) + if err != nil { + return err + } + + err = store.Set(skey, bz) + if err != nil { + return err + } + + return sdkCtx.EventManager().EmitTypedEvent(&authz.EventGrant{ + MsgTypeUrl: authorization.MsgTypeURL(), + Granter: granter.String(), + Grantee: grantee.String(), + }) +} + // DeleteGrant revokes any authorization for the provided message type granted to the grantee // by the granter. func (k Keeper) DeleteGrant(ctx context.Context, grantee, granter sdk.AccAddress, msgType string) error { diff --git a/x/authz/keeper/msg_server.go b/x/authz/keeper/msg_server.go index b6755a9f8436..80a7ffc05cad 100644 --- a/x/authz/keeper/msg_server.go +++ b/x/authz/keeper/msg_server.go @@ -52,7 +52,7 @@ 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) + err = k.SaveGrantWithRules(ctx, grantee, granter, authorization, msg.Grant.Expiration, msg.Rules) if err != nil { return nil, err } 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/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:]) From 62db0e7267df1dfbb4d808b096a0653c66413992 Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 22 May 2024 16:01:10 +0530 Subject: [PATCH 15/30] review changes --- api/cosmos/authz/v1beta1/authz.pulsar.go | 1463 ++++++++++++---------- api/cosmos/authz/v1beta1/tx.pulsar.go | 274 ++-- proto/cosmos/authz/v1beta1/authz.proto | 46 +- proto/cosmos/authz/v1beta1/tx.proto | 2 +- x/auth/ante/authz_rules_ante.go | 79 +- x/auth/ante/expected_keepers.go | 4 +- x/authz/authorization_grant.go | 21 +- x/authz/authorizations.go | 4 - x/authz/authz.pb.go | 483 +++---- x/authz/client/cli/tx.go | 41 +- x/authz/consts.go | 8 + x/authz/generic_authorization.go | 5 - x/authz/keeper/keeper.go | 121 +- x/authz/keeper/msg_server_test.go | 20 +- x/authz/msgs.go | 2 +- x/authz/msgs_test.go | 6 +- x/authz/simulation/decoder_test.go | 2 +- x/authz/tx.pb.go | 115 +- x/bank/types/send_authorization.go | 5 - x/staking/types/authz.go | 5 - 20 files changed, 1471 insertions(+), 1235 deletions(-) create mode 100644 x/authz/consts.go diff --git a/api/cosmos/authz/v1beta1/authz.pulsar.go b/api/cosmos/authz/v1beta1/authz.pulsar.go index 42424dd25f4f..865fe2408dc3 100644 --- a/api/cosmos/authz/v1beta1/authz.pulsar.go +++ b/api/cosmos/authz/v1beta1/authz.pulsar.go @@ -438,6 +438,57 @@ 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 @@ -531,7 +582,7 @@ func (x *fastReflection_Grant) Range(f func(protoreflect.FieldDescriptor, protor } } if len(x.Rules) != 0 { - value := protoreflect.ValueOfBytes(x.Rules) + value := protoreflect.ValueOfList(&_Grant_3_list{list: &x.Rules}) if !f(fd_Grant_rules, value) { return } @@ -602,8 +653,11 @@ func (x *fastReflection_Grant) Get(descriptor protoreflect.FieldDescriptor) prot value := x.Expiration return protoreflect.ValueOfMessage(value.ProtoReflect()) case "cosmos.authz.v1beta1.Grant.rules": - value := x.Rules - return protoreflect.ValueOfBytes(value) + 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")) @@ -629,7 +683,9 @@ func (x *fastReflection_Grant) Set(fd protoreflect.FieldDescriptor, value protor case "cosmos.authz.v1beta1.Grant.expiration": x.Expiration = value.Message().Interface().(*timestamppb.Timestamp) case "cosmos.authz.v1beta1.Grant.rules": - x.Rules = value.Bytes() + 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")) @@ -661,7 +717,11 @@ func (x *fastReflection_Grant) Mutable(fd protoreflect.FieldDescriptor) protoref } return protoreflect.ValueOfMessage(x.Expiration.ProtoReflect()) case "cosmos.authz.v1beta1.Grant.rules": - panic(fmt.Errorf("field rules of message cosmos.authz.v1beta1.Grant is not mutable")) + 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")) @@ -682,7 +742,8 @@ func (x *fastReflection_Grant) NewField(fd protoreflect.FieldDescriptor) protore m := new(timestamppb.Timestamp) return protoreflect.ValueOfMessage(m.ProtoReflect()) case "cosmos.authz.v1beta1.Grant.rules": - return protoreflect.ValueOfBytes(nil) + 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")) @@ -760,9 +821,11 @@ func (x *fastReflection_Grant) ProtoMethods() *protoiface.Methods { l = options.Size(x.Expiration) n += 1 + l + runtime.Sov(uint64(l)) } - l = len(x.Rules) - if l > 0 { - 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) @@ -794,11 +857,20 @@ func (x *fastReflection_Grant) ProtoMethods() *protoiface.Methods { 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] = 0x1a + 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) @@ -953,7 +1025,7 @@ func (x *fastReflection_Grant) ProtoMethods() *protoiface.Methods { 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 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow @@ -963,24 +1035,24 @@ func (x *fastReflection_Grant) ProtoMethods() *protoiface.Methods { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + if msglen < 0 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength } - postIndex := iNdEx + byteLen + 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[:0], dAtA[iNdEx:postIndex]...) - if x.Rules == nil { - x.Rules = []byte{} + 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: @@ -1018,32 +1090,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)) @@ -1055,43 +1169,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, @@ -1099,28 +1213,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) { - return - } - } - if x.Authorization != nil { - value := protoreflect.ValueOfMessage(x.Authorization.ProtoReflect()) - if !f(fd_GrantAuthorization_authorization, 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.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 } } @@ -1137,21 +1239,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())) } } @@ -1161,21 +1259,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())) } } @@ -1185,25 +1279,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())) } } @@ -1217,21 +1308,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())) } } @@ -1245,60 +1334,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") } @@ -1306,7 +1384,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 } @@ -1317,7 +1395,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 } @@ -1329,7 +1407,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 } @@ -1339,9 +1417,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, @@ -1353,21 +1431,15 @@ func (x *fastReflection_GrantAuthorization) ProtoMethods() *protoiface.Methods { 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) + l = len(x.Key) 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) @@ -1379,7 +1451,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, @@ -1398,47 +1470,21 @@ 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 + 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))) + } + 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] = 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 + dAtA[i] = 0xa } if input.Buf != nil { input.Buf = append(input.Buf, dAtA...) @@ -1451,7 +1497,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, @@ -1483,15 +1529,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 { @@ -1519,11 +1565,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 { @@ -1551,79 +1597,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 @@ -1660,72 +1634,32 @@ func (x *fastReflection_GrantAuthorization) ProtoMethods() *protoiface.Methods { } } -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 + 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_GrantQueueItem = File_cosmos_authz_v1beta1_authz_proto.Messages().ByName("GrantQueueItem") - fd_GrantQueueItem_msg_type_urls = md_GrantQueueItem.Fields().ByName("msg_type_urls") + 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_GrantQueueItem)(nil) +var _ protoreflect.Message = (*fastReflection_GrantAuthorization)(nil) -type fastReflection_GrantQueueItem GrantQueueItem +type fastReflection_GrantAuthorization GrantAuthorization -func (x *GrantQueueItem) ProtoReflect() protoreflect.Message { - return (*fastReflection_GrantQueueItem)(x) +func (x *GrantAuthorization) ProtoReflect() protoreflect.Message { + return (*fastReflection_GrantAuthorization)(x) } -func (x *GrantQueueItem) slowProtoReflect() protoreflect.Message { +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)) @@ -1737,43 +1671,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_GrantAuthorization_messageType fastReflection_GrantAuthorization_messageType +var _ protoreflect.MessageType = fastReflection_GrantAuthorization_messageType{} -type fastReflection_GrantQueueItem_messageType struct{} +type fastReflection_GrantAuthorization_messageType struct{} -func (x fastReflection_GrantQueueItem_messageType) Zero() protoreflect.Message { - return (*fastReflection_GrantQueueItem)(nil) +func (x fastReflection_GrantAuthorization_messageType) Zero() protoreflect.Message { + return (*fastReflection_GrantAuthorization)(nil) } -func (x fastReflection_GrantQueueItem_messageType) New() protoreflect.Message { - return new(fastReflection_GrantQueueItem) +func (x fastReflection_GrantAuthorization_messageType) New() protoreflect.Message { + return new(fastReflection_GrantAuthorization) } -func (x fastReflection_GrantQueueItem_messageType) Descriptor() protoreflect.MessageDescriptor { - return md_GrantQueueItem +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_GrantQueueItem) Descriptor() protoreflect.MessageDescriptor { - return md_GrantQueueItem +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_GrantQueueItem) Type() protoreflect.MessageType { - return _fastReflection_GrantQueueItem_messageType +func (x *fastReflection_GrantAuthorization) Type() protoreflect.MessageType { + return _fastReflection_GrantAuthorization_messageType } // New returns a newly allocated and mutable empty message. -func (x *fastReflection_GrantQueueItem) New() protoreflect.Message { - return new(fastReflection_GrantQueueItem) +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_GrantQueueItem) Interface() protoreflect.ProtoMessage { - return (*GrantQueueItem)(x) +func (x *fastReflection_GrantAuthorization) Interface() protoreflect.ProtoMessage { + return (*GrantAuthorization)(x) } // Range iterates over every populated field in an undefined order, @@ -1781,10 +1715,28 @@ 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_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 } } @@ -1801,15 +1753,21 @@ 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_GrantAuthorization) 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.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.GrantQueueItem")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.GrantAuthorization")) } - panic(fmt.Errorf("message cosmos.authz.v1beta1.GrantQueueItem does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message cosmos.authz.v1beta1.GrantAuthorization does not contain field %s", fd.FullName())) } } @@ -1819,15 +1777,21 @@ 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_GrantAuthorization) 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())) + 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())) } } @@ -1837,19 +1801,25 @@ 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_GrantAuthorization) 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) + 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.GrantQueueItem")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.GrantAuthorization")) } - panic(fmt.Errorf("message cosmos.authz.v1beta1.GrantQueueItem does not contain field %s", descriptor.FullName())) + panic(fmt.Errorf("message cosmos.authz.v1beta1.GrantAuthorization does not contain field %s", descriptor.FullName())) } } @@ -1863,17 +1833,21 @@ 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_GrantAuthorization) 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 + 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.GrantQueueItem")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.GrantAuthorization")) } - panic(fmt.Errorf("message cosmos.authz.v1beta1.GrantQueueItem does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message cosmos.authz.v1beta1.GrantAuthorization does not contain field %s", fd.FullName())) } } @@ -1887,45 +1861,60 @@ 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_GrantAuthorization) 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.GrantAuthorization.authorization": + if x.Authorization == nil { + x.Authorization = new(anypb.Any) } - value := &_GrantQueueItem_1_list{list: &x.MsgTypeUrls} - return protoreflect.ValueOfList(value) + 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.GrantQueueItem")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.GrantAuthorization")) } - panic(fmt.Errorf("message cosmos.authz.v1beta1.GrantQueueItem does not contain field %s", fd.FullName())) + 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_GrantQueueItem) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { +func (x *fastReflection_GrantAuthorization) 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}) + 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.GrantQueueItem")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.GrantAuthorization")) } - panic(fmt.Errorf("message cosmos.authz.v1beta1.GrantQueueItem does not contain field %s", fd.FullName())) + 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_GrantQueueItem) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { +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.GrantQueueItem", d.FullName())) + panic(fmt.Errorf("%s is not a oneof field in cosmos.authz.v1beta1.GrantAuthorization", d.FullName())) } panic("unreachable") } @@ -1933,7 +1922,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_GrantAuthorization) GetUnknown() protoreflect.RawFields { return x.unknownFields } @@ -1944,7 +1933,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_GrantAuthorization) SetUnknown(fields protoreflect.RawFields) { x.unknownFields = fields } @@ -1956,7 +1945,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_GrantAuthorization) IsValid() bool { return x != nil } @@ -1966,9 +1955,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_GrantAuthorization) ProtoMethods() *protoiface.Methods { size := func(input protoiface.SizeInput) protoiface.SizeOutput { - x := input.Message.Interface().(*GrantQueueItem) + x := input.Message.Interface().(*GrantAuthorization) if x == nil { return protoiface.SizeOutput{ NoUnkeyedLiterals: input.NoUnkeyedLiterals, @@ -1980,11 +1969,21 @@ func (x *fastReflection_GrantQueueItem) ProtoMethods() *protoiface.Methods { 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)) - } + 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) @@ -1996,7 +1995,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().(*GrantAuthorization) if x == nil { return protoiface.MarshalOutput{ NoUnkeyedLiterals: input.NoUnkeyedLiterals, @@ -2015,14 +2014,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]))) - i-- - dAtA[i] = 0xa + 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...) @@ -2035,7 +2067,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().(*GrantAuthorization) if x == nil { return protoiface.UnmarshalOutput{ NoUnkeyedLiterals: input.NoUnkeyedLiterals, @@ -2063,21 +2095,121 @@ func (x *fastReflection_GrantQueueItem) ProtoMethods() *protoiface.Methods { 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: + } + 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 MsgTypeUrls", wireType) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Expiration", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow @@ -2087,23 +2219,27 @@ func (x *fastReflection_GrantQueueItem) ProtoMethods() *protoiface.Methods { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength } - postIndex := iNdEx + intStringLen + 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.MsgTypeUrls = append(x.MsgTypeUrls, string(dAtA[iNdEx:postIndex])) + 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 @@ -2140,26 +2276,72 @@ func (x *fastReflection_GrantQueueItem) ProtoMethods() *protoiface.Methods { } } +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_AuthzRuleKeys protoreflect.MessageDescriptor - fd_AuthzRuleKeys_raw_json protoreflect.FieldDescriptor + md_GrantQueueItem protoreflect.MessageDescriptor + fd_GrantQueueItem_msg_type_urls protoreflect.FieldDescriptor ) func init() { file_cosmos_authz_v1beta1_authz_proto_init() - md_AuthzRuleKeys = File_cosmos_authz_v1beta1_authz_proto.Messages().ByName("AuthzRuleKeys") - fd_AuthzRuleKeys_raw_json = md_AuthzRuleKeys.Fields().ByName("raw_json") + 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_AuthzRuleKeys)(nil) +var _ protoreflect.Message = (*fastReflection_GrantQueueItem)(nil) -type fastReflection_AuthzRuleKeys AuthzRuleKeys +type fastReflection_GrantQueueItem GrantQueueItem -func (x *AuthzRuleKeys) ProtoReflect() protoreflect.Message { - return (*fastReflection_AuthzRuleKeys)(x) +func (x *GrantQueueItem) ProtoReflect() protoreflect.Message { + return (*fastReflection_GrantQueueItem)(x) } -func (x *AuthzRuleKeys) slowProtoReflect() protoreflect.Message { +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)) @@ -2171,43 +2353,43 @@ func (x *AuthzRuleKeys) slowProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -var _fastReflection_AuthzRuleKeys_messageType fastReflection_AuthzRuleKeys_messageType -var _ protoreflect.MessageType = fastReflection_AuthzRuleKeys_messageType{} +var _fastReflection_GrantQueueItem_messageType fastReflection_GrantQueueItem_messageType +var _ protoreflect.MessageType = fastReflection_GrantQueueItem_messageType{} -type fastReflection_AuthzRuleKeys_messageType struct{} +type fastReflection_GrantQueueItem_messageType struct{} -func (x fastReflection_AuthzRuleKeys_messageType) Zero() protoreflect.Message { - return (*fastReflection_AuthzRuleKeys)(nil) +func (x fastReflection_GrantQueueItem_messageType) Zero() protoreflect.Message { + return (*fastReflection_GrantQueueItem)(nil) } -func (x fastReflection_AuthzRuleKeys_messageType) New() protoreflect.Message { - return new(fastReflection_AuthzRuleKeys) +func (x fastReflection_GrantQueueItem_messageType) New() protoreflect.Message { + return new(fastReflection_GrantQueueItem) } -func (x fastReflection_AuthzRuleKeys_messageType) Descriptor() protoreflect.MessageDescriptor { - return md_AuthzRuleKeys +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_AuthzRuleKeys) Descriptor() protoreflect.MessageDescriptor { - return md_AuthzRuleKeys +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_AuthzRuleKeys) Type() protoreflect.MessageType { - return _fastReflection_AuthzRuleKeys_messageType +func (x *fastReflection_GrantQueueItem) Type() protoreflect.MessageType { + return _fastReflection_GrantQueueItem_messageType } // New returns a newly allocated and mutable empty message. -func (x *fastReflection_AuthzRuleKeys) New() protoreflect.Message { - return new(fastReflection_AuthzRuleKeys) +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_AuthzRuleKeys) Interface() protoreflect.ProtoMessage { - return (*AuthzRuleKeys)(x) +func (x *fastReflection_GrantQueueItem) Interface() protoreflect.ProtoMessage { + return (*GrantQueueItem)(x) } // Range iterates over every populated field in an undefined order, @@ -2215,10 +2397,10 @@ func (x *fastReflection_AuthzRuleKeys) 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_AuthzRuleKeys) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { - if len(x.RawJson) != 0 { - value := protoreflect.ValueOfBytes(x.RawJson) - if !f(fd_AuthzRuleKeys_raw_json, value) { +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 } } @@ -2235,15 +2417,15 @@ func (x *fastReflection_AuthzRuleKeys) Range(f func(protoreflect.FieldDescriptor // 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_AuthzRuleKeys) Has(fd protoreflect.FieldDescriptor) bool { +func (x *fastReflection_GrantQueueItem) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { - case "cosmos.authz.v1beta1.AuthzRuleKeys.raw_json": - return len(x.RawJson) != 0 + 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.AuthzRuleKeys")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.GrantQueueItem")) } - panic(fmt.Errorf("message cosmos.authz.v1beta1.AuthzRuleKeys does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message cosmos.authz.v1beta1.GrantQueueItem does not contain field %s", fd.FullName())) } } @@ -2253,15 +2435,15 @@ func (x *fastReflection_AuthzRuleKeys) Has(fd protoreflect.FieldDescriptor) bool // associated with the given field number. // // Clear is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_AuthzRuleKeys) Clear(fd protoreflect.FieldDescriptor) { +func (x *fastReflection_GrantQueueItem) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { - case "cosmos.authz.v1beta1.AuthzRuleKeys.raw_json": - x.RawJson = nil + 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.AuthzRuleKeys")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.GrantQueueItem")) } - panic(fmt.Errorf("message cosmos.authz.v1beta1.AuthzRuleKeys does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message cosmos.authz.v1beta1.GrantQueueItem does not contain field %s", fd.FullName())) } } @@ -2271,16 +2453,19 @@ func (x *fastReflection_AuthzRuleKeys) 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_AuthzRuleKeys) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { +func (x *fastReflection_GrantQueueItem) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { switch descriptor.FullName() { - case "cosmos.authz.v1beta1.AuthzRuleKeys.raw_json": - value := x.RawJson - return protoreflect.ValueOfBytes(value) + 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.AuthzRuleKeys")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.GrantQueueItem")) } - panic(fmt.Errorf("message cosmos.authz.v1beta1.AuthzRuleKeys does not contain field %s", descriptor.FullName())) + panic(fmt.Errorf("message cosmos.authz.v1beta1.GrantQueueItem does not contain field %s", descriptor.FullName())) } } @@ -2294,15 +2479,17 @@ func (x *fastReflection_AuthzRuleKeys) Get(descriptor protoreflect.FieldDescript // empty, read-only value, then it panics. // // Set is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_AuthzRuleKeys) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { +func (x *fastReflection_GrantQueueItem) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { switch fd.FullName() { - case "cosmos.authz.v1beta1.AuthzRuleKeys.raw_json": - x.RawJson = value.Bytes() + 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.AuthzRuleKeys")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.GrantQueueItem")) } - panic(fmt.Errorf("message cosmos.authz.v1beta1.AuthzRuleKeys does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message cosmos.authz.v1beta1.GrantQueueItem does not contain field %s", fd.FullName())) } } @@ -2316,40 +2503,45 @@ func (x *fastReflection_AuthzRuleKeys) Set(fd protoreflect.FieldDescriptor, valu // It panics if the field does not contain a composite type. // // Mutable is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_AuthzRuleKeys) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { +func (x *fastReflection_GrantQueueItem) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "cosmos.authz.v1beta1.AuthzRuleKeys.raw_json": - panic(fmt.Errorf("field raw_json of message cosmos.authz.v1beta1.AuthzRuleKeys is not mutable")) + 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.AuthzRuleKeys")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.GrantQueueItem")) } - panic(fmt.Errorf("message cosmos.authz.v1beta1.AuthzRuleKeys does not contain field %s", fd.FullName())) + 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_AuthzRuleKeys) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { +func (x *fastReflection_GrantQueueItem) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "cosmos.authz.v1beta1.AuthzRuleKeys.raw_json": - return protoreflect.ValueOfBytes(nil) + 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.AuthzRuleKeys")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.GrantQueueItem")) } - panic(fmt.Errorf("message cosmos.authz.v1beta1.AuthzRuleKeys does not contain field %s", fd.FullName())) + 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_AuthzRuleKeys) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { +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.AuthzRuleKeys", d.FullName())) + panic(fmt.Errorf("%s is not a oneof field in cosmos.authz.v1beta1.GrantQueueItem", d.FullName())) } panic("unreachable") } @@ -2357,7 +2549,7 @@ func (x *fastReflection_AuthzRuleKeys) WhichOneof(d protoreflect.OneofDescriptor // 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_AuthzRuleKeys) GetUnknown() protoreflect.RawFields { +func (x *fastReflection_GrantQueueItem) GetUnknown() protoreflect.RawFields { return x.unknownFields } @@ -2368,7 +2560,7 @@ func (x *fastReflection_AuthzRuleKeys) 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_AuthzRuleKeys) SetUnknown(fields protoreflect.RawFields) { +func (x *fastReflection_GrantQueueItem) SetUnknown(fields protoreflect.RawFields) { x.unknownFields = fields } @@ -2380,7 +2572,7 @@ func (x *fastReflection_AuthzRuleKeys) 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_AuthzRuleKeys) IsValid() bool { +func (x *fastReflection_GrantQueueItem) IsValid() bool { return x != nil } @@ -2390,9 +2582,9 @@ func (x *fastReflection_AuthzRuleKeys) 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_AuthzRuleKeys) ProtoMethods() *protoiface.Methods { +func (x *fastReflection_GrantQueueItem) ProtoMethods() *protoiface.Methods { size := func(input protoiface.SizeInput) protoiface.SizeOutput { - x := input.Message.Interface().(*AuthzRuleKeys) + x := input.Message.Interface().(*GrantQueueItem) if x == nil { return protoiface.SizeOutput{ NoUnkeyedLiterals: input.NoUnkeyedLiterals, @@ -2404,9 +2596,11 @@ func (x *fastReflection_AuthzRuleKeys) ProtoMethods() *protoiface.Methods { var n int var l int _ = l - l = len(x.RawJson) - if l > 0 { - n += 1 + l + runtime.Sov(uint64(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) @@ -2418,7 +2612,7 @@ func (x *fastReflection_AuthzRuleKeys) ProtoMethods() *protoiface.Methods { } marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { - x := input.Message.Interface().(*AuthzRuleKeys) + x := input.Message.Interface().(*GrantQueueItem) if x == nil { return protoiface.MarshalOutput{ NoUnkeyedLiterals: input.NoUnkeyedLiterals, @@ -2437,12 +2631,14 @@ func (x *fastReflection_AuthzRuleKeys) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } - if len(x.RawJson) > 0 { - i -= len(x.RawJson) - copy(dAtA[i:], x.RawJson) - i = runtime.EncodeVarint(dAtA, i, uint64(len(x.RawJson))) - i-- - dAtA[i] = 0xa + 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...) @@ -2455,7 +2651,7 @@ func (x *fastReflection_AuthzRuleKeys) ProtoMethods() *protoiface.Methods { }, nil } unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { - x := input.Message.Interface().(*AuthzRuleKeys) + x := input.Message.Interface().(*GrantQueueItem) if x == nil { return protoiface.UnmarshalOutput{ NoUnkeyedLiterals: input.NoUnkeyedLiterals, @@ -2487,17 +2683,17 @@ func (x *fastReflection_AuthzRuleKeys) 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: AuthzRuleKeys: wiretype end group for non-group") + 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: AuthzRuleKeys: illegal tag %d (wire type %d)", fieldNum, wire) + 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 RawJson", wireType) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field MsgTypeUrls", wireType) } - var byteLen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow @@ -2507,25 +2703,23 @@ func (x *fastReflection_AuthzRuleKeys) ProtoMethods() *protoiface.Methods { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength } - postIndex := iNdEx + byteLen + 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.RawJson = append(x.RawJson[:0], dAtA[iNdEx:postIndex]...) - if x.RawJson == nil { - x.RawJson = []byte{} - } + x.MsgTypeUrls = append(x.MsgTypeUrls, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex default: iNdEx = preIndex @@ -2628,7 +2822,7 @@ type Grant struct { // 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 []byte `protobuf:"bytes,3,opt,name=rules,proto3" json:"rules,omitempty"` + Rules []*Rule `protobuf:"bytes,3,rep,name=rules,proto3" json:"rules,omitempty"` } func (x *Grant) Reset() { @@ -2665,13 +2859,57 @@ func (x *Grant) GetExpiration() *timestamppb.Timestamp { return nil } -func (x *Grant) GetRules() []byte { +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 { @@ -2688,7 +2926,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) } @@ -2702,7 +2940,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 { @@ -2746,7 +2984,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) } @@ -2760,7 +2998,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 { @@ -2770,42 +3008,6 @@ func (x *GrantQueueItem) GetMsgTypeUrls() []string { return nil } -// AuthzRuleKeys is app specific options to the keys -type AuthzRuleKeys struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - RawJson []byte `protobuf:"bytes,1,opt,name=raw_json,json=rawJson,proto3" json:"raw_json,omitempty"` -} - -func (x *AuthzRuleKeys) Reset() { - *x = AuthzRuleKeys{} - if protoimpl.UnsafeEnabled { - mi := &file_cosmos_authz_v1beta1_authz_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *AuthzRuleKeys) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AuthzRuleKeys) ProtoMessage() {} - -// Deprecated: Use AuthzRuleKeys.ProtoReflect.Descriptor instead. -func (*AuthzRuleKeys) Descriptor() ([]byte, []int) { - return file_cosmos_authz_v1beta1_authz_proto_rawDescGZIP(), []int{4} -} - -func (x *AuthzRuleKeys) GetRawJson() []byte { - if x != nil { - return x.RawJson - } - return nil -} - var File_cosmos_authz_v1beta1_authz_proto protoreflect.FileDescriptor var file_cosmos_authz_v1beta1_authz_proto_rawDesc = []byte{ @@ -2829,7 +3031,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, 0xc7, + 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, @@ -2841,46 +3043,48 @@ 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, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x75, 0x6c, 0x65, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x0c, 0x52, 0x05, 0x72, 0x75, 0x6c, 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, 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, 0x2a, 0x0a, 0x0d, 0x41, 0x75, 0x74, 0x68, 0x7a, 0x52, 0x75, 0x6c, 0x65, - 0x4b, 0x65, 0x79, 0x73, 0x12, 0x19, 0x0a, 0x08, 0x72, 0x61, 0x77, 0x5f, 0x6a, 0x73, 0x6f, 0x6e, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x72, 0x61, 0x77, 0x4a, 0x73, 0x6f, 0x6e, 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, + 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, + 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, 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 ( @@ -2899,22 +3103,23 @@ var file_cosmos_authz_v1beta1_authz_proto_msgTypes = make([]protoimpl.MessageInf 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 - (*AuthzRuleKeys)(nil), // 4: cosmos.authz.v1beta1.AuthzRuleKeys + (*Rule)(nil), // 2: cosmos.authz.v1beta1.Rule + (*GrantAuthorization)(nil), // 3: cosmos.authz.v1beta1.GrantAuthorization + (*GrantQueueItem)(nil), // 4: cosmos.authz.v1beta1.GrantQueueItem (*anypb.Any)(nil), // 5: google.protobuf.Any (*timestamppb.Timestamp)(nil), // 6: google.protobuf.Timestamp } var file_cosmos_authz_v1beta1_authz_proto_depIdxs = []int32{ 5, // 0: cosmos.authz.v1beta1.Grant.authorization:type_name -> google.protobuf.Any 6, // 1: cosmos.authz.v1beta1.Grant.expiration:type_name -> google.protobuf.Timestamp - 5, // 2: cosmos.authz.v1beta1.GrantAuthorization.authorization:type_name -> google.protobuf.Any - 6, // 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 + 2, // 2: cosmos.authz.v1beta1.Grant.rules:type_name -> cosmos.authz.v1beta1.Rule + 5, // 3: cosmos.authz.v1beta1.GrantAuthorization.authorization:type_name -> google.protobuf.Any + 6, // 4: cosmos.authz.v1beta1.GrantAuthorization.expiration:type_name -> google.protobuf.Timestamp + 5, // [5:5] is the sub-list for method output_type + 5, // [5:5] is the sub-list for method input_type + 5, // [5:5] is the sub-list for extension type_name + 5, // [5:5] is the sub-list for extension extendee + 0, // [0:5] is the sub-list for field type_name } func init() { file_cosmos_authz_v1beta1_authz_proto_init() } @@ -2948,7 +3153,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: @@ -2960,7 +3165,7 @@ 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.(*GrantQueueItem); i { + switch v := v.(*GrantAuthorization); i { case 0: return &v.state case 1: @@ -2972,7 +3177,7 @@ func file_cosmos_authz_v1beta1_authz_proto_init() { } } file_cosmos_authz_v1beta1_authz_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*AuthzRuleKeys); i { + switch v := v.(*GrantQueueItem); i { case 0: return &v.state case 1: diff --git a/api/cosmos/authz/v1beta1/tx.pulsar.go b/api/cosmos/authz/v1beta1/tx.pulsar.go index 4fc726a1e59b..b3474119b1e5 100644 --- a/api/cosmos/authz/v1beta1/tx.pulsar.go +++ b/api/cosmos/authz/v1beta1/tx.pulsar.go @@ -17,6 +17,57 @@ import ( sync "sync" ) +var _ protoreflect.List = (*_MsgGrant_4_list)(nil) + +type _MsgGrant_4_list struct { + list *[]*Rule +} + +func (x *_MsgGrant_4_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_MsgGrant_4_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfMessage((*x.list)[i].ProtoReflect()) +} + +func (x *_MsgGrant_4_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*Rule) + (*x.list)[i] = concreteValue +} + +func (x *_MsgGrant_4_list) Append(value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*Rule) + *x.list = append(*x.list, concreteValue) +} + +func (x *_MsgGrant_4_list) AppendMutable() protoreflect.Value { + v := new(Rule) + *x.list = append(*x.list, v) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_MsgGrant_4_list) Truncate(n int) { + for i := n; i < len(*x.list); i++ { + (*x.list)[i] = nil + } + *x.list = (*x.list)[:n] +} + +func (x *_MsgGrant_4_list) NewElement() protoreflect.Value { + v := new(Rule) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_MsgGrant_4_list) IsValid() bool { + return x.list != nil +} + var ( md_MsgGrant protoreflect.MessageDescriptor fd_MsgGrant_granter protoreflect.FieldDescriptor @@ -118,7 +169,7 @@ func (x *fastReflection_MsgGrant) Range(f func(protoreflect.FieldDescriptor, pro } } if len(x.Rules) != 0 { - value := protoreflect.ValueOfBytes(x.Rules) + value := protoreflect.ValueOfList(&_MsgGrant_4_list{list: &x.Rules}) if !f(fd_MsgGrant_rules, value) { return } @@ -196,8 +247,11 @@ func (x *fastReflection_MsgGrant) Get(descriptor protoreflect.FieldDescriptor) p value := x.Grant return protoreflect.ValueOfMessage(value.ProtoReflect()) case "cosmos.authz.v1beta1.MsgGrant.rules": - value := x.Rules - return protoreflect.ValueOfBytes(value) + if len(x.Rules) == 0 { + return protoreflect.ValueOfList(&_MsgGrant_4_list{}) + } + listValue := &_MsgGrant_4_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.MsgGrant")) @@ -225,7 +279,9 @@ func (x *fastReflection_MsgGrant) Set(fd protoreflect.FieldDescriptor, value pro case "cosmos.authz.v1beta1.MsgGrant.grant": x.Grant = value.Message().Interface().(*Grant) case "cosmos.authz.v1beta1.MsgGrant.rules": - x.Rules = value.Bytes() + lv := value.List() + clv := lv.(*_MsgGrant_4_list) + x.Rules = *clv.list default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.MsgGrant")) @@ -251,12 +307,16 @@ func (x *fastReflection_MsgGrant) Mutable(fd protoreflect.FieldDescriptor) proto x.Grant = new(Grant) } return protoreflect.ValueOfMessage(x.Grant.ProtoReflect()) + case "cosmos.authz.v1beta1.MsgGrant.rules": + if x.Rules == nil { + x.Rules = []*Rule{} + } + value := &_MsgGrant_4_list{list: &x.Rules} + return protoreflect.ValueOfList(value) case "cosmos.authz.v1beta1.MsgGrant.granter": 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")) @@ -278,7 +338,8 @@ func (x *fastReflection_MsgGrant) NewField(fd protoreflect.FieldDescriptor) prot m := new(Grant) return protoreflect.ValueOfMessage(m.ProtoReflect()) case "cosmos.authz.v1beta1.MsgGrant.rules": - return protoreflect.ValueOfBytes(nil) + list := []*Rule{} + return protoreflect.ValueOfList(&_MsgGrant_4_list{list: &list}) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.MsgGrant")) @@ -360,9 +421,11 @@ 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 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) @@ -394,11 +457,20 @@ func (x *fastReflection_MsgGrant) ProtoMethods() *protoiface.Methods { 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 + 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] = 0x22 + } } if x.Grant != nil { encoded, err := options.Marshal(x.Grant) @@ -581,7 +653,7 @@ func (x *fastReflection_MsgGrant) ProtoMethods() *protoiface.Methods { 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 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow @@ -591,24 +663,24 @@ func (x *fastReflection_MsgGrant) ProtoMethods() *protoiface.Methods { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + if msglen < 0 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength } - postIndex := iNdEx + byteLen + 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[:0], dAtA[iNdEx:postIndex]...) - if x.Rules == nil { - x.Rules = []byte{} + 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: @@ -2970,7 +3042,7 @@ type MsgGrant struct { 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"` + Rules []*Rule `protobuf:"bytes,4,rep,name=rules,proto3" json:"rules,omitempty"` } func (x *MsgGrant) Reset() { @@ -3014,7 +3086,7 @@ func (x *MsgGrant) GetGrant() *Grant { return nil } -func (x *MsgGrant) GetRules() []byte { +func (x *MsgGrant) GetRules() []*Rule { if x != nil { return x.Rules } @@ -3229,7 +3301,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, - 0xec, 0x01, 0x0a, 0x08, 0x4d, 0x73, 0x67, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x12, 0x32, 0x0a, 0x07, + 0x88, 0x02, 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, @@ -3240,68 +3312,70 @@ 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, 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, + 0x6e, 0x74, 0x12, 0x30, 0x0a, 0x05, 0x72, 0x75, 0x6c, 0x65, 0x73, 0x18, 0x04, 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, 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, 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, + 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 ( @@ -3325,22 +3399,24 @@ var file_cosmos_authz_v1beta1_tx_proto_goTypes = []interface{}{ (*MsgRevoke)(nil), // 4: cosmos.authz.v1beta1.MsgRevoke (*MsgRevokeResponse)(nil), // 5: cosmos.authz.v1beta1.MsgRevokeResponse (*Grant)(nil), // 6: cosmos.authz.v1beta1.Grant - (*anypb.Any)(nil), // 7: google.protobuf.Any + (*Rule)(nil), // 7: cosmos.authz.v1beta1.Rule + (*anypb.Any)(nil), // 8: google.protobuf.Any } var file_cosmos_authz_v1beta1_tx_proto_depIdxs = []int32{ 6, // 0: cosmos.authz.v1beta1.MsgGrant.grant:type_name -> cosmos.authz.v1beta1.Grant - 7, // 1: cosmos.authz.v1beta1.MsgExec.msgs:type_name -> google.protobuf.Any - 0, // 2: cosmos.authz.v1beta1.Msg.Grant:input_type -> cosmos.authz.v1beta1.MsgGrant - 2, // 3: cosmos.authz.v1beta1.Msg.Exec:input_type -> cosmos.authz.v1beta1.MsgExec - 4, // 4: cosmos.authz.v1beta1.Msg.Revoke:input_type -> cosmos.authz.v1beta1.MsgRevoke - 1, // 5: cosmos.authz.v1beta1.Msg.Grant:output_type -> cosmos.authz.v1beta1.MsgGrantResponse - 3, // 6: cosmos.authz.v1beta1.Msg.Exec:output_type -> cosmos.authz.v1beta1.MsgExecResponse - 5, // 7: cosmos.authz.v1beta1.Msg.Revoke:output_type -> cosmos.authz.v1beta1.MsgRevokeResponse - 5, // [5:8] is the sub-list for method output_type - 2, // [2:5] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name + 7, // 1: cosmos.authz.v1beta1.MsgGrant.rules:type_name -> cosmos.authz.v1beta1.Rule + 8, // 2: cosmos.authz.v1beta1.MsgExec.msgs:type_name -> google.protobuf.Any + 0, // 3: cosmos.authz.v1beta1.Msg.Grant:input_type -> cosmos.authz.v1beta1.MsgGrant + 2, // 4: cosmos.authz.v1beta1.Msg.Exec:input_type -> cosmos.authz.v1beta1.MsgExec + 4, // 5: cosmos.authz.v1beta1.Msg.Revoke:input_type -> cosmos.authz.v1beta1.MsgRevoke + 1, // 6: cosmos.authz.v1beta1.Msg.Grant:output_type -> cosmos.authz.v1beta1.MsgGrantResponse + 3, // 7: cosmos.authz.v1beta1.Msg.Exec:output_type -> cosmos.authz.v1beta1.MsgExecResponse + 5, // 8: cosmos.authz.v1beta1.Msg.Revoke:output_type -> cosmos.authz.v1beta1.MsgRevokeResponse + 6, // [6:9] is the sub-list for method output_type + 3, // [3:6] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name } func init() { file_cosmos_authz_v1beta1_tx_proto_init() } diff --git a/proto/cosmos/authz/v1beta1/authz.proto b/proto/cosmos/authz/v1beta1/authz.proto index 0e80a8082d7b..85188ba62051 100644 --- a/proto/cosmos/authz/v1beta1/authz.proto +++ b/proto/cosmos/authz/v1beta1/authz.proto @@ -32,7 +32,13 @@ message Grant { google.protobuf.Timestamp expiration = 2 [(gogoproto.stdtime) = true, (gogoproto.nullable) = true]; // rules are conditions to execute the grant. - bytes rules = 3; + 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. @@ -50,41 +56,3 @@ message GrantQueueItem { // msg_type_urls contains the list of TypeURL of a sdk.Msg. repeated string msg_type_urls = 1; } - -// // AuthzRules defines the rules for authz messages. -// message AuthzRules { -// // Send authz rules -// SendAuthzRules send = 1 [(gogoproto.nullable) = false]; - -// // Stake authz rules -// StakeAuthzRules stake = 2 [(gogoproto.nullable) = false]; - -// // Generic authz rules -// GenericAuthzRules generic = 3 [(gogoproto.nullable) = false]; -// } - -// // Send authz rules -// message SendAuthzRules { -// repeated cosmos.base.v1beta1.Coin spend_limit = 1 [ -// (gogoproto.nullable) = false, -// (amino.dont_omitempty) = true, -// (amino.encoding) = "legacy_coins", -// (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" -// ]; -// repeated string blocked_recipients = 2; -// } - -// // Stake authz rules -// message StakeAuthzRules { -// repeated string blocked_validators = 1; -// } - -// // Generic authz rules -// message GenericAuthzRules { -// repeated string blocked_messages = 1; -// } - -// AuthzRuleKeys is app specific options to the keys -message AuthzRuleKeys { - bytes raw_json = 1; -} \ No newline at end of file diff --git a/proto/cosmos/authz/v1beta1/tx.proto b/proto/cosmos/authz/v1beta1/tx.proto index 858b582dcd05..1429f015b15e 100644 --- a/proto/cosmos/authz/v1beta1/tx.proto +++ b/proto/cosmos/authz/v1beta1/tx.proto @@ -44,7 +44,7 @@ message MsgGrant { cosmos.authz.v1beta1.Grant grant = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; // rules are conditions to execute the grant. - bytes rules = 4; + repeated cosmos.authz.v1beta1.Rule rules = 4; } // MsgGrantResponse defines the Msg/MsgGrant response type. diff --git a/x/auth/ante/authz_rules_ante.go b/x/auth/ante/authz_rules_ante.go index 8a15c49a2641..93ebba1f9f99 100644 --- a/x/auth/ante/authz_rules_ante.go +++ b/x/auth/ante/authz_rules_ante.go @@ -3,6 +3,7 @@ package ante import ( "strings" + stakingv1beta1 "cosmossdk.io/api/cosmos/staking/v1beta1" errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -11,11 +12,6 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" ) -const ( - AllowedRecipients = "allowed_recipients" - MaxAmount = "max_amount" -) - type AuthzDecorator struct { azk AuthzKeeper ak AccountKeeper @@ -59,7 +55,13 @@ func (azd AuthzDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, if isRulesBroken { return ctx, err } + case *stakingv1beta1.MsgDelegate: + isRulesBroken, err := azd.handleStakeAuthzRules(ctx, innerMsgConverted, grantee) + if isRulesBroken { + return ctx, err + } } + } } } @@ -77,12 +79,10 @@ func (azd AuthzDecorator) handleSendAuthzRules(ctx sdk.Context, msg *banktypes.M } _, rules := azd.azk.GetAuthzWithRules(ctx, grantee, granter, sdk.MsgTypeURL(&banktypes.MsgSend{})) - if rules != nil { - if allowedAddrs, ok := rules[AllowedRecipients]; ok { - allowedAddrsValue := allowedAddrs.(string) - allowedAddrs := strings.Split(allowedAddrsValue, ",") + for _, rule := range rules { + if rule.Key == authztypes.AllowedRecipients { isAllowed := false - for _, allowedRecipient := range allowedAddrs { + for _, allowedRecipient := range rule.Values { if msg.ToAddress == allowedRecipient { isAllowed = true break @@ -94,9 +94,8 @@ func (azd AuthzDecorator) handleSendAuthzRules(ctx sdk.Context, msg *banktypes.M } } - if spendLimitInterface, ok := rules[MaxAmount]; ok { - spendLimit := spendLimitInterface.(string) - limit, err := sdk.ParseCoinsNormalized(spendLimit) + if rule.Key == authztypes.MaxAmount { + limit, err := sdk.ParseCoinsNormalized(strings.Join(rule.Values, ",")) if err != nil { return true, err } @@ -104,20 +103,50 @@ func (azd AuthzDecorator) handleSendAuthzRules(ctx sdk.Context, msg *banktypes.M return true, errorsmod.Wrap(sdkerrors.ErrTxDecode, "Amount exceeds the max_amount limit set by the granter") } } + } return false, nil } -// func checkGenericAuthzRules(_ *authztypes.MsgGrant, authz *authztypes.GenericAuthorization, genericRules map[string]string) bool { -// if msgsStr, ok := genericRules["blockedMessages"]; ok { -// msgs := strings.Split(msgsStr, ",") -// for _, v := range msgs { -// if v == authz.Msg { -// return true -// } -// } -// } - -// return false -// } +func (azd AuthzDecorator) handleStakeAuthzRules(ctx sdk.Context, msg *stakingv1beta1.MsgDelegate, grantee []byte) (bool, error) { + granter, err := azd.ak.AddressCodec().StringToBytes(msg.DelegatorAddress) + if err != nil { + return true, err + } + + _, rules := azd.azk.GetAuthzWithRules(ctx, grantee, granter, sdk.MsgTypeURL(&banktypes.MsgSend{})) + + for _, rule := range rules { + if rule.Key == authztypes.AllowedStakeValidators { + isAllowed := false + for _, allowedValidator := range rule.Values { + if msg.ValidatorAddress == allowedValidator { + isAllowed = true + break + } + } + + if !isAllowed { + return true, errorsmod.Wrap(sdkerrors.ErrTxDecode, "Validator is not in the allowed validators of the grant") + } + } + + if rule.Key == authztypes.AllowedMaxStakeAmount { + limit, err := sdk.ParseCoinsNormalized(strings.Join(rule.Values, ",")) + if err != nil { + return true, err + } + amount, err := sdk.ParseCoinNormalized(msg.Amount.String()) + if err != nil { + return true, err + } + + if !limit.IsAllGTE(sdk.NewCoins(amount)) { + return true, errorsmod.Wrap(sdkerrors.ErrTxDecode, "Amount exceeds the max_amount limit set by the granter") + } + } + } + + return false, nil +} diff --git a/x/auth/ante/expected_keepers.go b/x/auth/ante/expected_keepers.go index 1478fc45a2a8..5c80b9ffc1d1 100644 --- a/x/auth/ante/expected_keepers.go +++ b/x/auth/ante/expected_keepers.go @@ -26,7 +26,5 @@ type FeegrantKeeper interface { } type AuthzKeeper interface { - GetAuthzOptions() map[string]map[string]string - GetAuthzRulesKeys(ctx context.Context) (map[string]interface{}, error) - GetAuthzWithRules(ctx context.Context, grantee, granter sdk.AccAddress, msgType string) (authz.Authorization, map[string]interface{}) + GetAuthzWithRules(ctx context.Context, grantee, granter sdk.AccAddress, msgType string) (authz.Authorization, []*authz.Rule) } diff --git a/x/authz/authorization_grant.go b/x/authz/authorization_grant.go index 2b3efd6cbaaa..9390410dc661 100644 --- a/x/authz/authorization_grant.go +++ b/x/authz/authorization_grant.go @@ -14,26 +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) { - 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)) - } - msg, ok := a.(proto.Message) - if !ok { - return Grant{}, sdkerrors.ErrPackAny.Wrapf("cannot proto marshal %T", a) - } - any, err := cdctypes.NewAnyWithValue(msg) - if err != nil { - return Grant{}, err - } - return Grant{ - Expiration: expiration, - Authorization: any, - }, nil -} - -// NewGrantWithRules does the same as NewGrant but takes rules as extra arg. -func NewGrantWithRules(blockTime time.Time, a Authorization, expiration *time.Time, rules []byte) (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)) } diff --git a/x/authz/authorizations.go b/x/authz/authorizations.go index 70cb6f8d60c4..75b2e0659097 100644 --- a/x/authz/authorizations.go +++ b/x/authz/authorizations.go @@ -2,7 +2,6 @@ package authz import ( context "context" - "encoding/json" "github.com/cosmos/gogoproto/proto" @@ -25,9 +24,6 @@ type Authorization interface { // ValidateBasic does a simple validation check that // doesn't require access to any other information. ValidateBasic() error - - // GetOptions are, rules defined if any. - GetOptions() json.RawMessage } // AcceptResponse instruments the controller of an authz message if the request is accepted diff --git a/x/authz/authz.pb.go b/x/authz/authz.pb.go index b84eefa30b7c..6b4a528ffd56 100644 --- a/x/authz/authz.pb.go +++ b/x/authz/authz.pb.go @@ -80,7 +80,7 @@ type Grant struct { // 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 []byte `protobuf:"bytes,3,opt,name=rules,proto3" json:"rules,omitempty"` + Rules []*Rule `protobuf:"bytes,3,rep,name=rules,proto3" json:"rules,omitempty"` } func (m *Grant) Reset() { *m = Grant{} } @@ -116,6 +116,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 { @@ -129,7 +168,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) @@ -168,7 +207,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) @@ -197,88 +236,50 @@ func (m *GrantQueueItem) XXX_DiscardUnknown() { var xxx_messageInfo_GrantQueueItem proto.InternalMessageInfo -// AuthzRuleKeys is app specific options to the keys -type AuthzRuleKeys struct { - RawJson []byte `protobuf:"bytes,1,opt,name=raw_json,json=rawJson,proto3" json:"raw_json,omitempty"` -} - -func (m *AuthzRuleKeys) Reset() { *m = AuthzRuleKeys{} } -func (m *AuthzRuleKeys) String() string { return proto.CompactTextString(m) } -func (*AuthzRuleKeys) ProtoMessage() {} -func (*AuthzRuleKeys) Descriptor() ([]byte, []int) { - return fileDescriptor_544dc2e84b61c637, []int{4} -} -func (m *AuthzRuleKeys) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *AuthzRuleKeys) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_AuthzRuleKeys.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 *AuthzRuleKeys) XXX_Merge(src proto.Message) { - xxx_messageInfo_AuthzRuleKeys.Merge(m, src) -} -func (m *AuthzRuleKeys) XXX_Size() int { - return m.Size() -} -func (m *AuthzRuleKeys) XXX_DiscardUnknown() { - xxx_messageInfo_AuthzRuleKeys.DiscardUnknown(m) -} - -var xxx_messageInfo_AuthzRuleKeys 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((*AuthzRuleKeys)(nil), "cosmos.authz.v1beta1.AuthzRuleKeys") } func init() { proto.RegisterFile("cosmos/authz/v1beta1/authz.proto", fileDescriptor_544dc2e84b61c637) } var fileDescriptor_544dc2e84b61c637 = []byte{ // 505 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x53, 0xcd, 0x6e, 0xd3, 0x40, - 0x10, 0xce, 0x36, 0x2d, 0x6d, 0xb7, 0x2d, 0x02, 0xcb, 0x87, 0x34, 0x07, 0x27, 0xb2, 0x10, 0x8a, - 0x2a, 0xc5, 0x56, 0x0b, 0x27, 0x4e, 0xc4, 0x42, 0xaa, 0x28, 0x27, 0x4c, 0xb9, 0x70, 0x89, 0xd6, - 0xc9, 0xb0, 0x31, 0xd8, 0x5e, 0x6b, 0x7f, 0x68, 0x9d, 0x47, 0xe0, 0xd4, 0x67, 0xe0, 0x09, 0x38, - 0xf4, 0x1d, 0x88, 0x38, 0x55, 0x9c, 0x38, 0xf1, 0x93, 0x1c, 0x78, 0x0d, 0x94, 0x5d, 0x1b, 0x92, - 0xb6, 0x12, 0x3d, 0x70, 0x59, 0xed, 0xec, 0x7c, 0xdf, 0xcc, 0x7c, 0x9f, 0x66, 0x71, 0x7b, 0xc0, - 0x44, 0xca, 0x84, 0x4f, 0x94, 0x1c, 0x8d, 0xfd, 0x77, 0xfb, 0x11, 0x48, 0xb2, 0x6f, 0x22, 0x2f, - 0xe7, 0x4c, 0x32, 0xcb, 0x36, 0x08, 0xcf, 0xbc, 0x95, 0x88, 0xe6, 0x5d, 0x92, 0xc6, 0x19, 0xf3, - 0xf5, 0x69, 0x80, 0xcd, 0x5d, 0x03, 0xec, 0xeb, 0xc8, 0x2f, 0x59, 0x26, 0xd5, 0xa2, 0x8c, 0xd1, - 0x04, 0x7c, 0x1d, 0x45, 0xea, 0xb5, 0x2f, 0xe3, 0x14, 0x84, 0x24, 0x69, 0x5e, 0x02, 0x6c, 0xca, - 0x28, 0x33, 0xc4, 0xf9, 0xad, 0xaa, 0x78, 0x99, 0x46, 0xb2, 0xa2, 0x4c, 0x39, 0xe5, 0xdc, 0x11, - 0x11, 0xf0, 0x67, 0xec, 0x01, 0x8b, 0x33, 0x93, 0x77, 0x25, 0xb6, 0x0f, 0x21, 0x03, 0x1e, 0x0f, - 0x7a, 0x4a, 0x8e, 0x18, 0x8f, 0xc7, 0x44, 0xc6, 0x2c, 0xb3, 0xee, 0xe0, 0x7a, 0x2a, 0x68, 0x03, - 0xb5, 0x51, 0x67, 0x33, 0x9c, 0x5f, 0x1f, 0x1d, 0x7d, 0x3e, 0xef, 0xba, 0xd7, 0x69, 0xf4, 0x96, - 0x98, 0xef, 0x7f, 0x7d, 0xdc, 0x6b, 0x19, 0x58, 0x57, 0x0c, 0xdf, 0xfa, 0xd7, 0x55, 0x77, 0x3f, - 0x21, 0xbc, 0x76, 0xc8, 0x49, 0x26, 0xad, 0x08, 0xef, 0x90, 0xc5, 0x94, 0xee, 0xb8, 0x75, 0x60, - 0x7b, 0x46, 0x92, 0x57, 0x49, 0xf2, 0x7a, 0x59, 0x11, 0xdc, 0xbf, 0xd9, 0x08, 0xe1, 0x72, 0x49, - 0xeb, 0x09, 0xc6, 0x70, 0x9a, 0xc7, 0xdc, 0x34, 0x58, 0xd1, 0x0d, 0x9a, 0x57, 0x1a, 0x1c, 0x57, - 0x56, 0x07, 0x1b, 0x93, 0x6f, 0x2d, 0x74, 0xf6, 0xbd, 0x85, 0xc2, 0x05, 0x9e, 0x65, 0xe3, 0x35, - 0xae, 0x12, 0x10, 0x8d, 0x7a, 0x1b, 0x75, 0xb6, 0x43, 0x13, 0xb8, 0x1f, 0x56, 0xb0, 0xa5, 0x95, - 0x2c, 0xdb, 0x77, 0x80, 0xd7, 0xe9, 0xfc, 0x15, 0xb8, 0xb1, 0x30, 0x68, 0x7c, 0x39, 0xef, 0x56, - 0x1b, 0xd2, 0x1b, 0x0e, 0x39, 0x08, 0xf1, 0x42, 0xf2, 0x38, 0xa3, 0x61, 0x05, 0xfc, 0xcb, 0x01, - 0x3d, 0xe3, 0x0d, 0x38, 0x70, 0xd5, 0xbe, 0xfa, 0xff, 0xb7, 0xef, 0xf1, 0x92, 0x7d, 0xab, 0xff, - 0xb4, 0x6f, 0xf5, 0xb2, 0x75, 0xee, 0x43, 0x7c, 0x5b, 0x7b, 0xf4, 0x5c, 0x81, 0x82, 0xa7, 0x12, - 0x52, 0xcb, 0xc5, 0x3b, 0xa9, 0xa0, 0x7d, 0x59, 0xe4, 0xd0, 0x57, 0x3c, 0x11, 0x0d, 0xd4, 0xae, - 0x77, 0x36, 0xc3, 0xad, 0x54, 0xd0, 0xe3, 0x22, 0x87, 0x97, 0x3c, 0x11, 0xee, 0x1e, 0xde, 0x99, - 0xcf, 0x35, 0x0e, 0x55, 0x02, 0xcf, 0xa0, 0x10, 0xd6, 0x2e, 0xde, 0xe0, 0xe4, 0xa4, 0xff, 0x46, - 0x94, 0x6b, 0xb2, 0x1d, 0xae, 0x73, 0x72, 0x72, 0x24, 0x58, 0x16, 0x04, 0x93, 0x9f, 0x4e, 0x6d, - 0x32, 0x75, 0xd0, 0xc5, 0xd4, 0x41, 0x3f, 0xa6, 0x0e, 0x3a, 0x9b, 0x39, 0xb5, 0x8b, 0x99, 0x53, - 0xfb, 0x3a, 0x73, 0x6a, 0xaf, 0xee, 0xd1, 0x58, 0x8e, 0x54, 0xe4, 0x0d, 0x58, 0x5a, 0xfe, 0x37, - 0x7f, 0x61, 0x43, 0x4f, 0xcd, 0x37, 0x8e, 0x6e, 0x69, 0x2d, 0x0f, 0x7e, 0x07, 0x00, 0x00, 0xff, - 0xff, 0x5e, 0x66, 0xb7, 0xda, 0xeb, 0x03, 0x00, 0x00, + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x53, 0xcb, 0x6e, 0xd3, 0x40, + 0x14, 0x8d, 0xe3, 0xb4, 0xd0, 0xa9, 0x8a, 0xc0, 0x8a, 0x90, 0xc9, 0xc2, 0x89, 0x2c, 0x84, 0x2a, + 0xa4, 0xd8, 0x6d, 0x61, 0xc5, 0x8a, 0x58, 0x48, 0x15, 0xec, 0x30, 0x65, 0xc3, 0x26, 0x1a, 0x27, + 0x97, 0x89, 0x15, 0xdb, 0x63, 0xcd, 0xa3, 0xaa, 0xfb, 0x09, 0xac, 0xfa, 0x0d, 0x7c, 0x01, 0x8b, + 0x7e, 0x44, 0xc4, 0xaa, 0x62, 0xc5, 0x8a, 0x47, 0xb2, 0xe0, 0x37, 0x90, 0x67, 0x6c, 0x48, 0xda, + 0x48, 0x64, 0xc1, 0xc6, 0xf2, 0x9d, 0x7b, 0xce, 0x7d, 0x9c, 0x33, 0x83, 0x7a, 0x23, 0xca, 0x53, + 0xca, 0x7d, 0x2c, 0xc5, 0xe4, 0xdc, 0x3f, 0x3d, 0x8c, 0x40, 0xe0, 0x43, 0x1d, 0x79, 0x39, 0xa3, + 0x82, 0x5a, 0x6d, 0x8d, 0xf0, 0xf4, 0x59, 0x85, 0xe8, 0xdc, 0xc3, 0x69, 0x9c, 0x51, 0x5f, 0x7d, + 0x35, 0xb0, 0xf3, 0x40, 0x03, 0x87, 0x2a, 0xf2, 0x2b, 0x96, 0x4e, 0x75, 0x09, 0xa5, 0x24, 0x01, + 0x5f, 0x45, 0x91, 0x7c, 0xef, 0x8b, 0x38, 0x05, 0x2e, 0x70, 0x9a, 0x57, 0x80, 0x36, 0xa1, 0x84, + 0x6a, 0x62, 0xf9, 0x57, 0x57, 0xbc, 0x4e, 0xc3, 0x59, 0x51, 0xa5, 0x9c, 0x6a, 0xee, 0x08, 0x73, + 0xf8, 0x33, 0xf6, 0x88, 0xc6, 0x99, 0xce, 0xbb, 0x02, 0xb5, 0x8f, 0x21, 0x03, 0x16, 0x8f, 0x06, + 0x52, 0x4c, 0x28, 0x8b, 0xcf, 0xb1, 0x88, 0x69, 0x66, 0xdd, 0x45, 0x66, 0xca, 0x89, 0x6d, 0xf4, + 0x8c, 0xfd, 0x9d, 0xb0, 0xfc, 0x7d, 0xf6, 0xea, 0xf3, 0x65, 0xdf, 0x5d, 0xb7, 0xa3, 0xb7, 0xc2, + 0xfc, 0xf0, 0xeb, 0xd3, 0xe3, 0xae, 0x86, 0xf5, 0xf9, 0x78, 0xea, 0xaf, 0xab, 0xee, 0x2e, 0x0c, + 0xb4, 0x75, 0xcc, 0x70, 0x26, 0xac, 0x08, 0xed, 0xe1, 0xe5, 0x94, 0xea, 0xb8, 0x7b, 0xd4, 0xf6, + 0xf4, 0x4a, 0x5e, 0xbd, 0x92, 0x37, 0xc8, 0x8a, 0xe0, 0xd1, 0x66, 0x23, 0x84, 0xab, 0x25, 0xad, + 0x17, 0x08, 0xc1, 0x59, 0x1e, 0x33, 0xdd, 0xa0, 0xa9, 0x1a, 0x74, 0x6e, 0x34, 0x38, 0xa9, 0xa5, + 0x0e, 0x6e, 0xcf, 0xbe, 0x75, 0x8d, 0x8b, 0xef, 0x5d, 0x23, 0x5c, 0xe2, 0x59, 0x07, 0x68, 0x8b, + 0xc9, 0x04, 0xb8, 0x6d, 0xf6, 0x4c, 0x55, 0x60, 0xed, 0x20, 0xa1, 0x4c, 0x20, 0xd4, 0x40, 0xf7, + 0x00, 0xb5, 0xca, 0xb0, 0xd4, 0x72, 0x0a, 0x45, 0xad, 0xe5, 0x14, 0x0a, 0xeb, 0x3e, 0xda, 0x3e, + 0xc5, 0x89, 0x04, 0x6e, 0x37, 0x7b, 0xe6, 0xfe, 0x4e, 0x58, 0x45, 0xee, 0xc7, 0x26, 0xb2, 0x94, + 0x2e, 0xab, 0x66, 0x1c, 0xa1, 0x5b, 0xa4, 0x3c, 0x05, 0xa6, 0x8b, 0x04, 0xf6, 0x97, 0xcb, 0x7e, + 0x7d, 0xdf, 0x06, 0xe3, 0x31, 0x03, 0xce, 0xdf, 0x08, 0x16, 0x67, 0x24, 0xac, 0x81, 0x7f, 0x39, + 0xa0, 0x36, 0xde, 0x80, 0x03, 0x37, 0xcd, 0x30, 0xff, 0xbf, 0x19, 0xcf, 0x57, 0xcc, 0x68, 0xfd, + 0xd3, 0x8c, 0xd6, 0x75, 0x23, 0xdc, 0xa7, 0xe8, 0x8e, 0xd2, 0xe8, 0xb5, 0x04, 0x09, 0x2f, 0x05, + 0xa4, 0x96, 0x8b, 0xf6, 0x52, 0x4e, 0x86, 0xa2, 0xc8, 0x61, 0x28, 0x59, 0xc2, 0x6d, 0x43, 0xa9, + 0xba, 0x9b, 0x72, 0x72, 0x52, 0xe4, 0xf0, 0x96, 0x25, 0x3c, 0x08, 0x66, 0x3f, 0x9d, 0xc6, 0x6c, + 0xee, 0x18, 0x57, 0x73, 0xc7, 0xf8, 0x31, 0x77, 0x8c, 0x8b, 0x85, 0xd3, 0xb8, 0x5a, 0x38, 0x8d, + 0xaf, 0x0b, 0xa7, 0xf1, 0xee, 0x21, 0x89, 0xc5, 0x44, 0x46, 0xde, 0x88, 0xa6, 0xd5, 0x8b, 0xf4, + 0x97, 0xee, 0xf0, 0x99, 0x7e, 0xe8, 0xd1, 0xb6, 0x9a, 0xef, 0xc9, 0xef, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x7b, 0x22, 0x81, 0x7c, 0x0d, 0x04, 0x00, 0x00, } func (m *GenericAuthorization) Marshal() (dAtA []byte, err error) { @@ -332,11 +333,18 @@ func (m *Grant) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l if len(m.Rules) > 0 { - i -= len(m.Rules) - copy(dAtA[i:], m.Rules) - i = encodeVarintAuthz(dAtA, i, uint64(len(m.Rules))) - i-- - dAtA[i] = 0x1a + 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):]) @@ -363,6 +371,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) @@ -454,36 +501,6 @@ func (m *GrantQueueItem) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *AuthzRuleKeys) 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 *AuthzRuleKeys) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *AuthzRuleKeys) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.RawJson) > 0 { - i -= len(m.RawJson) - copy(dAtA[i:], m.RawJson) - i = encodeVarintAuthz(dAtA, i, uint64(len(m.RawJson))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - func encodeVarintAuthz(dAtA []byte, offset int, v uint64) int { offset -= sovAuthz(v) base := offset @@ -522,10 +539,31 @@ func (m *Grant) Size() (n int) { l = github_com_cosmos_gogoproto_types.SizeOfStdTime(*m.Expiration) n += 1 + l + sovAuthz(uint64(l)) } - l = len(m.Rules) + 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 } @@ -569,19 +607,6 @@ func (m *GrantQueueItem) Size() (n int) { return n } -func (m *AuthzRuleKeys) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.RawJson) - if l > 0 { - n += 1 + l + sovAuthz(uint64(l)) - } - return n -} - func sovAuthz(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -775,7 +800,7 @@ func (m *Grant) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Rules", wireType) } - var byteLen int + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowAuthz @@ -785,24 +810,24 @@ func (m *Grant) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + if msglen < 0 { return ErrInvalidLengthAuthz } - postIndex := iNdEx + byteLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthAuthz } if postIndex > l { return io.ErrUnexpectedEOF } - m.Rules = append(m.Rules[:0], dAtA[iNdEx:postIndex]...) - if m.Rules == nil { - m.Rules = []byte{} + 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: @@ -826,6 +851,120 @@ func (m *Grant) Unmarshal(dAtA []byte) error { } return nil } +func (m *Rule) 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: Rule: wiretype end group for non-group") + } + if fieldNum <= 0 { + 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 Key", 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.Key = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Values", 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.Values = append(m.Values, 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 (m *GrantAuthorization) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1094,90 +1233,6 @@ func (m *GrantQueueItem) Unmarshal(dAtA []byte) error { } return nil } -func (m *AuthzRuleKeys) 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: AuthzRuleKeys: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: AuthzRuleKeys: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RawJson", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAuthz - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAuthz - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAuthz - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.RawJson = append(m.RawJson[:0], dAtA[iNdEx:postIndex]...) - if m.RawJson == nil { - m.RawJson = []byte{} - } - 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 80da44d113a0..27b8df71e97c 100644 --- a/x/authz/client/cli/tx.go +++ b/x/authz/client/cli/tx.go @@ -1,6 +1,7 @@ package cli import ( + "encoding/json" "errors" "fmt" "os" @@ -9,6 +10,7 @@ import ( "github.com/spf13/cobra" + bankv1beta1 "cosmossdk.io/api/cosmos/bank/v1beta1" "cosmossdk.io/core/address" "github.com/cosmos/cosmos-sdk/client" @@ -216,7 +218,12 @@ Examples: return err } - msg.SetAuthzRules(contents) + rules, err := buildRules(args[1], contents) + if err != nil { + return err + } + + msg.SetAuthzRules(rules) } return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) @@ -233,6 +240,38 @@ Examples: return cmd } +func buildRules(msg string, rulesBytes []byte) ([]*authz.Rule, error) { + type internalRules struct { + AllowedRecipients []string `json:"allowed_recepients"` + MaxAmount []string `json:"max_amount"` + AllowedStakeValidators []string `json:"allowed_stake_validators"` + AllowedMaxStakeAmount []string `json:"allowed_max_stake_amount"` + } + + var rulesJson internalRules + err := json.Unmarshal(rulesBytes, &rulesJson) + if err != nil { + return nil, err + } + + switch msg { + case sdk.MsgTypeURL(&bankv1beta1.MsgSend{}): + return []*authz.Rule{ + {Key: authz.AllowedRecipients, Values: rulesJson.AllowedRecipients}, + {Key: authz.MaxAmount, Values: rulesJson.MaxAmount}, + }, nil + + case sdk.MsgTypeURL(&staking.MsgDelegate{}): + return []*authz.Rule{ + {Key: authz.AllowedStakeValidators, Values: rulesJson.AllowedStakeValidators}, + {Key: authz.AllowedMaxStakeAmount, Values: rulesJson.AllowedMaxStakeAmount}, + }, nil + + default: + return []*authz.Rule{}, nil + } +} + func getExpireTime(cmd *cobra.Command) (*time.Time, error) { exp, err := cmd.Flags().GetInt64(FlagExpiration) if err != nil { diff --git a/x/authz/consts.go b/x/authz/consts.go new file mode 100644 index 000000000000..06b58f3bc015 --- /dev/null +++ b/x/authz/consts.go @@ -0,0 +1,8 @@ +package authz + +const ( + AllowedRecipients = "allowed_recipients" + MaxAmount = "max_amount" + AllowedStakeValidators = "allowed_stake_validators" + AllowedMaxStakeAmount = "allowed_Max_stake_amount" +) diff --git a/x/authz/generic_authorization.go b/x/authz/generic_authorization.go index 535ff2a93383..a7c790e02bf1 100644 --- a/x/authz/generic_authorization.go +++ b/x/authz/generic_authorization.go @@ -2,7 +2,6 @@ package authz import ( "context" - "encoding/json" "errors" sdk "github.com/cosmos/cosmos-sdk/types" @@ -34,7 +33,3 @@ func (a GenericAuthorization) ValidateBasic() error { } return nil } - -func (a GenericAuthorization) GetOptions() json.RawMessage { - return nil -} diff --git a/x/authz/keeper/keeper.go b/x/authz/keeper/keeper.go index 68990079cdb4..7220ff5c252f 100644 --- a/x/authz/keeper/keeper.go +++ b/x/authz/keeper/keeper.go @@ -3,7 +3,6 @@ package keeper import ( "bytes" "context" - "encoding/json" "fmt" "strconv" "time" @@ -69,65 +68,6 @@ func (k Keeper) getGrant(ctx context.Context, skey []byte) (grant authz.Grant, f return grant, true } -func (k Keeper) SetAuthzRulesKeys(ctx context.Context, options json.RawMessage) error { - store := k.storeService.OpenKVStore(ctx) - - optionsBytes, err := json.Marshal(options) - if err != nil { - return err - } - - authzRuleKeys := authz.AuthzRuleKeys{ - RawJson: optionsBytes, - } - - bz, err := k.cdc.Marshal(&authzRuleKeys) - if err != nil { - return err - } - - err = store.Set(AuthzOptionsKeys, bz) - return err -} - -func (k Keeper) GetAuthzRulesKeys(ctx context.Context) (map[string]interface{}, error) { - store := k.storeService.OpenKVStore(ctx) - bz, err := store.Get(AuthzOptionsKeys) - - if err != nil { - return nil, err - } - - var keys json.RawMessage - var authzRuleKeys authz.AuthzRuleKeys - err = k.cdc.Unmarshal(bz, &authzRuleKeys) - if err != nil { - return nil, err - } - - err = json.Unmarshal(authzRuleKeys.RawJson, &keys) - if err != nil { - return nil, err - } - - // rules := map[string]interface{}{ - // "Send": []string{"AllowRecipients", "SpendLImit"}, - // "Stake": []string{"DelegateLimit"}, - // } - rules := map[string]interface{}{ - // "Send": []string{"AllowRecipients", "SpendLImit"}, - // "Stake": []string{"DelegateLimit"}, - } - - return rules, nil - - // return keys, nil -} - -func (k Keeper) GetAuthzOptions() map[string]map[string]string { - return nil -} - func (k Keeper) update(ctx context.Context, grantee, granter sdk.AccAddress, updated authz.Authorization) error { skey := grantStoreKey(grantee, granter, updated.MsgTypeURL()) grant, found := k.getGrant(ctx, skey) @@ -247,54 +187,7 @@ func (k Keeper) SaveGrant(ctx context.Context, grantee, granter sdk.AccAddress, store := k.storeService.OpenKVStore(ctx) skey := grantStoreKey(grantee, granter, msgType) - grant, err := authz.NewGrant(sdkCtx.BlockTime(), authorization, expiration) - if err != nil { - return err - } - - var oldExp *time.Time - if oldGrant, found := k.getGrant(ctx, skey); found { - oldExp = oldGrant.Expiration - } - - if oldExp != nil && (expiration == nil || !oldExp.Equal(*expiration)) { - if err = k.removeFromGrantQueue(ctx, skey, granter, grantee, *oldExp); err != nil { - return err - } - } - - // If the expiration didn't change, then we don't remove it and we should not insert again - if expiration != nil && (oldExp == nil || !oldExp.Equal(*expiration)) { - if err = k.insertIntoGrantQueue(ctx, granter, grantee, msgType, *expiration); err != nil { - return err - } - } - - bz, err := k.cdc.Marshal(&grant) - if err != nil { - return err - } - - err = store.Set(skey, bz) - if err != nil { - return err - } - - return sdkCtx.EventManager().EmitTypedEvent(&authz.EventGrant{ - MsgTypeUrl: authorization.MsgTypeURL(), - Granter: granter.String(), - Grantee: grantee.String(), - }) -} - -// SaveGrantWithRules method does the same as SaveGrant method but stores rules. -func (k Keeper) SaveGrantWithRules(ctx context.Context, grantee, granter sdk.AccAddress, authorization authz.Authorization, expiration *time.Time, rules []byte) error { - sdkCtx := sdk.UnwrapSDKContext(ctx) - msgType := authorization.MsgTypeURL() - store := k.storeService.OpenKVStore(ctx) - skey := grantStoreKey(grantee, granter, msgType) - - grant, err := authz.NewGrantWithRules(sdkCtx.BlockTime(), authorization, expiration, rules) + grant, err := authz.NewGrant(sdkCtx.BlockTime(), authorization, expiration, nil) if err != nil { return err } @@ -409,25 +302,19 @@ 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, map[string]interface{}) { +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 } - auth, err := grant.GetAuthorization() - if err != nil { - return nil, nil - } - - var rules map[string]interface{} - err = json.Unmarshal(grant.Rules, &rules) + authz, err := grant.GetAuthorization() if err != nil { return nil, nil } - return auth, rules + return authz, grant.Rules } // IterateGrants iterates over all authorization grants 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/msgs.go b/x/authz/msgs.go index bfdef2a7b6ea..9de397bb3855 100644 --- a/x/authz/msgs.go +++ b/x/authz/msgs.go @@ -33,7 +33,7 @@ func NewMsgGrant(granter, grantee sdk.AccAddress, a Authorization, expiration *t return m, nil } -func (msg *MsgGrant) SetAuthzRules(rules []byte) { +func (msg *MsgGrant) SetAuthzRules(rules []*Rule) { msg.Rules = rules } 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/tx.pb.go b/x/authz/tx.pb.go index ead6fd14538f..57e48244884a 100644 --- a/x/authz/tx.pb.go +++ b/x/authz/tx.pb.go @@ -39,7 +39,7 @@ type MsgGrant struct { 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"` + Rules []*Rule `protobuf:"bytes,4,rep,name=rules,proto3" json:"rules,omitempty"` } func (m *MsgGrant) Reset() { *m = MsgGrant{} } @@ -284,43 +284,43 @@ func init() { func init() { proto.RegisterFile("cosmos/authz/v1beta1/tx.proto", fileDescriptor_3ceddab7d8589ad1) } var fileDescriptor_3ceddab7d8589ad1 = []byte{ - // 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, + // 572 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x54, 0x3f, 0x6f, 0xd3, 0x40, + 0x14, 0xcf, 0x35, 0x49, 0x43, 0xae, 0x95, 0xa0, 0x6e, 0x24, 0x5c, 0x57, 0x75, 0x2d, 0xd3, 0x42, + 0x14, 0x14, 0x9b, 0x84, 0x2d, 0x62, 0x69, 0xa4, 0x8a, 0x85, 0x08, 0xc9, 0xc0, 0xc2, 0x12, 0xd9, + 0xc9, 0x71, 0x8d, 0x6a, 0xfb, 0x22, 0x9f, 0x1d, 0x25, 0x4c, 0x88, 0x09, 0x31, 0xf1, 0x31, 0x60, + 0xcb, 0xd0, 0x91, 0x0f, 0x10, 0x31, 0x55, 0x4c, 0x4c, 0x08, 0x92, 0x21, 0x1f, 0x03, 0xe4, 0xfb, + 0x13, 0x52, 0x94, 0x96, 0x4e, 0x2c, 0xf6, 0x7b, 0xef, 0xf7, 0x7b, 0xe7, 0xf7, 0x7b, 0xef, 0xf9, + 0xe0, 0x5e, 0x87, 0xd0, 0x80, 0x50, 0xdb, 0x4d, 0xe2, 0x93, 0xd7, 0xf6, 0xa0, 0xe6, 0xa1, 0xd8, + 0xad, 0xd9, 0xf1, 0xd0, 0xea, 0x47, 0x24, 0x26, 0x4a, 0x89, 0xc3, 0x16, 0x83, 0x2d, 0x01, 0x6b, + 0x3b, 0x3c, 0xda, 0x66, 0x1c, 0x5b, 0x50, 0x98, 0xa3, 0x95, 0x30, 0xc1, 0x84, 0xc7, 0x53, 0x4b, + 0x44, 0x77, 0x30, 0x21, 0xd8, 0x47, 0x36, 0xf3, 0xbc, 0xe4, 0x95, 0xed, 0x86, 0x23, 0x01, 0x19, + 0x2b, 0x0b, 0xe0, 0xdf, 0xe3, 0x8c, 0xdb, 0x82, 0x11, 0x50, 0x6c, 0x0f, 0x6a, 0xe9, 0x4b, 0x00, + 0x5b, 0x6e, 0xd0, 0x0b, 0x89, 0xcd, 0x9e, 0x3c, 0x64, 0xbe, 0x5b, 0x83, 0x37, 0x5a, 0x14, 0x3f, + 0x8e, 0xdc, 0x30, 0x56, 0xea, 0xb0, 0x80, 0x53, 0x03, 0x45, 0x2a, 0x30, 0x40, 0xb9, 0xd8, 0x54, + 0xbf, 0x9e, 0x55, 0xa5, 0xa2, 0xa3, 0x6e, 0x37, 0x42, 0x94, 0x3e, 0x8b, 0xa3, 0x5e, 0x88, 0x1d, + 0x49, 0xfc, 0x93, 0x83, 0xd4, 0xb5, 0xeb, 0xe5, 0x20, 0xe5, 0x11, 0xcc, 0x33, 0x53, 0xcd, 0x1a, + 0xa0, 0xbc, 0x51, 0xdf, 0xb5, 0x56, 0x35, 0xcd, 0x62, 0x35, 0x35, 0x8b, 0x93, 0xef, 0xfb, 0x99, + 0x8f, 0xf3, 0x71, 0x05, 0x38, 0x3c, 0x49, 0x79, 0x00, 0xf3, 0x51, 0xe2, 0x23, 0xaa, 0xe6, 0x8c, + 0x6c, 0x79, 0xa3, 0xae, 0xad, 0xce, 0x76, 0x12, 0x1f, 0x39, 0x9c, 0xd8, 0x38, 0x78, 0x3b, 0x1f, + 0x57, 0x64, 0xc5, 0xef, 0xe7, 0xe3, 0xca, 0x36, 0x4f, 0xa9, 0xd2, 0xee, 0xa9, 0x2d, 0xd5, 0x9b, + 0x0a, 0xbc, 0x25, 0x6d, 0x07, 0xd1, 0x3e, 0x09, 0x29, 0x32, 0x3f, 0x01, 0x58, 0x68, 0x51, 0x7c, + 0x3c, 0x44, 0x9d, 0x65, 0xa5, 0xe0, 0xba, 0x4a, 0x8f, 0x61, 0x2e, 0xa0, 0x98, 0xaa, 0x6b, 0xac, + 0xd4, 0x92, 0xc5, 0xc7, 0x6a, 0xc9, 0xb1, 0x5a, 0x47, 0xe1, 0xa8, 0xb9, 0xfb, 0xe5, 0xac, 0x2a, + 0x46, 0x66, 0x79, 0x2e, 0x45, 0x0b, 0x09, 0x2d, 0x8a, 0x1d, 0x96, 0xde, 0xb8, 0xb3, 0x24, 0x00, + 0xa5, 0x02, 0x94, 0x8b, 0x02, 0xd2, 0xfa, 0xcc, 0xfb, 0xf0, 0xa6, 0x30, 0x65, 0xf9, 0x8a, 0x0a, + 0x0b, 0x11, 0xa2, 0x89, 0x1f, 0x53, 0x15, 0x18, 0xd9, 0xf2, 0xa6, 0x23, 0x5d, 0xf3, 0x33, 0x80, + 0xc5, 0xf4, 0x7c, 0x34, 0x20, 0xa7, 0xe8, 0xbf, 0x0d, 0xde, 0x80, 0x9b, 0x01, 0xc5, 0xed, 0x78, + 0xd4, 0x47, 0xed, 0x24, 0xf2, 0xd9, 0xfc, 0x8b, 0x0e, 0x0c, 0x28, 0x7e, 0x3e, 0xea, 0xa3, 0x17, + 0x91, 0xdf, 0x38, 0xfc, 0x7b, 0x54, 0xa5, 0x8b, 0x4a, 0x79, 0xc1, 0xe6, 0x36, 0xdc, 0x5a, 0x38, + 0x52, 0x6d, 0xfd, 0x17, 0x80, 0xd9, 0x16, 0xc5, 0xca, 0x53, 0x98, 0xe7, 0xfb, 0xac, 0xaf, 0x5e, + 0x0d, 0x39, 0x65, 0xed, 0xee, 0xd5, 0xf8, 0xa2, 0x8d, 0x4f, 0x60, 0x8e, 0x6d, 0xc0, 0xde, 0xa5, + 0xfc, 0x14, 0xd6, 0x0e, 0xaf, 0x84, 0x17, 0xa7, 0x39, 0x70, 0x5d, 0xb4, 0x7d, 0xff, 0xd2, 0x04, + 0x4e, 0xd0, 0xee, 0xfd, 0x83, 0x20, 0xcf, 0xd4, 0xf2, 0x6f, 0xd2, 0x3f, 0xa4, 0xd9, 0x9c, 0xfc, + 0xd4, 0x33, 0x93, 0xa9, 0x0e, 0xce, 0xa7, 0x3a, 0xf8, 0x31, 0xd5, 0xc1, 0x87, 0x99, 0x9e, 0x39, + 0x9f, 0xe9, 0x99, 0x6f, 0x33, 0x3d, 0xf3, 0xf2, 0x00, 0xf7, 0xe2, 0x93, 0xc4, 0xb3, 0x3a, 0x24, + 0x10, 0x77, 0x90, 0xbd, 0xd4, 0xdc, 0x21, 0xbf, 0x43, 0xbc, 0x75, 0xb6, 0x9c, 0x0f, 0x7f, 0x07, + 0x00, 0x00, 0xff, 0xff, 0xe7, 0x98, 0xd2, 0x96, 0xe9, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -514,11 +514,18 @@ func (m *MsgGrant) MarshalToSizedBuffer(dAtA []byte) (int, error) { 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 + 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 = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } } { size, err := m.Grant.MarshalToSizedBuffer(dAtA[:i]) @@ -740,9 +747,11 @@ 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)) + if len(m.Rules) > 0 { + for _, e := range m.Rules { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } } return n } @@ -956,7 +965,7 @@ func (m *MsgGrant) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Rules", wireType) } - var byteLen int + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -966,24 +975,24 @@ func (m *MsgGrant) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + if msglen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + byteLen + postIndex := iNdEx + msglen 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{} + 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: diff --git a/x/bank/types/send_authorization.go b/x/bank/types/send_authorization.go index 9c174058ea50..22449301700b 100644 --- a/x/bank/types/send_authorization.go +++ b/x/bank/types/send_authorization.go @@ -2,7 +2,6 @@ package types import ( context "context" - "encoding/json" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -97,7 +96,3 @@ func toBech32Addresses(allowed []sdk.AccAddress) []string { return allowedAddrs } - -func (a SendAuthorization) GetOptions() json.RawMessage { - return nil -} diff --git a/x/staking/types/authz.go b/x/staking/types/authz.go index 223e1fe7641e..284be1fa5af8 100644 --- a/x/staking/types/authz.go +++ b/x/staking/types/authz.go @@ -2,7 +2,6 @@ package types import ( context "context" - "encoding/json" errorsmod "cosmossdk.io/errors" @@ -154,10 +153,6 @@ func (a StakeAuthorization) Accept(ctx context.Context, msg sdk.Msg) (authz.Acce }, nil } -func (a StakeAuthorization) GetOptions() json.RawMessage { - return nil -} - func validateAllowAndDenyValidators(allowed, denied []sdk.ValAddress) ([]string, []string, error) { if len(allowed) == 0 && len(denied) == 0 { return nil, nil, sdkerrors.ErrInvalidRequest.Wrap("both allowed & deny list cannot be empty") From d5b0c287e48c30106e2f764d3aa8c1dfbb02ffe0 Mon Sep 17 00:00:00 2001 From: atheesh Date: Fri, 24 May 2024 15:11:18 +0530 Subject: [PATCH 16/30] review changes --- api/cosmos/authz/v1beta1/authz.pulsar.go | 601 ++++++++++++++++++++++- proto/cosmos/authz/v1beta1/authz.proto | 5 + simapp/app.go | 22 + x/auth/ante/authz_rules_ante.go | 40 +- x/authz/authz.pb.go | 241 +++++++-- x/authz/keeper/keeper.go | 33 +- x/authz/keeper/keys.go | 2 +- x/authz/keeper/msg_server.go | 61 ++- 8 files changed, 922 insertions(+), 83 deletions(-) diff --git a/api/cosmos/authz/v1beta1/authz.pulsar.go b/api/cosmos/authz/v1beta1/authz.pulsar.go index 865fe2408dc3..1b3f9f560bf5 100644 --- a/api/cosmos/authz/v1beta1/authz.pulsar.go +++ b/api/cosmos/authz/v1beta1/authz.pulsar.go @@ -2756,6 +2756,500 @@ func (x *fastReflection_GrantQueueItem) ProtoMethods() *protoiface.Methods { } } +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, + } +} + // Since: cosmos-sdk 0.43 // Code generated by protoc-gen-go. DO NOT EDIT. @@ -3008,6 +3502,42 @@ 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 +} + var File_cosmos_authz_v1beta1_authz_proto protoreflect.FileDescriptor var file_cosmos_authz_v1beta1_authz_proto_rawDesc = []byte{ @@ -3071,20 +3601,25 @@ var file_cosmos_authz_v1beta1_authz_proto_rawDesc = []byte{ 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, + 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, 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, 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, + 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 ( @@ -3099,27 +3634,29 @@ 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, 5) +var file_cosmos_authz_v1beta1_authz_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_cosmos_authz_v1beta1_authz_proto_goTypes = []interface{}{ (*GenericAuthorization)(nil), // 0: cosmos.authz.v1beta1.GenericAuthorization (*Grant)(nil), // 1: cosmos.authz.v1beta1.Grant (*Rule)(nil), // 2: cosmos.authz.v1beta1.Rule (*GrantAuthorization)(nil), // 3: cosmos.authz.v1beta1.GrantAuthorization (*GrantQueueItem)(nil), // 4: cosmos.authz.v1beta1.GrantQueueItem - (*anypb.Any)(nil), // 5: google.protobuf.Any - (*timestamppb.Timestamp)(nil), // 6: google.protobuf.Timestamp + (*AllowedGrantRulesKeys)(nil), // 5: cosmos.authz.v1beta1.AllowedGrantRulesKeys + (*anypb.Any)(nil), // 6: google.protobuf.Any + (*timestamppb.Timestamp)(nil), // 7: google.protobuf.Timestamp } var file_cosmos_authz_v1beta1_authz_proto_depIdxs = []int32{ - 5, // 0: cosmos.authz.v1beta1.Grant.authorization:type_name -> google.protobuf.Any - 6, // 1: cosmos.authz.v1beta1.Grant.expiration:type_name -> google.protobuf.Timestamp + 6, // 0: cosmos.authz.v1beta1.Grant.authorization:type_name -> google.protobuf.Any + 7, // 1: cosmos.authz.v1beta1.Grant.expiration:type_name -> google.protobuf.Timestamp 2, // 2: cosmos.authz.v1beta1.Grant.rules:type_name -> cosmos.authz.v1beta1.Rule - 5, // 3: cosmos.authz.v1beta1.GrantAuthorization.authorization:type_name -> google.protobuf.Any - 6, // 4: cosmos.authz.v1beta1.GrantAuthorization.expiration:type_name -> google.protobuf.Timestamp - 5, // [5:5] is the sub-list for method output_type - 5, // [5:5] is the sub-list for method input_type - 5, // [5:5] is the sub-list for extension type_name - 5, // [5:5] is the sub-list for extension extendee - 0, // [0:5] is the sub-list for field type_name + 6, // 3: cosmos.authz.v1beta1.GrantAuthorization.authorization:type_name -> google.protobuf.Any + 7, // 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() } @@ -3188,6 +3725,18 @@ 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 + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -3195,7 +3744,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: 5, + NumMessages: 6, NumExtensions: 0, NumServices: 0, }, diff --git a/proto/cosmos/authz/v1beta1/authz.proto b/proto/cosmos/authz/v1beta1/authz.proto index 85188ba62051..e09853294d77 100644 --- a/proto/cosmos/authz/v1beta1/authz.proto +++ b/proto/cosmos/authz/v1beta1/authz.proto @@ -56,3 +56,8 @@ 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; +} diff --git a/simapp/app.go b/simapp/app.go index 241f7b54a26a..d81602e1f8a9 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -3,6 +3,7 @@ package simapp import ( + "context" "encoding/json" "fmt" "io" @@ -562,6 +563,27 @@ func NewSimApp( return app } +func (app *SimApp) RegisterUpgradeHandlers() { + // Upgrade handler for v2 + 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{ + &authz.Rule{Key: sdk.MsgTypeURL(&banktypes.MsgSend{}), Values: []string{ + authz.MaxAmount, authz.AllowedRecipients, + }}, + &authz.Rule{Key: sdk.MsgTypeURL(&stakingtypes.MsgDelegate{}), Values: []string{ + authz.AllowedStakeValidators, authz.AllowedMaxStakeAmount, + }}, + }, + }) + + return app.ModuleManager.RunMigrations(ctx, app.Configurator(), fromVM) + }, + ) +} + func (app *SimApp) setAnteHandler(txConfig client.TxConfig) { anteHandler, err := NewAnteHandler( HandlerOptions{ diff --git a/x/auth/ante/authz_rules_ante.go b/x/auth/ante/authz_rules_ante.go index 93ebba1f9f99..9d138ee2d5ce 100644 --- a/x/auth/ante/authz_rules_ante.go +++ b/x/auth/ante/authz_rules_ante.go @@ -43,25 +43,24 @@ func (azd AuthzDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, // Check if the message is an authorization message if authzMsg, ok := msg.(*authztypes.MsgExec); ok { - msgs, err := authzMsg.GetMessages() + authzMsgs, err := authzMsg.GetMessages() if err != nil { return ctx, err } - for _, innerMsg := range msgs { + for _, innerMsg := range authzMsgs { switch innerMsgConverted := innerMsg.(type) { case *banktypes.MsgSend: - isRulesBroken, err := azd.handleSendAuthzRules(ctx, innerMsgConverted, grantee) - if isRulesBroken { + err := azd.handleSendAuthzRules(ctx, innerMsgConverted, grantee) + if err != nil { return ctx, err } case *stakingv1beta1.MsgDelegate: - isRulesBroken, err := azd.handleStakeAuthzRules(ctx, innerMsgConverted, grantee) - if isRulesBroken { + err := azd.handleStakeAuthzRules(ctx, innerMsgConverted, grantee) + if err != nil { return ctx, err } } - } } } @@ -71,11 +70,10 @@ func (azd AuthzDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, } // handleCheckSendAuthzRules returns true if the rules are voilated -func (azd AuthzDecorator) handleSendAuthzRules(ctx sdk.Context, msg *banktypes.MsgSend, grantee []byte) (bool, error) { - +func (azd AuthzDecorator) handleSendAuthzRules(ctx sdk.Context, msg *banktypes.MsgSend, grantee []byte) error { granter, err := azd.ak.AddressCodec().StringToBytes(msg.FromAddress) if err != nil { - return true, err + return err } _, rules := azd.azk.GetAuthzWithRules(ctx, grantee, granter, sdk.MsgTypeURL(&banktypes.MsgSend{})) @@ -90,29 +88,29 @@ func (azd AuthzDecorator) handleSendAuthzRules(ctx sdk.Context, msg *banktypes.M } if !isAllowed { - return true, errorsmod.Wrap(sdkerrors.ErrTxDecode, "Recipient is not in the allowed list of the grant") + return errorsmod.Wrap(sdkerrors.ErrTxDecode, "Recipient is not in the allowed list of the grant") } } if rule.Key == authztypes.MaxAmount { limit, err := sdk.ParseCoinsNormalized(strings.Join(rule.Values, ",")) if err != nil { - return true, err + return err } if !limit.IsAllGTE(msg.Amount) { - return true, errorsmod.Wrap(sdkerrors.ErrTxDecode, "Amount exceeds the max_amount limit set by the granter") + return errorsmod.Wrap(sdkerrors.ErrTxDecode, "Amount exceeds the max_amount limit set by the granter") } } } - return false, nil + return nil } -func (azd AuthzDecorator) handleStakeAuthzRules(ctx sdk.Context, msg *stakingv1beta1.MsgDelegate, grantee []byte) (bool, error) { +func (azd AuthzDecorator) handleStakeAuthzRules(ctx sdk.Context, msg *stakingv1beta1.MsgDelegate, grantee []byte) error { granter, err := azd.ak.AddressCodec().StringToBytes(msg.DelegatorAddress) if err != nil { - return true, err + return err } _, rules := azd.azk.GetAuthzWithRules(ctx, grantee, granter, sdk.MsgTypeURL(&banktypes.MsgSend{})) @@ -128,25 +126,25 @@ func (azd AuthzDecorator) handleStakeAuthzRules(ctx sdk.Context, msg *stakingv1b } if !isAllowed { - return true, errorsmod.Wrap(sdkerrors.ErrTxDecode, "Validator is not in the allowed validators of the grant") + return errorsmod.Wrap(sdkerrors.ErrTxDecode, "Validator is not in the allowed validators of the grant") } } if rule.Key == authztypes.AllowedMaxStakeAmount { limit, err := sdk.ParseCoinsNormalized(strings.Join(rule.Values, ",")) if err != nil { - return true, err + return err } amount, err := sdk.ParseCoinNormalized(msg.Amount.String()) if err != nil { - return true, err + return err } if !limit.IsAllGTE(sdk.NewCoins(amount)) { - return true, errorsmod.Wrap(sdkerrors.ErrTxDecode, "Amount exceeds the max_amount limit set by the granter") + return errorsmod.Wrap(sdkerrors.ErrTxDecode, "Amount exceeds the max_amount limit set by the granter") } } } - return false, nil + return nil } diff --git a/x/authz/authz.pb.go b/x/authz/authz.pb.go index 6b4a528ffd56..4af0bdcde723 100644 --- a/x/authz/authz.pb.go +++ b/x/authz/authz.pb.go @@ -236,50 +236,91 @@ 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 + 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") } func init() { proto.RegisterFile("cosmos/authz/v1beta1/authz.proto", fileDescriptor_544dc2e84b61c637) } var fileDescriptor_544dc2e84b61c637 = []byte{ - // 505 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x53, 0xcb, 0x6e, 0xd3, 0x40, - 0x14, 0x8d, 0xe3, 0xb4, 0xd0, 0xa9, 0x8a, 0xc0, 0x8a, 0x90, 0xc9, 0xc2, 0x89, 0x2c, 0x84, 0x2a, - 0xa4, 0xd8, 0x6d, 0x61, 0xc5, 0x8a, 0x58, 0x48, 0x15, 0xec, 0x30, 0x65, 0xc3, 0x26, 0x1a, 0x27, - 0x97, 0x89, 0x15, 0xdb, 0x63, 0xcd, 0xa3, 0xaa, 0xfb, 0x09, 0xac, 0xfa, 0x0d, 0x7c, 0x01, 0x8b, + // 533 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xcb, 0x6e, 0xd3, 0x40, + 0x14, 0x8d, 0x93, 0xb4, 0xd0, 0xa9, 0x8a, 0xc0, 0x0a, 0xc8, 0x64, 0xe1, 0x44, 0x16, 0x42, 0x15, + 0x52, 0xec, 0xb6, 0xb0, 0x62, 0x45, 0x2c, 0xa4, 0x08, 0x58, 0x61, 0xca, 0x86, 0x4d, 0x34, 0x4e, + 0x2e, 0x13, 0x2b, 0xb6, 0xc7, 0x9a, 0x47, 0xa9, 0xfb, 0x09, 0xac, 0xfa, 0x0d, 0x7c, 0x01, 0x8b, 0x7e, 0x44, 0xc4, 0xaa, 0x62, 0xc5, 0x8a, 0x47, 0xb2, 0xe0, 0x37, 0x90, 0x67, 0x6c, 0x48, 0xda, - 0x48, 0x64, 0xc1, 0xc6, 0xf2, 0x9d, 0x7b, 0xce, 0x7d, 0x9c, 0x33, 0x83, 0x7a, 0x23, 0xca, 0x53, - 0xca, 0x7d, 0x2c, 0xc5, 0xe4, 0xdc, 0x3f, 0x3d, 0x8c, 0x40, 0xe0, 0x43, 0x1d, 0x79, 0x39, 0xa3, - 0x82, 0x5a, 0x6d, 0x8d, 0xf0, 0xf4, 0x59, 0x85, 0xe8, 0xdc, 0xc3, 0x69, 0x9c, 0x51, 0x5f, 0x7d, - 0x35, 0xb0, 0xf3, 0x40, 0x03, 0x87, 0x2a, 0xf2, 0x2b, 0x96, 0x4e, 0x75, 0x09, 0xa5, 0x24, 0x01, - 0x5f, 0x45, 0x91, 0x7c, 0xef, 0x8b, 0x38, 0x05, 0x2e, 0x70, 0x9a, 0x57, 0x80, 0x36, 0xa1, 0x84, - 0x6a, 0x62, 0xf9, 0x57, 0x57, 0xbc, 0x4e, 0xc3, 0x59, 0x51, 0xa5, 0x9c, 0x6a, 0xee, 0x08, 0x73, - 0xf8, 0x33, 0xf6, 0x88, 0xc6, 0x99, 0xce, 0xbb, 0x02, 0xb5, 0x8f, 0x21, 0x03, 0x16, 0x8f, 0x06, - 0x52, 0x4c, 0x28, 0x8b, 0xcf, 0xb1, 0x88, 0x69, 0x66, 0xdd, 0x45, 0x66, 0xca, 0x89, 0x6d, 0xf4, - 0x8c, 0xfd, 0x9d, 0xb0, 0xfc, 0x7d, 0xf6, 0xea, 0xf3, 0x65, 0xdf, 0x5d, 0xb7, 0xa3, 0xb7, 0xc2, - 0xfc, 0xf0, 0xeb, 0xd3, 0xe3, 0xae, 0x86, 0xf5, 0xf9, 0x78, 0xea, 0xaf, 0xab, 0xee, 0x2e, 0x0c, - 0xb4, 0x75, 0xcc, 0x70, 0x26, 0xac, 0x08, 0xed, 0xe1, 0xe5, 0x94, 0xea, 0xb8, 0x7b, 0xd4, 0xf6, - 0xf4, 0x4a, 0x5e, 0xbd, 0x92, 0x37, 0xc8, 0x8a, 0xe0, 0xd1, 0x66, 0x23, 0x84, 0xab, 0x25, 0xad, - 0x17, 0x08, 0xc1, 0x59, 0x1e, 0x33, 0xdd, 0xa0, 0xa9, 0x1a, 0x74, 0x6e, 0x34, 0x38, 0xa9, 0xa5, - 0x0e, 0x6e, 0xcf, 0xbe, 0x75, 0x8d, 0x8b, 0xef, 0x5d, 0x23, 0x5c, 0xe2, 0x59, 0x07, 0x68, 0x8b, - 0xc9, 0x04, 0xb8, 0x6d, 0xf6, 0x4c, 0x55, 0x60, 0xed, 0x20, 0xa1, 0x4c, 0x20, 0xd4, 0x40, 0xf7, - 0x00, 0xb5, 0xca, 0xb0, 0xd4, 0x72, 0x0a, 0x45, 0xad, 0xe5, 0x14, 0x0a, 0xeb, 0x3e, 0xda, 0x3e, - 0xc5, 0x89, 0x04, 0x6e, 0x37, 0x7b, 0xe6, 0xfe, 0x4e, 0x58, 0x45, 0xee, 0xc7, 0x26, 0xb2, 0x94, - 0x2e, 0xab, 0x66, 0x1c, 0xa1, 0x5b, 0xa4, 0x3c, 0x05, 0xa6, 0x8b, 0x04, 0xf6, 0x97, 0xcb, 0x7e, - 0x7d, 0xdf, 0x06, 0xe3, 0x31, 0x03, 0xce, 0xdf, 0x08, 0x16, 0x67, 0x24, 0xac, 0x81, 0x7f, 0x39, - 0xa0, 0x36, 0xde, 0x80, 0x03, 0x37, 0xcd, 0x30, 0xff, 0xbf, 0x19, 0xcf, 0x57, 0xcc, 0x68, 0xfd, - 0xd3, 0x8c, 0xd6, 0x75, 0x23, 0xdc, 0xa7, 0xe8, 0x8e, 0xd2, 0xe8, 0xb5, 0x04, 0x09, 0x2f, 0x05, - 0xa4, 0x96, 0x8b, 0xf6, 0x52, 0x4e, 0x86, 0xa2, 0xc8, 0x61, 0x28, 0x59, 0xc2, 0x6d, 0x43, 0xa9, - 0xba, 0x9b, 0x72, 0x72, 0x52, 0xe4, 0xf0, 0x96, 0x25, 0x3c, 0x08, 0x66, 0x3f, 0x9d, 0xc6, 0x6c, - 0xee, 0x18, 0x57, 0x73, 0xc7, 0xf8, 0x31, 0x77, 0x8c, 0x8b, 0x85, 0xd3, 0xb8, 0x5a, 0x38, 0x8d, - 0xaf, 0x0b, 0xa7, 0xf1, 0xee, 0x21, 0x89, 0xc5, 0x44, 0x46, 0xde, 0x88, 0xa6, 0xd5, 0x8b, 0xf4, - 0x97, 0xee, 0xf0, 0x99, 0x7e, 0xe8, 0xd1, 0xb6, 0x9a, 0xef, 0xc9, 0xef, 0x00, 0x00, 0x00, 0xff, - 0xff, 0x7b, 0x22, 0x81, 0x7c, 0x0d, 0x04, 0x00, 0x00, + 0x08, 0xba, 0x60, 0x13, 0xcd, 0x9d, 0x7b, 0xce, 0x7d, 0x9c, 0x93, 0x31, 0xea, 0x8e, 0x28, 0x4f, + 0x28, 0xf7, 0xb0, 0x14, 0x93, 0x13, 0xef, 0x68, 0x3f, 0x04, 0x81, 0xf7, 0x75, 0xe4, 0x66, 0x8c, + 0x0a, 0x6a, 0xb6, 0x34, 0xc2, 0xd5, 0x77, 0x25, 0xa2, 0x7d, 0x0b, 0x27, 0x51, 0x4a, 0x3d, 0xf5, + 0xab, 0x81, 0xed, 0xbb, 0x1a, 0x38, 0x54, 0x91, 0x57, 0xb2, 0x74, 0xaa, 0x43, 0x28, 0x25, 0x31, + 0x78, 0x2a, 0x0a, 0xe5, 0x5b, 0x4f, 0x44, 0x09, 0x70, 0x81, 0x93, 0xac, 0x04, 0xb4, 0x08, 0x25, + 0x54, 0x13, 0x8b, 0x53, 0x55, 0xf1, 0x22, 0x0d, 0xa7, 0x79, 0x99, 0xb2, 0xcb, 0xb9, 0x43, 0xcc, + 0xe1, 0xf7, 0xd8, 0x23, 0x1a, 0xa5, 0x3a, 0xef, 0x08, 0xd4, 0x1a, 0x40, 0x0a, 0x2c, 0x1a, 0xf5, + 0xa5, 0x98, 0x50, 0x16, 0x9d, 0x60, 0x11, 0xd1, 0xd4, 0xbc, 0x89, 0x1a, 0x09, 0x27, 0x96, 0xd1, + 0x35, 0x76, 0xb7, 0x82, 0xe2, 0xf8, 0xf8, 0xf9, 0xa7, 0xb3, 0x9e, 0xb3, 0x6e, 0x47, 0x77, 0x85, + 0xf9, 0xfe, 0xe7, 0xc7, 0x07, 0x1d, 0x0d, 0xeb, 0xf1, 0xf1, 0xd4, 0x5b, 0x57, 0xdd, 0x59, 0x18, + 0x68, 0x63, 0xc0, 0x70, 0x2a, 0xcc, 0x10, 0xed, 0xe0, 0xe5, 0x94, 0xea, 0xb8, 0x7d, 0xd0, 0x72, + 0xf5, 0x4a, 0x6e, 0xb5, 0x92, 0xdb, 0x4f, 0x73, 0xff, 0xfe, 0xd5, 0x46, 0x08, 0x56, 0x4b, 0x9a, + 0x4f, 0x11, 0x82, 0xe3, 0x2c, 0x62, 0xba, 0x41, 0x5d, 0x35, 0x68, 0x5f, 0x6a, 0x70, 0x58, 0x49, + 0xed, 0x5f, 0x9f, 0x7d, 0xed, 0x18, 0xa7, 0xdf, 0x3a, 0x46, 0xb0, 0xc4, 0x33, 0xf7, 0xd0, 0x06, + 0x93, 0x31, 0x70, 0xab, 0xd1, 0x6d, 0xa8, 0x02, 0x6b, 0x07, 0x09, 0x64, 0x0c, 0x81, 0x06, 0x3a, + 0x7b, 0xa8, 0x59, 0x84, 0x85, 0x96, 0x53, 0xc8, 0x2b, 0x2d, 0xa7, 0x90, 0x9b, 0x77, 0xd0, 0xe6, + 0x11, 0x8e, 0x25, 0x70, 0xab, 0xde, 0x6d, 0xec, 0x6e, 0x05, 0x65, 0xe4, 0x7c, 0xa8, 0x23, 0x53, + 0xe9, 0xb2, 0x6a, 0xc6, 0x01, 0xba, 0x46, 0x8a, 0x5b, 0x60, 0xba, 0x88, 0x6f, 0x7d, 0x3e, 0xeb, + 0x55, 0xff, 0xb7, 0xfe, 0x78, 0xcc, 0x80, 0xf3, 0x57, 0x82, 0x45, 0x29, 0x09, 0x2a, 0xe0, 0x1f, + 0x0e, 0xa8, 0x8d, 0xaf, 0xc0, 0x81, 0xcb, 0x66, 0x34, 0xfe, 0xbf, 0x19, 0x4f, 0x56, 0xcc, 0x68, + 0xfe, 0xd3, 0x8c, 0xe6, 0x45, 0x23, 0x9c, 0x47, 0xe8, 0x86, 0xd2, 0xe8, 0xa5, 0x04, 0x09, 0xcf, + 0x04, 0x24, 0xa6, 0x83, 0x76, 0x12, 0x4e, 0x86, 0x22, 0xcf, 0x60, 0x28, 0x59, 0xcc, 0x2d, 0x43, + 0xa9, 0xba, 0x9d, 0x70, 0x72, 0x98, 0x67, 0xf0, 0x9a, 0xc5, 0xdc, 0x19, 0xa0, 0xdb, 0xfd, 0x38, + 0xa6, 0xef, 0x60, 0xac, 0xc8, 0x85, 0x31, 0xfc, 0x05, 0xe4, 0xdc, 0x74, 0x51, 0x73, 0x0a, 0xb9, + 0xe6, 0xfc, 0xdd, 0x56, 0x85, 0xf3, 0xfd, 0xd9, 0x0f, 0xbb, 0x36, 0x9b, 0xdb, 0xc6, 0xf9, 0xdc, + 0x36, 0xbe, 0xcf, 0x6d, 0xe3, 0x74, 0x61, 0xd7, 0xce, 0x17, 0x76, 0xed, 0xcb, 0xc2, 0xae, 0xbd, + 0xb9, 0x47, 0x22, 0x31, 0x91, 0xa1, 0x3b, 0xa2, 0x49, 0xf9, 0xb4, 0xbd, 0xa5, 0xc7, 0x70, 0xac, + 0xbf, 0x18, 0xe1, 0xa6, 0x5a, 0xf4, 0xe1, 0xaf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x44, 0xd3, 0x32, + 0x34, 0x56, 0x04, 0x00, 0x00, } func (m *GenericAuthorization) Marshal() (dAtA []byte, err error) { @@ -501,6 +542,43 @@ 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 encodeVarintAuthz(dAtA []byte, offset int, v uint64) int { offset -= sovAuthz(v) base := offset @@ -607,6 +685,21 @@ 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 sovAuthz(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1233,6 +1326,90 @@ 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 skipAuthz(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/authz/keeper/keeper.go b/x/authz/keeper/keeper.go index 7220ff5c252f..c1a750576c85 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, nil) + grant, err := authz.NewGrant(sdkCtx.BlockTime(), authorization, expiration, rules) if err != nil { return err } @@ -337,6 +337,35 @@ 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) { + 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/keys.go b/x/authz/keeper/keys.go index 120af14b652e..24e4f1428a1a 100644 --- a/x/authz/keeper/keys.go +++ b/x/authz/keeper/keys.go @@ -18,7 +18,7 @@ import ( var ( GrantKey = []byte{0x01} // prefix for each key GrantQueuePrefix = []byte{0x02} - AuthzOptionsKeys = []byte{0x04} + 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 80a7ffc05cad..030acb8e64e0 100644 --- a/x/authz/keeper/msg_server.go +++ b/x/authz/keeper/msg_server.go @@ -3,6 +3,8 @@ package keeper import ( "context" "errors" + "fmt" + "reflect" "strings" errorsmod "cosmossdk.io/errors" @@ -52,7 +54,14 @@ func (k Keeper) Grant(goCtx context.Context, msg *authz.MsgGrant) (*authz.MsgGra return nil, sdkerrors.ErrInvalidType.Wrapf("%s doesn't exist.", t) } - err = k.SaveGrantWithRules(ctx, grantee, granter, authorization, msg.Grant.Expiration, msg.Rules) + if msg.Rules != nil { + err := k.VerifyTheRules(goCtx, msg.Grant.Authorization.GetTypeUrl(), msg.Rules) + if err != nil { + return nil, err + } + } + + err = k.SaveGrant(ctx, grantee, granter, authorization, msg.Grant.Expiration, msg.Rules) if err != nil { return nil, err } @@ -60,6 +69,56 @@ 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) VerifyTheRules(goCtx context.Context, msg string, rules []*authz.Rule) error { + registeredRules, err := k.GetAuthzRulesKeys(goCtx) + if err != nil { + return err + } + + var values []string + for _, v := range registeredRules.Keys { + if v.Key == msg { + values = v.Values + break + } + } + + if err := checkStructKeys(rules, values); err != nil { + return err + } + + return 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 +} + // 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) { From 0002d1b53fce25291ce72a17947defc25e9c16f3 Mon Sep 17 00:00:00 2001 From: atheesh Date: Tue, 28 May 2024 14:34:28 +0530 Subject: [PATCH 17/30] fix build --- simapp/app.go | 22 ---------------- simapp/upgrades.go | 22 ++++++++++++++++ x/authz/authorization_grant_test.go | 2 +- x/authz/keeper/genesis.go | 2 +- x/authz/keeper/genesis_test.go | 2 +- x/authz/keeper/grpc_query_test.go | 4 +-- x/authz/keeper/keeper_test.go | 38 +++++++++++++-------------- x/authz/module/abci_test.go | 2 +- x/authz/simulation/operations_test.go | 4 +-- 9 files changed, 49 insertions(+), 49 deletions(-) diff --git a/simapp/app.go b/simapp/app.go index d81602e1f8a9..241f7b54a26a 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -3,7 +3,6 @@ package simapp import ( - "context" "encoding/json" "fmt" "io" @@ -563,27 +562,6 @@ func NewSimApp( return app } -func (app *SimApp) RegisterUpgradeHandlers() { - // Upgrade handler for v2 - 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{ - &authz.Rule{Key: sdk.MsgTypeURL(&banktypes.MsgSend{}), Values: []string{ - authz.MaxAmount, authz.AllowedRecipients, - }}, - &authz.Rule{Key: sdk.MsgTypeURL(&stakingtypes.MsgDelegate{}), Values: []string{ - authz.AllowedStakeValidators, authz.AllowedMaxStakeAmount, - }}, - }, - }) - - return app.ModuleManager.RunMigrations(ctx, app.Configurator(), fromVM) - }, - ) -} - func (app *SimApp) setAnteHandler(txConfig client.TxConfig) { anteHandler, err := NewAnteHandler( HandlerOptions{ diff --git a/simapp/upgrades.go b/simapp/upgrades.go index 66c9fb87e7c0..cdfa1075c9fc 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,24 @@ 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{ + &authz.Rule{Key: sdk.MsgTypeURL(&banktypes.MsgSend{}), Values: []string{ + authz.MaxAmount, authz.AllowedRecipients, + }}, + &authz.Rule{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/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/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_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/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/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 From 80a08d1edf4d791566a0557b3bda30647bf8a3e8 Mon Sep 17 00:00:00 2001 From: atheesh Date: Tue, 28 May 2024 15:08:23 +0530 Subject: [PATCH 18/30] fix build --- simapp/app.go | 2 +- simapp/app_v2.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/simapp/app.go b/simapp/app.go index 241f7b54a26a..aea21e2830ae 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -1,4 +1,4 @@ -//go:build !app_v1 +//go:build app_v1 package simapp diff --git a/simapp/app_v2.go b/simapp/app_v2.go index 40620509414a..e10a54e7449e 100644 --- a/simapp/app_v2.go +++ b/simapp/app_v2.go @@ -1,4 +1,4 @@ -//go:build app_v1 +//go:build !app_v1 package simapp From 7954140e268c4809fd75dce96892d1469744e9c2 Mon Sep 17 00:00:00 2001 From: atheesh Date: Tue, 28 May 2024 17:28:25 +0530 Subject: [PATCH 19/30] review changes --- api/cosmos/authz/v1beta1/authz.pulsar.go | 984 ++++++++++++++++++++++- api/cosmos/authz/v1beta1/tx.pulsar.go | 274 +++---- proto/cosmos/authz/v1beta1/authz.proto | 8 + proto/cosmos/authz/v1beta1/tx.proto | 2 +- x/authz/authz.pb.go | 388 ++++++++- x/authz/client/cli/tx.go | 41 +- x/authz/keeper/msg_server.go | 38 +- x/authz/msgs.go | 2 +- x/authz/tx.pb.go | 115 ++- 9 files changed, 1509 insertions(+), 343 deletions(-) mode change 100644 => 100755 proto/cosmos/authz/v1beta1/tx.proto diff --git a/api/cosmos/authz/v1beta1/authz.pulsar.go b/api/cosmos/authz/v1beta1/authz.pulsar.go index 1b3f9f560bf5..a48e0f5cccdd 100644 --- a/api/cosmos/authz/v1beta1/authz.pulsar.go +++ b/api/cosmos/authz/v1beta1/authz.pulsar.go @@ -3250,6 +3250,858 @@ func (x *fastReflection_AllowedGrantRulesKeys) ProtoMethods() *protoiface.Method } } +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) +} + +func (x *_AppAuthzRules_4_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfString((*x.list)[i]) +} + +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 ( + 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 +) + +func init() { + file_cosmos_authz_v1beta1_authz_proto_init() + 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") +} + +var _ protoreflect.Message = (*fastReflection_AppAuthzRules)(nil) + +type fastReflection_AppAuthzRules AppAuthzRules + +func (x *AppAuthzRules) ProtoReflect() protoreflect.Message { + return (*fastReflection_AppAuthzRules)(x) +} + +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 { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_AppAuthzRules_messageType fastReflection_AppAuthzRules_messageType +var _ protoreflect.MessageType = fastReflection_AppAuthzRules_messageType{} + +type fastReflection_AppAuthzRules_messageType struct{} + +func (x fastReflection_AppAuthzRules_messageType) Zero() protoreflect.Message { + return (*fastReflection_AppAuthzRules)(nil) +} +func (x fastReflection_AppAuthzRules_messageType) New() protoreflect.Message { + return new(fastReflection_AppAuthzRules) +} +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_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_AppAuthzRules) Type() protoreflect.MessageType { + return _fastReflection_AppAuthzRules_messageType +} + +// New returns a newly allocated and mutable empty message. +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_AppAuthzRules) Interface() protoreflect.ProtoMessage { + return (*AppAuthzRules)(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_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 + } + } +} + +// 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_AppAuthzRules) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + 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 + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.AppAuthzRules")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.AppAuthzRules 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_AppAuthzRules) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + 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 + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.AppAuthzRules")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.AppAuthzRules 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_AppAuthzRules) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "cosmos.authz.v1beta1.AppAuthzRules.allowed_recipients": + if len(x.AllowedRecipients) == 0 { + return protoreflect.ValueOfList(&_AppAuthzRules_1_list{}) + } + 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) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.AppAuthzRules")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.AppAuthzRules 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_AppAuthzRules) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "cosmos.authz.v1beta1.AppAuthzRules.allowed_recipients": + lv := value.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 + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.AppAuthzRules")) + } + panic(fmt.Errorf("message cosmos.authz.v1beta1.AppAuthzRules 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_AppAuthzRules) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.authz.v1beta1.AppAuthzRules.allowed_recipients": + if x.AllowedRecipients == nil { + x.AllowedRecipients = []string{} + } + 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) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.AppAuthzRules")) + } + 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_AppAuthzRules) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.authz.v1beta1.AppAuthzRules.allowed_recipients": + list := []string{} + 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}) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.AppAuthzRules")) + } + 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_AppAuthzRules) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.authz.v1beta1.AppAuthzRules", 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_AppAuthzRules) 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_AppAuthzRules) 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_AppAuthzRules) 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_AppAuthzRules) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*AppAuthzRules) + 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.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 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().(*AppAuthzRules) + 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.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 + } + } + 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().(*AppAuthzRules) + 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: 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 + } + 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) + } + 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 AllowedStakeValidators", 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.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 + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + // Since: cosmos-sdk 0.43 // Code generated by protoc-gen-go. DO NOT EDIT. @@ -3538,6 +4390,66 @@ func (x *AllowedGrantRulesKeys) GetKeys() []*Rule { 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"` +} + +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 +} + var File_cosmos_authz_v1beta1_authz_proto protoreflect.FileDescriptor var file_cosmos_authz_v1beta1_authz_proto_rawDesc = []byte{ @@ -3605,21 +4517,34 @@ var file_cosmos_authz_v1beta1_authz_proto_rawDesc = []byte{ 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, 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, + 0x52, 0x75, 0x6c, 0x65, 0x52, 0x04, 0x6b, 0x65, 0x79, 0x73, 0x22, 0xd0, 0x01, 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, 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 ( @@ -3634,7 +4559,7 @@ 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, 6) +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 @@ -3642,15 +4567,16 @@ var file_cosmos_authz_v1beta1_authz_proto_goTypes = []interface{}{ (*GrantAuthorization)(nil), // 3: cosmos.authz.v1beta1.GrantAuthorization (*GrantQueueItem)(nil), // 4: cosmos.authz.v1beta1.GrantQueueItem (*AllowedGrantRulesKeys)(nil), // 5: cosmos.authz.v1beta1.AllowedGrantRulesKeys - (*anypb.Any)(nil), // 6: google.protobuf.Any - (*timestamppb.Timestamp)(nil), // 7: google.protobuf.Timestamp + (*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{ - 6, // 0: cosmos.authz.v1beta1.Grant.authorization:type_name -> google.protobuf.Any - 7, // 1: cosmos.authz.v1beta1.Grant.expiration:type_name -> google.protobuf.Timestamp + 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 - 6, // 3: cosmos.authz.v1beta1.GrantAuthorization.authorization:type_name -> google.protobuf.Any - 7, // 4: cosmos.authz.v1beta1.GrantAuthorization.expiration:type_name -> google.protobuf.Timestamp + 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 @@ -3737,6 +4663,18 @@ func file_cosmos_authz_v1beta1_authz_proto_init() { 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{ @@ -3744,7 +4682,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: 6, + 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 b3474119b1e5..4fc726a1e59b 100644 --- a/api/cosmos/authz/v1beta1/tx.pulsar.go +++ b/api/cosmos/authz/v1beta1/tx.pulsar.go @@ -17,57 +17,6 @@ import ( sync "sync" ) -var _ protoreflect.List = (*_MsgGrant_4_list)(nil) - -type _MsgGrant_4_list struct { - list *[]*Rule -} - -func (x *_MsgGrant_4_list) Len() int { - if x.list == nil { - return 0 - } - return len(*x.list) -} - -func (x *_MsgGrant_4_list) Get(i int) protoreflect.Value { - return protoreflect.ValueOfMessage((*x.list)[i].ProtoReflect()) -} - -func (x *_MsgGrant_4_list) Set(i int, value protoreflect.Value) { - valueUnwrapped := value.Message() - concreteValue := valueUnwrapped.Interface().(*Rule) - (*x.list)[i] = concreteValue -} - -func (x *_MsgGrant_4_list) Append(value protoreflect.Value) { - valueUnwrapped := value.Message() - concreteValue := valueUnwrapped.Interface().(*Rule) - *x.list = append(*x.list, concreteValue) -} - -func (x *_MsgGrant_4_list) AppendMutable() protoreflect.Value { - v := new(Rule) - *x.list = append(*x.list, v) - return protoreflect.ValueOfMessage(v.ProtoReflect()) -} - -func (x *_MsgGrant_4_list) Truncate(n int) { - for i := n; i < len(*x.list); i++ { - (*x.list)[i] = nil - } - *x.list = (*x.list)[:n] -} - -func (x *_MsgGrant_4_list) NewElement() protoreflect.Value { - v := new(Rule) - return protoreflect.ValueOfMessage(v.ProtoReflect()) -} - -func (x *_MsgGrant_4_list) IsValid() bool { - return x.list != nil -} - var ( md_MsgGrant protoreflect.MessageDescriptor fd_MsgGrant_granter protoreflect.FieldDescriptor @@ -169,7 +118,7 @@ func (x *fastReflection_MsgGrant) Range(f func(protoreflect.FieldDescriptor, pro } } if len(x.Rules) != 0 { - value := protoreflect.ValueOfList(&_MsgGrant_4_list{list: &x.Rules}) + value := protoreflect.ValueOfBytes(x.Rules) if !f(fd_MsgGrant_rules, value) { return } @@ -247,11 +196,8 @@ func (x *fastReflection_MsgGrant) Get(descriptor protoreflect.FieldDescriptor) p value := x.Grant return protoreflect.ValueOfMessage(value.ProtoReflect()) case "cosmos.authz.v1beta1.MsgGrant.rules": - if len(x.Rules) == 0 { - return protoreflect.ValueOfList(&_MsgGrant_4_list{}) - } - listValue := &_MsgGrant_4_list{list: &x.Rules} - return protoreflect.ValueOfList(listValue) + 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")) @@ -279,9 +225,7 @@ func (x *fastReflection_MsgGrant) Set(fd protoreflect.FieldDescriptor, value pro case "cosmos.authz.v1beta1.MsgGrant.grant": x.Grant = value.Message().Interface().(*Grant) case "cosmos.authz.v1beta1.MsgGrant.rules": - lv := value.List() - clv := lv.(*_MsgGrant_4_list) - x.Rules = *clv.list + x.Rules = value.Bytes() default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.MsgGrant")) @@ -307,16 +251,12 @@ func (x *fastReflection_MsgGrant) Mutable(fd protoreflect.FieldDescriptor) proto x.Grant = new(Grant) } return protoreflect.ValueOfMessage(x.Grant.ProtoReflect()) - case "cosmos.authz.v1beta1.MsgGrant.rules": - if x.Rules == nil { - x.Rules = []*Rule{} - } - value := &_MsgGrant_4_list{list: &x.Rules} - return protoreflect.ValueOfList(value) case "cosmos.authz.v1beta1.MsgGrant.granter": 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")) @@ -338,8 +278,7 @@ func (x *fastReflection_MsgGrant) NewField(fd protoreflect.FieldDescriptor) prot m := new(Grant) return protoreflect.ValueOfMessage(m.ProtoReflect()) case "cosmos.authz.v1beta1.MsgGrant.rules": - list := []*Rule{} - return protoreflect.ValueOfList(&_MsgGrant_4_list{list: &list}) + return protoreflect.ValueOfBytes(nil) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.authz.v1beta1.MsgGrant")) @@ -421,11 +360,9 @@ func (x *fastReflection_MsgGrant) ProtoMethods() *protoiface.Methods { l = options.Size(x.Grant) 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)) - } + l = len(x.Rules) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) } if x.unknownFields != nil { n += len(x.unknownFields) @@ -457,20 +394,11 @@ func (x *fastReflection_MsgGrant) ProtoMethods() *protoiface.Methods { 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] = 0x22 - } + 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) @@ -653,7 +581,7 @@ func (x *fastReflection_MsgGrant) ProtoMethods() *protoiface.Methods { 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 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow @@ -663,24 +591,24 @@ func (x *fastReflection_MsgGrant) ProtoMethods() *protoiface.Methods { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + if byteLen < 0 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength } - postIndex := iNdEx + msglen + 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, &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 + x.Rules = append(x.Rules[:0], dAtA[iNdEx:postIndex]...) + if x.Rules == nil { + x.Rules = []byte{} } iNdEx = postIndex default: @@ -3042,7 +2970,7 @@ type MsgGrant struct { 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 []*Rule `protobuf:"bytes,4,rep,name=rules,proto3" json:"rules,omitempty"` + Rules []byte `protobuf:"bytes,4,opt,name=rules,proto3" json:"rules,omitempty"` } func (x *MsgGrant) Reset() { @@ -3086,7 +3014,7 @@ func (x *MsgGrant) GetGrant() *Grant { return nil } -func (x *MsgGrant) GetRules() []*Rule { +func (x *MsgGrant) GetRules() []byte { if x != nil { return x.Rules } @@ -3301,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, - 0x88, 0x02, 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, @@ -3312,70 +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, 0x12, 0x30, 0x0a, 0x05, 0x72, 0x75, 0x6c, 0x65, 0x73, 0x18, 0x04, 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, 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, + 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, 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, + 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 ( @@ -3399,24 +3325,22 @@ var file_cosmos_authz_v1beta1_tx_proto_goTypes = []interface{}{ (*MsgRevoke)(nil), // 4: cosmos.authz.v1beta1.MsgRevoke (*MsgRevokeResponse)(nil), // 5: cosmos.authz.v1beta1.MsgRevokeResponse (*Grant)(nil), // 6: cosmos.authz.v1beta1.Grant - (*Rule)(nil), // 7: cosmos.authz.v1beta1.Rule - (*anypb.Any)(nil), // 8: google.protobuf.Any + (*anypb.Any)(nil), // 7: google.protobuf.Any } var file_cosmos_authz_v1beta1_tx_proto_depIdxs = []int32{ 6, // 0: cosmos.authz.v1beta1.MsgGrant.grant:type_name -> cosmos.authz.v1beta1.Grant - 7, // 1: cosmos.authz.v1beta1.MsgGrant.rules:type_name -> cosmos.authz.v1beta1.Rule - 8, // 2: cosmos.authz.v1beta1.MsgExec.msgs:type_name -> google.protobuf.Any - 0, // 3: cosmos.authz.v1beta1.Msg.Grant:input_type -> cosmos.authz.v1beta1.MsgGrant - 2, // 4: cosmos.authz.v1beta1.Msg.Exec:input_type -> cosmos.authz.v1beta1.MsgExec - 4, // 5: cosmos.authz.v1beta1.Msg.Revoke:input_type -> cosmos.authz.v1beta1.MsgRevoke - 1, // 6: cosmos.authz.v1beta1.Msg.Grant:output_type -> cosmos.authz.v1beta1.MsgGrantResponse - 3, // 7: cosmos.authz.v1beta1.Msg.Exec:output_type -> cosmos.authz.v1beta1.MsgExecResponse - 5, // 8: cosmos.authz.v1beta1.Msg.Revoke:output_type -> cosmos.authz.v1beta1.MsgRevokeResponse - 6, // [6:9] is the sub-list for method output_type - 3, // [3:6] is the sub-list for method input_type - 3, // [3:3] is the sub-list for extension type_name - 3, // [3:3] is the sub-list for extension extendee - 0, // [0:3] is the sub-list for field type_name + 7, // 1: cosmos.authz.v1beta1.MsgExec.msgs:type_name -> google.protobuf.Any + 0, // 2: cosmos.authz.v1beta1.Msg.Grant:input_type -> cosmos.authz.v1beta1.MsgGrant + 2, // 3: cosmos.authz.v1beta1.Msg.Exec:input_type -> cosmos.authz.v1beta1.MsgExec + 4, // 4: cosmos.authz.v1beta1.Msg.Revoke:input_type -> cosmos.authz.v1beta1.MsgRevoke + 1, // 5: cosmos.authz.v1beta1.Msg.Grant:output_type -> cosmos.authz.v1beta1.MsgGrantResponse + 3, // 6: cosmos.authz.v1beta1.Msg.Exec:output_type -> cosmos.authz.v1beta1.MsgExecResponse + 5, // 7: cosmos.authz.v1beta1.Msg.Revoke:output_type -> cosmos.authz.v1beta1.MsgRevokeResponse + 5, // [5:8] is the sub-list for method output_type + 2, // [2:5] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name } func init() { file_cosmos_authz_v1beta1_tx_proto_init() } diff --git a/proto/cosmos/authz/v1beta1/authz.proto b/proto/cosmos/authz/v1beta1/authz.proto index e09853294d77..9198778f1b45 100644 --- a/proto/cosmos/authz/v1beta1/authz.proto +++ b/proto/cosmos/authz/v1beta1/authz.proto @@ -61,3 +61,11 @@ message GrantQueueItem { 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; +} \ 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 1429f015b15e..858b582dcd05 --- a/proto/cosmos/authz/v1beta1/tx.proto +++ b/proto/cosmos/authz/v1beta1/tx.proto @@ -44,7 +44,7 @@ message MsgGrant { cosmos.authz.v1beta1.Grant grant = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; // rules are conditions to execute the grant. - repeated cosmos.authz.v1beta1.Rule rules = 4; + bytes rules = 4; } // MsgGrantResponse defines the Msg/MsgGrant response type. diff --git a/x/authz/authz.pb.go b/x/authz/authz.pb.go index 4af0bdcde723..912440e06cd9 100644 --- a/x/authz/authz.pb.go +++ b/x/authz/authz.pb.go @@ -274,6 +274,47 @@ func (m *AllowedGrantRulesKeys) XXX_DiscardUnknown() { 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"` +} + +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") @@ -281,46 +322,53 @@ func init() { 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{ - // 533 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xcb, 0x6e, 0xd3, 0x40, - 0x14, 0x8d, 0x93, 0xb4, 0xd0, 0xa9, 0x8a, 0xc0, 0x0a, 0xc8, 0x64, 0xe1, 0x44, 0x16, 0x42, 0x15, - 0x52, 0xec, 0xb6, 0xb0, 0x62, 0x45, 0x2c, 0xa4, 0x08, 0x58, 0x61, 0xca, 0x86, 0x4d, 0x34, 0x4e, - 0x2e, 0x13, 0x2b, 0xb6, 0xc7, 0x9a, 0x47, 0xa9, 0xfb, 0x09, 0xac, 0xfa, 0x0d, 0x7c, 0x01, 0x8b, - 0x7e, 0x44, 0xc4, 0xaa, 0x62, 0xc5, 0x8a, 0x47, 0xb2, 0xe0, 0x37, 0x90, 0x67, 0x6c, 0x48, 0xda, - 0x08, 0xba, 0x60, 0x13, 0xcd, 0x9d, 0x7b, 0xce, 0x7d, 0x9c, 0x93, 0x31, 0xea, 0x8e, 0x28, 0x4f, - 0x28, 0xf7, 0xb0, 0x14, 0x93, 0x13, 0xef, 0x68, 0x3f, 0x04, 0x81, 0xf7, 0x75, 0xe4, 0x66, 0x8c, - 0x0a, 0x6a, 0xb6, 0x34, 0xc2, 0xd5, 0x77, 0x25, 0xa2, 0x7d, 0x0b, 0x27, 0x51, 0x4a, 0x3d, 0xf5, - 0xab, 0x81, 0xed, 0xbb, 0x1a, 0x38, 0x54, 0x91, 0x57, 0xb2, 0x74, 0xaa, 0x43, 0x28, 0x25, 0x31, - 0x78, 0x2a, 0x0a, 0xe5, 0x5b, 0x4f, 0x44, 0x09, 0x70, 0x81, 0x93, 0xac, 0x04, 0xb4, 0x08, 0x25, - 0x54, 0x13, 0x8b, 0x53, 0x55, 0xf1, 0x22, 0x0d, 0xa7, 0x79, 0x99, 0xb2, 0xcb, 0xb9, 0x43, 0xcc, - 0xe1, 0xf7, 0xd8, 0x23, 0x1a, 0xa5, 0x3a, 0xef, 0x08, 0xd4, 0x1a, 0x40, 0x0a, 0x2c, 0x1a, 0xf5, - 0xa5, 0x98, 0x50, 0x16, 0x9d, 0x60, 0x11, 0xd1, 0xd4, 0xbc, 0x89, 0x1a, 0x09, 0x27, 0x96, 0xd1, - 0x35, 0x76, 0xb7, 0x82, 0xe2, 0xf8, 0xf8, 0xf9, 0xa7, 0xb3, 0x9e, 0xb3, 0x6e, 0x47, 0x77, 0x85, - 0xf9, 0xfe, 0xe7, 0xc7, 0x07, 0x1d, 0x0d, 0xeb, 0xf1, 0xf1, 0xd4, 0x5b, 0x57, 0xdd, 0x59, 0x18, - 0x68, 0x63, 0xc0, 0x70, 0x2a, 0xcc, 0x10, 0xed, 0xe0, 0xe5, 0x94, 0xea, 0xb8, 0x7d, 0xd0, 0x72, - 0xf5, 0x4a, 0x6e, 0xb5, 0x92, 0xdb, 0x4f, 0x73, 0xff, 0xfe, 0xd5, 0x46, 0x08, 0x56, 0x4b, 0x9a, - 0x4f, 0x11, 0x82, 0xe3, 0x2c, 0x62, 0xba, 0x41, 0x5d, 0x35, 0x68, 0x5f, 0x6a, 0x70, 0x58, 0x49, - 0xed, 0x5f, 0x9f, 0x7d, 0xed, 0x18, 0xa7, 0xdf, 0x3a, 0x46, 0xb0, 0xc4, 0x33, 0xf7, 0xd0, 0x06, - 0x93, 0x31, 0x70, 0xab, 0xd1, 0x6d, 0xa8, 0x02, 0x6b, 0x07, 0x09, 0x64, 0x0c, 0x81, 0x06, 0x3a, - 0x7b, 0xa8, 0x59, 0x84, 0x85, 0x96, 0x53, 0xc8, 0x2b, 0x2d, 0xa7, 0x90, 0x9b, 0x77, 0xd0, 0xe6, - 0x11, 0x8e, 0x25, 0x70, 0xab, 0xde, 0x6d, 0xec, 0x6e, 0x05, 0x65, 0xe4, 0x7c, 0xa8, 0x23, 0x53, - 0xe9, 0xb2, 0x6a, 0xc6, 0x01, 0xba, 0x46, 0x8a, 0x5b, 0x60, 0xba, 0x88, 0x6f, 0x7d, 0x3e, 0xeb, - 0x55, 0xff, 0xb7, 0xfe, 0x78, 0xcc, 0x80, 0xf3, 0x57, 0x82, 0x45, 0x29, 0x09, 0x2a, 0xe0, 0x1f, - 0x0e, 0xa8, 0x8d, 0xaf, 0xc0, 0x81, 0xcb, 0x66, 0x34, 0xfe, 0xbf, 0x19, 0x4f, 0x56, 0xcc, 0x68, - 0xfe, 0xd3, 0x8c, 0xe6, 0x45, 0x23, 0x9c, 0x47, 0xe8, 0x86, 0xd2, 0xe8, 0xa5, 0x04, 0x09, 0xcf, - 0x04, 0x24, 0xa6, 0x83, 0x76, 0x12, 0x4e, 0x86, 0x22, 0xcf, 0x60, 0x28, 0x59, 0xcc, 0x2d, 0x43, - 0xa9, 0xba, 0x9d, 0x70, 0x72, 0x98, 0x67, 0xf0, 0x9a, 0xc5, 0xdc, 0x19, 0xa0, 0xdb, 0xfd, 0x38, - 0xa6, 0xef, 0x60, 0xac, 0xc8, 0x85, 0x31, 0xfc, 0x05, 0xe4, 0xdc, 0x74, 0x51, 0x73, 0x0a, 0xb9, - 0xe6, 0xfc, 0xdd, 0x56, 0x85, 0xf3, 0xfd, 0xd9, 0x0f, 0xbb, 0x36, 0x9b, 0xdb, 0xc6, 0xf9, 0xdc, - 0x36, 0xbe, 0xcf, 0x6d, 0xe3, 0x74, 0x61, 0xd7, 0xce, 0x17, 0x76, 0xed, 0xcb, 0xc2, 0xae, 0xbd, - 0xb9, 0x47, 0x22, 0x31, 0x91, 0xa1, 0x3b, 0xa2, 0x49, 0xf9, 0xb4, 0xbd, 0xa5, 0xc7, 0x70, 0xac, - 0xbf, 0x18, 0xe1, 0xa6, 0x5a, 0xf4, 0xe1, 0xaf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x44, 0xd3, 0x32, - 0x34, 0x56, 0x04, 0x00, 0x00, + // 634 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xcd, 0x6e, 0xd3, 0x4c, + 0x14, 0x8d, 0x9b, 0xb4, 0xdf, 0x97, 0xa9, 0x8a, 0xe8, 0x28, 0xad, 0x42, 0x25, 0x9c, 0xc8, 0x42, + 0xa8, 0x42, 0x8a, 0xdd, 0x16, 0x24, 0x10, 0x2b, 0x12, 0x21, 0x55, 0x80, 0x58, 0xe0, 0x16, 0x16, + 0x6c, 0xa2, 0x71, 0x72, 0x71, 0xad, 0x78, 0x3c, 0xd6, 0xcc, 0xb8, 0xc4, 0x7d, 0x04, 0x56, 0x7d, + 0x06, 0x9e, 0x80, 0x45, 0x1f, 0xa2, 0x62, 0x55, 0xb1, 0x62, 0xc5, 0x4f, 0xb3, 0xe0, 0x35, 0x90, + 0x67, 0xc6, 0x6d, 0xd3, 0x46, 0xd0, 0x05, 0x9b, 0xc8, 0x77, 0xce, 0x39, 0xf7, 0xef, 0x4c, 0x06, + 0xb5, 0x07, 0x4c, 0x50, 0x26, 0x3c, 0x92, 0xc9, 0xbd, 0x03, 0x6f, 0x7f, 0x33, 0x00, 0x49, 0x36, + 0x75, 0xe4, 0xa6, 0x9c, 0x49, 0x86, 0x1b, 0x9a, 0xe1, 0xea, 0x33, 0xc3, 0x58, 0x5b, 0x26, 0x34, + 0x4a, 0x98, 0xa7, 0x7e, 0x35, 0x71, 0xed, 0x96, 0x26, 0xf6, 0x55, 0xe4, 0x19, 0x95, 0x86, 0x5a, + 0x21, 0x63, 0x61, 0x0c, 0x9e, 0x8a, 0x82, 0xec, 0x9d, 0x27, 0x23, 0x0a, 0x42, 0x12, 0x9a, 0x1a, + 0x42, 0x23, 0x64, 0x21, 0xd3, 0xc2, 0xe2, 0xab, 0xcc, 0x78, 0x59, 0x46, 0x92, 0xdc, 0x40, 0xb6, + 0xe9, 0x3b, 0x20, 0x02, 0xce, 0xda, 0x1e, 0xb0, 0x28, 0xd1, 0xb8, 0x23, 0x51, 0x63, 0x1b, 0x12, + 0xe0, 0xd1, 0xa0, 0x9b, 0xc9, 0x3d, 0xc6, 0xa3, 0x03, 0x22, 0x23, 0x96, 0xe0, 0x9b, 0xa8, 0x4a, + 0x45, 0xd8, 0xb4, 0xda, 0xd6, 0x7a, 0xdd, 0x2f, 0x3e, 0x1f, 0x3f, 0xff, 0x7c, 0xd4, 0x71, 0x66, + 0xcd, 0xe8, 0x4e, 0x29, 0x3f, 0xfc, 0xfa, 0x74, 0xaf, 0xa5, 0x69, 0x1d, 0x31, 0x1c, 0x79, 0xb3, + 0xb2, 0x3b, 0x13, 0x0b, 0xcd, 0x6f, 0x73, 0x92, 0x48, 0x1c, 0xa0, 0x25, 0x72, 0x11, 0x52, 0x15, + 0x17, 0xb7, 0x1a, 0xae, 0x1e, 0xc9, 0x2d, 0x47, 0x72, 0xbb, 0x49, 0xde, 0xbb, 0x7b, 0xbd, 0x16, + 0xfc, 0xe9, 0x94, 0xf8, 0x29, 0x42, 0x30, 0x4e, 0x23, 0xae, 0x0b, 0xcc, 0xa9, 0x02, 0x6b, 0x57, + 0x0a, 0xec, 0x96, 0xab, 0xee, 0xfd, 0x7f, 0xfc, 0xad, 0x65, 0x1d, 0x7e, 0x6f, 0x59, 0xfe, 0x05, + 0x1d, 0xde, 0x40, 0xf3, 0x3c, 0x8b, 0x41, 0x34, 0xab, 0xed, 0xaa, 0x4a, 0x30, 0xb3, 0x11, 0x3f, + 0x8b, 0xc1, 0xd7, 0x44, 0x67, 0x03, 0xd5, 0x8a, 0xb0, 0xd8, 0xe5, 0x08, 0xf2, 0x72, 0x97, 0x23, + 0xc8, 0xf1, 0x2a, 0x5a, 0xd8, 0x27, 0x71, 0x06, 0xa2, 0x39, 0xd7, 0xae, 0xae, 0xd7, 0x7d, 0x13, + 0x39, 0x1f, 0xe7, 0x10, 0x56, 0x7b, 0x99, 0x36, 0x63, 0x0b, 0xfd, 0x17, 0x16, 0xa7, 0xc0, 0x75, + 0x92, 0x5e, 0xf3, 0xcb, 0x51, 0xa7, 0xbc, 0x6f, 0xdd, 0xe1, 0x90, 0x83, 0x10, 0x3b, 0x92, 0x47, + 0x49, 0xe8, 0x97, 0xc4, 0x73, 0x0d, 0xa8, 0x89, 0xaf, 0xa1, 0x81, 0xab, 0x66, 0x54, 0xff, 0xbd, + 0x19, 0x4f, 0xa6, 0xcc, 0xa8, 0xfd, 0xd5, 0x8c, 0xda, 0x65, 0x23, 0x9c, 0x07, 0xe8, 0x86, 0xda, + 0xd1, 0xab, 0x0c, 0x32, 0x78, 0x26, 0x81, 0x62, 0x07, 0x2d, 0x51, 0x11, 0xf6, 0x65, 0x9e, 0x42, + 0x3f, 0xe3, 0xb1, 0x68, 0x5a, 0x6a, 0xab, 0x8b, 0x54, 0x84, 0xbb, 0x79, 0x0a, 0xaf, 0x79, 0x2c, + 0x9c, 0x6d, 0xb4, 0xd2, 0x8d, 0x63, 0xf6, 0x1e, 0x86, 0x4a, 0x5c, 0x18, 0x23, 0x5e, 0x40, 0x2e, + 0xb0, 0x8b, 0x6a, 0x23, 0xc8, 0xb5, 0xe6, 0xcf, 0xb6, 0x2a, 0x9e, 0x73, 0x62, 0xa1, 0xa5, 0x6e, + 0x9a, 0x16, 0x43, 0x1e, 0xa8, 0x2c, 0xb8, 0x83, 0x30, 0xd1, 0xa9, 0xfb, 0x1c, 0x06, 0x51, 0x1a, + 0x41, 0x22, 0xcb, 0x1e, 0x96, 0x0d, 0xe2, 0x9f, 0x01, 0xf8, 0x36, 0x42, 0x94, 0x8c, 0xfb, 0x84, + 0xb2, 0x2c, 0x91, 0xe6, 0x02, 0xd4, 0x29, 0x19, 0x77, 0xd5, 0x01, 0x7e, 0x84, 0x9a, 0x65, 0x36, + 0x21, 0xc9, 0x08, 0xfa, 0xfb, 0x24, 0x8e, 0x86, 0x44, 0x32, 0xae, 0xaf, 0x5e, 0xdd, 0x5f, 0x35, + 0xf8, 0x4e, 0x01, 0xbf, 0x39, 0x43, 0xf1, 0xc3, 0x73, 0x65, 0x51, 0x40, 0xab, 0x4d, 0x99, 0x9a, + 0x52, 0xae, 0x18, 0xfc, 0x25, 0x19, 0x2b, 0xb1, 0x2e, 0xd9, 0xeb, 0x1d, 0xff, 0xb4, 0x2b, 0xc7, + 0xa7, 0xb6, 0x75, 0x72, 0x6a, 0x5b, 0x3f, 0x4e, 0x6d, 0xeb, 0x70, 0x62, 0x57, 0x4e, 0x26, 0x76, + 0xe5, 0xeb, 0xc4, 0xae, 0xbc, 0xbd, 0x13, 0x46, 0x72, 0x2f, 0x0b, 0xdc, 0x01, 0xa3, 0xe6, 0xb5, + 0xf2, 0x2e, 0xfc, 0xbf, 0xc7, 0xfa, 0x11, 0x0c, 0x16, 0x94, 0x77, 0xf7, 0x7f, 0x07, 0x00, 0x00, + 0xff, 0xff, 0x4a, 0x33, 0x08, 0xe0, 0x29, 0x05, 0x00, 0x00, } func (m *GenericAuthorization) Marshal() (dAtA []byte, err error) { @@ -579,6 +627,65 @@ func (m *AllowedGrantRulesKeys) MarshalToSizedBuffer(dAtA []byte) (int, error) { 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.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 @@ -700,6 +807,39 @@ func (m *AllowedGrantRulesKeys) Size() (n int) { 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)) + } + } + return n +} + func sovAuthz(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1410,6 +1550,184 @@ func (m *AllowedGrantRulesKeys) Unmarshal(dAtA []byte) error { } 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 + 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 27b8df71e97c..80da44d113a0 100644 --- a/x/authz/client/cli/tx.go +++ b/x/authz/client/cli/tx.go @@ -1,7 +1,6 @@ package cli import ( - "encoding/json" "errors" "fmt" "os" @@ -10,7 +9,6 @@ import ( "github.com/spf13/cobra" - bankv1beta1 "cosmossdk.io/api/cosmos/bank/v1beta1" "cosmossdk.io/core/address" "github.com/cosmos/cosmos-sdk/client" @@ -218,12 +216,7 @@ Examples: return err } - rules, err := buildRules(args[1], contents) - if err != nil { - return err - } - - msg.SetAuthzRules(rules) + msg.SetAuthzRules(contents) } return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) @@ -240,38 +233,6 @@ Examples: return cmd } -func buildRules(msg string, rulesBytes []byte) ([]*authz.Rule, error) { - type internalRules struct { - AllowedRecipients []string `json:"allowed_recepients"` - MaxAmount []string `json:"max_amount"` - AllowedStakeValidators []string `json:"allowed_stake_validators"` - AllowedMaxStakeAmount []string `json:"allowed_max_stake_amount"` - } - - var rulesJson internalRules - err := json.Unmarshal(rulesBytes, &rulesJson) - if err != nil { - return nil, err - } - - switch msg { - case sdk.MsgTypeURL(&bankv1beta1.MsgSend{}): - return []*authz.Rule{ - {Key: authz.AllowedRecipients, Values: rulesJson.AllowedRecipients}, - {Key: authz.MaxAmount, Values: rulesJson.MaxAmount}, - }, nil - - case sdk.MsgTypeURL(&staking.MsgDelegate{}): - return []*authz.Rule{ - {Key: authz.AllowedStakeValidators, Values: rulesJson.AllowedStakeValidators}, - {Key: authz.AllowedMaxStakeAmount, Values: rulesJson.AllowedMaxStakeAmount}, - }, nil - - default: - return []*authz.Rule{}, nil - } -} - func getExpireTime(cmd *cobra.Command) (*time.Time, error) { exp, err := cmd.Flags().GetInt64(FlagExpiration) if err != nil { diff --git a/x/authz/keeper/msg_server.go b/x/authz/keeper/msg_server.go index 030acb8e64e0..fdd919257b95 100644 --- a/x/authz/keeper/msg_server.go +++ b/x/authz/keeper/msg_server.go @@ -2,6 +2,7 @@ package keeper import ( "context" + "encoding/json" "errors" "fmt" "reflect" @@ -9,9 +10,11 @@ import ( errorsmod "cosmossdk.io/errors" + bankv1beta1 "cosmossdk.io/api/cosmos/bank/v1beta1" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/authz" + staking "github.com/cosmos/cosmos-sdk/x/staking/types" ) var _ authz.MsgServer = Keeper{} @@ -54,14 +57,16 @@ func (k Keeper) Grant(goCtx context.Context, msg *authz.MsgGrant) (*authz.MsgGra return nil, sdkerrors.ErrInvalidType.Wrapf("%s doesn't exist.", t) } + var rules []*authz.Rule if msg.Rules != nil { - err := k.VerifyTheRules(goCtx, msg.Grant.Authorization.GetTypeUrl(), msg.Rules) + var err error + err, rules = k.VerifyAndBuildRules(goCtx, msg.Grant.Authorization.GetTypeUrl(), msg.Rules) if err != nil { return nil, err } } - err = k.SaveGrant(ctx, grantee, granter, authorization, msg.Grant.Expiration, msg.Rules) + err = k.SaveGrant(ctx, grantee, granter, authorization, msg.Grant.Expiration, rules) if err != nil { return nil, err } @@ -70,10 +75,31 @@ func (k Keeper) Grant(goCtx context.Context, msg *authz.MsgGrant) (*authz.MsgGra } // VerifyTheRules checks the keys of rules provided are allowed -func (k Keeper) VerifyTheRules(goCtx context.Context, msg string, rules []*authz.Rule) error { +func (k Keeper) VerifyAndBuildRules(goCtx context.Context, msg string, rulesBytes []byte) (error, []*authz.Rule) { + var rulesJson authz.AppAuthzRules + err := json.Unmarshal(rulesBytes, &rulesJson) + if err != nil { + return err, nil + } + + var rules []*authz.Rule + switch msg { + case sdk.MsgTypeURL(&bankv1beta1.MsgSend{}): + rules = []*authz.Rule{ + {Key: authz.AllowedRecipients, Values: rulesJson.AllowedRecipients}, + {Key: authz.MaxAmount, Values: rulesJson.MaxAmount}, + } + + case sdk.MsgTypeURL(&staking.MsgDelegate{}): + rules = []*authz.Rule{ + {Key: authz.AllowedStakeValidators, Values: rulesJson.AllowedStakeValidators}, + {Key: authz.AllowedMaxStakeAmount, Values: rulesJson.AllowedMaxStakeAmount}, + } + } + registeredRules, err := k.GetAuthzRulesKeys(goCtx) if err != nil { - return err + return err, nil } var values []string @@ -85,10 +111,10 @@ func (k Keeper) VerifyTheRules(goCtx context.Context, msg string, rules []*authz } if err := checkStructKeys(rules, values); err != nil { - return err + return err, nil } - return nil + return nil, rules } func checkStructKeys(s interface{}, allowedKeys []string) error { diff --git a/x/authz/msgs.go b/x/authz/msgs.go index 9de397bb3855..bfdef2a7b6ea 100644 --- a/x/authz/msgs.go +++ b/x/authz/msgs.go @@ -33,7 +33,7 @@ func NewMsgGrant(granter, grantee sdk.AccAddress, a Authorization, expiration *t return m, nil } -func (msg *MsgGrant) SetAuthzRules(rules []*Rule) { +func (msg *MsgGrant) SetAuthzRules(rules []byte) { msg.Rules = rules } diff --git a/x/authz/tx.pb.go b/x/authz/tx.pb.go index 57e48244884a..ead6fd14538f 100644 --- a/x/authz/tx.pb.go +++ b/x/authz/tx.pb.go @@ -39,7 +39,7 @@ type MsgGrant struct { 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 []*Rule `protobuf:"bytes,4,rep,name=rules,proto3" json:"rules,omitempty"` + Rules []byte `protobuf:"bytes,4,opt,name=rules,proto3" json:"rules,omitempty"` } func (m *MsgGrant) Reset() { *m = MsgGrant{} } @@ -284,43 +284,43 @@ func init() { func init() { proto.RegisterFile("cosmos/authz/v1beta1/tx.proto", fileDescriptor_3ceddab7d8589ad1) } var fileDescriptor_3ceddab7d8589ad1 = []byte{ - // 572 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x54, 0x3f, 0x6f, 0xd3, 0x40, - 0x14, 0xcf, 0x35, 0x49, 0x43, 0xae, 0x95, 0xa0, 0x6e, 0x24, 0x5c, 0x57, 0x75, 0x2d, 0xd3, 0x42, - 0x14, 0x14, 0x9b, 0x84, 0x2d, 0x62, 0x69, 0xa4, 0x8a, 0x85, 0x08, 0xc9, 0xc0, 0xc2, 0x12, 0xd9, - 0xc9, 0x71, 0x8d, 0x6a, 0xfb, 0x22, 0x9f, 0x1d, 0x25, 0x4c, 0x88, 0x09, 0x31, 0xf1, 0x31, 0x60, - 0xcb, 0xd0, 0x91, 0x0f, 0x10, 0x31, 0x55, 0x4c, 0x4c, 0x08, 0x92, 0x21, 0x1f, 0x03, 0xe4, 0xfb, - 0x13, 0x52, 0x94, 0x96, 0x4e, 0x2c, 0xf6, 0x7b, 0xef, 0xf7, 0x7b, 0xe7, 0xf7, 0x7b, 0xef, 0xf9, - 0xe0, 0x5e, 0x87, 0xd0, 0x80, 0x50, 0xdb, 0x4d, 0xe2, 0x93, 0xd7, 0xf6, 0xa0, 0xe6, 0xa1, 0xd8, - 0xad, 0xd9, 0xf1, 0xd0, 0xea, 0x47, 0x24, 0x26, 0x4a, 0x89, 0xc3, 0x16, 0x83, 0x2d, 0x01, 0x6b, - 0x3b, 0x3c, 0xda, 0x66, 0x1c, 0x5b, 0x50, 0x98, 0xa3, 0x95, 0x30, 0xc1, 0x84, 0xc7, 0x53, 0x4b, - 0x44, 0x77, 0x30, 0x21, 0xd8, 0x47, 0x36, 0xf3, 0xbc, 0xe4, 0x95, 0xed, 0x86, 0x23, 0x01, 0x19, - 0x2b, 0x0b, 0xe0, 0xdf, 0xe3, 0x8c, 0xdb, 0x82, 0x11, 0x50, 0x6c, 0x0f, 0x6a, 0xe9, 0x4b, 0x00, - 0x5b, 0x6e, 0xd0, 0x0b, 0x89, 0xcd, 0x9e, 0x3c, 0x64, 0xbe, 0x5b, 0x83, 0x37, 0x5a, 0x14, 0x3f, - 0x8e, 0xdc, 0x30, 0x56, 0xea, 0xb0, 0x80, 0x53, 0x03, 0x45, 0x2a, 0x30, 0x40, 0xb9, 0xd8, 0x54, - 0xbf, 0x9e, 0x55, 0xa5, 0xa2, 0xa3, 0x6e, 0x37, 0x42, 0x94, 0x3e, 0x8b, 0xa3, 0x5e, 0x88, 0x1d, - 0x49, 0xfc, 0x93, 0x83, 0xd4, 0xb5, 0xeb, 0xe5, 0x20, 0xe5, 0x11, 0xcc, 0x33, 0x53, 0xcd, 0x1a, - 0xa0, 0xbc, 0x51, 0xdf, 0xb5, 0x56, 0x35, 0xcd, 0x62, 0x35, 0x35, 0x8b, 0x93, 0xef, 0xfb, 0x99, - 0x8f, 0xf3, 0x71, 0x05, 0x38, 0x3c, 0x49, 0x79, 0x00, 0xf3, 0x51, 0xe2, 0x23, 0xaa, 0xe6, 0x8c, - 0x6c, 0x79, 0xa3, 0xae, 0xad, 0xce, 0x76, 0x12, 0x1f, 0x39, 0x9c, 0xd8, 0x38, 0x78, 0x3b, 0x1f, - 0x57, 0x64, 0xc5, 0xef, 0xe7, 0xe3, 0xca, 0x36, 0x4f, 0xa9, 0xd2, 0xee, 0xa9, 0x2d, 0xd5, 0x9b, - 0x0a, 0xbc, 0x25, 0x6d, 0x07, 0xd1, 0x3e, 0x09, 0x29, 0x32, 0x3f, 0x01, 0x58, 0x68, 0x51, 0x7c, - 0x3c, 0x44, 0x9d, 0x65, 0xa5, 0xe0, 0xba, 0x4a, 0x8f, 0x61, 0x2e, 0xa0, 0x98, 0xaa, 0x6b, 0xac, - 0xd4, 0x92, 0xc5, 0xc7, 0x6a, 0xc9, 0xb1, 0x5a, 0x47, 0xe1, 0xa8, 0xb9, 0xfb, 0xe5, 0xac, 0x2a, - 0x46, 0x66, 0x79, 0x2e, 0x45, 0x0b, 0x09, 0x2d, 0x8a, 0x1d, 0x96, 0xde, 0xb8, 0xb3, 0x24, 0x00, - 0xa5, 0x02, 0x94, 0x8b, 0x02, 0xd2, 0xfa, 0xcc, 0xfb, 0xf0, 0xa6, 0x30, 0x65, 0xf9, 0x8a, 0x0a, - 0x0b, 0x11, 0xa2, 0x89, 0x1f, 0x53, 0x15, 0x18, 0xd9, 0xf2, 0xa6, 0x23, 0x5d, 0xf3, 0x33, 0x80, - 0xc5, 0xf4, 0x7c, 0x34, 0x20, 0xa7, 0xe8, 0xbf, 0x0d, 0xde, 0x80, 0x9b, 0x01, 0xc5, 0xed, 0x78, - 0xd4, 0x47, 0xed, 0x24, 0xf2, 0xd9, 0xfc, 0x8b, 0x0e, 0x0c, 0x28, 0x7e, 0x3e, 0xea, 0xa3, 0x17, - 0x91, 0xdf, 0x38, 0xfc, 0x7b, 0x54, 0xa5, 0x8b, 0x4a, 0x79, 0xc1, 0xe6, 0x36, 0xdc, 0x5a, 0x38, - 0x52, 0x6d, 0xfd, 0x17, 0x80, 0xd9, 0x16, 0xc5, 0xca, 0x53, 0x98, 0xe7, 0xfb, 0xac, 0xaf, 0x5e, - 0x0d, 0x39, 0x65, 0xed, 0xee, 0xd5, 0xf8, 0xa2, 0x8d, 0x4f, 0x60, 0x8e, 0x6d, 0xc0, 0xde, 0xa5, - 0xfc, 0x14, 0xd6, 0x0e, 0xaf, 0x84, 0x17, 0xa7, 0x39, 0x70, 0x5d, 0xb4, 0x7d, 0xff, 0xd2, 0x04, - 0x4e, 0xd0, 0xee, 0xfd, 0x83, 0x20, 0xcf, 0xd4, 0xf2, 0x6f, 0xd2, 0x3f, 0xa4, 0xd9, 0x9c, 0xfc, - 0xd4, 0x33, 0x93, 0xa9, 0x0e, 0xce, 0xa7, 0x3a, 0xf8, 0x31, 0xd5, 0xc1, 0x87, 0x99, 0x9e, 0x39, - 0x9f, 0xe9, 0x99, 0x6f, 0x33, 0x3d, 0xf3, 0xf2, 0x00, 0xf7, 0xe2, 0x93, 0xc4, 0xb3, 0x3a, 0x24, - 0x10, 0x77, 0x90, 0xbd, 0xd4, 0xdc, 0x21, 0xbf, 0x43, 0xbc, 0x75, 0xb6, 0x9c, 0x0f, 0x7f, 0x07, - 0x00, 0x00, 0xff, 0xff, 0xe7, 0x98, 0xd2, 0x96, 0xe9, 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. @@ -514,18 +514,11 @@ func (m *MsgGrant) MarshalToSizedBuffer(dAtA []byte) (int, error) { 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 = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } + 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]) @@ -747,11 +740,9 @@ func (m *MsgGrant) Size() (n int) { } l = m.Grant.Size() n += 1 + l + sovTx(uint64(l)) - if len(m.Rules) > 0 { - for _, e := range m.Rules { - l = e.Size() - n += 1 + l + sovTx(uint64(l)) - } + l = len(m.Rules) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) } return n } @@ -965,7 +956,7 @@ func (m *MsgGrant) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Rules", wireType) } - var msglen int + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -975,24 +966,24 @@ func (m *MsgGrant) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + if byteLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + msglen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthTx } 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 + m.Rules = append(m.Rules[:0], dAtA[iNdEx:postIndex]...) + if m.Rules == nil { + m.Rules = []byte{} } iNdEx = postIndex default: From b8aad2584b3163240051c0d8a0071cd8b604625d Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 29 May 2024 10:45:36 +0530 Subject: [PATCH 20/30] validations --- x/authz/keeper/msg_server.go | 78 +++++++++++++++++++++++++++--------- 1 file changed, 58 insertions(+), 20 deletions(-) diff --git a/x/authz/keeper/msg_server.go b/x/authz/keeper/msg_server.go index fdd919257b95..ff304efea20c 100644 --- a/x/authz/keeper/msg_server.go +++ b/x/authz/keeper/msg_server.go @@ -60,7 +60,7 @@ func (k Keeper) Grant(goCtx context.Context, msg *authz.MsgGrant) (*authz.MsgGra var rules []*authz.Rule if msg.Rules != nil { var err error - err, rules = k.VerifyAndBuildRules(goCtx, msg.Grant.Authorization.GetTypeUrl(), msg.Rules) + rules, err = k.VerifyAndBuildRules(goCtx, msg.Grant.Authorization.GetTypeUrl(), msg.Rules) if err != nil { return nil, err } @@ -75,31 +75,20 @@ func (k Keeper) Grant(goCtx context.Context, msg *authz.MsgGrant) (*authz.MsgGra } // VerifyTheRules checks the keys of rules provided are allowed -func (k Keeper) VerifyAndBuildRules(goCtx context.Context, msg string, rulesBytes []byte) (error, []*authz.Rule) { +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 err, nil + return nil, err } - var rules []*authz.Rule - switch msg { - case sdk.MsgTypeURL(&bankv1beta1.MsgSend{}): - rules = []*authz.Rule{ - {Key: authz.AllowedRecipients, Values: rulesJson.AllowedRecipients}, - {Key: authz.MaxAmount, Values: rulesJson.MaxAmount}, - } - - case sdk.MsgTypeURL(&staking.MsgDelegate{}): - rules = []*authz.Rule{ - {Key: authz.AllowedStakeValidators, Values: rulesJson.AllowedStakeValidators}, - {Key: authz.AllowedMaxStakeAmount, Values: rulesJson.AllowedMaxStakeAmount}, - } + if err := validateRules(rulesJson); err != nil { + return nil, err } registeredRules, err := k.GetAuthzRulesKeys(goCtx) if err != nil { - return err, nil + return nil, err } var values []string @@ -110,11 +99,26 @@ func (k Keeper) VerifyAndBuildRules(goCtx context.Context, msg string, rulesByte } } - if err := checkStructKeys(rules, values); err != nil { - return err, nil + if err := checkStructKeys(rulesJson, values); err != nil { + return nil, err } - return nil, rules + var rules []*authz.Rule + switch msg { + case sdk.MsgTypeURL(&bankv1beta1.MsgSend{}): + rules = []*authz.Rule{ + {Key: authz.AllowedRecipients, Values: rulesJson.AllowedRecipients}, + {Key: authz.MaxAmount, Values: rulesJson.MaxAmount}, + } + + case sdk.MsgTypeURL(&staking.MsgDelegate{}): + rules = []*authz.Rule{ + {Key: authz.AllowedStakeValidators, Values: rulesJson.AllowedStakeValidators}, + {Key: authz.AllowedMaxStakeAmount, Values: rulesJson.AllowedMaxStakeAmount}, + } + } + + return rules, nil } func checkStructKeys(s interface{}, allowedKeys []string) error { @@ -145,6 +149,40 @@ func isAllowedKey(key string, allowedKeys []string) bool { 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) { From 4c90b5579bd2918385a88e3939864af81bf78936 Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 29 May 2024 10:50:33 +0530 Subject: [PATCH 21/30] lint --- proto/cosmos/authz/v1beta1/authz.proto | 1 - 1 file changed, 1 deletion(-) mode change 100644 => 100755 proto/cosmos/authz/v1beta1/authz.proto diff --git a/proto/cosmos/authz/v1beta1/authz.proto b/proto/cosmos/authz/v1beta1/authz.proto old mode 100644 new mode 100755 index 9198778f1b45..65ad4e51c695 --- a/proto/cosmos/authz/v1beta1/authz.proto +++ b/proto/cosmos/authz/v1beta1/authz.proto @@ -7,7 +7,6 @@ import "cosmos_proto/cosmos.proto"; import "google/protobuf/timestamp.proto"; import "gogoproto/gogo.proto"; import "google/protobuf/any.proto"; -import "cosmos/base/v1beta1/coin.proto"; option go_package = "github.com/cosmos/cosmos-sdk/x/authz"; option (gogoproto.goproto_getters_all) = false; From b4571b873d593bc928deaecc90a882d68083f40c Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 29 May 2024 10:52:04 +0530 Subject: [PATCH 22/30] lint --- simapp/upgrades.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/simapp/upgrades.go b/simapp/upgrades.go index cdfa1075c9fc..720ee1eff266 100644 --- a/simapp/upgrades.go +++ b/simapp/upgrades.go @@ -35,10 +35,10 @@ func (app SimApp) RegisterUpgradeHandlers() { func(ctx context.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { app.AuthzKeeper.SetAuthzRulesKeys(ctx, &authz.AllowedGrantRulesKeys{ Keys: []*authz.Rule{ - &authz.Rule{Key: sdk.MsgTypeURL(&banktypes.MsgSend{}), Values: []string{ + {Key: sdk.MsgTypeURL(&banktypes.MsgSend{}), Values: []string{ authz.MaxAmount, authz.AllowedRecipients, }}, - &authz.Rule{Key: sdk.MsgTypeURL(&stakingtypes.MsgDelegate{}), Values: []string{ + {Key: sdk.MsgTypeURL(&stakingtypes.MsgDelegate{}), Values: []string{ authz.AllowedStakeValidators, authz.AllowedMaxStakeAmount, }}, }, From 2601990c7c0d74d3c0df293d733f5f0bf3bdffa6 Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 29 May 2024 10:54:40 +0530 Subject: [PATCH 23/30] lint --- simapp/upgrades.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/simapp/upgrades.go b/simapp/upgrades.go index 720ee1eff266..2e55db6c67af 100644 --- a/simapp/upgrades.go +++ b/simapp/upgrades.go @@ -35,12 +35,14 @@ func (app SimApp) RegisterUpgradeHandlers() { 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, - }}, + { + Key: sdk.MsgTypeURL(&banktypes.MsgSend{}), + Values: []string{authz.MaxAmount, authz.AllowedRecipients}, + }, + { + Key: sdk.MsgTypeURL(&stakingtypes.MsgDelegate{}), + Values: []string{authz.AllowedStakeValidators, authz.AllowedMaxStakeAmount}, + }, }, }) From 5c21c6095222cbd356435395ad2127e05b2d0581 Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 29 May 2024 16:09:11 +0530 Subject: [PATCH 24/30] lint --- x/auth/ante/authz_rules_ante.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/x/auth/ante/authz_rules_ante.go b/x/auth/ante/authz_rules_ante.go index 9d138ee2d5ce..d36f97177cb1 100644 --- a/x/auth/ante/authz_rules_ante.go +++ b/x/auth/ante/authz_rules_ante.go @@ -3,13 +3,14 @@ package ante import ( "strings" - stakingv1beta1 "cosmossdk.io/api/cosmos/staking/v1beta1" - errorsmod "cosmossdk.io/errors" 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" + + stakingv1beta1 "cosmossdk.io/api/cosmos/staking/v1beta1" + errorsmod "cosmossdk.io/errors" ) type AuthzDecorator struct { From 5fd01d47f5b54cb8daf6fc369515ee8949f35ea7 Mon Sep 17 00:00:00 2001 From: atheesh Date: Thu, 30 May 2024 11:02:43 +0530 Subject: [PATCH 25/30] fix bug --- api/cosmos/authz/v1beta1/authz.pulsar.go | 5 +- x/auth/ante/authz_rules_ante.go | 2 +- x/authz/authz.pb.go | 78 ++++++++++++------------ 3 files changed, 40 insertions(+), 45 deletions(-) diff --git a/api/cosmos/authz/v1beta1/authz.pulsar.go b/api/cosmos/authz/v1beta1/authz.pulsar.go index a48e0f5cccdd..ed4f5a5bcd7c 100644 --- a/api/cosmos/authz/v1beta1/authz.pulsar.go +++ b/api/cosmos/authz/v1beta1/authz.pulsar.go @@ -3,7 +3,6 @@ package authzv1beta1 import ( _ "cosmossdk.io/api/amino" - _ "cosmossdk.io/api/cosmos/base/v1beta1" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" @@ -4464,9 +4463,7 @@ var file_cosmos_authz_v1beta1_authz_proto_rawDesc = []byte{ 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x14, 0x67, 0x6f, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x67, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, - 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x63, 0x6f, - 0x69, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x74, 0x0a, 0x14, 0x47, 0x65, 0x6e, 0x65, + 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x74, 0x0a, 0x14, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x69, 0x63, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x3a, 0x4a, 0xca, 0xb4, 0x2d, 0x22, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, diff --git a/x/auth/ante/authz_rules_ante.go b/x/auth/ante/authz_rules_ante.go index d36f97177cb1..d8833f212f16 100644 --- a/x/auth/ante/authz_rules_ante.go +++ b/x/auth/ante/authz_rules_ante.go @@ -114,7 +114,7 @@ func (azd AuthzDecorator) handleStakeAuthzRules(ctx sdk.Context, msg *stakingv1b return err } - _, rules := azd.azk.GetAuthzWithRules(ctx, grantee, granter, sdk.MsgTypeURL(&banktypes.MsgSend{})) + _, rules := azd.azk.GetAuthzWithRules(ctx, grantee, granter, sdk.MsgTypeURL(&stakingv1beta1.MsgDelegate{})) for _, rule := range rules { if rule.Key == authztypes.AllowedStakeValidators { diff --git a/x/authz/authz.pb.go b/x/authz/authz.pb.go index 912440e06cd9..dc68ad13f40d 100644 --- a/x/authz/authz.pb.go +++ b/x/authz/authz.pb.go @@ -7,7 +7,6 @@ import ( fmt "fmt" _ "github.com/cosmos/cosmos-proto" types "github.com/cosmos/cosmos-sdk/codec/types" - _ "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/cosmos-sdk/types/tx/amino" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" @@ -328,47 +327,46 @@ func init() { func init() { proto.RegisterFile("cosmos/authz/v1beta1/authz.proto", fileDescriptor_544dc2e84b61c637) } var fileDescriptor_544dc2e84b61c637 = []byte{ - // 634 bytes of a gzipped FileDescriptorProto + // 623 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xcd, 0x6e, 0xd3, 0x4c, - 0x14, 0x8d, 0x9b, 0xb4, 0xdf, 0x97, 0xa9, 0x8a, 0xe8, 0x28, 0xad, 0x42, 0x25, 0x9c, 0xc8, 0x42, - 0xa8, 0x42, 0x8a, 0xdd, 0x16, 0x24, 0x10, 0x2b, 0x12, 0x21, 0x55, 0x80, 0x58, 0xe0, 0x16, 0x16, - 0x6c, 0xa2, 0x71, 0x72, 0x71, 0xad, 0x78, 0x3c, 0xd6, 0xcc, 0xb8, 0xc4, 0x7d, 0x04, 0x56, 0x7d, + 0x14, 0x8d, 0x9b, 0xb4, 0xdf, 0x97, 0xa9, 0x8a, 0xe8, 0x28, 0xad, 0x4c, 0x25, 0x9c, 0xc8, 0x42, + 0xa8, 0x42, 0x8a, 0xdd, 0x16, 0x24, 0x10, 0x2b, 0x1c, 0x21, 0x55, 0x80, 0x58, 0xe0, 0x16, 0x16, + 0x6c, 0xac, 0x49, 0x72, 0x71, 0xad, 0x78, 0x3c, 0xd6, 0xcc, 0xb8, 0xc4, 0x7d, 0x04, 0x56, 0x7d, 0x06, 0x9e, 0x80, 0x45, 0x1f, 0xa2, 0x62, 0x55, 0xb1, 0x62, 0xc5, 0x4f, 0xb3, 0xe0, 0x35, 0x90, - 0x67, 0xc6, 0x6d, 0xd3, 0x46, 0xd0, 0x05, 0x9b, 0xc8, 0x77, 0xce, 0x39, 0xf7, 0xef, 0x4c, 0x06, - 0xb5, 0x07, 0x4c, 0x50, 0x26, 0x3c, 0x92, 0xc9, 0xbd, 0x03, 0x6f, 0x7f, 0x33, 0x00, 0x49, 0x36, - 0x75, 0xe4, 0xa6, 0x9c, 0x49, 0x86, 0x1b, 0x9a, 0xe1, 0xea, 0x33, 0xc3, 0x58, 0x5b, 0x26, 0x34, - 0x4a, 0x98, 0xa7, 0x7e, 0x35, 0x71, 0xed, 0x96, 0x26, 0xf6, 0x55, 0xe4, 0x19, 0x95, 0x86, 0x5a, - 0x21, 0x63, 0x61, 0x0c, 0x9e, 0x8a, 0x82, 0xec, 0x9d, 0x27, 0x23, 0x0a, 0x42, 0x12, 0x9a, 0x1a, - 0x42, 0x23, 0x64, 0x21, 0xd3, 0xc2, 0xe2, 0xab, 0xcc, 0x78, 0x59, 0x46, 0x92, 0xdc, 0x40, 0xb6, - 0xe9, 0x3b, 0x20, 0x02, 0xce, 0xda, 0x1e, 0xb0, 0x28, 0xd1, 0xb8, 0x23, 0x51, 0x63, 0x1b, 0x12, - 0xe0, 0xd1, 0xa0, 0x9b, 0xc9, 0x3d, 0xc6, 0xa3, 0x03, 0x22, 0x23, 0x96, 0xe0, 0x9b, 0xa8, 0x4a, - 0x45, 0xd8, 0xb4, 0xda, 0xd6, 0x7a, 0xdd, 0x2f, 0x3e, 0x1f, 0x3f, 0xff, 0x7c, 0xd4, 0x71, 0x66, - 0xcd, 0xe8, 0x4e, 0x29, 0x3f, 0xfc, 0xfa, 0x74, 0xaf, 0xa5, 0x69, 0x1d, 0x31, 0x1c, 0x79, 0xb3, - 0xb2, 0x3b, 0x13, 0x0b, 0xcd, 0x6f, 0x73, 0x92, 0x48, 0x1c, 0xa0, 0x25, 0x72, 0x11, 0x52, 0x15, - 0x17, 0xb7, 0x1a, 0xae, 0x1e, 0xc9, 0x2d, 0x47, 0x72, 0xbb, 0x49, 0xde, 0xbb, 0x7b, 0xbd, 0x16, - 0xfc, 0xe9, 0x94, 0xf8, 0x29, 0x42, 0x30, 0x4e, 0x23, 0xae, 0x0b, 0xcc, 0xa9, 0x02, 0x6b, 0x57, - 0x0a, 0xec, 0x96, 0xab, 0xee, 0xfd, 0x7f, 0xfc, 0xad, 0x65, 0x1d, 0x7e, 0x6f, 0x59, 0xfe, 0x05, - 0x1d, 0xde, 0x40, 0xf3, 0x3c, 0x8b, 0x41, 0x34, 0xab, 0xed, 0xaa, 0x4a, 0x30, 0xb3, 0x11, 0x3f, - 0x8b, 0xc1, 0xd7, 0x44, 0x67, 0x03, 0xd5, 0x8a, 0xb0, 0xd8, 0xe5, 0x08, 0xf2, 0x72, 0x97, 0x23, - 0xc8, 0xf1, 0x2a, 0x5a, 0xd8, 0x27, 0x71, 0x06, 0xa2, 0x39, 0xd7, 0xae, 0xae, 0xd7, 0x7d, 0x13, - 0x39, 0x1f, 0xe7, 0x10, 0x56, 0x7b, 0x99, 0x36, 0x63, 0x0b, 0xfd, 0x17, 0x16, 0xa7, 0xc0, 0x75, - 0x92, 0x5e, 0xf3, 0xcb, 0x51, 0xa7, 0xbc, 0x6f, 0xdd, 0xe1, 0x90, 0x83, 0x10, 0x3b, 0x92, 0x47, - 0x49, 0xe8, 0x97, 0xc4, 0x73, 0x0d, 0xa8, 0x89, 0xaf, 0xa1, 0x81, 0xab, 0x66, 0x54, 0xff, 0xbd, - 0x19, 0x4f, 0xa6, 0xcc, 0xa8, 0xfd, 0xd5, 0x8c, 0xda, 0x65, 0x23, 0x9c, 0x07, 0xe8, 0x86, 0xda, - 0xd1, 0xab, 0x0c, 0x32, 0x78, 0x26, 0x81, 0x62, 0x07, 0x2d, 0x51, 0x11, 0xf6, 0x65, 0x9e, 0x42, - 0x3f, 0xe3, 0xb1, 0x68, 0x5a, 0x6a, 0xab, 0x8b, 0x54, 0x84, 0xbb, 0x79, 0x0a, 0xaf, 0x79, 0x2c, - 0x9c, 0x6d, 0xb4, 0xd2, 0x8d, 0x63, 0xf6, 0x1e, 0x86, 0x4a, 0x5c, 0x18, 0x23, 0x5e, 0x40, 0x2e, - 0xb0, 0x8b, 0x6a, 0x23, 0xc8, 0xb5, 0xe6, 0xcf, 0xb6, 0x2a, 0x9e, 0x73, 0x62, 0xa1, 0xa5, 0x6e, - 0x9a, 0x16, 0x43, 0x1e, 0xa8, 0x2c, 0xb8, 0x83, 0x30, 0xd1, 0xa9, 0xfb, 0x1c, 0x06, 0x51, 0x1a, - 0x41, 0x22, 0xcb, 0x1e, 0x96, 0x0d, 0xe2, 0x9f, 0x01, 0xf8, 0x36, 0x42, 0x94, 0x8c, 0xfb, 0x84, - 0xb2, 0x2c, 0x91, 0xe6, 0x02, 0xd4, 0x29, 0x19, 0x77, 0xd5, 0x01, 0x7e, 0x84, 0x9a, 0x65, 0x36, - 0x21, 0xc9, 0x08, 0xfa, 0xfb, 0x24, 0x8e, 0x86, 0x44, 0x32, 0xae, 0xaf, 0x5e, 0xdd, 0x5f, 0x35, - 0xf8, 0x4e, 0x01, 0xbf, 0x39, 0x43, 0xf1, 0xc3, 0x73, 0x65, 0x51, 0x40, 0xab, 0x4d, 0x99, 0x9a, - 0x52, 0xae, 0x18, 0xfc, 0x25, 0x19, 0x2b, 0xb1, 0x2e, 0xd9, 0xeb, 0x1d, 0xff, 0xb4, 0x2b, 0xc7, - 0xa7, 0xb6, 0x75, 0x72, 0x6a, 0x5b, 0x3f, 0x4e, 0x6d, 0xeb, 0x70, 0x62, 0x57, 0x4e, 0x26, 0x76, - 0xe5, 0xeb, 0xc4, 0xae, 0xbc, 0xbd, 0x13, 0x46, 0x72, 0x2f, 0x0b, 0xdc, 0x01, 0xa3, 0xe6, 0xb5, - 0xf2, 0x2e, 0xfc, 0xbf, 0xc7, 0xfa, 0x11, 0x0c, 0x16, 0x94, 0x77, 0xf7, 0x7f, 0x07, 0x00, 0x00, - 0xff, 0xff, 0x4a, 0x33, 0x08, 0xe0, 0x29, 0x05, 0x00, 0x00, + 0x67, 0xec, 0xb6, 0x69, 0x23, 0xe8, 0x82, 0x8d, 0x35, 0x77, 0xce, 0x39, 0xf7, 0xde, 0xb9, 0x67, + 0x3c, 0xa8, 0x33, 0x60, 0x82, 0x32, 0xe1, 0x92, 0x4c, 0xee, 0x1d, 0xb8, 0xfb, 0x9b, 0x7d, 0x90, + 0x64, 0x53, 0x47, 0x4e, 0xca, 0x99, 0x64, 0xb8, 0xa5, 0x19, 0x8e, 0xde, 0x2b, 0x19, 0x6b, 0xcb, + 0x84, 0x46, 0x09, 0x73, 0xd5, 0x57, 0x13, 0xd7, 0x6e, 0x69, 0x62, 0xa0, 0x22, 0xb7, 0x54, 0x69, + 0xa8, 0x1d, 0x32, 0x16, 0xc6, 0xe0, 0xaa, 0xa8, 0x9f, 0xbd, 0x73, 0x65, 0x44, 0x41, 0x48, 0x42, + 0xd3, 0x92, 0xd0, 0x0a, 0x59, 0xc8, 0xb4, 0xb0, 0x58, 0x55, 0x19, 0x2f, 0xcb, 0x48, 0x92, 0x6b, + 0xc8, 0x96, 0xa8, 0xb5, 0x0d, 0x09, 0xf0, 0x68, 0xe0, 0x65, 0x72, 0x8f, 0xf1, 0xe8, 0x80, 0xc8, + 0x88, 0x25, 0xf8, 0x26, 0xaa, 0x53, 0x11, 0x9a, 0x46, 0xc7, 0x58, 0x6f, 0xfa, 0xc5, 0xf2, 0xf1, + 0xf3, 0xcf, 0x47, 0x5d, 0x7b, 0xd6, 0x19, 0x9c, 0x29, 0xe5, 0x87, 0x5f, 0x9f, 0xee, 0xb5, 0x35, + 0xad, 0x2b, 0x86, 0x23, 0x77, 0x56, 0x76, 0x7b, 0x62, 0xa0, 0xf9, 0x6d, 0x4e, 0x12, 0x89, 0xfb, + 0x68, 0x89, 0x5c, 0x84, 0x54, 0xc5, 0xc5, 0xad, 0x96, 0xa3, 0x5b, 0x76, 0xaa, 0x96, 0x1d, 0x2f, + 0xc9, 0x7b, 0x77, 0xaf, 0xd7, 0x82, 0x3f, 0x9d, 0x12, 0x3f, 0x45, 0x08, 0xc6, 0x69, 0xc4, 0x75, + 0x81, 0x39, 0x55, 0x60, 0xed, 0x4a, 0x81, 0xdd, 0x6a, 0x94, 0xbd, 0xff, 0x8f, 0xbf, 0xb5, 0x8d, + 0xc3, 0xef, 0x6d, 0xc3, 0xbf, 0xa0, 0xc3, 0x1b, 0x68, 0x9e, 0x67, 0x31, 0x08, 0xb3, 0xde, 0xa9, + 0xab, 0x04, 0x33, 0x1b, 0xf1, 0xb3, 0x18, 0x7c, 0x4d, 0xb4, 0x37, 0x50, 0xa3, 0x08, 0x8b, 0x59, + 0x8e, 0x20, 0xaf, 0x66, 0x39, 0x82, 0x1c, 0xaf, 0xa2, 0x85, 0x7d, 0x12, 0x67, 0x20, 0xcc, 0xb9, + 0x4e, 0x7d, 0xbd, 0xe9, 0x97, 0x91, 0xfd, 0x71, 0x0e, 0x61, 0x35, 0x97, 0x69, 0x33, 0xb6, 0xd0, + 0x7f, 0x61, 0xb1, 0x0b, 0x5c, 0x27, 0xe9, 0x99, 0x5f, 0x8e, 0xba, 0xd5, 0x7d, 0xf2, 0x86, 0x43, + 0x0e, 0x42, 0xec, 0x48, 0x1e, 0x25, 0xa1, 0x5f, 0x11, 0xcf, 0x35, 0xa0, 0x4e, 0x7c, 0x0d, 0x0d, + 0x5c, 0x35, 0xa3, 0xfe, 0xef, 0xcd, 0x78, 0x32, 0x65, 0x46, 0xe3, 0xaf, 0x66, 0x34, 0x2e, 0x1b, + 0x61, 0x3f, 0x40, 0x37, 0xd4, 0x8c, 0x5e, 0x65, 0x90, 0xc1, 0x33, 0x09, 0x14, 0xdb, 0x68, 0x89, + 0x8a, 0x30, 0x90, 0x79, 0x0a, 0x41, 0xc6, 0x63, 0x61, 0x1a, 0x6a, 0xaa, 0x8b, 0x54, 0x84, 0xbb, + 0x79, 0x0a, 0xaf, 0x79, 0x2c, 0xec, 0x6d, 0xb4, 0xe2, 0xc5, 0x31, 0x7b, 0x0f, 0x43, 0x25, 0x2e, + 0x8c, 0x11, 0x2f, 0x20, 0x17, 0xd8, 0x41, 0x8d, 0x11, 0xe4, 0x5a, 0xf3, 0x67, 0x5b, 0x15, 0xcf, + 0x3e, 0x31, 0xd0, 0x92, 0x97, 0xa6, 0xc5, 0x21, 0x0f, 0x54, 0x16, 0xdc, 0x45, 0x98, 0xe8, 0xd4, + 0x01, 0x87, 0x41, 0x94, 0x46, 0x90, 0xc8, 0xaa, 0x87, 0xe5, 0x12, 0xf1, 0xcf, 0x00, 0x7c, 0x1b, + 0x21, 0x4a, 0xc6, 0x01, 0xa1, 0x2c, 0x4b, 0x64, 0x79, 0x01, 0x9a, 0x94, 0x8c, 0x3d, 0xb5, 0x81, + 0x1f, 0x21, 0xb3, 0xca, 0x26, 0x24, 0x19, 0x41, 0xb0, 0x4f, 0xe2, 0x68, 0x48, 0x24, 0xe3, 0xfa, + 0xea, 0x35, 0xfd, 0xd5, 0x12, 0xdf, 0x29, 0xe0, 0x37, 0x67, 0x28, 0x7e, 0x78, 0xae, 0x2c, 0x0a, + 0x68, 0x75, 0x59, 0xa6, 0xa1, 0x94, 0x2b, 0x25, 0xfe, 0x92, 0x8c, 0x95, 0x58, 0x97, 0xec, 0xf5, + 0x8e, 0x7f, 0x5a, 0xb5, 0xe3, 0x53, 0xcb, 0x38, 0x39, 0xb5, 0x8c, 0x1f, 0xa7, 0x96, 0x71, 0x38, + 0xb1, 0x6a, 0x27, 0x13, 0xab, 0xf6, 0x75, 0x62, 0xd5, 0xde, 0xde, 0x09, 0x23, 0xb9, 0x97, 0xf5, + 0x9d, 0x01, 0xa3, 0xe5, 0x6b, 0xe4, 0x5e, 0xf8, 0xbf, 0xc7, 0xfa, 0x91, 0xeb, 0x2f, 0x28, 0xef, + 0xee, 0xff, 0x0e, 0x00, 0x00, 0xff, 0xff, 0x75, 0x91, 0xe4, 0x3a, 0x09, 0x05, 0x00, 0x00, } func (m *GenericAuthorization) Marshal() (dAtA []byte, err error) { From 4e27d6acda9190d813b7378b47a21c53f6781a5e Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 17 Jul 2024 14:42:22 +0530 Subject: [PATCH 26/30] authz spec --- x/auth/ante/authz_rules_spec.md | 65 +++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 x/auth/ante/authz_rules_spec.md diff --git a/x/auth/ante/authz_rules_spec.md b/x/auth/ante/authz_rules_spec.md new file mode 100644 index 000000000000..83c7b05c09ea --- /dev/null +++ b/x/auth/ante/authz_rules_spec.md @@ -0,0 +1,65 @@ +# Description + +Problem: +The existing authorization (authz) module lacks the flexibility to grant permissions (authz grants) for various types of messages along with specific conditions or rules. This limitation constrains users from customizing their transaction behavior based on specific needs or strategies. + +## Specific Examples of Limitations: +Swapping Reward Tokens: + - Currently, users cannot set a rule to swap their reward tokens or any other tokens for another token with a specified limit. +Sending Tokens to Selected Addresses: + - Users are unable to authorize sending tokens to a pre-defined or selected address, restricting the ability to control where tokens are transferred. +Staking Tokens with Limitations: + - The module does not allow users to grant permission to stake tokens with certain limits or to stake only with selected validators. This limits the user's control over staking decisions. + +## PR diff: +This PR adds a feature which an authz can be granted with some rules, +for example: + - if a staker wants to stake some portion of rewards he can do that by allowing max stake amount + - if he wants to stake only to selected validators + - swap some portion of rewards to another token or liquid staked token + - also we can add rules to every message before granting. + +Changes: +updated the ante handlers flow to check in the message is executing the authz message and any rules need to be checked before processing the message. if the message is not reaching the rules then it will eventually fail. + +added an extra ante handler: +``` +// handleCheckSendAuthzRules returns true if the rules are voilated +func (azd AuthzDecorator) handleSendAuthzRules(ctx sdk.Context, msg *banktypes.MsgSend, grantee []byte) error { + granter, err := azd.ak.AddressCodec().StringToBytes(msg.FromAddress) + if err != nil { + return err + } + + _, rules := azd.azk.GetAuthzWithRules(ctx, grantee, granter, sdk.MsgTypeURL(&banktypes.MsgSend{})) + for _, rule := range rules { + if rule.Key == authztypes.AllowedRecipients { + isAllowed := false + for _, allowedRecipient := range rule.Values { + if msg.ToAddress == allowedRecipient { + isAllowed = true + break + } + } + + if !isAllowed { + return errorsmod.Wrap(sdkerrors.ErrTxDecode, "Recipient is not in the allowed list of the grant") + } + } + + 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 +} +``` +the above snippet checks the rules for `MsgSend` likewise we can add checks to every messages. \ No newline at end of file From 4422fdaaef01ff8fe9b49d348d77604c923788f4 Mon Sep 17 00:00:00 2001 From: atheesh Date: Fri, 19 Jul 2024 10:58:28 +0530 Subject: [PATCH 27/30] add spec --- x/auth/ante/authz_rules_spec.md | 224 +++++++++++++++++++++++++------- 1 file changed, 179 insertions(+), 45 deletions(-) diff --git a/x/auth/ante/authz_rules_spec.md b/x/auth/ante/authz_rules_spec.md index 83c7b05c09ea..b14809284211 100644 --- a/x/auth/ante/authz_rules_spec.md +++ b/x/auth/ante/authz_rules_spec.md @@ -1,51 +1,182 @@ -# Description - -Problem: -The existing authorization (authz) module lacks the flexibility to grant permissions (authz grants) for various types of messages along with specific conditions or rules. This limitation constrains users from customizing their transaction behavior based on specific needs or strategies. - -## Specific Examples of Limitations: -Swapping Reward Tokens: - - Currently, users cannot set a rule to swap their reward tokens or any other tokens for another token with a specified limit. -Sending Tokens to Selected Addresses: - - Users are unable to authorize sending tokens to a pre-defined or selected address, restricting the ability to control where tokens are transferred. -Staking Tokens with Limitations: - - The module does not allow users to grant permission to stake tokens with certain limits or to stake only with selected validators. This limits the user's control over staking decisions. - -## PR diff: -This PR adds a feature which an authz can be granted with some rules, -for example: - - if a staker wants to stake some portion of rewards he can do that by allowing max stake amount - - if he wants to stake only to selected validators - - swap some portion of rewards to another token or liquid staked token - - also we can add rules to every message before granting. - -Changes: -updated the ante handlers flow to check in the message is executing the authz message and any rules need to be checked before processing the message. if the message is not reaching the rules then it will eventually fail. - -added an extra ante handler: -``` +# 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) handleSendAuthzRules(ctx sdk.Context, msg *banktypes.MsgSend, grantee []byte) error { - granter, err := azd.ak.AddressCodec().StringToBytes(msg.FromAddress) - if err != nil { - return err - } +func (azd AuthzDecorator) handleVote(ctx sdk.Context, msg *govtypes.MsgVote, grantee []byte) error { - _, rules := azd.azk.GetAuthzWithRules(ctx, grantee, granter, sdk.MsgTypeURL(&banktypes.MsgSend{})) - for _, rule := range rules { - if rule.Key == authztypes.AllowedRecipients { - isAllowed := false - for _, allowedRecipient := range rule.Values { - if msg.ToAddress == allowedRecipient { - isAllowed = true - break - } - } + _, 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 + } - if !isAllowed { - return errorsmod.Wrap(sdkerrors.ErrTxDecode, "Recipient is not in the allowed list of the grant") + 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, ",")) @@ -61,5 +192,8 @@ func (azd AuthzDecorator) handleSendAuthzRules(ctx sdk.Context, msg *banktypes.M return nil } -``` -the above snippet checks the rules for `MsgSend` likewise we can add checks to every messages. \ No newline at end of file +``` + +# 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 From 0fc59afb5ce88a84e0889d039cd41240cfbced21 Mon Sep 17 00:00:00 2001 From: atheesh Date: Wed, 24 Jul 2024 15:41:25 +0530 Subject: [PATCH 28/30] add proposal based vote authz --- x/auth/ante/authz_rules_ante.go | 193 ++++++++++++++++++++++---------- x/auth/ante/expected_keepers.go | 5 + x/authz/consts.go | 3 +- x/gov/keeper/grpc_query.go | 12 ++ 4 files changed, 150 insertions(+), 63 deletions(-) diff --git a/x/auth/ante/authz_rules_ante.go b/x/auth/ante/authz_rules_ante.go index d8833f212f16..5ae43e4811bc 100644 --- a/x/auth/ante/authz_rules_ante.go +++ b/x/auth/ante/authz_rules_ante.go @@ -9,13 +9,15 @@ import ( authztypes "github.com/cosmos/cosmos-sdk/x/authz" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + govv1beta1 "cosmossdk.io/api/cosmos/gov/v1beta1" stakingv1beta1 "cosmossdk.io/api/cosmos/staking/v1beta1" errorsmod "cosmossdk.io/errors" ) type AuthzDecorator struct { - azk AuthzKeeper - ak AccountKeeper + azk AuthzKeeper + ak AccountKeeper + govKeeper GovKeeper } func NewAuthzDecorator(azk AuthzKeeper, ak AccountKeeper) AuthzDecorator { @@ -25,127 +27,194 @@ func NewAuthzDecorator(azk AuthzKeeper, ak AccountKeeper) AuthzDecorator { } } -// AuthzDecorator checks the authorization message grants for some rules. +// 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 - if authzMsg, ok := msg.(*authztypes.MsgExec); ok { + authzMsg, ok := msg.(*authztypes.MsgExec) + if !ok { + continue + } - authzMsgs, err := authzMsg.GetMessages() - if err != nil { - return ctx, err - } + // Get the inner messages of the authorization message + 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 *stakingv1beta1.MsgDelegate: - err := azd.handleStakeAuthzRules(ctx, innerMsgConverted, grantee) - if err != nil { - return ctx, err - } + // Handle each inner message based on its type + for _, innerMsg := range authzMsgs { + switch innerMsg := innerMsg.(type) { + case *banktypes.MsgSend: + if err := azd.handleSendAuthzRules(ctx, innerMsg, grantee); err != nil { + return ctx, err + } + case *stakingv1beta1.MsgDelegate: + if err := azd.handleStakeAuthzRules(ctx, innerMsg, grantee); err != nil { + return ctx, err + } + case *govv1beta1.MsgVote: + if err := azd.handleProposalAuthzRules(ctx, innerMsg, grantee); err != nil { + return ctx, err } } } } - // Continue with the transaction if all checks pass + // Continue with the next AnteHandler if all checks pass return next(ctx, tx, simulate) } -// handleCheckSendAuthzRules returns true if the rules are voilated +// 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{})) - for _, rule := range rules { - if rule.Key == authztypes.AllowedRecipients { - isAllowed := false - for _, allowedRecipient := range rule.Values { - if msg.ToAddress == allowedRecipient { - isAllowed = true - break - } - } - if !isAllowed { - return errorsmod.Wrap(sdkerrors.ErrTxDecode, "Recipient is not in the allowed list of the grant") - } - } + // Initialize maps for quick lookup + allowedRecipients := make(map[string]struct{}) + var maxAmount sdk.Coins - if rule.Key == authztypes.MaxAmount { - limit, err := sdk.ParseCoinsNormalized(strings.Join(rule.Values, ",")) + // 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 } - if !limit.IsAllGTE(msg.Amount) { - return errorsmod.Wrap(sdkerrors.ErrTxDecode, "Amount exceeds the max_amount limit set by the granter") - } } + } + // 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{})) - for _, rule := range rules { - if rule.Key == authztypes.AllowedStakeValidators { - isAllowed := false - for _, allowedValidator := range rule.Values { - if msg.ValidatorAddress == allowedValidator { - isAllowed = true - break - } - } - - if !isAllowed { - return errorsmod.Wrap(sdkerrors.ErrTxDecode, "Validator is not in the allowed validators of the grant") - } - } + // Initialize maps for quick lookup + allowedValidators := make(map[string]struct{}) + var maxStakeAmount sdk.Coins - if rule.Key == authztypes.AllowedMaxStakeAmount { - limit, err := sdk.ParseCoinsNormalized(strings.Join(rule.Values, ",")) - if err != nil { - return err + // Populate maps with rule values + for _, rule := range rules { + switch rule.Key { + case authztypes.AllowedStakeValidators: + for _, validator := range rule.Values { + allowedValidators[validator] = struct{}{} } - amount, err := sdk.ParseCoinNormalized(msg.Amount.String()) + case authztypes.AllowedMaxStakeAmount: + maxStakeAmount, err = sdk.ParseCoinsNormalized(strings.Join(rule.Values, ",")) if err != nil { return err } + } + } - if !limit.IsAllGTE(sdk.NewCoins(amount)) { - return errorsmod.Wrap(sdkerrors.ErrTxDecode, "Amount exceeds the max_amount limit set by the granter") - } + // 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 *govv1beta1.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(&govv1beta1.MsgVote{})) + + // 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.TypeUrl]; !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/expected_keepers.go b/x/auth/ante/expected_keepers.go index 5c80b9ffc1d1..4f7f3d8c0667 100644 --- a/x/auth/ante/expected_keepers.go +++ b/x/auth/ante/expected_keepers.go @@ -8,6 +8,7 @@ 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. @@ -28,3 +29,7 @@ type FeegrantKeeper interface { 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/consts.go b/x/authz/consts.go index 06b58f3bc015..38f41f232c85 100644 --- a/x/authz/consts.go +++ b/x/authz/consts.go @@ -4,5 +4,6 @@ const ( AllowedRecipients = "allowed_recipients" MaxAmount = "max_amount" AllowedStakeValidators = "allowed_stake_validators" - AllowedMaxStakeAmount = "allowed_Max_stake_amount" + AllowedMaxStakeAmount = "allowed_max_stake_amount" + AllowedProposalTypes = "allowed_proposal_types" ) diff --git a/x/gov/keeper/grpc_query.go b/x/gov/keeper/grpc_query.go index b42a114cfb14..faa40ef0afa2 100644 --- a/x/gov/keeper/grpc_query.go +++ b/x/gov/keeper/grpc_query.go @@ -54,6 +54,18 @@ func (q queryServer) Proposal(ctx context.Context, req *v1.QueryProposalRequest) return &v1.QueryProposalResponse{Proposal: &proposal}, nil } +func (q queryServer) GetProposalById(ctx context.Context, proposalId uint64) (*v1.Proposal, error) { + proposal, err := q.k.Proposals.Get(ctx, proposalId) + if err != nil { + if errors.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 +} + // Proposals implements the Query/Proposals gRPC method func (q queryServer) Proposals(ctx context.Context, req *v1.QueryProposalsRequest) (*v1.QueryProposalsResponse, error) { filteredProposals, pageRes, err := query.CollectionFilteredPaginate(ctx, q.k.Proposals, req.Pagination, func(key uint64, p v1.Proposal) (include bool, err error) { From 7a4da4c6343270e39deae957956207067f0ad8aa Mon Sep 17 00:00:00 2001 From: atheesh Date: Fri, 26 Jul 2024 15:59:11 +0530 Subject: [PATCH 29/30] feat: add the proposal based voting --- api/cosmos/authz/v1beta1/authz.pulsar.go | 167 ++++++++++++++++++++--- proto/cosmos/authz/v1beta1/authz.proto | 1 + simapp/ante.go | 2 +- x/auth/ante/ante.go | 2 + x/auth/ante/authz_rules_ante.go | 34 +++-- x/authz/authz.pb.go | 130 ++++++++++++------ x/authz/keeper/keeper.go | 38 ++++-- x/authz/keeper/msg_server.go | 33 +++-- x/gov/keeper/grpc_query.go | 12 -- x/gov/keeper/proposal.go | 14 ++ 10 files changed, 328 insertions(+), 105 deletions(-) diff --git a/api/cosmos/authz/v1beta1/authz.pulsar.go b/api/cosmos/authz/v1beta1/authz.pulsar.go index ed4f5a5bcd7c..60729519614d 100644 --- a/api/cosmos/authz/v1beta1/authz.pulsar.go +++ b/api/cosmos/authz/v1beta1/authz.pulsar.go @@ -3433,12 +3433,59 @@ 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 *_AppAuthzRules_5_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_AppAuthzRules_5_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfString((*x.list)[i]) +} + +func (x *_AppAuthzRules_5_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.String() + concreteValue := valueUnwrapped + (*x.list)[i] = concreteValue +} + +func (x *_AppAuthzRules_5_list) Append(value protoreflect.Value) { + valueUnwrapped := value.String() + concreteValue := valueUnwrapped + *x.list = append(*x.list, concreteValue) +} + +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 *_AppAuthzRules_5_list) Truncate(n int) { + *x.list = (*x.list)[:n] +} + +func (x *_AppAuthzRules_5_list) NewElement() protoreflect.Value { + v := "" + return protoreflect.ValueOfString(v) +} + +func (x *_AppAuthzRules_5_list) IsValid() bool { + return x.list != nil +} + var ( 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() { @@ -3448,6 +3495,7 @@ func init() { 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_AppAuthzRules)(nil) @@ -3539,6 +3587,12 @@ func (x *fastReflection_AppAuthzRules) Range(f func(protoreflect.FieldDescriptor return } } + if len(x.AllowedProposalTypes) != 0 { + value := protoreflect.ValueOfList(&_AppAuthzRules_5_list{list: &x.AllowedProposalTypes}) + if !f(fd_AppAuthzRules_allowed_proposal_types, value) { + return + } + } } // Has reports whether a field is populated. @@ -3562,6 +3616,8 @@ func (x *fastReflection_AppAuthzRules) Has(fd protoreflect.FieldDescriptor) bool 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.AppAuthzRules")) @@ -3586,6 +3642,8 @@ func (x *fastReflection_AppAuthzRules) Clear(fd protoreflect.FieldDescriptor) { 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.AppAuthzRules")) @@ -3626,6 +3684,12 @@ func (x *fastReflection_AppAuthzRules) Get(descriptor protoreflect.FieldDescript } 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.AppAuthzRules")) @@ -3662,6 +3726,10 @@ func (x *fastReflection_AppAuthzRules) Set(fd protoreflect.FieldDescriptor, valu 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.AppAuthzRules")) @@ -3706,6 +3774,12 @@ func (x *fastReflection_AppAuthzRules) Mutable(fd protoreflect.FieldDescriptor) } 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.AppAuthzRules")) @@ -3731,6 +3805,9 @@ func (x *fastReflection_AppAuthzRules) NewField(fd protoreflect.FieldDescriptor) 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.AppAuthzRules")) @@ -3824,6 +3901,12 @@ func (x *fastReflection_AppAuthzRules) ProtoMethods() *protoiface.Methods { 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)) + } + } if x.unknownFields != nil { n += len(x.unknownFields) } @@ -3853,6 +3936,15 @@ func (x *fastReflection_AppAuthzRules) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } + 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]) @@ -4066,6 +4158,38 @@ func (x *fastReflection_AppAuthzRules) ProtoMethods() *protoiface.Methods { } 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 skippy, err := runtime.Skip(dAtA[iNdEx:]) @@ -4399,6 +4523,7 @@ type AppAuthzRules struct { 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() { @@ -4449,6 +4574,13 @@ func (x *AppAuthzRules) GetAllowedMaxStakeAmount() []string { 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{ @@ -4514,7 +4646,7 @@ var file_cosmos_authz_v1beta1_authz_proto_rawDesc = []byte{ 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, 0xd0, 0x01, 0x0a, 0x0d, 0x41, + 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, @@ -4527,21 +4659,24 @@ var file_cosmos_authz_v1beta1_authz_proto_rawDesc = []byte{ 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, 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, + 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 ( diff --git a/proto/cosmos/authz/v1beta1/authz.proto b/proto/cosmos/authz/v1beta1/authz.proto index 65ad4e51c695..22eb7bfa4067 100755 --- a/proto/cosmos/authz/v1beta1/authz.proto +++ b/proto/cosmos/authz/v1beta1/authz.proto @@ -67,4 +67,5 @@ message AppAuthzRules { 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/simapp/ante.go b/simapp/ante.go index 11676d622c2c..58d90eb0e4d1 100644 --- a/simapp/ante.go +++ b/simapp/ante.go @@ -40,7 +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), + 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/x/auth/ante/ante.go b/x/auth/ante/ante.go index 6d1c1912ec7a..e1fe15bcb269 100644 --- a/x/auth/ante/ante.go +++ b/x/auth/ante/ante.go @@ -21,6 +21,7 @@ type HandlerOptions struct { 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 @@ -47,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 index 5ae43e4811bc..6f5a89ae410d 100644 --- a/x/auth/ante/authz_rules_ante.go +++ b/x/auth/ante/authz_rules_ante.go @@ -1,6 +1,7 @@ package ante import ( + "fmt" "strings" sdk "github.com/cosmos/cosmos-sdk/types" @@ -8,9 +9,9 @@ import ( 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" - govv1beta1 "cosmossdk.io/api/cosmos/gov/v1beta1" - stakingv1beta1 "cosmossdk.io/api/cosmos/staking/v1beta1" errorsmod "cosmossdk.io/errors" ) @@ -20,10 +21,11 @@ type AuthzDecorator struct { govKeeper GovKeeper } -func NewAuthzDecorator(azk AuthzKeeper, ak AccountKeeper) AuthzDecorator { +func NewAuthzDecorator(azk AuthzKeeper, ak AccountKeeper, govKeeper GovKeeper) AuthzDecorator { return AuthzDecorator{ - azk: azk, - ak: ak, + azk: azk, + ak: ak, + govKeeper: govKeeper, } } @@ -61,19 +63,22 @@ func (azd AuthzDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, // Handle each inner message based on its type for _, innerMsg := range authzMsgs { - switch innerMsg := innerMsg.(type) { + switch innerMsg1 := innerMsg.(type) { case *banktypes.MsgSend: - if err := azd.handleSendAuthzRules(ctx, innerMsg, grantee); err != nil { + if err := azd.handleSendAuthzRules(ctx, innerMsg1, grantee); err != nil { return ctx, err } case *stakingv1beta1.MsgDelegate: - if err := azd.handleStakeAuthzRules(ctx, innerMsg, grantee); err != nil { + if err := azd.handleStakeAuthzRules(ctx, innerMsg1, grantee); err != nil { return ctx, err } - case *govv1beta1.MsgVote: - if err := azd.handleProposalAuthzRules(ctx, innerMsg, grantee); err != nil { + 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) } } } @@ -181,7 +186,7 @@ func (azd AuthzDecorator) handleStakeAuthzRules(ctx sdk.Context, msg *stakingv1b } // handleProposalAuthzRules checks if a MsgVote transaction is authorized based on the rules set by the granter. -func (azd AuthzDecorator) handleProposalAuthzRules(ctx sdk.Context, msg *govv1beta1.MsgVote, grantee []byte) error { +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 { @@ -195,7 +200,10 @@ func (azd AuthzDecorator) handleProposalAuthzRules(ctx sdk.Context, msg *govv1be } // Retrieve authorization rules - _, rules := azd.azk.GetAuthzWithRules(ctx, grantee, granter, sdk.MsgTypeURL(&govv1beta1.MsgVote{})) + _, 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{}) @@ -211,7 +219,7 @@ func (azd AuthzDecorator) handleProposalAuthzRules(ctx sdk.Context, msg *govv1be // Check if any of the proposal messages' types are allowed for _, msg := range proposal.GetMessages() { - if _, exists := allowedProposalTypes[msg.TypeUrl]; !exists { + if _, exists := allowedProposalTypes[msg.GetTypeUrl()]; exists { return nil // Proposal type is allowed } } diff --git a/x/authz/authz.pb.go b/x/authz/authz.pb.go index dc68ad13f40d..c5d7ce12af4b 100644 --- a/x/authz/authz.pb.go +++ b/x/authz/authz.pb.go @@ -279,6 +279,7 @@ type AppAuthzRules struct { 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{} } @@ -327,46 +328,48 @@ func init() { func init() { proto.RegisterFile("cosmos/authz/v1beta1/authz.proto", fileDescriptor_544dc2e84b61c637) } var fileDescriptor_544dc2e84b61c637 = []byte{ - // 623 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xcd, 0x6e, 0xd3, 0x4c, - 0x14, 0x8d, 0x9b, 0xb4, 0xdf, 0x97, 0xa9, 0x8a, 0xe8, 0x28, 0xad, 0x4c, 0x25, 0x9c, 0xc8, 0x42, - 0xa8, 0x42, 0x8a, 0xdd, 0x16, 0x24, 0x10, 0x2b, 0x1c, 0x21, 0x55, 0x80, 0x58, 0xe0, 0x16, 0x16, - 0x6c, 0xac, 0x49, 0x72, 0x71, 0xad, 0x78, 0x3c, 0xd6, 0xcc, 0xb8, 0xc4, 0x7d, 0x04, 0x56, 0x7d, - 0x06, 0x9e, 0x80, 0x45, 0x1f, 0xa2, 0x62, 0x55, 0xb1, 0x62, 0xc5, 0x4f, 0xb3, 0xe0, 0x35, 0x90, - 0x67, 0xec, 0xb6, 0x69, 0x23, 0xe8, 0x82, 0x8d, 0x35, 0x77, 0xce, 0x39, 0xf7, 0xde, 0xb9, 0x67, - 0x3c, 0xa8, 0x33, 0x60, 0x82, 0x32, 0xe1, 0x92, 0x4c, 0xee, 0x1d, 0xb8, 0xfb, 0x9b, 0x7d, 0x90, - 0x64, 0x53, 0x47, 0x4e, 0xca, 0x99, 0x64, 0xb8, 0xa5, 0x19, 0x8e, 0xde, 0x2b, 0x19, 0x6b, 0xcb, - 0x84, 0x46, 0x09, 0x73, 0xd5, 0x57, 0x13, 0xd7, 0x6e, 0x69, 0x62, 0xa0, 0x22, 0xb7, 0x54, 0x69, - 0xa8, 0x1d, 0x32, 0x16, 0xc6, 0xe0, 0xaa, 0xa8, 0x9f, 0xbd, 0x73, 0x65, 0x44, 0x41, 0x48, 0x42, - 0xd3, 0x92, 0xd0, 0x0a, 0x59, 0xc8, 0xb4, 0xb0, 0x58, 0x55, 0x19, 0x2f, 0xcb, 0x48, 0x92, 0x6b, - 0xc8, 0x96, 0xa8, 0xb5, 0x0d, 0x09, 0xf0, 0x68, 0xe0, 0x65, 0x72, 0x8f, 0xf1, 0xe8, 0x80, 0xc8, - 0x88, 0x25, 0xf8, 0x26, 0xaa, 0x53, 0x11, 0x9a, 0x46, 0xc7, 0x58, 0x6f, 0xfa, 0xc5, 0xf2, 0xf1, - 0xf3, 0xcf, 0x47, 0x5d, 0x7b, 0xd6, 0x19, 0x9c, 0x29, 0xe5, 0x87, 0x5f, 0x9f, 0xee, 0xb5, 0x35, - 0xad, 0x2b, 0x86, 0x23, 0x77, 0x56, 0x76, 0x7b, 0x62, 0xa0, 0xf9, 0x6d, 0x4e, 0x12, 0x89, 0xfb, - 0x68, 0x89, 0x5c, 0x84, 0x54, 0xc5, 0xc5, 0xad, 0x96, 0xa3, 0x5b, 0x76, 0xaa, 0x96, 0x1d, 0x2f, - 0xc9, 0x7b, 0x77, 0xaf, 0xd7, 0x82, 0x3f, 0x9d, 0x12, 0x3f, 0x45, 0x08, 0xc6, 0x69, 0xc4, 0x75, - 0x81, 0x39, 0x55, 0x60, 0xed, 0x4a, 0x81, 0xdd, 0x6a, 0x94, 0xbd, 0xff, 0x8f, 0xbf, 0xb5, 0x8d, - 0xc3, 0xef, 0x6d, 0xc3, 0xbf, 0xa0, 0xc3, 0x1b, 0x68, 0x9e, 0x67, 0x31, 0x08, 0xb3, 0xde, 0xa9, - 0xab, 0x04, 0x33, 0x1b, 0xf1, 0xb3, 0x18, 0x7c, 0x4d, 0xb4, 0x37, 0x50, 0xa3, 0x08, 0x8b, 0x59, - 0x8e, 0x20, 0xaf, 0x66, 0x39, 0x82, 0x1c, 0xaf, 0xa2, 0x85, 0x7d, 0x12, 0x67, 0x20, 0xcc, 0xb9, - 0x4e, 0x7d, 0xbd, 0xe9, 0x97, 0x91, 0xfd, 0x71, 0x0e, 0x61, 0x35, 0x97, 0x69, 0x33, 0xb6, 0xd0, - 0x7f, 0x61, 0xb1, 0x0b, 0x5c, 0x27, 0xe9, 0x99, 0x5f, 0x8e, 0xba, 0xd5, 0x7d, 0xf2, 0x86, 0x43, - 0x0e, 0x42, 0xec, 0x48, 0x1e, 0x25, 0xa1, 0x5f, 0x11, 0xcf, 0x35, 0xa0, 0x4e, 0x7c, 0x0d, 0x0d, - 0x5c, 0x35, 0xa3, 0xfe, 0xef, 0xcd, 0x78, 0x32, 0x65, 0x46, 0xe3, 0xaf, 0x66, 0x34, 0x2e, 0x1b, - 0x61, 0x3f, 0x40, 0x37, 0xd4, 0x8c, 0x5e, 0x65, 0x90, 0xc1, 0x33, 0x09, 0x14, 0xdb, 0x68, 0x89, - 0x8a, 0x30, 0x90, 0x79, 0x0a, 0x41, 0xc6, 0x63, 0x61, 0x1a, 0x6a, 0xaa, 0x8b, 0x54, 0x84, 0xbb, - 0x79, 0x0a, 0xaf, 0x79, 0x2c, 0xec, 0x6d, 0xb4, 0xe2, 0xc5, 0x31, 0x7b, 0x0f, 0x43, 0x25, 0x2e, - 0x8c, 0x11, 0x2f, 0x20, 0x17, 0xd8, 0x41, 0x8d, 0x11, 0xe4, 0x5a, 0xf3, 0x67, 0x5b, 0x15, 0xcf, - 0x3e, 0x31, 0xd0, 0x92, 0x97, 0xa6, 0xc5, 0x21, 0x0f, 0x54, 0x16, 0xdc, 0x45, 0x98, 0xe8, 0xd4, - 0x01, 0x87, 0x41, 0x94, 0x46, 0x90, 0xc8, 0xaa, 0x87, 0xe5, 0x12, 0xf1, 0xcf, 0x00, 0x7c, 0x1b, - 0x21, 0x4a, 0xc6, 0x01, 0xa1, 0x2c, 0x4b, 0x64, 0x79, 0x01, 0x9a, 0x94, 0x8c, 0x3d, 0xb5, 0x81, - 0x1f, 0x21, 0xb3, 0xca, 0x26, 0x24, 0x19, 0x41, 0xb0, 0x4f, 0xe2, 0x68, 0x48, 0x24, 0xe3, 0xfa, - 0xea, 0x35, 0xfd, 0xd5, 0x12, 0xdf, 0x29, 0xe0, 0x37, 0x67, 0x28, 0x7e, 0x78, 0xae, 0x2c, 0x0a, - 0x68, 0x75, 0x59, 0xa6, 0xa1, 0x94, 0x2b, 0x25, 0xfe, 0x92, 0x8c, 0x95, 0x58, 0x97, 0xec, 0xf5, - 0x8e, 0x7f, 0x5a, 0xb5, 0xe3, 0x53, 0xcb, 0x38, 0x39, 0xb5, 0x8c, 0x1f, 0xa7, 0x96, 0x71, 0x38, - 0xb1, 0x6a, 0x27, 0x13, 0xab, 0xf6, 0x75, 0x62, 0xd5, 0xde, 0xde, 0x09, 0x23, 0xb9, 0x97, 0xf5, - 0x9d, 0x01, 0xa3, 0xe5, 0x6b, 0xe4, 0x5e, 0xf8, 0xbf, 0xc7, 0xfa, 0x91, 0xeb, 0x2f, 0x28, 0xef, - 0xee, 0xff, 0x0e, 0x00, 0x00, 0xff, 0xff, 0x75, 0x91, 0xe4, 0x3a, 0x09, 0x05, 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) { @@ -645,6 +648,15 @@ func (m *AppAuthzRules) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = 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]) @@ -835,6 +847,12 @@ func (m *AppAuthzRules) Size() (n int) { 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 } @@ -1705,6 +1723,38 @@ func (m *AppAuthzRules) Unmarshal(dAtA []byte) error { } 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:]) diff --git a/x/authz/keeper/keeper.go b/x/authz/keeper/keeper.go index c1a750576c85..147aaba368cf 100644 --- a/x/authz/keeper/keeper.go +++ b/x/authz/keeper/keeper.go @@ -350,20 +350,32 @@ func (k Keeper) SetAuthzRulesKeys(ctx context.Context, rules *authz.AllowedGrant } func (k Keeper) GetAuthzRulesKeys(ctx context.Context) (*authz.AllowedGrantRulesKeys, error) { - 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 + // 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) { diff --git a/x/authz/keeper/msg_server.go b/x/authz/keeper/msg_server.go index ff304efea20c..644a2a95602b 100644 --- a/x/authz/keeper/msg_server.go +++ b/x/authz/keeper/msg_server.go @@ -10,10 +10,11 @@ import ( errorsmod "cosmossdk.io/errors" - bankv1beta1 "cosmossdk.io/api/cosmos/bank/v1beta1" 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" ) @@ -60,7 +61,7 @@ func (k Keeper) Grant(goCtx context.Context, msg *authz.MsgGrant) (*authz.MsgGra var rules []*authz.Rule if msg.Rules != nil { var err error - rules, err = k.VerifyAndBuildRules(goCtx, msg.Grant.Authorization.GetTypeUrl(), msg.Rules) + rules, err = k.VerifyAndBuildRules(goCtx, t, msg.Rules) if err != nil { return nil, err } @@ -100,21 +101,33 @@ func (k Keeper) VerifyAndBuildRules(goCtx context.Context, msg string, rulesByte } if err := checkStructKeys(rulesJson, values); err != nil { - return nil, err + // TODO the condition back + // return nil, err } - var rules []*authz.Rule + rules := []*authz.Rule{} switch msg { case sdk.MsgTypeURL(&bankv1beta1.MsgSend{}): - rules = []*authz.Rule{ - {Key: authz.AllowedRecipients, Values: rulesJson.AllowedRecipients}, - {Key: authz.MaxAmount, Values: rulesJson.MaxAmount}, + 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{ - {Key: authz.AllowedStakeValidators, Values: rulesJson.AllowedStakeValidators}, - {Key: authz.AllowedMaxStakeAmount, Values: rulesJson.AllowedMaxStakeAmount}, + 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}) } } diff --git a/x/gov/keeper/grpc_query.go b/x/gov/keeper/grpc_query.go index faa40ef0afa2..b42a114cfb14 100644 --- a/x/gov/keeper/grpc_query.go +++ b/x/gov/keeper/grpc_query.go @@ -54,18 +54,6 @@ func (q queryServer) Proposal(ctx context.Context, req *v1.QueryProposalRequest) return &v1.QueryProposalResponse{Proposal: &proposal}, nil } -func (q queryServer) GetProposalById(ctx context.Context, proposalId uint64) (*v1.Proposal, error) { - proposal, err := q.k.Proposals.Get(ctx, proposalId) - if err != nil { - if errors.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 -} - // Proposals implements the Query/Proposals gRPC method func (q queryServer) Proposals(ctx context.Context, req *v1.QueryProposalsRequest) (*v1.QueryProposalsResponse, error) { filteredProposals, pageRes, err := query.CollectionFilteredPaginate(ctx, q.k.Proposals, req.Pagination, func(key uint64, p v1.Proposal) (include bool, err error) { 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 +} From ffa9b81982d872f1e2c7a2287a9c558db5e8b4b9 Mon Sep 17 00:00:00 2001 From: atheesh Date: Fri, 26 Jul 2024 16:00:39 +0530 Subject: [PATCH 30/30] add todos --- simapp/app.go | 5 ++++- simapp/app_v2.go | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/simapp/app.go b/simapp/app.go index aea21e2830ae..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 @@ -572,6 +574,7 @@ func (app *SimApp) setAnteHandler(txConfig client.TxConfig) { 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)