diff --git a/api/cosmos/accounts/defaults/base/v1/base.pulsar.go b/api/cosmos/accounts/defaults/base/v1/base.pulsar.go index cc079ae338b6..f1136248cde1 100644 --- a/api/cosmos/accounts/defaults/base/v1/base.pulsar.go +++ b/api/cosmos/accounts/defaults/base/v1/base.pulsar.go @@ -7,6 +7,7 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + anypb "google.golang.org/protobuf/types/known/anypb" io "io" reflect "reflect" sync "sync" @@ -88,8 +89,8 @@ func (x *fastReflection_MsgInit) Interface() protoreflect.ProtoMessage { // While iterating, mutating operations may only be performed // on the current field descriptor. func (x *fastReflection_MsgInit) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { - if len(x.PubKey) != 0 { - value := protoreflect.ValueOfBytes(x.PubKey) + if x.PubKey != nil { + value := protoreflect.ValueOfMessage(x.PubKey.ProtoReflect()) if !f(fd_MsgInit_pub_key, value) { return } @@ -110,7 +111,7 @@ func (x *fastReflection_MsgInit) Range(f func(protoreflect.FieldDescriptor, prot func (x *fastReflection_MsgInit) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { case "cosmos.accounts.defaults.base.v1.MsgInit.pub_key": - return len(x.PubKey) != 0 + return x.PubKey != nil default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.base.v1.MsgInit")) @@ -147,7 +148,7 @@ func (x *fastReflection_MsgInit) Get(descriptor protoreflect.FieldDescriptor) pr switch descriptor.FullName() { case "cosmos.accounts.defaults.base.v1.MsgInit.pub_key": value := x.PubKey - return protoreflect.ValueOfBytes(value) + return protoreflect.ValueOfMessage(value.ProtoReflect()) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.base.v1.MsgInit")) @@ -169,7 +170,7 @@ func (x *fastReflection_MsgInit) Get(descriptor protoreflect.FieldDescriptor) pr func (x *fastReflection_MsgInit) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { switch fd.FullName() { case "cosmos.accounts.defaults.base.v1.MsgInit.pub_key": - x.PubKey = value.Bytes() + x.PubKey = value.Message().Interface().(*anypb.Any) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.base.v1.MsgInit")) @@ -191,7 +192,10 @@ func (x *fastReflection_MsgInit) Set(fd protoreflect.FieldDescriptor, value prot func (x *fastReflection_MsgInit) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { case "cosmos.accounts.defaults.base.v1.MsgInit.pub_key": - panic(fmt.Errorf("field pub_key of message cosmos.accounts.defaults.base.v1.MsgInit is not mutable")) + if x.PubKey == nil { + x.PubKey = new(anypb.Any) + } + return protoreflect.ValueOfMessage(x.PubKey.ProtoReflect()) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.base.v1.MsgInit")) @@ -206,7 +210,8 @@ func (x *fastReflection_MsgInit) Mutable(fd protoreflect.FieldDescriptor) protor func (x *fastReflection_MsgInit) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { case "cosmos.accounts.defaults.base.v1.MsgInit.pub_key": - return protoreflect.ValueOfBytes(nil) + m := new(anypb.Any) + return protoreflect.ValueOfMessage(m.ProtoReflect()) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.base.v1.MsgInit")) @@ -276,8 +281,8 @@ func (x *fastReflection_MsgInit) ProtoMethods() *protoiface.Methods { var n int var l int _ = l - l = len(x.PubKey) - if l > 0 { + if x.PubKey != nil { + l = options.Size(x.PubKey) n += 1 + l + runtime.Sov(uint64(l)) } if x.unknownFields != nil { @@ -309,10 +314,17 @@ func (x *fastReflection_MsgInit) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } - if len(x.PubKey) > 0 { - i -= len(x.PubKey) - copy(dAtA[i:], x.PubKey) - i = runtime.EncodeVarint(dAtA, i, uint64(len(x.PubKey))) + if x.PubKey != nil { + encoded, err := options.Marshal(x.PubKey) + 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 } @@ -369,7 +381,7 @@ func (x *fastReflection_MsgInit) ProtoMethods() *protoiface.Methods { if wireType != 2 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field PubKey", 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 @@ -379,24 +391,26 @@ func (x *fastReflection_MsgInit) 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.PubKey = append(x.PubKey[:0], dAtA[iNdEx:postIndex]...) if x.PubKey == nil { - x.PubKey = []byte{} + x.PubKey = &anypb.Any{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.PubKey); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err } iNdEx = postIndex default: @@ -866,8 +880,8 @@ func (x *fastReflection_MsgSwapPubKey) Interface() protoreflect.ProtoMessage { // While iterating, mutating operations may only be performed // on the current field descriptor. func (x *fastReflection_MsgSwapPubKey) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { - if len(x.NewPubKey) != 0 { - value := protoreflect.ValueOfBytes(x.NewPubKey) + if x.NewPubKey != nil { + value := protoreflect.ValueOfMessage(x.NewPubKey.ProtoReflect()) if !f(fd_MsgSwapPubKey_new_pub_key, value) { return } @@ -888,7 +902,7 @@ func (x *fastReflection_MsgSwapPubKey) Range(f func(protoreflect.FieldDescriptor func (x *fastReflection_MsgSwapPubKey) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { case "cosmos.accounts.defaults.base.v1.MsgSwapPubKey.new_pub_key": - return len(x.NewPubKey) != 0 + return x.NewPubKey != nil default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.base.v1.MsgSwapPubKey")) @@ -925,7 +939,7 @@ func (x *fastReflection_MsgSwapPubKey) Get(descriptor protoreflect.FieldDescript switch descriptor.FullName() { case "cosmos.accounts.defaults.base.v1.MsgSwapPubKey.new_pub_key": value := x.NewPubKey - return protoreflect.ValueOfBytes(value) + return protoreflect.ValueOfMessage(value.ProtoReflect()) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.base.v1.MsgSwapPubKey")) @@ -947,7 +961,7 @@ func (x *fastReflection_MsgSwapPubKey) Get(descriptor protoreflect.FieldDescript func (x *fastReflection_MsgSwapPubKey) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { switch fd.FullName() { case "cosmos.accounts.defaults.base.v1.MsgSwapPubKey.new_pub_key": - x.NewPubKey = value.Bytes() + x.NewPubKey = value.Message().Interface().(*anypb.Any) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.base.v1.MsgSwapPubKey")) @@ -969,7 +983,10 @@ func (x *fastReflection_MsgSwapPubKey) Set(fd protoreflect.FieldDescriptor, valu func (x *fastReflection_MsgSwapPubKey) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { case "cosmos.accounts.defaults.base.v1.MsgSwapPubKey.new_pub_key": - panic(fmt.Errorf("field new_pub_key of message cosmos.accounts.defaults.base.v1.MsgSwapPubKey is not mutable")) + if x.NewPubKey == nil { + x.NewPubKey = new(anypb.Any) + } + return protoreflect.ValueOfMessage(x.NewPubKey.ProtoReflect()) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.base.v1.MsgSwapPubKey")) @@ -984,7 +1001,8 @@ func (x *fastReflection_MsgSwapPubKey) Mutable(fd protoreflect.FieldDescriptor) func (x *fastReflection_MsgSwapPubKey) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { case "cosmos.accounts.defaults.base.v1.MsgSwapPubKey.new_pub_key": - return protoreflect.ValueOfBytes(nil) + m := new(anypb.Any) + return protoreflect.ValueOfMessage(m.ProtoReflect()) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.base.v1.MsgSwapPubKey")) @@ -1054,8 +1072,8 @@ func (x *fastReflection_MsgSwapPubKey) ProtoMethods() *protoiface.Methods { var n int var l int _ = l - l = len(x.NewPubKey) - if l > 0 { + if x.NewPubKey != nil { + l = options.Size(x.NewPubKey) n += 1 + l + runtime.Sov(uint64(l)) } if x.unknownFields != nil { @@ -1087,10 +1105,17 @@ func (x *fastReflection_MsgSwapPubKey) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } - if len(x.NewPubKey) > 0 { - i -= len(x.NewPubKey) - copy(dAtA[i:], x.NewPubKey) - i = runtime.EncodeVarint(dAtA, i, uint64(len(x.NewPubKey))) + if x.NewPubKey != nil { + encoded, err := options.Marshal(x.NewPubKey) + 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 } @@ -1147,7 +1172,7 @@ func (x *fastReflection_MsgSwapPubKey) ProtoMethods() *protoiface.Methods { if wireType != 2 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field NewPubKey", 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 @@ -1157,24 +1182,26 @@ func (x *fastReflection_MsgSwapPubKey) 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.NewPubKey = append(x.NewPubKey[:0], dAtA[iNdEx:postIndex]...) if x.NewPubKey == nil { - x.NewPubKey = []byte{} + x.NewPubKey = &anypb.Any{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.NewPubKey); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err } iNdEx = postIndex default: @@ -2328,179 +2355,970 @@ func (x *fastReflection_QuerySequenceResponse) ProtoMethods() *protoiface.Method } } -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.27.0 -// protoc (unknown) -// source: cosmos/accounts/defaults/base/v1/base.proto - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +var ( + md_QueryPubKey protoreflect.MessageDescriptor ) -// MsgInit is used to initialize a base account. -type MsgInit struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // pub_key defines the secp256k1 pubkey for the account. - PubKey []byte `protobuf:"bytes,1,opt,name=pub_key,json=pubKey,proto3" json:"pub_key,omitempty"` -} - -func (x *MsgInit) Reset() { - *x = MsgInit{} - if protoimpl.UnsafeEnabled { - mi := &file_cosmos_accounts_defaults_base_v1_base_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *MsgInit) String() string { - return protoimpl.X.MessageStringOf(x) +func init() { + file_cosmos_accounts_defaults_base_v1_base_proto_init() + md_QueryPubKey = File_cosmos_accounts_defaults_base_v1_base_proto.Messages().ByName("QueryPubKey") } -func (*MsgInit) ProtoMessage() {} - -// Deprecated: Use MsgInit.ProtoReflect.Descriptor instead. -func (*MsgInit) Descriptor() ([]byte, []int) { - return file_cosmos_accounts_defaults_base_v1_base_proto_rawDescGZIP(), []int{0} -} +var _ protoreflect.Message = (*fastReflection_QueryPubKey)(nil) -func (x *MsgInit) GetPubKey() []byte { - if x != nil { - return x.PubKey - } - return nil -} +type fastReflection_QueryPubKey QueryPubKey -// MsgInitResponse is the response returned after base account initialization. -// This is empty. -type MsgInitResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields +func (x *QueryPubKey) ProtoReflect() protoreflect.Message { + return (*fastReflection_QueryPubKey)(x) } -func (x *MsgInitResponse) Reset() { - *x = MsgInitResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_cosmos_accounts_defaults_base_v1_base_proto_msgTypes[1] +func (x *QueryPubKey) slowProtoReflect() protoreflect.Message { + mi := &file_cosmos_accounts_defaults_base_v1_base_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms } + return mi.MessageOf(x) } -func (x *MsgInitResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} +var _fastReflection_QueryPubKey_messageType fastReflection_QueryPubKey_messageType +var _ protoreflect.MessageType = fastReflection_QueryPubKey_messageType{} -func (*MsgInitResponse) ProtoMessage() {} +type fastReflection_QueryPubKey_messageType struct{} -// Deprecated: Use MsgInitResponse.ProtoReflect.Descriptor instead. -func (*MsgInitResponse) Descriptor() ([]byte, []int) { - return file_cosmos_accounts_defaults_base_v1_base_proto_rawDescGZIP(), []int{1} +func (x fastReflection_QueryPubKey_messageType) Zero() protoreflect.Message { + return (*fastReflection_QueryPubKey)(nil) +} +func (x fastReflection_QueryPubKey_messageType) New() protoreflect.Message { + return new(fastReflection_QueryPubKey) +} +func (x fastReflection_QueryPubKey_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_QueryPubKey } -// MsgSwapPubKey is used to change the pubkey for the account. -type MsgSwapPubKey struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // new_pub_key defines the secp256k1 pubkey to swap the account to. - NewPubKey []byte `protobuf:"bytes,1,opt,name=new_pub_key,json=newPubKey,proto3" json:"new_pub_key,omitempty"` +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_QueryPubKey) Descriptor() protoreflect.MessageDescriptor { + return md_QueryPubKey } -func (x *MsgSwapPubKey) Reset() { - *x = MsgSwapPubKey{} - if protoimpl.UnsafeEnabled { - mi := &file_cosmos_accounts_defaults_base_v1_base_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } +// 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_QueryPubKey) Type() protoreflect.MessageType { + return _fastReflection_QueryPubKey_messageType } -func (x *MsgSwapPubKey) String() string { - return protoimpl.X.MessageStringOf(x) +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_QueryPubKey) New() protoreflect.Message { + return new(fastReflection_QueryPubKey) } -func (*MsgSwapPubKey) ProtoMessage() {} +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_QueryPubKey) Interface() protoreflect.ProtoMessage { + return (*QueryPubKey)(x) +} -// Deprecated: Use MsgSwapPubKey.ProtoReflect.Descriptor instead. -func (*MsgSwapPubKey) Descriptor() ([]byte, []int) { - return file_cosmos_accounts_defaults_base_v1_base_proto_rawDescGZIP(), []int{2} +// 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_QueryPubKey) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { } -func (x *MsgSwapPubKey) GetNewPubKey() []byte { - if x != nil { - return x.NewPubKey +// 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_QueryPubKey) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.base.v1.QueryPubKey")) + } + panic(fmt.Errorf("message cosmos.accounts.defaults.base.v1.QueryPubKey does not contain field %s", fd.FullName())) } - return nil } -// MsgSwapPubKeyResponse is the response for the MsgSwapPubKey message. -// This is empty. -type MsgSwapPubKeyResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields +// 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_QueryPubKey) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.base.v1.QueryPubKey")) + } + panic(fmt.Errorf("message cosmos.accounts.defaults.base.v1.QueryPubKey does not contain field %s", fd.FullName())) + } } -func (x *MsgSwapPubKeyResponse) Reset() { - *x = MsgSwapPubKeyResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_cosmos_accounts_defaults_base_v1_base_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) +// 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_QueryPubKey) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.base.v1.QueryPubKey")) + } + panic(fmt.Errorf("message cosmos.accounts.defaults.base.v1.QueryPubKey does not contain field %s", descriptor.FullName())) } } -func (x *MsgSwapPubKeyResponse) String() string { - return protoimpl.X.MessageStringOf(x) +// 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_QueryPubKey) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.base.v1.QueryPubKey")) + } + panic(fmt.Errorf("message cosmos.accounts.defaults.base.v1.QueryPubKey does not contain field %s", fd.FullName())) + } } -func (*MsgSwapPubKeyResponse) ProtoMessage() {} - -// Deprecated: Use MsgSwapPubKeyResponse.ProtoReflect.Descriptor instead. -func (*MsgSwapPubKeyResponse) Descriptor() ([]byte, []int) { - return file_cosmos_accounts_defaults_base_v1_base_proto_rawDescGZIP(), []int{3} +// 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_QueryPubKey) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.base.v1.QueryPubKey")) + } + panic(fmt.Errorf("message cosmos.accounts.defaults.base.v1.QueryPubKey does not contain field %s", fd.FullName())) + } } -// QuerySequence is the request for the account sequence. -type QuerySequence struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields +// 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_QueryPubKey) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.base.v1.QueryPubKey")) + } + panic(fmt.Errorf("message cosmos.accounts.defaults.base.v1.QueryPubKey does not contain field %s", fd.FullName())) + } } -func (x *QuerySequence) Reset() { - *x = QuerySequence{} - if protoimpl.UnsafeEnabled { - mi := &file_cosmos_accounts_defaults_base_v1_base_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) +// 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_QueryPubKey) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.accounts.defaults.base.v1.QueryPubKey", d.FullName())) } + panic("unreachable") } -func (x *QuerySequence) String() string { - return protoimpl.X.MessageStringOf(x) +// 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_QueryPubKey) GetUnknown() protoreflect.RawFields { + return x.unknownFields } -func (*QuerySequence) ProtoMessage() {} +// 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_QueryPubKey) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} -// Deprecated: Use QuerySequence.ProtoReflect.Descriptor instead. -func (*QuerySequence) Descriptor() ([]byte, []int) { - return file_cosmos_accounts_defaults_base_v1_base_proto_rawDescGZIP(), []int{4} +// 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_QueryPubKey) IsValid() bool { + return x != nil } -// QuerySequenceResponse returns the sequence of the account. -type QuerySequenceResponse struct { - state protoimpl.MessageState +// 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_QueryPubKey) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*QueryPubKey) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*QueryPubKey) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*QueryPubKey) + 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: QueryPubKey: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: QueryPubKey: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +var ( + md_QueryPubKeyResponse protoreflect.MessageDescriptor + fd_QueryPubKeyResponse_pub_key protoreflect.FieldDescriptor +) + +func init() { + file_cosmos_accounts_defaults_base_v1_base_proto_init() + md_QueryPubKeyResponse = File_cosmos_accounts_defaults_base_v1_base_proto.Messages().ByName("QueryPubKeyResponse") + fd_QueryPubKeyResponse_pub_key = md_QueryPubKeyResponse.Fields().ByName("pub_key") +} + +var _ protoreflect.Message = (*fastReflection_QueryPubKeyResponse)(nil) + +type fastReflection_QueryPubKeyResponse QueryPubKeyResponse + +func (x *QueryPubKeyResponse) ProtoReflect() protoreflect.Message { + return (*fastReflection_QueryPubKeyResponse)(x) +} + +func (x *QueryPubKeyResponse) slowProtoReflect() protoreflect.Message { + mi := &file_cosmos_accounts_defaults_base_v1_base_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_QueryPubKeyResponse_messageType fastReflection_QueryPubKeyResponse_messageType +var _ protoreflect.MessageType = fastReflection_QueryPubKeyResponse_messageType{} + +type fastReflection_QueryPubKeyResponse_messageType struct{} + +func (x fastReflection_QueryPubKeyResponse_messageType) Zero() protoreflect.Message { + return (*fastReflection_QueryPubKeyResponse)(nil) +} +func (x fastReflection_QueryPubKeyResponse_messageType) New() protoreflect.Message { + return new(fastReflection_QueryPubKeyResponse) +} +func (x fastReflection_QueryPubKeyResponse_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_QueryPubKeyResponse +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_QueryPubKeyResponse) Descriptor() protoreflect.MessageDescriptor { + return md_QueryPubKeyResponse +} + +// 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_QueryPubKeyResponse) Type() protoreflect.MessageType { + return _fastReflection_QueryPubKeyResponse_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_QueryPubKeyResponse) New() protoreflect.Message { + return new(fastReflection_QueryPubKeyResponse) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_QueryPubKeyResponse) Interface() protoreflect.ProtoMessage { + return (*QueryPubKeyResponse)(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_QueryPubKeyResponse) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.PubKey != nil { + value := protoreflect.ValueOfMessage(x.PubKey.ProtoReflect()) + if !f(fd_QueryPubKeyResponse_pub_key, 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_QueryPubKeyResponse) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "cosmos.accounts.defaults.base.v1.QueryPubKeyResponse.pub_key": + return x.PubKey != nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.base.v1.QueryPubKeyResponse")) + } + panic(fmt.Errorf("message cosmos.accounts.defaults.base.v1.QueryPubKeyResponse 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_QueryPubKeyResponse) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "cosmos.accounts.defaults.base.v1.QueryPubKeyResponse.pub_key": + x.PubKey = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.base.v1.QueryPubKeyResponse")) + } + panic(fmt.Errorf("message cosmos.accounts.defaults.base.v1.QueryPubKeyResponse 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_QueryPubKeyResponse) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "cosmos.accounts.defaults.base.v1.QueryPubKeyResponse.pub_key": + value := x.PubKey + return protoreflect.ValueOfMessage(value.ProtoReflect()) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.base.v1.QueryPubKeyResponse")) + } + panic(fmt.Errorf("message cosmos.accounts.defaults.base.v1.QueryPubKeyResponse 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_QueryPubKeyResponse) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "cosmos.accounts.defaults.base.v1.QueryPubKeyResponse.pub_key": + x.PubKey = value.Message().Interface().(*anypb.Any) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.base.v1.QueryPubKeyResponse")) + } + panic(fmt.Errorf("message cosmos.accounts.defaults.base.v1.QueryPubKeyResponse 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_QueryPubKeyResponse) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.accounts.defaults.base.v1.QueryPubKeyResponse.pub_key": + if x.PubKey == nil { + x.PubKey = new(anypb.Any) + } + return protoreflect.ValueOfMessage(x.PubKey.ProtoReflect()) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.base.v1.QueryPubKeyResponse")) + } + panic(fmt.Errorf("message cosmos.accounts.defaults.base.v1.QueryPubKeyResponse 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_QueryPubKeyResponse) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.accounts.defaults.base.v1.QueryPubKeyResponse.pub_key": + m := new(anypb.Any) + return protoreflect.ValueOfMessage(m.ProtoReflect()) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.accounts.defaults.base.v1.QueryPubKeyResponse")) + } + panic(fmt.Errorf("message cosmos.accounts.defaults.base.v1.QueryPubKeyResponse 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_QueryPubKeyResponse) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.accounts.defaults.base.v1.QueryPubKeyResponse", 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_QueryPubKeyResponse) 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_QueryPubKeyResponse) 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_QueryPubKeyResponse) 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_QueryPubKeyResponse) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*QueryPubKeyResponse) + 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.PubKey != nil { + l = options.Size(x.PubKey) + 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().(*QueryPubKeyResponse) + 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.PubKey != nil { + encoded, err := options.Marshal(x.PubKey) + 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().(*QueryPubKeyResponse) + 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: QueryPubKeyResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: QueryPubKeyResponse: 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 PubKey", 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.PubKey == nil { + x.PubKey = &anypb.Any{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.PubKey); 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, + } +} + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.27.0 +// protoc (unknown) +// source: cosmos/accounts/defaults/base/v1/base.proto + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// MsgInit is used to initialize a base account. +type MsgInit struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // pub_key defines a pubkey for the account arbitrary encapsulated. + PubKey *anypb.Any `protobuf:"bytes,1,opt,name=pub_key,json=pubKey,proto3" json:"pub_key,omitempty"` +} + +func (x *MsgInit) Reset() { + *x = MsgInit{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_accounts_defaults_base_v1_base_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MsgInit) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MsgInit) ProtoMessage() {} + +// Deprecated: Use MsgInit.ProtoReflect.Descriptor instead. +func (*MsgInit) Descriptor() ([]byte, []int) { + return file_cosmos_accounts_defaults_base_v1_base_proto_rawDescGZIP(), []int{0} +} + +func (x *MsgInit) GetPubKey() *anypb.Any { + if x != nil { + return x.PubKey + } + return nil +} + +// MsgInitResponse is the response returned after base account initialization. +// This is empty. +type MsgInitResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *MsgInitResponse) Reset() { + *x = MsgInitResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_accounts_defaults_base_v1_base_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MsgInitResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MsgInitResponse) ProtoMessage() {} + +// Deprecated: Use MsgInitResponse.ProtoReflect.Descriptor instead. +func (*MsgInitResponse) Descriptor() ([]byte, []int) { + return file_cosmos_accounts_defaults_base_v1_base_proto_rawDescGZIP(), []int{1} +} + +// MsgSwapPubKey is used to change the pubkey for the account. +type MsgSwapPubKey struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // new_pub_key defines the secp256k1 pubkey to swap the account to. + NewPubKey *anypb.Any `protobuf:"bytes,1,opt,name=new_pub_key,json=newPubKey,proto3" json:"new_pub_key,omitempty"` +} + +func (x *MsgSwapPubKey) Reset() { + *x = MsgSwapPubKey{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_accounts_defaults_base_v1_base_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MsgSwapPubKey) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MsgSwapPubKey) ProtoMessage() {} + +// Deprecated: Use MsgSwapPubKey.ProtoReflect.Descriptor instead. +func (*MsgSwapPubKey) Descriptor() ([]byte, []int) { + return file_cosmos_accounts_defaults_base_v1_base_proto_rawDescGZIP(), []int{2} +} + +func (x *MsgSwapPubKey) GetNewPubKey() *anypb.Any { + if x != nil { + return x.NewPubKey + } + return nil +} + +// MsgSwapPubKeyResponse is the response for the MsgSwapPubKey message. +// This is empty. +type MsgSwapPubKeyResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *MsgSwapPubKeyResponse) Reset() { + *x = MsgSwapPubKeyResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_accounts_defaults_base_v1_base_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MsgSwapPubKeyResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MsgSwapPubKeyResponse) ProtoMessage() {} + +// Deprecated: Use MsgSwapPubKeyResponse.ProtoReflect.Descriptor instead. +func (*MsgSwapPubKeyResponse) Descriptor() ([]byte, []int) { + return file_cosmos_accounts_defaults_base_v1_base_proto_rawDescGZIP(), []int{3} +} + +// QuerySequence is the request for the account sequence. +type QuerySequence struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *QuerySequence) Reset() { + *x = QuerySequence{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_accounts_defaults_base_v1_base_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *QuerySequence) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*QuerySequence) ProtoMessage() {} + +// Deprecated: Use QuerySequence.ProtoReflect.Descriptor instead. +func (*QuerySequence) Descriptor() ([]byte, []int) { + return file_cosmos_accounts_defaults_base_v1_base_proto_rawDescGZIP(), []int{4} +} + +// QuerySequenceResponse returns the sequence of the account. +type QuerySequenceResponse struct { + state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields @@ -2535,6 +3353,69 @@ func (x *QuerySequenceResponse) GetSequence() uint64 { return 0 } +// QueryPubKey is the request used to query the pubkey of an account. +type QueryPubKey struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *QueryPubKey) Reset() { + *x = QueryPubKey{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_accounts_defaults_base_v1_base_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *QueryPubKey) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*QueryPubKey) ProtoMessage() {} + +// Deprecated: Use QueryPubKey.ProtoReflect.Descriptor instead. +func (*QueryPubKey) Descriptor() ([]byte, []int) { + return file_cosmos_accounts_defaults_base_v1_base_proto_rawDescGZIP(), []int{6} +} + +// QueryPubKeyResponse is the response returned when a QueryPubKey message is sent. +type QueryPubKeyResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + PubKey *anypb.Any `protobuf:"bytes,1,opt,name=pub_key,json=pubKey,proto3" json:"pub_key,omitempty"` +} + +func (x *QueryPubKeyResponse) Reset() { + *x = QueryPubKeyResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_accounts_defaults_base_v1_base_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *QueryPubKeyResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*QueryPubKeyResponse) ProtoMessage() {} + +// Deprecated: Use QueryPubKeyResponse.ProtoReflect.Descriptor instead. +func (*QueryPubKeyResponse) Descriptor() ([]byte, []int) { + return file_cosmos_accounts_defaults_base_v1_base_proto_rawDescGZIP(), []int{7} +} + +func (x *QueryPubKeyResponse) GetPubKey() *anypb.Any { + if x != nil { + return x.PubKey + } + return nil +} + var File_cosmos_accounts_defaults_base_v1_base_proto protoreflect.FileDescriptor var file_cosmos_accounts_defaults_base_v1_base_proto_rawDesc = []byte{ @@ -2542,38 +3423,47 @@ var file_cosmos_accounts_defaults_base_v1_base_proto_rawDesc = []byte{ 0x73, 0x2f, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x20, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x64, - 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x22, - 0x22, 0x0a, 0x07, 0x4d, 0x73, 0x67, 0x49, 0x6e, 0x69, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x70, 0x75, - 0x62, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x70, 0x75, 0x62, - 0x4b, 0x65, 0x79, 0x22, 0x11, 0x0a, 0x0f, 0x4d, 0x73, 0x67, 0x49, 0x6e, 0x69, 0x74, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2f, 0x0a, 0x0d, 0x4d, 0x73, 0x67, 0x53, 0x77, 0x61, - 0x70, 0x50, 0x75, 0x62, 0x4b, 0x65, 0x79, 0x12, 0x1e, 0x0a, 0x0b, 0x6e, 0x65, 0x77, 0x5f, 0x70, - 0x75, 0x62, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x6e, 0x65, - 0x77, 0x50, 0x75, 0x62, 0x4b, 0x65, 0x79, 0x22, 0x17, 0x0a, 0x15, 0x4d, 0x73, 0x67, 0x53, 0x77, - 0x61, 0x70, 0x50, 0x75, 0x62, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x0f, 0x0a, 0x0d, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, - 0x65, 0x22, 0x33, 0x0a, 0x15, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x65, 0x71, 0x75, 0x65, 0x6e, - 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, - 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x73, 0x65, - 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x42, 0x90, 0x02, 0x0a, 0x24, 0x63, 0x6f, 0x6d, 0x2e, 0x63, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x64, - 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x42, - 0x09, 0x42, 0x61, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x38, 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, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2f, 0x64, - 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2f, 0x76, 0x31, 0x3b, - 0x62, 0x61, 0x73, 0x65, 0x76, 0x31, 0xa2, 0x02, 0x04, 0x43, 0x41, 0x44, 0x42, 0xaa, 0x02, 0x20, - 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, - 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x2e, 0x56, 0x31, - 0xca, 0x02, 0x20, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, - 0x74, 0x73, 0x5c, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x5c, 0x42, 0x61, 0x73, 0x65, - 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x2c, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x63, 0x63, - 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x5c, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x5c, 0x42, - 0x61, 0x73, 0x65, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, - 0x74, 0x61, 0xea, 0x02, 0x24, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x41, 0x63, 0x63, - 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x3a, 0x3a, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x3a, - 0x3a, 0x42, 0x61, 0x73, 0x65, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, + 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 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, 0x38, 0x0a, 0x07, 0x4d, 0x73, + 0x67, 0x49, 0x6e, 0x69, 0x74, 0x12, 0x2d, 0x0a, 0x07, 0x70, 0x75, 0x62, 0x5f, 0x6b, 0x65, 0x79, + 0x18, 0x01, 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, 0x52, 0x06, 0x70, 0x75, + 0x62, 0x4b, 0x65, 0x79, 0x22, 0x11, 0x0a, 0x0f, 0x4d, 0x73, 0x67, 0x49, 0x6e, 0x69, 0x74, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x45, 0x0a, 0x0d, 0x4d, 0x73, 0x67, 0x53, 0x77, + 0x61, 0x70, 0x50, 0x75, 0x62, 0x4b, 0x65, 0x79, 0x12, 0x34, 0x0a, 0x0b, 0x6e, 0x65, 0x77, 0x5f, + 0x70, 0x75, 0x62, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01, 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, 0x52, 0x09, 0x6e, 0x65, 0x77, 0x50, 0x75, 0x62, 0x4b, 0x65, 0x79, 0x22, 0x17, + 0x0a, 0x15, 0x4d, 0x73, 0x67, 0x53, 0x77, 0x61, 0x70, 0x50, 0x75, 0x62, 0x4b, 0x65, 0x79, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x0f, 0x0a, 0x0d, 0x51, 0x75, 0x65, 0x72, 0x79, + 0x53, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x22, 0x33, 0x0a, 0x15, 0x51, 0x75, 0x65, 0x72, + 0x79, 0x53, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x04, 0x52, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x22, 0x0d, 0x0a, + 0x0b, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x75, 0x62, 0x4b, 0x65, 0x79, 0x22, 0x44, 0x0a, 0x13, + 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x75, 0x62, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x2d, 0x0a, 0x07, 0x70, 0x75, 0x62, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01, + 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, 0x52, 0x06, 0x70, 0x75, 0x62, 0x4b, + 0x65, 0x79, 0x42, 0x90, 0x02, 0x0a, 0x24, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x64, 0x65, 0x66, 0x61, 0x75, + 0x6c, 0x74, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x09, 0x42, 0x61, 0x73, + 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x38, 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, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2f, 0x64, 0x65, 0x66, 0x61, 0x75, + 0x6c, 0x74, 0x73, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x62, 0x61, 0x73, 0x65, + 0x76, 0x31, 0xa2, 0x02, 0x04, 0x43, 0x41, 0x44, 0x42, 0xaa, 0x02, 0x20, 0x43, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x2e, 0x44, 0x65, 0x66, 0x61, + 0x75, 0x6c, 0x74, 0x73, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x20, 0x43, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x5c, 0x44, + 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x5c, 0x42, 0x61, 0x73, 0x65, 0x5c, 0x56, 0x31, 0xe2, + 0x02, 0x2c, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x73, 0x5c, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x5c, 0x42, 0x61, 0x73, 0x65, 0x5c, + 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, + 0x24, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x73, 0x3a, 0x3a, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x3a, 0x3a, 0x42, 0x61, 0x73, + 0x65, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -2588,7 +3478,7 @@ func file_cosmos_accounts_defaults_base_v1_base_proto_rawDescGZIP() []byte { return file_cosmos_accounts_defaults_base_v1_base_proto_rawDescData } -var file_cosmos_accounts_defaults_base_v1_base_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_cosmos_accounts_defaults_base_v1_base_proto_msgTypes = make([]protoimpl.MessageInfo, 8) var file_cosmos_accounts_defaults_base_v1_base_proto_goTypes = []interface{}{ (*MsgInit)(nil), // 0: cosmos.accounts.defaults.base.v1.MsgInit (*MsgInitResponse)(nil), // 1: cosmos.accounts.defaults.base.v1.MsgInitResponse @@ -2596,13 +3486,19 @@ var file_cosmos_accounts_defaults_base_v1_base_proto_goTypes = []interface{}{ (*MsgSwapPubKeyResponse)(nil), // 3: cosmos.accounts.defaults.base.v1.MsgSwapPubKeyResponse (*QuerySequence)(nil), // 4: cosmos.accounts.defaults.base.v1.QuerySequence (*QuerySequenceResponse)(nil), // 5: cosmos.accounts.defaults.base.v1.QuerySequenceResponse + (*QueryPubKey)(nil), // 6: cosmos.accounts.defaults.base.v1.QueryPubKey + (*QueryPubKeyResponse)(nil), // 7: cosmos.accounts.defaults.base.v1.QueryPubKeyResponse + (*anypb.Any)(nil), // 8: google.protobuf.Any } var file_cosmos_accounts_defaults_base_v1_base_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name + 8, // 0: cosmos.accounts.defaults.base.v1.MsgInit.pub_key:type_name -> google.protobuf.Any + 8, // 1: cosmos.accounts.defaults.base.v1.MsgSwapPubKey.new_pub_key:type_name -> google.protobuf.Any + 8, // 2: cosmos.accounts.defaults.base.v1.QueryPubKeyResponse.pub_key:type_name -> google.protobuf.Any + 3, // [3:3] is the sub-list for method output_type + 3, // [3:3] 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_accounts_defaults_base_v1_base_proto_init() } @@ -2683,6 +3579,30 @@ func file_cosmos_accounts_defaults_base_v1_base_proto_init() { return nil } } + file_cosmos_accounts_defaults_base_v1_base_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*QueryPubKey); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_cosmos_accounts_defaults_base_v1_base_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*QueryPubKeyResponse); 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{ @@ -2690,7 +3610,7 @@ func file_cosmos_accounts_defaults_base_v1_base_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_cosmos_accounts_defaults_base_v1_base_proto_rawDesc, NumEnums: 0, - NumMessages: 6, + NumMessages: 8, NumExtensions: 0, NumServices: 0, }, diff --git a/scripts/protocgen.sh b/scripts/protocgen.sh index 34f993bba5ce..c731c75e4fa7 100755 --- a/scripts/protocgen.sh +++ b/scripts/protocgen.sh @@ -29,7 +29,7 @@ for dir in $proto_dirs; do # check if buf.gen.gogo.yaml exists in the proto directory if [ -f "buf.gen.gogo.yaml" ]; then - for file in $(find . -maxdepth 5 -name '*.proto'); do + for file in $(find . -maxdepth 8 -name '*.proto'); do # this regex checks if a proto file has its go_package set to cosmossdk.io/api/... # gogo proto files SHOULD ONLY be generated if this is false # we don't want gogo proto to run for proto files which are natively built for google.golang.org/protobuf diff --git a/simapp/CHANGELOG.md b/simapp/CHANGELOG.md index b2b2ee639cc1..5e6dae65ec2b 100644 --- a/simapp/CHANGELOG.md +++ b/simapp/CHANGELOG.md @@ -45,7 +45,7 @@ Always refer to the [UPGRADING.md](https://github.com/cosmos/cosmos-sdk/blob/mai * [#20771](https://github.com/cosmos/cosmos-sdk/pull/20771) Use client/v2 `GetNodeHomeDirectory` helper in `app.go` and use the `DefaultNodeHome` constant everywhere in the app. * [#20490](https://github.com/cosmos/cosmos-sdk/pull/20490) Refactor simulations to make use of `testutil/sims` instead of `runsims`. * [#19726](https://github.com/cosmos/cosmos-sdk/pull/19726) Update APIs to match CometBFT v1. - +* [#21466](https://github.com/cosmos/cosmos-sdk/pull/21466) Allow chains to plug in their own public key types in `base.Account` ## v0.47 to v0.50 diff --git a/simapp/app.go b/simapp/app.go index 274d7aa7aa52..0d29c542bb17 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -311,7 +311,7 @@ func NewSimApp( accountstd.AddAccount(lockup.DELAYED_LOCKING_ACCOUNT, lockup.NewDelayedLockingAccount), accountstd.AddAccount(lockup.PERMANENT_LOCKING_ACCOUNT, lockup.NewPermanentLockingAccount), // PRODUCTION: add - baseaccount.NewAccount("base", txConfig.SignModeHandler()), + baseaccount.NewAccount("base", txConfig.SignModeHandler(), baseaccount.WithSecp256K1PubKey()), ) if err != nil { panic(err) diff --git a/store/internal/kv/kv.pb.go b/store/internal/kv/kv.pb.go index 847bd11d4484..311a1913b359 100644 --- a/store/internal/kv/kv.pb.go +++ b/store/internal/kv/kv.pb.go @@ -24,6 +24,11 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Pairs defines a repeated slice of Pair objects. +// +// Deprecated: Store v1 is deprecated as of v0.50.x, please use Store v2 types +// instead. +// +// Deprecated: Do not use. type Pairs struct { Pairs []Pair `protobuf:"bytes,1,rep,name=pairs,proto3" json:"pairs"` } @@ -69,6 +74,11 @@ func (m *Pairs) GetPairs() []Pair { } // Pair defines a key/value bytes tuple. +// +// Deprecated: Store v1 is deprecated as of v0.50.x, please use Store v2 types +// instead. +// +// Deprecated: Do not use. type Pair struct { Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` @@ -131,21 +141,21 @@ func init() { } var fileDescriptor_534782c4083e056d = []byte{ - // 217 bytes of a gzipped FileDescriptorProto + // 223 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x4c, 0xce, 0x2f, 0xce, 0xcd, 0x2f, 0xd6, 0x2f, 0x2e, 0xc9, 0x2f, 0x4a, 0xd5, 0xcf, 0xcc, 0x2b, 0x49, 0x2d, 0xca, 0x4b, 0xcc, 0xd1, 0xcf, 0x2e, 0xd3, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0xcf, 0x2e, 0xd3, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x52, 0x80, 0x28, 0xd5, 0x03, 0x2b, 0xd5, 0x83, 0x29, 0xd5, 0xcb, 0x2e, 0xd3, 0x83, 0x2a, 0x95, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x2b, 0xd6, 0x07, 0xb1, - 0x20, 0xfa, 0x94, 0xbc, 0xb9, 0x58, 0x03, 0x12, 0x33, 0x8b, 0x8a, 0x85, 0x9c, 0xb8, 0x58, 0x0b, + 0x20, 0xfa, 0x94, 0xfc, 0xb9, 0x58, 0x03, 0x12, 0x33, 0x8b, 0x8a, 0x85, 0x9c, 0xb8, 0x58, 0x0b, 0x40, 0x0c, 0x09, 0x46, 0x05, 0x66, 0x0d, 0x6e, 0x23, 0x35, 0x3d, 0x42, 0x06, 0xea, 0x81, 0xf4, - 0x39, 0xb1, 0x9c, 0xb8, 0x27, 0xcf, 0x10, 0x04, 0xd1, 0xaa, 0xa4, 0xc7, 0xc5, 0x02, 0x12, 0x14, - 0x12, 0xe0, 0x62, 0xce, 0x4e, 0xad, 0x94, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x09, 0x02, 0x31, 0x85, - 0x44, 0xb8, 0x58, 0xcb, 0x12, 0x73, 0x4a, 0x53, 0x25, 0x98, 0xc0, 0x62, 0x10, 0x8e, 0x93, 0xc5, - 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, - 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0xc9, 0x41, 0x6c, 0x2f, 0x4e, 0xc9, - 0xd6, 0xcb, 0xcc, 0xc7, 0xf4, 0x7f, 0x12, 0x1b, 0xd8, 0xf5, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, - 0xff, 0x5d, 0xad, 0x97, 0xdd, 0x22, 0x01, 0x00, 0x00, + 0x39, 0xb1, 0x9c, 0xb8, 0x27, 0xcf, 0x10, 0x04, 0xd1, 0x6a, 0xc5, 0x24, 0xc1, 0xa8, 0x64, 0xc4, + 0xc5, 0x02, 0x92, 0x10, 0x12, 0xe0, 0x62, 0xce, 0x4e, 0xad, 0x94, 0x60, 0x54, 0x60, 0xd4, 0xe0, + 0x09, 0x02, 0x31, 0x85, 0x44, 0xb8, 0x58, 0xcb, 0x12, 0x73, 0x4a, 0x53, 0x25, 0x98, 0xc0, 0x62, + 0x10, 0x0e, 0x48, 0x8f, 0x93, 0xc5, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, + 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, + 0xc9, 0x41, 0x5c, 0x51, 0x9c, 0x92, 0xad, 0x97, 0x99, 0x8f, 0x19, 0x0e, 0x49, 0x6c, 0x60, 0x5f, + 0x18, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0xf8, 0x41, 0x82, 0x6e, 0x2a, 0x01, 0x00, 0x00, } func (m *Pairs) Marshal() (dAtA []byte, err error) { diff --git a/tests/integration/auth/keeper/msg_server_test.go b/tests/integration/auth/keeper/msg_server_test.go index 5bb902c08b01..14df4e4df1aa 100644 --- a/tests/integration/auth/keeper/msg_server_test.go +++ b/tests/integration/auth/keeper/msg_server_test.go @@ -78,7 +78,7 @@ func initFixture(t *testing.T) *fixture { queryRouter := baseapp.NewGRPCQueryRouter() handler := directHandler{} - account := baseaccount.NewAccount("base", signing.NewHandlerMap(handler)) + account := baseaccount.NewAccount("base", signing.NewHandlerMap(handler), baseaccount.WithSecp256K1PubKey()) accountsKeeper, err := accounts.NewKeeper( cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[accounts.StoreKey]), log.NewNopLogger(), runtime.EnvWithQueryRouterService(queryRouter), runtime.EnvWithMsgRouterService(router)), diff --git a/x/accounts/defaults/base/account.go b/x/accounts/defaults/base/account.go index 550227599f36..eef6e6c2153e 100644 --- a/x/accounts/defaults/base/account.go +++ b/x/accounts/defaults/base/account.go @@ -5,7 +5,6 @@ import ( "errors" "fmt" - dcrd_secp256k1 "github.com/decred/dcrd/dcrec/secp256k1/v4" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/anypb" @@ -20,42 +19,56 @@ import ( accountsv1 "cosmossdk.io/x/accounts/v1" "cosmossdk.io/x/tx/signing" - "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" - "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/types/tx" ) var ( - PubKeyPrefix = collections.NewPrefix(0) - SequencePrefix = collections.NewPrefix(1) + PubKeyPrefix = collections.NewPrefix(0) + PubKeyTypePrefix = collections.NewPrefix(1) + SequencePrefix = collections.NewPrefix(2) ) -func NewAccount(name string, handlerMap *signing.HandlerMap) accountstd.AccountCreatorFunc { +type Option func(a *Account) + +func NewAccount(name string, handlerMap *signing.HandlerMap, options ...Option) accountstd.AccountCreatorFunc { return func(deps accountstd.Dependencies) (string, accountstd.Interface, error) { - return name, Account{ - PubKey: collections.NewItem(deps.SchemaBuilder, PubKeyPrefix, "pub_key", codec.CollValue[secp256k1.PubKey](deps.LegacyStateCodec)), - Sequence: collections.NewSequence(deps.SchemaBuilder, SequencePrefix, "sequence"), - addrCodec: deps.AddressCodec, - signingHandlers: handlerMap, - hs: deps.Environment.HeaderService, - }, nil + acc := Account{ + PubKey: collections.NewItem(deps.SchemaBuilder, PubKeyPrefix, "pub_key_bytes", collections.BytesValue), + PubKeyType: collections.NewItem(deps.SchemaBuilder, PubKeyTypePrefix, "pub_key_type", collections.StringValue), + Sequence: collections.NewSequence(deps.SchemaBuilder, SequencePrefix, "sequence"), + addrCodec: deps.AddressCodec, + hs: deps.Environment.HeaderService, + supportedPubKeys: map[string]pubKeyImpl{}, + signingHandlers: handlerMap, + } + for _, option := range options { + option(&acc) + } + if len(acc.supportedPubKeys) == 0 { + return "", nil, fmt.Errorf("no public keys plugged for account type %s", name) + } + return name, acc, nil } } // Account implements a base account. type Account struct { - PubKey collections.Item[secp256k1.PubKey] + PubKey collections.Item[[]byte] + PubKeyType collections.Item[string] + Sequence collections.Sequence addrCodec address.Codec hs header.Service + supportedPubKeys map[string]pubKeyImpl + signingHandlers *signing.HandlerMap } func (a Account) Init(ctx context.Context, msg *v1.MsgInit) (*v1.MsgInitResponse, error) { - return &v1.MsgInitResponse{}, a.verifyAndSetPubKey(ctx, msg.PubKey) + return &v1.MsgInitResponse{}, a.savePubKey(ctx, msg.PubKey) } func (a Account) SwapPubKey(ctx context.Context, msg *v1.MsgSwapPubKey) (*v1.MsgSwapPubKeyResponse, error) { @@ -63,15 +76,7 @@ func (a Account) SwapPubKey(ctx context.Context, msg *v1.MsgSwapPubKey) (*v1.Msg return nil, errors.New("unauthorized") } - return &v1.MsgSwapPubKeyResponse{}, a.verifyAndSetPubKey(ctx, msg.NewPubKey) -} - -func (a Account) verifyAndSetPubKey(ctx context.Context, key []byte) error { - _, err := dcrd_secp256k1.ParsePubKey(key) - if err != nil { - return err - } - return a.PubKey.Set(ctx, secp256k1.PubKey{Key: key}) + return &v1.MsgSwapPubKeyResponse{}, a.savePubKey(ctx, msg.NewPubKey) } // Authenticate implements the authentication flow of an abstracted base account. @@ -82,12 +87,12 @@ func (a Account) Authenticate(ctx context.Context, msg *aa_interface_v1.MsgAuthe pubKey, signerData, err := a.computeSignerData(ctx) if err != nil { - return nil, err + return nil, fmt.Errorf("unable to compute signer data: %w", err) } txData, err := a.getTxData(msg) if err != nil { - return nil, err + return nil, fmt.Errorf("unable to get tx data: %w", err) } gotSeq := msg.Tx.AuthInfo.SignerInfos[msg.SignerIndex].Sequence @@ -104,7 +109,7 @@ func (a Account) Authenticate(ctx context.Context, msg *aa_interface_v1.MsgAuthe signBytes, err := a.signingHandlers.GetSignBytes(ctx, signMode, signerData, txData) if err != nil { - return nil, err + return nil, fmt.Errorf("unable to get sign bytes: %w", err) } if !pubKey.VerifySignature(signBytes, signature) { @@ -123,31 +128,31 @@ func parseSignMode(info *tx.ModeInfo) (signingv1beta1.SignMode, error) { } // computeSignerData will populate signer data and also increase the sequence. -func (a Account) computeSignerData(ctx context.Context) (secp256k1.PubKey, signing.SignerData, error) { +func (a Account) computeSignerData(ctx context.Context) (PubKey, signing.SignerData, error) { addrStr, err := a.addrCodec.BytesToString(accountstd.Whoami(ctx)) if err != nil { - return secp256k1.PubKey{}, signing.SignerData{}, err + return nil, signing.SignerData{}, err } chainID := a.hs.HeaderInfo(ctx).ChainID wantSequence, err := a.Sequence.Next(ctx) if err != nil { - return secp256k1.PubKey{}, signing.SignerData{}, err + return nil, signing.SignerData{}, err } - pk, err := a.PubKey.Get(ctx) + pk, err := a.loadPubKey(ctx) if err != nil { - return secp256k1.PubKey{}, signing.SignerData{}, err + return nil, signing.SignerData{}, err } - pkAny, err := codectypes.NewAnyWithValue(&pk) + pkAny, err := codectypes.NewAnyWithValue(pk) if err != nil { - return secp256k1.PubKey{}, signing.SignerData{}, err + return nil, signing.SignerData{}, err } accNum, err := a.getNumber(ctx, addrStr) if err != nil { - return secp256k1.PubKey{}, signing.SignerData{}, err + return nil, signing.SignerData{}, err } return pk, signing.SignerData{ @@ -200,6 +205,54 @@ func (a Account) getTxData(msg *aa_interface_v1.MsgAuthenticate) (signing.TxData }, nil } +func (a Account) loadPubKey(ctx context.Context) (PubKey, error) { + pkType, err := a.PubKeyType.Get(ctx) + if err != nil { + return nil, err + } + + publicKey, exists := a.supportedPubKeys[pkType] + // this means that the chain developer suddenly started using a key type. + if !exists { + return nil, fmt.Errorf("pubkey type %s is not supported by the chain anymore", pkType) + } + + pkBytes, err := a.PubKey.Get(ctx) + if err != nil { + return nil, err + } + + pubKey, err := publicKey.decode(pkBytes) + if err != nil { + return nil, err + } + return pubKey, nil +} + +func (a Account) savePubKey(ctx context.Context, anyPk *codectypes.Any) error { + // check if known + name := nameFromTypeURL(anyPk.TypeUrl) + impl, exists := a.supportedPubKeys[name] + if !exists { + return fmt.Errorf("unknown pubkey type %s", name) + } + pk, err := impl.decode(anyPk.Value) + if err != nil { + return fmt.Errorf("unable to decode pubkey: %w", err) + } + err = impl.validate(pk) + if err != nil { + return fmt.Errorf("unable to validate pubkey: %w", err) + } + + // save into state + err = a.PubKey.Set(ctx, anyPk.Value) + if err != nil { + return fmt.Errorf("unable to save pubkey: %w", err) + } + return a.PubKeyType.Set(ctx, name) +} + func (a Account) QuerySequence(ctx context.Context, _ *v1.QuerySequence) (*v1.QuerySequenceResponse, error) { seq, err := a.Sequence.Peek(ctx) if err != nil { diff --git a/x/accounts/defaults/base/account_test.go b/x/accounts/defaults/base/account_test.go index a895d0f68ecd..8523d47c1f9b 100644 --- a/x/accounts/defaults/base/account_test.go +++ b/x/accounts/defaults/base/account_test.go @@ -5,6 +5,9 @@ import ( "errors" "testing" + gogoproto "github.com/cosmos/gogoproto/proto" + types "github.com/cosmos/gogoproto/types/any" + dcrd_secp256k1 "github.com/decred/dcrd/dcrec/secp256k1/v4" "github.com/stretchr/testify/require" "cosmossdk.io/core/store" @@ -24,7 +27,10 @@ func setupBaseAccount(t *testing.T, ss store.KVStoreService) Account { deps := makeMockDependencies(ss) handler := directHandler{} - createAccFn := NewAccount("base", signing.NewHandlerMap(handler)) + createAccFn := NewAccount("base", signing.NewHandlerMap(handler), WithPubKeyWithValidationFunc(func(pt *secp256k1.PubKey) error { + _, err := dcrd_secp256k1.ParsePubKey(pt.Key) + return err + })) _, acc, err := createAccFn(deps) baseAcc := acc.(Account) require.NoError(t, err) @@ -36,7 +42,7 @@ func TestInit(t *testing.T) { ctx, ss := newMockContext(t) baseAcc := setupBaseAccount(t, ss) _, err := baseAcc.Init(ctx, &v1.MsgInit{ - PubKey: secp256k1.GenPrivKey().PubKey().Bytes(), + PubKey: toAnyPb(t, secp256k1.GenPrivKey().PubKey()), }) require.NoError(t, err) @@ -48,14 +54,14 @@ func TestInit(t *testing.T) { { "valid init", &v1.MsgInit{ - PubKey: secp256k1.GenPrivKey().PubKey().Bytes(), + PubKey: toAnyPb(t, secp256k1.GenPrivKey().PubKey()), }, false, }, { "invalid pubkey", &v1.MsgInit{ - PubKey: []byte("invalid_pk"), + PubKey: toAnyPb(t, &secp256k1.PubKey{Key: []byte("invalid")}), }, true, }, @@ -77,7 +83,7 @@ func TestSwapKey(t *testing.T) { ctx, ss := newMockContext(t) baseAcc := setupBaseAccount(t, ss) _, err := baseAcc.Init(ctx, &v1.MsgInit{ - PubKey: secp256k1.GenPrivKey().PubKey().Bytes(), + PubKey: toAnyPb(t, secp256k1.GenPrivKey().PubKey()), }) require.NoError(t, err) @@ -94,7 +100,7 @@ func TestSwapKey(t *testing.T) { return accountstd.SetSender(ctx, []byte("mock_base_account")) }, &v1.MsgSwapPubKey{ - NewPubKey: secp256k1.GenPrivKey().PubKey().Bytes(), + NewPubKey: toAnyPb(t, secp256k1.GenPrivKey().PubKey()), }, false, nil, @@ -105,7 +111,7 @@ func TestSwapKey(t *testing.T) { return accountstd.SetSender(ctx, []byte("sender")) }, &v1.MsgSwapPubKey{ - NewPubKey: secp256k1.GenPrivKey().PubKey().Bytes(), + NewPubKey: toAnyPb(t, secp256k1.GenPrivKey().PubKey()), }, true, errors.New("unauthorized"), @@ -116,7 +122,7 @@ func TestSwapKey(t *testing.T) { return accountstd.SetSender(ctx, []byte("mock_base_account")) }, &v1.MsgSwapPubKey{ - NewPubKey: []byte("invalid_pk"), + NewPubKey: toAnyPb(t, &secp256k1.PubKey{Key: []byte("invalid")}), }, true, nil, @@ -149,7 +155,7 @@ func TestAuthenticate(t *testing.T) { pkAny, err := codectypes.NewAnyWithValue(privKey.PubKey()) require.NoError(t, err) _, err = baseAcc.Init(ctx, &v1.MsgInit{ - PubKey: privKey.PubKey().Bytes(), + PubKey: toAnyPb(t, privKey.PubKey()), }) require.NoError(t, err) @@ -251,3 +257,13 @@ func TestAuthenticate(t *testing.T) { }) require.Equal(t, errors.New("signature verification failed"), err) } + +func toAnyPb(t *testing.T, pm gogoproto.Message) *codectypes.Any { + t.Helper() + if gogoproto.MessageName(pm) == gogoproto.MessageName(&types.Any{}) { + t.Fatal("no") + } + pb, err := codectypes.NewAnyWithValue(pm) + require.NoError(t, err) + return pb +} diff --git a/x/accounts/defaults/base/pubkey.go b/x/accounts/defaults/base/pubkey.go new file mode 100644 index 000000000000..874d53ea6a7f --- /dev/null +++ b/x/accounts/defaults/base/pubkey.go @@ -0,0 +1,75 @@ +package base + +import ( + "fmt" + "strings" + + gogoproto "github.com/cosmos/gogoproto/proto" + dcrd_secp256k1 "github.com/decred/dcrd/dcrec/secp256k1/v4" + + "cosmossdk.io/core/transaction" + + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" +) + +// this file implements a general mechanism to plugin public keys to a baseaccount + +// PubKey defines a generic pubkey. +type PubKey interface { + transaction.Msg + VerifySignature(msg, sig []byte) bool +} + +type PubKeyG[T any] interface { + *T + PubKey +} + +type pubKeyImpl struct { + decode func(b []byte) (PubKey, error) + validate func(key PubKey) error +} + +func WithSecp256K1PubKey() Option { + return WithPubKeyWithValidationFunc(func(pt *secp256k1.PubKey) error { + _, err := dcrd_secp256k1.ParsePubKey(pt.Key) + return err + }) +} + +func WithPubKey[T any, PT PubKeyG[T]]() Option { + return WithPubKeyWithValidationFunc[T, PT](func(_ PT) error { + return nil + }) +} + +func WithPubKeyWithValidationFunc[T any, PT PubKeyG[T]](validateFn func(PT) error) Option { + pkImpl := pubKeyImpl{ + decode: func(b []byte) (PubKey, error) { + key := PT(new(T)) + err := gogoproto.Unmarshal(b, key) + if err != nil { + return nil, err + } + return key, nil + }, + validate: func(k PubKey) error { + concrete, ok := k.(PT) + if !ok { + return fmt.Errorf("invalid pubkey type passed for validation, wanted: %T, got: %T", concrete, k) + } + return validateFn(concrete) + }, + } + return func(a *Account) { + a.supportedPubKeys[gogoproto.MessageName(PT(new(T)))] = pkImpl + } +} + +func nameFromTypeURL(url string) string { + name := url + if i := strings.LastIndexByte(url, '/'); i >= 0 { + name = name[i+len("/"):] + } + return name +} diff --git a/x/accounts/defaults/base/v1/base.pb.go b/x/accounts/defaults/base/v1/base.pb.go index 4affa55d7009..cc9078c736e1 100644 --- a/x/accounts/defaults/base/v1/base.pb.go +++ b/x/accounts/defaults/base/v1/base.pb.go @@ -6,6 +6,7 @@ package v1 import ( fmt "fmt" proto "github.com/cosmos/gogoproto/proto" + any "github.com/cosmos/gogoproto/types/any" io "io" math "math" math_bits "math/bits" @@ -24,8 +25,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // MsgInit is used to initialize a base account. type MsgInit struct { - // pub_key defines the secp256k1 pubkey for the account. - PubKey []byte `protobuf:"bytes,1,opt,name=pub_key,json=pubKey,proto3" json:"pub_key,omitempty"` + // pub_key defines a pubkey for the account arbitrary encapsulated. + PubKey *any.Any `protobuf:"bytes,1,opt,name=pub_key,json=pubKey,proto3" json:"pub_key,omitempty"` } func (m *MsgInit) Reset() { *m = MsgInit{} } @@ -61,7 +62,7 @@ func (m *MsgInit) XXX_DiscardUnknown() { var xxx_messageInfo_MsgInit proto.InternalMessageInfo -func (m *MsgInit) GetPubKey() []byte { +func (m *MsgInit) GetPubKey() *any.Any { if m != nil { return m.PubKey } @@ -109,7 +110,7 @@ var xxx_messageInfo_MsgInitResponse proto.InternalMessageInfo // MsgSwapPubKey is used to change the pubkey for the account. type MsgSwapPubKey struct { // new_pub_key defines the secp256k1 pubkey to swap the account to. - NewPubKey []byte `protobuf:"bytes,1,opt,name=new_pub_key,json=newPubKey,proto3" json:"new_pub_key,omitempty"` + NewPubKey *any.Any `protobuf:"bytes,1,opt,name=new_pub_key,json=newPubKey,proto3" json:"new_pub_key,omitempty"` } func (m *MsgSwapPubKey) Reset() { *m = MsgSwapPubKey{} } @@ -145,7 +146,7 @@ func (m *MsgSwapPubKey) XXX_DiscardUnknown() { var xxx_messageInfo_MsgSwapPubKey proto.InternalMessageInfo -func (m *MsgSwapPubKey) GetNewPubKey() []byte { +func (m *MsgSwapPubKey) GetNewPubKey() *any.Any { if m != nil { return m.NewPubKey } @@ -273,6 +274,88 @@ func (m *QuerySequenceResponse) GetSequence() uint64 { return 0 } +// QueryPubKey is the request used to query the pubkey of an account. +type QueryPubKey struct { +} + +func (m *QueryPubKey) Reset() { *m = QueryPubKey{} } +func (m *QueryPubKey) String() string { return proto.CompactTextString(m) } +func (*QueryPubKey) ProtoMessage() {} +func (*QueryPubKey) Descriptor() ([]byte, []int) { + return fileDescriptor_7c860870b5ed6dc2, []int{6} +} +func (m *QueryPubKey) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryPubKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPubKey.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 *QueryPubKey) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPubKey.Merge(m, src) +} +func (m *QueryPubKey) XXX_Size() int { + return m.Size() +} +func (m *QueryPubKey) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPubKey.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryPubKey proto.InternalMessageInfo + +// QueryPubKeyResponse is the response returned when a QueryPubKey message is sent. +type QueryPubKeyResponse struct { + PubKey *any.Any `protobuf:"bytes,1,opt,name=pub_key,json=pubKey,proto3" json:"pub_key,omitempty"` +} + +func (m *QueryPubKeyResponse) Reset() { *m = QueryPubKeyResponse{} } +func (m *QueryPubKeyResponse) String() string { return proto.CompactTextString(m) } +func (*QueryPubKeyResponse) ProtoMessage() {} +func (*QueryPubKeyResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_7c860870b5ed6dc2, []int{7} +} +func (m *QueryPubKeyResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryPubKeyResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPubKeyResponse.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 *QueryPubKeyResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPubKeyResponse.Merge(m, src) +} +func (m *QueryPubKeyResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryPubKeyResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPubKeyResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryPubKeyResponse proto.InternalMessageInfo + +func (m *QueryPubKeyResponse) GetPubKey() *any.Any { + if m != nil { + return m.PubKey + } + return nil +} + func init() { proto.RegisterType((*MsgInit)(nil), "cosmos.accounts.defaults.base.v1.MsgInit") proto.RegisterType((*MsgInitResponse)(nil), "cosmos.accounts.defaults.base.v1.MsgInitResponse") @@ -280,6 +363,8 @@ func init() { proto.RegisterType((*MsgSwapPubKeyResponse)(nil), "cosmos.accounts.defaults.base.v1.MsgSwapPubKeyResponse") proto.RegisterType((*QuerySequence)(nil), "cosmos.accounts.defaults.base.v1.QuerySequence") proto.RegisterType((*QuerySequenceResponse)(nil), "cosmos.accounts.defaults.base.v1.QuerySequenceResponse") + proto.RegisterType((*QueryPubKey)(nil), "cosmos.accounts.defaults.base.v1.QueryPubKey") + proto.RegisterType((*QueryPubKeyResponse)(nil), "cosmos.accounts.defaults.base.v1.QueryPubKeyResponse") } func init() { @@ -287,23 +372,26 @@ func init() { } var fileDescriptor_7c860870b5ed6dc2 = []byte{ - // 254 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x4e, 0xce, 0x2f, 0xce, - 0xcd, 0x2f, 0xd6, 0x4f, 0x4c, 0x4e, 0xce, 0x2f, 0xcd, 0x2b, 0x29, 0xd6, 0x4f, 0x49, 0x4d, 0x4b, - 0x2c, 0xcd, 0x29, 0x29, 0xd6, 0x4f, 0x4a, 0x2c, 0x4e, 0xd5, 0x2f, 0x33, 0x04, 0xd3, 0x7a, 0x05, - 0x45, 0xf9, 0x25, 0xf9, 0x42, 0x0a, 0x10, 0xc5, 0x7a, 0x30, 0xc5, 0x7a, 0x30, 0xc5, 0x7a, 0x60, - 0x45, 0x65, 0x86, 0x4a, 0x4a, 0x5c, 0xec, 0xbe, 0xc5, 0xe9, 0x9e, 0x79, 0x99, 0x25, 0x42, 0xe2, - 0x5c, 0xec, 0x05, 0xa5, 0x49, 0xf1, 0xd9, 0xa9, 0x95, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x3c, 0x41, - 0x6c, 0x05, 0xa5, 0x49, 0xde, 0xa9, 0x95, 0x4a, 0x82, 0x5c, 0xfc, 0x50, 0x35, 0x41, 0xa9, 0xc5, - 0x05, 0xf9, 0x79, 0xc5, 0xa9, 0x4a, 0xfa, 0x5c, 0xbc, 0xbe, 0xc5, 0xe9, 0xc1, 0xe5, 0x89, 0x05, - 0x01, 0x60, 0x35, 0x42, 0x72, 0x5c, 0xdc, 0x79, 0xa9, 0xe5, 0xf1, 0xa8, 0x06, 0x70, 0xe6, 0xa5, - 0x96, 0x43, 0xe4, 0x95, 0xc4, 0xb9, 0x44, 0x51, 0x34, 0xc0, 0x4d, 0xe2, 0xe7, 0xe2, 0x0d, 0x2c, - 0x4d, 0x2d, 0xaa, 0x0c, 0x4e, 0x2d, 0x2c, 0x4d, 0xcd, 0x4b, 0x4e, 0x55, 0x32, 0xe6, 0x12, 0x45, - 0x11, 0x80, 0xa9, 0x14, 0x92, 0xe2, 0xe2, 0x28, 0x86, 0x8a, 0x81, 0xcd, 0x67, 0x09, 0x82, 0xf3, - 0x9d, 0x9c, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, - 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0x4a, 0x03, 0x12, 0x04, - 0xc5, 0x29, 0xd9, 0x7a, 0x99, 0xf9, 0xfa, 0x15, 0xb8, 0xc3, 0x2d, 0x89, 0x0d, 0x1c, 0x66, 0xc6, - 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x99, 0x31, 0x20, 0x4a, 0x62, 0x01, 0x00, 0x00, + // 303 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x91, 0xcf, 0x4a, 0xc3, 0x40, + 0x10, 0xc6, 0x1b, 0x90, 0x56, 0xa7, 0x94, 0x62, 0xb4, 0xa8, 0x3d, 0x2c, 0x65, 0x4f, 0x05, 0x71, + 0x97, 0x5a, 0x0f, 0x5e, 0x2d, 0x7a, 0x10, 0x29, 0x68, 0x7a, 0xf3, 0x52, 0x92, 0x74, 0x1a, 0x4a, + 0xeb, 0x6e, 0xec, 0x66, 0x1b, 0xf3, 0x16, 0x3e, 0x96, 0xc7, 0x1e, 0x3d, 0x4a, 0xf2, 0x22, 0xc2, + 0xe6, 0x0f, 0xf6, 0x20, 0xe8, 0x69, 0x99, 0xe1, 0xf7, 0xfb, 0x06, 0xf6, 0x83, 0x73, 0x5f, 0xaa, + 0x17, 0xa9, 0xb8, 0xeb, 0xfb, 0x52, 0x8b, 0x48, 0xf1, 0x19, 0xce, 0x5d, 0xbd, 0x8a, 0x14, 0xf7, + 0x5c, 0x85, 0x7c, 0x33, 0x30, 0x2f, 0x0b, 0xd7, 0x32, 0x92, 0x76, 0x2f, 0x87, 0x59, 0x09, 0xb3, + 0x12, 0x66, 0x06, 0xda, 0x0c, 0xba, 0x67, 0x81, 0x94, 0xc1, 0x0a, 0xb9, 0xe1, 0x3d, 0x3d, 0xe7, + 0xae, 0x48, 0x72, 0x99, 0x5e, 0x43, 0x63, 0xac, 0x82, 0x7b, 0xb1, 0x88, 0xec, 0x0b, 0x68, 0x84, + 0xda, 0x9b, 0x2e, 0x31, 0x39, 0xb5, 0x7a, 0x56, 0xbf, 0x79, 0x79, 0xcc, 0x72, 0x8f, 0x95, 0x1e, + 0xbb, 0x11, 0x89, 0x53, 0x0f, 0xb5, 0xf7, 0x80, 0x09, 0x3d, 0x84, 0x76, 0x61, 0x3a, 0xa8, 0x42, + 0x29, 0x14, 0xd2, 0x3b, 0x68, 0x8d, 0x55, 0x30, 0x89, 0xdd, 0xf0, 0xd1, 0x30, 0xf6, 0x15, 0x34, + 0x05, 0xc6, 0xd3, 0xbf, 0xc4, 0x1e, 0x08, 0x8c, 0x73, 0x8b, 0x9e, 0x40, 0x67, 0x27, 0xa6, 0xca, + 0x6f, 0x43, 0xeb, 0x49, 0xe3, 0x3a, 0x99, 0xe0, 0xab, 0x46, 0xe1, 0x23, 0x1d, 0x42, 0x67, 0x67, + 0x51, 0x92, 0x76, 0x17, 0xf6, 0x55, 0xb1, 0x33, 0x57, 0xf7, 0x9c, 0x6a, 0xa6, 0x2d, 0x68, 0x1a, + 0xa9, 0xb8, 0x76, 0x0b, 0x47, 0x3f, 0xc6, 0x2a, 0xe1, 0x7f, 0xbf, 0x31, 0x1a, 0x7d, 0xa4, 0xc4, + 0xda, 0xa6, 0xc4, 0xfa, 0x4a, 0x89, 0xf5, 0x9e, 0x91, 0xda, 0x36, 0x23, 0xb5, 0xcf, 0x8c, 0xd4, + 0x9e, 0xfb, 0x79, 0x3d, 0x6a, 0xb6, 0x64, 0x0b, 0xc9, 0xdf, 0x7e, 0xef, 0xd4, 0xab, 0x9b, 0xe4, + 0xe1, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0x8f, 0xe1, 0xb2, 0xd8, 0xfe, 0x01, 0x00, 0x00, } func (m *MsgInit) Marshal() (dAtA []byte, err error) { @@ -326,10 +414,15 @@ func (m *MsgInit) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.PubKey) > 0 { - i -= len(m.PubKey) - copy(dAtA[i:], m.PubKey) - i = encodeVarintBase(dAtA, i, uint64(len(m.PubKey))) + if m.PubKey != nil { + { + size, err := m.PubKey.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintBase(dAtA, i, uint64(size)) + } i-- dAtA[i] = 0xa } @@ -379,10 +472,15 @@ func (m *MsgSwapPubKey) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.NewPubKey) > 0 { - i -= len(m.NewPubKey) - copy(dAtA[i:], m.NewPubKey) - i = encodeVarintBase(dAtA, i, uint64(len(m.NewPubKey))) + if m.NewPubKey != nil { + { + size, err := m.NewPubKey.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintBase(dAtA, i, uint64(size)) + } i-- dAtA[i] = 0xa } @@ -463,6 +561,64 @@ func (m *QuerySequenceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *QueryPubKey) 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 *QueryPubKey) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryPubKey) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryPubKeyResponse) 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 *QueryPubKeyResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryPubKeyResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.PubKey != nil { + { + size, err := m.PubKey.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintBase(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintBase(dAtA []byte, offset int, v uint64) int { offset -= sovBase(v) base := offset @@ -480,8 +636,8 @@ func (m *MsgInit) Size() (n int) { } var l int _ = l - l = len(m.PubKey) - if l > 0 { + if m.PubKey != nil { + l = m.PubKey.Size() n += 1 + l + sovBase(uint64(l)) } return n @@ -502,8 +658,8 @@ func (m *MsgSwapPubKey) Size() (n int) { } var l int _ = l - l = len(m.NewPubKey) - if l > 0 { + if m.NewPubKey != nil { + l = m.NewPubKey.Size() n += 1 + l + sovBase(uint64(l)) } return n @@ -539,6 +695,28 @@ func (m *QuerySequenceResponse) Size() (n int) { return n } +func (m *QueryPubKey) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryPubKeyResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PubKey != nil { + l = m.PubKey.Size() + n += 1 + l + sovBase(uint64(l)) + } + return n +} + func sovBase(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -578,7 +756,7 @@ func (m *MsgInit) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field PubKey", wireType) } - var byteLen int + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowBase @@ -588,24 +766,26 @@ func (m *MsgInit) 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 ErrInvalidLengthBase } - postIndex := iNdEx + byteLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthBase } if postIndex > l { return io.ErrUnexpectedEOF } - m.PubKey = append(m.PubKey[:0], dAtA[iNdEx:postIndex]...) if m.PubKey == nil { - m.PubKey = []byte{} + m.PubKey = &any.Any{} + } + if err := m.PubKey.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex default: @@ -712,7 +892,7 @@ func (m *MsgSwapPubKey) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field NewPubKey", wireType) } - var byteLen int + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowBase @@ -722,24 +902,26 @@ func (m *MsgSwapPubKey) 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 ErrInvalidLengthBase } - postIndex := iNdEx + byteLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthBase } if postIndex > l { return io.ErrUnexpectedEOF } - m.NewPubKey = append(m.NewPubKey[:0], dAtA[iNdEx:postIndex]...) if m.NewPubKey == nil { - m.NewPubKey = []byte{} + m.NewPubKey = &any.Any{} + } + if err := m.NewPubKey.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex default: @@ -932,6 +1114,142 @@ func (m *QuerySequenceResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryPubKey) 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 ErrIntOverflowBase + } + 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: QueryPubKey: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPubKey: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipBase(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthBase + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryPubKeyResponse) 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 ErrIntOverflowBase + } + 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: QueryPubKeyResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPubKeyResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PubKey", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBase + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthBase + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthBase + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.PubKey == nil { + m.PubKey = &any.Any{} + } + if err := m.PubKey.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipBase(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthBase + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipBase(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/accounts/depinject.go b/x/accounts/depinject.go index 04a45c533453..1110a0525a20 100644 --- a/x/accounts/depinject.go +++ b/x/accounts/depinject.go @@ -64,7 +64,7 @@ func (s directHandler) GetSignBytes(_ context.Context, _ signing.SignerData, _ s func ProvideModule(in ModuleInputs) ModuleOutputs { handler := directHandler{} - account := baseaccount.NewAccount("base", signing.NewHandlerMap(handler)) + account := baseaccount.NewAccount("base", signing.NewHandlerMap(handler), baseaccount.WithSecp256K1PubKey()) accountskeeper, err := NewKeeper( in.Cdc, in.Environment, in.AddressCodec, in.Registry, account, accountstd.AddAccount(lockup.CONTINUOUS_LOCKING_ACCOUNT, lockup.NewContinuousLockingAccount), diff --git a/x/accounts/proto/cosmos/accounts/defaults/base/v1/base.proto b/x/accounts/proto/cosmos/accounts/defaults/base/v1/base.proto index 0919c62bbd13..1df7f92b501d 100644 --- a/x/accounts/proto/cosmos/accounts/defaults/base/v1/base.proto +++ b/x/accounts/proto/cosmos/accounts/defaults/base/v1/base.proto @@ -4,10 +4,12 @@ package cosmos.accounts.defaults.base.v1; option go_package = "cosmossdk.io/x/accounts/defaults/base/v1"; +import "google/protobuf/any.proto"; + // MsgInit is used to initialize a base account. message MsgInit { - // pub_key defines the secp256k1 pubkey for the account. - bytes pub_key = 1; + // pub_key defines a pubkey for the account arbitrary encapsulated. + google.protobuf.Any pub_key = 1; } // MsgInitResponse is the response returned after base account initialization. @@ -17,7 +19,7 @@ message MsgInitResponse {} // MsgSwapPubKey is used to change the pubkey for the account. message MsgSwapPubKey { // new_pub_key defines the secp256k1 pubkey to swap the account to. - bytes new_pub_key = 1; + google.protobuf.Any new_pub_key = 1; } // MsgSwapPubKeyResponse is the response for the MsgSwapPubKey message. @@ -32,3 +34,11 @@ message QuerySequenceResponse { // sequence is the current sequence of the account. uint64 sequence = 1; } + +// QueryPubKey is the request used to query the pubkey of an account. +message QueryPubKey {} + +// QueryPubKeyResponse is the response returned when a QueryPubKey message is sent. +message QueryPubKeyResponse { + google.protobuf.Any pub_key = 1; +} \ No newline at end of file